Subversion Repositories SvarDOS

Rev

Rev 2054 | Rev 2056 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2054 Rev 2055
Line 87... Line 87...
87
 
87
 
88
 
88
 
89
 
89
 
90
/* Global constants */
90
/* Global constants */
91
#define SERIALLEN 16      /* Defines max size of volume & serial number   */
91
#define SERIALLEN 16      /* Defines max size of volume & serial number   */
92
#define VOLLEN 128
92
#define VOLLEN 16
93
 
93
 
94
#define MAXBUF 1024       /* Must be larger than max file path length     */
-
 
95
char path[MAXBUF];        /* Path to begin search from, default=current   */
94
char path[PATH_MAX];      /* Path to begin search from, default=current   */
96
 
95
 
97
#define MAXPADLEN (MAXBUF*2) /* Must be large enough to hold the maximum padding */
96
#define MAXPADLEN (PATH_MAX*2) /* Must be large enough to hold the maximum padding */
98
/* (MAXBUF/2)*4 == (max path len / min 2chars dirs "?\") * 4chars per padding    */
97
/* (PATH_MAX/2)*4 == (max path len / min 2chars dirs "?\") * 4chars per padding    */
99
 
98
 
100
/* The maximum size any line of text output can be, including room for '\0'*/
99
/* The maximum size any line of text output can be, including room for '\0'*/
101
#define MAXLINE 160        /* Increased to fit two lines for translations  */
100
#define MAXLINE 160        /* Increased to fit two lines for translations  */
102
 
101
 
103
 
102
 
Line 268... Line 267...
268
static int pprintf(const char *msg, ...) {
267
static int pprintf(const char *msg, ...) {
269
  static int lineCnt = -1;
268
  static int lineCnt = -1;
270
  static int lineCol = 0;
269
  static int lineCol = 0;
271
  va_list argptr;
270
  va_list argptr;
272
  int cnt;
271
  int cnt;
273
  char buffer[MAXBUF];
272
  char buffer[MAXLINE];
274
 
273
 
275
  if (lineCnt == -1) lineCnt = rows;
274
  if (lineCnt == -1) lineCnt = rows;
276
 
275
 
277
  va_start(argptr, msg);
276
  va_start(argptr, msg);
278
  cnt = vsprintf(buffer, msg, argptr);
277
  cnt = vsprintf(buffer, msg, argptr);
Line 364... Line 363...
364
 */
363
 */
365
static char *fixPathForDisplay(char *path);
364
static char *fixPathForDisplay(char *path);
366
 
365
 
367
/* Displays error message for invalid path; Does NOT exit */
366
/* Displays error message for invalid path; Does NOT exit */
368
static void showInvalidPath(char *path) {
367
static void showInvalidPath(char *path) {
369
  char partialPath[MAXBUF], dummy[MAXBUF];
368
  char partialPath[PATH_MAX], dummy[PATH_MAX];
370
 
369
 
371
  pprintf("%s\n", path);
370
  pprintf("%s\n", path);
372
  splitpath(path, dummy, partialPath);
371
  splitpath(path, dummy, partialPath);
373
  pprintf(invalidPath, fixPathForDisplay(partialPath));
372
  pprintf(invalidPath, fixPathForDisplay(partialPath));
374
}
373
}
Line 532... Line 531...
532
 * Volume and/or serial # returned may be blank if the path specified
531
 * Volume and/or serial # returned may be blank if the path specified
533
 * does not contain them, or an error retrieving
532
 * does not contain them, or an error retrieving
534
 * (ie UNC paths under DOS), but path is valid.
533
 * (ie UNC paths under DOS), but path is valid.
535
 */
534
 */
536
static void GetVolumeAndSerial(char *volume, char *serial, char *path) {
535
static void GetVolumeAndSerial(char *volume, char *serial, char *path) {
537
  char rootPath[MAXBUF];
536
  char rootPath[PATH_MAX];
538
  char dummy[MAXBUF];
537
  char dummy[PATH_MAX];
539
  union serialNumber {
538
  union serialNumber {
540
    unsigned long serialFull;
539
    unsigned long serialFull;
541
    struct {
540
    struct {
542
      unsigned short a;
541
      unsigned short a;
543
      unsigned short b;
542
      unsigned short b;
Line 595... Line 594...
595
 * and path is valid.
594
 * and path is valid.
596
 */
595
 */
597
static long hasSubdirectories(char *path, DIRDATA *ddata) {
596
static long hasSubdirectories(char *path, DIRDATA *ddata) {
598
  static struct FFDTA findData;
597
  static struct FFDTA findData;
599
  struct FFDTA *hnd;
598
  struct FFDTA *hnd;
600
  static char buffer[MAXBUF];
599
  static char buffer[PATH_MAX + 2];
601
  int hasSubdirs = 0;
600
  int hasSubdirs = 0;
602
 
601
 
603
  /* get the handle to start with (using wildcard spec) */
602
  /* get the handle to start with (using wildcard spec) */
604
  strcpy(buffer, path);
603
  strcpy(buffer, path);
605
  strcat(buffer, "*");
604
  strcat(buffer, "*");
Line 754... Line 753...
754
 * Takes a given path, strips any \ or / that may appear on the end.
753
 * Takes a given path, strips any \ or / that may appear on the end.
755
 * Returns a pointer to its static buffer containing path
754
 * Returns a pointer to its static buffer containing path
756
 * without trailing slash and any necessary display conversions.
755
 * without trailing slash and any necessary display conversions.
757
 */
756
 */
758
static char *fixPathForDisplay(char *path) {
757
static char *fixPathForDisplay(char *path) {
759
  static char buffer[MAXBUF];
758
  static char buffer[PATH_MAX];
760
  int pathlen;
759
  int pathlen;
761
 
760
 
762
  strcpy(buffer, path);
761
  strcpy(buffer, path);
763
  pathlen = strlen(buffer);
762
  pathlen = strlen(buffer);
764
  if (pathlen > 1) {
763
  if (pathlen > 1) {
Line 848... Line 847...
848
 * Returns -1 on error,
847
 * Returns -1 on error,
849
 *          0 if no files, but no errors either,
848
 *          0 if no files, but no errors either,
850
 *      or  1 if files displayed, no errors.
849
 *      or  1 if files displayed, no errors.
851
 */
850
 */
852
static int displayFiles(const char *path, char *padding, int hasMoreSubdirs, DIRDATA *ddata) {
851
static int displayFiles(const char *path, char *padding, int hasMoreSubdirs, DIRDATA *ddata) {
853
  static char buffer[MAXBUF];
852
  char buffer[PATH_MAX + 2];
854
  struct FFDTA entry;   /* current directory entry info    */
853
  struct FFDTA entry;   /* current directory entry info    */
855
  struct FFDTA *dir;    /* Current directory entry working with      */
854
  struct FFDTA *dir;    /* Current directory entry working with      */
856
  unsigned long filesShown = 0;
855
  unsigned long filesShown = 0;
857
 
856
 
858
  /* get handle for files in current directory (using wildcard spec) */
857
  /* get handle for files in current directory (using wildcard spec) */
Line 960... Line 959...
960
 * passed to findnextsubdir to find subsequent subdirectories.
959
 * passed to findnextsubdir to find subsequent subdirectories.
961
 * Returns NULL on error.
960
 * Returns NULL on error.
962
 * currentpath must end in \
961
 * currentpath must end in \
963
 */
962
 */
964
static struct FFDTA *findFirstSubdir(char *currentpath, char *subdir, char *dsubdir) {
963
static struct FFDTA *findFirstSubdir(char *currentpath, char *subdir, char *dsubdir) {
965
  static char buffer[MAXBUF];
964
  char buffer[PATH_MAX];
966
  struct FFDTA *dir;         /* Current directory entry working with      */
965
  struct FFDTA *dir;         /* Current directory entry working with      */
967
 
966
 
968
  /* get handle for files in current directory (using wildcard spec) */
967
  /* get handle for files in current directory (using wildcard spec) */
969
  strcpy(buffer, currentpath);
968
  strcpy(buffer, currentpath);
970
  strcat(buffer, "*");
969
  strcat(buffer, "*");
Line 1009... Line 1008...
1009
 * Returns the count of subdirs in initialpath.
1008
 * Returns the count of subdirs in initialpath.
1010
 */
1009
 */
1011
static long traverseTree(char *initialpath) {
1010
static long traverseTree(char *initialpath) {
1012
  long subdirsInInitialpath;
1011
  long subdirsInInitialpath;
1013
  char padding[MAXPADLEN] = "";
1012
  char padding[MAXPADLEN] = "";
1014
  char subdir[MAXBUF];
1013
  char subdir[PATH_MAX];
1015
  char dsubdir[MAXBUF];
1014
  char dsubdir[PATH_MAX];
1016
  SUBDIRINFO *sdi;
1015
  SUBDIRINFO *sdi;
1017
 
1016
 
1018
  STACK s;
1017
  STACK s;
1019
  stackDefaults(&s);
1018
  stackDefaults(&s);
1020
  stackInit(&s);
1019
  stackInit(&s);