The SWORD Project  1.9.0.svnversion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
stepdump.cpp File Reference
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <iostream>
#include <string>
#include <io.h>
#include <filemgr.h>
#include <lzsscomprs.h>
+ Include dependency graph for stepdump.cpp:

Go to the source code of this file.

Classes

struct  Version
 
struct  ViewableBlock
 
struct  ViewableHeader
 

Functions

int main (int argc, char **argv)
 
void readHeaderControlWordAreaText (int fd, char **buf)
 
void readVersion (int fd, Version *versionRecord)
 
void readViewableBlock (int fd, ViewableBlock *vb)
 
void readViewableBlockText (int fd, ViewableBlock *vb, char **buf)
 
void readViewableHeader (int fd, ViewableHeader *viewableHeaderRecord)
 

Variables

SWCompresscompress = 0
 

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 87 of file stepdump.cpp.

87  {
88 
89  compress = new LZSSCompress();
90  char *buf;
91  Version versionRecord;
92  ViewableHeader viewableHeaderRecord;
93 
94  if (argc < 2) {
95  cerr << "usage: "<< *argv << " <database to step module>\n";
96  exit (-1);
97  }
98 
99  string bookpath = argv[1];
100  string fileName;
101 
102  if ((argv[1][strlen(argv[1])-1] != '/') &&
103  (argv[1][strlen(argv[1])-1] != '\\'))
104  bookpath += "/";
105 
106  fileName = bookpath + "Book.dat";
107  int fd = FileMgr::openFileReadOnly(fileName.c_str());
108 
109  if (fd < 1) {
110  cerr << "error, couldn't open file: " << fileName << "\n";
111  exit (-2);
112  }
113 
114  readVersion(fd, &versionRecord);
116  delete [] buf;
117 
118 
119  fileName = bookpath + "Viewable.idx";
120  int fdv = FileMgr::openFileReadOnly(fileName.c_str());
121 
122  if (fdv < 1) {
123  cerr << "error, couldn't open file: " << fileName << "\n";
124  exit (-3);
125  }
126 
127  readVersion(fdv, &versionRecord);
128  readViewableHeader(fdv, &viewableHeaderRecord);
129 
130  ViewableBlock vb;
131 
132  cout << "\n\nReading special preface viewable BLOCK 0";
133 
134  readViewableBlock(fdv, &vb);
135  readViewableBlockText(fd, &vb, &buf);
136  delete [] buf;
137 
138  int nonGlossBlocksCount = viewableHeaderRecord.viewableBlocksCount
139  - viewableHeaderRecord.glossBlocksCount;
140 
141  cout << "\n\nReading " << nonGlossBlocksCount << " non-glossary viewable blocks";
142  // 1 because we already read the first block above
143  for (int i = 1; i < nonGlossBlocksCount; i++) {
144  cout << "\nNon-Glossary viewable block: " << i;
145  readViewableBlock(fdv, &vb);
146  readViewableBlockText(fd, &vb, &buf);
147  delete [] buf;
148  }
149 
150  cout << "\n\nReading " << viewableHeaderRecord.glossBlocksCount << " glossary viewable blocks";
151  for (int i = 0; i < viewableHeaderRecord.glossBlocksCount; i++) {
152  cout << "\nGlossary viewable block: " << i;
153  readViewableBlock(fdv, &vb);
154  readViewableBlockText(fd, &vb, &buf);
155  delete [] buf;
156  }
157 
158  close(fdv);
159  close(fd);
160 
161 }
void readViewableBlockText(int fd, ViewableBlock *vb, char **buf)
Definition: step2vpl.cpp:312
static int openFileReadOnly(const char *fName)
Definition: filemgr.cpp:474
SWCompress * compress
Definition: step2vpl.cpp:140
long viewableBlocksCount
Definition: step2vpl.cpp:79
void readViewableBlock(int fd, ViewableBlock *vb)
Definition: step2vpl.cpp:324
void readVersion(int fd, Version *versionRecord)
Definition: step2vpl.cpp:230
long glossBlocksCount
Definition: step2vpl.cpp:80
void readViewableHeader(int fd, ViewableHeader *viewableHeaderRecord)
Definition: step2vpl.cpp:272
void readHeaderControlWordAreaText(int fd, char **buf)
Definition: step2vpl.cpp:332
void readHeaderControlWordAreaText ( int  fd,
char **  buf 
)
void readVersion ( int  fd,
Version versionRecord 
)
void readViewableBlock ( int  fd,
ViewableBlock vb 
)
void readViewableBlockText ( int  fd,
ViewableBlock vb,
char **  buf 
)
void readViewableHeader ( int  fd,
ViewableHeader viewableHeaderRecord 
)

Variable Documentation

SWCompress* compress = 0

Definition at line 85 of file stepdump.cpp.