[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r6184 - GNUnet/src/applications/chat
From: |
gnunet |
Subject: |
[GNUnet-SVN] r6184 - GNUnet/src/applications/chat |
Date: |
Thu, 7 Feb 2008 00:00:21 -0700 (MST) |
Author: nevans
Date: 2008-02-07 00:00:20 -0700 (Thu, 07 Feb 2008)
New Revision: 6184
Modified:
GNUnet/src/applications/chat/clientapi.c
GNUnet/src/applications/chat/gnunet-chat.c
Log:
Modified: GNUnet/src/applications/chat/clientapi.c
===================================================================
--- GNUnet/src/applications/chat/clientapi.c 2008-02-07 06:33:05 UTC (rev
6183)
+++ GNUnet/src/applications/chat/clientapi.c 2008-02-07 07:00:20 UTC (rev
6184)
@@ -121,7 +121,12 @@
}
chat_msg = GNUNET_malloc (sizeof (CS_chat_MESSAGE));
+<<<<<<< .mine
+ GNUNET_free(chat_msg);
+
+=======
+>>>>>>> .r6183
// connect
// allocate & init room struct
@@ -151,11 +156,16 @@
* Leave a chat room.
*/
void
-GNUNET_CHAT_leave_room (struct GNUNET_CHAT_Room *room)
+GNUNET_CHAT_leave_room (struct GNUNET_CHAT_Room *chat_room)
{
// stop thread
// join thread
- // free room struct
+ // free room struct
+
+ GNUNET_free(chat_room->nickname);
+ GNUNET_free(chat_room->memberInfo);
+ GNUNET_client_connection_destroy(chat_room->sock);
+
}
/**
@@ -172,7 +182,24 @@
GNUNET_CHAT_MSG_OPTIONS options,
const GNUNET_RSA_PublicKey * receiver)
{
- return GNUNET_SYSERR;
+ int ret = GNUNET_OK;
+ GNUNET_MessageHeader cs_msg_hdr;
+ CS_chat_MESSAGE *msg_to_send;
+
+ msg_to_send = GNUNET_malloc(sizeof(CS_chat_MESSAGE));
+
+ cs_msg_hdr.size = htons (sizeof (GNUNET_MessageHeader));
+ cs_msg_hdr.type = htons (GNUNET_CS_PROTO_CHAT_MSG);
+ msg_to_send->header = cs_msg_hdr;
+
+ if (GNUNET_SYSERR == GNUNET_client_connection_write (room->sock,
(GNUNET_MessageHeader *)&msg_to_send))
+ {
+ fprintf (stderr, _("Error writing to socket.\n"));
+ ret = GNUNET_SYSERR;
+ }
+
+
+ return ret;
}
/**
Modified: GNUnet/src/applications/chat/gnunet-chat.c
===================================================================
--- GNUnet/src/applications/chat/gnunet-chat.c 2008-02-07 06:33:05 UTC (rev
6183)
+++ GNUnet/src/applications/chat/gnunet-chat.c 2008-02-07 07:00:20 UTC (rev
6184)
@@ -29,6 +29,7 @@
#include "gnunet_directories.h"
#include "gnunet_chat_lib.h"
+static const int MAX_MESSAGE_LENGTH = 1024;
static struct GNUNET_GC_Configuration *cfg;
static struct GNUNET_GE_Context *ectx;
@@ -39,6 +40,8 @@
static char *roomname = "gnunet";
+static char *quit = "quit";
+
/**
* All gnunet-chat command line options
*/
@@ -124,7 +127,13 @@
struct GNUNET_CHAT_Room *room;
GNUNET_RSA_PublicKey *my_pub;
struct GNUNET_RSA_PrivateKey *my_priv;
- char message[1024];
+ char *message;
+ /*char *quit;
+
+ quit = GNUNET_malloc(sizeof("quit")+1);
+ quit = strdup("quit");*/
+ message = GNUNET_malloc(MAX_MESSAGE_LENGTH+1);
+
int ret = GNUNET_OK;
if (GNUNET_SYSERR == GNUNET_init (argc,
@@ -150,11 +159,19 @@
}
/* read messages from command line and send */
- while (ret == GNUNET_OK)
+ while ((ret == GNUNET_OK)&&(strcmp(message,quit)!=0))
{
- memset (message, 0, 1024);
- if (NULL == fgets (message, 1023, stdin))
+
+ bzero(message, MAX_MESSAGE_LENGTH+1);
+ if (NULL == fgets (message, MAX_MESSAGE_LENGTH, stdin))
break;
+ else if (strncmp(message,quit,sizeof(quit))==0)
+ break;
+ else
+ {
+ if(message[strlen(message)-1] == '\n')
+ message[strlen(message)-1] = '\0';
+ }
if (GNUNET_OK != GNUNET_CHAT_send_message (room,
message,
&confirmation_callback,
@@ -164,8 +181,13 @@
{
fprintf (stderr, _("Failed to send message.\n"));
}
+
}
+
+
GNUNET_CHAT_leave_room (room);
+ GNUNET_free(room);
+ GNUNET_free(message);
GNUNET_fini (ectx, cfg);
return GNUNET_OK;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r6184 - GNUnet/src/applications/chat,
gnunet <=