1*c8a0e2f4SThomas Veerman /* $NetBSD: setprogname.c,v 1.5 2008/04/28 20:24:12 martin Exp $ */
2*c8a0e2f4SThomas Veerman
3*c8a0e2f4SThomas Veerman /*-
4*c8a0e2f4SThomas Veerman * Copyright (c) 2001 The NetBSD Foundation, Inc.
5*c8a0e2f4SThomas Veerman * All rights reserved.
6*c8a0e2f4SThomas Veerman *
7*c8a0e2f4SThomas Veerman * This code is derived from software contributed to The NetBSD Foundation
8*c8a0e2f4SThomas Veerman * by Todd Vierling.
9*c8a0e2f4SThomas Veerman *
10*c8a0e2f4SThomas Veerman * Redistribution and use in source and binary forms, with or without
11*c8a0e2f4SThomas Veerman * modification, are permitted provided that the following conditions
12*c8a0e2f4SThomas Veerman * are met:
13*c8a0e2f4SThomas Veerman * 1. Redistributions of source code must retain the above copyright
14*c8a0e2f4SThomas Veerman * notice, this list of conditions and the following disclaimer.
15*c8a0e2f4SThomas Veerman * 2. Redistributions in binary form must reproduce the above copyright
16*c8a0e2f4SThomas Veerman * notice, this list of conditions and the following disclaimer in the
17*c8a0e2f4SThomas Veerman * documentation and/or other materials provided with the distribution.
18*c8a0e2f4SThomas Veerman *
19*c8a0e2f4SThomas Veerman * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20*c8a0e2f4SThomas Veerman * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21*c8a0e2f4SThomas Veerman * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22*c8a0e2f4SThomas Veerman * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23*c8a0e2f4SThomas Veerman * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24*c8a0e2f4SThomas Veerman * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25*c8a0e2f4SThomas Veerman * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26*c8a0e2f4SThomas Veerman * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27*c8a0e2f4SThomas Veerman * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28*c8a0e2f4SThomas Veerman * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29*c8a0e2f4SThomas Veerman * POSSIBILITY OF SUCH DAMAGE.
30*c8a0e2f4SThomas Veerman */
31*c8a0e2f4SThomas Veerman
32*c8a0e2f4SThomas Veerman #include "nbtool_config.h"
33*c8a0e2f4SThomas Veerman
34*c8a0e2f4SThomas Veerman #if !HAVE_SETPROGNAME
35*c8a0e2f4SThomas Veerman #include <string.h>
36*c8a0e2f4SThomas Veerman
37*c8a0e2f4SThomas Veerman static const char *__progname = "command line";
38*c8a0e2f4SThomas Veerman
39*c8a0e2f4SThomas Veerman void
setprogname(const char * progname)40*c8a0e2f4SThomas Veerman setprogname(const char *progname)
41*c8a0e2f4SThomas Veerman {
42*c8a0e2f4SThomas Veerman __progname = strrchr(progname, '/');
43*c8a0e2f4SThomas Veerman if (__progname == NULL)
44*c8a0e2f4SThomas Veerman __progname = progname;
45*c8a0e2f4SThomas Veerman else
46*c8a0e2f4SThomas Veerman __progname++;
47*c8a0e2f4SThomas Veerman }
48*c8a0e2f4SThomas Veerman
49*c8a0e2f4SThomas Veerman const char *
getprogname(void)50*c8a0e2f4SThomas Veerman getprogname(void)
51*c8a0e2f4SThomas Veerman {
52*c8a0e2f4SThomas Veerman return __progname;
53*c8a0e2f4SThomas Veerman }
54*c8a0e2f4SThomas Veerman #endif
55