Home | History | Annotate | Line # | Download | only in src
      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_markers (const struct file_info *);
     37 void get_file (const char *, const char *, const char *,
     38                char **, size_t *, size_t *);
     39 void resolve_symlink (char **filename);
     40 char *backup_file (const char *file, const char *suffix);
     41 char *shell_escape (char *buf, const char *str);
     42 void sleep_past (time_t desttime);
     43 
     44 /* for format_cmdline function - when a list variable is bound to a user string,
     45  * we need to pass some data through walklist into the callback function.
     46  * We use this struct.
     47  */
     48 struct format_cmdline_walklist_closure
     49 {
     50     const char *format;	/* the format string the user passed us */
     51     char **buf;		/* *dest = our NUL terminated and possibly too short
     52 			 * destination string
     53 			 */
     54     size_t *length;	/* *dlen = how many bytes have already been allocated to
     55 			 * *dest.
     56 			 */
     57     char **d;		/* our pointer into buf where the next char should go */
     58     char quotes;	/* quotes we are currently between, if any */
     59 #ifdef SUPPORT_OLD_INFO_FMT_STRINGS
     60     int onearg;
     61     int firstpass;
     62     const char *srepos;
     63 #endif /* SUPPORT_OLD_INFO_FMT_STRINGS */
     64     void *closure;	/* our user defined closure */
     65 };
     66 char *cmdlinequote (char quotes, char *s);
     67 char *cmdlineescape (char quotes, char *s);
     68 #ifdef SUPPORT_OLD_INFO_FMT_STRINGS
     69 char *format_cmdline (bool oldway, const char *srepos, const char *format, ...);
     70 #else /* SUPPORT_OLD_INFO_FMT_STRINGS */
     71 char *format_cmdline (const char *format, ...);
     72 #endif /* SUPPORT_OLD_INFO_FMT_STRINGS */
     73 
     74 /* Many, many CVS calls to xstrdup depend on it to return NULL when its
     75  * argument is NULL.
     76  */
     77 #define xstrdup Xstrdup
     78 char *Xstrdup (const char *str)
     79 	__attribute__ ((__malloc__));
     80 
     81 char *Xasprintf (const char *format, ...)
     82 	__attribute__ ((__malloc__, __format__ (__printf__, 1, 2)));
     83 char *Xasnprintf (char *resultbuf, size_t *lengthp, const char *format, ...)
     84         __attribute__ ((__malloc__, __format__ (__printf__, 3, 4)));
     85 bool readBool (const char *infopath, const char *option,
     86 	       const char *p, bool *val);
     87 
     88 FILE *xfopen (const char *, const char *);
     89 char *xcanonicalize_file_name (const char *path);
     90 bool isThisHost (const char *otherhost);
     91 bool isSamePath (const char *path1_in, const char *path2_in);
     92 #endif /* !SUBR_H */
     93