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 8951cb19 2022-07-01 op #include <sys/types.h>
20 8951cb19 2022-07-01 op
21 8951cb19 2022-07-01 op #include <errno.h>
22 8951cb19 2022-07-01 op
23 8951cb19 2022-07-01 op #if HAVE_GETEXECNAME
24 8951cb19 2022-07-01 op #include <stdlib.h>
25 8951cb19 2022-07-01 op const char *
26 8951cb19 2022-07-01 op getprogname(void)
27 8951cb19 2022-07-01 op {
28 8951cb19 2022-07-01 op return getexecname();
29 8951cb19 2022-07-01 op }
30 8951cb19 2022-07-01 op #elif HAVE_PROGRAM_INVOCATION_SHORT_NAME
31 8951cb19 2022-07-01 op const char *
32 8951cb19 2022-07-01 op getprogname(void)
33 8951cb19 2022-07-01 op {
34 8951cb19 2022-07-01 op return (program_invocation_short_name);
35 8951cb19 2022-07-01 op }
36 8951cb19 2022-07-01 op #elif HAVE___PROGNAME
37 8951cb19 2022-07-01 op const char *
38 8951cb19 2022-07-01 op getprogname(void)
39 8951cb19 2022-07-01 op {
40 8951cb19 2022-07-01 op extern char *__progname;
41 8951cb19 2022-07-01 op
42 8951cb19 2022-07-01 op return (__progname);
43 8951cb19 2022-07-01 op }
44 8951cb19 2022-07-01 op #else
45 8951cb19 2022-07-01 op #error No getprogname available.
46 8951cb19 2022-07-01 op #endif