*** ./scripts/mkadeonainst.sh.osr6	Sat Oct 11 22:51:12 2008
--- ./scripts/mkadeonainst.sh	Sat Oct 11 22:51:03 2008
***************
*** 0 ****
--- 1,130 ----
+ #!/bin/bash
+ #
+ # Copyright (c) 2007-2008 University of Washington
+ # 
+ # All rights reserved. For information, contact the Adeona research
+ # team at adeona@cs.washington.edu
+ #
+ # See the file License.txt included in this distribution for details.
+ #
+ 
+ ADEONAPREFIX=/usr/local
+ INSTALLDIR=$ADEONAPREFIX/adeona
+ 
+ ADEONARESOURCES=$INSTALLDIR/resources
+ ADEONALOGS=$INSTALLDIR/logs
+ ADEONASCRIPTS=$INSTALLDIR/scripts
+ 
+ #CRONTABFILE=/etc/crontab
+ CRONTABENTRY="@reboot $INSTALLDIR/adeona-client.exe -s $INSTALLDIR/adeona-clientstate.cst -r $ADEONARESOURCES/ -l $ADEONALOGS/ &"
+ 
+ 
+ #####################################################################
+ if [ ! -e './configure' ]; then
+     echo;echo "Please run $0 from the adeona project directory";echo;
+     exit 1;
+ fi
+ 
+ if [ ! -e './config.h' ]; then
+     echo;echo "Please run ./configure to generate config.h";
+     echo "Please make sure there are no errors from the configure script.";echo;
+     exit 1;
+ fi
+ 
+ clear;
+ 
+ #
+ # existing?
+ #
+ if [ -d $INSTALLDIR -a -e $INSTALLDIR/adeona-client.exe ]; then
+     echo; echo "You have an existing installation of Adeona. Would you like to overwrite?";
+     echo;
+     while [ 1 ]; do
+         echo -n "Enter 'y' to overwrite or 'n' to exit installation: "
+         read response;
+         if [ "$response" == "y" ]; then
+             break;
+         elif [ "$response" == "n" ]; then
+             echo; echo "Exiting installation...";
+             exit 0;
+         else
+             echo "Sorry, invalid response"; echo;
+         fi
+     done
+     
+     oldclient=`ps axo pid,command | grep adeona-client.exe | grep -v grep | { read pid dontcare; echo $pid; }`;
+     if [ "$oldclient" != "" ]; then
+         kill -9 $oldclient 2>&1 > /dev/null;
+     fi
+ 
+     rm -rf $INSTALLDIR;
+ 
+ #    OLDCRONENTRY=`grep -n adeona-client.exe $CRONTABFILE | cut -f1 -d:`;
+ #    sed -i -e "$OLDCRONENTRY,$OLDCRONENTRY d" $CRONTABFILE;
+     echo;echo "Your old Adeona installation has been removed";
+     echo "Please make sure to update your crontab entry for adeona-client.exe at the end of the installation.";
+     echo;echo -n "Press any key to continue..."; read;
+ fi
+ 
+ #
+ # license agreement
+ #
+ clear;
+ echo;
+ cat License.txt;
+ echo;
+ while [ 1 ]; do
+     echo -n "Enter 'y' to agree or 'n' to exit the installation: "
+     read response;
+     if [ "$response" == "y" ]; then
+         echo; echo "Starting Adeona installation...";
+         break;
+     elif [ "$response" == "n" ]; then
+         echo; echo "Exiting installation...";
+         exit 0;
+     else
+         echo "Sorry, invalid response"; echo;
+     fi
+ done
+ 
+ #
+ # build 
+ # 
+ if [ ! -e adeona-init.exe -o ! -e adeona-client.exe -o ! -e adeona-retrieve.exe ]; then
+     make RELEASE=1;
+ fi
+ 
+ if [ ! -e adeona-init.exe -o ! -e adeona-client.exe -o ! -e adeona-retrieve.exe ]; then
+     echo "Could not build Adeona programs.";
+     exit 1;
+ fi
+ 
+ #
+ # make directories
+ #
+ if [ ! -d $INSTALLDIR ]; then
+     mkdir $INSTALLDIR;
+     mkdir $ADEONARESOURCES;
+     mkdir $ADEONALOGS;
+     mkdir $ADEONASCRIPTS;
+ fi
+ 
+ if [ ! -d $INSTALLDIR ]; then
+     echo "Could not create installation directory. Please check your permissions.";
+     echo "Try 'sudo make install'";
+     exit 1;
+ fi
+ 
+ #
+ # copy files
+ #
+ mv adeona-init.exe $INSTALLDIR;
+ mv adeona-client.exe $INSTALLDIR;
+ mv adeona-retrieve.exe $INSTALLDIR;
+ 
+ cp resources/gateways.adeona $ADEONARESOURCES;
+ cp resources/landmarks.adeona $ADEONARESOURCES;
+ cp resources/options.adeona $ADEONARESOURCES;
+ 
+ cp Readme.txt $INSTALLDIR;
+ 
*** ./common/getline.c.osr6	Sat Oct 11 21:00:53 2008
--- ./common/getline.c	Sat Oct 11 21:00:53 2008
***************
*** 0 ****
--- 1,174 ----
+ /* getline.c -- Replacement for GNU C library function getline
+ 
+ Copyright (C) 1993 Free Software Foundation, Inc.
+ 
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+ 
+ This program 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
+ General Public License for more details.  */
+ 
+ /* Written by Jan Brittenson, bson@gnu.ai.mit.edu.  */
+ 
+ #ifdef HAVE_CONFIG_H
+ #include <config.h>
+ #endif
+ 
+ #include <sys/types.h>
+ #include <stdio.h>
+ #include <assert.h>
+ #include <errno.h>
+ #include "getline.h"
+ 
+ #if STDC_HEADERS
+ #include <stdlib.h>
+ #else
+ char *malloc (), *realloc ();
+ #endif
+ 
+ /* Always add at least this many bytes when extending the buffer.  */
+ #define MIN_CHUNK 64
+ 
+ /* Read up to (and including) a TERMINATOR from STREAM into *LINEPTR
+    + OFFSET (and null-terminate it).  If LIMIT is non-negative, then
+    read no more than LIMIT chars.
+ 
+    *LINEPTR is a pointer returned from malloc (or NULL), pointing to
+    *N characters of space.  It is realloc'd as necessary.  
+ 
+    Return the number of characters read (not including the null
+    terminator), or -1 on error or EOF.  On a -1 return, the caller
+    should check feof(), if not then errno has been set to indicate the
+    error.  */
+ 
+ int
+ getstr (lineptr, n, stream, terminator, offset, limit)
+      char **lineptr;
+      size_t *n;
+      FILE *stream;
+      int terminator;
+      int offset;
+      int limit;
+ {
+   int nchars_avail;		/* Allocated but unused chars in *LINEPTR.  */
+   char *read_pos;		/* Where we're reading into *LINEPTR. */
+   int ret;
+ 
+   if (!lineptr || !n || !stream)
+     {
+       errno = EINVAL;
+       return -1;
+     }
+ 
+   if (!*lineptr)
+     {
+       *n = MIN_CHUNK;
+       *lineptr = malloc (*n);
+       if (!*lineptr)
+ 	{
+ 	  errno = ENOMEM;
+ 	  return -1;
+ 	}
+       *lineptr[0] = '\0';
+     }
+ 
+   nchars_avail = *n - offset;
+   read_pos = *lineptr + offset;
+ 
+   for (;;)
+     {
+       int save_errno;
+       register int c;
+ 
+       if (limit == 0)
+           break;
+       else
+       {
+           c = getc (stream);
+ 
+           /* If limit is negative, then we shouldn't pay attention to
+              it, so decrement only if positive. */
+           if (limit > 0)
+               limit--;
+       }
+ 
+       save_errno = errno;
+ 
+       /* We always want at least one char left in the buffer, since we
+ 	 always (unless we get an error while reading the first char)
+ 	 NUL-terminate the line buffer.  */
+ 
+       assert((*lineptr + *n) == (read_pos + nchars_avail));
+       if (nchars_avail < 2)
+ 	{
+ 	  if (*n > MIN_CHUNK)
+ 	    *n *= 2;
+ 	  else
+ 	    *n += MIN_CHUNK;
+ 
+ 	  nchars_avail = *n + *lineptr - read_pos;
+ 	  *lineptr = realloc (*lineptr, *n);
+ 	  if (!*lineptr)
+ 	    {
+ 	      errno = ENOMEM;
+ 	      return -1;
+ 	    }
+ 	  read_pos = *n - nchars_avail + *lineptr;
+ 	  assert((*lineptr + *n) == (read_pos + nchars_avail));
+ 	}
+ 
+       if (ferror (stream))
+ 	{
+ 	  /* Might like to return partial line, but there is no
+ 	     place for us to store errno.  And we don't want to just
+ 	     lose errno.  */
+ 	  errno = save_errno;
+ 	  return -1;
+ 	}
+ 
+       if (c == EOF)
+ 	{
+ 	  /* Return partial line, if any.  */
+ 	  if (read_pos == *lineptr)
+ 	    return -1;
+ 	  else
+ 	    break;
+ 	}
+ 
+       *read_pos++ = c;
+       nchars_avail--;
+ 
+       if (c == terminator)
+ 	/* Return the line.  */
+ 	break;
+     }
+ 
+   /* Done - NUL terminate and return the number of chars read.  */
+   *read_pos = '\0';
+ 
+   ret = read_pos - (*lineptr + offset);
+   return ret;
+ }
+ 
+ int
+ getline (lineptr, n, stream)
+      char **lineptr;
+      size_t *n;
+      FILE *stream;
+ {
+   return getstr (lineptr, n, stream, '\n', 0, GETLINE_NO_LIMIT);
+ }
+ 
+ int
+ getline_safe (lineptr, n, stream, limit)
+      char **lineptr;
+      size_t *n;
+      FILE *stream;
+      int limit;
+ {
+   return getstr (lineptr, n, stream, '\n', 0, limit);
+ }
*** ./common/getline.h.osr6	Sat Oct 11 21:00:53 2008
--- ./common/getline.h	Sat Oct 11 21:00:53 2008
***************
*** 0 ****
--- 1,23 ----
+ #ifndef _getline_h_
+ #define _getline_h_ 1
+ 
+ #include <stdio.h>
+ 
+ #if defined (__GNUC__) || (defined (__STDC__) && __STDC__)
+ #define __PROTO(args) args
+ #else
+ #define __PROTO(args) ()
+ #endif  /* GCC.  */
+ 
+ #define GETLINE_NO_LIMIT -1
+ 
+ int
+   getline __PROTO ((char **_lineptr, size_t *_n, FILE *_stream));
+ int
+   getline_safe __PROTO ((char **_lineptr, size_t *_n, FILE *_stream,
+                          int limit));
+ int
+   getstr __PROTO ((char **_lineptr, size_t *_n, FILE *_stream,
+ 		   int _terminator, int _offset, int limit));
+ 
+ #endif /* _getline_h_ */
*** ./location/ipaddress.c.osr6	Sun Jul 13 18:30:54 2008
--- ./location/ipaddress.c	Sat Oct 11 21:00:53 2008
***************
*** 8,15 ****
--- 8,19 ----
   *
   */
  #if !defined( __CYGWIN__ )
+ #if defined(__SCO__)
+     #include <heimdal/roken/ifaddrs.h>
+ #else
      #include <ifaddrs.h>
  #endif
+ #endif
  
  #include <netdb.h>
  #include <arpa/inet.h>
*** ./Makefile.osr6	Sun Jul 13 18:30:55 2008
--- ./Makefile	Sat Oct 11 22:52:31 2008
***************
*** 21,26 ****
--- 21,30 ----
  	PLATFORM := "Linux"
  endif
  
+ ifeq ("SCO_SV", "$(shell uname -s)")
+ 	PLATFORM := "SCO"
+ endif
+ 
  ifeq ("Darwin", "$(shell uname -s)")
  	PLATFORM := "MacOS"
  	MACOSVERSION := 10.4
***************
*** 35,46 ****
--- 39,59 ----
  #
  ## Build options:
  #
+ ifeq ($(PLATFORM), "SCO")
+ ADEONA_BUILD_MODE := "release"
+ ifeq "$(origin RELEASE)" "command line"
+ ifeq "$(RELEASE)" "0"
+ 	ADEONA_BUILD_MODE := "debug"
+ endif
+ endif
+ else
  ADEONA_BUILD_MODE := "debug"
  ifeq "$(origin RELEASE)" "command line"
  ifeq "$(RELEASE)" "1"
  	ADEONA_BUILD_MODE := "release"
  endif
  endif
+ endif
  
  
  CFLAGS := -Wall
***************
*** 51,62 ****
  
  ifeq ($(ADEONA_BUILD_MODE), "debug")
  CFLAGS += -D_ADEONA_BUILD_DEBUG_
! CFLAGS += -ggdb
  else
  CFLAGS += -D_ADEONA_BUILD_RELEASE_
  CFLAGS += -O2
  endif
  
  #
  ## Setup paths:
  #
--- 64,79 ----
  
  ifeq ($(ADEONA_BUILD_MODE), "debug")
  CFLAGS += -D_ADEONA_BUILD_DEBUG_
! CFLAGS += -g
  else
  CFLAGS += -D_ADEONA_BUILD_RELEASE_
  CFLAGS += -O2
  endif
  
+ ifeq ($(PLATFORM), "SCO")
+ CFLAGS += -D__SCO__
+ endif
+ 
  #
  ## Setup paths:
  #
***************
*** 79,84 ****
--- 96,105 ----
  	LIBS += -lrpc
  endif
  
+ ifeq ($(PLATFORM), "SCO")
+ 	LIBS += -lroken
+ endif
+ 
  #
  ## Finders
  #
***************
*** 234,240 ****
--- 255,265 ----
  	$(NSIS_EXE) $(WIN_REL_PATH)/adeonainstaller.nsi
  
  install :
+ ifeq ($(PLATFORM), "SCO")
+ 	$(SCRIPTS_DIR)/mkadeonainst.sh
+ else
  	$(SCRIPTS_DIR)/installadeona.sh
+ endif
  
  $(CLNT_EXE) : $(ALL_RPC) $(CLNT_OBJ)
  	$(GCC) $(CFLAGS) $(CLNT_OBJ) $(LIBS) -o $(CLNT_EXE)
