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

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

Rodgers new C++ mg

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