3 * @author Alex Ott <alexott@gmail.com>
5 * Version: $Id: catppt.c,v 1.2 2006-10-17 19:11:29 vitus Exp $
8 * @brief main module for text extracting from .ppt
29 #define strcasecmp(a,b) strcmpi(a,b)
33 * Displays help message
37 printf("Usage:\n catppt [-lV] [-b string] [-s charset] [-d charset] files\n");
40 extern char *slide_separator;
41 char *input_buffer, *output_buffer;
51 int main(int argc, char *argv[]) {
53 FILE *new_file, *ole_file;
55 short int *tmp_charset;
59 read_config_file(SYSTEMRC);
61 tempname=find_file(strdup(USERRC),getenv("HOME"));
63 read_config_file(tempname);
71 check_charset(&dest_csname,dest_csname);
73 while ((c=getopt(argc,argv,"Vls:d:b:"))!=-1) {
76 list_charsets(); exit(0);
78 check_charset(&source_csname,optarg);
79 source_charset=read_charset(source_csname);
82 check_charset(&dest_csname,optarg);
85 slide_separator = strdup(optarg);
87 case 'V': printf("Catdoc Version %s\n",CATDOC_VERSION);
94 /* If we are using system strftime, we need to set LC_TIME locale
95 * category unless choosen charset is not same as system locale
97 #if defined(HAVE_LANGINFO) && defined(HAVE_STRFTIME) && !defined(__TURB0C__)
100 /* charset conversion init*/
101 input_buffer=malloc(FILE_BUFFER);
102 if (strcmp(dest_csname,"utf-8")) {
103 tmp_charset=read_charset(dest_csname);
105 fprintf(stderr,"Cannot load target charset %s\n",dest_csname);
108 target_charset=make_reverse_map(tmp_charset);
113 spec_chars=read_substmap(stradd("ascii",SPEC_EXT));
115 fprintf(stderr,"Cannod read substitution map ascii%s\n",
119 replacements=read_substmap(stradd("ascii",REPL_EXT));
121 fprintf(stderr,"Cannod read substitution map ascii%s\n",
126 if (isatty(fileno(stdin))) {
130 do_ppt(stdin,"STDIN");
133 for (i=optind;i<argc;i++) {
135 input=fopen(filename,"rb");
140 if ((new_file=ole_init(input, NULL, 0)) != NULL) {
142 while((ole_file=ole_readdir(new_file)) != NULL) {
143 int res=ole_open(ole_file);
144 /* fprintf(stderr, "name = %s\n", ((oleEntry*)ole_file)->name); */
146 if (strcasecmp(((oleEntry*)ole_file)->name , "PowerPoint Document") == 0) {
147 do_ppt(ole_file,filename);
156 fprintf(stderr, "%s is not OLE file or Error\n", filename);