/*
- * $Id: includes.h,v 1.1 2002/01/22 16:03:01 dfs Exp $
+ * $Id: includes.h,v 1.2 2002/02/27 15:51:19 dfs Exp $
*
* Copyright (C) 1997 Lars Fenneberg
*
* Copyright 1992 Livingston Enterprises, Inc.
*
- * Copyright 1992,1993, 1994,1995 The Regents of the University of Michigan
+ * Copyright 1992,1993, 1994,1995 The Regents of the University of Michigan
* and Merit Network, Inc. All Rights Reserved
*
- * See the file COPYRIGHT for the respective terms and conditions.
- * If the file is missing contact me at lf@elemental.net
+ * See the file COPYRIGHT for the respective terms and conditions.
+ * If the file is missing contact me at lf@elemental.net
* and I'll send you a copy.
*
*/
* prefer srandom/random over srand/rand as there generator has a
* better distribution of the numbers on certain systems.
* on Linux both generators are identical.
- */
+ */
#ifndef HAVE_RANDOM
# ifdef HAVE_RAND
# define srandom srand
/*
- * $Id: messages.h,v 1.1 2002/01/22 16:03:01 dfs Exp $
+ * $Id: messages.h,v 1.2 2002/02/27 15:51:19 dfs Exp $
*
* Copyright (C) 1995,1996 Lars Fenneberg
*
* Copyright 1992 Livingston Enterprises, Inc.
*
- * Copyright 1992,1993, 1994,1995 The Regents of the University of Michigan
+ * Copyright 1992,1993, 1994,1995 The Regents of the University of Michigan
* and Merit Network, Inc. All Rights Reserved
*
- * See the file COPYRIGHT for the respective terms and conditions.
- * If the file is missing contact me at lf@elemental.net
+ * See the file COPYRIGHT for the respective terms and conditions.
+ * If the file is missing contact me at lf@elemental.net
* and I'll send you a copy.
*
*/
#define SC_STATUS_FAILED "RADIUS: Status failure\r\n"
-#endif /* MESSAGES_H */
\ No newline at end of file
+#endif /* MESSAGES_H */
/*
- * $Id: pathnames.h,v 1.1 2002/01/22 16:03:01 dfs Exp $
+ * $Id: pathnames.h,v 1.2 2002/02/27 15:51:19 dfs Exp $
*
* Copyright (C) 1995,1996 Lars Fenneberg
*
* Copyright 1992 Livingston Enterprises, Inc.
*
- * Copyright 1992,1993, 1994,1995 The Regents of the University of Michigan
+ * Copyright 1992,1993, 1994,1995 The Regents of the University of Michigan
* and Merit Network, Inc. All Rights Reserved
*
- * See the file COPYRIGHT for the respective terms and conditions.
- * If the file is missing contact me at lf@elemental.net
+ * See the file COPYRIGHT for the respective terms and conditions.
+ * If the file is missing contact me at lf@elemental.net
* and I'll send you a copy.
*
*/
#define _PATH_ETC_RADIUSCLIENT_CONF "/etc/radiusclient.conf"
#endif
-#endif /* PATHNAMES_H */
\ No newline at end of file
+#endif /* PATHNAMES_H */
/*
- * $Id: radiusclient.h,v 1.1 2002/01/22 16:03:01 dfs Exp $
+ * $Id: radiusclient.h,v 1.2 2002/02/27 15:51:19 dfs Exp $
*
* Copyright (C) 1995,1996,1997,1998 Lars Fenneberg
*
* Copyright 1992 Livingston Enterprises, Inc.
*
- * Copyright 1992,1993, 1994,1995 The Regents of the University of Michigan
+ * Copyright 1992,1993, 1994,1995 The Regents of the University of Michigan
* and Merit Network, Inc. All Rights Reserved
*
- * See the file COPYRIGHT for the respective terms and conditions.
- * If the file is missing contact me at lf@elemental.net
+ * See the file COPYRIGHT for the respective terms and conditions.
+ * If the file is missing contact me at lf@elemental.net
* and I'll send you a copy.
*
*/
#endif
typedef unsigned long UINT4;
-typedef long INT4;
+typedef long INT4;
#define AUTH_VECTOR_LEN 16
#define AUTH_PASS_LEN (3 * 16) /* multiple of 16 */
typedef struct server {
int max;
char *name[SERVER_MAX];
- unsigned short port[SERVER_MAX];
+ unsigned short port[SERVER_MAX];
} SERVER;
typedef struct pw_auth_hdr
#define PW_CALLBACK 16
#define PW_USER_ERROR 17
#define PW_HOST_REQUEST 18
-
+
/* NAS PORT TYPES */
#define PW_ASYNC 0
char name[NAME_LENGTH + 1]; /* attribute name */
int value; /* attribute index */
int type; /* string, int, etc. */
- int vendorcode; /* vendor code */
+ int vendorcode; /* vendor code */
struct dict_attr *next;
} DICT_ATTR;
{
char name[NAME_LENGTH + 1];
int attribute;
- int vendorcode;
+ int vendorcode;
int type;
UINT4 lvalue;
char strvalue[AUTH_STRING_LEN + 1];
/* don't change this, as it has to be the same as in the Merit radiusd code */
#define MGMT_POLL_SECRET "Hardlyasecret"
-/* Define return codes from "SendServer" utility */
+/* Define return codes from "SendServer" utility */
#define BADRESP_RC -2
#define ERROR_RC -1
/*
- * $Id: clientid.c,v 1.1 2002/01/22 16:03:02 dfs Exp $
+ * $Id: clientid.c,v 1.2 2002/02/27 15:51:20 dfs Exp $
*
* Copyright (C) 1995,1996,1997 Lars Fenneberg
*
- * See the file COPYRIGHT for the respective terms and conditions.
- * If the file is missing contact me at lf@elemental.net
+ * See the file COPYRIGHT for the respective terms and conditions.
+ * If the file is missing contact me at lf@elemental.net
* and I'll send you a copy.
*
*/
struct map2id_s *next;
};
-static struct map2id_s *map2id_list = NULL;
+static struct map2id_s *map2id_list = NULL;
/*
* Function: rc_read_mapfile
*
* Arguments: the file name of the map file
*
- * Returns: zero on success, negative integer on failure
+ * Returns: zero on success, negative integer on failure
*/
int rc_read_mapfile(char *filename)
struct map2id_s *p;
int lnr = 0;
- if ((mapfd = fopen(filename,"r")) == NULL)
- {
- rc_log(LOG_ERR,"rc_read_mapfile: can't read %s: %s", filename, strerror(errno));
+ if ((mapfd = fopen(filename,"r")) == NULL)
+ {
+ rc_log(LOG_ERR,"rc_read_mapfile: can't read %s: %s", filename, strerror(errno));
return (-1);
}
-
+
#define SKIP(p) while(*p && isspace(*p)) p++;
- while (fgets(buffer, sizeof(buffer), mapfd) != NULL)
- {
- lnr++;
-
+ while (fgets(buffer, sizeof(buffer), mapfd) != NULL)
+ {
+ lnr++;
+
q = buffer;
-
- SKIP(q);
-
- if ((*q == '\n') || (*q == '#') || (*q == '\0'))
+
+ SKIP(q);
+
+ if ((*q == '\n') || (*q == '#') || (*q == '\0'))
continue;
if (( c = strchr(q, ' ')) || (c = strchr(q,'\t'))) {
*c = '\0'; c++;
SKIP(c);
-
+
name = q;
id = c;
-
+
if ((p = (struct map2id_s *)malloc(sizeof(*p))) == NULL) {
rc_log(LOG_CRIT,"rc_read_mapfile: out of memory");
return (-1);
}
-
+
p->name = strdup(name);
p->id = atoi(id);
p->next = map2id_list;
- map2id_list = p;
-
+ map2id_list = p;
+
} else {
-
- rc_log(LOG_ERR, "rc_read_mapfile: malformed line in %s, line %d", filename, lnr);
+
+ rc_log(LOG_ERR, "rc_read_mapfile: malformed line in %s, line %d", filename, lnr);
return (-1);
}
}
-
+
#undef SKIP
fclose(mapfd);
*ttyname = '\0';
if (*name != '/')
strcpy(ttyname, "/dev/");
-
+
strncat(ttyname, name, sizeof(ttyname));
-
+
for(p = map2id_list; p; p = p->next)
if (!strcmp(ttyname, p->name)) return p->id;
rc_log(LOG_WARNING,"rc_map2id: can't find tty %s in map database", ttyname);
-
+
return 0;
}
/*
- * $Id: config.c,v 1.1 2002/01/22 16:03:02 dfs Exp $
+ * $Id: config.c,v 1.2 2002/02/27 15:51:20 dfs Exp $
*
* Copyright (C) 1995,1996,1997 Lars Fenneberg
*
* Copyright 1992 Livingston Enterprises, Inc.
*
- * Copyright 1992,1993, 1994,1995 The Regents of the University of Michigan
+ * Copyright 1992,1993, 1994,1995 The Regents of the University of Michigan
* and Merit Network, Inc. All Rights Reserved
*
- * See the file COPYRIGHT for the respective terms and conditions.
- * If the file is missing contact me at lf@elemental.net
+ * See the file COPYRIGHT for the respective terms and conditions.
+ * If the file is missing contact me at lf@elemental.net
* and I'll send you a copy.
*
*/
*
* Returns: pointer to option on success, NULL otherwise
*/
-
+
static OPTION *find_option(char *optname, unsigned int type)
{
int i;
for (i = 0; i < num_options; i++) {
if (!strcmp(config_options[i].name, optname) &&
(config_options[i].type & type))
- return &config_options[i];
+ return &config_options[i];
}
return NULL;
*/
static int set_option_str(char *filename, int line, OPTION *option, char *p)
-{
+{
if (p)
option->val = (void *) strdup(p);
else
rc_log(LOG_CRIT, "read_config: out of memory");
return (-1);
}
-
- *iptr = atoi(p);
+
+ *iptr = atoi(p);
option->val = (void *) iptr;
return 0;
rc_log(LOG_CRIT, "read_config: out of memory");
return (-1);
}
-
+
*iptr = 0;
p = strtok(p, ", \t");
*iptr = AUTH_RADIUS_FST;
else {
rc_log(LOG_ERR,"%s: auth_order: unknown keyword: %s", filename, p);
- return (-1);
+ return (-1);
}
-
+
p = strtok(NULL, ", \t");
-
+
if (p && (*p != '\0')) {
if ((*iptr & AUTH_RADIUS_FST) && !strcmp(p, "local"))
*iptr = (*iptr) | AUTH_LOCAL_SND;
else if ((*iptr & AUTH_LOCAL_FST) && !strcmp(p, "radius"))
- *iptr = (*iptr) | AUTH_RADIUS_SND;
+ *iptr = (*iptr) | AUTH_RADIUS_SND;
else {
rc_log(LOG_ERR,"%s: auth_order: unknown or unexpected keyword: %s", filename, p);
- return (-1);
+ return (-1);
}
}
* Function: rc_read_config
*
* Purpose: read the global config file
- *
+ *
* Returns: 0 on success, -1 when failure
*/
{
line++;
p = buffer;
-
+
if ((*p == '\n') || (*p == '#') || (*p == '\0'))
continue;
p[strlen(p)-1] = '\0';
-
-
+
+
if ((pos = strcspn(p, "\t ")) == 0) {
rc_log(LOG_ERR, "%s: line %d: bogus format: %s", filename, line, p);
return (-1);
- }
-
+ }
+
p[pos] = '\0';
-
+
if ((option = find_option(p, OT_ANY)) == NULL) {
rc_log(LOG_ERR, "%s: line %d: unrecognized keyword: %s", filename, line, p);
return (-1);
}
p += pos+1;
- while (isspace(*p))
+ while (isspace(*p))
p++;
switch (option->type) {
case OT_STR:
if (set_option_str(filename, line, option, p) < 0)
- return (-1);
- break;
+ return (-1);
+ break;
case OT_INT:
if (set_option_int(filename, line, option, p) < 0)
- return (-1);
+ return (-1);
break;
case OT_SRV:
if (set_option_srv(filename, line, option, p) < 0)
- return (-1);
+ return (-1);
break;
case OT_AUO:
if (set_option_auo(filename, line, option, p) < 0)
- return (-1);
+ return (-1);
break;
default:
rc_log(LOG_CRIT, "rc_read_config: impossible case branch!");
* Function: rc_conf_str, rc_conf_int, rc_conf_src
*
* Purpose: get the value of a config option
- *
+ *
* Returns: config option value
*/
OPTION *option;
option = find_option(optname, OT_STR);
-
+
if (option != NULL) {
- return (char *)option->val;
+ return (char *)option->val;
} else {
rc_log(LOG_CRIT, "rc_conf_str: unkown config option requested: %s", optname);
abort();
OPTION *option;
option = find_option(optname, OT_INT|OT_AUO);
-
+
if (option != NULL) {
- return *((int *)option->val);
+ return *((int *)option->val);
} else {
rc_log(LOG_CRIT, "rc_conf_int: unkown config option requested: %s", optname);
abort();
OPTION *option;
option = find_option(optname, OT_SRV);
-
+
if (option != NULL) {
- return (SERVER *)option->val;
+ return (SERVER *)option->val;
} else {
rc_log(LOG_CRIT, "rc_conf_srv: unkown config option requested: %s", optname);
abort();
{
rc_log(LOG_ERR,"%s: no servers file specified", filename);
return (-1);
- }
+ }
if (!rc_conf_str("dictionary"))
{
rc_log(LOG_ERR,"%s: no dictionary specified", filename);
rc_log(LOG_ERR,"%s: radius_timeout <= 0 is illegal", filename);
return (-1);
}
- if (rc_conf_int("radius_retries") <= 0)
+ if (rc_conf_int("radius_retries") <= 0)
{
rc_log(LOG_ERR,"%s: radius_retries <= 0 is illegal", filename);
return (-1);
- }
+ }
#if 0
file = rc_conf_str("login_local");
return (-1);
}
#endif
-
+
if (rc_conf_int("login_tries") <= 0)
{
rc_log(LOG_ERR,"%s: login_tries <= 0 is illegal", filename);
return (-1);
- }
+ }
if (rc_conf_str("seqfile") == NULL)
{
rc_log(LOG_ERR,"%s: seqfile not specified", filename);
return (-1);
- }
+ }
if (rc_conf_int("login_timeout") <= 0)
{
rc_log(LOG_ERR,"%s: login_timeout <= 0 is illegal", filename);
return (-1);
- }
+ }
if (rc_conf_str("mapfile") == NULL)
{
rc_log(LOG_ERR,"%s: mapfile not specified", filename);
return (-1);
- }
+ }
if (rc_conf_str("nologin") == NULL)
{
rc_log(LOG_ERR,"%s: nologin not specified", filename);
return (-1);
- }
+ }
return 0;
}
}
}
return (-1);
-}
+}
/*
* Function: rc_find_server
* Returns: 0 on success, -1 on failure
*
*/
-
+
int rc_find_server (char *server_name, UINT4 *ip_addr, char *secret)
{
- UINT4 myipaddr = 0;
+ UINT4 myipaddr = 0;
int len;
int result;
FILE *clientfd;
rc_log(LOG_ERR, "rc_find_server: couldn't open file: %s: %s", strerror(errno), rc_conf_str("servers"));
return (-1);
}
-
+
if ((myipaddr = rc_own_ipaddress()) == 0)
return (-1);
/*
- * $Id: env.c,v 1.1 2002/01/22 16:03:02 dfs Exp $
+ * $Id: env.c,v 1.2 2002/02/27 15:51:20 dfs Exp $
*
* Copyright (C) 1995,1996,1997 Lars Fenneberg
*
- * See the file COPYRIGHT for the respective terms and conditions.
- * If the file is missing contact me at lf@elemental.net
+ * See the file COPYRIGHT for the respective terms and conditions.
+ * If the file is missing contact me at lf@elemental.net
* and I'll send you a copy.
*
*/
* Purpose: allocate space for a new environment
*
*/
-
+
ENV *rc_new_env(int size)
{
ENV *p;
if ((p = malloc(sizeof(*p))) == NULL)
return NULL;
-
+
if ((p->env = malloc(size * sizeof(char *))) == NULL)
{
rc_log(LOG_CRIT, "rc_new_env: out of memory");
free(p);
return NULL;
- }
+ }
p->env[0] = NULL;
-
+
p->size = 0;
- p->maxsize = size;
-
+ p->maxsize = size;
+
return p;
}
* Purpose: free the space used by an env structure
*
*/
-
+
void rc_free_env(ENV *env)
{
free(env->env);
- free(env);
+ free(env);
}
/*
* Purpose: add an environment entry
*
*/
-
+
int rc_add_env(ENV *env, char *name, char *value)
{
int i;
for (i = 0; env->env[i] != NULL; i++)
{
if (strncmp(env->env[i], name, MAX(strchr(env->env[i], '=') - env->env[i],strlen(name))) == 0)
- break;
+ break;
}
if (env->env[i])
rc_log(LOG_CRIT, "rc_add_env: not enough space for environment (increase ENV_SIZE)");
return (-1);
}
-
+
if ((env->env[env->size] = malloc(strlen(name)+strlen(value)+2)) == NULL) {
rc_log(LOG_CRIT, "rc_add_env: out of memory");
return (-1);
}
-
+
sprintf(env->env[env->size],"%s=%s", name, value);
-
+
env->size++;
env->env[env->size] = NULL;
}
- return 0;
+ return 0;
}
/*
* Purpose: imports an array of null-terminated strings
*
*/
-
+
int rc_import_env(ENV *env, char **import)
{
char *es;
-
+
while (*import)
{
es = strchr(*import, '=');
-
+
if (!es)
{
import++;
continue;
}
-
+
/* ok, i grant thats not very clean... */
*es = '\0';
*es = '=';
return (-1);
}
-
+
*es = '=';
-
+
import++;
}
-
+
return 0;
}
/*
- * $Id: ip_util.c,v 1.1 2002/01/22 16:03:02 dfs Exp $
+ * $Id: ip_util.c,v 1.2 2002/02/27 15:51:20 dfs Exp $
*
* Copyright (C) 1995,1996,1997 Lars Fenneberg
*
* Copyright 1992 Livingston Enterprises, Inc.
*
- * Copyright 1992,1993, 1994,1995 The Regents of the University of Michigan
+ * Copyright 1992,1993, 1994,1995 The Regents of the University of Michigan
* and Merit Network, Inc. All Rights Reserved
*
- * See the file COPYRIGHT for the respective terms and conditions.
- * If the file is missing contact me at lf@elemental.net
+ * See the file COPYRIGHT for the respective terms and conditions.
+ * If the file is missing contact me at lf@elemental.net
* and I'll send you a copy.
*
*/
return ((UINT4) 0);
}
return ntohl((*(UINT4 *) hp->h_addr));
-}
+}
/*
* Function: rc_good_ipaddr
* for the supplied IP address.
*
*/
-
+
const char *rc_ip_hostname (UINT4 h_ipaddr)
{
struct hostent *hp;
AF_INET)) == NULL) {
rc_log(LOG_ERR,"rc_ip_hostname: couldn't look up host by addr: %08lX", h_ipaddr);
}
-
+
return ((hp==NULL)?"unknown":hp->h_name);
-}
+}
/*
* Function: rc_getport
}
#else
return -1;
-#endif
+#endif
return 0;
}
rc_log(LOG_ERR, "rc_own_ipaddress: couldn't get own IP address");
return 0;
}
- }
-
+ }
+
return this_host_ipaddr;
}
/*
- * $Id: lock.c,v 1.1 2002/01/22 16:03:02 dfs Exp $
+ * $Id: lock.c,v 1.2 2002/02/27 15:51:20 dfs Exp $
*
* Copyright (C) 1997 Lars Fenneberg
*
- * See the file COPYRIGHT for the respective terms and conditions.
- * If the file is missing contact me at lf@elemental.net
+ * See the file COPYRIGHT for the respective terms and conditions.
+ * If the file is missing contact me at lf@elemental.net
* and I'll send you a copy.
*
*/
{
flock_t fl;
int res;
-
+
memset((void *)&fl, 0, sizeof(fl));
-
+
fl.l_type = F_WRLCK;
fl.l_whence = fl.l_start = 0;
fl.l_len = 0; /* 0 means "to end of file" */
res = fcntl(fd, F_SETLK, &fl);
-
+
if ((res == -1) && (errno == EAGAIN))
errno = EWOULDBLOCK;
int do_unlock(int fd)
{
flock_t fl;
-
+
memset((void *)&fl, 0, sizeof(fl));
-
+
fl.l_type = F_UNLCK;
fl.l_whence = fl.l_start = 0;
fl.l_len = 0; /* 0 means "to end of file" */
#else
YOU_LOOSE "need either flock(2) or fcntl(2)"
#endif
-
/*
- * $Id: log.c,v 1.1 2002/01/22 16:03:02 dfs Exp $
+ * $Id: log.c,v 1.2 2002/02/27 15:51:20 dfs Exp $
*
* Copyright (C) 1995,1996,1997 Lars Fenneberg
*
- * See the file COPYRIGHT for the respective terms and conditions.
- * If the file is missing contact me at lf@elemental.net
+ * See the file COPYRIGHT for the respective terms and conditions.
+ * If the file is missing contact me at lf@elemental.net
* and I'll send you a copy.
*
*/
{
char buff[1024];
va_list ap;
-
+
va_start(ap,format);
vsnprintf(buff, sizeof(buff), format, ap);
va_end(ap);
-
+
syslog(prio, "%s", buff);
}
/*
- * $Id: md5.c,v 1.1 2002/01/22 16:03:02 dfs Exp $
+ * $Id: md5.c,v 1.2 2002/02/27 15:51:20 dfs Exp $
*/
/* MD5C.C - RSA Data Security, Inc., MD5 message-digest algorithm
static void MD5Update (MD5_CTX *context, unsigned char *input, unsigned int inputLen)
{
unsigned int i,
- index,
- partLen;
+ index,
+ partLen;
/* Compute number of bytes mod 64 */
index = (unsigned int) ((context->count[0] >> 3) & 0x3F);
{
unsigned char bits[8];
unsigned int index,
- padLen;
+ padLen;
/* Save number of bits */
Encode (bits, context->count, 8);
static void MD5Transform (UINT4 *state, unsigned char *block)
{
UINT4 a = state[0],
- b = state[1],
- c = state[2],
- d = state[3],
- x[16];
+ b = state[1],
+ c = state[2],
+ d = state[3],
+ x[16];
Decode (x, block, 64);
static void Encode (unsigned char *output, UINT4 *input, unsigned int len)
{
unsigned int i,
- j;
+ j;
for (i = 0, j = 0; j < len; i++, j += 4)
{
static void Decode (UINT4 *output, unsigned char *input, unsigned int len)
{
unsigned int i,
- j;
+ j;
for (i = 0, j = 0; j < len; i++, j += 4)
output[i] = ((UINT4) input[j]) | (((UINT4) input[j + 1]) << 8) |
/*
- * $Id: memcmp.c,v 1.1 2002/01/22 16:03:02 dfs Exp $
+ * $Id: memcmp.c,v 1.2 2002/02/27 15:51:20 dfs Exp $
*
* Taken from the Linux kernel. GPL applies.
* Copyright (C) 1991, 1992 Linus Torvalds
{
const unsigned char *su1, *su2;
signed char res = 0;
-
+
for( su1 = cs, su2 = ct; 0 < count; ++su1, ++su2, count--)
if ((res = *su1 - *su2) != 0)
break;
- return res;
+ return res;
}
-
\ No newline at end of file
/*
- * $Id: strcasecmp.c,v 1.1 2002/01/22 16:03:02 dfs Exp $
+ * $Id: strcasecmp.c,v 1.2 2002/02/27 15:51:20 dfs Exp $
*
* Copyright (C) 1996 Lars Fenneberg and Christian Graefe
*
- * This file is provided under the terms and conditions of the GNU general
- * public license, version 2 or any later version, incorporated herein by
- * reference.
+ * This file is provided under the terms and conditions of the GNU general
+ * public license, version 2 or any later version, incorporated herein by
+ * reference.
*
*/
int strcasecmp(char *s1, char *s2)
{
while (*s1 && *s2 && toupper(*s1) == toupper(*s2))
- s1++, s2++;
-
+ s1++, s2++;
+
if (!*s1 && !*s2)
- return 0;
+ return 0;
else
- return (toupper(*s1) - toupper(*s2));
+ return (toupper(*s1) - toupper(*s2));
}
#endif
/*
- * $Id: strdup.c,v 1.1 2002/01/22 16:03:02 dfs Exp $
+ * $Id: strdup.c,v 1.2 2002/02/27 15:51:20 dfs Exp $
*
* Copyright (C) 1996 Lars Fenneberg and Christian Graefe
*
- * This file is provided under the terms and conditions of the GNU general
- * public license, version 2 or any later version, incorporated herein by
- * reference.
+ * This file is provided under the terms and conditions of the GNU general
+ * public license, version 2 or any later version, incorporated herein by
+ * reference.
*
*/
if ((p = (char *)malloc(strlen(str)+1)) == NULL)
return p;
- return strcpy(p, str);
+ return strcpy(p, str);
}
/*
- * $Id: strerror.c,v 1.1 2002/01/22 16:03:02 dfs Exp $
+ * $Id: strerror.c,v 1.2 2002/02/27 15:51:20 dfs Exp $
*
* Copyright (C) 1996 Lars Fenneberg and Christian Graefe
*
- * This file is provided under the terms and conditions of the GNU general
- * public license, version 2 or any later version, incorporated herein by
- * reference.
+ * This file is provided under the terms and conditions of the GNU general
+ * public license, version 2 or any later version, incorporated herein by
+ * reference.
*
*/
/*
- * $Id: util.c,v 1.1 2002/01/22 16:03:02 dfs Exp $
+ * $Id: util.c,v 1.2 2002/02/27 15:51:20 dfs Exp $
*
* Copyright (C) 1995,1996,1997 Lars Fenneberg
*
* Copyright 1992 Livingston Enterprises, Inc.
*
- * Copyright 1992,1993, 1994,1995 The Regents of the University of Michigan
+ * Copyright 1992,1993, 1994,1995 The Regents of the University of Michigan
* and Merit Network, Inc. All Rights Reserved
*
- * See the file COPYRIGHT for the respective terms and conditions.
- * If the file is missing contact me at lf@elemental.net
+ * See the file COPYRIGHT for the respective terms and conditions.
+ * If the file is missing contact me at lf@elemental.net
* and I'll send you a copy.
*
*/
char *rc_getifname(char *tty)
{
-#if defined(BSD4_4) || defined(linux)
- static char name[512];
+#if defined(BSD4_4) || defined(linux)
+ static char name[512];
int fd;
if ((fd = open(tty, O_RDWR|O_NDELAY)) < 0) {
rc_log(LOG_ERR, "rc_getifname: can't open %s: %s", tty, strerror(errno));
return NULL;
}
-#endif
-
+#endif
+
#ifdef BSD4_4
strcpy(name,ttyname(fd));
if (strlen(name) < 1) {
return NULL;
#endif
-#if defined(BSD4_4) || defined(linux)
+#if defined(BSD4_4) || defined(linux)
close(fd);
return name;
#endif
if ((is_term = isatty(in)))
{
-
+
(void) tcgetattr (in, &term_old);
term_new = term_old;
if (do_echo)
term_new.c_lflag |= ECHO;
- else
+ else
term_new.c_lflag &= ~ECHO;
-
+
if (tcsetattr (in, TCSAFLUSH, &term_new) == 0)
flushed = 1;
-
+
}
else
{
if ((flags = fcntl(in, F_GETFL, 0)) >= 0) {
old_flags = flags;
flags |= O_NONBLOCK;
-
+
fcntl(in, F_SETFL, flags);
-
+
while (read(in, &c, 1) > 0)
/* nothing */;
-
+
fcntl(in, F_SETFL, old_flags);
-
+
flushed = 1;
- }
+ }
}
-
+
write(out, prompt, strlen(prompt));
/* well, this looks ugly, but it handles the following end of line
{
if (read(in, &c, 1) <= 0)
return NULL;
-
+
if (!flushed && ((c == '\0') || (c == '\r') || (c == '\n'))) {
flushed = 1;
continue;
}
*p = '\0';
-
+
if (!do_echo || !is_term) write(out, "\r\n", 2);
-
+
if (is_term)
tcsetattr (in, TCSAFLUSH, &term_old);
else {
if ((flags = fcntl(in, F_GETFL, 0)) >= 0) {
old_flags = flags;
flags |= O_NONBLOCK;
-
+
fcntl(in, F_SETFL, flags);
-
+
while (read(in, &c, 1) > 0)
/* nothing */;
-
+
fcntl(in, F_SETFL, old_flags);
- }
+ }
}
(void) sigprocmask (SIG_SETMASK, &oldset, NULL);
void rc_mdelay(int msecs)
{
struct timeval tv;
-
+
tv.tv_sec = (int) msecs / 1000;
tv.tv_usec = (msecs % 1000) * 1000;