00001
00002
00003
00004
00005
00006 #ifdef USE_SYSTEM_LDM_HEADERS
00007 #include <pq.h>
00008 #define _LDMCPP_H
00009 #endif
00010
00011 #ifndef _LDMCPP_H
00012 #define _LDMCPP_H
00013
00014
00015
00016 #include <sys/types.h>
00017 #include <stddef.h>
00018 #include <stdlib.h>
00019 #include <sys/types.h>
00020 #include <netinet/in.h>
00021 #include <arpa/inet.h>
00022 #include <sys/time.h>
00023 #include <regex.h>
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 extern const char* ldm_version;
00035
00036
00037 typedef struct timeval timestampt;
00038
00039 extern const struct timeval TS_NONE;
00040 extern const struct timeval TS_ZERO;
00041 extern const struct timeval TS_ENDT;
00042
00043
00044
00045 typedef u_int feedtypet;
00046
00047 struct prod_spec {
00048 feedtypet feedtype;
00049 char *pattern;
00050 regex_t rgx;
00051 };
00052 typedef struct prod_spec prod_spec;
00053
00054
00055
00056
00057
00058 struct prod_class {
00059 timestampt from;
00060 timestampt to;
00061 struct {
00062 u_int psa_len;
00063 prod_spec *psa_val;
00064 } psa;
00065 };
00066 typedef struct prod_class prod_class;
00067
00068 typedef unsigned char signaturet[16];
00069
00070
00071
00072
00073
00074 typedef char *keyt;
00075
00076
00077
00078
00079
00080
00081
00082
00083 struct prod_info {
00084 timestampt arrival;
00085 signaturet signature;
00086 char *origin;
00087 feedtypet feedtype;
00088 u_int seqno;
00089 keyt ident;
00090 u_int sz;
00091 };
00092 typedef struct prod_info prod_info;
00093
00094
00095 #ifndef _PROD_CLASS_H_
00096 #define _PROD_CLASS_H_
00097
00098
00099
00100
00101 extern const prod_class _clss_all;
00102 #define PQ_CLASS_ALL (&_clss_all)
00103 extern const prod_spec _spec_all;
00104 #define PQ_SPEC_ALL (&_spec_all)
00105
00106
00107 extern void
00108 free_prod_class(prod_class *clssp);
00109
00110 extern prod_class *
00111 new_prod_class(u_int psa_len);
00112
00113 #endif
00114
00115
00116 #ifndef _PQ_H
00117 #define _PQ_H
00118
00119
00120
00121
00122
00123
00124
00125 #ifndef ENOERR
00126 #define ENOERR 0
00127 #endif
00129 #define PQ_CORRUPT -1
00130
00131 typedef struct pqueue pqueue;
00132
00133
00134
00135
00136
00137 #define PQ_DEFAULT 0x00
00138 #define PQ_NOCLOBBER 0x01
00139 #define PQ_READONLY 0x02
00140 #define PQ_NOLOCK 0x04
00141 #define PQ_PRIVATE 0x08
00142 #define PQ_NOGROW 0x10
00143 #define PQ_NOMAP 0x20
00144 #define PQ_MAPRGNS 0x40
00145 #define PQ_SPARSE 0x80
00146
00147
00148 extern int
00149 pq_create(const char *path, mode_t mode, int pflags,
00150 size_t align, off_t initialsz, size_t nproducts,
00151 pqueue **pqp);
00152
00153 extern int
00154 pq_open(const char *path,
00155 int pflags,
00156 pqueue **pqp);
00157
00158 extern int
00159 pq_close(pqueue *pq);
00160
00161
00162
00163
00164 typedef int pq_seqfunc(const prod_info *infop, const void *datap,
00165 void *xprod, size_t len,
00166 void *otherargs);
00167
00168
00169
00170
00171 typedef enum {
00172 TV_LT = -1,
00173 TV_EQ = 0,
00174 TV_GT = 1
00175 } pq_match;
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201 #define PQUEUE_END (-1)
00202 extern int
00203 pq_sequence(pqueue *pq, pq_match mt,
00204 const prod_class *clssp, pq_seqfunc *ifMatch, void *otherargs);
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215 extern unsigned
00216 pq_suspend(unsigned int maxsleep);
00217 #endif
00218
00219
00220
00221 #endif
00222