chiark / gitweb /
quis: remove the leading `-' from the name, in case we're invoked as a
[mLib] / quis.c
1 /* -*-c-*-
2  *
3  * $Id: quis.c,v 1.2 1999/02/28 15:16:29 mdw Exp $
4  *
5  * Setting the program name
6  *
7  * (c) 1998 Straylight/Edgeware
8  */
9
10 /*----- Licensing notice --------------------------------------------------*
11  *
12  * This file is part of the mLib utilities library.
13  *
14  * mLib is free software; you can redistribute it and/or modify
15  * it under the terms of the GNU General Public License as published by
16  * the Free Software Foundation; either version 2 of the License, or
17  * (at your option) any later version.
18  *
19  * mLib is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22  * GNU General Public License for more details.
23  *
24  * You should have received a copy of the GNU General Public License
25  * along with mLib; if not, write to the Free Software Foundation,
26  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27  */
28
29 /*----- Revision history --------------------------------------------------*
30  *
31  * $Log: quis.c,v $
32  * Revision 1.2  1999/02/28 15:16:29  mdw
33  * quis: remove the leading `-' from the name, in case we're invoked as a
34  * login shell.
35  *
36  * Revision 1.1.1.1  1998/06/17 23:44:42  mdw
37  * Initial version of mLib
38  *
39  */
40
41 /*----- Header files ------------------------------------------------------*/
42
43 #include <stdarg.h>
44 #include <stdio.h>
45 #include <stdlib.h>
46 #include <string.h>
47
48 #include "quis.h"
49
50 /*----- Global variables --------------------------------------------------*/
51
52 const char *pn__name = "<UNNAMED>";     /* Program name */
53
54 /*----- Functions provided ------------------------------------------------*/
55
56 /* --- @quis@ --- *
57  *
58  * Arguments:   ---
59  *
60  * Returns:     Pointer to the program name.
61  *
62  * Use:         Returns the program name.
63  */
64
65 const char *quis(void) { return (QUIS); }
66
67 /* --- @ego@ --- *
68  *
69  * Arguments:   @const char *p@ = pointer to program name
70  *
71  * Returns:     ---
72  *
73  * Use:         Tells mLib what the program's name is.
74  */
75
76 #ifndef PATHSEP
77 #  if defined(__riscos)
78 #    define PATHSEP '.'
79 #  elif defined(__unix) || defined(unix)
80 #    define PATHSEP '/'
81 #  else
82 #    define PATHSEP '\\'
83 #  endif
84 #endif
85
86 void ego(const char *p)
87 {
88   const char *q = p;
89   while (*q) {
90     if (*q++ == PATHSEP)
91       p = q;
92   }
93   if (*p == '-')
94     p++;
95   pn__name = p;
96 }
97
98 /*----- That's all, folks -------------------------------------------------*/