]> andersk Git - moira.git/blobdiff - gdb/gdb.c
Fixed polarity of USELOCALTOOLS
[moira.git] / gdb / gdb.c
index d53e8faf05dd74d44247f3fa61ab04d55545a235..03d10ee59682e44aa868f001007ab08f869ff5f1 100644 (file)
--- a/gdb/gdb.c
+++ b/gdb/gdb.c
@@ -34,12 +34,19 @@ static char *rcsid_gdb_c = "$Header$";
 #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[];
 
 extern int errno;
 
+/* This global is defined to make sure that Moira clients are linked
+ * against the correct library.
+ */
+int link_against_the_moira_version_of_gdb = 0;
 int g_inited = FALSE;                          /* gdb_init has not been */
                                                /* called */
 
@@ -61,10 +68,18 @@ gdb_init()
        char hostname[255];                     /* name of local host */
        extern uid_t getuid();
        int uid;                                /* Unix user-i.d. number */
-       char *uname;                            /* string form of i.d. */
+       char *username;                         /* string form of i.d. */
 
        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
         */
@@ -92,11 +107,9 @@ gdb_init()
         */
        gdb_mfd = 0;
 
-       for (i=0; i<NFDBITS/sizeof(int); i++) {
-               gdb_crfds.fds_bits[i] = 0;
-               gdb_cwfds.fds_bits[i] = 0;
-               gdb_cefds.fds_bits[i] = 0;
-       }
+       FD_ZERO(&gdb_crfds);
+       FD_ZERO(&gdb_cwfds);
+       FD_ZERO(&gdb_cefds);
 
        /*
         * Initialize the server/client layer
@@ -108,13 +121,23 @@ gdb_init()
         * 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);
 
@@ -124,11 +147,11 @@ gdb_init()
 
        if (pw_struct != NULL && pw_struct ->pw_name != NULL &&
            *pw_struct->pw_name !='\0') 
-               uname = pw_struct->pw_name;
+               username = pw_struct->pw_name;
        else
-               uname = "????";
-       gdb_uname = db_alloc(strlen(hostname)+1);
-       (void) strcpy(gdb_uname, uname);        
+               username = "????";
+       gdb_uname = db_alloc(strlen(username)+1);
+       (void) strcpy(gdb_uname, username);     
        
        return 0;
 }
This page took 0.076623 seconds and 4 git commands to generate.