source: branches/New_Config_Format-branch/gsdl/src/mgpp/text/mg_decompress_text.cpp@ 1279

Last change on this file since 1279 was 1279, checked in by sjboddie, 24 years ago

merged changes to trunk into New_Config_Format branch

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 2.4 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 * $Id: mg_decompress_text.cpp 1279 2000-07-12 22:21:53Z sjboddie $
21 *
22 **************************************************************************/
23
24#include "sysfuncs.h"
25
26#include "TextGet.h"
27#include "UCArray.h"
28
29#include "messages.h"
30#include "mg_files.h"
31
32
33int main (int argc, char **argv) {
34 int ch;
35 char *filename = "";
36 char *basePath = "";
37 UCArray level;
38 SetCStr (level, "Document");
39
40 opterr = 0;
41 msg_prefix = argv[0];
42
43 // process the command line arguments
44 while ((ch = getopt (argc, argv, "f:d:K:h")) != -1) {
45 switch (ch) {
46 case 'f': /* input file */
47 filename = optarg;
48 break;
49 case 'd':
50 basePath = optarg;
51 set_basepath (optarg);
52 break;
53 case 'K':
54 SetCStr (level, optarg);
55 break;
56 case 'h':
57 case '?':
58 fprintf (stderr, "usage: %s [-h] [-K level] [-d directory] -f name\n",
59 argv[0]);
60 exit (1);
61 }
62 }
63
64 // load up the text information
65 TextData td;
66 if (!td.LoadData (basePath, filename)) {
67 FatalError (1, "Couldn't load text information for \"%s\"", filename);
68 }
69
70 // output each document in the level
71// cout << td.levels << "\n";
72
73 TextLevelInfo levelInfo = td.levels.levelInfo[level];
74 unsigned long docNum = 1;
75 UCArray docText;
76 while (docNum <= levelInfo.numEntries) {
77// TextIdx docIdx;
78// if (GetDocIdx (td, level, docNum, docIdx)) {
79// cout << "doc: " << docNum << "\n";
80// cout << docIdx;
81// }
82
83 if (!GetDocText (td, level, docNum, docText)) {
84 FatalError (1, "Error while trying to get document %u", docNum);
85 }
86
87 cout << docText << "\n";
88
89 docNum++;
90 }
91
92 return 0;
93}
94
95
Note: See TracBrowser for help on using the repository browser.