File: esl_regexp.h

package info (click to toggle)
hmmer 3.2.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 23,380 kB
  • sloc: ansic: 119,305; perl: 8,791; sh: 3,266; makefile: 1,871; python: 598
file content (70 lines) | stat: -rw-r--r-- 2,839 bytes parent folder | download
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
/* Regular expression matching on strings.
 * 
 * SRE, Sun Jan  2 10:52:34 2005 [Zaragoza]
 ******************************************************************
 * The regexp module is a wrapper around a modified version of Henry
 * Spencer's regex library. Spencer's copyright notice appears below,
 * after my wrappers, prefacing the section that includes his code. I
 * believe you can obtain the original code from:
 *    ftp://ftp.zoo.toronto.edu/pub/bookregex.tar.Z
 * Thanks, Henry!
 *****************************************************************
 */    
#ifndef eslREGEXP_INCLUDED
#define eslREGEXP_INCLUDED
#include "esl_config.h"

/* ESL_REGEXP_NSUB specifies the maximum number of () expressions
 * in a regexp. The whole regexp counts as one, so 16 allows for 
 * parsing out up to 15 tokens from the match.
 */
#define ESL_REGEXP_NSUB 16

/* The esl__regexp structure is from the original Spencer code.
 * It's wrapped by the ESL_REGEXP structure, below.
 */
typedef struct {
  char *startp[ESL_REGEXP_NSUB]; /* ptrs to starts of submatches on target string */
  char *endp[ESL_REGEXP_NSUB];   /* ptrs to 1 char after ends of submatches */
  char regstart;		 /* Internal use only. */
  char reganch;		         /* Internal use only. */
  char *regmust;		 /* Internal use only. */
  int regmlen;		         /* Internal use only. */
  char program[1];	         /* Unwarranted chumminess with compiler. */  
} esl__regexp;


/* This looks sort of stupid, wrapping a single ptr in a structure, but we
 * want the machine to be persistent even if different NDFAs are
 * compiled and used. Without this persistency, we would have to
 * create/destroy every time we used a different pattern, instead of
 * one create/destroy per block of code that uses regex matching
 * functionaility.
 *
 * Plus, if we ever need to keep other persistent info 
 * beyond Spencer's compiled NDFA (which we'd rather not mess
 * with), we have a place to put it.
 */
typedef struct {
  esl__regexp *ndfa;	 /* a compiled regexp */
} ESL_REGEXP;


/* Declaration of functions in the API
 */

extern ESL_REGEXP *esl_regexp_Create(void);
extern void        esl_regexp_Destroy(ESL_REGEXP *machine);

extern int  esl_regexp_Match(ESL_REGEXP *machine, const char *pattern, const char *s);
extern int  esl_regexp_Compile(ESL_REGEXP *machine, const char *pattern);
extern int  esl_regexp_MultipleMatches(ESL_REGEXP *machine, char **sptr);

extern char *esl_regexp_SubmatchDup(ESL_REGEXP *machine, int elem);
extern int   esl_regexp_SubmatchCopy(ESL_REGEXP *machine, int elem, char *buffer, int nc);
extern int   esl_regexp_SubmatchCoords(ESL_REGEXP *machine, char *origin, int elem, 
				       int *ret_start, int *ret_end);
extern int   esl_regexp_ParseCoordString(const char *cstring, uint32_t *ret_start, uint32_t *ret_end);

#endif /*eslREGEXP_INCLUDED*/