| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
#ifndef _MEW_H_ |
| 12 |
#define _MEW_H_ |
| 13 |
|
| 14 |
#include "config.h" |
| 15 |
#include <stdio.h> |
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
#define TRUE 1 |
| 22 |
#define FALSE 0 |
| 23 |
|
| 24 |
#define YES 1 |
| 25 |
#define NO 0 |
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
#define READ 0 |
| 32 |
#define WRITE 1 |
| 33 |
#define SYNC 3 |
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
#define FDREAD "rb" |
| 40 |
#define FDWRITE "wb" |
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
#define NUL '\0' |
| 47 |
#define CR '\r' |
| 48 |
#define LF '\n' |
| 49 |
#define EQ '=' |
| 50 |
#define TAB '\t' |
| 51 |
#define SP ' ' |
| 52 |
#define DOT '.' |
| 53 |
#define DEL 127 |
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
#define MEW_MTIME_FILE ".mew-mtime" |
| 60 |
#define MEW_MTIME_PHRASE "touched by mewl." |
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
#define SUFFIX ".mew" |
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
#define FILESEP '/' |
| 73 |
|
| 74 |
#define STRCMP(str1, str2) strncmp(str1, str2, sizeof(str2) - 1) |
| 75 |
#define STRCPY(dst, src) do {strncpy(dst, src, sizeof(dst) - 1); dst[sizeof(dst) -1] = NUL;} while (0); |
| 76 |
#define STRDUP(dst, src) if (((dst) = strdup((src))) == NULL) warn_exit("memory fault.") |
| 77 |
#define MALLOC(p, siz) if (((p) = malloc((siz))) == NULL) warn_exit("memory fault.") |
| 78 |
#define REALLOC(p, siz) if (((p) = realloc((p), (siz))) == NULL) warn_exit("memory fault.") |
| 79 |
|
| 80 |
#ifndef HAVE_STRNCASECMP |
| 81 |
# ifdef HAVE_STRNICMP |
| 82 |
# define strncasecmp strnicmp |
| 83 |
# endif |
| 84 |
#endif |
| 85 |
|
| 86 |
#ifndef HAVE_CHDIR |
| 87 |
# ifdef HAVE__CHDIR2 |
| 88 |
# define chdir _chdir2 |
| 89 |
# endif |
| 90 |
#endif |
| 91 |
|
| 92 |
#ifdef HAVE_FCNTL_H |
| 93 |
# include <fcntl.h> |
| 94 |
# ifdef HAVE_IO_H |
| 95 |
# include <io.h> |
| 96 |
# endif |
| 97 |
# ifdef O_BINARY |
| 98 |
# ifndef HAVE_SETMODE |
| 99 |
# ifdef HAVE__SETMODE |
| 100 |
# define setmode _setmode |
| 101 |
# endif |
| 102 |
# endif |
| 103 |
# ifndef HAVE_FILENO |
| 104 |
# ifdef HAVE__FILENO |
| 105 |
# define fileno _fileno |
| 106 |
# endif |
| 107 |
# endif |
| 108 |
# define SET_BINARY_MODE(fd) setmode(fileno((fd)), O_BINARY) |
| 109 |
# else |
| 110 |
# define SET_BINARY_MODE(fd) {} |
| 111 |
# endif |
| 112 |
#endif |
| 113 |
|
| 114 |
#ifndef HAVE_USLEEP |
| 115 |
# ifdef HAVE_SLEEP |
| 116 |
# define usleep(x) Sleep(x / 1000) |
| 117 |
# elif defined(HAVE_POLL) |
| 118 |
# define usleep(x) poll(0, 0, (x)/1000) |
| 119 |
# endif |
| 120 |
#endif |
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
#define public extern |
| 127 |
#define private static |
| 128 |
|
| 129 |
public char *getprognm(char *); |
| 130 |
public void warning(const char *, ...); |
| 131 |
public void warn_exit(const char *, ...); |
| 132 |
public int search_string(char *, char *, int); |
| 133 |
public void pattern_init(char *); |
| 134 |
public int pattern_match(void); |
| 135 |
public char *Getline(FILE *); |
| 136 |
public int Getopt(int, char **, const char *); |
| 137 |
|
| 138 |
extern char *warn_prog; |
| 139 |
extern int Optind; |
| 140 |
extern char *Optarg; |
| 141 |
|
| 142 |
#endif |
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
|
| 170 |
|
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
|
| 176 |
|