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

Function enumConfigSet

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

Source from the content-addressed store, hash-verified

1884}
1885
1886static int enumConfigSet(typeData data, sds value, int update, const char **err) {
1887 int enumval = configEnumGetValue(data.enumd.enum_value, value);
1888 if (enumval == INT_MIN) {
1889 sds enumerr = sdsnew("argument must be one of the following: ");
1890 configEnum *enumNode = data.enumd.enum_value;
1891 while(enumNode->name != NULL) {
1892 enumerr = sdscatlen(enumerr, enumNode->name,
1893 strlen(enumNode->name));
1894 enumerr = sdscatlen(enumerr, ", ", 2);
1895 enumNode++;
1896 }
1897 sdsrange(enumerr,0,-3); /* Remove final ", ". */
1898
1899 strncpy(loadbuf, enumerr, LOADBUF_SIZE);
1900 loadbuf[LOADBUF_SIZE - 1] = '\0';
1901
1902 sdsfree(enumerr);
1903 *err = loadbuf;
1904 return 0;
1905 }
1906 if (data.enumd.is_valid_fn && !data.enumd.is_valid_fn(enumval, err))
1907 return 0;
1908 int prev = *(data.enumd.config);
1909 *(data.enumd.config) = enumval;
1910 if (update && data.enumd.update_fn && !data.enumd.update_fn(enumval, prev, err)) {
1911 *(data.enumd.config) = prev;
1912 return 0;
1913 }
1914 return 1;
1915}
1916
1917static void enumConfigGet(client *c, typeData data) {
1918 addReplyBulkCString(c, configEnumGetNameOrUnknown(data.enumd.enum_value,*data.enumd.config));

Callers

nothing calls this directly

Calls 6

configEnumGetValueFunction · 0.85
sdsnewFunction · 0.85
sdscatlenFunction · 0.85
sdsrangeFunction · 0.85
strncpyFunction · 0.85
sdsfreeFunction · 0.85

Tested by

no test coverage detected