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. */
| 7095 | * NULL or empty string indicates the default section (only `<modulename>`) is used. |
| 7096 | * When return value is REDISMODULE_ERR, the section should and will be skipped. */ |
| 7097 | int RM_InfoAddSection(RedisModuleInfoCtx *ctx, char *name) { |
| 7098 | sds full_name = sdsdup(ctx->module->name); |
| 7099 | if (name != NULL && strlen(name) > 0) |
| 7100 | full_name = sdscatfmt(full_name, "_%s", name); |
| 7101 | |
| 7102 | /* Implicitly end dicts, instead of returning an error which is likely un checked. */ |
| 7103 | if (ctx->in_dict_field) |
| 7104 | RM_InfoEndDictField(ctx); |
| 7105 | |
| 7106 | /* proceed only if: |
| 7107 | * 1) no section was requested (emit all) |
| 7108 | * 2) the module name was requested (emit all) |
| 7109 | * 3) this specific section was requested. */ |
| 7110 | if (ctx->requested_section) { |
| 7111 | if (strcasecmp(ctx->requested_section, full_name) && |
| 7112 | strcasecmp(ctx->requested_section, ctx->module->name)) { |
| 7113 | sdsfree(full_name); |
| 7114 | ctx->in_section = 0; |
| 7115 | return REDISMODULE_ERR; |
| 7116 | } |
| 7117 | } |
| 7118 | if (ctx->sections++) ctx->info = sdscat(ctx->info,"\r\n"); |
| 7119 | ctx->info = sdscatfmt(ctx->info, "# %S\r\n", full_name); |
| 7120 | ctx->in_section = 1; |
| 7121 | sdsfree(full_name); |
| 7122 | return REDISMODULE_OK; |
| 7123 | } |
| 7124 | |
| 7125 | /* Starts a dict field, similar to the ones in INFO KEYSPACE. Use normal |
| 7126 | * RedisModule_InfoAddField* functions to add the items to this field, and |
nothing calls this directly
no test coverage detected