[BACK]Return to gnuplot-v4.diff CVS log [TXT][DIR] Up to [local] / OpenXM / src / gnuplot

Annotation of OpenXM/src/gnuplot/gnuplot-v4.diff, Revision 1.1

1.1     ! ohara       1: diff -urN gnuplot-4.0.0.orig/configure.in gnuplot-4.0.0/configure.in
        !             2: --- gnuplot-4.0.0.orig/configure.in    Sun Apr 11 00:55:14 2004
        !             3: +++ gnuplot-4.0.0/configure.in Wed Dec 15 11:07:49 2004
        !             4: @@ -827,6 +827,10 @@
        !             5:             tutorial/Makefile],
        !             6:            [test -z "$CONFIG_HEADERS" || echo timestamp >stamp-h])
        !             7:
        !             8: +dnl for Solaris 2.x
        !             9: +AC_CHECK_FUNC(socket, , [AC_CHECK_LIB(socket,socket)])
        !            10: +AC_CHECK_FUNC(gethostbyname, , [AC_CHECK_LIB(nsl,gethostbyname)])
        !            11: +
        !            12:  dnl Report configuration
        !            13:  AC_MSG_RESULT([
        !            14:  ** Configuration summary for $PACKAGE $VERSION:
        !            15: diff -urN gnuplot-4.0.0.orig/src/plot.c gnuplot-4.0.0/src/plot.c
        !            16: --- gnuplot-4.0.0.orig/src/plot.c      Thu Apr 15 00:26:21 2004
        !            17: +++ gnuplot-4.0.0/src/plot.c   Wed Dec 15 11:08:39 2004
        !            18: @@ -53,6 +53,23 @@
        !            19:  #include <signal.h>
        !            20:  #include <setjmp.h>
        !            21:
        !            22: +/* TAKAYAMA Nobuki */
        !            23: +#include <sys/types.h>
        !            24: +#include <sys/socket.h>
        !            25: +#include <sys/time.h>
        !            26: +#include <netinet/in.h>
        !            27: +#include <netdb.h>
        !            28: +
        !            29: +FILE *openTCP     __P((char *));
        !            30: +
        !            31: +int socketConnect __P((char *, int));
        !            32: +int socketOpen        __P((char *, int));
        !            33: +int socketAccept  __P((int));
        !            34: +
        !            35: +int oxSocketSelect0   __P((int, int));
        !            36: +int oxSocketMultiSelect   __P((int *, int, int, int *));
        !            37: +/* END */
        !            38: +
        !            39:  #ifdef OS2 /* os2.h required for gpexecute.h */
        !            40:  # define INCL_DOS
        !            41:  # define INCL_REXXSAA
        !            42: @@ -618,8 +635,11 @@
        !            43:
        !            44:  /* interactive = FALSE; */ /* should this be here? */
        !            45:
        !            46: -          } else
        !            47: -              load_file(loadpath_fopen(*argv, "r"), *argv, FALSE);
        !            48: +          } else {
        !            49: +              load_file(openTCP(*argv), *argv, FALSE);
        !            50: +              fprintf(stderr, "gnuplot : EOF or there was an error"
        !            51: +                              "in the input stream.\n");
        !            52: +          }
        !            53:        }
        !            54:  #ifdef _Windows
        !            55:        if (noend) {
        !            56: @@ -950,3 +970,307 @@
        !            57:  #endif
        !            58:  }
        !            59:  #endif /* HAVE_LIBREADLINE && GNUPLOT_HISTORY */
        !            60: +
        !            61: +/*
        !            62: + * TAKAYAMA Nobuki
        !            63: + */
        !            64: +FILE *
        !            65: +openTCP(name)
        !            66: +      char *name;
        !            67: +{
        !            68: +      FILE *fp;
        !            69: +      int fd, port, reverse = 0;
        !            70: +
        !            71: +      fprintf(stderr, "openTCP port number : %s\n", name);
        !            72: +
        !            73: +      if (name[0] == 'r') {
        !            74: +              fprintf(stderr, "openTCP : trying to reverse connetion.\n");
        !            75: +              reverse = 1;
        !            76: +              sscanf(&name[1], "%d", &port);
        !            77: +      } else {
        !            78: +              sscanf(name, "%d", &port);
        !            79: +      }
        !            80: +
        !            81: +      if (reverse) {
        !            82: +              fd = socketConnect("localhost", port);
        !            83: +              fprintf(stderr, "socketConnect is succeded: fd = %d.", fd);
        !            84: +      } else {
        !            85: +              fprintf(stderr, "Port number is %d.\n", port);
        !            86: +              fd = socketOpen("localhost", port);
        !            87: +              fprintf(stderr, "socketOpen is succeded: fd = %d.", fd);
        !            88: +              fd = socketAccept(fd);
        !            89: +      }
        !            90: +
        !            91: +      fprintf(stderr, "\n Port %d : Connected.\n", port);
        !            92: +      fp = fdopen(fd, "r");
        !            93: +
        !            94: +      return(fp);
        !            95: +}
        !            96: +
        !            97: +#define       READBUFSIZE     10000
        !            98: +
        !            99: +int OpenedSocket = 0, Quiet = 0;
        !           100: +
        !           101: +int
        !           102: +socketConnect(serverName, portNumber)
        !           103: +      char *serverName;
        !           104: +      int portNumber;
        !           105: +{
        !           106: +      struct hostent *servhost;
        !           107: +      struct sockaddr_in serv;
        !           108: +      int socketid, on;
        !           109: +
        !           110: +      if ((servhost = gethostbyname(serverName)) == NULL) {
        !           111: +              fprintf(stderr, "Bad server name.\n\n");
        !           112: +              return (-1);
        !           113: +      }
        !           114: +
        !           115: +      bzero((void *)&serv, sizeof(serv));
        !           116: +      serv.sin_family = AF_INET;
        !           117: +      serv.sin_port = htons(portNumber);
        !           118: +      bcopy(servhost->h_addr, (void *)&serv.sin_addr, servhost->h_length);
        !           119: +
        !           120: +      if ((socketid = socket(AF_INET, SOCK_STREAM, 0)) <0) {
        !           121: +              fprintf(stderr, "Socket allocation is failed.\n\n");
        !           122: +              return (-1);
        !           123: +      }
        !           124: +
        !           125: +#if 0 /* XXX */
        !           126: +      on = 1;
        !           127: +      setsockopt(socketid, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));
        !           128: +#endif
        !           129: +
        !           130: +      if (!Quiet) {
        !           131: +              fprintf(stderr, "Trying to connect port %d, ip=%x\n",
        !           132: +                      ntohs(serv.sin_port), serv.sin_addr);
        !           133: +      }
        !           134: +
        !           135: +      if (connect(socketid, (struct sockaddr *)&serv, sizeof(serv)) == -1) {
        !           136: +              fprintf(stderr, "cannot connect\n");
        !           137: +              return (-1);
        !           138: +      }
        !           139: +
        !           140: +      if (!Quiet)
        !           141: +              fprintf(stderr, "connected.\n");
        !           142: +
        !           143: +      return(socketid);
        !           144: +}
        !           145: +
        !           146: +int
        !           147: +socketOpen(serverName, portNumber)
        !           148: +      char *serverName;
        !           149: +      int portNumber;
        !           150: +{
        !           151: +      static struct hostent *servhost;
        !           152: +      static struct sockaddr_in serv;
        !           153: +      static int s_wait;
        !           154: +      static int on;
        !           155: +      extern int errno;
        !           156: +      int tt;
        !           157: +
        !           158: +      fprintf(stderr, "Hello from open. serverName is %s "
        !           159: +                          "and portNumber is %d\n", serverName, portNumber);
        !           160: +
        !           161: +      if ((servhost = gethostbyname(serverName)) == NULL) {
        !           162: +              fprintf(stderr, "Bad server name.\n");
        !           163: +              return (-1);
        !           164: +      }
        !           165: +
        !           166: +      bzero((void *)&serv, sizeof(serv));
        !           167: +      serv.sin_family = AF_INET;
        !           168: +      serv.sin_port = htons(portNumber);
        !           169: +      bcopy(servhost->h_addr, &serv.sin_addr, servhost->h_length);
        !           170: +
        !           171: +      if ((s_wait = socket(AF_INET,SOCK_STREAM, 0)) < 0) {
        !           172: +              fprintf(stderr, "Socket allocation is failed.\n");
        !           173: +              return (-1);
        !           174: +      }
        !           175: +
        !           176: +      on = 1;
        !           177: +      setsockopt(s_wait, SOL_SOCKET,SO_REUSEADDR, &on, sizeof(on));
        !           178: +
        !           179: +      /* important */
        !           180: +      if ((tt = bind(s_wait, (struct sockaddr *)&serv, sizeof(serv))) == -1) {
        !           181: +              fprintf(stderr, "bind error. Error no is %d. "
        !           182: +                                  "See /usr/include/sys/errno.h. "
        !           183: +                                  "(asm/errno.h)\n", errno);
        !           184: +              fprintf(stderr, "cannot bind\n");
        !           185: +              return (-1);
        !           186: +      }
        !           187: +
        !           188: +#if 0 /* XXX */
        !           189: +      printf("bind returns %d\n", tt);
        !           190: +#endif
        !           191: +
        !           192: +      tt = sizeof(serv);
        !           193: +      if (getsockname(s_wait, (struct sockaddr *)&serv, &tt) < 0) {
        !           194: +              fprintf(stderr, "getsockname error. Error no is %d. "
        !           195: +                                  "See /usr/include/sys/errno.h "
        !           196: +                                  "(asm/errno.h).\n", errno);
        !           197: +              fprintf(stderr, "cannot getsockname\n");
        !           198: +              return (-1);
        !           199: +      }
        !           200: +
        !           201: +      if (listen(s_wait, 1) < 0) {
        !           202: +              fprintf(stderr, "Listen failed\n");
        !           203: +              return (-1);
        !           204: +      }
        !           205: +
        !           206: +      fprintf(stderr, "Done the initialization. "
        !           207: +                          "port =%d\n", ntohs(serv.sin_port));
        !           208: +      OpenedSocket = ntohs(serv.sin_port);
        !           209: +
        !           210: +      return (s_wait);
        !           211: +}
        !           212: +
        !           213: +int
        !           214: +socketAccept(snum)
        !           215: +      int snum;
        !           216: +{
        !           217: +      int s, news;
        !           218: +
        !           219: +      s = snum;
        !           220: +
        !           221: +      fprintf(stderr, "Trying to accept... ");
        !           222: +      fflush(stderr);
        !           223: +
        !           224: +      if ((news = accept(s, NULL, NULL)) < 0) {
        !           225: +              fprintf(stderr, "Error in accept.\n");
        !           226: +              return (-1);
        !           227: +      }
        !           228: +
        !           229: +      fprintf(stderr, "Accepted.\n");
        !           230: +      fflush(stderr);
        !           231: +
        !           232: +      if (close(s) < 0) {
        !           233: +              fprintf(stderr, "Error in closing the old socket.\n");
        !           234: +              return (-1);
        !           235: +      }
        !           236: +
        !           237: +      return(news);
        !           238: +}
        !           239: +
        !           240: +int
        !           241: +oxSocketSelect0(fd, t)
        !           242: +      int fd, t;
        !           243: +{
        !           244: +      fd_set readfds;
        !           245: +      struct timeval timeout;
        !           246: +      int debug = 0;
        !           247: +      extern int errno;
        !           248: +
        !           249: +      FD_ZERO(&readfds);
        !           250: +      FD_SET(fd, &readfds);
        !           251: +      timeout.tv_sec = 0;
        !           252: +      timeout.tv_usec = (long)t;
        !           253: +
        !           254: +      if (t >= 0) {
        !           255: +              if (debug) {
        !           256: +                      printf("select t >= 0 for fd = %d\n", fd);
        !           257: +                      fflush(NULL);
        !           258: +              }
        !           259: +
        !           260: +              /* It must be fd + 1!, Not fd. */
        !           261: +              if (select(fd + 1, &readfds, NULL, NULL, &timeout) < 0) {
        !           262: +                      fprintf(stderr, "select (non-block) error. "
        !           263: +                                          "Error no is %d. "
        !           264: +                                          "See /usr/include/sys/errno.h "
        !           265: +                                          "(asm/errno.h).\n", errno);
        !           266: +                      fprintf(stderr, "oxSocketSelect0() : select failed.\n");
        !           267: +                      return (0);
        !           268: +              }
        !           269: +
        !           270: +              if (debug) {
        !           271: +                      printf("Return from select t >= 0 for fd = %d\n", fd);
        !           272: +                      fflush(NULL);
        !           273: +              }
        !           274: +      } else {
        !           275: +              /* block */
        !           276: +              if (select(fd + 1, &readfds, NULL, NULL, NULL) < 0) {
        !           277: +                      fprintf(stderr, "select (block) error. "
        !           278: +                                          "Error no is %d. "
        !           279: +                                          "See /usr/include/sys/errno.h "
        !           280: +                                          "(asm/errno.h).\n", errno);
        !           281: +                      fprintf(stderr, "socketSelect0() : select failed.\n");
        !           282: +                      return (0);
        !           283: +              }
        !           284: +      }
        !           285: +
        !           286: +      if (FD_ISSET(fd, &readfds)) {
        !           287: +              return(1);
        !           288: +      } else {
        !           289: +              return(0);
        !           290: +      }
        !           291: +}
        !           292: +
        !           293: +int
        !           294: +oxSocketMultiSelect(sid, size, t, result)
        !           295: +      int sid[], size, t, result[];
        !           296: +{
        !           297: +      fd_set readfds;
        !           298: +      struct timeval timeout;
        !           299: +      int i, fd, p, isdata = 0;
        !           300: +      extern int errno;
        !           301: +
        !           302: +      FD_ZERO(&readfds);
        !           303: +      timeout.tv_sec = 0;
        !           304: +      timeout.tv_usec = (long)t;
        !           305: +
        !           306: +      fd = 0;
        !           307: +
        !           308: +      for (i = 0 ; i < size ; i++) {
        !           309: +              if (sid[i] >= 0) {
        !           310: +                      p = sid[i];
        !           311: +                      if (p > fd)
        !           312: +                              fd = p;
        !           313: +                      FD_SET(p,&readfds);
        !           314: +#if 0 /* XXX */
        !           315: +                      printf("p = %d, fd=%d", p, fd);
        !           316: +#endif
        !           317: +              }
        !           318: +      }
        !           319: +
        !           320: +#if 0 /* XXX */
        !           321: +      printf("MultiSelect..\n");
        !           322: +      fflush(NULL);
        !           323: +#endif
        !           324: +
        !           325: +      if (t >= 0) {
        !           326: +              /* It must be fd + 1!, Not fd. */
        !           327: +              if (select(fd + 1, &readfds, NULL, NULL, &timeout) < 0) {
        !           328: +                      fprintf(stderr, "Select error. Error no is %d. "
        !           329: +                                          "See /usr/include/sys/errno.h "
        !           330: +                                          "(asm/errno.h).\n", errno);
        !           331: +                      fprintf(stderr, "oxSocketMultiSelect() : "
        !           332: +                                      "select failed.\n");
        !           333: +                      return (0);
        !           334: +              }
        !           335: +      } else {
        !           336: +              /* block */
        !           337: +              if (select(fd + 1, &readfds, NULL, NULL, NULL) < 0) {
        !           338: +                      fprintf(stderr, "Select error. Error no is %d. "
        !           339: +                                          "See /usr/include/sys/errno.h "
        !           340: +                                          "(asm/errno.h).\n", errno);
        !           341: +                      fprintf(stderr, "oxSocketMultiSelect() : "
        !           342: +                                      "(block) select failed.\n");
        !           343: +                      return (0);
        !           344: +              }
        !           345: +      }
        !           346: +
        !           347: +#if 0 /* XXX */
        !           348: +      printf("Done. MultiSelect.\n");
        !           349: +      fflush(NULL);
        !           350: +#endif
        !           351: +
        !           352: +      for (i = 0 ; i < size ; i++) {
        !           353: +              p = sid[i];
        !           354: +              if ((sid[i] >= 0) && FD_ISSET(p, &readfds)) {
        !           355: +                      result[i] = 1;
        !           356: +                      isdata = 1;
        !           357: +              } else {
        !           358: +                      result[i] = 0;
        !           359: +              }
        !           360: +      }
        !           361: +
        !           362: +      return (isdata);
        !           363: +}

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>