MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / configGetCommand

Function configGetCommand

src/config.cpp:1140–1300  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1138} while(0)
1139
1140void configGetCommand(client *c) {
1141 robj *o = c->argv[2];
1142 void *replylen = addReplyDeferredLen(c);
1143 char *pattern = szFromObj(o);
1144 char buf[128];
1145 int matches = 0;
1146 serverAssertWithInfo(c,o,sdsEncodedObject(o));
1147
1148 /* Iterate the configs that are standard */
1149 for (standardConfig *config = configs; config->name != NULL; config++) {
1150 if (stringmatch(pattern,config->name,1)) {
1151 addReplyBulkCString(c,config->name);
1152 config->interface.get(c,config->data);
1153 matches++;
1154 }
1155 if (config->alias && stringmatch(pattern,config->alias,1)) {
1156 addReplyBulkCString(c,config->alias);
1157 config->interface.get(c,config->data);
1158 matches++;
1159 }
1160 }
1161
1162 /* String values */
1163 config_get_string_field("logfile",g_pserver->logfile);
1164
1165 /* Numerical values */
1166 config_get_numerical_field("watchdog-period",g_pserver->watchdog_period);
1167
1168 /* Everything we can't handle with macros follows. */
1169
1170 if (stringmatch(pattern,"dir",1)) {
1171 char buf[1024];
1172
1173 if (getcwd(buf,sizeof(buf)) == NULL)
1174 buf[0] = '\0';
1175
1176 addReplyBulkCString(c,"dir");
1177 addReplyBulkCString(c,buf);
1178 matches++;
1179 }
1180 if (stringmatch(pattern,"save",1)) {
1181 sds buf = sdsempty();
1182 int j;
1183
1184 for (j = 0; j < g_pserver->saveparamslen; j++) {
1185 buf = sdscatprintf(buf,"%jd %d",
1186 (intmax_t)g_pserver->saveparams[j].seconds,
1187 g_pserver->saveparams[j].changes);
1188 if (j != g_pserver->saveparamslen-1)
1189 buf = sdscatlen(buf," ",1);
1190 }
1191 addReplyBulkCString(c,"save");
1192 addReplyBulkCString(c,buf);
1193 sdsfree(buf);
1194 matches++;
1195 }
1196 if (stringmatch(pattern,"client-output-buffer-limit",1)) {
1197 sds buf = sdsempty();

Callers 1

configCommandFunction · 0.85

Calls 15

addReplyDeferredLenFunction · 0.85
szFromObjFunction · 0.85
stringmatchFunction · 0.85
addReplyBulkCStringFunction · 0.85
sdsemptyFunction · 0.85
sdscatprintfFunction · 0.85
sdscatlenFunction · 0.85
sdsfreeFunction · 0.85
getClientTypeNameFunction · 0.85
listRewindFunction · 0.85
listNextFunction · 0.85

Tested by

no test coverage detected