Date: Thu Mar 13 22:59:34 CET 2003
User: Derick Rethans
Directory: srm/test/srmclient
Log Message:
[3.00]
- Re-implement application vars in the standard module.
- Fixed the 'srmclient' test program to use the new function names.
Modified files:
srm/modules/standard/Makefile.am (version: 1.12)
srm/modules/standard/srm_standard.h (version: 1.17)
srm/modules/standard/standard.c (version: 1.39)
srm/test/srmclient/main.c (version: 1.46)
Added files:
srm/modules/standard/appl_vars.c (new version: 1.1)
[FILE: /srm/modules/standard/appl_vars.c]
/* $Id: cvstemp,v 1.1 2003/03/13 21:59:33 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
* except in compliance with the License. You may obtain a copy of
* the License at http://www.vl-srm.net/vlpl/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is vl-srm.net code.
*
* The Initial Developer of the Original Code is the Vulcan Logic
* Group. Portions created by Vulcan Logic Group are Copyright (C)
* 2000, 2001, 2002, 2003 Vulcan Logic Group. All Rights Reserved.
*
* Contributor(s):
* Derick Rethans <d.rethans@jdimedia.nl>
*/
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include "ini_parser.h"
#include "srm_config.h"
#include "srm_hash.h"
#include "srm_llist.h"
#include "srm_value.h"
#include "srm_modules.h"
#include "srm_standard.h"
static srm_hash* store_hash;
static pthread_mutex_t store_hash_lock = PTHREAD_MUTEX_INITIALIZER;
void store_init(void)
{
pthread_mutex_init(&store_hash_lock, NULL);
pthread_mutex_lock(&store_hash_lock);
store_hash = srm_hash_alloc(32, SRM_VALUE_FREE);
pthread_mutex_unlock(&store_hash_lock);
}
void store_destroy(void)
{
pthread_mutex_lock(&store_hash_lock);
srm_hash_destroy(store_hash);
pthread_mutex_unlock(&store_hash_lock);
pthread_mutex_destroy(&store_hash_lock);
}
static inline srm_value* find_store(srm_hash* hash, char *name, int name_len)
{
srm_value *container;
srm_hash *tmp_hash;
if (srm_hash_find(hash, name, name_len, (void*) &container) == SRM_FAILED) {
/* It doesn't exist, so we create it */
container = srm_value_init();
tmp_hash = srm_hash_alloc(64, SRM_VALUE_FREE);
VALP_SET_HASH(container);
SRMVALP_HASH(container) = tmp_hash;
/* we add it to the store hash */
srm_hash_add(store_hash, name, name_len, container);
/* and we return it. */
return container;
} else {
/* It does exist, lets see if it's a hash too */
if (VALP_IS_HASH(container)) {
/* It is, so we return it */
return container;
} else {
/* It's not :(, not our problem them, let the user rot */
return NULL;
}
}
}
/* {{{ function bool set_data(string store, list indices, mixed value)
Adds a value to a store */
SRM_FUNCTION(set_data)
{
srm_value *store;
srm_value *indices;
srm_value *value;
srm_value *c;
srm_value *key;
/*
srm_llist_element *e;
*/
SRM_ARGC_CHECK(3);
SRM_GET_ARG(0, (store), STR);
SRM_GET_ARG(1, (indices), LIST);
value = SRM_LLIST_VALP(srm_llist_jump(input->list, LIST_HEAD, 2));
c = find_store(store_hash, SRMVALP_STR(store), SRMVALP_STRLEN(store));
/*
e = SRM_LLIST_HEAD(SRMVALP_LIST(indices));
while (e != NULL) {
if (e != SRM_LLIST_TAIL(SRMVALP_LIST(indices))) {
printf ("INDICE: \n");
} else {
printf ("LAST indice: \n");
}
srm_value_dump(SRM_LLIST_VALP(e), 0);
e = SRM_LLIST_NEXT(e);
}
*/
key = (srm_value *) SRM_LLIST_VALP(SRM_LLIST_TAIL(SRMVALP_LIST(indices)));
srm_hash_add(SRMVALP_HASH(c), SRMVALP_STR(key), SRMVALP_STRLEN(key), value);
value->ref_count++;
SRM_RETVAL_BOOL(TRUE);
}
/* }}} */
/* {{{ function mixed get_data(string store, list indices)
Adds a value to a store */
SRM_FUNCTION(get_data)
{
srm_value *store;
srm_value *indices;
srm_value *value = NULL;
srm_value *c;
srm_value *key;
SRM_ARGC_CHECK(2);
SRM_GET_ARG(0, (store), STR);
SRM_GET_ARG(1, (indices), LIST);
c = find_store(store_hash, SRMVALP_STR(store), SRMVALP_STRLEN(store));
key = (srm_value *) SRM_LLIST_VALP(SRM_LLIST_TAIL(SRMVALP_LIST(indices)));
srm_hash_find(SRMVALP_HASH(c), SRMVALP_STR(key), SRMVALP_STRLEN(key), (void *) &value);
if (value) {
SRM_RETVAL_SVAL(value);
} else {
SRM_RETVAL_NULL;
}
}
/* }}} */
/* {{{ function bool remove_data(string store, list indices)
Adds a value to a store */
SRM_FUNCTION(remove_data)
{
srm_value *store;
srm_value *indices;
srm_value *c;
srm_value *key;
SRM_ARGC_CHECK(2);
SRM_GET_ARG(0, (store), STR);
SRM_GET_ARG(1, (indices), LIST);
c = find_store(store_hash, SRMVALP_STR(store), SRMVALP_STRLEN(store));
key = (srm_value *) SRM_LLIST_VALP(SRM_LLIST_TAIL(SRMVALP_LIST(indices)));
srm_hash_delete(SRMVALP_HASH(c), SRMVALP_STR(key), SRMVALP_STRLEN(key));
SRM_RETVAL_BOOL(TRUE);
}
/* }}} */
/* {{{ function list application_keys()
Lists all currently set global variabeles */
SRM_FUNCTION(application_keys)
{
srm_llist *list;
/* Initializing return list */
list = srm_llist_alloc(SRM_LLIST_VALUE_FREE);
/* srm_hash_apply (AST, (void *) list, srm_add_key_to_list); */
SRM_RETVAL_LIST(list);
}
/* }}} */
/* {{{ function list session_keys()
Lists all currently set session ids */
SRM_FUNCTION(session_keys)
{
srm_llist *list;
/* Initializing return list */
list = srm_llist_alloc(SRM_LLIST_VALUE_FREE);
/* srm_hash_apply (SST, (void *) list, srm_add_key_to_list); */
SRM_RETVAL_LIST(list);
}
/* }}} */
/* {{{ function bool lock(string variabele)
Put an advisery lock on the global variabele 'variabele' */
SRM_FUNCTION(lock)
{
srm_value *arg1;
/*
void *dummy;
srm_value *key = NULL;
*/
#ifdef SRM_DEBUG
srm_value_dump(input, 0);
#endif
SRM_ARGC_CHECK(1);
SRM_GET_ARG(0, (arg1), STR);
/*
if (srm_hash_find (ALH, SRMVALP_STR(arg1), arg1->value_length, &dummy) == SRM_FAILED) {
SRMVALP_SET_BINSTR (key, session_key, sizeof (sess_key_t), 1);
if (srm_hash_add (ALH, SRMVALP_STR(arg1), arg1->value_length, NULL) == SRM_SUCCESS) {
SRM_RETVAL_BOOL (TRUE)
return;
}
}
if (key) {
srm_value_free (key);
}
*/
SRM_RETVAL_BOOL(FALSE)
return;
}
/* }}} */
/* {{{ function bool unlock(string variabele)
Releases an advisery lock from the global variabele 'variabele' */
SRM_FUNCTION(unlock)
{
srm_value *arg1;
/*
srm_value *key = NULL;
*/
#ifdef SRM_DEBUG
srm_value_dump(input, 0);
#endif
SRM_ARGC_CHECK(1);
SRM_GET_ARG(0, (arg1), STR);
/*
if (srm_hash_find (ALH, SRMVALP_STR(arg1), arg1->value_length, (void *) &key) == SRM_SUCCESS) {
if (memcmp (session_key, SRMVALP_STR(arg1), sizeof (sess_key_t)) == 0) {
if (srm_hash_delete (ALH, SRMVALP_STR(arg1), arg1->value_length) == SRM_SUCCESS) {
SRM_RETVAL_BOOL(TRUE)
} else {
SRM_RETVAL_BOOL(FALSE)
}
} else {
SRM_RETVAL_BOOL(FALSE)
}
}
*/
SRM_RETVAL_BOOL(FALSE)
return;
}
/* }}} */
/*
* Local Variables:
* c-basic-offset: 4
* tab-width: 4
* End:
* vim600: fdm=marker
* vim: noet sw=4 ts=4
*/
[FILE: /srm/modules/standard/Makefile.am]
--- srm/modules/standard/Makefile.am:1.11 Thu Feb 20 19:33:33 2003 GMT
+++ srm/modules/standard/Makefile.am Thu Mar 13 20:59:33 2003 GMT
@@ -1,5 +1,5 @@
##
-## $Id: cvstemp,v 1.11 2003/02/20 20:33:33 derick Exp $
+## $Id: cvstemp,v 1.12 2003/03/13 21:59:33 derick Exp $
##
## The contents of this file are subject to the Vulcan Logic Public
@@ -19,7 +19,8 @@
## 2000, 2001, 2002, 2003 Vulcan Logic Group. All Rights Reserved.
##
## Contributor(s):
+## Derick Rethans <d.rethans@jdimedia.nl>
##/
noinst_LTLIBRARIES = libstandard.la
-libstandard_la_SOURCES = standard.c
+libstandard_la_SOURCES = standard.c appl_vars.c
[FILE: /srm/modules/standard/srm_standard.h]
--- srm/modules/standard/srm_standard.h:1.16 Fri Feb 21 18:33:11 2003 GMT
+++ srm/modules/standard/srm_standard.h Thu Mar 13 20:59:33 2003 GMT
@@ -1,4 +1,4 @@
-/* $Id: cvstemp,v 1.16 2003/02/21 19:33:11 derick Exp $ */
+/* $Id: cvstemp,v 1.17 2003/03/13 21:59:33 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,7 +17,7 @@
* 2000, 2001, 2002, 2003 Vulcan Logic Group. All Rights Reserved.
*
* Contributor(s):
- * Derick Rethans <derick@vl-srm.net>
+ * Derick Rethans <d.rethans@jdimedia.nl>
*/
#ifndef __SRM_STANDARD_H__
@@ -30,23 +30,31 @@
#define srmmod_standard_ptr &standard_module_entry
/* }}} */
-extern srm_hash *AST;
-extern srm_hash *SST;
-extern srm_hash *ALH;
-extern srm_hash *SLH;
-
/* {{{ Function list */
-SRM_FUNCTION(srm_version);
-/* SRM_FUNCTION(srm_ini_entries); */
-SRM_FUNCTION(srm_function_list);
-SRM_FUNCTION(srm_function_exists);
-SRM_FUNCTION(srm_module_list);
-SRM_FUNCTION(srm_module_exists);
-SRM_FUNCTION(srm_module_info);
-SRM_FUNCTION(srm_application_keys);
-SRM_FUNCTION(srm_session_keys);
+SRM_LOAD(standard);
+SRM_UNLOAD(standard);
+
+/* standard.c: */
+SRM_FUNCTION(version);
+/* SRM_FUNCTION(get_ini_entries); */
+SRM_FUNCTION(function_list);
+SRM_FUNCTION(function_exists);
+SRM_FUNCTION(module_list);
+SRM_FUNCTION(module_exists);
+SRM_FUNCTION(module_info);
+
+/* appl_vars.c: */
+SRM_FUNCTION(set_data);
+SRM_FUNCTION(get_data);
+SRM_FUNCTION(remove_data);
+
+SRM_FUNCTION(application_keys);
+SRM_FUNCTION(session_keys);
SRM_FUNCTION(lock);
SRM_FUNCTION(unlock);
/* }}} */
+
+void store_init(void);
+void store_destroy(void);
#endif
[FILE: /srm/modules/standard/standard.c]
--- srm/modules/standard/standard.c:1.38 Sat Feb 22 18:34:51 2003 GMT
+++ srm/modules/standard/standard.c Thu Mar 13 20:59:33 2003 GMT
@@ -1,4 +1,4 @@
-/* $Id: cvstemp,v 1.38 2003/02/22 19:34:51 derick Exp $ */
+/* $Id: cvstemp,v 1.39 2003/03/13 21:59:33 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,7 +17,7 @@
* 2000, 2001, 2002, 2003 Vulcan Logic Group. All Rights Reserved.
*
* Contributor(s):
- * Derick Rethans <derick@vl-srm.net>
+ * Derick Rethans <d.rethans@jdimedia.nl>
*/
#include <stdio.h>
@@ -34,17 +34,24 @@
/* {{{ Function list */
BEGIN_FUNC_LIST(standard_functions)
- SRM_FE (srm_version, NULL)
-/* SRM_FE (srm_ini_entries, NULL) */
- SRM_FE (srm_function_list, NULL)
- SRM_FE (srm_function_exists, NULL)
- SRM_FE (srm_module_list, NULL)
- SRM_FE (srm_module_exists, NULL)
- SRM_FE (srm_module_info, NULL)
- SRM_FE (srm_application_keys, NULL)
- SRM_FE (srm_session_keys, NULL)
- SRM_FE (lock, NULL)
- SRM_FE (unlock, NULL)
+/* standard.c: */
+ SRM_FE(version, NULL)
+/* SRM_FE(get_ini_entries, NULL) */
+ SRM_FE(function_list, NULL)
+ SRM_FE(function_exists, NULL)
+ SRM_FE(module_list, NULL)
+ SRM_FE(module_exists, NULL)
+ SRM_FE(module_info, NULL)
+
+/* appl_vars.c: */
+ SRM_FE(set_data, NULL)
+ SRM_FE(get_data, NULL)
+ SRM_FE(remove_data, NULL)
+
+ SRM_FE(application_keys, NULL)
+ SRM_FE(session_keys, NULL)
+ SRM_FE(lock, NULL)
+ SRM_FE(unlock, NULL)
END_FUNC_LIST
/* }}} */
@@ -55,8 +62,8 @@
NULL,
NULL,
NULL,
- NULL,
- NULL,
+ SRM_MODULE_LOAD(standard),
+ SRM_MODULE_UNLOAD(standard),
SRM_MODULE_INFO
(
MODULE_VERSION(SRM_MAJOR_VERSION,SRM_MINOR_VERSION,SRM_MICRO_VERSION),
@@ -67,6 +74,19 @@
};
/* }}} */
+SRM_LOAD(standard)
+{
+ store_init();
+
+ return SRM_SUCCESS;
+}
+
+SRM_UNLOAD(standard)
+{
+ store_destroy();
+
+ return SRM_SUCCESS;
+}
/* {{{ helper void srm_add_key_to_list (data, e)
Helper function which adds a key associated with the hash element
@@ -124,25 +144,25 @@
/* }}} */
-/* {{{ function srm_ini_entries()
+/* {{{ function get_ini_entries()
This function lists all ini settings from srm.ini
-SRM_FUNCTION(srm_ini_entries)
+SRM_FUNCTION(get_ini_entries)
{
}
}}} */
-/* {{{ function u32 srm_version()
+/* {{{ function u32 version()
Returns the API version number */
-SRM_FUNCTION(srm_version)
+SRM_FUNCTION(version)
{
SRM_RETVAL_U32(SRM_API_VERSION);
}
/* }}} */
-/* {{{ function list srm_function_list()
+/* {{{ function list function_list()
Lists all functions available through SRM */
-SRM_FUNCTION(srm_function_list)
+SRM_FUNCTION(function_list)
{
srm_llist* list;
@@ -153,9 +173,9 @@
}
/* }}} */
-/* {{{ function bool srm_function_exists(string function_name)
+/* {{{ function bool function_exists(string function_name)
Checks whether the function 'function_name' is available */
-SRM_FUNCTION(srm_function_exists)
+SRM_FUNCTION(function_exists)
{
srm_value *arg1;
void *dummy;
@@ -175,9 +195,9 @@
}
/* }}} */
-/* {{{ function list srm_module_list()
+/* {{{ function list module_list()
Lists all modules available through SRM */
-SRM_FUNCTION(srm_module_list)
+SRM_FUNCTION(module_list)
{
srm_llist* list;
@@ -188,9 +208,9 @@
}
/* }}} */
-/* {{{ function bool srm_module_exists(string module_name)
+/* {{{ function bool module_exists(string module_name)
Checks whether a module is available trough SRM */
-SRM_FUNCTION(srm_module_exists)
+SRM_FUNCTION(module_exists)
{
srm_value *arg1;
void *dummy;
@@ -210,9 +230,9 @@
}
/* }}} */
-/* {{{ function list srm_module_info(string module_name)
+/* {{{ function list module_info(string module_name)
Retrieves modules information about module 'module_name' */
-SRM_FUNCTION(srm_module_info)
+SRM_FUNCTION(module_info)
{
srm_value *arg1, *record;
srm_llist *list;
@@ -232,7 +252,7 @@
/* Initializing return list */
list = srm_llist_alloc (SRM_LLIST_VALUE_FREE);
- info[0] = module->info.name;
+ info[0] = module->info.name;
info[1] = module->info.version_string;
info[2] = module->info.vendor;
info[3] = module->info.description;
@@ -256,97 +276,6 @@
}
/* }}} */
-/* {{{ function list srm_application_keys()
- Lists all currently set global variabeles */
-SRM_FUNCTION(srm_application_keys)
-{
- srm_llist *list;
-
- /* Initializing return list */
- list = srm_llist_alloc (SRM_LLIST_VALUE_FREE);
-/* srm_hash_apply (AST, (void *) list, srm_add_key_to_list); */
- SRM_RETVAL_LIST(list);
-}
-/* }}} */
-
-/* {{{ function list srm_session_keys()
- Lists all currently set session ids */
-SRM_FUNCTION(srm_session_keys)
-{
- srm_llist *list;
-
- /* Initializing return list */
- list = srm_llist_alloc (SRM_LLIST_VALUE_FREE);
-/* srm_hash_apply (SST, (void *) list, srm_add_key_to_list); */
- SRM_RETVAL_LIST(list);
-}
-/* }}} */
-
-/* {{{ function bool lock(string variabele)
- Put an advisery lock on the global variabele 'variabele' */
-SRM_FUNCTION(lock)
-{
- srm_value *arg1;
-/*
- void *dummy;
- srm_value *key = NULL;
-*/
-
-#ifdef SRM_DEBUG
- srm_value_dump (input, 0);
-#endif
-
- SRM_ARGC_CHECK (1);
- SRM_GET_ARG (0, (arg1), STR);
-/*
- if (srm_hash_find (ALH, SRMVALP_STR(arg1), arg1->value_length, &dummy) == SRM_FAILED) {
- SRMVALP_SET_BINSTR (key, session_key, sizeof (sess_key_t), 1);
- if (srm_hash_add (ALH, SRMVALP_STR(arg1), arg1->value_length, NULL) == SRM_SUCCESS) {
- SRM_RETVAL_BOOL (TRUE)
- return;
- }
- }
- if (key) {
- srm_value_free (key);
- }
-*/
- SRM_RETVAL_BOOL (FALSE)
- return;
-}
-/* }}} */
-
-/* {{{ function bool unlock(string variabele)
- Releases an advisery lock from the global variabele 'variabele' */
-SRM_FUNCTION(unlock)
-{
- srm_value *arg1;
-/*
- srm_value *key = NULL;
-*/
-
-#ifdef SRM_DEBUG
- srm_value_dump (input, 0);
-#endif
-
- SRM_ARGC_CHECK (1);
- SRM_GET_ARG (0, (arg1), STR);
-/*
- if (srm_hash_find (ALH, SRMVALP_STR(arg1), arg1->value_length, (void *) &key) == SRM_SUCCESS) {
- if (memcmp (session_key, SRMVALP_STR(arg1), sizeof (sess_key_t)) == 0) {
- if (srm_hash_delete (ALH, SRMVALP_STR(arg1), arg1->value_length) == SRM_SUCCESS) {
- SRM_RETVAL_BOOL(TRUE)
- } else {
- SRM_RETVAL_BOOL(FALSE)
- }
- } else {
- SRM_RETVAL_BOOL(FALSE)
- }
- }
-*/
- SRM_RETVAL_BOOL (FALSE)
- return;
-}
-/* }}} */
/*
* Local Variables:
[FILE: /srm/test/srmclient/main.c]
--- srm/test/srmclient/main.c:1.45 Fri Feb 21 18:33:12 2003 GMT
+++ srm/test/srmclient/main.c Thu Mar 13 20:59:34 2003 GMT
@@ -1,4 +1,4 @@
-/* $Id: cvstemp,v 1.45 2003/02/21 19:33:12 derick Exp $ */
+/* $Id: cvstemp,v 1.46 2003/03/13 21:59:34 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
@@ -49,7 +49,8 @@
host.family = AF_UNIX;
}
} else {
- srm_fmt_message (LL_USAGE, "Usage", "srmclient [ ( hort port ) | ( socket UNIX ) ]");
+ printf("Usage: srmclient [ ( hort port ) | ( socket UNIX ) ]\n\n");
+ exit(0);
}
/* We set the connect_data to NULL so that SRM will create one */
@@ -69,52 +70,48 @@
}
/* srm_module_list() */
- ret_val = srm_do_command (connect_data, "srm_module_list", NULL);
+ ret_val = srm_do_command (connect_data, "module_list", NULL);
srm_value_dump (ret_val, 0);
srm_value_free (ret_val);
/* srm_function_list() */
- ret_val = srm_do_command (connect_data, "srm_function_list", NULL);
+ ret_val = srm_do_command (connect_data, "function_list", NULL);
srm_value_dump (ret_val, 0);
srm_value_free (ret_val);
/* srm_function_exists(functionname) */
SRM_LIST_INIT(params);
SRM_LIST_ADD (STR, params, "srm_module_list");
- ret_val = srm_do_command (connect_data, "srm_function_exists", params);
+ ret_val = srm_do_command (connect_data, "function_exists", params);
srm_value_dump (ret_val, 0);
srm_value_free (ret_val);
- SRM_LIST_FREE (params);
/* srm_module_exists(modulename) */
SRM_LIST_INIT(params);
SRM_LIST_ADD (STR, params, "smxs");
- ret_val = srm_do_command (connect_data, "srm_module_exists", params);
+ ret_val = srm_do_command (connect_data, "module_exists", params);
srm_value_dump (ret_val, 0);
srm_value_free (ret_val);
- SRM_LIST_FREE (params);
/* srm_module_info(modulename) */
SRM_LIST_INIT(params);
SRM_LIST_ADD (STR, params, "dbquery");
- ret_val = srm_do_command (connect_data, "srm_module_info", params);
+ ret_val = srm_do_command (connect_data, "module_info", params);
srm_value_dump (ret_val, 0);
srm_value_free (ret_val);
- SRM_LIST_FREE (params);
/* Some functions */
SRM_LIST_INIT(params);
SRM_LIST_ADD (STR, params, "http");
- ret_val = srm_do_command (connect_data, "srm_module_info", params);
+ ret_val = srm_do_command (connect_data, "module_info", params);
srm_value_dump (ret_val, 0);
srm_value_free (ret_val);
- SRM_LIST_FREE (params);
- ret_val = srm_do_command (connect_data, "srm_version", NULL);
+ ret_val = srm_do_command (connect_data, "version", NULL);
srm_value_dump (ret_val, 0);
srm_value_free (ret_val);
- ret_val = srm_do_command (connect_data, "srm_application_keys", NULL);
+ ret_val = srm_do_command (connect_data, "application_keys", NULL);
srm_value_dump (ret_val, 0);
srm_value_free (ret_val);
Received on Thu Mar 13 22:59:39 2003
This archive was generated by hypermail 2.1.8 : Tue Jan 06 2009 - 04:00:03 CET