00001 /*************************************************************************** 00002 $RCSfile$ 00003 ------------------- 00004 cvs : $Id$ 00005 begin : Fri May 07 2004 00006 copyright : (C) 2004 by Martin Preuss 00007 email : martin@libchipcard.de 00008 00009 *************************************************************************** 00010 * Please see toplevel file COPYING for license details * 00011 ***************************************************************************/ 00012 00013 #ifdef HAVE_CONFIG_H 00014 # include <config.h> 00015 #endif 00016 00017 #include <strings.h> 00018 00019 #include "requestmgr_p.h" 00020 #include <gwenhywfar/misc.h> 00021 00022 00023 00024 00025 GWEN_IPC_REQUEST_MANAGER *GWEN_IpcRequestManager_new(GWEN_IPCMANAGER *ipcMgr){ 00026 GWEN_IPC_REQUEST_MANAGER *rm; 00027 00028 GWEN_NEW_OBJECT(GWEN_IPC_REQUEST_MANAGER, rm); 00029 rm->ipcManager=ipcMgr; 00030 rm->requests=GWEN_IpcRequest_List_new(); 00031 00032 return rm; 00033 } 00034 00035 00036 00037 void GWEN_IpcRequestManager_free(GWEN_IPC_REQUEST_MANAGER *rm){ 00038 if (rm) { 00039 GWEN_IpcRequest_List_free(rm->requests); 00040 GWEN_FREE_OBJECT(rm); 00041 } 00042 } 00043 00044 00045 00046 GWEN_IPCMANAGER* 00047 GWEN_IpcRequestManager_GetIpcManager(const GWEN_IPC_REQUEST_MANAGER *rm){ 00048 assert(rm); 00049 return rm->ipcManager; 00050 } 00051 00052 00053 00054 GWEN_IPC_REQUEST_LIST* 00055 GWEN_IpcRequestManager_GetRequests(const GWEN_IPC_REQUEST_MANAGER *rm){ 00056 assert(rm); 00057 return rm->requests; 00058 } 00059 00060 00061 00062 void GWEN_IpcRequestManager_AddRequest(GWEN_IPC_REQUEST_MANAGER *rm, 00063 GWEN_IPC_REQUEST *rq){ 00064 assert(rm); 00065 GWEN_IpcRequest_List_Add(rq, rm->requests); 00066 } 00067 00068 00069 00070 int GWEN_IpcRequestManager__Work(GWEN_IPC_REQUEST_LIST *rql){ 00071 GWEN_IPC_REQUEST *rq; 00072 int done=0; 00073 00074 rq=GWEN_IpcRequest_List_First(rql); 00075 while(rq) { 00076 GWEN_IPC_REQUEST_LIST *crql; 00077 GWEN_IPC_REQUEST *rqNext; 00078 int rv; 00079 00080 rqNext=GWEN_IpcRequest_List_Next(rq); 00081 crql=GWEN_IpcRequest_GetSubRequests(rq); 00082 if (crql) { 00083 rv=GWEN_IpcRequestManager__Work(crql); 00084 if (rv!=1) 00085 done++; 00086 } 00087 00088 rv=GWEN_IpcRequest_WorkFn(rq); 00089 if (rv!=1) 00090 done++; 00091 00092 rq=rqNext; 00093 } 00094 00095 if (done) 00096 return 0; 00097 return 1; 00098 } 00099 00100 00101 00102 int GWEN_IpcRequestManager_Work(GWEN_IPC_REQUEST_MANAGER *rm){ 00103 return GWEN_IpcRequestManager__Work(rm->requests); 00104 } 00105 00106 00107 00108 00109 00110 00111