[Tux4kids-commits] r1038 - in tuxmath/branches/lan: . server

akash gangil gangil-guest at alioth.debian.org
Fri Jun 12 20:33:49 UTC 2009


Author: gangil-guest
Date: 2009-06-12 20:33:49 +0000 (Fri, 12 Jun 2009)
New Revision: 1038

Added:
   tuxmath/branches/lan/server/transtruct.h
Modified:
   tuxmath/branches/lan/aclocal.m4
   tuxmath/branches/lan/server/Makefile.am
   tuxmath/branches/lan/server/mathcards.c
   tuxmath/branches/lan/server/mathcards.h
   tuxmath/branches/lan/server/server.c
   tuxmath/branches/lan/server/testclient.c
Log:
seperating transferring data structs

Modified: tuxmath/branches/lan/aclocal.m4
===================================================================
--- tuxmath/branches/lan/aclocal.m4	2009-06-12 12:19:21 UTC (rev 1037)
+++ tuxmath/branches/lan/aclocal.m4	2009-06-12 20:33:49 UTC (rev 1038)
@@ -1,4 +1,4 @@
-# generated automatically by aclocal 1.10.2 -*- Autoconf -*-
+# generated automatically by aclocal 1.10.1 -*- Autoconf -*-
 
 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
 # 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
@@ -13,8 +13,8 @@
 
 m4_ifndef([AC_AUTOCONF_VERSION],
   [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
-m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.63],,
-[m4_warning([this file was generated for autoconf 2.63.
+m4_if(AC_AUTOCONF_VERSION, [2.61],,
+[m4_warning([this file was generated for autoconf 2.61.
 You have another version of autoconf.  It may work, but is not guaranteed to.
 If you have problems, you may need to regenerate the build system entirely.
 To do so, use the procedure documented by the package, typically `autoreconf'.])])
@@ -177,7 +177,7 @@
 fi[]dnl
 ])# PKG_CHECK_MODULES
 
-# Copyright (C) 2002, 2003, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
+# Copyright (C) 2002, 2003, 2005, 2006, 2007  Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -192,7 +192,7 @@
 [am__api_version='1.10'
 dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
 dnl require some minimum version.  Point them to the right macro.
-m4_if([$1], [1.10.2], [],
+m4_if([$1], [1.10.1], [],
       [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
 ])
 
@@ -206,12 +206,12 @@
 # AM_SET_CURRENT_AUTOMAKE_VERSION
 # -------------------------------
 # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
-# This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
+# This function is AC_REQUIREd by AC_INIT_AUTOMAKE.
 AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
-[AM_AUTOMAKE_VERSION([1.10.2])dnl
+[AM_AUTOMAKE_VERSION([1.10.1])dnl
 m4_ifndef([AC_AUTOCONF_VERSION],
   [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
-_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
+_AM_AUTOCONF_VERSION(AC_AUTOCONF_VERSION)])
 
 # AM_AUX_DIR_EXPAND                                         -*- Autoconf -*-
 
@@ -461,28 +461,19 @@
 
 # Generate code to set up dependency tracking.              -*- Autoconf -*-
 
-# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008
+# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005
 # Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-#serial 4
+#serial 3
 
 # _AM_OUTPUT_DEPENDENCY_COMMANDS
 # ------------------------------
 AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
-[# Autoconf 2.62 quotes --file arguments for eval, but not when files
-# are listed without --file.  Let's play safe and only enable the eval
-# if we detect the quoting.
-case $CONFIG_FILES in
-*\'*) eval set x "$CONFIG_FILES" ;;
-*)   set x $CONFIG_FILES ;;
-esac
-shift
-for mf
-do
+[for mf in $CONFIG_FILES; do
   # Strip MF so we end up with the name of the file.
   mf=`echo "$mf" | sed -e 's/:.*$//'`
   # Check whether this is an Automake generated Makefile or not.
@@ -814,13 +805,13 @@
 
 # Helper functions for option handling.                     -*- Autoconf -*-
 
-# Copyright (C) 2001, 2002, 2003, 2005, 2008  Free Software Foundation, Inc.
+# Copyright (C) 2001, 2002, 2003, 2005  Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-# serial 4
+# serial 3
 
 # _AM_MANGLE_OPTION(NAME)
 # -----------------------
@@ -837,7 +828,7 @@
 # ----------------------------------
 # OPTIONS is a space-separated list of Automake options.
 AC_DEFUN([_AM_SET_OPTIONS],
-[m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])])
+[AC_FOREACH([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])])
 
 # _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET])
 # -------------------------------------------

Modified: tuxmath/branches/lan/server/Makefile.am
===================================================================
--- tuxmath/branches/lan/server/Makefile.am	2009-06-12 12:19:21 UTC (rev 1037)
+++ tuxmath/branches/lan/server/Makefile.am	2009-06-12 20:33:49 UTC (rev 1038)
@@ -3,7 +3,7 @@
 
 bin_PROGRAMS = tuxmathserver tuxmathtestclient
 
-tuxmathserver_SOURCES = server.c mathcards.c
+tuxmathserver_SOURCES = server.c mathcards.c 
 tuxmathtestclient_SOURCES = testclient.c
 
 EXTRA_DIST = mathcards.h

Modified: tuxmath/branches/lan/server/mathcards.c
===================================================================
--- tuxmath/branches/lan/server/mathcards.c	2009-06-12 12:19:21 UTC (rev 1037)
+++ tuxmath/branches/lan/server/mathcards.c	2009-06-12 20:33:49 UTC (rev 1038)
@@ -22,9 +22,10 @@
 #include <math.h>
 #include <time.h>
 
+
+#include "transtruct.h"
 #include "mathcards.h"
 
-
 /* extern'd constants */
 
 const char* const MC_OPTION_TEXT[NOPTS+1] = {

Modified: tuxmath/branches/lan/server/mathcards.h
===================================================================
--- tuxmath/branches/lan/server/mathcards.h	2009-06-12 12:19:21 UTC (rev 1037)
+++ tuxmath/branches/lan/server/mathcards.h	2009-06-12 20:33:49 UTC (rev 1038)
@@ -22,7 +22,6 @@
 #define mcdprintf(...) 0
 #endif
 
-#define MC_USE_NEWARC
 
 /* different classes of problems TuxMath will ask */
 typedef enum _MC_ProblemType {
@@ -151,27 +150,8 @@
   int iopts[NOPTS];
 } MC_Options;
 
-#ifndef MC_USE_NEWARC
-/* struct for individual "flashcard" */
-typedef struct MC_FlashCard {
-  int num1;
-  int num2;
-  int num3;
-  int operation;
-  int format;
-  char formula_string[MC_FORMULA_LEN];
-  char answer_string[MC_ANSWER_LEN];
-} MC_FlashCard;
-#else
-/* experimental struct for a more generalized flashcard */
-typedef struct _MC_FlashCard {
-  char* formula_string;
-  char* answer_string;
-  int answer;
-  int difficulty;
-} MC_FlashCard;
-#endif
 
+
 /* struct for node in math "flashcard" list */
 typedef struct MC_MathQuestion {
   MC_FlashCard card;

Modified: tuxmath/branches/lan/server/server.c
===================================================================
--- tuxmath/branches/lan/server/server.c	2009-06-12 12:19:21 UTC (rev 1037)
+++ tuxmath/branches/lan/server/server.c	2009-06-12 20:33:49 UTC (rev 1038)
@@ -21,13 +21,20 @@
 #include <string.h>
  
 #include "SDL_net.h"
+#include "transtruct.h"
+#include "mathcards.h"
  
+
+TCPsocket sd, csd; /* Socket descriptor, Client socket descriptor */
+
 int main(int argc, char **argv)
 {
-        TCPsocket sd, csd; /* Socket descriptor, Client socket descriptor */
+       
         IPaddress ip, *remoteIP;
         int quit, quit2;
         char buffer[512];
+        char func;
+        MC_FlashCard* fc;
  
         if (SDLNet_Init() < 0)
         {
@@ -36,7 +43,7 @@
         }
  
         /* Resolving the host using NULL make network interface to listen */
-        if (SDLNet_ResolveHost(&ip, NULL, 2000) < 0)
+        if (SDLNet_ResolveHost(&ip, NULL, 2740) < 0)
         {
                 fprintf(stderr, "SDLNet_ResolveHost: %s\n", SDLNet_GetError());
                 exit(EXIT_FAILURE);
@@ -73,8 +80,49 @@
                                 if (SDLNet_TCP_Recv(csd, buffer, 512) > 0)
                                 {
                                         printf("Client say: %s\n", buffer);
+                                        
+                                        //'a' for the setting up the question list                                           
+                                        if(strcmp(buffer,"a")==0)
+                                        {
+                                           func='1';              
+					} 
+                                       
+					//'b' for asking for a question(flashcard)
+                                        if(strcmp(buffer,"b")==0)
+                                        {
+                                           func='2';              
+					} 
  
-                                        if(strcmp(buffer, "exit") == 0) /* Terminate this connection */
+					switch(func)
+ 
+					{
+						case '1':                                                //mainly to setup the question list
+                                                 if (!MC_StartGame())
+						  {
+						    
+						    fprintf(stderr, "\nMC_StartGame() failed!");
+						    return 0;
+						  } 
+  
+						case '2':
+                                                  
+                                                  {
+                                                   if (!MC_NextQuestion(fc))
+                                                   { 
+                                                     /* no more questions available - cannot create comet.  */
+                                                     return 0;
+                                                   }
+                                                     
+                                            //      if(!SendQuestion(fc))
+                                            //       {
+      				            //          printf("Unable to send Question\n");
+     				//		     }
+                                                  }					
+					}
+
+
+
+                                       if(strcmp(buffer, "exit") == 0) /* Terminate this connection */
                                         {
                                                 quit2 = 1;
                                                 printf("Terminate connection\n");
@@ -97,4 +145,41 @@
         SDLNet_Quit();
  
         return EXIT_SUCCESS;
-}
\ No newline at end of file
+}
+
+
+/*                 ********workin on this now*******
+int SendQuestion(MC_FlashCard* fc)                           //function to send a flashcard from the server to the client
+{
+      char *ch;
+
+
+      SDLNet_TCP_Send(csd,fc->formula_string,4);
+      SDLNet_TCP_Recv(csd,ch,1);                                     //will send in the next item only when the first one is receive
+      if(*ch=='1')
+      {
+       SDLNet_TCP_Send(csd,fc->answer_string,4);
+       SDLNet_TCP_Recv(csd,ch,1);
+        if(*ch=='1')
+        { 
+         SDLNet_TCP_Send(csd,&(fc->answer),4);
+	 SDLNet_TCP_Recv(csd,ch,1);
+          if(*ch=='1')
+           {
+            SDLNet_TCP_Send(csd,&(fc->difficulty),4);
+            SDLNet_TCP_Recv(csd,ch,1);
+             if(*ch=='1')
+              {		
+	       return 0;
+              }
+            }
+       }
+    return 1;
+
+}
+*/
+
+
+
+
+

Modified: tuxmath/branches/lan/server/testclient.c
===================================================================
--- tuxmath/branches/lan/server/testclient.c	2009-06-12 12:19:21 UTC (rev 1037)
+++ tuxmath/branches/lan/server/testclient.c	2009-06-12 20:33:49 UTC (rev 1038)
@@ -21,14 +21,16 @@
 #include <string.h>
  
 #include "SDL_net.h"
- 
+#include "transtruct.h"
+
 int main(int argc, char **argv)
 {
         IPaddress ip;           /* Server address */
         TCPsocket sd;           /* Socket descriptor */
         int quit, len;
         char buffer[512];
- 
+        MC_FlashCard* fc;
+     
         /* Simple parameter checking */
         if (argc < 3)
         {
@@ -69,7 +71,12 @@
                         fprintf(stderr, "SDLNet_TCP_Send: %s\n", SDLNet_GetError());
                         exit(EXIT_FAILURE);
                 }
- 
+               /* if(strcmp(buffer,"b")==0)
+		{ 
+                 if(!ReceiveQuestion(fc))
+                 printf("unable to recv question\n"); 
+                } */ 
+
                 if(strcmp(buffer, "exit") == 0)
                         quit = 1;
                 if(strcmp(buffer, "quit") == 0)
@@ -80,4 +87,4 @@
         SDLNet_Quit();
  
         return EXIT_SUCCESS;
-}
\ No newline at end of file
+}

Added: tuxmath/branches/lan/server/transtruct.h
===================================================================
--- tuxmath/branches/lan/server/transtruct.h	                        (rev 0)
+++ tuxmath/branches/lan/server/transtruct.h	2009-06-12 20:33:49 UTC (rev 1038)
@@ -0,0 +1,42 @@
+/*
+
+        transtruct.h
+
+        Description: contains headers for the data structures
+        that would be transferred between the server and the client
+        during the multiplayer LAN game.
+
+        Author: David Bruce ,Akash Gangil and the TuxMath team, (C) 2009
+
+        Copyright: See COPYING file that comes with this distribution (briefly, GNU GPL version 2 or later)
+
+*/
+#ifndef TRANSTRUCT_H
+#define TRANSTRUCT_H
+
+#define MC_USE_NEWARC
+
+
+#ifndef MC_USE_NEWARC
+/* struct for individual "flashcard" */
+typedef struct MC_FlashCard {
+  int num1;
+  int num2;
+  int num3;
+  int operation;
+  int format;
+  char formula_string[MC_FORMULA_LEN];
+  char answer_string[MC_ANSWER_LEN];
+} MC_FlashCard;
+#else
+/* experimental struct for a more generalized flashcard */
+typedef struct _MC_FlashCard {
+  char* formula_string;
+  char* answer_string;
+  int answer;
+  int difficulty;
+} MC_FlashCard;
+#endif
+
+
+#endif




More information about the Tux4kids-commits mailing list