2
* $Id: routines.h,v 1.11 2006/05/30 04:37:12 darren Exp $
4
* Copyright (c) 2002, Darren Hiebert
6
* This source code is released for free distribution under the terms of the
7
* GNU General Public License.
9
* External interface to routines.c
17
#include "general.h" /* must always come first */
22
#define xMalloc(n,Type) (Type *)eMalloc((size_t)(n) * sizeof (Type))
23
#define xCalloc(n,Type) (Type *)eCalloc((size_t)(n), sizeof (Type))
24
#define xRealloc(p,n,Type) (Type *)eRealloc((p), (n) * sizeof (Type))
29
#ifndef PATH_SEPARATOR
30
# if defined (MSDOS_STYLE_PATH)
31
# define PATH_SEPARATOR '\\'
33
# define PATH_SEPARATOR '_'
35
# define PATH_SEPARATOR '/'
39
#if defined (MSDOS_STYLE_PATH) && defined (UNIX_PATH_SEPARATOR)
40
# define OUTPUT_PATH_SEPARATOR '/'
42
# define OUTPUT_PATH_SEPARATOR PATH_SEPARATOR
48
#if defined (MSDOS_STYLE_PATH) || defined (VMS)
49
extern const char *const PathDelimiters;
51
extern char *CurrentDirectory;
52
typedef int errorSelection;
53
enum eErrorTypes { FATAL = 1, WARNING = 2, PERROR = 4 };
56
/* Name of file for which status is valid */
59
/* Does file exist? If not, members below do not contain valid data. */
62
/* is file path a symbolic link to another file? */
63
boolean isSymbolicLink;
65
/* Is file (pointed to) a directory? */
68
/* Is file (pointed to) a normal file? */
71
/* Is file (pointed to) executable? */
74
/* Is file (pointed to) setuid? */
77
/* Size of file (pointed to) */
84
extern void freeRoutineResources (void);
85
extern void setExecutableName (const char *const path);
86
extern const char *getExecutableName (void);
87
extern void error (const errorSelection selection, const char *const format, ...) __printf__ (2, 3);
89
/* Memory allocation functions */
90
#ifdef NEED_PROTO_MALLOC
91
extern void *malloc (size_t);
92
extern void *realloc (void *ptr, size_t);
94
extern void *eMalloc (const size_t size);
95
extern void *eCalloc (const size_t count, const size_t size);
96
extern void *eRealloc (void *const ptr, const size_t size);
97
extern void eFree (void *const ptr);
99
/* String manipulation functions */
100
extern int struppercmp (const char *s1, const char *s2);
101
extern int strnuppercmp (const char *s1, const char *s2, size_t n);
103
extern char* strstr (const char *str, const char *substr);
105
extern char* eStrdup (const char* str);
106
extern void toLowerString (char* str);
107
extern void toUpperString (char* str);
108
extern char* newLowerString (const char* str);
109
extern char* newUpperString (const char* str);
111
/* File system functions */
112
extern void setCurrentDirectory (void);
113
extern fileStatus *eStat (const char *const fileName);
114
extern boolean doesFileExist (const char *const fileName);
115
extern boolean isRecursiveLink (const char* const dirName);
116
extern boolean isSameFile (const char *const name1, const char *const name2);
117
#if defined(NEED_PROTO_FGETPOS)
118
extern int fgetpos (FILE *stream, fpos_t *pos);
119
extern int fsetpos (FILE *stream, fpos_t *pos);
121
extern const char *baseFilename (const char *const filePath);
122
extern const char *fileExtension (const char *const fileName);
123
extern boolean isAbsolutePath (const char *const path);
124
extern vString *combinePathAndFile (const char *const path, const char *const file);
125
extern char* absoluteFilename (const char *file);
126
extern char* absoluteDirname (char *file);
127
extern char* relativeFilename (const char *file, const char *dir);
128
extern FILE *tempFile (const char *const mode, char **const pName);
130
#endif /* _ROUTINES_H */
132
/* vi:set tabstop=4 shiftwidth=4: */