1/* $Header: /p/tcsh/cvsroot/tcsh/gethost.c,v 1.12 2006/03/02 18:46:44 christos Exp $ */ |
2/* 3 * gethost.c: Create version file from prototype 4 */ 5/*- 6 * Copyright (c) 1980, 1991 The Regents of the University of California. 7 * All rights reserved. 8 * 9 * Redistribution and use in source and binary forms, with or without --- 17 unchanged lines hidden (view full) --- 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 */ 33#include "sh.h" 34 |
35RCSID("$tcsh: gethost.c,v 1.12 2006/03/02 18:46:44 christos Exp $") |
36 37#ifdef SCO 38# define perror __perror 39# define rename __rename 40# define getopt __getopt 41# define system __system 42#endif 43#include <stdio.h> --- 40 unchanged lines hidden (view full) --- 84#define T_NONE 10 85}; 86 87#define S_DISCARD 0 88#define S_COMMENT 1 89#define S_CODE 2 90#define S_KEYWORD 3 91 |
92static int findtoken (char *); 93static char *gettoken (char **, char *); |
94 |
95int main (int, char *[]); |
96 97/* findtoken(): 98 * Return the token number of the given token 99 */ 100static int |
101findtoken(char *ptr) |
102{ 103 int i; 104 105 if (ptr == NULL || *ptr == '\0') 106 return T_NONE; 107 108 for (i = 0; keyword[i] != NULL; i++) 109 if (strcmp(keyword[i], ptr) == 0) 110 return i; 111 112 return T_NONE; 113} 114 115 116/* gettoken(): 117 * Get : delimited token and remove leading/trailing blanks/newlines 118 */ 119static char * |
120gettoken(char **pptr, char *token) |
121{ 122 char *ptr = *pptr; 123 char *tok = token; 124 125 for (; *ptr && ISSPACE(*ptr); ptr++) 126 continue; 127 128 for (; *ptr && *ptr != ':'; *tok++ = *ptr++) --- 10 unchanged lines hidden (view full) --- 139 *++tok = '\0'; 140 141 *pptr = ptr; 142 return token; 143} 144 145 146int |
147main(int argc, char *argv[]) |
148{ 149 char line[INBUFSIZE]; 150 char *pname; 151 const char *fname = "stdin"; 152 char *ptr, *tok; 153 char defs[INBUFSIZE]; 154 char stmt[INBUFSIZE]; 155 FILE *fp = stdin; --- 174 unchanged lines hidden --- |