1 ///////////////////////////////////////////////////////////////////////////////
3 /// \file tuklib_progname.c
4 /// \brief Program name to be displayed in messages
6 // Author: Lasse Collin
8 // This file has been put into the public domain.
9 // You can do whatever you want with this file.
11 ///////////////////////////////////////////////////////////////////////////////
13 #include "tuklib_progname.h"
17 #ifndef HAVE_PROGRAM_INVOCATION_NAME
18 char *progname
= NULL
;
23 tuklib_progname_init(char **argv
)
26 // On these systems, argv[0] always has the full path and .exe
27 // suffix even if the user just types the plain program name.
28 // We modify argv[0] to make it nicer to read.
30 // Strip the leading path.
31 char *p
= argv
[0] + strlen(argv
[0]);
32 while (argv
[0] < p
&& p
[-1] != '/' && p
[-1] != '\\')
37 // Strip the .exe suffix.
43 for (p
= argv
[0]; *p
!= '\0'; ++p
)
44 if (*p
>= 'A' && *p
<= 'Z')