Used to start a new section, before adding any fields. the section name will * be prefixed by ` _` and must only include A-Z,a-z,0-9. * NULL or empty string indicates the default section (only ` `) is used. * When return value is REDISMODULE_ERR, the section should and will be skipped. */
| 6903 | * NULL or empty string indicates the default section (only `<modulename>`) is used. |
| 6904 | * When return value is REDISMODULE_ERR, the section should and will be skipped. */ |
| 6905 | int RM_InfoAddSection(RedisModuleInfoCtx *ctx, char *name) { |
| 6906 | sds full_name = sdsdup(ctx->module->name); |
| 6907 | if (name != NULL && strlen(name) > 0) |
| 6908 | full_name = sdscatfmt(full_name, "_%s", name); |
| 6909 | |
| 6910 | /* Implicitly end dicts, instead of returning an error which is likely un checked. */ |
| 6911 | if (ctx->in_dict_field) |
| 6912 | RM_InfoEndDictField(ctx); |
| 6913 | |
| 6914 | /* proceed only if: |
| 6915 | * 1) no section was requested (emit all) |
| 6916 | * 2) the module name was requested (emit all) |
| 6917 | * 3) this specific section was requested. */ |
| 6918 | if (ctx->requested_section) { |
| 6919 | if (strcasecmp(ctx->requested_section, full_name) && |
| 6920 | strcasecmp(ctx->requested_section, ctx->module->name)) { |
| 6921 | sdsfree(full_name); |
| 6922 | ctx->in_section = 0; |
| 6923 | return REDISMODULE_ERR; |
| 6924 | } |
| 6925 | } |
| 6926 | if (ctx->sections++) ctx->info = sdscat(ctx->info,"\r\n"); |
| 6927 | ctx->info = sdscatfmt(ctx->info, "# %S\r\n", full_name); |
| 6928 | ctx->in_section = 1; |
| 6929 | sdsfree(full_name); |
| 6930 | return REDISMODULE_OK; |
| 6931 | } |
| 6932 | |
| 6933 | /* Starts a dict field, similar to the ones in INFO KEYSPACE. Use normal |
| 6934 | * RedisModule_InfoAddField* functions to add the items to this field, and |
nothing calls this directly
no test coverage detected