/[darkstattype]/trunk/darkstattype.c
ViewVC logotype

Diff of /trunk/darkstattype.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 13 by trond, 2014-03-21T16:59:56Z Revision 14 by trond, 2014-03-21T18:35:50Z
# Line 66  int main(int argc, char **argv) Line 66  int main(int argc, char **argv)
66        case 'v':        case 'v':
67          show_version();          show_version();
68          break;          break;
69    
70        case '?':        case '?':
71          /*FALLTHROUGH*/          /*FALLTHROUGH*/
72        default:        default:
73          fprintf(stderr, "%s: illegal option -%c\n\n", progname, optopt);          fprintf(stderr, "%s: illegal option -%c\n\n", progname, optopt);
74          show_usage(EXIT_FAILURE);          show_usage(EXIT_FAILURE);
75          break;          break;
76      } // switch      } // switch
77    }  // while    }  // while
78    argc -= optind;    argc -= optind;
79    argv += optind;    argv += optind;
80    
81    if (argv[0] == NULL) {    if (*argv == NULL) {
82      fprintf(stderr, "%s: missing filename\n\n", progname);      fprintf(stderr, "%s: missing filename\n\n", progname);
83      show_usage(EXIT_FAILURE);      show_usage(EXIT_FAILURE);
84    } // if    } // if
85    
86    filename = argv[0];    while (*argv != NULL) {
87        filename = *argv;
88    
89    decode_file();      decode_file();
90    
91        argv++;
92      } // while
93    
94    return EXIT_SUCCESS;    return EXIT_SUCCESS;
95  } // main()  } // main()
96    
97  void show_usage(int exitcode)  void show_usage(int exitcode)
98  {  {
99    fprintf((exitcode == EXIT_SUCCESS) ? stdout : stderr,    fprintf((exitcode == EXIT_SUCCESS) ? stdout : stderr,
100      "Usage: %s [-f] [-h] [-v] filename\n"      "Usage: %s [-f] [-h] [-v] filename ...\n"
101      " E.g.: %s darkstat.db\n\n"      " E.g.: %s darkstat.db\n\n"
102    
103      "Options:\n"      "Options:\n"
104      "-f\tToggle follow strict specification, default is false.\n"      "-f\tToggle follow strict specification, default is false.\n"
105      "-h\tShow this help message and exit.\n"      "-h\tShow this help message and exit.\n"
106      "-v\tShow version and copyright and exit.\n",      "-v\tShow version and copyright and exit.\n",
107      progname, progname);      progname, progname);
108    
109    exit(exitcode);    exit(exitcode);
110  } // show_usage()  } // show_usage()
111    
112  void show_version(void)  void show_version(void)
113  {  {
114    puts("darkstattype 1.0");    puts("darkstattype 1.0");
115    puts("$Ximalas$");    puts("$Ximalas$");
# Line 196  void decode_file(void) Line 200  void decode_file(void)
200        printf("Section header host_db v1 0x%x\n", sectionheader);        printf("Section header host_db v1 0x%x\n", sectionheader);
201        decode_host_db_v1();        decode_host_db_v1();
202      } // if      } // if
203      else if (sectionheader == GRAPH_DB_V1) {      else if (sectionheader == GRAPH_DB_V1) {
204        print_indentation();        print_indentation();
205        printf("Section header graph_db v1 0x%x\n", sectionheader);        printf("Section header graph_db v1 0x%x\n", sectionheader);
206        decode_graph_db_v1();        decode_graph_db_v1();
207      } // else if      } // else if
208      else {      else {
209        fprintf(stderr, "%s:%s:%ld: unknown section header = 0x%x, neither 0x%x nor 0x%x\n", progname, filename, ftell(file), sectionheader, HOST_DB_V1, GRAPH_DB_V1);        fprintf(stderr, "%s:%s:%ld: unknown section header = 0x%x, neither 0x%x nor 0x%x\n", progname, filename, ftell(file), sectionheader, HOST_DB_V1, GRAPH_DB_V1);
210        exit(EXIT_FAILURE);        exit(EXIT_FAILURE);
211      } // else      } // else
212    } // for    } // for
213    
214    exdent();    exdent();
215    
216      if (fclose(file) != 0) {
217        fprintf(stderr, "%s: fclose(\"%s\") = %s (%d)\n", progname, filename, strerror(errno), errno);
218        exit(EXIT_FAILURE);
219      } // if
220  } // decode_file()  } // decode_file()
221    
222  void decode_host_db_v1(void)  void decode_host_db_v1(void)
223  {  {
224    void decode_host_header_v1(void);    void decode_host_header_v1(void);
225    void decode_host_header_v2(void);    void decode_host_header_v2(void);
226    void decode_host_header_v3(void);    void decode_host_header_v3(void);
227    
228    unsigned int hostcount;    unsigned int hostcount;
229    unsigned int i;    unsigned int i;
230    
231    indent();    indent();
232    
233    hostcount = read32u();    hostcount = read32u();
234    


Legend:
Removed lines/characters  
Changed lines/characters
  Added lines/characters

svn@ximalas.info
ViewVC Help
Powered by ViewVC 1.3.0-dev