Fix scandir() callback signatures

This commit is contained in:
2025-12-14 11:48:35 +01:00
parent f7567c5512
commit a67eeb9fd2
4 changed files with 34 additions and 26 deletions

View File

@@ -103,8 +103,10 @@ long mh_copy (MAILSTREAM *stream,char *sequence,char *mailbox,
long options); long options);
long mh_append (MAILSTREAM *stream,char *mailbox,append_t af,void *data); long mh_append (MAILSTREAM *stream,char *mailbox,append_t af,void *data);
int mh_select (struct direct *name); #include <dirent.h>
int mh_numsort (const void *d1,const void *d2);
int mh_select (const struct dirent *name);
int mh_numsort (const struct dirent **d1, const struct dirent **d2);
char *mh_file (char *dst,char *name); char *mh_file (char *dst,char *name);
long mh_canonicalize (char *pattern,char *ref,char *pat); long mh_canonicalize (char *pattern,char *ref,char *pat);
void mh_setdate (char *file,MESSAGECACHE *elt); void mh_setdate (char *file,MESSAGECACHE *elt);
@@ -1194,7 +1196,7 @@ long mh_append (MAILSTREAM *stream,char *mailbox,append_t af,void *data)
* Returns: T to use file name, NIL to skip it * Returns: T to use file name, NIL to skip it
*/ */
int mh_select (struct direct *name) int mh_select (const struct dirent *name)
{ {
char c; char c;
char *s = name->d_name; char *s = name->d_name;
@@ -1209,7 +1211,7 @@ int mh_select (struct direct *name)
* Returns: negative if d1 < d2, 0 if d1 == d2, postive if d1 > d2 * Returns: negative if d1 < d2, 0 if d1 == d2, postive if d1 > d2
*/ */
int mh_numsort (const void *d1,const void *d2) int mh_numsort (const struct dirent **d1, const struct dirent **d2)
{ {
return atoi ((*(struct direct **) d1)->d_name) - return atoi ((*(struct direct **) d1)->d_name) -
atoi ((*(struct direct **) d2)->d_name); atoi ((*(struct direct **) d2)->d_name);
@@ -1279,5 +1281,5 @@ void mh_setdate (char *file,MESSAGECACHE *elt)
time_t tp[2]; time_t tp[2];
tp[0] = time (0); /* atime is now */ tp[0] = time (0); /* atime is now */
tp[1] = mail_longdate (elt); /* modification time */ tp[1] = mail_longdate (elt); /* modification time */
utime (file,tp); /* set the times */ set_utime_from_tp(file,tp); /* set the times */
} }

View File

@@ -125,7 +125,7 @@ long mix_unsubscribe (MAILSTREAM *stream,char *mailbox);
long mix_create (MAILSTREAM *stream,char *mailbox); long mix_create (MAILSTREAM *stream,char *mailbox);
long mix_delete (MAILSTREAM *stream,char *mailbox); long mix_delete (MAILSTREAM *stream,char *mailbox);
long mix_rename (MAILSTREAM *stream,char *old,char *newname); long mix_rename (MAILSTREAM *stream,char *old,char *newname);
int mix_rselect (struct direct *name); int mix_rselect (const struct dirent *name);
MAILSTREAM *mix_open (MAILSTREAM *stream); MAILSTREAM *mix_open (MAILSTREAM *stream);
void mix_close (MAILSTREAM *stream,long options); void mix_close (MAILSTREAM *stream,long options);
void mix_abort (MAILSTREAM *stream); void mix_abort (MAILSTREAM *stream);
@@ -140,8 +140,8 @@ THREADNODE *mix_thread (MAILSTREAM *stream,char *type,char *charset,
long mix_ping (MAILSTREAM *stream); long mix_ping (MAILSTREAM *stream);
void mix_check (MAILSTREAM *stream); void mix_check (MAILSTREAM *stream);
long mix_expunge (MAILSTREAM *stream,char *sequence,long options); long mix_expunge (MAILSTREAM *stream,char *sequence,long options);
int mix_select (struct direct *name); int mix_select (const struct dirent *name);
int mix_msgfsort (const void *d1,const void *d2); int mix_msgfsort (const struct dirent **d1, const struct dirent **d2);
long mix_addset (SEARCHSET **set,unsigned long start,unsigned long size); long mix_addset (SEARCHSET **set,unsigned long start,unsigned long size);
long mix_burp (MAILSTREAM *stream,MIXBURP *burp,unsigned long *reclaimed); long mix_burp (MAILSTREAM *stream,MIXBURP *burp,unsigned long *reclaimed);
long mix_burp_check (SEARCHSET *set,size_t size,char *file); long mix_burp_check (SEARCHSET *set,size_t size,char *file);
@@ -587,7 +587,7 @@ long mix_rename (MAILSTREAM *stream,char *old,char *newname)
* Returns: T if mix file name, NIL otherwise * Returns: T if mix file name, NIL otherwise
*/ */
int mix_rselect (struct direct *name) int mix_rselect (const struct dirent *name)
{ {
return mix_dirfmttest (name->d_name); return mix_dirfmttest (name->d_name);
} }
@@ -1146,7 +1146,7 @@ long mix_expunge (MAILSTREAM *stream,char *sequence,long options)
* ".mix" with no suffix was used by experimental versions * ".mix" with no suffix was used by experimental versions
*/ */
int mix_select (struct direct *name) int mix_select (const struct dirent *name)
{ {
char c,*s; char c,*s;
/* make sure name has prefix */ /* make sure name has prefix */
@@ -1165,15 +1165,16 @@ int mix_select (struct direct *name)
* Returns: -1 if d1 < d2, 0 if d1 == d2, 1 d1 > d2 * Returns: -1 if d1 < d2, 0 if d1 == d2, 1 d1 > d2
*/ */
int mix_msgfsort (const void *d1,const void *d2) int mix_msgfsort (const struct dirent **d1, const struct dirent **d2)
{ {
char *n1 = (*(struct direct **) d1)->d_name + sizeof (MIXNAME) - 1; const char *n1 = (*d1)->d_name + sizeof (MIXNAME) - 1;
char *n2 = (*(struct direct **) d2)->d_name + sizeof (MIXNAME) - 1; const char *n2 = (*d2)->d_name + sizeof (MIXNAME) - 1;
return compare_ulong (*n1 ? strtoul (n1, NIL, 16) : 0, return compare_ulong (*n1 ? strtoul (n1, NIL, 16) : 0,
*n2 ? strtoul (n2, NIL, 16) : 0); *n2 ? strtoul (n2, NIL, 16) : 0);
} }
/* MIX add a range to a set /* MIX add a range to a set
* Accepts: pointer to set to add * Accepts: pointer to set to add
* start of set * start of set

View File

@@ -98,8 +98,8 @@ long mx_append (MAILSTREAM *stream,char *mailbox,append_t af,void *data);
long mx_append_msg (MAILSTREAM *stream,char *flags,MESSAGECACHE *elt, long mx_append_msg (MAILSTREAM *stream,char *flags,MESSAGECACHE *elt,
STRING *st,SEARCHSET *set); STRING *st,SEARCHSET *set);
int mx_select (struct direct *name); int mx_select (const struct dirent *name);
int mx_numsort (const void *d1,const void *d2); int mx_numsort (const struct dirent **d1, const struct dirent **d2);
char *mx_file (char *dst,char *name); char *mx_file (char *dst,char *name);
long mx_lockindex (MAILSTREAM *stream); long mx_lockindex (MAILSTREAM *stream);
void mx_unlockindex (MAILSTREAM *stream); void mx_unlockindex (MAILSTREAM *stream);
@@ -1110,7 +1110,7 @@ long mx_append_msg (MAILSTREAM *stream,char *flags,MESSAGECACHE *elt,
* Returns: T to use file name, NIL to skip it * Returns: T to use file name, NIL to skip it
*/ */
int mx_select (struct direct *name) int mx_select (const struct dirent *name)
{ {
char c; char c;
char *s = name->d_name; char *s = name->d_name;
@@ -1125,10 +1125,9 @@ int mx_select (struct direct *name)
* Returns: negative if d1 < d2, 0 if d1 == d2, postive if d1 > d2 * Returns: negative if d1 < d2, 0 if d1 == d2, postive if d1 > d2
*/ */
int mx_numsort (const void *d1,const void *d2) int mx_numsort (const struct dirent **d1, const struct dirent **d2)
{ {
return atoi ((*(struct direct **) d1)->d_name) - return atoi ((*d1)->d_name) - atoi ((*d2)->d_name);
atoi ((*(struct direct **) d2)->d_name);
} }
@@ -1283,5 +1282,5 @@ void mx_setdate (char *file,MESSAGECACHE *elt)
time_t tp[2]; time_t tp[2];
tp[0] = time (0); /* atime is now */ tp[0] = time (0); /* atime is now */
tp[1] = mail_longdate (elt); /* modification time */ tp[1] = mail_longdate (elt); /* modification time */
utime (file,tp); /* set the times */ set_utime_from_tp(file,tp); /* set the times */
} }

View File

@@ -76,8 +76,12 @@ long news_create (MAILSTREAM *stream,char *mailbox);
long news_delete (MAILSTREAM *stream,char *mailbox); long news_delete (MAILSTREAM *stream,char *mailbox);
long news_rename (MAILSTREAM *stream,char *old,char *newname); long news_rename (MAILSTREAM *stream,char *old,char *newname);
MAILSTREAM *news_open (MAILSTREAM *stream); MAILSTREAM *news_open (MAILSTREAM *stream);
int news_select (struct direct *name);
int news_numsort (const void *d1,const void *d2); #include <dirent.h> /* falls nicht schon drin */
int news_select (const struct dirent *name);
int news_numsort (const struct dirent **d1, const struct dirent **d2);
void news_close (MAILSTREAM *stream,long options); void news_close (MAILSTREAM *stream,long options);
void news_fast (MAILSTREAM *stream,char *sequence,long flags); void news_fast (MAILSTREAM *stream,char *sequence,long flags);
void news_flags (MAILSTREAM *stream,char *sequence,long flags); void news_flags (MAILSTREAM *stream,char *sequence,long flags);
@@ -402,7 +406,8 @@ MAILSTREAM *news_open (MAILSTREAM *stream)
* Returns: T to use file name, NIL to skip it * Returns: T to use file name, NIL to skip it
*/ */
int news_select (struct direct *name) int news_select (const struct dirent *name)
{ {
char c; char c;
char *s = name->d_name; char *s = name->d_name;
@@ -417,7 +422,8 @@ int news_select (struct direct *name)
* Returns: negative if d1 < d2, 0 if d1 == d2, postive if d1 > d2 * Returns: negative if d1 < d2, 0 if d1 == d2, postive if d1 > d2
*/ */
int news_numsort (const void *d1,const void *d2) int news_numsort (const struct dirent **d1, const struct dirent **d2)
{ {
return atoi ((*(struct direct **) d1)->d_name) - return atoi ((*(struct direct **) d1)->d_name) -
atoi ((*(struct direct **) d2)->d_name); atoi ((*(struct direct **) d2)->d_name);