IBM / portlibfori

A set of APIs to enable applications to be more easily ported to PASE on IBM i
Other
8 stars 7 forks source link

Implement setprogname #26

Closed markdirish closed 2 years ago

markdirish commented 2 years ago

Newer versions of rpm make use of getprogname/setprogname to change behavior of the main program. We had privately implemented getprogname, but this PR seeks to implement setprogname as well. I created a static global variable __progname to track the string, which is then returned from getprogname.

HOWEVER, I wasn't sure if it was best practice to modify current getprogname behavior, which is to simply go and grab the program name if it hasn't already been set. As written in this PR, getprogname will set the progname to the value retrieved from getargs if setprogname hasn't been called yet.

Part of: https://github.ibm.com/ibmi-oss/rpm-specs/issues/1527

Create an implementation of setprogname that sets the global progname variable Modify getprogname to use the new global progname variable, but still generates its own name if __progname is NULL Move progname functions to err.c

Signed-off-by: Mark Irish markdirish@gmail.com

markdirish commented 2 years ago

Made some changes. In the error functions that previously used getprogname, I changed to the new libutil_getprogname, but they will return NULL now unless the calling program calls libutil_setprogname

markdirish commented 2 years ago

Thanks for help navigating it. If I have to make a PR again, at least I'll know how everything fits together now.