/* * Copyright 1998-2002 Ben Smithurst * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ /* * $BCPS: src/mailutils/misc.h,v 1.50 2003/01/19 19:18:25 ben Exp $ */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define VERSION "1.0" #define LF_GET 1 #define LF_REL 2 #define LF_GET_SOFT 4 typedef struct _tree { char *file; struct _tree *left; struct _tree *right; } TREE; typedef struct { FILE *fp; char *buf; size_t size; int eof; } gl_getline_t; FILE *open_mailbox(char *, char **, int *); char *gl_getline(FILE *); char *homedir(void); char *inbox_check(char *); char *mailpath(void); char *user_inbox(void); int is_from(char *, int); int is_maildir(const char *); int mailbox_size(const char *, int *); int mailboxlock(char *, int, int, int); int process(char **, int (*)(FILE *, FILE *), int (*)(int, char *, FILE *)); unsigned int str_to_int(char *); void add_to_tree(TREE **, char *); void array_to_tree(TREE **, char **); void check_tree(TREE *, void (*)(char *)); void files_to_tree(TREE **, const char *); void free_tree(TREE *); void gl_destroy(FILE *); char *print_mailbox(const char *); void signal_handler(int); void xerr(int, char *, ...); void xerrx(int, char *, ...); void xfprintf(FILE *, char *, ...); /* Return values for functions called by process() */ #define RET_ERROR 0 /* Error as specified by `errno' */ #define RET_CHANGE 1 /* The file was changed, replace it with temp */ #define RET_NOCHANGE 2 /* No change, just delete temp */ #define RET_LOCALERROR 3 /* * An error where `errno' is meaningless: * don't print anything, the called function is * assumed to have done so. */ #define RET_DELETE 4 /* delete the file (maildir only) */ #define MALLOC(d, s) { \ if ((d = malloc(s)) == NULL) \ err(1, "malloc"); \ } #define assertnl(line, len) do { \ assert(len > 0 && line[len-1] == '\n'); \ len--; \ } while (0) #define chop(line, len) do { \ assertnl(line, len); \ line[len] = '\0'; \ } while (0) extern int quiet; extern char *curfile; extern volatile sig_atomic_t sig_count;