1 /*
2 *   Copyright (c) 2002, Darren Hiebert
3 *
4 *   This source code is released for free distribution under the terms of the
5 *   GNU General Public License version 2 or (at your option) any later version.
6 *
7 *   Main part private interface to routines.c
8 */
9 #ifndef CTAGS_MAIN_ROUTINES_PRIVATE_H
10 #define CTAGS_MAIN_ROUTINES_PRIVATE_H
11 
12 /*
13 *   INCLUDE FILES
14 */
15 #include "general.h"  /* must always come first */
16 #include "mio.h"
17 #include "portable-dirent_p.h"
18 
19 /*
20  *  Portability macros
21  */
22 #ifndef PATH_SEPARATOR
23 # if defined (MSDOS_STYLE_PATH)
24 #  define PATH_SEPARATOR '\\'
25 # else
26 #  define PATH_SEPARATOR '/'
27 # endif
28 #endif
29 
30 #if defined (MSDOS_STYLE_PATH)
31 # define OUTPUT_PATH_SEPARATOR	'/'
32 #else
33 # define OUTPUT_PATH_SEPARATOR	PATH_SEPARATOR
34 #endif
35 
36 /*
37 *   DATA DECLARATIONS
38 */
39 extern char *CurrentDirectory;
40 #if defined (MSDOS_STYLE_PATH)
41 extern const char *const PathDelimiters;
42 #endif
43 
44 typedef struct {
45 		/* Name of file for which status is valid */
46 	char* name;
47 
48 		/* Does file exist? If not, members below do not contain valid data. */
49 	bool exists;
50 
51 		/* is file path a symbolic link to another file? */
52 	bool isSymbolicLink;
53 
54 		/* Is file (pointed to) a directory? */
55 	bool isDirectory;
56 
57 		/* Is file (pointed to) a normal file? */
58 	bool isNormalFile;
59 
60 		/* Is file (pointed to) executable? */
61 	bool isExecutable;
62 
63 		/* Is file (pointed to) setuid? */
64 	bool isSetuid;
65 
66 		/* Is file (pointed to) setgid? */
67 	bool isSetgid;
68 
69 		/* Size of file (pointed to) */
70 	unsigned long size;
71 
72 		/* The last modified time */
73 	time_t mtime;
74 } fileStatus;
75 
76 /*
77 *   FUNCTION PROTOTYPES
78 */
79 extern void freeRoutineResources (void);
80 extern void setExecutableName (const char *const path);
81 
82 /* File system functions */
83 extern const char *getExecutableName (void);
84 extern const char *getExecutablePath (void);
85 extern void setCurrentDirectory (void);
86 extern fileStatus *eStat (const char *const fileName);
87 extern void eStatFree (fileStatus *status);
88 extern bool doesFileExist (const char *const fileName);
89 extern bool doesExecutableExist (const char *const fileName);
90 extern bool isRecursiveLink (const char* const dirName);
91 extern bool isSameFile (const char *const name1, const char *const name2);
92 extern bool isAbsolutePath (const char *const path);
93 extern char *combinePathAndFile (const char *const path, const char *const file);
94 extern char* absoluteFilename (const char *file);
95 extern char* absoluteDirname (char *file);
96 extern char* relativeFilename (const char *file, const char *dir);
97 extern MIO *tempFile (const char *const mode, char **const pName);
98 
99 extern char* baseFilenameSansExtensionNew (const char *const fileName, const char *const templateExt);
100 
101 #endif  /* CTAGS_MAIN_ROUTINES_PRIVATE_H */
102