source: trunk/gsdl/src/mgpp/text/mg_decompress_text.cpp@ 2468

Last change on this file since 2468 was 2468, checked in by sjboddie, 23 years ago

Fiddled about with mgpp to get it compiling on Windows under VC++ 6.0. I
still can't get it to compile under VC++ 4.2 because of some weird
behaviour in STLport.

Also tidied up a little and removed some of the old log information
that was scattered about in some of the files.

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 2.5 KB
Line 
1/**************************************************************************
2 *
3 * mg_decompress_text.cpp --
4 * Copyright (C) 1999 Rodger McNab
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 *
20 **************************************************************************/
21
22#define _XOPEN_SOURCE 1
23#define _XOPEN_SOURCE_EXTENDED 1
24
25#if defined __WIN32__
26# include "getopt.h"
27#else
28# include <unistd.h>
29#endif
30
31#include "UCArray.h"
32#include "sysfuncs.h"
33#include "TextGet.h"
34#include "messages.h"
35#include "mg_files.h"
36
37int main (int argc, char **argv) {
38 int ch;
39 char *filename = "";
40 char *basePath = "";
41 UCArray level;
42 SetCStr (level, "Document");
43
44 opterr = 0;
45 msg_prefix = argv[0];
46
47 // process the command line arguments
48 while ((ch = getopt (argc, argv, "f:d:K:h")) != -1) {
49 switch (ch) {
50 case 'f': /* input file */
51 filename = optarg;
52 break;
53 case 'd':
54 basePath = optarg;
55 set_basepath (optarg);
56 break;
57 case 'K':
58 SetCStr (level, optarg);
59 break;
60 case 'h':
61 case '?':
62 fprintf (stderr, "usage: %s [-h] [-K level] [-d directory] -f name\n",
63 argv[0]);
64 exit (1);
65 }
66 }
67
68 // load up the text information
69 TextData td;
70 if (!td.LoadData (basePath, filename)) {
71 FatalError (1, "Couldn't load text information for \"%s\"", filename);
72 }
73
74 // output each document in the level
75// cout << td.levels << "\n";
76
77 TextLevelInfo levelInfo = td.levels.levelInfo[level];
78 unsigned long docNum = 1;
79 UCArray docText;
80 while (docNum <= levelInfo.numEntries) {
81// TextIdx docIdx;
82// if (GetDocIdx (td, level, docNum, docIdx)) {
83// cout << "doc: " << docNum << "\n";
84// cout << docIdx;
85// }
86
87 if (!GetDocText (td, level, docNum, docText)) {
88 FatalError (1, "Error while trying to get document %u", docNum);
89 }
90
91 cout << docText << "\n";
92
93 docNum++;
94 }
95
96 return 0;
97}
98
99
Note: See TracBrowser for help on using the repository browser.