add .gbp.conf for gbp service
[tools/isomd5sum.git] / implantisomd5.c
1 /*
2  * simple program to insert an md5sum into application data area of iso99660
3  * Copyright (C) 2001-2007 Red Hat, Inc.
4  * Michael Fulbright <msf@redhat.com>
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
19  */
20
21 #include <stdio.h>
22 #include <stdlib.h>
23 #include <popt.h>
24
25 #include "md5.h"
26 #include "libimplantisomd5.h"
27
28
29 static void usage(void) {
30     fprintf(stderr, "implantisomd5:         implantisomd5 [--force] [--supported-iso] <isofilename>\n");
31     exit(1);
32 }
33
34
35 int main(int argc, char **argv) {
36     int rc;
37     char *errstr;
38     const char **args;
39
40     int forceit=0;
41     int supported=0;
42     int help=0;
43
44     poptContext optCon;
45     struct poptOption options[] = {
46         { "force", 'f', POPT_ARG_NONE, &forceit, 0 },
47         { "supported-iso", 'S', POPT_ARG_NONE, &supported, 0 },
48         { "help", 'h', POPT_ARG_NONE, &help, 0},
49         { 0, 0, 0, 0, 0}
50     };
51
52
53     optCon = poptGetContext("implantisomd5", argc, (const char **)argv, options, 0);
54
55     if ((rc = poptGetNextOpt(optCon)) < -1) {
56         fprintf(stderr, "bad option %s: %s\n",
57                 poptBadOption(optCon, POPT_BADOPTION_NOALIAS),
58                 poptStrerror(rc));
59         exit(1);
60     }
61
62     if (help)
63         usage();
64
65     args = poptGetArgs(optCon);
66     if (!args || !args[0] || !args[0][0])
67         usage();
68
69     rc = implantISOFile((char *)args[0], supported, forceit, 0, &errstr);
70     if (rc) {
71         fprintf(stderr, "ERROR: ");
72         fprintf(stderr, errstr, (char *)args[0]);
73         exit(1);
74     } else {
75         exit(0);
76     }
77 }