186d7f5d3SJohn Marino.\" 286d7f5d3SJohn Marino.\" Copyright (c) 2001 Christopher G. Demetriou 386d7f5d3SJohn Marino.\" All rights reserved. 486d7f5d3SJohn Marino.\" 586d7f5d3SJohn Marino.\" Redistribution and use in source and binary forms, with or without 686d7f5d3SJohn Marino.\" modification, are permitted provided that the following conditions 786d7f5d3SJohn Marino.\" are met: 886d7f5d3SJohn Marino.\" 1. Redistributions of source code must retain the above copyright 986d7f5d3SJohn Marino.\" notice, this list of conditions and the following disclaimer. 1086d7f5d3SJohn Marino.\" 2. Redistributions in binary form must reproduce the above copyright 1186d7f5d3SJohn Marino.\" notice, this list of conditions and the following disclaimer in the 1286d7f5d3SJohn Marino.\" documentation and/or other materials provided with the distribution. 1386d7f5d3SJohn Marino.\" 3. All advertising materials mentioning features or use of this software 1486d7f5d3SJohn Marino.\" must display the following acknowledgement: 1586d7f5d3SJohn Marino.\" This product includes software developed for the 1686d7f5d3SJohn Marino.\" NetBSD Project. See http://www.netbsd.org/ for 1786d7f5d3SJohn Marino.\" information about NetBSD. 1886d7f5d3SJohn Marino.\" 4. The name of the author may not be used to endorse or promote products 1986d7f5d3SJohn Marino.\" derived from this software without specific prior written permission. 2086d7f5d3SJohn Marino.\" 2186d7f5d3SJohn Marino.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 2286d7f5d3SJohn Marino.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 2386d7f5d3SJohn Marino.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 2486d7f5d3SJohn Marino.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 2586d7f5d3SJohn Marino.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 2686d7f5d3SJohn Marino.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2786d7f5d3SJohn Marino.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2886d7f5d3SJohn Marino.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2986d7f5d3SJohn Marino.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 3086d7f5d3SJohn Marino.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 3186d7f5d3SJohn Marino.\" 3286d7f5d3SJohn Marino.\" $FreeBSD: src/lib/libc/gen/getprogname.3,v 1.1.2.5 2001/12/14 18:33:51 ru Exp $ 3386d7f5d3SJohn Marino.\" $DragonFly: src/lib/libc/gen/getprogname.3,v 1.3 2004/03/11 12:28:50 hmp Exp $ 3486d7f5d3SJohn Marino.\" 3586d7f5d3SJohn Marino.Dd May 1, 2001 3686d7f5d3SJohn Marino.Dt GETPROGNAME 3 3786d7f5d3SJohn Marino.Os 3886d7f5d3SJohn Marino.Sh NAME 3986d7f5d3SJohn Marino.Nm getprogname , 4086d7f5d3SJohn Marino.Nm setprogname 4186d7f5d3SJohn Marino.Nd get or set the program name 4286d7f5d3SJohn Marino.Sh LIBRARY 4386d7f5d3SJohn Marino.Lb libc 4486d7f5d3SJohn Marino.Sh SYNOPSIS 4586d7f5d3SJohn Marino.In stdlib.h 4686d7f5d3SJohn Marino.Ft const char * 4786d7f5d3SJohn Marino.Fn getprogname "void" 4886d7f5d3SJohn Marino.Ft void 4986d7f5d3SJohn Marino.Fn setprogname "const char *progname" 5086d7f5d3SJohn Marino.Sh DESCRIPTION 5186d7f5d3SJohn MarinoThe 5286d7f5d3SJohn Marino.Fn getprogname 5386d7f5d3SJohn Marinoand 5486d7f5d3SJohn Marino.Fn setprogname 5586d7f5d3SJohn Marinofunctions manipulate the name of the current program. 5686d7f5d3SJohn MarinoThey are used by error-reporting routines to produce 5786d7f5d3SJohn Marinoconsistent output. 5886d7f5d3SJohn Marino.Pp 5986d7f5d3SJohn MarinoThe 6086d7f5d3SJohn Marino.Fn getprogname 6186d7f5d3SJohn Marinofunction returns the name of the program. 6286d7f5d3SJohn MarinoIf the name has not been set yet, it will return 6386d7f5d3SJohn Marino.Dv NULL . 6486d7f5d3SJohn Marino.Pp 6586d7f5d3SJohn MarinoThe 6686d7f5d3SJohn Marino.Fn setprogname 6786d7f5d3SJohn Marinofunction sets the name of the program to be the last component of the 6886d7f5d3SJohn Marino.Fa progname 6986d7f5d3SJohn Marinoargument. 7086d7f5d3SJohn MarinoSince a pointer to the given string is kept as the program name, 7186d7f5d3SJohn Marinoit should not be modified for the rest of the program's lifetime. 7286d7f5d3SJohn Marino.Pp 7386d7f5d3SJohn MarinoIn 7486d7f5d3SJohn Marino.Dx , 7586d7f5d3SJohn Marinothe name of the program is set by the start-up code that is run before 7686d7f5d3SJohn Marino.Fn main ; 7786d7f5d3SJohn Marinothus, 7886d7f5d3SJohn Marinorunning 7986d7f5d3SJohn Marino.Fn setprogname 8086d7f5d3SJohn Marinois not necessary. 8186d7f5d3SJohn MarinoPrograms that desire maximum portability should still call it; 8286d7f5d3SJohn Marinoon another operating system, 8386d7f5d3SJohn Marinothese functions may be implemented in a portability library. 8486d7f5d3SJohn MarinoCalling 8586d7f5d3SJohn Marino.Fn setprogname 8686d7f5d3SJohn Marinoallows the aforementioned library to learn the program name without 8786d7f5d3SJohn Marinomodifications to the start-up code. 8886d7f5d3SJohn Marino.Sh SEE ALSO 8986d7f5d3SJohn Marino.Xr err 3 , 9086d7f5d3SJohn Marino.Xr setproctitle 3 9186d7f5d3SJohn Marino.Sh HISTORY 9286d7f5d3SJohn MarinoThese functions first appeared in 9386d7f5d3SJohn Marino.Nx 1.6 , 9486d7f5d3SJohn Marinoand made their way into 9586d7f5d3SJohn Marino.Fx 4.4 . 96