1 /*
2  * libtu/util.c
3  *
4  * Copyright (c) Tuomo Valkonen 1999-2002.
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.
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 
19 #include <libtu/util.h>
20 #include <libtu/misc.h>
21 
22 
23 static const char *progname=NULL;
24 
25 
libtu_init(const char * argv0)26 void libtu_init(const char *argv0)
27 {
28 	progname=argv0;
29 
30 #ifdef CONFIG_LOCALE
31 	textdomain(simple_basename(argv0));
32 #endif
33 }
34 
35 
libtu_init_copt(int argc,char * const argv[],const OptParserCommonInfo * cinfo)36 void libtu_init_copt(int argc, char *const argv[],
37 					 const OptParserCommonInfo *cinfo)
38 {
39 	int opt;
40 
41 	libtu_init(argv[0]);
42 
43 	optparser_init(argc, argv, OPTP_DEFAULT, NULL, cinfo);
44 
45     while((opt=optparser_get_opt())){
46 		switch(opt){
47 		default:
48 			optparser_print_error();
49 			exit(EXIT_FAILURE);
50 		}
51 	}
52 }
53 
54 
prog_execname()55 const char *prog_execname()
56 {
57 	return progname;
58 }
59 
60