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

Function configGetCommand

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

Source from the content-addressed store, hash-verified

918} while(0)
919
920void configGetCommand(client *c) {
921 robj *o = c->argv[2];
922 void *replylen = addReplyDeferredLen(c);
923 char *pattern = o->ptr;
924 char buf[128];
925 int matches = 0;
926 serverAssertWithInfo(c,o,sdsEncodedObject(o));
927
928 /* Iterate the configs that are standard */
929 for (standardConfig *config = configs; config->name != NULL; config++) {
930 if (stringmatch(pattern,config->name,1)) {
931 addReplyBulkCString(c,config->name);
932 config->interface.get(c,config->data);
933 matches++;
934 }
935 if (config->alias && stringmatch(pattern,config->alias,1)) {
936 addReplyBulkCString(c,config->alias);
937 config->interface.get(c,config->data);
938 matches++;
939 }
940 }
941
942 /* String values */
943 config_get_string_field("logfile",server.logfile);
944
945 /* Numerical values */
946 config_get_numerical_field("watchdog-period",server.watchdog_period);
947
948 /* Everything we can't handle with macros follows. */
949
950 if (stringmatch(pattern,"dir",1)) {
951 char buf[1024];
952
953 if (getcwd(buf,sizeof(buf)) == NULL)
954 buf[0] = '\0';
955
956 addReplyBulkCString(c,"dir");
957 addReplyBulkCString(c,buf);
958 matches++;
959 }
960 if (stringmatch(pattern,"save",1)) {
961 sds buf = sdsempty();
962 int j;
963
964 for (j = 0; j < server.saveparamslen; j++) {
965 buf = sdscatprintf(buf,"%jd %d",
966 (intmax_t)server.saveparams[j].seconds,
967 server.saveparams[j].changes);
968 if (j != server.saveparamslen-1)
969 buf = sdscatlen(buf," ",1);
970 }
971 addReplyBulkCString(c,"save");
972 addReplyBulkCString(c,buf);
973 sdsfree(buf);
974 matches++;
975 }
976 if (stringmatch(pattern,"client-output-buffer-limit",1)) {
977 sds buf = sdsempty();

Callers 1

configCommandFunction · 0.85

Calls 13

addReplyDeferredLenFunction · 0.85
stringmatchFunction · 0.85
addReplyBulkCStringFunction · 0.85
sdsemptyFunction · 0.85
sdscatprintfFunction · 0.85
sdscatlenFunction · 0.85
sdsfreeFunction · 0.85
getClientTypeNameFunction · 0.85
snprintfFunction · 0.85
addReplyBulkSdsFunction · 0.85
sdsjoinFunction · 0.85

Tested by

no test coverage detected