changeset 73:ad401b7c97bb

fix warnings
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Fri, 23 Oct 2009 14:16:59 +0900
parents dba61c334c38 (current diff) 0352536c33fa (diff)
children be8bc83c001a
files examples/filesend/reader.c examples/filesend/writer.c tools/Linda_library/liblindaapi.a
diffstat 3 files changed, 35 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/examples/filesend/reader.c	Fri Oct 23 14:13:13 2009 +0900
+++ b/examples/filesend/reader.c	Fri Oct 23 14:16:59 2009 +0900
@@ -10,10 +10,10 @@
 #define PORT 10000
 
 void
-mainLoop(int tid, int read_id, FILE* out)
+mainLoop(unsigned int tid, int read_id, FILE* out)
 {
-	int rd_seq;
-	char *tuple, *data;
+	unsigned int rd_seq;
+	unsigned char *tuple, *data;
 	int len;
 
 	/* すでにデータが書き込まれた状態で動くこと  */
--- a/examples/filesend/writer.c	Fri Oct 23 14:13:13 2009 +0900
+++ b/examples/filesend/writer.c	Fri Oct 23 14:16:59 2009 +0900
@@ -10,6 +10,7 @@
 
 #define PORT 10000
 
+#define SERIAL_REGIST_TUPLE_NO 1
 
 void
 mainLoop(int tid, int write_id, int fd)
@@ -32,24 +33,47 @@
 	psx_out(tid, write_id, addr, sb.st_size);
 	psx_sync_n();
 
-
 	return;
 }
 
+int get_serial_id(int tid) {
+	char *data;
+	int serial;
+	int seq;
+
+	seq = psx_in(tid, 65535);
+	psx_sync_n();
+	data = (char *)psx_reply(seq);
+	serial = atoi(data + LINDA_HEADER_SIZE);
+	psx_free(data);
+
+	return serial;
+}
+
+void send_serial_id(int tid, int serial_id) {
+	int safe_id = htonl(serial_id);
+
+	psx_out(tid, SERIAL_REGIST_TUPLE_NO, (unsigned char *)&safe_id, sizeof(safe_id));
+	psx_sync_n();
+}
 
 int
 main(int argc, char *argv[]) {
 	int len = 0;
 	int tspace;
-
+	int serial;
+	int xml_id;
+	const char *linda_serv = "localhost";
+	if (argc > 1)
+		linda_serv = argv[1];
 	init_linda();
-	tspace = open_linda_java("localhost", PORT);
+	tspace = open_linda_java(linda_serv, PORT);
 	printf("open socket (tupple space id) = %d\n", tspace);
-
-	mainLoop(tspace, 10, fileno(stdin));
-
+	serial = get_serial_id(tspace);
+	xml_id = serial * 10;
+	mainLoop(tspace, xml_id, fileno(stdin));
+	sleep(1);
+	send_serial_id(tspace, serial);
 	printf("mainLoop finished\n");
 	exit(EXIT_SUCCESS);
 }
-
-
Binary file tools/Linda_library/liblindaapi.a has changed