Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
att
GitHub Repository: att/ast
Path: blob/master/src/lib/libvcodex/Vcwindow/vcwhdr.h
1810 views
1
/***********************************************************************
2
* *
3
* This software is part of the ast package *
4
* Copyright (c) 2003-2011 AT&T Intellectual Property *
5
* and is licensed under the *
6
* Eclipse Public License, Version 1.0 *
7
* by AT&T Intellectual Property *
8
* *
9
* A copy of the License is available at *
10
* http://www.eclipse.org/org/documents/epl-v10.html *
11
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
12
* *
13
* Information and Software Systems Research *
14
* AT&T Research *
15
* Florham Park NJ *
16
* *
17
* Phong Vo <[email protected]> *
18
* *
19
***********************************************************************/
20
#ifndef _VCWHDR_H
21
#define _VCWHDR_H 1
22
23
#include "vchdr.h"
24
25
#define NG_BYTE 4
26
#define H0 (1)
27
#define H1 ((Grint_t)0x101)
28
#define H2 (H1*H1)
29
#define H3 (H1*H2)
30
#define NGINIT(s,g) (g = H3*s[0] + H2*s[1] + H1*s[2] + H0*s[3] )
31
#define NGNEXT(s,g) (g = H1*(g - H3*s[-1]) + s[3])
32
33
#define NG_FREQ (1<<13) /* this is the size of the alphabet */
34
/* used in counting frequencies. */
35
#define NGINDEX(g) (g & (NG_FREQ-1))
36
37
#define NG_NSEG (1<<7) /* default # of segments per window */
38
#define NG_SIZE (1<<10) /* segment size to sum n-gram values */
39
#define NG_BITS (1<<20) /* # of bits used per n-gram value */
40
#define NGVALUE(g) (g & (NG_BITS-1))
41
42
/* extra amount to add to windows to enhance matching */
43
#define VCWEXTRA(s) ((s)/4)
44
45
typedef unsigned int Grint_t; /* n-gram integer value */
46
47
typedef struct _vcwfile_s
48
{ Sfio_t* file; /* the file to be searched for windows */
49
Sfoff_t size; /* extent of file */
50
int done; /* 0: undone, -1: error, 1: ok */
51
52
Grint_t* work; /* signatures of a window to be matched */
53
int nwork;
54
55
Grint_t* sig; /* signatures of each file index */
56
Grint_t** ssig; /* sorted signatures */
57
int nsig; /* number of signatures */
58
59
int nidx; /* indices of where to search */
60
int idx[8];
61
} Vcwfile_t;
62
63
_BEGIN_EXTERNS_
64
extern int vcwngfreq _ARG_((size_t*, Vcchar_t*, size_t));
65
extern double vcwngmatch _ARG_((int*,size_t*,size_t,Vcchar_t*,size_t,size_t,double));
66
extern Grint_t vcwngsig _ARG_((Vcchar_t*, size_t));
67
68
extern Vcwfile_t* vcwfopen _ARG_((Sfio_t*));
69
extern void vcwfclose _ARG_((Vcwfile_t*));
70
extern int vcwfsearch _ARG_((Vcwfile_t*, Vcchar_t*, size_t));
71
72
extern Vcwmethod_t* Vcwdecode; /* special windowing method for decoding */
73
_END_EXTERNS_
74
75
#endif /*_VCWHDR_H*/
76
77