3 * @author Alex Ott <alexott@gmail.com>
5 * Version: $Id: catppt.c,v 1.1 2006-02-24 17:44:06 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 ppt2text [-lV] [-b string] [-s charset] [-d charset] files\n");
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:p:"))!=-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);
84 case 'V': printf("Catdoc Version %s\n",CATDOC_VERSION);
91 /* If we are using system strftime, we need to set LC_TIME locale
92 * category unless choosen charset is not same as system locale
94 #if defined(HAVE_LANGINFO) && defined(HAVE_STRFTIME) && !defined(__TURB0C__)
97 /* charset conversion init*/
98 input_buffer=malloc(FILE_BUFFER);
99 if (strcmp(dest_csname,"utf-8")) {
100 tmp_charset=read_charset(dest_csname);
102 fprintf(stderr,"Cannot load target charset %s\n",dest_csname);
105 target_charset=make_reverse_map(tmp_charset);
110 spec_chars=read_substmap(stradd("ascii",SPEC_EXT));
112 fprintf(stderr,"Cannod read substitution map ascii%s\n",
116 replacements=read_substmap(stradd("ascii",REPL_EXT));
118 fprintf(stderr,"Cannod read substitution map ascii%s\n",
123 if (isatty(fileno(stdin))) {
127 do_ppt(stdin,"STDIN");
130 for (i=optind;i<argc;i++) {
132 input=fopen(filename,"rb");
137 if ((new_file=ole_init(input, NULL, 0)) != NULL) {
139 while((ole_file=ole_readdir(new_file)) != NULL) {
140 int res=ole_open(ole_file);
141 /* fprintf(stderr, "name = %s\n", ((oleEntry*)ole_file)->name); */
143 if (strcasecmp(((oleEntry*)ole_file)->name , "PowerPoint Document") == 0) {
144 do_ppt(ole_file,filename);
153 fprintf(stderr, "%s is not OLE file or Error\n", filename);