File: sufary.h

package info (click to toggle)
sufary 2.1.1-2
  • links: PTS
  • area: main
  • in suites: woody
  • size: 1,236 kB
  • ctags: 782
  • sloc: ansic: 4,122; perl: 1,378; makefile: 726; sh: 664; tcl: 441; cpp: 192
file content (129 lines) | stat: -rw-r--r-- 4,076 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/*--------------------------------------------------------------*
 *                                                              *
 *         SUFARY --- Suffix Array ΤΥ饤֥       *
 *                                                              *
 *  sufary.h - SUFARY饤֥إåե                   *
 *                                                              *
 *--------------------------------------------------------------*/

#ifndef _SUFARY_H_
#define _SUFARY_H_

#include <sys/types.h>
#include <sys/mman.h>
#ifndef KEYWORD_MAX_LENGTH
#define KEYWORD_MAX_LENGTH 5000
#endif

/* ޥɤ */
typedef enum eresult_{
  CONT,
  FAIL,
  EXIT,
  ERROR
} eresult;

/* 顼 */
typedef enum eerror_ {
  NOERROR,
  COMMAND,
  MEMORY,
  FILEIN,
  FILEOUT,
  STRUCTURE,
  UNKNOWN
} eerror;

/* SUFARY¤ */
typedef struct {
  eerror ee;      /* Х륨顼ɤݻ */
  long arraysize; /* Array 礭 */
  long left;  /* ϰϤκü(ϰϤ¦ؤ)   g_bottom */
  long right;     /* ϰϤαü(ϰϤ¦ؤ)   g_top */
  int txtfd;      /* ƥȥե */
  int aryfd;      /* 쥤ե */
  off_t txtsz;    /* ƥȥեΥ */
  off_t arysz;    /* 쥤եΥ */
  caddr_t txtmap; /* ƥȥեΥޥåץɥ쥹 */
  caddr_t arymap; /* 쥤եΥޥåץɥ쥹 */
  caddr_t aryorig; /* ꥸʥΥ쥤 */
  caddr_t op_result; /* 黻 */
  char filename[256]; /* ե̾(text file) for DEBUG */
  /*ary_sort_t sort; *//* arymapΥȾ */
} SUFARY;



/* DID¤ */
typedef struct {
  eerror ee;      /* Х륨顼ɤݻ */
  char filename[256]; /* ե̾ for DEBUG */
  
  long didsize;   /* DID 礭 */
  int didfd;      /* DIDե */
  off_t didsz;    /* DIDեΥ */
  caddr_t didmap; /* DIDեΥޥåץɥ쥹 */
  long *docid;      /* mmap줿 */

  long doc_start;
  long doc_size;
  long doc_no;
} DID;


/* ץȥ ѥ롼 */
/*** search.c ***/
/* level 1 : ܴؿ */
eresult sa_sel(SUFARY *ary, char *s);
long sa_left(SUFARY *ary);
long sa_right(SUFARY *ary);
char *sa_getblock(SUFARY *ary, long pos, char* d1, char* d2);
char *sa_getline(SUFARY *ary, long pos);
char *sa_getlines(SUFARY *ary, long pos, int B, int A);
char *sa_aryidx2txtptr(SUFARY *ary, long pos);
void sa_reset(SUFARY *ary);

void sa_didsearch(DID *did, long target); /* 981016 */
char *sa_getstr(SUFARY *ary, long from, long size); /* 981021 */
long sa_doc_start(DID *did); /* 981022 */
long sa_doc_size(DID *did);  /* 981022 */
long sa_doc_no(DID *did);    /* 981028 */
long sa_did_size(DID *did);  /* 981028 */

/* level 2 :  */
eresult sa_search(SUFARY *ary, char *s, int keylen, int base_offset);
long sa_aryidx2txtidx(SUFARY *ary, long idx);
char *sa_txtidx2txtptr(SUFARY *ary, long idx);
long *sa_common_prefix_search(SUFARY *ary, char *kw, char we);
void sa_mojibakebousi(char *buf);
void sa_ctrl_code_tubusi(char *buf);
/* level 3 : ԺѤβǽ */
eresult sa_uniq_near(SUFARY *ret, SUFARY *ary1, SUFARY *ary2,
		     int is_near, int width);


/* 켰ؿ : Ver.2.0 ǤϺͽ */
/*long sa_bottom(SUFARY *ary); *//* = sa_left */
/*long sa_top(SUFARY *ary); *//* = sa_right */
/*char *sa_getkatamari(SUFARY *ary,long pos,char* d1,char* d2); =sa_getblock */
/*long sa_arraytotext(SUFARY *ary, long pos); *//* = sa_aryidx2txtidx  */
/*char *sa_gettext(SUFARY *ary, long pos); *//* = sa_aryidx2txtptr */
/*long *sa_morph_search(SUFARY *ary, char *kw, char *we); *//* =sa_c._p._search */


/*** file.c ***/
/* level 1 : ܴؿ  */
SUFARY *sa_openfiles(char *s, char *t);
void sa_closefiles(SUFARY *ary);

DID *sa_opendid(char *fn); /* since 981016 */
void sa_closedid(DID *d);  /* since 981016 */

/* level 2 : ܴؿƤӽФƤؿñΤǻȤȤϤʤ */
eresult sa_opentextfile(SUFARY *ary, char *s);
eresult sa_openarrayfile(SUFARY *ary, char *s);

/*void sa_closetextfile(SUFARY *ary);*/
/*void sa_closearrayfile(SUFARY *ary);*/

#endif /* _SUFARY_H_ */