Subversion Repositories SvarDOS

Rev

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

Rev 2063 Rev 2064
Line 85... Line 85...
85
 
85
 
86
/* Global constants */
86
/* Global constants */
87
#define SERIALLEN 16      /* Defines max size of volume & serial number   */
87
#define SERIALLEN 16      /* Defines max size of volume & serial number   */
88
#define VOLLEN 16
88
#define VOLLEN 16
89
 
89
 
90
char path[PATH_MAX];      /* Path to begin search from, default=current   */
90
static char path[PATH_MAX];   /* Path to begin search from, default=current   */
91
 
91
 
92
#define MAXPADLEN (PATH_MAX*2) /* Must be large enough to hold the maximum padding */
92
#define MAXPADLEN (PATH_MAX*2) /* Must be large enough to hold the maximum padding */
93
/* (PATH_MAX/2)*4 == (max path len / min 2chars dirs "?\") * 4chars per padding    */
93
/* (PATH_MAX/2)*4 == (max path len / min 2chars dirs "?\") * 4chars per padding    */
94
 
94
 
95
/* The maximum size any line of text output can be, including room for '\0'*/
95
/* The maximum size any line of text output can be, including room for '\0'*/
Line 138... Line 138...
138
char pathListingWithLabel[MAXLINE] = "Directory PATH listing for Volume %s\n"; /* %s for label */
138
char pathListingWithLabel[MAXLINE] = "Directory PATH listing for Volume %s\n"; /* %s for label */
139
char serialNumber[MAXLINE] = "Volume serial number is %s\n"; /* Must include %s for serial #   */
139
char serialNumber[MAXLINE] = "Volume serial number is %s\n"; /* Must include %s for serial #   */
140
char noSubDirs[MAXLINE] = "No subdirectories exist\n\n";
140
char noSubDirs[MAXLINE] = "No subdirectories exist\n\n";
141
char pauseMsg[MAXLINE]  = " --- Press any key to continue ---\n";
141
char pauseMsg[MAXLINE]  = " --- Press any key to continue ---\n";
142
 
142
 
143
/* Option Processing - parseArguments [Set 8]      */
-
 
144
char optionchar1 = '/';  /* Primary character used to determine option follows  */
-
 
145
char optionchar2 = '-';  /* Secondary character used to determine option follows  */
-
 
146
const char OptShowFiles[2] = { 'F', 'f' };  /* Show files */
-
 
147
const char OptUseASCII[2]  = { 'A', 'a' };  /* Use ASCII only */
-
 
148
const char OptVersion[2]   = { 'V', 'v' };  /* Version information */
-
 
149
const char OptPause[2]     = { 'P', 'p' };  /* Pause after each page (screenfull) */
-
 
150
const char OptDisplay[2]   = { 'D', 'd' };  /* modify Display settings */
-
 
151
 
143
 
152
 
144
 
153
/* Procedures */
145
/* Procedures */
154
 
146
 
155
 
147
 
Line 390... Line 382...
390
  splitpath(path, dummy, partialPath);
382
  splitpath(path, dummy, partialPath);
391
  pprintf(invalidPath, fixPathForDisplay(partialPath));
383
  pprintf(invalidPath, fixPathForDisplay(partialPath));
392
}
384
}
393
 
385
 
394
/* Displays error message for out of memory; Does NOT exit */
386
/* Displays error message for out of memory; Does NOT exit */
395
static void showOutOfMemory(char *path) {
387
static void showOutOfMemory(const char *path) {
396
  pprintf(outOfMemory, path);
388
  pprintf(outOfMemory, path);
397
}
389
}
398
 
390
 
399
 
391
 
400
/**
392
/**
Line 451... Line 443...
451
      strcpy(path, src);
443
      strcpy(path, src);
452
    }
444
    }
453
    else /* path only starting at root directory */
445
    else /* path only starting at root directory */
454
    {
446
    {
455
      /* no drive, so set path to same as fullpath */
447
      /* no drive, so set path to same as fullpath */
456
      strcpy(drive, "");
448
      drive[0] = 0;
457
      strcpy(path, fullpath);
449
      strcpy(path, fullpath);
458
    }
450
    }
459
  }
451
  }
460
  else
452
  else
461
  {
453
  {
Line 474... Line 466...
474
      strcpy(path, src);
466
      strcpy(path, src);
475
    }
467
    }
476
    else
468
    else
477
    {
469
    {
478
      /* no drive, so set path to same as fullpath */
470
      /* no drive, so set path to same as fullpath */
479
      strcpy(drive, "");
471
      drive[0] = 0;
480
      strcpy(path, fullpath);
472
      strcpy(path, fullpath);
481
    }
473
    }
482
  }
474
  }
483
}
475
}
484
 
476
 
485
 
477
 
486
/* Parses the command line and sets global variables. */
478
/* Parses the command line and sets global variables. */
487
static void parseArguments(int argc, char *argv[]) {
479
static void parseArguments(int argc, char **argv) {
488
  int i;     /* temp loop variable */
480
  int i;
489
 
481
 
490
  /* if no drive specified on command line, use current */
482
  /* if no drive specified on command line, use current */
491
  if (truename(path, ".") != 0) showInvalidDrive();
483
  if (truename(path, ".") != 0) showInvalidDrive();
492
 
484
 
493
  for (i = 1; i < argc; i++)
485
  for (i = 1; i < argc; i++) {
494
  {
-
 
495
    /* Check if user is giving an option or drive/path */
-
 
496
    if ((argv[i][0] == optionchar1) || (argv[i][0] == optionchar2) )
-
 
497
    {
-
 
498
      /* check multi character options 1st */
-
 
499
      if ((argv[i][1] == OptDisplay[0]) || (argv[i][1] == OptDisplay[1]))
-
 
500
      {
-
 
501
        switch (argv[i][2] & 0xDF)
-
 
502
        {
-
 
503
          case 'A' :       /*  /DA  display attributes */
-
 
504
            dspAttr = 1;
-
 
505
            break;
-
 
506
          case 'F' :       /*  /DF  display filesizes  */
-
 
507
            dspSize = 1;
-
 
508
            break;
-
 
509
          case 'H' :       /*  /DH  display hidden & system files (normally not shown) */
-
 
510
            dspAll = 1;
-
 
511
            break;
-
 
512
          case 'R' :       /*  /DR  display results at end */
-
 
513
            dspSumDirs = 1;
-
 
514
            break;
-
 
515
          default:
-
 
516
            showInvalidUsage(argv[i]);
-
 
517
        }
-
 
518
      }
-
 
519
      else /* a 1 character option (or invalid) */
-
 
520
      {
-
 
521
        if (argv[i][2] != '\0')
-
 
522
          showInvalidUsage(argv[i]);
-
 
523
 
486
 
524
        /* Must check both uppercase and lowercase                        */
487
    /* Check if user is giving an option or drive/path */
525
        if ((argv[i][1] == OptShowFiles[0]) || (argv[i][1] == OptShowFiles[1]))
488
    if ((argv[i][0] != '/') && (argv[i][0] != '-') ) {
526
          showFiles = SHOWFILESON; /* set file display flag appropriately */
489
      if (truename(path, argv[i]) != 0) showInvalidPath(argv[i]);
-
 
490
      continue;
-
 
491
    }
-
 
492
 
527
        else if ((argv[i][1] == OptUseASCII[0]) || (argv[i][1] == OptUseASCII[1]))
493
    /* must be an option then */
528
          charSet = ASCIICHARS;    /* set charset flag appropriately      */
494
    /* check multi character options 1st */
-
 
495
    if (argv[i][1] & 0xDF == 'D') {
529
        else if (argv[i][1] == '?')
496
      switch(argv[i][2] & 0xDF) {
530
          showUsage();             /* show usage info and exit            */
497
        case 'A' :       /*  /DA  display attributes */
531
        else if ((argv[i][1] == OptVersion[0]) || (argv[i][1] == OptVersion[1]))
498
          dspAttr = 1;
-
 
499
          break;
532
          showVersionInfo();       /* show version info and exit          */
500
        case 'F' :       /*  /DF  display filesizes  */
-
 
501
          dspSize = 1;
-
 
502
          break;
533
        else if ((argv[i][1] == OptPause[0]) || (argv[i][1] == OptPause[1]))
503
        case 'H' :       /*  /DH  display hidden & system files (normally not shown) */
-
 
504
          dspAll = 1;
-
 
505
          break;
534
          pause = PAUSE;     /* wait for keypress after each page (pause) */
506
        case 'R' :       /*  /DR  display results at end */
535
        else /* Invalid or unknown option */
507
          dspSumDirs = 1;
-
 
508
          break;
-
 
509
        default:
536
          showInvalidUsage(argv[i]);
510
          showInvalidUsage(argv[i]);
537
      }
511
      }
-
 
512
      continue;
-
 
513
    }
-
 
514
 
538
    } else { /* should be a drive/path */
515
    /* a 1 character option (or invalid) */
539
      if (truename(path, argv[i]) != 0) showInvalidDrive();
516
    if (argv[i][2] != 0) showInvalidUsage(argv[i]);
-
 
517
 
-
 
518
    switch(argv[i][1] & 0xDF) { /* upcase */
-
 
519
      case 'F': /* show files */
-
 
520
        showFiles = SHOWFILESON; /* set file display flag appropriately */
-
 
521
        break;
-
 
522
      case 'A': /* use ASCII only (7-bit) */
-
 
523
        charSet = ASCIICHARS;    /* set charset flag appropriately      */
-
 
524
        break;
-
 
525
      case 'V': /* Version information */
-
 
526
        showVersionInfo();       /* show version info and exit          */
-
 
527
        break;
-
 
528
      case 'P': /* wait for keypress after each page (pause) */
-
 
529
        pause = PAUSE;
-
 
530
        break;
-
 
531
      case '?':
-
 
532
        showUsage();             /* show usage info and exit            */
-
 
533
        break;
-
 
534
      default: /* Invalid or unknown option */
-
 
535
        showInvalidUsage(argv[i]);
540
    }
536
    }
541
  }
537
  }
542
}
538
}
543
 
539
 
544
 
540
 
Line 1083... Line 1079...
1083
static void FixOptionText(void) {
1079
static void FixOptionText(void) {
1084
  char buffer[MAXLINE];  /* sprintf can have problems with src==dest */
1080
  char buffer[MAXLINE];  /* sprintf can have problems with src==dest */
1085
 
1081
 
1086
  /* Handle %c for options within messages using Set 8 */
1082
  /* Handle %c for options within messages using Set 8 */
1087
  strcpy(buffer, treeUsage);
1083
  strcpy(buffer, treeUsage);
1088
  sprintf(treeUsage, buffer, optionchar1, OptShowFiles[0], optionchar1, OptUseASCII[0]);
1084
  sprintf(treeUsage, buffer, '/', 'f', '/', 'a');
1089
  strcpy(buffer, treeFOption);
1085
  strcpy(buffer, treeFOption);
1090
  sprintf(treeFOption, buffer, optionchar1, OptShowFiles[0]);
1086
  sprintf(treeFOption, buffer, '/', 'f');
1091
  strcpy(buffer, treeAOption);
1087
  strcpy(buffer, treeAOption);
1092
  sprintf(treeAOption, buffer, optionchar1, OptUseASCII[0]);
1088
  sprintf(treeAOption, buffer, '/', 'a');
1093
  strcpy(buffer, useTreeHelp);
1089
  strcpy(buffer, useTreeHelp);
1094
  sprintf(useTreeHelp, buffer, optionchar1);
1090
  sprintf(useTreeHelp, buffer, '/');
1095
}
1091
}
1096
 
1092
 
1097
 
1093
 
1098
/* Loads all messages from the message catalog. */
1094
/* Loads all messages from the message catalog. */
1099
static void loadAllMessages(void) {
1095
static void loadAllMessages(void) {