Diff of /src/iso-info.c [e74fc3] .. [16bdbf]  Maximize  Restore

  Switch to unified view

a/src/iso-info.c b/src/iso-info.c
1
/*
1
/*
2
    $Id: iso-info.c,v 1.30 2005/03/18 12:56:00 rocky Exp $
2
    $Id: iso-info.c,v 1.31 2005/10/05 09:48:12 rocky Exp $
3
3
4
    Copyright (C) 2004, 2005 Rocky Bernstein <rocky@panix.com>
4
    Copyright (C) 2004, 2005 Rocky Bernstein <rocky@panix.com>
5
5
6
    This program is free software; you can redistribute it and/or modify
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
7
    it under the terms of the GNU General Public License as published by
...
...
45
#endif
45
#endif
46
#include <sys/types.h>
46
#include <sys/types.h>
47
47
48
#include <errno.h>
48
#include <errno.h>
49
49
50
#include <getopt.h>
50
51
51
#if 0
52
#if 0
52
#define STRONG "\033[1m"
53
#define STRONG "\033[1m"
53
#define NORMAL "\033[0m"
54
#define NORMAL "\033[0m"
54
#else
55
#else
...
...
71
  int            print_iso9660_short;
72
  int            print_iso9660_short;
72
} opts;
73
} opts;
73
     
74
     
74
/* Configuration option codes */
75
/* Configuration option codes */
75
enum {
76
enum {
76
  
77
  OP_HANDLED = 0,
78
79
  OP_USAGE,
80
77
  /* These are the remaining configuration options */
81
  /* These are the remaining configuration options */
78
  OP_VERSION,  
82
  OP_VERSION,  
79
  
83
  
80
};
84
};
81
85
82
char *temp_str;
86
char *temp_str;
83
87
84
88
85
/* Parse a all options. */
89
/* Parse a all options. */
86
static bool
90
static bool
87
parse_options (int argc, const char *argv[])
91
parse_options (int argc, char *argv[])
88
{
92
{
89
  int opt;
93
  int opt;
90
94
91
  struct poptOption optionsTable[] = {
95
  const char* helpText =
92
    {"debug",       'd', POPT_ARG_INT, &opts.debug_level, 0,
96
    "Usage: %s [OPTION...]\n"
93
     "Set debugging to LEVEL"},
97
    "  -d, --debug=INT        Set debugging to LEVEL\n"
94
    
98
    "  -i, --input[=FILE]     Filename to read ISO-9960 image from\n"
95
    {"input", 'i', POPT_ARG_STRING|POPT_ARGFLAG_OPTIONAL, &source_name, 0,
96
     "Filename to read ISO-9960 image from", "FILE"},
97
    
98
    {'\0',    'f', POPT_ARG_NONE, &opts.print_iso9660_short, 0,
99
     "Generate output similar to 'find . -print'"},
99
    "  -f                     Generate output similar to 'find . -print'\n"
100
100
    "  -l, --iso9660          Generate output similar to 'ls -lR'\n"
101
    {"iso9660",  'l', POPT_ARG_NONE, &opts.print_iso9660, 0,
101
    "  --no-header            Don't display header and copyright (for regression\n"
102
     "Generate output similar to 'ls -lR'"},
102
    "                         testing)\n"
103
    
104
    {"no-header", '\0', POPT_ARG_NONE, &opts.no_header, 
105
     0, "Don't display header and copyright (for regression testing)"},
106
107
#ifdef HAVE_JOLIET    
103
#ifdef HAVE_JOLIET    
108
    {"no-joliet", '\0', POPT_ARG_NONE, &opts.no_joliet, 
104
    "  --no-joliet            Don't use Joliet-extension information\n"
109
     0, "Don't use Joliet-extension information"},
110
#endif /*HAVE_JOLIET*/
105
#endif /*HAVE_JOLIET*/
111
    
106
    "  --no-rock-ridge        Don't use Rock-Ridge-extension information\n"
112
    {"no-rock-ridge", '\0', POPT_ARG_NONE, &opts.no_rock_ridge, 
107
    "  --no-xa                Don't use XA-extension information\n"
113
     0, "Don't use Rock-Ridge-extension information"},
108
    "  -q, --quiet            Don't produce warning output\n"
114
115
    {"no-xa", '\0', POPT_ARG_NONE, &opts.no_xa, 
116
     0, "Don't use XA-extension information"},
117
118
    {"quiet",       'q', POPT_ARG_NONE, &opts.silent, 0,
119
     "Don't produce warning output" },
120
    
121
    {"version", 'V', POPT_ARG_NONE, &opts.version_only, 0,
122
     "display version and copyright information and exit"},
109
    "  -V, --version          display version and copyright information and exit\n"
123
    POPT_AUTOHELP {NULL, 0, 0, NULL, 0}
110
    "\n"
111
    "Help options:\n"
112
    "  -?, --help             Show this help message\n"
113
    "  --usage                Display brief usage message\n";
114
115
  const char* usageText =
116
    "Usage: %s [-d|--debug INT] [-i|--input FILE] [-f] [-l|--iso9660]\n"
117
    "        [--no-header] [--no-joliet] [--no-rock-ridge] [--no-xa] [-q|--quiet]\n"
118
    "        [-V|--version] [-?|--help] [--usage]\n";
119
120
  const char* optionsString = "d:i::flqV?";
121
  struct option optionsTable[] = {
122
    {"debug", required_argument, NULL, 'd'},
123
    {"input", optional_argument, NULL, 'i'},
124
    {"iso9660", no_argument, NULL, 'l'},
125
    {"no-header", no_argument, &opts.no_header, 1 },
126
#ifdef HAVE_JOLIET    
127
    {"no-joliet", no_argument, &opts.no_joliet, 1 },
128
#endif /*HAVE_JOLIET*/
129
    {"no-rock-ridge", no_argument, &opts.no_rock_ridge, 1 },
130
    {"no-xa", no_argument, &opts.no_xa, 1 },
131
    {"quiet", no_argument, NULL, 'q'},
132
    {"version", no_argument, NULL, 'V'},
133
134
    {"help", no_argument, NULL, '?' },
135
    {"usage", no_argument, NULL, OP_USAGE },
136
    { NULL, 0, NULL, 0 }
124
  };
137
  };
125
  poptContext optCon = poptGetContext (NULL, argc, argv, optionsTable, 0);
126
138
127
  program_name = strrchr(argv[0],'/');
139
  program_name = strrchr(argv[0],'/');
128
  program_name = program_name ? strdup(program_name+1) : strdup(argv[0]);
140
  program_name = program_name ? strdup(program_name+1) : strdup(argv[0]);
129
141
130
  while ((opt = poptGetNextOpt (optCon)) >= 0) {
142
  while ((opt = getopt_long(argc, argv, optionsString, optionsTable, NULL)) >= 0) {
131
    ;
143
    switch (opt)
132
  }
144
      {
133
  if (opt < -1) {
145
      case 'd': opts.debug_level = atoi(optarg); break;
134
    /* an error occurred during option processing */
146
      case 'i': if (optarg != NULL) source_name = strdup(optarg); break;
135
    report(stderr, "%s: %s\n",
147
      case 'f': opts.print_iso9660_short = 1; break;
136
      poptBadOption(optCon, POPT_BADOPTION_NOALIAS),
148
      case 'l': opts.print_iso9660 = 1; break;
137
      poptStrerror(opt));
149
      case 'q': opts.silent = 1; break;
150
      case 'V': opts.version_only = 1; break;
151
  
152
      case '?':
153
        fprintf(stderr, helpText, program_name);
138
    free(program_name);
154
        free(program_name);
139
    exit (EXIT_FAILURE);
155
        exit(EXIT_FAILURE);
140
  }
156
        break;
141
  {
157
142
    const char *remaining_arg = poptGetArg(optCon);
158
      case OP_USAGE:
143
    if ( remaining_arg != NULL) {
159
        fprintf(stderr, usageText, program_name);
144
      if ( (poptGetArgs(optCon)) != NULL) {
145
  report( stderr, "%s: Source specified in previously %s and %s\n", 
146
          program_name, source_name, remaining_arg );
147
  poptFreeContext(optCon);
148
  free(program_name);
160
        free(program_name);
149
  exit (EXIT_FAILURE);
161
        exit(EXIT_FAILURE);
162
        break;
163
164
      case OP_HANDLED:
165
  break;
150
      }
166
      }
151
      source_name = strdup(remaining_arg);
167
  }
168
169
  if (optind < argc) {
170
    const char *remaining_arg = argv[optind++];
171
    if ( optind < argc ) {
172
      report( stderr, "%s: Source specified in previously %s and %s\n", 
173
        program_name, source_name, remaining_arg );
174
      free(program_name);
175
      exit (EXIT_FAILURE);
152
    }
176
    }
153
  }
177
    source_name = strdup(remaining_arg);
154
  
178
  }
155
  poptFreeContext(optCon);
179
  
156
  return true;
180
  return true;
157
}
181
}
158
182
159
/* CDIO logging routines */
183
/* CDIO logging routines */
160
184
...
...
284
  psz_str = NULL;             
308
  psz_str = NULL;             
285
309
286
/* ------------------------------------------------------------------------ */
310
/* ------------------------------------------------------------------------ */
287
311
288
int
312
int
289
main(int argc, const char *argv[])
313
main(int argc, char *argv[])
290
{
314
{
291
315
292
  iso9660_t           *p_iso=NULL;
316
  iso9660_t           *p_iso=NULL;
293
  iso_extension_mask_t iso_extension_mask = ISO_EXTENSION_ALL;
317
  iso_extension_mask_t iso_extension_mask = ISO_EXTENSION_ALL;
294
      
318
      

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks