getprogname (3)
Leading comments
Copyright (c) 2001 Christopher G. Demetriou All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation ...
NAME
getprogname setprogname - get or set the program nameLIBRARY
Lb libbsdSYNOPSIS
In stdlib.h (See libbsd(7) for include usage.) Ft const char * Fn getprogname void Ft void Fn setprogname const char *prognameDESCRIPTION
The Fn getprogname and Fn setprogname functions manipulate the name of the current program. They are used by error-reporting routines to produce consistent output.The Fn getprogname function returns the name of the program. If the name has not been set yet, it will return NULL
The Fn setprogname function sets the name of the program to be the last component of the Fa progname argument. Since a pointer to the given string is kept as the program name, it should not be modified for the rest of the program's lifetime.
In Fx , the name of the program is set by the start-up code that is run before Fn main ; thus, running Fn setprogname is not necessary. Programs that desire maximum portability should still call it; on another operating system, these functions may be implemented in a portability library. Calling Fn setprogname allows the aforementioned library to learn the program name without modifications to the start-up code.