The SWORD Project  1.9.0.svnversion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
lexdump.c File Reference
#include <ctype.h>
#include <stdio.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <io.h>
+ Include dependency graph for lexdump.c:

Go to the source code of this file.

Macros

#define O_BINARY   0
 

Functions

int main (int argc, char **argv)
 

Macro Definition Documentation

#define O_BINARY   0

Definition at line 43 of file lexdump.c.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 46 of file lexdump.c.

46  {
47  char *tmpbuf;
48  int idxfd, datfd;
49  long offset;
50  unsigned int size;
51  char datbuf[255];
52 
53  if (argc != 3) {
54  fprintf(stderr, "usage: %s <datapath/datafilebasename> <index>\n", argv[0]);
55  exit(1);
56  }
57 
58  tmpbuf = calloc(strlen(argv[1]) + 11,1);
59  sprintf(tmpbuf, "%s.idx", argv[1]);
60  idxfd = open(tmpbuf, O_RDONLY|O_BINARY);
61  sprintf(tmpbuf, "%s.dat", argv[1]);
62  datfd = open(tmpbuf, O_RDONLY|O_BINARY);
63  free(tmpbuf);
64 
65  offset = atoi(argv[2]) * 6;
66  lseek(idxfd, offset, SEEK_SET);
67  read(idxfd, &offset, 4);
68  read(idxfd, &size, 2);
69  printf("offset: %ld; size: %d\n", offset, size);
70  lseek(datfd, offset, SEEK_SET);
71  read(datfd, datbuf, 40);
72  datbuf[40] = 0;
73  printf("%s\n", datbuf);
74  close(datfd);
75  close(idxfd);
76  return 0;
77 
78 }
#define O_BINARY
Definition: lexdump.c:43
free(preg->fastmap)
#define SEEK_SET
Definition: zconf.h:244
int size
Definition: regex.c:5043