Mon, 20 Apr 2020 10:14:32 -0500
Convert README to markdown
0 | 1 | /* |
2 | * libtu/util.c | |
3 | * | |
36 | 4 | * Copyright (c) Tuomo Valkonen 1999-2002. |
53 | 5 | * |
6 | * You may distribute and modify this library under the terms of either | |
7 | * the Clarified Artistic License or the GNU LGPL, version 2.1 or later. | |
0 | 8 | */ |
9 | ||
10 | #include <stdarg.h> | |
11 | #include <stdio.h> | |
12 | #include <stdlib.h> | |
13 | #include <string.h> | |
14 | ||
117
c7ad4b23a277
locale.h name seems to conflict with system locale.h name on some systems
tuomov
parents:
112
diff
changeset
|
15 | #include "localex.h" |
70 | 16 | #include "util.h" |
17 | #include "misc.h" | |
0 | 18 | |
19 | ||
20 | static const char *progname=NULL; | |
21 | ||
22 | ||
12 | 23 | void libtu_init(const char *argv0) |
0 | 24 | { |
62 | 25 | progname=argv0; |
85 | 26 | |
112 | 27 | #ifndef CF_NO_GETTEXT |
62 | 28 | textdomain(simple_basename(argv0)); |
0 | 29 | #endif |
30 | } | |
31 | ||
32 | ||
109
96a557abc364
Renamed `prog_execname` `libtu_progname` and added `libtu_progbasename`.
Tuomo Valkonen <tuomov@iki.fi>
parents:
85
diff
changeset
|
33 | const char *libtu_progname() |
0 | 34 | { |
62 | 35 | return progname; |
0 | 36 | } |
37 | ||
109
96a557abc364
Renamed `prog_execname` `libtu_progname` and added `libtu_progbasename`.
Tuomo Valkonen <tuomov@iki.fi>
parents:
85
diff
changeset
|
38 | |
96a557abc364
Renamed `prog_execname` `libtu_progname` and added `libtu_progbasename`.
Tuomo Valkonen <tuomov@iki.fi>
parents:
85
diff
changeset
|
39 | const char *libtu_progbasename() |
96a557abc364
Renamed `prog_execname` `libtu_progname` and added `libtu_progbasename`.
Tuomo Valkonen <tuomov@iki.fi>
parents:
85
diff
changeset
|
40 | { |
96a557abc364
Renamed `prog_execname` `libtu_progname` and added `libtu_progbasename`.
Tuomo Valkonen <tuomov@iki.fi>
parents:
85
diff
changeset
|
41 | const char *s=strrchr(progname, '/'); |
96a557abc364
Renamed `prog_execname` `libtu_progname` and added `libtu_progbasename`.
Tuomo Valkonen <tuomov@iki.fi>
parents:
85
diff
changeset
|
42 | |
96a557abc364
Renamed `prog_execname` `libtu_progname` and added `libtu_progbasename`.
Tuomo Valkonen <tuomov@iki.fi>
parents:
85
diff
changeset
|
43 | return (s==NULL ? progname : s+1); |
96a557abc364
Renamed `prog_execname` `libtu_progname` and added `libtu_progbasename`.
Tuomo Valkonen <tuomov@iki.fi>
parents:
85
diff
changeset
|
44 | } |
96a557abc364
Renamed `prog_execname` `libtu_progname` and added `libtu_progbasename`.
Tuomo Valkonen <tuomov@iki.fi>
parents:
85
diff
changeset
|
45 |