diff options
Diffstat (limited to 'utility.h')
-rw-r--r-- | utility.h | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/utility.h b/utility.h new file mode 100644 index 000000000..7b275baa4 --- /dev/null +++ b/utility.h | |||
@@ -0,0 +1,73 @@ | |||
1 | /* | ||
2 | * Utility routines. | ||
3 | * | ||
4 | * Copyright (C) 1998 by Erik Andersen <andersee@debian.org> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
14 | * General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
19 | * | ||
20 | * Based in part on code from sash, Copyright (c) 1999 by David I. Bell | ||
21 | * Permission has been granted to redistribute this code under the GPL. | ||
22 | * | ||
23 | */ | ||
24 | |||
25 | #include "internal.h" | ||
26 | #include <stdio.h> | ||
27 | #include <string.h> | ||
28 | #include <errno.h> | ||
29 | #include <fcntl.h> | ||
30 | //#include <sys/types.h> | ||
31 | //#include <sys/stat.h> | ||
32 | #include <dirent.h> | ||
33 | #include <time.h> | ||
34 | #include <utime.h> | ||
35 | |||
36 | /* | ||
37 | * A chunk of data. | ||
38 | * Chunks contain data which is allocated as needed, but which is | ||
39 | * not freed until all of the data needs freeing, such as at | ||
40 | * the beginning of the next command. | ||
41 | */ | ||
42 | typedef struct chunk CHUNK; | ||
43 | #define CHUNK_INIT_SIZE 4 | ||
44 | |||
45 | struct chunk { | ||
46 | CHUNK *next; | ||
47 | char data[CHUNK_INIT_SIZE]; /* actually of varying length */ | ||
48 | }; | ||
49 | |||
50 | const char *modeString(int mode); | ||
51 | const char *timeString(time_t timeVal); | ||
52 | BOOL isDirectory(const char *name); | ||
53 | BOOL isDevice(const char *name); | ||
54 | BOOL copyFile(const char *srcName, const char *destName, BOOL setModes); | ||
55 | const char *buildName(const char *dirName, const char *fileName); | ||
56 | BOOL match(const char *text, const char *pattern); | ||
57 | BOOL makeArgs(const char *cmd, int *retArgc, const char ***retArgv); | ||
58 | BOOL makeString(int argc, const char **argv, char *buf, int bufLen); | ||
59 | char *getChunk(int size); | ||
60 | char *chunkstrdup(const char *str); | ||
61 | void freeChunks(void); | ||
62 | int fullWrite(int fd, const char *buf, int len); | ||
63 | int fullRead(int fd, char *buf, int len); | ||
64 | int | ||
65 | recursive(const char *fileName, BOOL followLinks, const char *pattern, | ||
66 | int (*fileAction) (const char *fileName, | ||
67 | const struct stat * statbuf), | ||
68 | int (*dirAction) (const char *fileName, | ||
69 | const struct stat * statbuf)); | ||
70 | |||
71 | int nameSort(const void *p1, const void *p2); | ||
72 | int expandWildCards(const char *fileNamePattern, | ||
73 | const char ***retFileTable); | ||