From a3619f23f4aeff53f82fbde8578382db13c65cf9 Mon Sep 17 00:00:00 2001 From: mid Date: Mon, 4 Sep 2000 00:05:19 +0000 Subject: [PATCH] - Sun Sep 3 23:58:17 UTC 2000 - Portability fixes (for solaris, set the SOLARIS env var first) --- CHANGES | 3 +++ Makefile | 4 ++++ Makefile.rules | 5 +++++ aim_rxqueue.c | 32 ++++++++++++++++++++++++++++++-- aim_util.c | 38 ++++++++++++++++++++++++++++++++++++++ faim/aim.h | 8 +++++--- mkbuildinfo.sh | 9 ++------- utils/aimdebugd/file.c | 4 ++-- utils/faimtest/faimtest.c | 2 +- 9 files changed, 90 insertions(+), 15 deletions(-) diff --git a/CHANGES b/CHANGES index 4b57c98..e3e3c23 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,9 @@ No release numbers ------------------ + - Sun Sep 3 23:58:17 UTC 2000 + - Portability fixes (for solaris, set the SOLARIS env var first) + - Sat Sep 2 23:42:37 UTC 2000 - Hopefully fix aim_snac.c bugs - Add Buddy List Rights parser (max buddies and max watchers) diff --git a/Makefile b/Makefile index 01f03f1..326eded 100644 --- a/Makefile +++ b/Makefile @@ -36,7 +36,11 @@ mkbuildinfo: libfaim: mkbuildinfo $(LIBFAIM_OBJECTS) $(AR) cru libfaim.a $(LIBFAIM_OBJECTS) $(RANLIB) libfaim.a +ifdef SOLARIS + ld -G -o $(SONAME) $(LIBFAIM_OBJECTS) -lresolv +else ld -o $(SONAME) $(LIBFAIM_OBJECTS) -shared -soname $(SONAME) +endif allutils: libfaim @echo "LIBFAIM_INC = $$PWD" > utils/Makefile.dynamicrules; \ diff --git a/Makefile.rules b/Makefile.rules index 553e590..9b8980b 100644 --- a/Makefile.rules +++ b/Makefile.rules @@ -10,6 +10,11 @@ ifdef LIBFAIM_LIB LDFLAGS += -lfaim -L$(LIBFAIM_LIB) endif +ifdef SOLARIS +CC = gcc +MAKE = gmake +endif + AR = ar RANLIB = ranlib diff --git a/aim_rxqueue.c b/aim_rxqueue.c index 72f4481..f362e39 100644 --- a/aim_rxqueue.c +++ b/aim_rxqueue.c @@ -8,6 +8,34 @@ #include +/* + * Since not all implementations support MSG_WAITALL, define + * an alternate guarenteed read function... + */ +static int aim_recv(int fd, void *buf, size_t count) +{ +#ifdef FAIM_HAS_MSG_WAITALL + return recv(fd, buf, count, MSG_WAITALL); +#else + int left, ret, cur = 0; + + left = count; + + while (left) { + ret = read(fd, buf+cur, left); + if (ret == -1) + return -1; + if (ret == 0) + return cur; + + cur += ret; + left -= ret; + } + + return cur; +#endif +} + /* * Grab a single command sequence off the socket, and enqueue * it in the incoming event queue in a seperate struct. @@ -41,7 +69,7 @@ int aim_get_command(struct aim_session_t *sess, struct aim_conn_t *conn) * 4 short -- Number of data bytes that follow. */ faim_mutex_lock(&conn->active); - if (recv(conn->fd, generic, 6, MSG_WAITALL) < 6){ + if (aim_recv(conn->fd, generic, 6) < 6){ aim_conn_close(conn); faim_mutex_unlock(&conn->active); return -1; @@ -89,7 +117,7 @@ int aim_get_command(struct aim_session_t *sess, struct aim_conn_t *conn) } /* read the data portion of the packet */ - if (recv(conn->fd, newrx->data, newrx->commandlen, MSG_WAITALL) < newrx->commandlen){ + if (aim_recv(conn->fd, newrx->data, newrx->commandlen) < newrx->commandlen){ free(newrx->data); free(newrx); aim_conn_close(conn); diff --git a/aim_util.c b/aim_util.c index 9bbf828..77a3ba3 100644 --- a/aim_util.c +++ b/aim_util.c @@ -227,3 +227,41 @@ int aim_sncmp(const char *sn1, const char *sn2) return 0; } + +/* strsep Copyright (C) 1992, 1993 Free Software Foundation, Inc. + strsep is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If + not, write to the Free Software Foundation, Inc., 675 Mass Ave, + Cambridge, MA 02139, USA. */ + +/* Minor changes by and1000 on 15/1/97 to make it go under Nemesis */ + +char *aim_strsep(char **pp, const char *delim) +{ + char *p, *q; + + if (!(p = *pp)) + return 0; + + if ((q = strpbrk (p, delim))) + { + *pp = q + 1; + *q = '\0'; + } + else + *pp = 0; + + return p; +} diff --git a/faim/aim.h b/faim/aim.h index 0327561..244c28b 100644 --- a/faim/aim.h +++ b/faim/aim.h @@ -70,9 +70,8 @@ #define gethostbyname(x) gethostbyname2(x, AF_INET) #endif -#if !defined(MSG_WAITALL) -#warning FIX YOUR LIBC! MSG_WAITALL is required! -#define MSG_WAITALL 0x100 +#if defined(MSG_WAITALL) +#define FAIM_HAS_MSG_WAITALL #endif /* @@ -747,6 +746,9 @@ char *aimutil_itemidx(char *toSearch, int index, char dl); int aim_snlen(const char *sn); int aim_sncmp(const char *sn1, const char *sn2); +/* for libc's that dont have it */ +char *aim_strsep(char **pp, const char *delim); + /* aim_meta.c */ char *aim_getbuilddate(void); char *aim_getbuildtime(void); diff --git a/mkbuildinfo.sh b/mkbuildinfo.sh index 32357d7..075687d 100755 --- a/mkbuildinfo.sh +++ b/mkbuildinfo.sh @@ -1,10 +1,5 @@ #!/bin/sh rm -rf aim_meta.o aim_buildcode.h -echo -n "#define AIM_BUILDDATE \"" > aim_buildcode.h -echo -n `date +%Y%m%d` >> aim_buildcode.h -echo "\"" >> aim_buildcode.h - -echo -n "#define AIM_BUILDTIME \"" >> aim_buildcode.h -echo -n `date +%H%M%S` >> aim_buildcode.h -echo "\"" >> aim_buildcode.h +echo "#define AIM_BUILDDATE \"`date +%Y%m%d`\"" > aim_buildcode.h +echo "#define AIM_BUILDTIME \"`date +%H%M%S`\"" >> aim_buildcode.h diff --git a/utils/aimdebugd/file.c b/utils/aimdebugd/file.c index a8e9867..04069d1 100644 --- a/utils/aimdebugd/file.c +++ b/utils/aimdebugd/file.c @@ -72,8 +72,8 @@ int parsescriptline2(struct aim_session_t *sess, struct aim_conn_t **scriptconn, { char *sn, *msg; buf = nextwhite(buf)+1; - sn = strsep(&buf, "/"); - msg = strsep(&buf, "/"); + sn = aim_strsep(&buf, "/"); + msg = aim_strsep(&buf, "/"); sendimtoclient(sess, aim_getconn_type(sess, AIM_CONN_TYPE_BOS), sn, 0, msg); } break; diff --git a/utils/faimtest/faimtest.c b/utils/faimtest/faimtest.c index a6e3cbf..150ed3e 100644 --- a/utils/faimtest/faimtest.c +++ b/utils/faimtest/faimtest.c @@ -657,7 +657,7 @@ int faimtest_parse_incoming_im(struct aim_session_t *sess, struct command_rx_str newconn = aim_directim_initiate(sess, command->conn, NULL, userinfo->sn); //aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINITIATE, faimtest_directim_initiate, 0); } else if (!strncmp(tmpstr, "reqsendmsg", 10)) { - aim_send_im(sess, command->conn, "vaxherder", 0, "sendmsg 7986"); + aim_send_im(sess, command->conn, "vaxherder", 0, "sendmsg 7900"); } else if (!strncmp(tmpstr, "sendmsg", 7)) { int i; i = atoi(tmpstr+8); -- 2.45.2