aboutsummaryrefslogtreecommitdiffstats
path: root/libversit/vctest.c
blob: b14e6c1b4ec2189ccfe2855efd95fb5253b9fe84 (plain) (blame)
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95

#include <stdio.h>
#include <string.h>
#include "vcc.h"

FILE *cfp;

void myMimeErrorHandler(char *s)
{
    printf("%s\n", s);
}

void main(int argc, char **argv)
{
    int testmem = 0;

    char * foo[2] = {"foo","alden.vcf"};

argc = 2;
argv = foo;

#ifdef _CONSOLE
    cfp = stdout;
    registerMimeErrorHandler(myMimeErrorHandler);
#else
    cfp = fopen("vctest.out", "w");
    if (!cfp) return;
#endif
    ++argv;
    while (--argc) {
    FILE *fp;
    if (strcmp(*argv,"-testmem") == 0) {
        testmem = 1;
        argv++;
        continue;
        }
    fprintf(cfp,"processing %s\n",*argv);
    fp = fopen(*argv,"r");
    if (!fp) {
        fprintf(cfp,"error opening file\n");
        }
    else {
        VObject *v, *t;
        FILE *ofp;
        char buf[256];
        char *p;
        strcpy(buf,*argv);
        p = strchr(buf,'.');
        if (p) *p = 0;
        strcat(buf,".out");
        fprintf(cfp,"reading text input from '%s'...\n", *argv);
        //v = Parse_MIME_FromFile(fp);
        v = Parse_MIME_FromFileName(*argv);
        writeVObjectToFile(buf,v);
        cleanVObject(v);

        /*
        fprintf(cfp,"pretty print internal format of '%s'...\n", *argv);
        ofp = fopen(buf,"w");
        while (v) {
        printVObject(cfp,v);
        if (testmem) {
            char *s, *p;
            fprintf(cfp,"test writing to mem...\n");
            p = s  = writeMemVObject(0,0,v);
            if (s) {
            while (*s) {
                fputc(*s,ofp);
                s++;
                }
            free(p);
            }
            }
        else {
            writeVObject(ofp,v);
            }
        t = v;
        v = nextVObjectInList(v);
        cleanVObject(t);
        }
        
        fclose(ofp);
        fclose(fp);
        */
        }
        
    cleanStrTbl();
    argv++;
    
    }
    
    if (cfp != stdout) fclose(cfp);

}