This concerns nettoe-1.1.0-2

I have added an option to specify the server and client ports on the
command line. The default ports (7501, and 7502) are not mentioned in
the man page. I didn't fix that. I have also slightly improved the way
multiple arguments
are handled by the argument parsing function. This patch/diff is below.

I put the altered sources in nettoe-1.1.1 just for my reference, I do
not intend to imply that my changes make a new release. I was not able
to get in touch with the original author.

I am not sure that I generated this patch properly. If not please give
me simple instructions (I know it is not very hard, but it has been
awhile since I have done it) if you would like to use the code. 

diff -p -c nettoe-1.1.0/src/game.h nettoe-1.1.1/src/game.h
*** nettoe-1.1.0/src/game.h     2001-07-21 16:59:10.000000000 -0400
--- nettoe-1.1.1/src/game.h     2007-11-07 02:38:10.000000000 -0500
***************
*** 22,29 ****
  #define AUTHOR_EMAIL "<[EMAIL PROTECTED]>"
  #define RELEASE_DATE "22 July 2001"
  
- #define SERVER_PORT_NUMBER 7501
- #define CLIENT_PORT_NUMBER 7502
  #define MAXDATASIZE 50
  
  #define MAX_PNAME_LEN 15 /* this define max chars for the player
names*/
--- 22,27 ----
***************
*** 31,37 ****
  int NO_BEEP;
  
  int NO_COLORS;
! 
  
  
  
--- 29,36 ----
  int NO_BEEP;
  
  int NO_COLORS;
! extern SERVER_PORT_NUMBER;
! extern CLIENT_PORT_NUMBER;
  
  
  
diff -p -c nettoe-1.1.0/src/misc.c nettoe-1.1.1/src/misc.c
*** nettoe-1.1.0/src/misc.c     2001-07-21 16:59:23.000000000 -0400
--- nettoe-1.1.1/src/misc.c     2007-11-07 02:47:55.000000000 -0500
***************
*** 28,33 ****
--- 28,34 ----
  #include "terminal.h"
  
  
+ 
  int who_start_first (void)
  {
    int generated_number;
*************** void print_infos_screen (void)
*** 101,113 ****
  void parse_cmd_args (int argc, char *argv[])
  {
     int i;
! 
     if (argc < 2)
       return;
  
    for (i = 1; i <= argc - 1; i++)
      {
- 
   if ( (!strcmp(argv[i], "-h")) || (!strcmp(argv[i], "--help")) )
       {
           fprintf(stdout, "netToe %s the enhanced, networked, Tic Tac
Toe game.\n", VERSION);
--- 102,113 ----
  void parse_cmd_args (int argc, char *argv[])
  {
     int i;
!    int nothing = 1;
     if (argc < 2)
       return;
  
    for (i = 1; i <= argc - 1; i++)
      {
   if ( (!strcmp(argv[i], "-h")) || (!strcmp(argv[i], "--help")) )
       {
           fprintf(stdout, "netToe %s the enhanced, networked, Tic Tac
Toe game.\n", VERSION);
*************** void parse_cmd_args (int argc, char *arg
*** 118,123 ****
--- 118,124 ----
         fprintf(stdout, "-nc, --no-colors disable colors\n");
           fprintf(stdout, "-h,  --help      display this help and exit
\n");
           fprintf(stdout, "-v,  --version   output version information
and exit\n");
+          fprintf(stdout, "-p [server] [client],  --port [server]
[client] set port numbers\n");
           fprintf(stdout, "\n");
           fprintf(stdout, "The netToe project can be found at: %s\n",
HOMEPAGE);
           fprintf(stdout, "\n");
*************** void parse_cmd_args (int argc, char *arg
*** 138,163 ****
  
           exit(EXIT_SUCCESS);
      }
- 
    else if ( (!strcmp(argv[i], "-nb"))  || (!strcmp(argv[i],
"--no-beep")) )
      {
         NO_BEEP = 1;
!        return;
      }
    else if ( (!strcmp(argv[i], "-nc"))  || (!strcmp(argv[i],
"--no-colors")) )
      {
         NO_COLORS = 1;
!        return;
      }
  
!   else
      {
         fprintf(stdout, "%s: unrecognized option `%s'\n", argv[0],
argv[i]);
         fprintf(stdout, "Try `%s --help' for more information.\n",
argv[0]);
  
         exit (EXIT_SUCCESS);
      }
!   }
  
    return;
  }
--- 139,176 ----
  
           exit(EXIT_SUCCESS);
      }
    else if ( (!strcmp(argv[i], "-nb"))  || (!strcmp(argv[i],
"--no-beep")) )
      {
         NO_BEEP = 1;
!        nothing = 0;
      }
    else if ( (!strcmp(argv[i], "-nc"))  || (!strcmp(argv[i],
"--no-colors")) )
      {
         NO_COLORS = 1;
!        nothing = 0;
      }
+   else if ( (!strcmp(argv[i], "-p"))  || (!strcmp(argv[i],
"--port")) )
+      {
+       if (argc >= i + 2)
+       {
+       SERVER_PORT_NUMBER = atoi(argv[(++i)]);
+       CLIENT_PORT_NUMBER = atoi(argv[(++i)]);
+       }
+       fprintf(stdout, "Server: %i Client: %i\n", SERVER_PORT_NUMBER,
CLIENT_PORT_NUMBER);
+       nothing = 0;
+      }
+ else {
+       nothing = 1;
+      }
  
!   if (nothing)
      {
         fprintf(stdout, "%s: unrecognized option `%s'\n", argv[0],
argv[i]);
         fprintf(stdout, "Try `%s --help' for more information.\n",
argv[0]);
  
         exit (EXIT_SUCCESS);
      }
!   } /*end for*/
  
    return;
  }
diff -p -c nettoe-1.1.0/src/nettoe.c nettoe-1.1.1/src/nettoe.c
*** nettoe-1.1.0/src/nettoe.c   2001-07-21 16:58:24.000000000 -0400
--- nettoe-1.1.1/src/nettoe.c   2007-11-07 02:37:32.000000000 -0500
***************
*** 29,35 ****
  #include "network.h"
  #include "game.h"
  
! 
  char c11, c12, c13;
  char c21, c22, c23;
  char c31, c32, c33;
--- 29,36 ----
  #include "network.h"
  #include "game.h"
  
! int SERVER_PORT_NUMBER = 7501;
! int CLIENT_PORT_NUMBER = 7502;
  char c11, c12, c13;
  char c21, c22, c23;
  char c31, c32, c33;

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to