| 475 | } |
| 476 | |
| 477 | void loadServerConfigFromString(char *config) { |
| 478 | const char *err = NULL; |
| 479 | int linenum = 0, totlines, i; |
| 480 | int slaveof_linenum = 0; |
| 481 | sds *lines; |
| 482 | int save_loaded = 0; |
| 483 | |
| 484 | lines = sdssplitlen(config,strlen(config),"\n",1,&totlines); |
| 485 | |
| 486 | for (i = 0; i < totlines; i++) { |
| 487 | sds *argv; |
| 488 | int argc; |
| 489 | |
| 490 | linenum = i+1; |
| 491 | lines[i] = sdstrim(lines[i]," \t\r\n"); |
| 492 | |
| 493 | /* Skip comments and blank lines */ |
| 494 | if (lines[i][0] == '#' || lines[i][0] == '\0') continue; |
| 495 | |
| 496 | /* Split into arguments */ |
| 497 | argv = sdssplitargs(lines[i],&argc); |
| 498 | if (argv == NULL) { |
| 499 | err = "Unbalanced quotes in configuration line"; |
| 500 | goto loaderr; |
| 501 | } |
| 502 | |
| 503 | /* Skip this line if the resulting command vector is empty. */ |
| 504 | if (argc == 0) { |
| 505 | sdsfreesplitres(argv,argc); |
| 506 | continue; |
| 507 | } |
| 508 | sdstolower(argv[0]); |
| 509 | |
| 510 | /* Iterate the configs that are standard */ |
| 511 | int match = 0; |
| 512 | for (standardConfig *config = configs; config->name != NULL; config++) { |
| 513 | if ((!strcasecmp(argv[0],config->name) || |
| 514 | (config->alias && !strcasecmp(argv[0],config->alias)))) |
| 515 | { |
| 516 | if (argc != 2) { |
| 517 | err = "wrong number of arguments"; |
| 518 | goto loaderr; |
| 519 | } |
| 520 | if (!config->interface.set(config->data, argv[1], 0, &err)) { |
| 521 | goto loaderr; |
| 522 | } |
| 523 | |
| 524 | match = 1; |
| 525 | break; |
| 526 | } |
| 527 | } |
| 528 | |
| 529 | if (match) { |
| 530 | sdsfreesplitres(argv,argc); |
| 531 | continue; |
| 532 | } |
| 533 | |
| 534 | /* Execute config directives */ |
no test coverage detected