2N/A/* Program name management. 2N/A Copyright (C) 2001-2003, 2005-2010 Free Software Foundation, Inc. 2N/A Written by Bruno Haible <bruno@clisp.org>, 2001. 2N/A This program is free software: you can redistribute it and/or modify 2N/A it under the terms of the GNU General Public License as published by 2N/A the Free Software Foundation; either version 3 of the License, or 2N/A (at your option) any later version. 2N/A This program is distributed in the hope that it will be useful, 2N/A but WITHOUT ANY WARRANTY; without even the implied warranty of 2N/A MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 2N/A GNU General Public License for more details. 2N/A You should have received a copy of the GNU General Public License 2N/A#
include <
errno.h>
/* get program_invocation_name declaration */ 2N/A/* String containing name the program is called with. 2N/A To be initialized by main(). */ 2N/A/* Set program_name, based on argv[0]. 2N/A argv0 must be a string allocated with indefinite extent, and must not be 2N/A modified after this call. */ 2N/A /* libtool creates a temporary executable whose name is sometimes prefixed 2N/A with "lt-" (depends on the platform). It also makes argv[0] absolute. 2N/A But the name of the temporary executable is a detail that should not be 2N/A visible to the end user and to the test suite. 2N/A Remove this "<dirname>/.libs/" or "<dirname>/.libs/lt-" prefix here. */ 2N/A /* Sanity check. POSIX requires the invoking process to pass a non-NULL 2N/A /* It's a bug in the invoking program. Help diagnosing it. */ 2N/A fputs (
"A NULL argv[0] was passed through an exec system call.\n",
2N/A /* On glibc systems, remove the "lt-" prefix from the variable 2N/A program_invocation_short_name. */ 2N/A /* But don't strip off a leading <dirname>/ in general, because when the user 2N/A he should get the error message 2N/A cp: `foo' and `foo' are the same file 2N/A /* On glibc systems, the error() function comes from libc and uses the 2N/A variable program_invocation_name, not program_name. So set this variable