Mon, 16 Feb 2004 00:44:56 +0100
trunk: changeset 1303
Moved header files to top level directory.
| 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 | ||
| 15 | #ifdef CONFIG_LOCALE | |
| 16 | #include <libintl.h> | |
| 17 | #endif | |
| 18 | ||
| 5 | 19 | #include <libtu/util.h> |
| 20 | #include <libtu/misc.h> | |
| 0 | 21 | |
| 22 | ||
| 23 | static const char *progname=NULL; | |
| 24 | ||
| 25 | ||
| 12 | 26 | void libtu_init(const char *argv0) |
| 0 | 27 | { |
| 28 | progname=argv0; | |
| 29 | ||
| 30 | #ifdef CONFIG_LOCALE | |
| 31 | textdomain(simple_basename(argv0)); | |
| 32 | #endif | |
| 33 | } | |
| 34 | ||
| 35 | ||
| 12 | 36 | void libtu_init_copt(int argc, char *const argv[], |
| 37 | const OptParserCommonInfo *cinfo) | |
| 0 | 38 | { |
| 12 | 39 | int opt; |
| 40 | ||
| 41 | libtu_init(argv[0]); | |
| 42 | ||
| 43 | optparser_init(argc, argv, OPTP_DEFAULT, NULL, cinfo); | |
| 0 | 44 | |
| 12 | 45 | while((opt=optparser_get_opt())){ |
| 46 | switch(opt){ | |
| 47 | default: | |
| 48 | optparser_print_error(); | |
| 49 | exit(EXIT_FAILURE); | |
| 50 | } | |
| 51 | } | |
| 0 | 52 | } |
| 53 | ||
| 54 | ||
| 55 | const char *prog_execname() | |
| 56 | { | |
| 57 | return progname; | |
| 58 | } | |
| 59 |