-
Notifications
You must be signed in to change notification settings - Fork 1
/
mork.c
63 lines (61 loc) · 1.47 KB
/
mork.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "parseMork.h"
void usage() {
fprintf( stderr, "usage: mork [-v] [-V vCardFileName] abook.mab\n" );
fprintf( stderr, " -g : Do not parse groups\n" );
fprintf( stderr, " -v : Verbose\n" );
fprintf( stderr, " -V vCardFileName : write vCards to the file\n" );
}
int main( int argc, char **argv ) {
char *vCardFile = (char *) 0;
char *arg;
int i;
morkDb *mork;
//morkLogfp = stdout;
morkLogfp = 0;
morkErrfp = stderr;
for( i = 1; i < argc; ++i ) {
arg = argv[i];
switch( *arg ) {
case '-': // Options
++arg;
switch( *arg ) {
case 'g': // Group parsing off
morkDoNotParseGroups = 1;
break;
case 'v': // verbose
morkLogfp = stdout;
break;
case 'V': // vCard
if( !*(++arg) ) arg = argv[++i];
vCardFile = arg;
break;
default:
usage();
return -1;
break;
}
break;
default: // File name
mork = parseMorkFile( argv[i] );
fprintf( stdout, "\nDump of Mork Data\n" );
fprintf( stdout, "----- columns table -----\n" );
dumpMorkColumns( stdout, mork );
fprintf( stdout, "----- values table -----\n" );
dumpMorkValues( stdout, mork );
fprintf( stdout, "----- mork structure -----\n" );
dumpTableScopeMap( stdout, mork );
if( vCardFile ) {
FILE *vCardfp = fopen( vCardFile, "w" );
dumpVcards( vCardfp, mork );
fclose( vCardfp );
}
freeMorkDb( mork );
break;
}
}
return 0;
}