mirror of
https://github.com/fumiama/simple-dict.git
synced 2026-06-05 02:00:25 +08:00
适配最新spb
This commit is contained in:
@@ -20,7 +20,7 @@ int main() {
|
|||||||
puts("Check config...");
|
puts("Check config...");
|
||||||
fp = fopen("cfg.sp", "rb");
|
fp = fopen("cfg.sp", "rb");
|
||||||
if(fp) {
|
if(fp) {
|
||||||
SIMPLE_PB* spb = get_pb(fp);
|
simple_pb_t* spb = get_pb(fp);
|
||||||
memset(&cfg, 0, sizeof(config_t));
|
memset(&cfg, 0, sizeof(config_t));
|
||||||
memcpy(&cfg, spb->target, sizeof(config_t));
|
memcpy(&cfg, spb->target, sizeof(config_t));
|
||||||
printf("set pwd: %s, sps: %s\n", cfg.pwd, cfg.sps);
|
printf("set pwd: %s, sps: %s\n", cfg.pwd, cfg.sps);
|
||||||
|
|||||||
2
client.c
2
client.c
@@ -156,7 +156,7 @@ int main(int argc, char *argv[]) { // usage: ./client cfg.sp host port
|
|||||||
perror("fopen");
|
perror("fopen");
|
||||||
return 1;
|
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) {
|
if(!spb) {
|
||||||
fprintf(stderr, "Error reading config file: %s\n", argv[1]);
|
fprintf(stderr, "Error reading config file: %s\n", argv[1]);
|
||||||
return 2;
|
return 2;
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ int main(int argc, char** argv) {
|
|||||||
int ch;
|
int ch;
|
||||||
|
|
||||||
while(has_next(old, ch)) {
|
while(has_next(old, ch)) {
|
||||||
SIMPLE_PB* spb = get_pb(old);
|
simple_pb_t* spb = get_pb(old);
|
||||||
DICTNEW* d;
|
DICTNEW* d;
|
||||||
switch(spb->struct_len) {
|
switch(spb->struct_len) {
|
||||||
case sizeof(DICTOLD):
|
case sizeof(DICTOLD):
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ int main(int argc, char** argv) {
|
|||||||
int ch;
|
int ch;
|
||||||
|
|
||||||
while(has_next(f, 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;
|
struct dict_t* d;
|
||||||
if(!spb) {
|
if(!spb) {
|
||||||
fputs("Bad spb file", stderr);
|
fputs("Bad spb file", stderr);
|
||||||
|
|||||||
10
server.c
10
server.c
@@ -223,7 +223,7 @@ static void init_dict_pool(FILE *fp) {
|
|||||||
int ch;
|
int ch;
|
||||||
while(has_next(fp, ch)) {
|
while(has_next(fp, ch)) {
|
||||||
if(!ch) continue; // skip null bytes
|
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) {
|
if(!spb) {
|
||||||
fputs("Bad spb file", stderr);
|
fputs("Bad spb file", stderr);
|
||||||
exit(EXIT_FAILURE);
|
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);
|
pthread_cleanup_push((void*)&close_dict, (void*)(uintptr_t)timer->index);
|
||||||
while(has_next(fp, ch)) {
|
while(has_next(fp, ch)) {
|
||||||
if(!ch) continue; // skip null bytes
|
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
|
if(!spb) continue; // skip error bytes
|
||||||
dict_t* d = (dict_t*)spb->target;
|
dict_t* d = (dict_t*)spb->target;
|
||||||
if(!strcmp(timer->dat, d->key)) {
|
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];
|
uint8_t buf[8+DICTSZ];
|
||||||
while(has_next(fp, ch)) {
|
while(has_next(fp, ch)) {
|
||||||
if(!ch) continue; // skip null bytes
|
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) {
|
if(!spb) {
|
||||||
fputs("Bad spb file", stderr);
|
fputs("Bad spb file", stderr);
|
||||||
pthread_exit(NULL);
|
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];
|
uint8_t buf[8+DICTSZ];
|
||||||
while(has_next(fp, ch)) {
|
while(has_next(fp, ch)) {
|
||||||
if(!ch) continue; // skip null bytes
|
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) {
|
if(!spb) {
|
||||||
fputs("Bad spb file", stderr);
|
fputs("Bad spb file", stderr);
|
||||||
pthread_exit(NULL);
|
pthread_exit(NULL);
|
||||||
@@ -1009,7 +1009,7 @@ int main(int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
if(~((uintptr_t)fp)) {
|
if(~((uintptr_t)fp)) {
|
||||||
uint8_t buf[8+sizeof(config_t)];
|
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) {
|
if(!spb) {
|
||||||
fprintf(stderr, "Error reading config file: %s\n", argv[as_daemon?4:3]);
|
fprintf(stderr, "Error reading config file: %s\n", argv[as_daemon?4:3]);
|
||||||
return 8;
|
return 8;
|
||||||
|
|||||||
Reference in New Issue
Block a user