gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r6286 - GNUnet/src/applications/chat


From: gnunet
Subject: [GNUnet-SVN] r6286 - GNUnet/src/applications/chat
Date: Wed, 13 Feb 2008 14:34:43 -0700 (MST)

Author: nevans
Date: 2008-02-13 14:34:43 -0700 (Wed, 13 Feb 2008)
New Revision: 6286

Modified:
   GNUnet/src/applications/chat/gnunet-chat.c
Log:


Modified: GNUnet/src/applications/chat/gnunet-chat.c
===================================================================
--- GNUnet/src/applications/chat/gnunet-chat.c  2008-02-13 21:33:40 UTC (rev 
6285)
+++ GNUnet/src/applications/chat/gnunet-chat.c  2008-02-13 21:34:43 UTC (rev 
6286)
@@ -46,7 +46,7 @@
  * All gnunet-chat command line options
  */
 static struct GNUNET_CommandLineOption gnunetchatOptions[] = {
-  GNUNET_COMMAND_LINE_OPTION_HELP (gettext_noop ("Join a chat on GNUnet.")),   
 /* -h */
+  GNUNET_COMMAND_LINE_OPTION_HELP (gettext_noop ("Join a chat on GNUnet.")),   
/* -h */
   GNUNET_COMMAND_LINE_OPTION_HOSTNAME,  /* -H */
   GNUNET_COMMAND_LINE_OPTION_LOGGING,   /* -L */
   {'n', "nick", "NAME",
@@ -55,13 +55,13 @@
   {'r', "room", "NAME",
    gettext_noop ("set the chat room to join (requred)"),
    1, &GNUNET_getopt_configure_set_string, &room_name},
-  GNUNET_COMMAND_LINE_OPTION_VERSION (PACKAGE_VERSION), /* -v */
+  GNUNET_COMMAND_LINE_OPTION_VERSION (PACKAGE_VERSION),        /* -v */
   GNUNET_COMMAND_LINE_OPTION_VERBOSE,
   GNUNET_COMMAND_LINE_OPTION_END,
 };
 
 /**
- * A message was send in the chat to us.
+ * A message was sent in the chat to us.
  *
  * @param timestamp when was the message sent?
  * @param senderNick what is the nickname of the sender? (maybe NULL)
@@ -124,23 +124,27 @@
 main (int argc, char **argv)
 {
   struct GNUNET_CHAT_Room *room;
-  GNUNET_RSA_PublicKey *my_pub;
+  
   struct GNUNET_RSA_PrivateKey *my_priv;
+  GNUNET_RSA_PublicKey my_pub;
+  
   char *message;
-
-  my_pub = NULL;
+  int ret = GNUNET_OK;
+  
+  GNUNET_disable_entropy_gathering();
+  
+  fprintf(stderr,"Generating public/private key pair\n");
   my_priv = GNUNET_RSA_create_key ();
-  GNUNET_RSA_get_public_key (my_priv, my_pub);
+  GNUNET_RSA_get_public_key(my_priv,&my_pub); 
+  message = GNUNET_malloc(MAX_MESSAGE_LENGTH+1);
+  
 
-  message = GNUNET_malloc (MAX_MESSAGE_LENGTH + 1);
-  int ret = GNUNET_OK;
-
   if (GNUNET_SYSERR == GNUNET_init (argc,
                                     argv,
                                     "gnunet-chat [OPTIONS]",
                                     &cfgFilename, gnunetchatOptions, &ectx,
                                     &cfg))
-    ret = GNUNET_SYSERR;        /* parse error, --help, etc. */
+    ret = GNUNET_SYSERR;                   /* parse error, --help, etc. */
   if (nickname == NULL)
     {
       fprintf (stderr, _("You must specify a nickname\n"));
@@ -149,28 +153,34 @@
 
   room = GNUNET_CHAT_join_room (ectx,
                                 cfg,
-                                nickname, room_name,
-                                my_pub, my_priv, "", &receive_callback, NULL);
+                                nickname,room_name,
+                                &my_pub, my_priv, "", &receive_callback, NULL);
   if (room == NULL)
     {
       fprintf (stderr, _("Failed to join the room\n"));
       ret = GNUNET_SYSERR;
     }
+  else
+  {
+       fprintf(stdout,"Room joined, type message and hit return to send.\nType 
quit when ready to quit\n");
+  }
 
   /* read messages from command line and send */
-  while ((ret == GNUNET_OK) && (strcmp (message, quit) != 0))
+  while ((ret == GNUNET_OK)&&(strcmp(message,quit)!=0))
     {
-
-      bzero (message, MAX_MESSAGE_LENGTH + 1);
+        
+      bzero(message, MAX_MESSAGE_LENGTH+1);
       if (NULL == fgets (message, MAX_MESSAGE_LENGTH, stdin))
         break;
-      else if (strncmp (message, quit, sizeof (quit)) == 0)
+      else if (strncmp(message,quit,sizeof(quit))==0)
         break;
       else
-        {
-          if (message[strlen (message) - 1] == '\n')
-            message[strlen (message) - 1] = '\0';
-        }
+      {
+       if(message[strlen(message)-1] == '\n')
+         message[strlen(message)-1] = '\0';
+      }
+      fprintf(stderr,"quit: %s message: %s\n",quit,message);
+      
       if (GNUNET_OK != GNUNET_CHAT_send_message (room,
                                                  message,
                                                  &confirmation_callback,
@@ -180,13 +190,13 @@
         {
           fprintf (stderr, _("Failed to send message.\n"));
         }
-
+        
     }
-
-
+    
+  
   GNUNET_CHAT_leave_room (room);
-  GNUNET_free (room);
-  GNUNET_free (message);
+  GNUNET_free(room);
+  GNUNET_free(message);
   GNUNET_fini (ectx, cfg);
   return GNUNET_OK;
 }





reply via email to

[Prev in Thread] Current Thread [Next in Thread]