MCPcopy Create free account
hub / github.com/F-Stack/f-stack / loadServerConfig

Function loadServerConfig

app/redis-6.2.6/src/config.c:647–679  ·  view source on GitHub ↗

Load the server configuration from the specified filename. * The function appends the additional configuration directives stored * in the 'options' string to the config file before loading. * * Both filename and options can be NULL, in such a case are considered * empty. This way loadServerConfig can be used to just load a file or * just load a string. */

Source from the content-addressed store, hash-verified

645 * empty. This way loadServerConfig can be used to just load a file or
646 * just load a string. */
647void loadServerConfig(char *filename, char config_from_stdin, char *options) {
648 sds config = sdsempty();
649 char buf[CONFIG_MAX_LINE+1];
650 FILE *fp;
651
652 /* Load the file content */
653 if (filename) {
654 if ((fp = fopen(filename,"r")) == NULL) {
655 serverLog(LL_WARNING,
656 "Fatal error, can't open config file '%s': %s",
657 filename, strerror(errno));
658 exit(1);
659 }
660 while(fgets(buf,CONFIG_MAX_LINE+1,fp) != NULL)
661 config = sdscat(config,buf);
662 fclose(fp);
663 }
664 /* Append content from stdin */
665 if (config_from_stdin) {
666 serverLog(LL_WARNING,"Reading config from stdin");
667 fp = stdin;
668 while(fgets(buf,CONFIG_MAX_LINE+1,fp) != NULL)
669 config = sdscat(config,buf);
670 }
671
672 /* Append the additional options */
673 if (options) {
674 config = sdscat(config,"\n");
675 config = sdscat(config,options);
676 }
677 loadServerConfigFromString(config);
678 sdsfree(config);
679}
680
681/*-----------------------------------------------------------------------------
682 * CONFIG SET implementation

Callers 2

mainFunction · 0.85

Calls 4

sdsemptyFunction · 0.85
sdscatFunction · 0.85
sdsfreeFunction · 0.85

Tested by

no test coverage detected