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