Lines Matching refs:c
46 static int cdb_match(struct cdb *c, char *key, unsigned int len, uint32 pos) in cdb_match() argument
55 if (cdb_read(c, buf, n, pos) == -1) in cdb_match()
82 void cdb_free(struct cdb *c) in cdb_free() argument
88 void cdb_findstart(struct cdb *c) in cdb_findstart() argument
90 c->loop = 0; in cdb_findstart()
95 void cdb_init(struct cdb *c, php_stream *fp) in cdb_init() argument
97 cdb_free(c); in cdb_init()
98 cdb_findstart(c); in cdb_init()
99 c->fp = fp; in cdb_init()
104 int cdb_read(struct cdb *c, char *buf, unsigned int len, uint32 pos) in cdb_read() argument
106 if (php_stream_seek(c->fp, pos, SEEK_SET) == -1) { in cdb_read()
113 r = php_stream_read(c->fp, buf, len); in cdb_read()
129 int cdb_findnext(struct cdb *c, char *key, unsigned int len) in cdb_findnext() argument
135 if (!c->loop) { in cdb_findnext()
137 if (cdb_read(c, buf, 8, (u << 3) & 2047) == -1) in cdb_findnext()
139 uint32_unpack(buf + 4,&c->hslots); in cdb_findnext()
140 if (!c->hslots) in cdb_findnext()
142 uint32_unpack(buf, &c->hpos); in cdb_findnext()
143 c->khash = u; in cdb_findnext()
145 u %= c->hslots; in cdb_findnext()
147 c->kpos = c->hpos + u; in cdb_findnext()
150 while (c->loop < c->hslots) { in cdb_findnext()
151 if (cdb_read(c, buf, 8, c->kpos) == -1) in cdb_findnext()
156 c->loop += 1; in cdb_findnext()
157 c->kpos += 8; in cdb_findnext()
158 if (c->kpos == c->hpos + (c->hslots << 3)) in cdb_findnext()
159 c->kpos = c->hpos; in cdb_findnext()
161 if (u == c->khash) { in cdb_findnext()
162 if (cdb_read(c, buf, 8, pos) == -1) in cdb_findnext()
166 switch(cdb_match(c, key, len, pos + 8)) { in cdb_findnext()
170 uint32_unpack(buf + 4, &c->dlen); in cdb_findnext()
171 c->dpos = pos + 8 + len; in cdb_findnext()
182 int cdb_find(struct cdb *c, char *key, unsigned int len) in cdb_find() argument
184 cdb_findstart(c); in cdb_find()
185 return cdb_findnext(c, key, len); in cdb_find()