/home/dko/projects/mobilec/trunk/src/data_structures.c

Go to the documentation of this file.
00001 /* SVN FILE INFO
00002  * $Revision: 174 $ : Last Committed Revision
00003  * $Date: 2008年06月24日 10:50:29 -0700 (2008年6月24日) $ : Last Committed Date */
00004 /*[
00005  * Copyright (c) 2007 Integration Engineering Laboratory
00006  University of California, Davis
00007  *
00008  * Permission to use, copy, and distribute this software and its
00009  * documentation for any purpose with or without fee is hereby granted,
00010  * provided that the above copyright notice appear in all copies and
00011  * that both that copyright notice and this permission notice appear
00012  * in supporting documentation.
00013  *
00014  * Permission to modify the software is granted, but not the right to
00015  * distribute the complete modified source code. Modifications are to
00016  * be distributed as patches to the released version. Permission to
00017  * distribute binaries produced by compiling modified sources is granted,
00018  * provided you
00019  * 1. distribute the corresponding source modifications from the
00020  * released version in the form of a patch file along with the binaries,
00021  * 2. add special version identification to distinguish your version
00022  * in addition to the base release version number,
00023  * 3. provide your name and address as the primary contact for the
00024  * support of your modified version, and
00025  * 4. retain our contact information in regard to use of the base
00026  * software.
00027  * Permission to distribute the released version of the source code along
00028  * with corresponding source modifications in the form of a patch file is
00029  * granted with same provisions 2 through 4 for binary distributions.
00030  *
00031  * This software is provided "as is" without express or implied warranty
00032  * to the extent permitted by applicable law.
00033 ]*/
00034 
00035 #include "include/ap_queue_template.h"
00036 #include "include/data_structures.h"
00037 /* Connection Queue */
00038 AP_QUEUE_STD_DEFN_TEMPLATE(connection_queue, connection)
00039 
00040 AP_QUEUE_SEARCH_TEMPLATE(
00041 connection_queue,
00042 Search,
00043 connection,
00044 int,
00045 (node->connect_id == key)
00046 )
00047 
00048 AP_QUEUE_REMOVE_TEMPLATE(
00049 connection_queue,
00050 Remove,
00051 connection,
00052 int,
00053 (node->connect_id == key)
00054 )
00055 
00056 int 
00057 connection_queue_Print(connection_queue_p queue)
00058 {
00059 int i;
00060 connection_p node;
00061 MUTEX_LOCK(queue->lock);
00062 for(i = 0; i < queue->size; i++) {
00063 node = (connection_p)ListSearch(queue->list, i);
00064 if (node != NULL) {
00065 printf("Connection id %d:\n\tremote:%s\n",
00066 node->connect_id,
00067 node->remote_hostname
00068 );
00069 }
00070 }
00071 MUTEX_UNLOCK(queue->lock);
00072 return i;
00073 }
00074 
00075 /* Agent variables */
00076 #include "include/interpreter_variable_data.h"
00077 AP_QUEUE_STD_DEFN_TEMPLATE(agent_variable_list, interpreter_variable_data)
00078 
00079 AP_QUEUE_SEARCH_TEMPLATE(
00080 agent_variable_list,
00081 Search,
00082 interpreter_variable_data,
00083 char*,
00084 (!strcmp(node->name, key))
00085 )
00086 
00087 AP_QUEUE_REMOVE_TEMPLATE(
00088 agent_variable_list,
00089 Remove,
00090 interpreter_variable_data,
00091 char*,
00092 (!strcmp(node->name, key))
00093 )
00094 
00095 /* Message Queue */
00096 AP_QUEUE_STD_DEFN_TEMPLATE(
00097 message_queue,
00098 message
00099 )
00100 
00101 AP_QUEUE_SEARCH_TEMPLATE(
00102 message_queue,
00103 Search,
00104 message,
00105 int,
00106 (node->message_id == key)
00107 )
00108 
00109 AP_QUEUE_REMOVE_TEMPLATE(
00110 message_queue,
00111 Remove,
00112 message,
00113 int,
00114 (node->message_id == key)
00115 )
00116 
00117 int
00118 message_queue_Print(message_queue_p queue)
00119 {
00120 int i;
00121 message_p node;
00122 MUTEX_LOCK(queue->lock);
00123 for(i = 0; i < queue->size; i++) {
00124 node = (message_p)ListSearch(queue->list, i);
00125 if (node != NULL) {
00126 printf("Connection id %d:\n\tfrom:%s\n\tto:%s\n",
00127 node->message_id,
00128 node->from_address,
00129 node->to_address
00130 );
00131 }
00132 }
00133 MUTEX_UNLOCK(queue->lock);
00134 return i;
00135 }
00136 
00137 
00138 /* Agent Queue */
00139 #include "include/agent.h"
00140 AP_QUEUE_STD_DEFN_TEMPLATE(
00141 agent_queue,
00142 agent
00143 )
00144 AP_QUEUE_SEARCH_TEMPLATE(
00145 agent_queue,
00146 Search,
00147 agent,
00148 int,
00149 (node->id == key)
00150 )
00151 AP_QUEUE_SEARCH_TEMPLATE(
00152 agent_queue,
00153 SearchName,
00154 agent,
00155 char*,
00156 (!strcmp(node->name, key))
00157 )
00158 AP_QUEUE_REMOVE_TEMPLATE(
00159 agent_queue,
00160 Remove,
00161 agent,
00162 int,
00163 (node->id == key)
00164 )
00165 AP_QUEUE_REMOVE_TEMPLATE(
00166 agent_queue,
00167 RemoveName,
00168 agent,
00169 char*,
00170 (!strcmp(node->name, key))
00171 )
00172 
00173 int
00174 agent_queue_Print(agent_queue_p queue)
00175 {
00176 int i;
00177 agent_p node;
00178 MUTEX_LOCK(queue->lock);
00179 for(i = 0; i < queue->size; i++) {
00180 node = (agent_p)ListSearch(queue->list, i);
00181 if (node != NULL) {
00182 printf("agent id %d:\n\tname:%s\n",
00183 (int)node->id,
00184 node->name
00185 );
00186 }
00187 }
00188 MUTEX_UNLOCK(queue->lock);
00189 return i;
00190 }
00191 
00192 /* Mail Queue */
00193 AP_QUEUE_STD_DEFN_TEMPLATE(
00194 mail_queue,
00195 fipa_acl_message
00196 )
00197 
00198 fipa_acl_message_p mail_queue_SearchReceivers( mail_queue_p mail_queue, const char* key)
00199 {
00200 listNode_t* parsenode;
00201 fipa_acl_message_t* node = NULL;
00202 fipa_acl_message_t* ret = NULL;
00203 int i;
00204 
00205 MUTEX_LOCK(mail_queue->lock);
00206 if (mail_queue->list->listhead == NULL) {
00207 MUTEX_UNLOCK(mail_queue->lock);
00208 return NULL;
00209 }
00210 for(
00211 parsenode = (listNode_t*)mail_queue->list->listhead;
00212 parsenode != NULL;
00213 parsenode = (listNode_t*)parsenode->next
00214 )
00215 {
00216 node = (fipa_acl_message_t*)parsenode->node_data;
00217 for(i = 0; i < node->receiver->num; i++) {
00218 if ( !strcmp(
00219 node->receiver->fipa_agent_identifiers[i]->name,
00220 key) )
00221 {
00222 ret = node;
00223 parsenode = NULL;
00224 break;
00225 }
00226 }
00227 }
00228 return ret;
00229 }
00230 
00231 /* Mailbox Queue */
00232 AP_QUEUE_STD_DEFN_TEMPLATE(
00233 mailbox_queue,
00234 agent_mailbox
00235 )
00236 

Generated on Tue Oct 28 17:03:22 2008 for Mobile-C by doxygen 1.5.5

AltStyle によって変換されたページ (->オリジナル) /