-
Notifications
You must be signed in to change notification settings - Fork 0
/
extractText.c
44 lines (38 loc) · 1.19 KB
/
extractText.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
#include <stdio.h>
#include <string.h>
#include "fileinfo.h"
#include "transform.h"
#include "zip.h"
#include "stopif.h"
#include "extractText.h"
#include "incbin.h"
INCBIN(DocxToTxt, "xsl/docxToTxt.xsl");
INCBIN(PptxToTxt, "xsl/pptxToTxt.xsl");
INCBIN(XlsxToTxt, "xsl/xlsxToTxt.xsl");
void usage(const char *name) {
printf("%s inputFile\n", name);
printf("Docx, xlsx and pptx are supported.\n");
}
int main(int argc, char **argv) {
if (argc < 2) {
usage(argv[0]);
return 1;
}
struct fileInfo *fi = newFileInfo(argv[1]);
Stopif(!fi, return 1, "Can't establish fileinfo!\n");
if (strcmp(fi->ext, "docx") == 0) {
Stopif(!transformLoad((char*)gDocxToTxtData, gDocxToTxtSize), return 1, "Can't load transform!\n");
readZIP(fi->fullname, wordFile);
}
else if (strcmp(fi->ext, "pptx") == 0) {
Stopif(!transformLoad((char*)gPptxToTxtData, gPptxToTxtSize), return 1, "Can't load transform!\n");
readZIP(fi->fullname, slideFiles);
readZIP(fi->fullname, drawingFiles);
}
else if (strcmp(fi->ext, "xlsx") == 0) {
Stopif(!transformLoad((char*)gXlsxToTxtData, gXlsxToTxtSize), return 1, "Can't load transform!\n");
readZIP(fi->fullname, xlsxFile);
}
transformCleanup();
freeFileInfo(fi);
}