/home/dko/projects/mobilec/trunk/src/include/df.h

Go to the documentation of this file.
00001 /*[
00002  * Copyright (c) 2007 Integration Engineering Laboratory
00003                       University of California, Davis
00004  *
00005  * Permission to use, copy, and distribute this software and its
00006  * documentation for any purpose with or without fee is hereby granted,
00007  * provided that the above copyright notice appear in all copies and
00008  * that both that copyright notice and this permission notice appear
00009  * in supporting documentation.
00010  *
00011  * Permission to modify the software is granted, but not the right to
00012  * distribute the complete modified source code.  Modifications are to
00013  * be distributed as patches to the released version.  Permission to
00014  * distribute binaries produced by compiling modified sources is granted,
00015  * provided you
00016  *   1. distribute the corresponding source modifications from the
00017  *    released version in the form of a patch file along with the binaries,
00018  *   2. add special version identification to distinguish your version
00019  *    in addition to the base release version number,
00020  *   3. provide your name and address as the primary contact for the
00021  *    support of your modified version, and
00022  *   4. retain our contact information in regard to use of the base
00023  *    software.
00024  * Permission to distribute the released version of the source code along
00025  * with corresponding source modifications in the form of a patch file is
00026  * granted with same provisions 2 through 4 for binary distributions.
00027  *
00028  * This software is provided "as is" without express or implied warranty
00029  * to the extent permitted by applicable law.
00030 ]*/
00031 
00032 #ifndef _DF_H_
00033 #define _DF_H_
00034 #include "../mc_list/list.h"
00035 #include "../include/macros.h"
00036 #ifdef _WIN32
00037 #include <windows.h>
00038 #endif
00039 
00040 struct mc_platform_s;
00041 
00042 /* Command Indices */
00043 enum df_request_list_index_e{
00044 #define REQUEST(name, string, description)     REQUEST_##name, 
00045 #include "df_request.x.h"
00046 #undef REQUEST
00047     REQUEST_COUNT
00048 };
00049 
00050 enum service_types_e {
00051     ZERO,
00052     MISC,
00053     INSERT,
00054     SOME,
00055     TYPES,
00056     HERE
00057 };
00058 
00059 STRUCT(df_request_list_node,
00060 
00061     MUTEX_T *lock;
00062     COND_T *cond;
00063     const char* command;
00064     void* data;
00065     int data_size;
00066     )
00067 
00068 STRUCT( df_request_list,
00069 
00070     MUTEX_T *lock;
00071     COND_T *cond;
00072     int size;
00073     list_p request_list;
00074     )
00075 
00076 STRUCT( df_search_results,
00077 
00078     char **agent_names;
00079     char **service_names;
00080     int *agent_ids;
00081     int num_results;
00082     )
00083 
00084 STRUCT( df_request_search,
00085     MUTEX_T *lock;
00086     COND_T *cond;
00087     char *search_string;
00088     df_search_results_p search_results;
00089     )
00090 
00091 STRUCT( df_node,
00092 
00093     MUTEX_T *lock;
00094 
00095     int agent_id;
00096     char *agent_name;
00097 
00098     int num_services;
00099     char **service_names;
00100     enum service_types_e service_types;
00101     )
00102 
00103 STRUCT( df,
00104     struct mc_platform_s* mc_platform;
00105     MUTEX_T *lock;
00106     COND_T *cond;
00107     list_p service_list;
00108     df_request_list_p request_list;
00109     
00110     int num_entries;
00111     int waiting; /* Flag indicating if thread is waiting for activity */
00112     MUTEX_T *waiting_lock;
00113     COND_T *waiting_cond;
00114     THREAD_T thread;
00115     )
00116 
00117 STRUCT( df_deregister,
00118 
00119     int agent_id;
00120     char *service_name;
00121     )
00122 
00123 
00124 /* df functions */
00125 int 
00126 df_Add(struct df_s* df, struct df_node_s * node);
00127 
00128 int 
00129 df_AddRequest(struct df_s* df, struct df_request_list_node_s* node);
00130 
00131 int 
00132 df_Destroy(df_p df);
00133 
00134 df_p 
00135 df_Initialize(struct mc_platform_s* mc_platform);
00136 
00137 int df_ProcessRequest(
00138         struct mc_platform_s* global
00139         );
00140 
00141 int 
00142 df_SearchForService(
00143         df_p df,
00144         const char* searchstring, 
00145         char*** agent_names,
00146         char*** service_names,
00147         int** agent_ids,
00148         int* num_entries
00149 );
00150 
00151 void
00152 df_Start(struct mc_platform_s* mc_platform);
00153 
00154 /* df_node functions */
00155   int
00156 df_node_Destroy(df_node_p df_node);
00157 
00158 /* df_request_list_node functions */
00159 int 
00160 df_request_list_node_Destroy(df_request_list_node_p node);
00161 
00162 df_request_list_node_p 
00163 df_request_list_node_New(void);
00164 
00165 /* df_request_list functions */
00166 int
00167 df_request_list_Destroy(df_request_list_p df_request_list);
00168 
00169 df_request_list_p 
00170 df_request_list_New(void);
00171 
00172 df_request_list_node_p
00173 df_request_list_Pop(df_request_list_p requests);
00174 
00175 /* df_request_search functions */
00176 
00177 df_request_search_p
00178 df_request_search_New(void);
00179 
00180 int 
00181 df_request_search_Destroy(df_request_search_p node);
00182 
00183 #ifndef _WIN32
00184 void* df_Thread(void* arg);
00185 #else
00186 DWORD WINAPI df_Thread( LPVOID arg );
00187 #endif
00188 
00189 /* Request Handler Function Prototypes */
00190 #define REQUEST(name, string, description)  \
00191     int request_handler_##name (struct mc_platform_s *global, void* data);
00192 #include "df_request.x.h"
00193 #undef REQUEST
00194 
00195 
00196 #endif /* AP_DF_H */

Generated on Fri May 16 14:49:54 2008 for Mobile-C by  doxygen 1.5.4