2008-04-16 Johannes Schmid <jhs@gnome.org>
[anjuta-git-plugin.git] / tagmanager / routines.h
blobce07657aed1820afce915b6e0820e368c8fcb017
1 /*
2 * $Id$
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
11 #ifndef _ROUTINES_H
12 #define _ROUTINES_H
15 * INCLUDE FILES
17 #include "general.h" /* must always come first */
20 * MACROS
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))
27 * Portability macros
29 #ifndef PATH_SEPARATOR
30 # if defined (MSDOS_STYLE_PATH)
31 # define PATH_SEPARATOR '\\'
32 # elif defined (QDOS)
33 # define PATH_SEPARATOR '_'
34 # else
35 # define PATH_SEPARATOR '/'
36 # endif
37 #endif
39 #if defined (MSDOS_STYLE_PATH) && defined (UNIX_PATH_SEPARATOR)
40 # define OUTPUT_PATH_SEPARATOR '/'
41 #else
42 # define OUTPUT_PATH_SEPARATOR PATH_SEPARATOR
43 #endif
46 * DATA DECLARATIONS
48 #if defined (MSDOS_STYLE_PATH) || defined (VMS)
49 extern const char *const PathDelimiters;
50 #endif
51 extern char *CurrentDirectory;
52 typedef int errorSelection;
53 enum eErrorTypes { FATAL = 1, WARNING = 2, PERROR = 4 };
55 typedef struct {
56 /* Name of file for which status is valid */
57 char* name;
59 /* Does file exist? If not, members below do not contain valid data. */
60 boolean exists;
62 /* is file path a symbolic link to another file? */
63 boolean isSymbolicLink;
65 /* Is file (pointed to) a directory? */
66 boolean isDirectory;
68 /* Is file (pointed to) a normal file? */
69 boolean isNormalFile;
71 /* Is file (pointed to) executable? */
72 boolean isExecutable;
74 /* Is file (pointed to) setuid? */
75 boolean isSetuid;
77 /* Size of file (pointed to) */
78 unsigned long size;
79 } fileStatus;
82 * FUNCTION PROTOTYPES
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);
93 #endif
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);
102 #ifndef HAVE_STRSTR
103 extern char* strstr (const char *str, const char *substr);
104 #endif
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);
120 #endif
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: */