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