home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / x / volume6 / xnetld / patch1 / RUPRPC.patch < prev   
Encoding:
Text File  |  1990-03-20  |  3.9 KB  |  142 lines

  1. *** Imakefile.dist    Tue Oct 10 08:06:25 1989
  2. --- Imakefile    Wed Feb 21 12:27:04 1990
  3. ***************
  4. *** 22,47 ****
  5.   # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  6.   #
  7.   
  8.   #
  9.   # Since xnetload finds the local machine's load using the standard Load
  10.   # widget stuff, it needs to be able to read kmem, i.e.  setgid kmem.  If
  11.   # you do not want this, then define NOLOCAL
  12. ! #        DEFINES = -O -DNOLOCAL
  13.   
  14. !        INCLUDES = -I$(TOP) -I$(TOP)/X11
  15.   
  16.   # Dynix doesn't have -L option on load, but I have left changing the
  17.   # XLIB specification up to individual sites.  Dynix and our Sun 3.5
  18.   # don't come with a memcpy, so you'll have to add in whichever library
  19.   # has memcpy.
  20. ! /* LOCAL_LIBRARIES = $(XAWLIB) $(XMULIB) $(XTOOLLIB) $(XLIB) */
  21. ! LOCAL_LIBRARIES = -L/usr/software/X11/lib -lXaw -lXmu -lXt -lX11
  22.   
  23. !            SRCS = xnetload.c getload.o
  24. !            OBJS = xnetload.o getload.o
  25.   
  26.      INSTALLFLAGS = $(INSTKMEMFLAGS)
  27.   
  28. ! all: xnetload
  29.   
  30. ! SingleProgramTarget(xnetload,$(OBJS),,$(LOCAL_LIBRARIES))
  31. --- 22,63 ----
  32.   # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  33.   #
  34.   
  35. +      COMPATFLAGS = -DXAW_BC
  36.   #
  37.   # Since xnetload finds the local machine's load using the standard Load
  38.   # widget stuff, it needs to be able to read kmem, i.e.  setgid kmem.  If
  39.   # you do not want this, then define NOLOCAL
  40. ! #if SunOSPlatform
  41. !       RUPDEFINES = -DRUPRPC -DDEFREMUPDATE=5 /* -DDEBUGGING */
  42. !    SYS_LIBRARIES = -lrpcsvc
  43. ! #endif
  44. !          DEFINES = /* -DNOLOCAL */ $(RUPDEFINES)
  45.   
  46. ! #       INCLUDES = -I$(TOP) -I$(TOP)/X11
  47.   
  48.   # Dynix doesn't have -L option on load, but I have left changing the
  49.   # XLIB specification up to individual sites.  Dynix and our Sun 3.5
  50.   # don't come with a memcpy, so you'll have to add in whichever library
  51.   # has memcpy.
  52. ! LOCAL_LIBRARIES = $(XAWLIB) $(XMULIB) $(XTOOLLIB) $(XLIB)
  53.   
  54. !            SRCS = xnetload.c getload.c X11/Load.c
  55. !            OBJS = xnetload.o getload.o Load.o
  56.   
  57.      INSTALLFLAGS = $(INSTKMEMFLAGS)
  58.   
  59. ! ComplexProgramTarget(xnetload)
  60.   
  61. ! Load.o:        X11/Load.c
  62. !         $(CC) -c $(CFLAGS) X11/Load.c
  63. ! #if SunOSPlatform
  64. ! #if HasGcc    /* GCC is too picky about syntax in Sun RPC header files */
  65. ! getload.o:    getload.c
  66. !         @if [ "$(CC)" != cc ] ;\
  67. !         then $(MAKE) CC=cc CCOPTIONS= getload.o ;\
  68. !         else cmd="$(CC) -c $(CFLAGS) getload.c"; echo $$cmd; $$cmd ;\
  69. !         fi
  70. ! #endif
  71. ! #endif
  72. *** getload.c.dist    Tue Oct 10 08:06:26 1989
  73. --- getload.c    Wed Feb 21 13:21:55 1990
  74. ***************
  75. *** 32,37 ****
  76. --- 32,87 ----
  77.   #include <sys/types.h>
  78.   #include <sys/time.h>
  79.   
  80. + #ifdef RUPRPC
  81. + #include <sys/param.h>
  82. + #include <sys/stat.h>
  83. + #include <sys/socket.h>
  84. + #include <rpcsvc/rstat.h>
  85. + #include <rpc/rpc.h>
  86. + #include <rpc/pmap_clnt.h>
  87. + int
  88. + getload(host)
  89. +     char *host;
  90. + {
  91. +     enum clnt_stat err;
  92. +     struct statstime sw;
  93. +     
  94. + #ifdef DEBUGGING
  95. +     fprintf(stderr, "xnetload: %s: ", host);
  96. +     fflush(stderr);
  97. + #endif
  98. +     err = (enum clnt_stat)callrpc(host, RSTATPROG, RSTATVERS_TIME,
  99. +         RSTATPROC_STATS, xdr_void, 0, xdr_statstime, &sw);
  100. +     if (err != RPC_SUCCESS)
  101. +          if (err == RPC_PROGVERSMISMATCH) {
  102. +         if (err = (enum clnt_stat)callrpc(host, RSTATPROG,
  103. +             RSTATVERS_SWTCH, RSTATPROC_STATS, xdr_void, 0,
  104. +             xdr_statsswtch, &sw)) {
  105. + #ifndef DEBUGGING
  106. +             fprintf(stderr, "xnetload: %s: ", host);
  107. + #endif
  108. +             clnt_perrno(err);
  109. +             fprintf(stderr, "\n");
  110. +             return( -1 );
  111. +         }
  112. +     }
  113. +     else {
  114. + #ifndef DEBUGGING
  115. +         fprintf(stderr, "xnetload: %s: ", host);
  116. + #endif
  117. +         clnt_perrno(err);
  118. +         fprintf(stderr, "\n");
  119. +         return( -1 );
  120. +     }
  121. + #ifdef DEBUGGING
  122. +     fprintf(stderr, "%lf\n", (double)sw.avenrun[0]/FSCALE);
  123. + #endif
  124. +     return( (double)sw.avenrun[0]/FSCALE * 100.0);
  125. + }
  126. + #else /* no RUPRPC */
  127.   /* Dynix doesn't have an rwhod.h file, so here's the struct for that system */
  128.   #ifdef sequent
  129.   struct  outmp {
  130. ***************
  131. *** 113,115 ****
  132. --- 163,166 ----
  133.       }
  134.       return(0);        /* couldn't read load if here */
  135.   }
  136. + #endif
  137.