rparecord.h
Go to the documentation of this file.
00001 /*
00002  *  Regular Pattern Analyzer Toolkit (RPA/Tk)
00003  *  Copyright (c) 2009-2012 Martin Stoilov
00004  *
00005  *  This program is free software: you can redistribute it and/or modify
00006  *  it under the terms of the GNU General Public License as published by
00007  *  the Free Software Foundation, either version 3 of the License, or
00008  *  (at your option) any later version.
00009  *
00010  *  This program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *  GNU General Public License for more details.
00014  *
00015  *  You should have received a copy of the GNU General Public License
00016  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
00017  *
00018  *  Martin Stoilov <martin@rpasearch.com>
00019  */
00020 
00062 #ifndef _RPARECORD_H_
00063 #define _RPARECORD_H_
00064 
00065 #include "rtypes.h"
00066 #include "rlib/rarray.h"
00067 #include "rlib/rlist.h"
00068 #include "rpa/rpavm.h"
00069 
00070 
00071 #ifdef __cplusplus
00072 extern "C" {
00073 #endif
00074 
00075 #define RPA_RECORD_NONE (0)                                             
00076 #define RPA_RECORD_START (1 << 0)                               
00077 #define RPA_RECORD_END (1 << 1)                                 
00082 typedef struct rparecord_s rparecord_t;
00083 
00087 typedef long (*rpa_recordtree_callback)(rarray_t *records, long rec, rpointer userdata);
00088 
00089 
00094 struct rparecord_s {
00095         ruint32 top;                    
00096         ruint32 size;                   
00097         const char *rule;               
00099         const char *input;              
00101         unsigned long inputoff;         
00102         unsigned long inputsiz;         
00103         ruint32 type;                   
00104         ruint32 ruleid;                 
00105         ruint32 ruleuid;                
00106         ruint32 usertype;               
00107         ruword userdata;                        
00108 };
00109 
00110 
00111 long rpa_recordtree_walk(rarray_t *src, long rec, long level, rpa_recordtree_callback callaback, rpointer userdata);
00112 
00130 long rpa_recordtree_get(rarray_t *records, long rec, unsigned long type);
00131 
00132 
00140 long rpa_recordtree_firstchild(rarray_t *records, long rec, unsigned long type);
00141 
00142 
00150 long rpa_recordtree_lastchild(rarray_t *records, long rec, unsigned long type);
00151 
00152 
00160 long rpa_recordtree_next(rarray_t *records, long rec, unsigned long type);
00161 
00162 
00170 long rpa_recordtree_prev(rarray_t *records, long rec, unsigned long type);
00171 
00172 
00180 long rpa_recordtree_parent(rarray_t *records, long rec, unsigned long type);
00181 
00182 
00189 long rpa_recordtree_size(rarray_t *records, long rec);                                  /* Size of the tree */
00190 
00191 
00199 long rpa_recordtree_copy(rarray_t *dst, rarray_t *src, long rec);
00200 
00201 
00207 rparecord_t *rpa_record_get(rarray_t *records, long rec);
00208 
00209 
00214 rarray_t *rpa_records_create();
00215 
00220 void rpa_records_destroy(rarray_t *records);
00221 
00222 int rpa_recordtree_move(rarray_t *records, long dst, long src, long size);
00223 
00224 void rpa_record_dumpindented(rarray_t *records, long rec, int level);
00225 void rpa_record_dump(rarray_t *records, long rec);
00226 long rpa_record_getruleuid(rarray_t *records, long rec);
00227 void rpa_record_setusertype(rarray_t *records, long rec, ruint32 usertype, rvalset_t op);
00228 long rpa_record_getusertype(rarray_t *records, long rec);
00229 int rpa_record_optchar(rparecord_t *prec, int defc);
00230 int rpa_record_loopchar(rparecord_t *prec, int defc);
00231 long rpa_records_length(rarray_t *records);
00232 rparecord_t *rpa_records_slot(rarray_t *records, long index);
00233 
00234 #ifdef __cplusplus
00235 }
00236 #endif
00237 
00238 #endif