On 9/7/19 1:51 PM, Alessio Vanni wrote: > Hello, > > 3rd-party applications often require a particular initialization, for > example localization or even just a custom version string. Currently, > clients can solve some of these situations by calling `GNUNET_OS_init' > in their `main' function, before `GNUNET_PROGRAM_run' (anything else not > covered by GNUNET_OS_ProjectData is left to the application itself.) > > For services, however, it is not as simple: the `GNUNET_SERVICE_MAIN' > macro completely hides the `main' function, so it's impossible to call > `GNUNET_OS_init' and the like. The macro could be expanded manually > (i.e. use an explicit `main' rather than the macro), but > `GNUNET_SERVICE_run_' has a name that, by convention, denotes a private > function that should not be used directly. > > I suggest to make the `GNUNET_SERVICE_run' public, so that applications > can run their initialization procedures before the service "connects" > with GNUnet. > > In theory this change would only require to change "run_" to "run" and > rewrite the gnunet-ext service accordingly. There's no need to outright > remove the macro as it can be used internally without problems.
Replacing the macro would destroy a planned future feature (aka "GNUnet
as a library"). So I'm not exactly for this. Using "run_" for code
that "really" knows what it's doing is something I'd consider
acceptable, but in this case there seems to be a better alternative: use
a C constructor to call GNUNET_OS_init():
/**
* Initialize i18n
*/
void __attribute__ ((constructor)) i18n_init () {
GNUNET_OS_init (...);
}
Constructors run before main(), so that should fix your problem nicely.
> In the meantime, the attached patch adds localization to services.
> Until now, even if the locale is changed, any message printed by a
> service would not be translated regardless of what the relevat PO file
> contains.
Looks reasonable, patch applied. Thanks!
signature.asc
Description: OpenPGP digital signature
_______________________________________________ GNUnet-developers mailing list [email protected] https://lists.gnu.org/mailman/listinfo/gnunet-developers
