]> git.sthu.org Git - pgp-tools.git/blob - keyanalyze/pgpring/lib.h
* debian.control: added ${misc:Depends} as Depends for the keyanalyze
[pgp-tools.git] / keyanalyze / pgpring / lib.h
1 /*
2 * Copyright (C) 1996-2000 Michael R. Elkins <me@cs.hmc.edu>
3 * Copyright (C) 1999-2000 Thomas Roessler <roessler@guug.de>
4 *
5 * This program is free software; you can redistribute it
6 * and/or modify it under the terms of the GNU General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later
9 * version.
10 *
11 * This program is distributed in the hope that it will be
12 * useful, but WITHOUT ANY WARRANTY; without even the implied
13 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more
15 * details.
16 *
17 * You should have received a copy of the GNU General Public
18 * License along with this program; if not, write to the Free
19 * Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111, USA.
21 */
22
23 /* mutt functions which are generally useful. */
24
25 #ifndef _LIB_H
26 # define _LIB_H
27
28 # include "config.h"
29
30 # include <stdio.h>
31 # include <string.h>
32 # ifdef HAVE_UNISTD_H
33 # include <unistd.h> /* needed for SEEK_SET */
34 # endif
35 # include <sys/types.h>
36 # include <sys/stat.h>
37 # include <time.h>
38 # include <limits.h>
39 # include <stdarg.h>
40 # include <signal.h>
41
42 # ifndef _POSIX_PATH_MAX
43 # include <posix1_lim.h>
44 # endif
45
46 # ifdef ENABLE_NLS
47 # include <libintl.h>
48 # define _(a) (gettext (a))
49 # ifdef gettext_noop
50 # define N_(a) gettext_noop (a)
51 # else
52 # define N_(a) (a)
53 # endif
54 # else
55 # define _(a) (a)
56 # define N_(a) a
57 # endif
58
59 # define TRUE 1
60 # define FALSE 0
61
62 # define HUGE_STRING 5120
63 # define LONG_STRING 1024
64 # define STRING 256
65 # define SHORT_STRING 128
66
67 # define FREE(x) safe_free(x)
68 # define NONULL(x) x?x:""
69 # define ISSPACE(c) isspace((unsigned char)c)
70 # define strfcpy(A,B,C) strncpy(A,B,C), *(A+(C)-1)=0
71
72 #define FOREVER while (1)
73
74 /* this macro must check for *c == 0 since isspace(0) has unreliable behavior
75 on some systems */
76 # define SKIPWS(c) while (*(c) && isspace ((unsigned char) *(c))) c++;
77
78 /*
79 * These functions aren't defined in lib.c, but
80 * they are used there.
81 *
82 * A non-mutt "implementation" (ahem) can be found in extlib.c.
83 */
84
85 # ifndef _EXTLIB_C
86 extern void (*mutt_error) (const char *, ...);
87 # endif
88 void mutt_exit (int);
89
90 /* The actual library functions. */
91
92 FILE *safe_fopen (const char *, const char *);
93
94 char *mutt_read_line (char *, size_t *, FILE *, int *);
95 char *mutt_skip_whitespace (char *);
96 char *mutt_strlower (char *);
97 char *mutt_substrcpy (char *, const char *, const char *, size_t);
98 char *mutt_substrdup (const char *, const char *);
99 char *safe_strdup (const char *);
100
101 const char *mutt_stristr (const char *, const char *);
102
103 int mutt_copy_stream (FILE *, FILE *);
104 int mutt_copy_bytes (FILE *, FILE *, size_t);
105 int mutt_rx_sanitize_string (char *, size_t, const char *);
106 int mutt_strcasecmp (const char *, const char *);
107 int mutt_strcmp (const char *, const char *);
108 int mutt_strncasecmp (const char *, const char *, size_t);
109 int mutt_strncmp (const char *, const char *, size_t);
110 int safe_open (const char *, int);
111 int safe_symlink (const char *, const char *);
112 int safe_rename (const char *, const char *);
113 int safe_fclose (FILE **);
114
115 size_t mutt_quote_filename (char *, size_t, const char *);
116 size_t mutt_strlen (const char *);
117
118 void *safe_calloc (size_t, size_t);
119 void *safe_malloc (size_t);
120 void mutt_nocurses_error (const char *, ...);
121 void mutt_remove_trailing_ws (char *);
122 void mutt_sanitize_filename (char *, short);
123 void mutt_str_replace (char **p, const char *s);
124 void mutt_str_adjust (char **p);
125 void mutt_unlink (const char *);
126 void safe_free (void *);
127 void safe_realloc (void *, size_t);
128
129 #endif