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