1
0
mirror of https://github.com/fumiama/simple-dict.git synced 2026-06-05 02:00:25 +08:00

适配最新spb

This commit is contained in:
源文雨
2023-07-08 20:03:23 +08:00
parent a1283e714d
commit 09d5bc4fc2
5 changed files with 9 additions and 9 deletions

View File

@@ -20,7 +20,7 @@ int main() {
puts("Check config...");
fp = fopen("cfg.sp", "rb");
if(fp) {
SIMPLE_PB* spb = get_pb(fp);
simple_pb_t* spb = get_pb(fp);
memset(&cfg, 0, sizeof(config_t));
memcpy(&cfg, spb->target, sizeof(config_t));
printf("set pwd: %s, sps: %s\n", cfg.pwd, cfg.sps);

View File

@@ -156,7 +156,7 @@ int main(int argc, char *argv[]) { // usage: ./client cfg.sp host port
perror("fopen");
return 1;
}
SIMPLE_PB* spb = read_pb_into(fp, (SIMPLE_PB*)buf);
simple_pb_t* spb = read_pb_into(fp, (simple_pb_t*)buf);
if(!spb) {
fprintf(stderr, "Error reading config file: %s\n", argv[1]);
return 2;

View File

@@ -31,7 +31,7 @@ int main(int argc, char** argv) {
int ch;
while(has_next(old, ch)) {
SIMPLE_PB* spb = get_pb(old);
simple_pb_t* spb = get_pb(old);
DICTNEW* d;
switch(spb->struct_len) {
case sizeof(DICTOLD):

View File

@@ -18,7 +18,7 @@ int main(int argc, char** argv) {
int ch;
while(has_next(f, ch)) {
SIMPLE_PB* spb = read_pb_into(f, (SIMPLE_PB*)buf);
simple_pb_t* spb = read_pb_into(f, (simple_pb_t*)buf);
struct dict_t* d;
if(!spb) {
fputs("Bad spb file", stderr);

View File

@@ -223,7 +223,7 @@ static void init_dict_pool(FILE *fp) {
int ch;
while(has_next(fp, ch)) {
if(!ch) continue; // skip null bytes
SIMPLE_PB* spb = read_pb_into(fp, (SIMPLE_PB*)buf);
simple_pb_t* spb = read_pb_into(fp, (simple_pb_t*)buf);
if(!spb) {
fputs("Bad spb file", stderr);
exit(EXIT_FAILURE);
@@ -308,7 +308,7 @@ static int s1_get(thread_timer_t *timer) {
pthread_cleanup_push((void*)&close_dict, (void*)(uintptr_t)timer->index);
while(has_next(fp, ch)) {
if(!ch) continue; // skip null bytes
SIMPLE_PB* spb = read_pb_into(fp, (SIMPLE_PB*)buf);
simple_pb_t* spb = read_pb_into(fp, (simple_pb_t*)buf);
if(!spb) continue; // skip error bytes
dict_t* d = (dict_t*)spb->target;
if(!strcmp(timer->dat, d->key)) {
@@ -338,7 +338,7 @@ static int insert_item(FILE *fp, const dict_t* dict, int keysize, int datasize)
uint8_t buf[8+DICTSZ];
while(has_next(fp, ch)) {
if(!ch) continue; // skip null bytes
SIMPLE_PB* spb = read_pb_into(fp, (SIMPLE_PB*)buf);
simple_pb_t* spb = read_pb_into(fp, (simple_pb_t*)buf);
if(!spb) {
fputs("Bad spb file", stderr);
pthread_exit(NULL);
@@ -475,7 +475,7 @@ static server_ack_t del(FILE *fp, const char* key, int len, char ret[4]) {
uint8_t buf[8+DICTSZ];
while(has_next(fp, ch)) {
if(!ch) continue; // skip null bytes
SIMPLE_PB* spb = read_pb_into(fp, (SIMPLE_PB*)buf);
simple_pb_t* spb = read_pb_into(fp, (simple_pb_t*)buf);
if(!spb) {
fputs("Bad spb file", stderr);
pthread_exit(NULL);
@@ -1009,7 +1009,7 @@ int main(int argc, char *argv[]) {
}
if(~((uintptr_t)fp)) {
uint8_t buf[8+sizeof(config_t)];
SIMPLE_PB* spb = read_pb_into(fp, (SIMPLE_PB*)buf);
simple_pb_t* spb = read_pb_into(fp, (simple_pb_t*)buf);
if(!spb) {
fprintf(stderr, "Error reading config file: %s\n", argv[as_daemon?4:3]);
return 8;