Date: Thu Mar 13 22:49:00 CET 2003
User: Derick Rethans
Directory: srm/test/storage
Log Message:
[1.00]
- Make it work with the new code
- Fixed some nasty memleaks
Modified files:
srm/test/storage/main.c (version: 1.13)
[FILE: /srm/test/storage/main.c]
--- srm/test/storage/main.c:1.12 Fri Feb 21 18:33:12 2003 GMT
+++ srm/test/storage/main.c Thu Mar 13 20:49:00 2003 GMT
@@ -1,4 +1,4 @@
-/* $Id: cvstemp,v 1.12 2003/02/21 19:33:12 derick Exp $ */
+/* $Id: cvstemp,v 1.13 2003/03/13 21:49:00 derick Exp $ */
/* The contents of this file are subject to the Vulcan Logic Public
* License Version 1.1 (the "License"); you may not use this file
@@ -17,6 +17,7 @@
* 2000, 2001, 2002, 2003 Vulcan Logic Group. All Rights Reserved.
*
* Contributor(s):
+ * Derick Rethans <d.rethans@jdimedia.nl>
*/
#include <stdlib.h>
@@ -30,51 +31,61 @@
struct srm_host_t host;
connect_data_t connect_data;
struct srm_value* ret_val;
-/*
- struct srm_value* data;
-*/
+ SRM_LIST(params)
+ SRM_LIST(indices)
if (argc < 3 || argc > 4) {
- srm_fmt_message (LL_USAGE, "Usage", "storage [operation] [key] [string]");
- srm_fmt_message (LL_USAGE, "Usage", "operation = s(tore) r(etrieve) or d(elete)");
- exit(ERROR_USAGE);
+ printf("Usage: storage [operation] [key] [string]\n");
+ printf("operation = s(tore) r(etrieve) or d(elete)\n\n");
+ exit(0);
}
- memset (&connect_data, 0, sizeof(connect_data));
+ memset(&connect_data, 0, sizeof(connect_data));
host.family = AF_INET;
host.host = "localhost";
host.port = 7777;
-/* We set the connect_data to NULL so that SRM will create one */
- if ((ret_val = srm_connect (host, 0, 0, &connect_data)) != NULL) {
- if (SRM_IS_ERROR (ret_val)) {
- srm_value_dump (ret_val, 0);
- srm_value_free (ret_val);
+
+ /* We set the connect_data to NULL so that SRM will create one */
+ if ((ret_val = srm_connect(host, 0, 0, &connect_data)) != NULL) {
+ if (SRM_IS_ERROR(ret_val)) {
+ srm_value_dump(ret_val, 0);
+ srm_value_free(ret_val);
exit(-1);
}
else if (SRM_IS_WARNING (ret_val)) {
- srm_value_dump (ret_val, 0);
- srm_value_free (ret_val);
+ srm_value_dump(ret_val, 0);
+ srm_value_free(ret_val);
}
else {
- srm_value_free (ret_val);
+ srm_value_free(ret_val);
}
}
-/*
+
+ SRM_LIST_INIT(params);
+ SRM_LIST_ADD(STR, params, "test");
+
+ SRM_LIST_INIT(indices);
+ SRM_LIST_ADD(STR, indices, argv[2]);
+ indices->ref_count++;
+ SRM_LIST_ADD_LST(params, indices);
+
switch (argv[1][0]) {
case 's':
- SRMVALP_SET_STR (data, strdup(argv[3]));
- ret_val = srm_data_store (SRM_ST_APPLICATION, connect_data, strdup(argv[2]), strlen(argv[2]), data);
- srm_value_free (data);
+ SRM_LIST_ADD(STR, params, argv[3]);
+ ret_val = srm_do_command(connect_data, "set_data", params);
break;
case 'r':
- ret_val = srm_data_retrieve (SRM_ST_APPLICATION, connect_data, strdup(argv[2]), strlen(argv[2]));
+ ret_val = srm_do_command(connect_data, "get_data", params);
break;
case 'd':
- ret_val = srm_data_delete (SRM_ST_APPLICATION, connect_data, strdup(argv[2]), strlen(argv[2]));
+ ret_val = srm_do_command(connect_data, "remove_data", params);
break;
}
- srm_value_dump (ret_val, 0);
- srm_value_free (ret_val);
-*/
+ srm_value_dump(ret_val, 0);
+ srm_value_free(ret_val);
+
+ srm_value_free(params);
+ srm_value_free(indices);
+
srm_disconnect(connect_data);
return 0;
}
Received on Thu Mar 13 22:49:03 2003
This archive was generated by hypermail 2.1.8 : Tue Jan 06 2009 - 03:00:03 CET