]> git.sur5r.net Git - cc65/blob - src/ar65/main.c
This commit was generated by cvs2svn to compensate for changes in r2,
[cc65] / src / ar65 / main.c
1 /*****************************************************************************/
2 /*                                                                           */
3 /*                                  main.c                                   */
4 /*                                                                           */
5 /*                    Main program for the ar65 archiver                     */
6 /*                                                                           */
7 /*                                                                           */
8 /*                                                                           */
9 /* (C) 1998     Ullrich von Bassewitz                                        */
10 /*              Wacholderweg 14                                              */
11 /*              D-70597 Stuttgart                                            */
12 /* EMail:       uz@musoftware.de                                             */
13 /*                                                                           */
14 /*                                                                           */
15 /* This software is provided 'as-is', without any expressed or implied       */
16 /* warranty.  In no event will the authors be held liable for any damages    */
17 /* arising from the use of this software.                                    */
18 /*                                                                           */
19 /* Permission is granted to anyone to use this software for any purpose,     */
20 /* including commercial applications, and to alter it and redistribute it    */
21 /* freely, subject to the following restrictions:                            */
22 /*                                                                           */
23 /* 1. The origin of this software must not be misrepresented; you must not   */
24 /*    claim that you wrote the original software. If you use this software   */
25 /*    in a product, an acknowledgment in the product documentation would be  */
26 /*    appreciated but is not required.                                       */
27 /* 2. Altered source versions must be plainly marked as such, and must not   */
28 /*    be misrepresented as being the original software.                      */
29 /* 3. This notice may not be removed or altered from any source              */
30 /*    distribution.                                                          */
31 /*                                                                           */
32 /*****************************************************************************/
33
34
35
36 #include <stdio.h>
37 #include <stdlib.h>
38 #include <string.h>
39 #include <time.h>
40
41 #include "../common/version.h"
42
43 #include "global.h"
44 #include "error.h"
45 #include "mem.h"
46 #include "add.h"
47 #include "del.h"
48 #include "list.h"
49 #include "extract.h"
50
51
52
53 /*****************************************************************************/
54 /*                                   Code                                    */
55 /*****************************************************************************/
56
57
58
59 static void Usage (void)
60 /* Print usage information and exit */
61 {
62     fprintf (stderr,
63              "Usage: %s <operation> lib file|module ...\n"
64              "Operation is one of:\n"
65              "\ta\tAdd modules\n"
66              "\td\tDelete modules\n"
67              "\tl\tList library contents\n"
68              "\tx\tExtract modules\n"
69              "\tV\tPrint the archiver version\n",
70              ProgName);
71     exit (EXIT_FAILURE);
72 }
73
74
75
76 int main (int argc, char* argv [])
77 /* Assembler main program */
78 {
79     int I;
80
81     /* We must have a file name */
82     if (argc < 2) {
83         Usage ();
84     }
85
86     /* Check the parameters */
87     I = 1;
88     while (I < argc) {
89
90         /* Get the argument */
91         const char* Arg = argv [I];
92
93         /* Check for an option */
94         if (strlen (Arg) != 1) {
95             Usage ();
96         }
97         switch (Arg [0]) {
98
99             case 'a':
100                 AddObjFiles (argc - I - 1, &argv [I+1]);
101                 break;
102
103             case 'd':
104                 DelObjFiles (argc - I - 1, &argv [I+1]);
105                 break;
106
107             case 'l':
108                 ListObjFiles (argc - I - 1, &argv [I+1]);
109                 break;
110
111             case 'v':
112                 ++Verbose;
113                 break;
114
115             case 'x':
116                 ExtractObjFiles (argc - I - 1, &argv [I+1]);
117                 break;
118
119             case 'V':
120                 fprintf (stderr,
121                          "ar65 V%u.%u.%u - (C) Copyright 1998-1999 Ullrich von Bassewitz\n",
122                          VER_MAJOR, VER_MINOR, VER_PATCH);
123                 break;
124
125             default:
126                 fprintf (stderr, "Unknown option: %s\n", Arg);
127                 Usage ();
128
129         }
130
131         /* Next argument */
132         ++I;
133     }
134
135     /* Return an apropriate exit code */
136     return EXIT_SUCCESS;
137 }
138
139
140