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 21void expand_string (char **, size_t *, size_t); 22char *Xreadlink (const char *link, size_t size); 23void xrealloc_and_strcat (char **, size_t *, const char *); 24int strip_trailing_newlines (char *str); 25int pathname_levels (const char *path); 26void free_names (int *pargc, char *argv[]); 27void line2argv (int *pargc, char ***argv, char *line, char *sepchars); 28int numdots (const char *s); 29int compare_revnums (const char *, const char *); 30char *increment_revnum (const char *); 31char *getcaller (void); 32char *previous_rev (RCSNode *rcs, const char *rev); 33char *gca (const char *rev1, const char *rev2); 34void check_numeric (const char *, int, char **); 35char *make_message_rcsvalid (const char *message); 36int file_has_markers (const struct file_info *); 37void get_file (const char *, const char *, const char *, 38 char **, size_t *, size_t *); 39void resolve_symlink (char **filename); 40char *backup_file (const char *file, const char *suffix); 41char *shell_escape (char *buf, const char *str); 42void 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 */ 48struct 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}; 66char *cmdlinequote (char quotes, char *s); 67char *cmdlineescape (char quotes, char *s); 68#ifdef SUPPORT_OLD_INFO_FMT_STRINGS 69char *format_cmdline (bool oldway, const char *srepos, const char *format, ...); 70#else /* SUPPORT_OLD_INFO_FMT_STRINGS */ 71char *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 78char *Xstrdup (const char *str) 79 __attribute__ ((__malloc__)); 80 81char *Xasprintf (const char *format, ...) 82 __attribute__ ((__malloc__, __format__ (__printf__, 1, 2))); 83char *Xasnprintf (char *resultbuf, size_t *lengthp, const char *format, ...) 84 __attribute__ ((__malloc__, __format__ (__printf__, 3, 4))); 85bool readBool (const char *infopath, const char *option, 86 const char *p, bool *val); 87 88FILE *xfopen (const char *, const char *); 89char *xcanonicalize_file_name (const char *path); 90bool isThisHost (const char *otherhost); 91bool isSamePath (const char *path1_in, const char *path2_in); 92#endif /* !SUBR_H */ 93