tcptrace-bugs Modified Xplot for OpenBSD 2.9

From: kfl (kfl@xiphos.ca)
Date: 07/08/02


From: "kfl" <kfl@xiphos.ca>
Subject: tcptrace-bugs Modified Xplot for OpenBSD 2.9
Date: Mon, 8 Jul 2002 12:22:19 -0400
Message-ID: <JCEDLMKGMLLELHAJNIHJIEJLCPAA.kfl@xiphos.ca>


Hi,

        There is a problem with the modified xplot in OpenBSD 2.9. The problem
is in timeval.c where the timezone stuff is different then in FreeBSD.
Anyway, when building it here is what I got (with the patch for it, also in
attatchement):

bash-2.04# ./configure
creating cache ./config.cache
checking for gcc... gcc
checking whether the C compiler (gcc ) works... yes
checking whether the C compiler (gcc ) is a cross-compiler... no
checking whether we are using GNU C... yes
checking whether gcc accepts -g... yes
checking for a BSD compatible install... /usr/bin/install -c
checking how to run the C preprocessor... gcc -E
checking for X... libraries /usr/X11R6/lib, headers /usr/X11R6/include
checking for dnet_ntoa in -ldnet... no
checking for dnet_ntoa in -ldnet_stub... no
checking for gethostbyname... yes
checking for connect... yes
checking for remove... yes
checking for shmat... yes
checking for IceConnectionNumber in -lICE... yes
checking for main in -lX11... yes
checking for main in -lm... yes
checking for inline... inline
checking for ANSI C header files... yes
checking whether time.h and sys/time.h may both be included... yes
checking whether struct tm is in sys/time.h or time.h... time.h
checking whether struct tm has tm_gmtoff... yes
checking has altzone in time.h... no
updating cache ./config.cache
creating ./config.status
creating Makefile
creating config.h

bash-2.04# make
gcc -g -O2 -Wall -I/usr/X11R6/include -DTCPTRACE -DHAVE_CONFIG_H -c
xplot.c
echo 'char *version_string = "'`cat version`'";' >version_string.c
gcc -g -O2 -Wall -I/usr/X11R6/include -DTCPTRACE -DHAVE_CONFIG_H -c
version_string.c
gcc -g -O2 -Wall -I/usr/X11R6/include -DTCPTRACE -DHAVE_CONFIG_H -c
coord.c
gcc -g -O2 -Wall -I/usr/X11R6/include -DTCPTRACE -DHAVE_CONFIG_H -c
unsigned.c
In file included from unsigned.c:34:
/usr/include/malloc.h:4: warning: #warning "<malloc.h> is obsolete, use
<stdlib.h>"
gcc -g -O2 -Wall -I/usr/X11R6/include -DTCPTRACE -DHAVE_CONFIG_H -c
signed.c
In file included from signed.c:34:
/usr/include/malloc.h:4: warning: #warning "<malloc.h> is obsolete, use
<stdlib.h>"
gcc -g -O2 -Wall -I/usr/X11R6/include -DTCPTRACE -DHAVE_CONFIG_H -c
timeval.c
In file included from timeval.c:34:
/usr/include/malloc.h:4: warning: #warning "<malloc.h> is obsolete, use
<stdlib.h>"
timeval.c:39: `timezone' redeclared as different kind of symbol
/usr/include/time.h:116: previous declaration of `timezone'
*** Error code 1

Then the patch:

bash-2.04$ cat OBSD_xplot.patch
*** ../../xplot/timeval.c Fri Jul 5 16:04:52 2002
--- timeval.c Wed Apr 24 18:11:34 2002
***************
*** 28,53 ****
  NOT be used in advertising or publicity pertaining to distribution of
  the software. Title to copyright in this software and any associated
  documentation shall at all times remain with M.I.T., and USER agrees
  to preserve same.
  */
  #include <math.h>
  #include <malloc.h>
  #include <stdio.h>
  #include <ctype.h>
  #include "xplot.h"
!
! extern time_t timezone;
! #ifdef HAS_ALTZONE
! extern time_t altzone;
! #else
! #define altzone (timezone - 3600)
! #endif
!
! extern int daylight;
! extern char *tzname[2];
!

  inline static
  void
  timeval_fix(coord *r)
  {
--- 28,44 ----
  NOT be used in advertising or publicity pertaining to distribution of
  the software. Title to copyright in this software and any associated
  documentation shall at all times remain with M.I.T., and USER agrees
  to preserve same.
  */
+ #include <X11/Xos.h>
  #include <math.h>
  #include <malloc.h>
  #include <stdio.h>
  #include <ctype.h>
  #include "xplot.h"
! #include "coord.h"

  inline static
  void
  timeval_fix(coord *r)
  {
***************
*** 178,236 ****

  coord timeval_round_down(coord c1, coord c2)
  {
    coord r;
    struct tm *tmp;
- time_t gmtoff;

    tmp = localtime((time_t *) &(c1.t.tv_sec));
  #ifdef TM_GMTOFF
    c1.t.tv_sec += tmp->tm_gmtoff;
  #endif
- if (tmp->tm_isdst==0) {
- gmtoff = -timezone;
- } else if (tmp->tm_isdst==1) {
- gmtoff = -altzone;
- } else {
- gmtoff = 0;
- }
- c1.t.tv_sec += gmtoff;

    if (c2.t.tv_sec == 0) {
      r.t.tv_sec = c1.t.tv_sec;
      r.t.tv_usec = (c1.t.tv_usec - (c1.t.tv_usec % c2.t.tv_usec));
    } else {
      r.t.tv_usec = 0;
      r.t.tv_sec = c1.t.tv_sec - (c1.t.tv_sec % c2.t.tv_sec);
    }

! r.t.tv_sec -= gmtoff;

    timeval_fix(&r);
    return r;
  }

  coord timeval_round_up(coord c1, coord c2)
  {
    coord r;
    struct tm *tmp;
- time_t gmtoff;

    tmp = localtime((time_t *) &(c1.t.tv_sec));

  #ifdef TM_GMTOFF
    c1.t.tv_sec += tmp->tm_gmtoff;
  #endif
- if (tmp->tm_isdst==0) {
- gmtoff = -timezone;
- } else if (tmp->tm_isdst==1) {
- gmtoff = -altzone;
- } else {
- gmtoff = 0;
- }
- c1.t.tv_sec += gmtoff;

    if (c2.t.tv_sec == 0) {
      r.t.tv_sec = c1.t.tv_sec;
      if (c1.t.tv_usec % c2.t.tv_usec == 0)
        r.t.tv_usec = c1.t.tv_usec;
--- 169,212 ----

  coord timeval_round_down(coord c1, coord c2)
  {
    coord r;
    struct tm *tmp;

    tmp = localtime((time_t *) &(c1.t.tv_sec));
+
  #ifdef TM_GMTOFF
    c1.t.tv_sec += tmp->tm_gmtoff;
  #endif

    if (c2.t.tv_sec == 0) {
      r.t.tv_sec = c1.t.tv_sec;
      r.t.tv_usec = (c1.t.tv_usec - (c1.t.tv_usec % c2.t.tv_usec));
    } else {
      r.t.tv_usec = 0;
      r.t.tv_sec = c1.t.tv_sec - (c1.t.tv_sec % c2.t.tv_sec);
    }

! #ifdef TM_GMTOFF
! r.t.tv_sec -= tmp->tm_gmtoff;
! #endif

    timeval_fix(&r);
    return r;
  }

  coord timeval_round_up(coord c1, coord c2)
  {
    coord r;
    struct tm *tmp;

    tmp = localtime((time_t *) &(c1.t.tv_sec));

  #ifdef TM_GMTOFF
    c1.t.tv_sec += tmp->tm_gmtoff;
  #endif

    if (c2.t.tv_sec == 0) {
      r.t.tv_sec = c1.t.tv_sec;
      if (c1.t.tv_usec % c2.t.tv_usec == 0)
        r.t.tv_usec = c1.t.tv_usec;
***************
*** 248,258 ****
        r.t.tv_sec = c1.t.tv_sec;
      else
        r.t.tv_sec = c1.t.tv_sec + (c2.t.tv_sec - (c1.t.tv_sec %
c2.t.tv_sec));
    }

! r.t.tv_sec -= gmtoff;

    timeval_fix(&r);
    return r;

  #if 0
--- 224,236 ----
        r.t.tv_sec = c1.t.tv_sec;
      else
        r.t.tv_sec = c1.t.tv_sec + (c2.t.tv_sec - (c1.t.tv_sec %
c2.t.tv_sec));
    }

! #ifdef TM_GMTOFF
! r.t.tv_sec -= tmp->tm_gmtoff;
! #endif

    timeval_fix(&r);
    return r;

  #if 0
***************
*** 323,333 ****
  };

  coord timeval_tick(int level)
  {
    coord r;
! extern void ianic();

    if (level < 0 || level >= sizeof(tick_table) / sizeof(struct
tick_table_s))
      panic("timeval_tick: level too large");

--- 301,311 ----
  };

  coord timeval_tick(int level)
  {
    coord r;
! extern void panic();

    if (level < 0 || level >= sizeof(tick_table) / sizeof(struct
tick_table_s))
      panic("timeval_tick: level too large");

I'm sure there is a more elegant way for correcting this but I didn't had
time to figure it out. It does the trick for me anyway ;)

Enjoy,

Karim.





This archive was generated by hypermail 2b30 : 07/09/02 EDT