Compare commits

..

2 Commits

Author SHA1 Message Date
844dc84974
Ignore backup files. 2023-03-07 16:54:41 +01:00
ee2489483b
Code cleanup and indentation.
C source files (with the exception of third-party files, i.e. getopt and
md5) have been indented with GNU indent.

The indentation "standard" has been documented in the readme file.
2023-03-07 16:51:33 +01:00
20 changed files with 676 additions and 594 deletions

2
.gitignore vendored
View File

@ -3,4 +3,6 @@ config.h
config.log config.log
config.status config.status
src/*.o src/*.o
src/*.c~
src/*.h~
src/mboxgrep src/mboxgrep

View File

@ -13,3 +13,6 @@ GNU/Linux distrubution, for example), please drop me a line about it.
For build instructions, read the file "INSTALL", and run For build instructions, read the file "INSTALL", and run
`./configure --help`. `./configure --help`.
This project aims to follow the GNU coding style (https://www.gnu.org/prep/standards/html_node/Formatting.html),
at least loosely. The code should be indented with indent -gnu -nut -ppi2.

View File

@ -36,7 +36,8 @@ print_wrap (char *str, int len, int *n)
fprintf (stdout, "\n"); fprintf (stdout, "\n");
*n = 0; *n = 0;
} }
else fprintf (stdout, " "); else
fprintf (stdout, " ");
} }
void void
@ -66,7 +67,8 @@ version (void)
#else #else
# ifdef HAVE_FTW # ifdef HAVE_FTW
print_wrap ("HAVE_FTW", 8, &n); print_wrap ("HAVE_FTW", 8, &n);
# endif /* HAVE_FTW */ # endif
/* HAVE_FTW */
#endif /* HAVE_FTS_OPEN */ #endif /* HAVE_FTS_OPEN */
/* /*
fprintf (stdout, "HAVE_LIBLOCKFILE "); fprintf (stdout, "HAVE_LIBLOCKFILE ");

View File

@ -30,13 +30,16 @@
# define NAMLEN(dirent) (dirent)->d_namlen # define NAMLEN(dirent) (dirent)->d_namlen
# ifdef HAVE_SYS_NDIR_H # ifdef HAVE_SYS_NDIR_H
# include <sys/ndir.h> # include <sys/ndir.h>
# endif /* HAVE_SYS_NDIR_H */ # endif
/* HAVE_SYS_NDIR_H */
# ifdef HAVE_SYS_DIR_H # ifdef HAVE_SYS_DIR_H
# include <sys/dir.h> # include <sys/dir.h>
# endif /* HAVE_SYS_DIR_H */ # endif
/* HAVE_SYS_DIR_H */
# ifdef HAVE_NDIR_H # ifdef HAVE_NDIR_H
# include <ndir.h> # include <ndir.h>
# endif /* HAVE_NDIR_H */ # endif
/* HAVE_NDIR_H */
#endif /* HAVE_DIRENT_H */ #endif /* HAVE_DIRENT_H */
#include <stdlib.h> #include <stdlib.h>
@ -157,7 +160,8 @@ maildir_read_message (maildir_t *mdp)
filename = filename =
(char *) xmalloc ((sizeof (char) * ((strlen (d_content->d_name)) (char *) xmalloc ((sizeof (char) * ((strlen (d_content->d_name))
+ (strlen (config.boxname)) + 6))); + (strlen (config.boxname)) +
6)));
/* /*
filename = filename =
@ -203,7 +207,8 @@ maildir_read_message (maildir_t *mdp)
message->headers = message->headers =
(char *) xrealloc (message->headers, (char *) xrealloc (message->headers,
((1 + s + message->hbytes) * sizeof (char))); ((1 + s +
message->hbytes) * sizeof (char)));
strcpy (message->headers + message->hbytes, buffer); strcpy (message->headers + message->hbytes, buffer);
message->hbytes += s; message->hbytes += s;
@ -212,7 +217,8 @@ maildir_read_message (maildir_t *mdp)
{ {
message->body = message->body =
(char *) xrealloc (message->body, (char *) xrealloc (message->body,
((1 + s + message->bbytes) * sizeof (char))); ((1 + s +
message->bbytes) * sizeof (char)));
strcpy (message->body + message->bbytes, buffer); strcpy (message->body + message->bbytes, buffer);
message->bbytes += s; message->bbytes += s;
} /* else */ } /* else */
@ -268,18 +274,24 @@ maildir_check (const char *path)
sprintf (s, "%s/cur", path); sprintf (s, "%s/cur", path);
i = stat (s, &fs); i = stat (s, &fs);
if (-1 == i) return -1; if (-1 == i)
if (! S_ISDIR (fs.st_mode)) return -1; return -1;
if (!S_ISDIR (fs.st_mode))
return -1;
sprintf (s, "%s/new", path); sprintf (s, "%s/new", path);
i = stat (s, &fs); i = stat (s, &fs);
if (-1 == i) return -1; if (-1 == i)
if (! S_ISDIR (fs.st_mode)) return -1; return -1;
if (!S_ISDIR (fs.st_mode))
return -1;
sprintf (s, "%s/tmp", path); sprintf (s, "%s/tmp", path);
i = stat (s, &fs); i = stat (s, &fs);
if (-1 == i) return -1; if (-1 == i)
if (! S_ISDIR (fs.st_mode)) return -1; return -1;
if (!S_ISDIR (fs.st_mode))
return -1;
free (s); free (s);

View File

@ -30,14 +30,18 @@
# define NAMLEN(dirent) (dirent)->d_namlen # define NAMLEN(dirent) (dirent)->d_namlen
# ifdef HAVE_SYS_NDIR_H # ifdef HAVE_SYS_NDIR_H
# include <sys/ndir.h> # include <sys/ndir.h>
# endif /* HAVE_SYS_NDIR_H */ # endif
/* HAVE_SYS_NDIR_H */
# ifdef HAVE_SYS_DIR_H # ifdef HAVE_SYS_DIR_H
# include <sys/dir.h> # include <sys/dir.h>
# endif /* HAVE_SYS_DIR_H */ # endif
/* HAVE_SYS_DIR_H */
# ifdef HAVE_NDIR_H # ifdef HAVE_NDIR_H
# include <ndir.h> # include <ndir.h>
# endif /* HAVE_NDIR_H */ # endif
#endif /* HAVE_DIRENT_H */ /* HAVE_NDIR_H */
# endif
/* HAVE_DIRENT_H */
# include "mboxgrep.h" # include "mboxgrep.h"

View File

@ -54,8 +54,7 @@ main (int argc, char **argv)
runtime.count = 0; runtime.count = 0;
runtime.maildir_count = 0; runtime.maildir_count = 0;
static struct option long_options[] = static struct option long_options[] = {
{
{"count", 0, 0, 'c'}, {"count", 0, 0, 'c'},
{"delete", 0, 0, 'd'}, {"delete", 0, 0, 'd'},
/* {"date", 1, 0, 'D'}, */ /* {"date", 1, 0, 'D'}, */

View File

@ -193,7 +193,8 @@ mbox_open (const char *path, const char *mode)
fprintf (stderr, "%s: (standard input): Not a mbox folder\n", fprintf (stderr, "%s: (standard input): Not a mbox folder\n",
APPNAME); APPNAME);
else else
fprintf (stderr, "%s: %s: Not a mbox folder\n", APPNAME, path); fprintf (stderr, "%s: %s: Not a mbox folder\n", APPNAME,
path);
} }
if (config.format == MBOX) if (config.format == MBOX)
fclose (mp->fp); fclose (mp->fp);
@ -402,11 +403,14 @@ tmpfile_mod_own (const int fd, const char *path)
if (stat (path, &s) != -1) if (stat (path, &s) != -1)
{ {
if (fchown (fd, s.st_uid, s.st_gid) == -1) if (fchown (fd, s.st_uid, s.st_gid) == -1)
if (config.merr) perror (config.tmpfilename); if (config.merr)
perror (config.tmpfilename);
if (fchmod (fd, s.st_mode) == -1) if (fchmod (fd, s.st_mode) == -1)
if (config.merr) perror (config.tmpfilename); if (config.merr)
perror (config.tmpfilename);
} }
else if (config.merr) perror (path); else if (config.merr)
perror (path);
} }
} }

View File

@ -29,13 +29,16 @@
# define NAMLEN(dirent) (dirent)->d_namlen # define NAMLEN(dirent) (dirent)->d_namlen
# ifdef HAVE_SYS_NDIR_H # ifdef HAVE_SYS_NDIR_H
# include <sys/ndir.h> # include <sys/ndir.h>
# endif /* HAVE_SYS_NDIR_H */ # endif
/* HAVE_SYS_NDIR_H */
# ifdef HAVE_SYS_DIR_H # ifdef HAVE_SYS_DIR_H
# include <sys/dir.h> # include <sys/dir.h>
# endif /* HAVE_SYS_DIR_H */ # endif
/* HAVE_SYS_DIR_H */
# ifdef HAVE_NDIR_H # ifdef HAVE_NDIR_H
# include <ndir.h> # include <ndir.h>
# endif /* HAVE_NDIR_H */ # endif
/* HAVE_NDIR_H */
#endif /* HAVE_DIRENT_H */ #endif /* HAVE_DIRENT_H */
#include <sys/types.h> #include <sys/types.h>
@ -54,7 +57,8 @@
extern option_t config; extern option_t config;
DIR *mh_open (const char *path) DIR *
mh_open (const char *path)
{ {
DIR *dp; DIR *dp;
@ -72,12 +76,14 @@ DIR *mh_open (const char *path)
return dp; return dp;
} /* mh_open */ } /* mh_open */
void mh_close (DIR *dp) void
mh_close (DIR * dp)
{ {
closedir (dp); closedir (dp);
} /* mh_close */ } /* mh_close */
message_t *mh_read_message (DIR *dp) message_t *
mh_read_message (DIR * dp)
{ {
int isheaders = 1; int isheaders = 1;
int have_from = 0, have_date = 0, have_sender = 0; int have_from = 0, have_date = 0, have_sender = 0;
@ -94,7 +100,8 @@ message_t *mh_read_message (DIR *dp)
for (;;) for (;;)
{ {
d_content = readdir (dp); d_content = readdir (dp);
if (d_content == NULL) return NULL; if (d_content == NULL)
return NULL;
if (d_content->d_name[0] == '.') if (d_content->d_name[0] == '.')
continue; continue;
@ -161,7 +168,8 @@ message_t *mh_read_message (DIR *dp)
message->headers = message->headers =
(char *) realloc (message->headers, (char *) realloc (message->headers,
((1 + s + message->hbytes) * sizeof (char))); ((1 + s +
message->hbytes) * sizeof (char)));
strcpy (message->headers + message->hbytes, buffer); strcpy (message->headers + message->hbytes, buffer);
message->hbytes += s; message->hbytes += s;
} /* if */ } /* if */
@ -169,7 +177,8 @@ message_t *mh_read_message (DIR *dp)
{ {
message->body = message->body =
(char *) realloc (message->body, (char *) realloc (message->body,
((1 + s + message->bbytes) * sizeof (char))); ((1 + s +
message->bbytes) * sizeof (char)));
strcpy (message->body + message->bbytes, buffer); strcpy (message->body + message->bbytes, buffer);
message->bbytes += s; message->bbytes += s;
} /* else */ } /* else */
@ -201,12 +210,14 @@ message_t *mh_read_message (DIR *dp)
} /* for */ } /* for */
} /* mh_read_message */ } /* mh_read_message */
void mh_write_message (message_t *m, const char *path) void
mh_write_message (message_t * m, const char *path)
{ {
struct dirent *dc; struct dirent *dc;
int x, y = 0; int x, y = 0;
char s1[BUFSIZ]; char s1[BUFSIZ];
DIR *d; FILE *f; DIR *d;
FILE *f;
d = m_opendir (path); d = m_opendir (path);
rewinddir (d); rewinddir (d);

View File

@ -27,14 +27,18 @@
# else # else
# ifdef HAVE_SYS_NDIR_H # ifdef HAVE_SYS_NDIR_H
# include <sys/ndir.h> # include <sys/ndir.h>
# endif /* HAVE_SYS_NDIR_H */ # endif
/* HAVE_SYS_NDIR_H */
# ifdef HAVE_SYS_DIR_H # ifdef HAVE_SYS_DIR_H
# include <sys/dir.h> # include <sys/dir.h>
# endif /* HAVE_SYS_DIR_H */ # endif
/* HAVE_SYS_DIR_H */
# ifdef HAVE_NDIR_H # ifdef HAVE_NDIR_H
# include <ndir.h> # include <ndir.h>
# endif /* HAVE_NDIR_H */ # endif
#endif /* HAVE_DIRENT_H */ /* HAVE_NDIR_H */
# endif
/* HAVE_DIRENT_H */
# include "mboxgrep.h" # include "mboxgrep.h"

View File

@ -68,7 +68,8 @@ folder_format (const char *name)
return f; return f;
} }
lockmethod_t lock_method (const char *name) lockmethod_t
lock_method (const char *name)
{ {
lockmethod_t l; lockmethod_t l;
@ -122,7 +123,8 @@ time_t parse_date(char *datestr)
} }
*/ */
char * parse_return_path(char *rpath) char *
parse_return_path (char *rpath)
{ {
char *blah1, blah2[BUFSIZ]; char *blah1, blah2[BUFSIZ];
@ -132,7 +134,8 @@ char * parse_return_path(char *rpath)
return blah1; return blah1;
} }
void * allocate_message (void) void *
allocate_message (void)
{ {
message_t *message; message_t *message;
@ -151,7 +154,8 @@ void * allocate_message (void)
return message; return message;
} }
void postmark_print (message_t *msg) void
postmark_print (message_t * msg)
{ {
time_t tt; time_t tt;
struct tm *ct; struct tm *ct;

View File

@ -32,6 +32,7 @@ char * parse_return_path(char *rpath);
void *allocate_message (void); void *allocate_message (void);
void postmark_print (message_t * msg); void postmark_print (message_t * msg);
void set_default_options (void); void set_default_options (void);
void get_runtime_options (int *argc, char **argv, struct option *long_options); void get_runtime_options (int *argc, char **argv,
struct option *long_options);
#endif /* MISC_H */ #endif /* MISC_H */

View File

@ -42,8 +42,7 @@ pcre_init (void)
if (config.pcre_pattern == NULL) if (config.pcre_pattern == NULL)
{ {
if (config.merr) if (config.merr)
fprintf (stderr, "%s: %s: %s\n", APPNAME, config.regex_s, fprintf (stderr, "%s: %s: %s\n", APPNAME, config.regex_s, error);
error);
exit (2); exit (2);
} }
} }
@ -57,14 +56,12 @@ pcre_match (message_t *msg)
config.res1 = config.res1 =
pcre_exec ((pcre *) config.pcre_pattern, pcre_exec ((pcre *) config.pcre_pattern,
(pcre_extra *) config.pcre_hints, (pcre_extra *) config.pcre_hints,
msg->headers, msg->headers, (int) strlen (msg->headers), 0, 0, of, BUFSIZ);
(int) strlen (msg->headers), 0, 0, of, BUFSIZ);
if (config.body) if (config.body)
config.res2 = config.res2 =
pcre_exec ((pcre *) config.pcre_pattern, pcre_exec ((pcre *) config.pcre_pattern,
(pcre_extra *) config.pcre_hints, (pcre_extra *) config.pcre_hints,
msg->body, msg->body, (int) strlen (msg->body), 0, 0, of, BUFSIZ);
(int) strlen (msg->body), 0, 0, of, BUFSIZ);
config.res1 = config.res1 ^ 1; config.res1 = config.res1 ^ 1;
config.res2 = config.res2 ^ 1; config.res2 = config.res2 ^ 1;
@ -90,7 +87,8 @@ regex_init (void)
{ {
if (config.merr) if (config.merr)
{ {
regerror (errcode, (regex_t *) config.posix_pattern, errbuf, BUFSIZ); regerror (errcode, (regex_t *) config.posix_pattern, errbuf,
BUFSIZ);
fprintf (stderr, "%s: %s: %s\n", APPNAME, config.regex_s, errbuf); fprintf (stderr, "%s: %s: %s\n", APPNAME, config.regex_s, errbuf);
} }
exit (2); exit (2);

View File

@ -32,13 +32,16 @@
# define NAMLEN(dirent) (dirent)->d_namlen # define NAMLEN(dirent) (dirent)->d_namlen
# ifdef HAVE_SYS_NDIR_H # ifdef HAVE_SYS_NDIR_H
# include <sys/ndir.h> # include <sys/ndir.h>
# endif /* HAVE_SYS_NDIR_H */ # endif
/* HAVE_SYS_NDIR_H */
# ifdef HAVE_SYS_DIR_H # ifdef HAVE_SYS_DIR_H
# include <sys/dir.h> # include <sys/dir.h>
# endif /* HAVE_SYS_DIR_H */ # endif
/* HAVE_SYS_DIR_H */
# ifdef HAVE_NDIR_H # ifdef HAVE_NDIR_H
# include <ndir.h> # include <ndir.h>
# endif /* HAVE_NDIR_H */ # endif
/* HAVE_NDIR_H */
#endif /* HAVE_DIRENT_H */ #endif /* HAVE_DIRENT_H */
#include <time.h> #include <time.h>
@ -61,14 +64,16 @@
#else #else
# ifdef HAVE_FTW # ifdef HAVE_FTW
# include <ftw.h> # include <ftw.h>
# endif /* HAVE_FTW */ # endif
/* HAVE_FTW */
#endif /* HAVE_FTS_OPEN */ #endif /* HAVE_FTS_OPEN */
#ifdef HAVE_LIBDMALLOC #ifdef HAVE_LIBDMALLOC
# include <dmalloc.h> # include <dmalloc.h>
#endif /* HAVE_LIBDMALLOC */ #endif /* HAVE_LIBDMALLOC */
void scan_mailbox (char path[]) void
scan_mailbox (char path[])
{ {
static FILE *outf; static FILE *outf;
static mbox_t *mbox, *out; static mbox_t *mbox, *out;
@ -99,17 +104,19 @@ void scan_mailbox (char path[])
if (config.action == DELETE) if (config.action == DELETE)
delete = 1; delete = 1;
if ((config.format == MBOX) || (config.format == ZMBOX) || if ((config.format == MBOX) || (config.format == ZMBOX)
(config.format == BZ2MBOX)) || (config.format == BZ2MBOX))
{ {
mbox = (mbox_t *) mbox_open (path, "r"); mbox = (mbox_t *) mbox_open (path, "r");
if (mbox == NULL) return; if (mbox == NULL)
return;
} }
else if ((config.format == MH) || (config.format == NNMH) || else if ((config.format == MH) || (config.format == NNMH)
(config.format == NNML)) || (config.format == NNML))
{ {
boxd = mh_open (path); boxd = mh_open (path);
if (boxd == NULL) return; if (boxd == NULL)
return;
} }
else if (config.format == MAILDIR) else if (config.format == MAILDIR)
{ {
@ -124,18 +131,20 @@ void scan_mailbox (char path[])
config.res1 = 1; config.res1 = 1;
config.res2 = 1; config.res2 = 1;
if ((config.format == MBOX) || (config.format == ZMBOX) || if ((config.format == MBOX) || (config.format == ZMBOX)
(config.format == BZ2MBOX)) || (config.format == BZ2MBOX))
msg = (message_t *) mbox_read_message (mbox); msg = (message_t *) mbox_read_message (mbox);
else if ((config.format == MH) || (config.format == NNMH) || else if ((config.format == MH) || (config.format == NNMH)
(config.format == NNML)) || (config.format == NNML))
msg = (message_t *) mh_read_message (boxd); msg = (message_t *) mh_read_message (boxd);
else if (config.format == MAILDIR) else if (config.format == MAILDIR)
msg = (message_t *) maildir_read_message (maildird); msg = (message_t *) maildir_read_message (maildird);
if (msg == NULL) break; if (msg == NULL)
break;
if (msg->from == NULL) msg->from = (char *) xstrdup ("nobody"); if (msg->from == NULL)
msg->from = (char *) xstrdup ("nobody");
#ifdef HAVE_LIBPCRE #ifdef HAVE_LIBPCRE
if (config.perl) if (config.perl)
@ -164,11 +173,11 @@ void scan_mailbox (char path[])
{ {
if (config.format == MAILDIR) if (config.format == MAILDIR)
maildir_write_message (msg, config.outboxname); maildir_write_message (msg, config.outboxname);
else if (config.format == MH || config.format == NNMH || else if (config.format == MH || config.format == NNMH
config.format == NNML) || config.format == NNML)
mh_write_message (msg, config.outboxname); mh_write_message (msg, config.outboxname);
else if ((config.format == MBOX) || (config.format == ZMBOX) || else if ((config.format == MBOX) || (config.format == ZMBOX)
(config.format == BZ2MBOX)) || (config.format == BZ2MBOX))
{ {
out = mbox_open (config.outboxname, "w"); out = mbox_open (config.outboxname, "w");
/* fprintf (out->fp, "%s\n%s", msg->headers, msg->body); */ /* fprintf (out->fp, "%s\n%s", msg->headers, msg->body); */
@ -194,14 +203,16 @@ void scan_mailbox (char path[])
else if (config.action == COUNT) else if (config.action == COUNT)
runtime.count++; runtime.count++;
else if (config.action == DELETE && else if (config.action == DELETE &&
((config.format == MBOX) || (config.format == ZMBOX) || ((config.format == MBOX) || (config.format == ZMBOX)
(config.format == BZ2MBOX))) || (config.format == BZ2MBOX)))
mbox_write_message (msg, runtime.tmp_mbox); mbox_write_message (msg, runtime.tmp_mbox);
} }
else if (((((config.res1 == 0) | (config.res2 == 0)) ^ config.invert) && delete) && else
((config.format == MH) || (config.format == NNMH) || if (((((config.res1 == 0) | (config.res2 == 0)) ^ config.invert)
(config.format == NNML) || (config.format == MAILDIR))) && delete) && ((config.format == MH) || (config.format == NNMH)
|| (config.format == NNML)
|| (config.format == MAILDIR)))
m_unlink (msg->filename); m_unlink (msg->filename);
free (msg->body); free (msg->body);
@ -209,15 +220,16 @@ void scan_mailbox (char path[])
free (msg); free (msg);
} /* for */ } /* for */
if ((config.format == MBOX) || (config.format == ZMBOX) || if ((config.format == MBOX) || (config.format == ZMBOX)
(config.format == BZ2MBOX)) || (config.format == BZ2MBOX))
mbox_close (mbox); mbox_close (mbox);
else if ((config.format == MH) || (config.format == NNMH) || else if ((config.format == MH) || (config.format == NNMH)
(config.format == NNML)) || (config.format == NNML))
mh_close (boxd); mh_close (boxd);
} }
void recursive_scan (char path[]) void
recursive_scan (char path[])
{ {
#ifdef HAVE_FTS_OPEN #ifdef HAVE_FTS_OPEN
FTS *ftsfoo; FTS *ftsfoo;
@ -250,7 +262,8 @@ void recursive_scan (char path[])
#endif /* HAVE_FTS_OPEN */ #endif /* HAVE_FTS_OPEN */
} }
int md5_check_message (char *body, checksum_t *chksum) int
md5_check_message (char *body, checksum_t * chksum)
{ {
struct md5_ctx a; struct md5_ctx a;
char b[16]; char b[16];
@ -271,7 +284,8 @@ int md5_check_message (char *body, checksum_t *chksum)
return 1; return 1;
} }
chksum->md5 = (char **) xrealloc (chksum->md5, (1 + chksum->n) * sizeof (char *)); chksum->md5 =
(char **) xrealloc (chksum->md5, (1 + chksum->n) * sizeof (char *));
chksum->md5[chksum->n] = xstrdup (b); chksum->md5[chksum->n] = xstrdup (b);

View File

@ -31,13 +31,16 @@
# define NAMLEN(dirent) (dirent)->d_namlen # define NAMLEN(dirent) (dirent)->d_namlen
# ifdef HAVE_SYS_NDIR_H # ifdef HAVE_SYS_NDIR_H
# include <sys/ndir.h> # include <sys/ndir.h>
# endif /* HAVE_SYS_NDIR_H */ # endif
/* HAVE_SYS_NDIR_H */
# ifdef HAVE_SYS_DIR_H # ifdef HAVE_SYS_DIR_H
# include <sys/dir.h> # include <sys/dir.h>
# endif /* HAVE_SYS_DIR_H */ # endif
/* HAVE_SYS_DIR_H */
# ifdef HAVE_NDIR_H # ifdef HAVE_NDIR_H
# include <ndir.h> # include <ndir.h>
# endif /* HAVE_NDIR_H */ # endif
/* HAVE_NDIR_H */
#endif /* HAVE_DIRENT_H */ #endif /* HAVE_DIRENT_H */
#ifdef HAVE_LIBZ #ifdef HAVE_LIBZ
# include <zlib.h> # include <zlib.h>
@ -59,7 +62,8 @@
#define BUFLEN 16384 #define BUFLEN 16384
int m_open (const char *pathname, int flags, mode_t mode) int
m_open (const char *pathname, int flags, mode_t mode)
{ {
int blah; int blah;
@ -78,7 +82,8 @@ int m_open (const char *pathname, int flags, mode_t mode)
return blah; return blah;
} }
FILE *m_fopen (const char *path, const char *mode) FILE *
m_fopen (const char *path, const char *mode)
{ {
FILE *blah; FILE *blah;
@ -96,7 +101,8 @@ FILE *m_fopen (const char *path, const char *mode)
return blah; return blah;
} }
FILE *m_fdopen (int fildes, const char *mode) FILE *
m_fdopen (int fildes, const char *mode)
{ {
FILE *blah; FILE *blah;
@ -111,7 +117,8 @@ FILE *m_fdopen (int fildes, const char *mode)
#ifdef HAVE_LIBZ #ifdef HAVE_LIBZ
gzFile m_gzdopen (int fildes, const char *mode) gzFile
m_gzdopen (int fildes, const char *mode)
{ {
gzFile blah; gzFile blah;
@ -126,7 +133,8 @@ gzFile m_gzdopen (int fildes, const char *mode)
#endif /* HAVE_LIBZ */ #endif /* HAVE_LIBZ */
DIR *m_opendir (const char *name) DIR *
m_opendir (const char *name)
{ {
DIR *blah; DIR *blah;
@ -144,7 +152,8 @@ DIR *m_opendir (const char *name)
#ifndef HAVE_LIBDMALLOC #ifndef HAVE_LIBDMALLOC
void *xmalloc (size_t size) void *
xmalloc (size_t size)
{ {
void *foo; void *foo;
@ -158,7 +167,8 @@ void *xmalloc (size_t size)
return foo; return foo;
} }
void *xrealloc (void *ptr, size_t size) void *
xrealloc (void *ptr, size_t size)
{ {
void *foo; void *foo;
@ -172,7 +182,8 @@ void *xrealloc (void *ptr, size_t size)
return foo; return foo;
} }
void *xcalloc (size_t nmemb, size_t size) void *
xcalloc (size_t nmemb, size_t size)
{ {
void *foo; void *foo;
@ -186,7 +197,8 @@ void *xcalloc (size_t nmemb, size_t size)
return foo; return foo;
} }
char *xstrdup (const char *s) char *
xstrdup (const char *s)
{ {
char *foo; char *foo;
@ -202,7 +214,8 @@ char *xstrdup (const char *s)
#endif /* HAVE_LIBDMALLOC */ #endif /* HAVE_LIBDMALLOC */
int m_unlink (const char *pathname) int
m_unlink (const char *pathname)
{ {
int baz; int baz;
@ -220,7 +233,8 @@ int m_unlink (const char *pathname)
#ifdef HAVE_LIBZ #ifdef HAVE_LIBZ
void gzwrite_loop (void *fp, char *str) void
gzwrite_loop (void *fp, char *str)
{ {
int quux, len, baz; int quux, len, baz;
@ -240,7 +254,8 @@ void gzwrite_loop (void *fp, char *str)
#ifdef HAVE_LIBBZ2 #ifdef HAVE_LIBBZ2
void bzwrite_loop (void *fp, char *str) void
bzwrite_loop (void *fp, char *str)
{ {
int quux, len, baz; int quux, len, baz;

View File

@ -33,23 +33,29 @@
# else # else
# ifdef HAVE_SYS_NDIR_H # ifdef HAVE_SYS_NDIR_H
# include <sys/ndir.h> # include <sys/ndir.h>
# endif /* HAVE_SYS_NDIR_H */ # endif
/* HAVE_SYS_NDIR_H */
# ifdef HAVE_SYS_DIR_H # ifdef HAVE_SYS_DIR_H
# include <sys/dir.h> # include <sys/dir.h>
# endif /* HAVE_SYS_DIR_H */ # endif
/* HAVE_SYS_DIR_H */
# ifdef HAVE_NDIR_H # ifdef HAVE_NDIR_H
# include <ndir.h> # include <ndir.h>
# endif /* HAVE_NDIR_H */ # endif
#endif /* HAVE_DIRENT_H */ /* HAVE_NDIR_H */
# endif
/* HAVE_DIRENT_H */
# ifdef HAVE_LIBZ # ifdef HAVE_LIBZ
# include <zlib.h> # include <zlib.h>
#endif /* HAVE_LIBZ */ # endif
/* HAVE_LIBZ */
# include <stdlib.h> # include <stdlib.h>
# ifdef HAVE_LIBDMALLOC # ifdef HAVE_LIBDMALLOC
# include <dmalloc.h> # include <dmalloc.h>
#endif /* HAVE_LIBDMALLOC */ # endif
/* HAVE_LIBDMALLOC */
int m_open (const char *pathname, int flags, mode_t mode); int m_open (const char *pathname, int flags, mode_t mode);
@ -58,10 +64,12 @@ FILE *m_fdopen (int fildes, const char *mode);
# ifdef HAVE_LIBZ # ifdef HAVE_LIBZ
gzFile m_gzdopen (int fildes, const char *mode); gzFile m_gzdopen (int fildes, const char *mode);
void gzwrite_loop (void *fp, char *str); void gzwrite_loop (void *fp, char *str);
#endif /* HAVE_LIBZ */ # endif
/* HAVE_LIBZ */
# ifdef HAVE_LIBBZ2 # ifdef HAVE_LIBBZ2
void bzwrite_loop (void *fp, char *str); void bzwrite_loop (void *fp, char *str);
#endif /* HAVE_LIBBZ2 */ # endif
/* HAVE_LIBBZ2 */
DIR *m_opendir (const char *name); DIR *m_opendir (const char *name);
@ -70,7 +78,8 @@ void *xmalloc (size_t size);
void *xrealloc (void *ptr, size_t size); void *xrealloc (void *ptr, size_t size);
void *xcalloc (size_t nmemb, size_t size); void *xcalloc (size_t nmemb, size_t size);
char *xstrdup (const char *s); char *xstrdup (const char *s);
#endif /* HAVE_LIBDMALLOC */ # endif
/* HAVE_LIBDMALLOC */
int m_unlink (const char *pathname); int m_unlink (const char *pathname);