Add CVS 1.12.12.
[dragonfly.git] / contrib / cvs-1.12.12 / src / subr.h
1 /*
2  * Copyright (c) 1992, Brian Berliner and Jeff Polk
3  * Copyright (c) 1989-1992, Brian Berliner
4  * Copyright (c) 2004, Derek R. Price and Ximbiot <http://ximbiot.com>
5  * Copyright (c) 1989-2004 The Free Software Foundation <http://gnu.org>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2, or (at your option)
10  * any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  */
17
18 #ifndef SUBR_H
19 # define SUBR_H
20
21 void expand_string (char **, size_t *, size_t);
22 char *Xreadlink (const char *link, size_t size);
23 void xrealloc_and_strcat (char **, size_t *, const char *);
24 int strip_trailing_newlines (char *str);
25 int pathname_levels (const char *path);
26 void free_names (int *pargc, char *argv[]);
27 void line2argv (int *pargc, char ***argv, char *line, char *sepchars);
28 int numdots (const char *s);
29 int compare_revnums (const char *, const char *);
30 char *increment_revnum (const char *);
31 char *getcaller (void);
32 char *previous_rev (RCSNode *rcs, const char *rev);
33 char *gca (const char *rev1, const char *rev2);
34 void check_numeric (const char *, int, char **);
35 char *make_message_rcsvalid (const char *message);
36 int file_has_conflict (const struct file_info *, const char *ts_conflict);
37 int file_has_markers (const struct file_info *);
38 void get_file (const char *, const char *, const char *,
39                char **, size_t *, size_t *);
40 void resolve_symlink (char **filename);
41 char *backup_file (const char *file, const char *suffix);
42 char *shell_escape (char *buf, const char *str);
43 void sleep_past (time_t desttime);
44
45 /* for format_cmdline function - when a list variable is bound to a user string,
46  * we need to pass some data through walklist into the callback function.
47  * We use this struct.
48  */
49 struct format_cmdline_walklist_closure
50 {
51     const char *format; /* the format string the user passed us */
52     char **buf;         /* *dest = our NUL terminated and possibly too short
53                          * destination string
54                          */
55     size_t *length;     /* *dlen = how many bytes have already been allocated to
56                          * *dest.
57                          */
58     char **d;           /* our pointer into buf where the next char should go */
59     char quotes;        /* quotes we are currently between, if any */
60 #ifdef SUPPORT_OLD_INFO_FMT_STRINGS
61     int onearg;
62     int firstpass;
63     const char *srepos;
64 #endif /* SUPPORT_OLD_INFO_FMT_STRINGS */
65     void *closure;      /* our user defined closure */
66 };
67 char *cmdlinequote (char quotes, char *s);
68 char *cmdlineescape (char quotes, char *s);
69 #ifdef SUPPORT_OLD_INFO_FMT_STRINGS
70 char *format_cmdline (bool oldway, const char *srepos, const char *format, ...);
71 #else /* SUPPORT_OLD_INFO_FMT_STRINGS */
72 char *format_cmdline (const char *format, ...);
73 #endif /* SUPPORT_OLD_INFO_FMT_STRINGS */
74
75 bool isabsolute (const char *filename);
76
77 /* Many, many CVS calls to xstrdup depend on it to return NULL when its
78  * argument is NULL.
79  */
80 #define xstrdup Xstrdup
81 char *Xstrdup (const char *str)
82         __attribute__ ((__malloc__));
83
84 char *Xasprintf (const char *format, ...)
85         __attribute__ ((__malloc__, __format__ (__printf__, 1, 2)));
86 char *Xasnprintf (char *resultbuf, size_t *lengthp, const char *format, ...)
87         __attribute__ ((__malloc__, __format__ (__printf__, 3, 4)));
88 bool readBool (const char *infopath, const char *option,
89                const char *p, bool *val);
90
91 FILE *xfopen (const char *, const char *);
92 #endif /* !SUBR_H */