33 * @author Martin Pulec <[email protected] > 44 */
55/*
6- * Copyright (c) 2011-2023 CESNET, z. s. p. o.
6+ * Copyright (c) 2011-2025 CESNET
77 * All rights reserved.
88 *
99 * Redistribution and use in source and binary forms, with or without
@@ -85,45 +85,59 @@ enum library_class {
8585 LIBRARY_CLASS_AUDIO_FILTER,
8686};
8787const void *load_library (const char *name, enum library_class, int abi_version);
88- void register_library (const char *name, const void *info, enum library_class, int abi_version, int hidden);
88+ void register_library (const char *name, const void *info, enum library_class,
89+ int abi_version, unsigned visibility_flag);
8990void list_modules (enum library_class, int abi_version, bool full);
9091bool list_all_modules ();
9192#ifdef __cplusplus
9293}
9394#endif
9495
96+ enum module_flag {
97+ MODULE_SHOW_VISIBLE_ONLY = 0 , // /< display only modules w/o flag
98+ MODULE_FLAG_HIDDEN = 1 << 0 , // /< flag - do not show in listing
99+ MODULE_FLAG_ALIAS =
100+ 1 << 1 , // /< ditto + hide for GUI, for explicit init only
101+ MODULE_SHOW_ALL =
102+ MODULE_FLAG_HIDDEN | MODULE_FLAG_ALIAS, // /< display all modules
103+ };
104+
95105#ifdef __cplusplus
96106#include < map>
97107#include < string>
98- std::map<std::string, const void *> get_libraries_for_class (enum library_class cls, int abi_version, bool include_hidden = true );
108+ std::map<std::string, const void *>
109+ get_libraries_for_class (enum library_class cls, int abi_version,
110+ unsigned include_flags = MODULE_FLAG_HIDDEN);
99111#endif
100112
101113/* *
102114 * Placeholder that installs module via constructor for every macro
103- * REGISTER_MODULE/REGISTER_MODULE_HIDDEN call
115+ * REGISTER_MODULE* call
104116 * @param name non-quoted module name
105117 * @param lclass class of the module
106118 * @param abi abi version (specific for every class)
107119 * @param funcname unique function name that will be used to register
108120 * the module (as a constructor)
109- * @param hidden 0/1 - whether the module should be visible by eg. '-c help'
110- * ( for technical and deprecated modules), default true
121+ * @param flag optional flag to limit visibility (@ref module_flag;
122+ * for technical, deprecated modules and aliases ), default 0
111123 */
112- #define REGISTER_MODULE_FUNCNAME (name, info, lclass, abi, funcname, hidden ) static void funcname (void ) __attribute__((constructor));\
124+ #define REGISTER_MODULE_FUNCNAME (name, info, lclass, abi, funcname, flag ) \
125+ static void funcname (void ) __attribute__((constructor)); \
113126\
114127static void funcname (void )\
115128{\
116- register_library (#name, info, lclass, abi, hidden );\
129+ register_library (#name, info, lclass, abi, flag );\
117130}\
118131struct NOT_DEFINED_STRUCT_THAT_SWALLOWS_SEMICOLON
119132
120- #define REGISTER_MODULE_FUNC_FUNCNAME (name, func, lclass, abi, funcname, hidden ) static void funcname (void ) __attribute__((constructor));\
133+ #define REGISTER_MODULE_FUNC_FUNCNAME (name, func, lclass, abi, funcname, flag ) \
134+ static void funcname (void ) __attribute__((constructor)); \
121135\
122136static void funcname (void )\
123137{\
124138 const void *info = func ();\
125139 if (info) {\
126- register_library (#name, info, lclass, abi, hidden );\
140+ register_library (#name, info, lclass, abi, flag );\
127141 }\
128142}\
129143struct NOT_DEFINED_STRUCT_THAT_SWALLOWS_SEMICOLON
@@ -150,10 +164,11 @@ struct NOT_DEFINED_STRUCT_THAT_SWALLOWS_SEMICOLON
150164#define REGISTER_MODULE_WITH_FUNC (name, func, lclass, abi ) REGISTER_MODULE_FUNC_FUNCNAME(name, func, lclass, abi, UNIQUE_LABEL, 0 )
151165
152166/* *
153- * Similar to @ref REGISTER_MODULE but do not show the module under help
154- * of corresponding class (usable for technical or deprecated modules).
167+ * Similar to @ref REGISTER_MODULE but allow @ref module_flag to be added to limit visibility.
155168 */
156- #define REGISTER_HIDDEN_MODULE (name, info, lclass, abi ) REGISTER_MODULE_FUNCNAME(name, info, lclass, abi, UNIQUE_LABEL, 1 )
169+ #define REGISTER_MODULE_WITH_FLAG (name, info, lclass, abi, flag ) \
170+ REGISTER_MODULE_FUNCNAME (name, info, lclass, abi, UNIQUE_LABEL, flag)
171+ #define REGISTER_HIDDEN_MODULE (name, info, lclass, abi ) REGISTER_MODULE_WITH_FLAG(name, info, lclass, abi, MODULE_FLAG_HIDDEN)
157172
158173#endif // defined LIB_COMMON_H
159174
0 commit comments