+/* 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
+ * emtpy. This way loadServerConfig can be used to just load a file or
+ * just load a string. */
+void loadServerConfig(char *filename, char *options) {
+ sds config = sdsempty();
+ char buf[REDIS_CONFIGLINE_MAX+1];
+
+ /* Load the file content */
+ if (filename) {
+ FILE *fp;
+
+ if (filename[0] == '-' && filename[1] == '\0') {
+ fp = stdin;
+ } else {
+ if ((fp = fopen(filename,"r")) == NULL) {
+ redisLog(REDIS_WARNING,
+ "Fatal error, can't open config file '%s'", filename);
+ exit(1);
+ }
+ }
+ while(fgets(buf,REDIS_CONFIGLINE_MAX+1,fp) != NULL)
+ config = sdscat(config,buf);
+ if (fp != stdin) fclose(fp);
+ }
+ /* Append the additional options */
+ if (options) {
+ config = sdscat(config,"\n");
+ config = sdscat(config,options);
+ }
+ loadServerConfigFromString(config);
+ sdsfree(config);
+}
+