diff -Naur fam-oss-2.6.2/fam/Cred.c++ fam-oss-2.6.2-new/fam/Cred.c++ --- fam-oss-2.6.2/fam/Cred.c++ Thu Mar 2 01:51:17 2000 +++ fam-oss-2.6.2-new/fam/Cred.c++ Wed Apr 5 15:07:47 2000 @@ -21,6 +21,7 @@ // Temple Place - Suite 330, Boston MA 02111-1307, USA. #include "Cred.h" +#include "snprintf.h" #include #include @@ -60,7 +61,11 @@ struct passwd *pwd; char buf[BUFSIZ]; gid_t *gs = new gid_t[ng]; +#ifdef IRIX_5_3 + if ((pwd=getpwuid(u)) && (pwd != NULL)) +#else if ((getpwuid_r(u, &pwbuf, buf, BUFSIZ, &pwd) == 0) && (pwd != NULL)) +#endif { #if HAVE_GETGRMEMBER ng = getgrmember(pwd->pw_name, gs, ng, 0); @@ -71,7 +76,11 @@ } #else char buf[BUFSIZ]; +#ifdef IRIX_5_3 + group *gb; +#else group gb; +#endif group *gbp; unsigned int ngi = 0; setgrent(); @@ -78,6 +87,21 @@ // getgrent_r differs between linux & irix. Assume we're on linux // if not HAVE_GETGRMEMBER, and use the linux getgent_r... This // should be handled better in configure.in. +#ifdef IRIX_5_3 + while ((ngi < ng) && (gb=getgrent())) + { + // See if our user's name is in the list of group members. + for (int i = 0; gb->gr_mem[i] != NULL; ++i) + { + if (!strcmp(pwd->pw_name, gb->gr_mem[i])) + { + gs[ngi++] = gb->gr_gid; + break; + } + } + } + +#else while ((ngi < ng) && (getgrent_r(&gb, buf, BUFSIZ, &gbp) == 0)) { // See if our user's name is in the list of group members. @@ -90,6 +114,7 @@ } } } +#endif endgrent(); ng = ngi; #endif // HAVE_GETGRMEMBER diff -Naur fam-oss-2.6.2/fam/IMonIrix.c++ fam-oss-2.6.2-new/fam/IMonIrix.c++ --- fam-oss-2.6.2/fam/IMonIrix.c++ Thu Mar 2 01:51:18 2000 +++ fam-oss-2.6.2-new/fam/IMonIrix.c++ Wed Apr 5 15:37:07 2000 @@ -34,6 +34,15 @@ #include "Log.h" #include "IMon.h" +#ifdef IRIX_5_3 +typedef struct revokdi { + dev_t rv_dev; + ino_t rv_ino; + intmask_t rv_what; +} revokdi_t; +#define IMONIOC_REVOKDI (('i' << 8) | 6) +#endif + const intmask_t INTEREST_MASK = (IMON_CONTENT | IMON_ATTRIBUTE | IMON_DELETE | IMON_EXEC | IMON_EXIT | IMON_RENAME); @@ -48,7 +57,11 @@ IMon::Status IMon::imon_express(const char *name, struct stat *status) { +#ifdef IRIX_5_3 + interest_t interest = { (char *) name, status, INTEREST_MASK }; +#else struct interest interest = { (char *) name, status, INTEREST_MASK }; +#endif int rc = ioctl(imonfd, IMONIOC_EXPRESS, &interest); if (rc < 0) { @@ -84,7 +97,11 @@ if (can_revokdi) { +#ifdef IRIX_5_3 + revokdi_t revokdi = { dev, ino, INTEREST_MASK }; +#else struct revokdi revokdi = { dev, ino, INTEREST_MASK }; +#endif int rc = ioctl(imonfd, IMONIOC_REVOKDI, &revokdi); if (rc < 0) { Log::perror("IMONIOC_REVOKDI on \"%s\" failed", name); @@ -99,7 +116,11 @@ { // Try the old revoke ioctl. +#ifdef IRIX_5_3 + interest_t interest = { (char *) name, NULL, INTEREST_MASK }; +#else struct interest interest = { (char *) name, NULL, INTEREST_MASK }; +#endif int rc = ioctl(imonfd, IMONIOC_REVOKE, &interest); if (rc < 0) { // Log error at LOG_DEBUG. IMONIOC_REVOKE fails all the time. diff -Naur fam-oss-2.6.2/fam/Listener.c++ fam-oss-2.6.2-new/fam/Listener.c++ --- fam-oss-2.6.2/fam/Listener.c++ Thu Mar 2 01:51:19 2000 +++ fam-oss-2.6.2-new/fam/Listener.c++ Wed Apr 5 15:11:46 2000 @@ -23,6 +23,7 @@ #include "Listener.h" #include +#include #include #include #include diff -Naur fam-oss-2.6.2/fam/LocalClient.c++ fam-oss-2.6.2-new/fam/LocalClient.c++ --- fam-oss-2.6.2/fam/LocalClient.c++ Thu Mar 2 01:51:19 2000 +++ fam-oss-2.6.2-new/fam/LocalClient.c++ Wed Apr 5 15:13:23 2000 @@ -21,6 +21,7 @@ // Temple Place - Suite 330, Boston MA 02111-1307, USA. #include +#include #include #include diff -Naur fam-oss-2.6.2/fam/MxClient.c++ fam-oss-2.6.2-new/fam/MxClient.c++ --- fam-oss-2.6.2/fam/MxClient.c++ Thu Mar 2 01:51:19 2000 +++ fam-oss-2.6.2-new/fam/MxClient.c++ Wed Apr 5 15:16:13 2000 @@ -20,6 +20,7 @@ // with this program; if not, write the Free Software Foundation, Inc., 59 // Temple Place - Suite 330, Boston MA 02111-1307, USA. +#include #include "MxClient.h" #include diff -Naur fam-oss-2.6.2/fam/NetConnection.c++ fam-oss-2.6.2-new/fam/NetConnection.c++ --- fam-oss-2.6.2/fam/NetConnection.c++ Thu Mar 2 01:51:19 2000 +++ fam-oss-2.6.2-new/fam/NetConnection.c++ Wed Apr 5 15:17:07 2000 @@ -20,6 +20,7 @@ // with this program; if not, write the Free Software Foundation, Inc., 59 // Temple Place - Suite 330, Boston MA 02111-1307, USA. +#include "snprintf.h" #include "NetConnection.h" #include diff -Naur fam-oss-2.6.2/fam/RPC_TCP_Connector.c++ fam-oss-2.6.2-new/fam/RPC_TCP_Connector.c++ --- fam-oss-2.6.2/fam/RPC_TCP_Connector.c++ Thu Mar 2 01:51:20 2000 +++ fam-oss-2.6.2-new/fam/RPC_TCP_Connector.c++ Wed Apr 5 16:09:05 2000 @@ -20,6 +20,7 @@ // with this program; if not, write the Free Software Foundation, Inc., 59 // Temple Place - Suite 330, Boston MA 02111-1307, USA. + #include "RPC_TCP_Connector.h" #include @@ -29,7 +30,11 @@ #include #include #include +#ifdef IRIX_5_3 +extern "C" int rresvport(int *port); +#else #include // for rresvport +#endif #include "Log.h" #include "Scheduler.h" diff -Naur fam-oss-2.6.2/fam/Scheduler.c++ fam-oss-2.6.2-new/fam/Scheduler.c++ --- fam-oss-2.6.2/fam/Scheduler.c++ Thu Mar 2 01:51:20 2000 +++ fam-oss-2.6.2-new/fam/Scheduler.c++ Wed Apr 5 15:29:58 2000 @@ -232,7 +232,7 @@ Scheduler::trim_fdinfo() { for (FDInfo *fp = &fdinfo[nfds - 1]; nfds > 0; --nfds, --fp) - if (fp->read.handler || fp->write.handler) + if (fp->read.xxx_handler || fp->write.xxx_handler) break; if (!nfds) @@ -249,8 +249,8 @@ assert(fd >= 0); assert(handler); FDInfo *fp = fd_to_info(fd); - IOHandler old_handler = (fp->*(iotype->iotype)).handler; - (fp->*(iotype->iotype)).handler = handler; + IOHandler old_handler = (fp->*(iotype->iotype)).xxx_handler; + (fp->*(iotype->iotype)).xxx_handler = handler; (fp->*(iotype->iotype)).closure = closure; assert(!old_handler || FD_ISSET(fd, &iotype->fds)); if (!FD_ISSET(fd, &iotype->fds)) @@ -266,8 +266,8 @@ { assert(fd >= 0 && fd < nfds); FDInfo *fp = fd_to_info(fd); - IOHandler old_handler = (fp->*(iotype->iotype)).handler; - (fp->*(iotype->iotype)).handler = NULL; + IOHandler old_handler = (fp->*(iotype->iotype)).xxx_handler; + (fp->*(iotype->iotype)).xxx_handler = NULL; (fp->*(iotype->iotype)).closure = NULL; trim_fdinfo(); assert(old_handler); @@ -311,7 +311,7 @@ if (FD_ISSET(fd, fds)) { FDInfo *fp = &fdinfo[fd]; assert(iotype == &FDInfo::read || iotype == &FDInfo::write); - (fp->*iotype).handler(fd, (fp->*iotype).closure); + (fp->*iotype).xxx_handler(fd, (fp->*iotype).closure); // Remember, handler may move fdinfo array. } } diff -Naur fam-oss-2.6.2/fam/Scheduler.h fam-oss-2.6.2-new/fam/Scheduler.h --- fam-oss-2.6.2/fam/Scheduler.h Thu Mar 2 01:51:24 2000 +++ fam-oss-2.6.2-new/fam/Scheduler.h Wed Apr 5 14:57:37 2000 @@ -24,6 +24,7 @@ #define Scheduler_included #include +#include #include "Boolean.h" @@ -94,7 +95,7 @@ struct FDInfo { struct handler { - IOHandler handler; + IOHandler xxx_handler; void *closure; } read, write; }; diff -Naur fam-oss-2.6.2/include/fam.h fam-oss-2.6.2-new/include/fam.h --- fam-oss-2.6.2/include/fam.h Thu Mar 2 01:56:12 2000 +++ fam-oss-2.6.2-new/include/fam.h Wed Apr 5 16:27:05 2000 @@ -43,7 +43,8 @@ /* For NAME_MAX - maximum # of chars in a filename */ #include "limits.h" - +#include +#include "snprintf.h" diff -Naur fam-oss-2.6.2/include/snprintf.h fam-oss-2.6.2-new/include/snprintf.h --- fam-oss-2.6.2/include/snprintf.h +++ fam-oss-2.6.2-new/include/snprintf.h Wed Apr 5 16:28:34 2000 @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2000 QUALCOMM Incorporated. All rights reserved. + * See License.txt file for terms and conditions for modification and + * redistribution. + * + * Revisions: + * + * 01/27/00 [rcg] + * - Changed snprintf to vsnprintf, added snprint as jacket. + * + * 01/20/00 [rg] + * - File added. + * + */ + + +#ifndef _SNPRINTF_H +# define _SNPRINTF_H + + +#ifdef __cplusplus +extern "C" { +#endif + +# include +# include + +#ifndef HAVE_SNPRINTF +int snprintf ( char *s, size_t n, const char *format, ... ); +#endif /* not HAVE_SNPRINTF */ + +#ifndef HAVE_VSNPRINTF +int vsnprintf ( char *s, size_t n, const char *format, va_list ap ); +#endif /* not HAVE_VSNPRINTF */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SNPRINTF_H */ + + diff -Naur fam-oss-2.6.2/test/snprintf.c fam-oss-2.6.2-new/test/snprintf.c --- fam-oss-2.6.2/test/snprintf.c +++ fam-oss-2.6.2-new/test/snprintf.c Wed Apr 5 16:43:20 2000 @@ -0,0 +1,322 @@ +/* + * Copyright (c) 2000 QUALCOMM Incorporated. All rights reserved. + * See License.txt file for terms and conditions for modification and + * redistribution. + * + * snprintf.c: + * + * Revisions: + * + * 01/27/00 [rcg] + * - Changed snprintf to vsnprintf, added snprint as jacket. + * + * 01/20/00 [rcg] + * - Guarded with #ifndef HAVE_SNPRINTF + * + */ + +#include +#include +#include +#include + +/*#include "config.h"*/ +#include "snprintf.h" + + + +/* + * A (hopefully full enough) snprintf implementation built over sprintf. + * Based on modified version of snprint from one extracted from K&R 'C'. + * Reference : Unix specification version 2. Copyright 1997 Open Group. + * null terminated string. + * + * Caveats : + * - Limited support for format modifiers. + * - No nth argument specification %n$. + * - The known formats "sdcfxXgGeEou%". + * - Assuming int as 4 bytes, double as 8 bytes. No support for + * long double. + * + * Parameters: + * s: buffer to print to. + * n: max number of bytes to print. + * format: the format string. + * + * Returned : On success the number of bytes printed to buffer. + * On failure -1. + */ + +#ifndef HAVE_VSNPRINTF + + +# define BUFSIZE 1024 +# define MIN(A,B) ( ( (A) < (B) ) ? (A) : (B) ) +# define MAX(A,B) ( ( (A) > (B) ) ? (A) : (B) ) + + +/* + * Copy chars and update pointer and remaining space count. + * + * Parameters: + * s: pointer to char * for destination. + * m: pointer to source string. + * l: maximum chars to copy. + * n: pointer to remaining space count. + * + * Results: + * String 'm' is appended to 's'; 's' is updated to + * point at terminating null; 'n' is decremented by + * length of 'm'. + */ +static void +copy_buf ( char **s, char *m, size_t l, size_t *n ) +{ + l = MIN ( *m, l ); + strncpy ( *s, m, l ); + + l = MIN ( l, strlen(m) ); + *n -= l; + *s += l; +} + + +enum STATES_TAG +{ + IN_FORM, /* Copying format string chars */ + IN_CONV, /* In a conversion specification */ + IN_LEN /* In a maximum length field */ +}; + +typedef enum STATES_TAG STATES; + + +int +vsnprintf ( char *s, size_t n, const char *format, va_list ap ) +{ + char *sval; + int ival; + double dval; + char cval; + float fval; + char *p = (char *)format, /* Pointer into format string */ + msgBuf [ BUFSIZE ], /* Temporary store for printing + * ints, floats etc using sprintf */ + frmToken [ 64 ], /* Temporary store for conversion + * tokens. */ + *f; /* Pointer into frmToken */ + STATES nState = IN_FORM; + size_t nSize = n-1; + long width; /* If we have a width minimum */ + long limit; /* If we have a length limiter */ + + + if ( s == NULL || n == 0 || format == NULL ) + return -1; + + s [ n-1 ] = '\0'; + + for ( ; nSize > 0 && *p != '\0'; p++ ) { + if ( nState == IN_FORM ) { + if ( *p != '%' ) { + /* + * Still not in a conversion spec; just copy the char + */ + *s++ = *p; + nSize--; + } + else { + /* + * Start of a conversion spec + */ + nState = IN_CONV; + width = -1; + limit = -1; + f = frmToken; + *f++ = *p; + } + } /* nState == IN_FORM */ + else { /* We're still inside a conversion spec */ + switch ( *p ) { + + case 'c': /* C converts char args to int */ + case 'd': + case 'i': + case 'o': + case 'u': + case 'x': + case 'X': + /* + * Ensure width or max length, if specified, does not exceed + * available space. + */ + if ( width != -1 || limit != -1 ) + if ( MAX ( width, limit ) > + MIN ( BUFSIZE, nSize ) + ) + return -1; + + *f++ = *p; + *f = '\0'; + ival = va_arg ( ap, int ); + sprintf ( msgBuf, frmToken, ival ); + copy_buf ( &s, msgBuf, nSize, &nSize ); + nState = IN_FORM; + break; + + case 'f': /* C converts float args to double */ + case 'e': + case 'E': + case 'g': + case 'G': + /* + * Ensure width or max length, if specified, does not exceed + * available space. + */ + if ( width != -1 || limit != -1 ) + if ( MAX ( width, limit ) > + MIN ( BUFSIZE, nSize ) + ) + return -1; + + *f++ = *p; + *f = '\0'; + dval = va_arg ( ap, double ); + sprintf ( msgBuf, frmToken, dval ); + copy_buf ( &s, msgBuf, nSize, &nSize ); + nState = IN_FORM; + break; + + case 's': + /* + * Ensure width or max length, if specified, does not exceed + * available space. + */ + if ( width != -1 || limit != -1 ) + if ( MAX ( width, limit ) > + MIN ( BUFSIZE, nSize ) + ) + return -1; + + /* + * Get the string pointer. If NULL, or if the maximum length + * is zero, we're done with this conversion. + */ + sval = va_arg ( ap, char * ); + if ( sval == NULL || limit == 0 ) { + nState = IN_FORM; + break; + } + + /* + * Make sure we have room if limit is unspecified. + */ + if ( limit == -1 && strlen(sval) > nSize ) + return -1; + + /* + * Handle minimum width + */ + if ( width != -1 && width > strlen(sval) ) { + for ( ; width > 0; width-- ) + copy_buf ( &s, " ", nSize, &nSize ); + } + + /* + * Handle maximum length + */ + if ( limit != -1 && limit < strlen(sval) ) + copy_buf ( &s, sval, limit, &nSize ); + else + copy_buf ( &s, sval, nSize, &nSize ); + + nState = IN_FORM; + break; + + case '%': + *s++ = *p; + nSize--; + nState = IN_FORM; + break; + + case '*': + /* + * Variable min width or max length specification. + */ + if ( nState == IN_LEN && limit == -1 ) { + limit = va_arg ( ap, int ); + f += sprintf ( f, "%i", limit ); + } + else + if ( nState == IN_FORM && width == -1 ) { + width = va_arg ( ap, int ); + f += sprintf ( f, "%i", width ); + } + else + return -1; + break; + + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + *f++ = *p; + *f = '\0'; + + /* + * Width or max length specification. If the + * appropriate variable is -1, this is the start; + * otherwise it is a subsequent digit and we just + * skip over it. + */ + if ( nState == IN_LEN && limit == -1 ) + limit = atoi ( p ); + else + if ( nState == IN_FORM && width == -1 ) + width = atoi ( p ); + break; + + case '.': + /* + * Max length follows + */ + *f++ = *p; + *f = '\0'; + nState = IN_LEN; + break; + + default: + *f++ = *p; + *f = '\0'; + break; + } /* switch */ + } /* We're still inside a format */ + } /* for loop */ + + if ( nSize ) + *s++ = *p; + return ( (n-1) - nSize ); +} + +#endif /* not HAVE_VSNPRINTF */ + +#ifndef HAVE_SNPRINTF +int +snprintf ( char *s, size_t n, const char *format, ... ) +{ + int rslt; + va_list ap; /* Pointer into stack to extract + * parameters */ + va_start ( ap, format ); + rslt = vsnprintf ( s, n, format, ap ); + va_end ( ap ); + return rslt; +} +#endif /* not HAVE_SNPRINTF */ + diff -Naur fam-oss-2.6.2/test/test.c++ fam-oss-2.6.2-new/test/test.c++ --- fam-oss-2.6.2/test/test.c++ Mon Feb 7 23:32:41 2000 +++ fam-oss-2.6.2-new/test/test.c++ Wed Apr 5 16:26:17 2000 @@ -2,7 +2,18 @@ #include #include #include -#include +#include +#ifdef IRIX_5_3 + extern "C" void (*signal (int sig, void (*func)(int)))(int); + extern "C" int kill(int, int); + #define SIGINT 2 /* interrupt (rubout) */ + #define SIGUSR1 16 /* user defined signal 1 */ + #define SIGUSR2 17 /* user defined signal 2 */ + #define SIGTSTP 24 /* stop signal from tty */ + #define SIGCONT 25 /* continue a stopped process */ +#else + #include +#endif #include #include //#include