Changeset 44 for trunk/src/reglookup.c


Ignore:
Timestamp:
08/06/05 09:47:07 (19 years ago)
Author:
tim
Message:

minor changes to command line option parsing

fixed some warnings with quote_string

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/reglookup.c

    r43 r44  
    5858 */
    5959static char* quote_buffer(const unsigned char* str,
    60                           unsigned int len, char* special)
     60                          unsigned int len, const char* special)
    6161{
    6262  unsigned int i;
     
    9494 * character.
    9595 */
    96 static char* quote_string(const char* str, char* special)
     96static char* quote_string(const char* str, const char* special)
    9797{
    9898  unsigned int len;
     
    785785  fprintf(stderr, "Options:\n");
    786786  fprintf(stderr, "\t-v\t sets verbose mode.\n");
    787   fprintf(stderr, "\t-s\t prints security descriptors.\n");
     787  fprintf(stderr, "\t-s\t enables security descriptor output.\n");
     788  fprintf(stderr, "\t-S\t disables security descriptor output. (default)\n");
    788789  fprintf(stderr, "\t-p\t restrict output to elements below this path.\n");
    789790  fprintf(stderr, "\t-t\t restrict results to this specific data type.\n");
     
    799800  REGF_NK_REC* root;
    800801  int retr_path_ret;
    801   uint32 argi;
     802  uint32 argi, arge;
    802803
    803804  /* Process command line arguments */
     
    805806  {
    806807    usage();
    807     bailOut(1, "ERROR: Requires 1 argument.\n");
     808    bailOut(1, "ERROR: Requires at least one argument.\n");
    808809  }
    809810 
    810   for(argi = 1; argi < argc; argi++)
     811  arge = argc-1;
     812  for(argi = 1; argi < arge; argi++)
    811813  {
    812814    if (strcmp("-p", argv[argi]) == 0)
    813815    {
    814       if(++argi > argc)
     816      if(++argi >= arge)
    815817      {
    816818        usage();
     
    824826    else if (strcmp("-t", argv[argi]) == 0)
    825827    {
    826       if(++argi > argc)
     828      if(++argi >= arge)
    827829      {
    828830        usage();
     
    839841    else if (strcmp("-s", argv[argi]) == 0)
    840842      print_security = true;
     843    else if (strcmp("-S", argv[argi]) == 0)
     844      print_security = false;
    841845    else if (strcmp("-v", argv[argi]) == 0)
    842846      print_verbose = true;
    843     else if (argv[argi][0] == '-')
     847    else
    844848    {
    845849      usage();
     
    847851      bailOut(1, "");
    848852    }
    849     else
    850     {
    851       if((registry_file = strdup(argv[argi])) == NULL)
    852         bailOut(2, "ERROR: Memory allocation problem.\n");
    853     }
    854   }
     853  }
     854  if((registry_file = strdup(argv[argi])) == NULL)
     855    bailOut(2, "ERROR: Memory allocation problem.\n");
    855856
    856857  f = regfio_open(registry_file);
Note: See TracChangeset for help on using the changeset viewer.