Lines Matching refs:c

44 static int cdb_match(struct cdb *c, char *key, unsigned int len, uint32 pos)  in cdb_match()  argument
53 if (cdb_read(c, buf, n, pos) == -1) in cdb_match()
80 void cdb_free(struct cdb *c) in cdb_free() argument
86 void cdb_findstart(struct cdb *c) in cdb_findstart() argument
88 c->loop = 0; in cdb_findstart()
93 void cdb_init(struct cdb *c, php_stream *fp) in cdb_init() argument
95 cdb_free(c); in cdb_init()
96 cdb_findstart(c); in cdb_init()
97 c->fp = fp; in cdb_init()
102 int cdb_read(struct cdb *c, char *buf, unsigned int len, uint32 pos) in cdb_read() argument
104 if (php_stream_seek(c->fp, pos, SEEK_SET) == -1) { in cdb_read()
111 r = php_stream_read(c->fp, buf, len); in cdb_read()
127 int cdb_findnext(struct cdb *c, char *key, unsigned int len) in cdb_findnext() argument
133 if (!c->loop) { in cdb_findnext()
135 if (cdb_read(c, buf, 8, (u << 3) & 2047) == -1) in cdb_findnext()
137 uint32_unpack(buf + 4,&c->hslots); in cdb_findnext()
138 if (!c->hslots) in cdb_findnext()
140 uint32_unpack(buf, &c->hpos); in cdb_findnext()
141 c->khash = u; in cdb_findnext()
143 u %= c->hslots; in cdb_findnext()
145 c->kpos = c->hpos + u; in cdb_findnext()
148 while (c->loop < c->hslots) { in cdb_findnext()
149 if (cdb_read(c, buf, 8, c->kpos) == -1) in cdb_findnext()
154 c->loop += 1; in cdb_findnext()
155 c->kpos += 8; in cdb_findnext()
156 if (c->kpos == c->hpos + (c->hslots << 3)) in cdb_findnext()
157 c->kpos = c->hpos; in cdb_findnext()
159 if (u == c->khash) { in cdb_findnext()
160 if (cdb_read(c, buf, 8, pos) == -1) in cdb_findnext()
164 switch(cdb_match(c, key, len, pos + 8)) { in cdb_findnext()
168 uint32_unpack(buf + 4, &c->dlen); in cdb_findnext()
169 c->dpos = pos + 8 + len; in cdb_findnext()
180 int cdb_find(struct cdb *c, char *key, unsigned int len) in cdb_find() argument
182 cdb_findstart(c); in cdb_find()
183 return cdb_findnext(c, key, len); in cdb_find()