#include "gdb.h"
#include "gdb_lib.h"
#include <errno.h>
+#ifdef POSIX
+#include <sys/utsname.h>
+#endif
extern int sys_nerr;
extern char *sys_errlist[];
struct passwd *pw_struct; /* passwd entry comes back */
/* here */
+#ifdef POSIX
+ struct utsname nameposix;
+ struct sigaction act;
+
+ sigemptyset(&act.sa_mask);
+ act.sa_flags = 0;
+#endif
+
/*
* So we know we've been initialized, and we do it only once
*/
* closed at the other end. gdb_move_data handles this condition
* synchronously.
*/
+#ifdef POSIX
+ act.sa_handler = (void(*)()) SIG_IGN;
+ (void) sigaction(SIGPIPE, &act, NULL);
+#else
(void) signal(SIGPIPE, SIG_IGN);
+#endif
/*
* Make a note of the local host and user name
*/
+#ifdef POSIX
+ (void) uname(&nameposix);
+ strncpy(hostname, nameposix.nodename, sizeof(hostname) - 1);
+#else
if (gethostname(hostname, sizeof(hostname)-1)!=0)
(void) strcpy(hostname, "????");
+#endif
gdb_host = db_alloc(strlen(hostname)+1);
(void) strcpy(gdb_host, hostname);
#include <mit-copyright.h>
#include <stdio.h>
-#include <strings.h>
+#include <string.h>
#include "gdb.h"
#include <sys/types.h>
#include <sys/uio.h>
CONNECTION gdb_allocate_connection();
-/************************************************************************/
-/*
-/* start_peer_connection (start_peer_connection)
-/*
-/* Starts a connection to another process which itself will be
-/* issuing a start_peer_connection to us. Current implementation
-/* builds at most one stream, with the risk of a hang if
-/* the attempts to connect cross in the night. This is a bug,
-/* but this level of support is acceptable for casual debugging
-/* of applications, and perhaps for some production use in
-/* controlled settings. I think the only other way to do it
-/* is to risk building two streams in parallel, possibly tearing
-/* one down when the duplication is discovered. Seems complicated
-/* and messy.
-/*
-/************************************************************************/
+/************************************************************************
+ *
+ * start_peer_connection (start_peer_connection)
+ *
+ * Starts a connection to another process which itself will be
+ * issuing a start_peer_connection to us. Current implementation
+ * builds at most one stream, with the risk of a hang if
+ * the attempts to connect cross in the night. This is a bug,
+ * but this level of support is acceptable for casual debugging
+ * of applications, and perhaps for some production use in
+ * controlled settings. I think the only other way to do it
+ * is to risk building two streams in parallel, possibly tearing
+ * one down when the duplication is discovered. Seems complicated
+ * and messy.
+ *
+ ************************************************************************/
CONNECTION
start_peer_connection(id)
} else
return NULL;
}
-\f
+
+
/************************************************************************/
/*
/* g_make_con
}
-\f/************************************************************************/
+
+/************************************************************************/
/*
/* g_null_con
/*
}
-\f
+
/************************************************************************/
/*
/* gdb_allocate_connection
return &gdb_cons[i]; /* return new highest con */
/* ever used*/
}
-\f
+
+
/************************************************************************/
/*
/* g_try_connecting
/*
/*----------------------------------------------------------*/
- bzero((char *)&target, sizeof(target));
+ memset((char *)&target, 0, sizeof(target));
g_parse_target(id, &peer_host, &target.sin_port);
if (peer_host == NULL) {
fprintf(gdb_log,"gdb: g_try_connecting... '%s' is not a valid host:server\n",
/*----------------------------------------------------------*/
- bcopy(peer_host->h_addr, (char *)&target.sin_addr, peer_host->h_length);
+ memcpy((char *)&target.sin_addr,peer_host->h_addr,peer_host->h_length);
target.sin_family = peer_host->h_addrtype;
/*----------------------------------------------------------*/
return TRUE;
}
-\f
+
+
/************************************************************************/
/*
/* g_parse_target
*port = serv->s_port;
}
}
-\f
+
+
/************************************************************************/
/*
/* g_try_accepting
/*
/*----------------------------------------------------------*/
- bzero((char *)&self, sizeof(self));
+ memset((char *)&self, 0, sizeof(self));
g_parse_target(id, &peer_host, &self.sin_port);
if (peer_host == NULL) {
GDB_GIVEUP("gdb_try_accepting: bad port not caught by try connecting")
con->out.fd = peer;
con->status = CON_STARTING;
}
-\f
+
+
/************************************************************************/
/*
/* g_ver_oprotocol
#endif !VERIFY_PROTOCOL
}
+
/************************************************************************/
/*
/* g_ver_iprotocol
#endif
}
-\f
+
/************************************************************************/
/*
/* sever_connection (sever_connection)
return NULL;
}
+
/************************************************************************/
/*
/* g_stop_with_errno
/*
/************************************************************************/
-
int
g_stop_with_errno(con)
CONNECTION con;
}
+
/************************************************************************/
/*
/* g_stop_connection
return;
}
-\f
+
/************************************************************************/
/*
/* gdb_de_allocate_connection
gdb_mcons = i + 1;
}
-\f
+
+
/************************************************************************/
/*
/* g_cleanup_half_conection
current = next;
}
}
-\f
+
+
/************************************************************************/
/*
/* create_listening_connection (create_listening_connection)
/*
/*----------------------------------------------------------*/
- bzero((char *)&self, sizeof(self));
+ memset((char *)&self, 0, sizeof(self));
/*
* Determine our port number
*/
gdb_mfd = con->in.fd + 1;
return con;
}
-\f
+
+
/************************************************************************/
/*
/* g_allocate_connection_buffers
#endif lint
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-/************************************************************************/
-/*
-/* gdb_stype.c
-/*
-/* GDB - System Data Type Definitions
-/*
-/* Author: Noah Mendelsohn
-/* Copyright: 1986 MIT Project Athena
-/* For copying and distribution information, please see
-/* the file <mit-copyright.h>.
-/*
-/* This file initializes the definitions for all system defined
-/* data types, and it includes the type specific semantic routines
-/* for each of the system defined types.
-/*
-/* The initialization routine which adds these type definitions
-/* to the type definition table is at the end of this source file.
-/*
-/************************************************************************/
-/*
-/* This file is organized into one section for each system
-/* defined type followed at the end by a final section which
-/* initializes the type tables. Each of the type specific
-/* sections does #defines for each type specific parameter. The
-/* gdb_i_stype initialization routine at the end of this source
-/* file uses these defines to initialize the appropriate entry in
-/* the type definition tables.
-/*
-/* NOTE: some of the type definitions in this file may be machine
-/* dependent.
-/*
-/************************************************************************/
+/************************************************************************
+ *
+ * gdb_stype.c
+ *
+ * GDB - System Data Type Definitions
+ *
+ * Author: Noah Mendelsohn
+ * Copyright: 1986 MIT Project Athena
+ * For copying and distribution information, please see
+ * the file <mit-copyright.h>.
+ *
+ * This file initializes the definitions for all system defined
+ * data types, and it includes the type specific semantic routines
+ * for each of the system defined types.
+ *
+ * The initialization routine which adds these type definitions
+ * to the type definition table is at the end of this source file.
+ *
+ ************************************************************************
+ *
+ * This file is organized into one section for each system
+ * defined type followed at the end by a final section which
+ * initializes the type tables. Each of the type specific
+ * sections does #defines for each type specific parameter. The
+ * gdb_i_stype initialization routine at the end of this source
+ * file uses these defines to initialize the appropriate entry in
+ * the type definition tables.
+ *
+ * NOTE: some of the type definitions in this file may be machine
+ * dependent.
+ *
+ ************************************************************************/
#include <mit-copyright.h>
#include <stdio.h>
-#include <strings.h>
+#include <string.h>
#include "gdb.h"
#ifdef vax /* XXX */
extern u_long ntohl(), htonl();
#endif vax
#include <netinet/in.h> /* for htonl routine */
-\f
-/************************************************************************/
-/*
-/* INTEGER_T
-/*
-/************************************************************************/
+
+
+/************************************************************************
+ *
+ * INTEGER_T
+ *
+ ************************************************************************/
#define IN_LEN (sizeof(int))
#define IN_ALI IN_LEN
{
fprintf(gdb_log, "INTEGER_T\t%s=%d\n",name,(*(int *)dp));
}
-\f
+
+
/************************************************************************/
/*
/* STRING_T
* Now, copy the data itself after the encoded integer length
*/
if (len > 0)
- bcopy(STRING_DATA(*stp), nextp, len);
+ memcpy(nextp, STRING_DATA(*stp), len);
/* copy the data without */
/* changing representation*/
return (int)(nextp+len);
/*
* Now, copy the data itself
*/
- bcopy(nextp, STRING_DATA(*stp), len); /* copy the data without */
+ memcpy(STRING_DATA(*stp), nextp, len); /* copy the data without */
/* changing representation*/
return (int)(nextp+len);
}
fprintf(gdb_log,"\"\n");
}
-\f
+
+
/************************************************************************/
/*
/* REAL_T
{
fprintf(gdb_log, "REAL_T\t\t%s=%le\n",name,*((double *)dp) );
}
-\f
+
+
/************************************************************************/
/*
/* DATE_T
{
char buf[DT_EXTERNSIZE+1];
- bcopy(dp, buf, DT_EXTERNSIZE); /* copy date to buffer */
+ memcpy(buf, dp, DT_EXTERNSIZE); /* copy date to buffer */
buf[DT_EXTERNSIZE] = '\0'; /* null terminate it */
fprintf(gdb_log, "DATE_T\t\t%s=%s\n",name,buf);
}
-\f
+
+
/************************************************************************/
/*
/* TUPLE_DESCRIPTOR_T
/*
* Finally, copy all the null terminated strings.
*/
- bcopy(((char *)(tdp))+gdb_descriptor_length(tdp->field_count),
- nextp, tdp->str_len); /* copy the string data all */
+ memcpy(nextp,((char *)(tdp))+gdb_descriptor_length(tdp->field_count),
+ tdp->str_len); /* copy the string data all */
/* at once */
return (int)(nextp+tdp->str_len);
}
}
fprintf(gdb_log,"\n");
}
-\f
+
+
/************************************************************************/
/*
/* TUPLE_T
fprintf(gdb_log,"END_OF_TUPLE\n");
}
-\f
+
+
/************************************************************************/
/*
/* TUPLE_DATA_T
fprintf(gdb_log,"END_OF_TUPLE\n");
}
-\f
+
+
/************************************************************************/
/*
/* RELATION_T
fprintf(gdb_log,"END_OF_RELATION\n");
}
-\f
+
+
/************************************************************************/
/*
/* DECLARE AND INITIALIZE THE SYSTEM TYPE DEFINITION
#endif lint
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-/************************************************************************/
-/*
-/* gdb_trans2.c
-/*
-/* GDB - Data Transport Services Routines (Part 2)
-/*
-/* Author: Noah Mendelsohn
-/* Copyright: 1986 MIT Project Athena
-/* For copying and distribution information, please see
-/* the file <mit-copyright.h>.
-/*
-/*
-/* These routines implement layer 6 of the Client Library
-/* Specification of the GDB system, as well as the facilities
-/* outlined in the GDB Protocol Specification. Part 2 of 2.
-/*
-/* Some of the routines specified are actually implemented as
-/* macros defined in gdb.h.
-/*
-/************************************************************************/
+/************************************************************************
+ *
+ * gdb_trans2.c
+ *
+ * GDB - Data Transport Services Routines (Part 2)
+ *
+ * Author: Noah Mendelsohn
+ * Copyright: 1986 MIT Project Athena
+ * For copying and distribution information, please see
+ * the file <mit-copyright.h>.
+ *
+ *
+ * These routines implement layer 6 of the Client Library
+ * Specification of the GDB system, as well as the facilities
+ * outlined in the GDB Protocol Specification. Part 2 of 2.
+ *
+ * Some of the routines specified are actually implemented as
+ * macros defined in gdb.h.
+ *
+ ************************************************************************/
#include <mit-copyright.h>
#include <sys/types.h>
#include "gdb.h"
#include <sys/uio.h>
#include <sys/socket.h>
+#include <string.h>
extern int errno; /* Unix error slot */
/*
* Copy the data, update both stream and data buffer pointers
*/
- bcopy(hc->stream_buffer_next, hc->next_byte, count);
+ memcpy(hc->next_byte, hc->stream_buffer_next, count);
hc->stream_buffer_next += count;
hc->stream_buffer_remaining -= count;
#ifdef SYSLOG
#include <syslog.h>
#endif
+#include <string.h>
/* mode to create the file with */
#ifdef ZEPHYR
ZNotice_t znotice;
+#ifdef POSIX
+ memset (&znotice, 0, sizeof (znotice));
+#else
bzero (&znotice, sizeof (znotice));
+#endif
znotice.z_kind = UNSAFE;
znotice.z_class = "MOIRA";
znotice.z_class_inst = inst;
#include <netinet/in.h>
#include <netdb.h>
#include <stdio.h>
-#include <strings.h>
+#ifdef POSIX
+#include <sys/utsname.h>
+#endif
+#include <string.h>
#include <ctype.h>
#include <moira.h>
int n_len;
int has_dot = 0;
char tbuf[BUFSIZ];
+#ifdef POSIX
+ struct utsname name;
+#endif
register char *cp;
if (strlen(host) > 2 && host[0] == '"' && host[strlen(host)-1] == '"') {
return(strsave(tbuf));
}
- if (index(host, '*') || index(host, '?') || index(host, '['))
+ if (strchr(host, '*') || strchr(host, '?') || strchr(host, '['))
return(host);
hp = gethostbyname(host);
static char *domain = NULL;
if (domain == NULL) {
+#ifdef POSIX
+ (void) uname(&name);
+ strncpy(tbuf, name.nodename, sizeof(tbuf));
+#else
gethostname(tbuf, sizeof(tbuf));
+#endif
hp = gethostbyname(tbuf);
- cp = index(hp->h_name, '.');
+ cp = strchr(hp->h_name, '.');
if (cp)
domain = strsave(++cp);
else
#include <mit-copyright.h>
#include <ctype.h>
#include <moira.h>
+#include <string.h>
extern char *malloc();
free(h);
return((struct hash *) NULL);
}
- bzero(h->data, size * sizeof(char *));
+ memset(h->data, 0, size * sizeof(char *));
return(h);
}
*/
#include <mit-copyright.h>
-#include <strings.h>
+#include <string.h>
#include <ctype.h>
{
char *hyphen;
- while ((hyphen = index(str, '-')) != (char *)0)
+ while ((hyphen = strchr(str, '-')) != (char *)0)
(void) strcpy(hyphen, hyphen + 1);
}
#include <mit-copyright.h>
#include "mr_private.h"
+#include <string.h>
+
/*
* Check access to a named query.
register char **nargv = (char **)malloc(sizeof(char *) * (argc+1));
register int status = 0;
nargv[0] = name;
- bcopy((char *)argv, (char *)(nargv+1), sizeof(char *) * argc);
+ memcpy((char *)(nargv+1), (char *)argv, sizeof(char *) * argc);
status = mr_access_internal(argc+1, nargv);
free(nargv);
return status;
#include <ctype.h>
#include <krb.h>
#include <krb_et.h>
-#include <strings.h>
+#include <string.h>
/* Authenticate this client with the MR server. prog is the name of the
* client program, and will be recorded in the database.
/* Build a Kerberos authenticator. */
- bzero(host, sizeof(host));
+ memset(host, 0, sizeof(host));
if (status = mr_host(host, sizeof(host) - 1))
return status;
- strcpy(realm, krb_realmofhost(host));
+ strcpy(realm, (char *)krb_realmofhost(host));
for (p = host; *p && *p != '.'; p++)
if (isupper(*p))
*p = tolower(*p);
#include <mit-copyright.h>
#include "mr_private.h"
#include <moira_site.h>
-#include <strings.h>
+#include <string.h>
static char *mr_server_host = 0;
server = MOIRA_SERVER;
}
- if (!index(server, ':')) {
- p = index(MOIRA_SERVER, ':');
+ if (!strchr(server, ':')) {
+ p = strchr(MOIRA_SERVER, ':');
p++;
sprintf(sbuf, "%s:%s", server, p);
server = sbuf;
*/
mr_server_host = strsave(server);
- if (p = index(mr_server_host, ':'))
+ if (p = strchr(mr_server_host, ':'))
*p = 0;
mr_server_host = canonicalize_hostname(mr_server_host);
return 0;
#include <sys/types.h>
#include <netinet/in.h>
#include "mr_private.h"
+#include <string.h>
/*
* GDB operations to send and recieve RPC requests and replies.
arg->mr_flattened = buf = malloc(mr_size);
- bzero(arg->mr_flattened, mr_size);
+ memset(arg->mr_flattened, 0, mr_size);
arg->mr_size = mr_size;
len = argl[i];
*((long *)bp) = htonl(len);
bp += sizeof(long);
- bcopy(arg->mr_argv[i], bp, len);
+ memcpy(bp, arg->mr_argv[i], len);
bp += sizeof(long) * howmany(len, sizeof(long));
}
op->fcn.cont = mr_cont_send;
}
arg->mr_flattened = malloc(arg->mr_size);
arg->mr_state = S_DECODE_DATA;
- bcopy((caddr_t)&arg->mr_size, arg->mr_flattened, sizeof(long));
+ memcpy(arg->mr_flattened, (caddr_t)&arg->mr_size, sizeof(long));
if (gdb_receive_data(hcon,
arg->mr_flattened + sizeof(long),
return OP_CANCELLED;
}
arg->mr_argv[i] = (char *)malloc(nlen);
- bcopy(cp, arg->mr_argv[i], nlen);
+ memcpy(arg->mr_argv[i], cp, nlen);
arg->mr_argl[i]=nlen;
cp += sizeof(long) * howmany(nlen, sizeof(long));
}
#include <mit-copyright.h>
#include "mr_private.h"
+#include <string.h>
/*
* This routine is the primary external interface to the mr library.
register char **nargv = (char **)malloc(sizeof(char *) * (argc+1));
register int status = 0;
nargv[0] = name;
- bcopy((char *)argv, (char *)(nargv+1), sizeof(char *) * argc);
+ memcpy((char *)(nargv+1), (char *)argv, sizeof(char *) * argc);
status = mr_query_internal(argc+1, nargv, callproc, callarg);
free(nargv);
return status;
#include <mit-copyright.h>
#include <moira.h>
#include <stdio.h>
-#include <strings.h>
+#include <string.h>
#include <ctype.h>
extern char *strsave();
do {
/* Copy next component of type to temp */
- char *t = index (cp, ',');
+ char *t = strchr (cp, ',');
if (t) {
- bcopy(cp, temp, t-cp);
+ memcpy(temp, cp, t-cp);
temp[t-cp]='\0';
cp = t + 1; /* one after the comma */
} else {
#include <mit-copyright.h>
#include <moira.h>
+#include <string.h>
extern char *malloc();
for (i = 0; i < argc; i++) {
n = strlen(argv[i]) + 1;
argv_copy[i] = (char *)malloc(n);
- bcopy(argv[i], argv_copy[i], n);
+ memcpy(argv_copy[i], argv[i], n);
}
sq_save_data(sq, (char *)argv_copy);
}
len = strlen(s) + 1;
p = malloc((u_int)len);
- if (p) bcopy(s, p, len);
+ if (p) memcpy(p, s, len);
return p;
}
/*
#include <mit-copyright.h>
#include <stdio.h>
-#include <strings.h>
+#include <string.h>
#include <gdb.h>
#include <krb.h>
#include <krb_et.h>
#include <netinet/in.h>
#include <errno.h>
+#ifdef POSIX
+#include <sys/utsname.h>
+#endif
extern char buf[BUFSIZ];
extern int have_authorization;
AUTH_DAT ad;
char *p, *first, *config_lookup();
KTEXT_ST ticket_st;
+#ifdef POSIX
+ struct utsname name;
+#endif
if (send_ok())
lose("sending okay for authorization (auth_001)");
code = connection_errno(conn);
lose("awaiting Kerberos authenticators");
}
- gethostname(host, BUFSIZ);
+#ifdef POSIX
+ (void) uname(&name);
+ strncpy(host, name.nodename, sizeof(host));
+#else
+ gethostname(host, sizeof(host));
+#endif
ticket_st.mbz = 0;
ticket_st.length = MAX_STRING_SIZE(data);
- bcopy(STRING_DATA(data), ticket_st.dat, MAX_STRING_SIZE(data));
+ memcpy(ticket_st.dat, STRING_DATA(data), MAX_STRING_SIZE(data));
code = krb_rd_req(&ticket_st, service,
krb_get_phost(host), 0,
&ad, KEYFILE);
lose("sending approval of authorization");
have_authorization = 1;
/* Stash away session key */
- bcopy(ad.session, session, sizeof(session));
+ memcpy(session, ad.session, sizeof(session));
return(0);
auth_failed:
sprintf(buf, "auth for %s.%s@%s failed: %s",