Blame


1 8951cb19 2022-07-01 op /*
2 8951cb19 2022-07-01 op * Copyright (c) 2016 Nicholas Marriott <nicholas.marriott@gmail.com>
3 8951cb19 2022-07-01 op * Copyright (c) 2017 Kristaps Dzonsons <kristaps@bsd.lv>
4 8951cb19 2022-07-01 op * Copyright (c) 2020 Stephen Gregoratto <dev@sgregoratto.me>
5 8951cb19 2022-07-01 op *
6 8951cb19 2022-07-01 op * Permission to use, copy, modify, and distribute this software for any
7 8951cb19 2022-07-01 op * purpose with or without fee is hereby granted, provided that the above
8 8951cb19 2022-07-01 op * copyright notice and this permission notice appear in all copies.
9 8951cb19 2022-07-01 op *
10 8951cb19 2022-07-01 op * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 8951cb19 2022-07-01 op * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 8951cb19 2022-07-01 op * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 8951cb19 2022-07-01 op * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 8951cb19 2022-07-01 op * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
15 8951cb19 2022-07-01 op * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
16 8951cb19 2022-07-01 op * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 8951cb19 2022-07-01 op */
18 8951cb19 2022-07-01 op
19 f164f2f4 2022-07-01 op #include "config.h"
20 f164f2f4 2022-07-01 op
21 8951cb19 2022-07-01 op #include <sys/types.h>
22 8951cb19 2022-07-01 op
23 8951cb19 2022-07-01 op #include <errno.h>
24 8951cb19 2022-07-01 op
25 8951cb19 2022-07-01 op #if HAVE_GETEXECNAME
26 8951cb19 2022-07-01 op #include <stdlib.h>
27 8951cb19 2022-07-01 op const char *
28 8951cb19 2022-07-01 op getprogname(void)
29 8951cb19 2022-07-01 op {
30 8951cb19 2022-07-01 op return getexecname();
31 8951cb19 2022-07-01 op }
32 8951cb19 2022-07-01 op #elif HAVE_PROGRAM_INVOCATION_SHORT_NAME
33 8951cb19 2022-07-01 op const char *
34 8951cb19 2022-07-01 op getprogname(void)
35 8951cb19 2022-07-01 op {
36 8951cb19 2022-07-01 op return (program_invocation_short_name);
37 8951cb19 2022-07-01 op }
38 8951cb19 2022-07-01 op #elif HAVE___PROGNAME
39 8951cb19 2022-07-01 op const char *
40 8951cb19 2022-07-01 op getprogname(void)
41 8951cb19 2022-07-01 op {
42 8951cb19 2022-07-01 op extern char *__progname;
43 8951cb19 2022-07-01 op
44 8951cb19 2022-07-01 op return (__progname);
45 8951cb19 2022-07-01 op }
46 8951cb19 2022-07-01 op #else
47 253e6ffe 2022-07-01 op #warning No getprogname available; falling back to mymenu
48 253e6ffe 2022-07-01 op const char *
49 253e6ffe 2022-07-01 op getprogname(void)
50 253e6ffe 2022-07-01 op {
51 253e6ffe 2022-07-01 op return ("mymenu");
52 253e6ffe 2022-07-01 op }
53 8951cb19 2022-07-01 op #endif