server/config.c

00001 /*
00002  * Copyright Ian Burnett 2005, 2006.
00003  *
00004  * This file is part of Ian's Interactive LCD controller (IILC).
00005  * 
00006  * IILC is free software; you can redistribute it and/or modify it under
00007  * the terms of the GNU General Public License as published by the Free
00008  * Software Foundation; either version 2 of the License, or (at your
00009  * option) any later version.
00010  *
00011  * IILC is distributed in the hope that it will be useful, but WITHOUT
00012  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00013  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00014  * for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License along
00017  * with IILC; if not, write to the Free Software Foundation, Inc.,
00018  * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.
00019  */
00020 
00021 #include <stdio.h>
00022 #include <string.h>
00023 #include "config.h"
00024 #include "module.h"
00025 #include "trace.h"
00026 #include "vector.h"
00027 
00028 #define IILC_MODULE MODULE_TYPE_APP
00029 
00030 
00031 
00032 /****************************************************************************
00033  *                                                                          *
00034  *                                                                          *
00035  *                                                                          *
00036  ****************************************************************************/
00037 
00038 
00043 typedef struct _tag_config_file
00044 {
00045     /* ----- Data held at parse time ----- */
00046 
00048     char * pszFileName;
00049 
00051     LPVECTOR pDisplays;
00052 
00053     /* ----- Data calculated during verify stage ----- */
00054 
00055 
00056 
00057 } CONFIG_FILE;
00058 
00059 
00063 typedef struct _tag_config_display
00064 {
00065     /* ----- Data held at parse time ----- */
00066 
00067     const char * pszName;
00068 
00069 
00070     LPCONFIG_DEVICE pDevice;
00071 
00072 
00073     LPVECTOR pModuleList;
00074 
00075     LPVECTOR pScreenList;
00076 
00077 
00078     /* ----- Data calculated during verify stage ----- */
00079 
00080 
00081 
00082 
00083     /* ----- Child data ----- */
00084 
00086 //    LPVECTOR pModules;
00087 
00089 //    LPVECTOR pScreens;
00090 
00091     /* -- Current screen being configured -- */
00092 //    LPSCREEN pCurrentScreen;
00093 
00094 
00095     /* ----- Config data ----- */
00096 
00098 //    LPCONFIG_DEVICE pConfigDevice;
00099 
00101 //    char * pszName;
00102     
00103     /* ----- Runtime data ----- */
00104 
00106 //    LPDISPLAY pDisplay;
00107 
00108 } CONFIG_DISPLAY;
00109 
00110 
00114 typedef struct _tag_config_device
00115 {
00116     /* ----- Data held at parse time ----- */
00117 
00119     LPVECTOR pObjectList;
00120 
00122     char * pszName;
00123 
00124     char * pszPort;
00125 
00126     char * pszClass;
00127 
00128     /* ----- Data calculated during verify stage ----- */
00129 
00130 
00131 } CONFIG_DEVICE;
00132 
00133 
00137 typedef struct _tag_config_module
00138 {
00139     /* ----- Data held at parse time ----- */
00140 
00142     const char * pszModuleName;
00143 
00145     const char * pszLibraryName;
00146 
00148     LPVECTOR pReportList;
00149 
00151     LPVECTOR pControlList;
00152 
00153     /* ----- Data calculated during verify stage ----- */
00154 
00155 
00156 
00157 } CONFIG_MODULE;
00158 
00159 
00160 
00164 typedef struct _tag_config_screen
00165 {
00166     char * pszScreen;
00167 
00168     LPVECTOR pWindowList;
00169 
00170 
00171 }
00172 CONFIG_SCREEN;
00173 
00174 
00175 typedef struct _tag_config_window
00176 {
00177     /* ----- Data held at parse time ----- */
00178 
00179     int x;
00180 
00181     int y;
00182 
00183     int width;
00184 
00185     int height;
00186 
00187     char * pszModule;
00188 
00189     /* ----- Data calculated during verify stage ----- */
00190 
00191     LPCONFIG_MODULE pModule;
00192 }
00193 CONFIG_WINDOW;
00194 
00195 
00199 typedef struct _tag_config_object
00200 {
00201     enum displayObjectType type;
00202 
00204     unsigned int physical_id;
00205 
00207     const char * pszName;
00208 
00210     LPCONFIG_MODULE pControllingModule;
00211 
00213     unsigned int nModuleControlAsID;
00214 
00216     LPVECTOR pReportModulesList;
00217 
00219     LPVECTOR pReportIDList;
00220 
00221 } CONFIG_OBJECT;
00222 
00223 
00224 
00225 /****************************************************************************/
00226 /*                                                                          */
00227 /* Config object function prototypes                                       */
00228 /*                                                                          */
00229 /****************************************************************************/
00230 
00231 
00232 static int configObjectCreate(LPCONFIG_OBJECT * ppObject, 
00233                               enum displayObjectType type, 
00234                               int physical_id, 
00235                               const char * pszName);
00236 
00237 
00238 
00239 /****************************************************************************/
00240 /*                                                                          */
00241 /* Config file functions                                                    */
00242 /*                                                                          */
00243 /****************************************************************************/
00244 
00245 
00246 int configFileCreate(LPCONFIG_FILE * ppFile, const char * pszName)
00247 {
00248     int rc = 0;
00249 
00250     LPCONFIG_FILE pFile = NULL;
00251 
00252     /* Alloc storage */
00253     pFile = (LPCONFIG_FILE) calloc(1, sizeof(CONFIG_FILE));
00254 
00255     /* Initialise */
00256     pFile->pszFileName = strdup(pszName);
00257     vectorCreate(&(pFile->pDisplays));
00258 
00259     /* Return to caller */
00260     *ppFile = pFile;
00261 
00262     return rc;
00263 }
00264 
00265 
00266 int configFileGetDisplayCount(LPCONFIG_FILE pConfig, int * pnCount)
00267 {
00268     int rc = 0;
00269     int nCount = 0;
00270 
00271     IILC_TRACE_ENTRY(IILC_MODULE, T_configGetDisplayCount);
00272     traceDebug(IILC_TRACE_CONTEXT, "pConfig %p, pnCount %p", pConfig, pnCount);
00273 
00274     if (pnCount == NULL) {
00275         rc = ERR_BAD_PARAMETER;
00276         goto end_of_function;
00277     }
00278 
00279     rc = vectorGetSize(pConfig->pDisplays, &nCount);
00280     if (rc) {
00281         goto end_of_function;
00282     }
00283 
00284     *pnCount = nCount;
00285     traceDebug(IILC_TRACE_CONTEXT, "*pnCount %d", *pnCount);
00286 
00287 end_of_function:
00288 
00289     IILC_TRACE_EXIT_RC(rc);
00290     return rc;
00291 }
00292 
00293 
00294 
00295 int configFileGetDisplay(LPCONFIG_FILE pFile, int nIndex, LPCONFIG_DISPLAY * ppDisplay)
00296 {
00297     int rc = 0;
00298 
00299     vectorGetElementAt(pFile->pDisplays, nIndex, (void **) ppDisplay);
00300 
00301     return rc;
00302 }
00303 
00304 
00305 
00306 int configFileAddDisplay(LPCONFIG_FILE pFile, LPCONFIG_DISPLAY pDisplay)
00307 {
00308     int rc = 0;
00309 
00310     vectorAdd(pFile->pDisplays, pDisplay);
00311 
00312     return rc;
00313 }
00314 
00315 int configFileValidate(LPCONFIG_FILE pFile)
00316 {
00317     int rc = 0;
00318 
00319     return rc = 0;
00320 }
00321 
00322 
00323 
00324 int configFileDispose(LPCONFIG_FILE * ppInst)
00325 {
00326     LPCONFIG_FILE pConfig = *ppInst;
00327     int count = 0;
00328     int i = 0;
00329     int rc = 0;
00330 
00331     vectorGetSize(pConfig->pDisplays, &count);
00332 
00333     /* Destory each display */
00334     for (i = 0; (i < count) && (rc == 0); i++) {
00335 
00336         LPCONFIG_DISPLAY pDisplay = NULL;
00337 
00338         rc = vectorGetElementAt(pConfig->pDisplays, i, (void **) &pDisplay);
00339 
00340         /* Remove from vector */
00341         vectorRemove(pConfig->pDisplays, pDisplay);
00342 
00343         /* Dispose of the display */
00344         configDisplayDispose(&pDisplay);
00345     }
00346 
00347     /* Dispose of vector list */
00348     vectorDestroy(&(pConfig->pDisplays));
00349 
00350     if (pConfig->pszFileName) free(pConfig->pszFileName);
00351 
00352     /* Release structure's memory */
00353     free(pConfig);
00354 
00355     /* Wipe user's reference */
00356     *ppInst = NULL;
00357 
00358     return 0;
00359 }
00360 
00361 
00362 /****************************************************************************/
00363 /*                                                                          */
00364 /* Config display functions                                                 */
00365 /*                                                                          */
00366 /****************************************************************************/
00367 
00368 
00369 int configDisplayCreate(LPCONFIG_DISPLAY * ppDisplay, const char * pszDisplay)
00370 {
00371     int rc = 0;
00372     LPCONFIG_DISPLAY pDisplay = NULL;
00373 
00374     /* Allocate storage */
00375     pDisplay = (LPCONFIG_DISPLAY) calloc(1, sizeof(CONFIG_DISPLAY));
00376     pDisplay->pszName = strdup(pszDisplay);
00377     vectorCreate(&(pDisplay->pModuleList));
00378     vectorCreate(&(pDisplay->pScreenList));
00379 
00380     /* Return to caller */
00381     *ppDisplay = pDisplay;
00382 
00383     return rc;
00384 }
00385 
00386 
00387 int configDisplayGetDevice(LPCONFIG_DISPLAY pDisplay, LPCONFIG_DEVICE * ppDevice)
00388 {
00389     int rc = 0;
00390 
00391 
00392     *ppDevice = pDisplay->pDevice;
00393 
00394 
00395     return rc;
00396 }
00397 
00398 
00399 int configDisplaySetDevice(LPCONFIG_DISPLAY pDisplay, LPCONFIG_DEVICE pDevice)
00400 {
00401     int rc = 0;
00402 
00403     pDisplay->pDevice = pDevice;
00404 
00405     return rc;
00406 }
00407 
00408 int configDisplayAddModule(LPCONFIG_DISPLAY pDisplay, LPCONFIG_MODULE pModule)
00409 {
00410     int rc = 0;
00411 
00412     vectorAdd(pDisplay->pModuleList, pModule);
00413 
00414     return rc;
00415 }
00416 
00417 int configDisplayGetModuleCount(LPCONFIG_DISPLAY pDisplay, int * pnCount)
00418 {
00419     int rc = 0;
00420 
00421     vectorGetSize(pDisplay->pModuleList, pnCount);
00422 
00423     return rc;
00424 }
00425 
00426 int configDisplayGetModule(LPCONFIG_DISPLAY pDisplay, int index, LPCONFIG_MODULE * ppModule)
00427 {
00428     int rc = 0;
00429 
00430     vectorGetElementAt(pDisplay->pModuleList, index, (void **) ppModule);
00431 
00432     return rc;
00433 }
00434 
00435 int configDisplayAddScreen(LPCONFIG_DISPLAY pDisplay, LPCONFIG_SCREEN pScreen)
00436 {
00437     int rc = 0;
00438 
00439     vectorAdd(pDisplay->pScreenList, pScreen);
00440 
00441     return rc;
00442 }
00443 
00444 int configDisplayGetScreenCount(LPCONFIG_DISPLAY pDisplay, int * pnCount)
00445 {
00446     int rc = 0;
00447 
00448     vectorGetSize(pDisplay->pScreenList, pnCount);
00449 
00450     return rc;
00451 }
00452 
00453 int configDisplayGetScreen(LPCONFIG_DISPLAY pDisplay, int nIndex, LPCONFIG_SCREEN * ppScreen)
00454 {
00455     int rc = 0;
00456 
00457     vectorGetElementAt(pDisplay->pScreenList, nIndex, (void **) ppScreen);
00458 
00459     return rc;
00460 }
00461 
00462 int configDisplayDispose(LPCONFIG_DISPLAY * ppDisplay)
00463 {
00464     int rc = 0;
00465     LPCONFIG_DISPLAY pDisplay = NULL;
00466 
00467     pDisplay = *ppDisplay;
00468 
00469     configDeviceDispose(&(pDisplay->pDevice));
00470 
00471     vectorDestroy(&(pDisplay->pModuleList));
00472     vectorDestroy(&(pDisplay->pScreenList));
00473 
00474     free((char *) pDisplay->pszName);
00475 
00476     free(pDisplay);
00477 
00478     return rc;
00479 }
00480 
00481 
00482 /****************************************************************************/
00483 /*                                                                          */
00484 /* Config device functions                                                  */
00485 /*                                                                          */
00486 /****************************************************************************/
00487 
00488 
00489 
00490 
00491 int configDeviceCreate(LPCONFIG_DEVICE * ppDevice, const char * pszDevice)
00492 {
00493     int rc = 0;
00494     LPCONFIG_DEVICE pDevice = NULL;
00495 
00496     /* Create new device & init */
00497     pDevice = (LPCONFIG_DEVICE) calloc(1, sizeof(CONFIG_DEVICE));
00498     if (pDevice == NULL) {
00499         rc = ERR_MEM_ALLOC_FAILED;
00500         goto end_of_function;
00501     }
00502 
00503     /* Initialise the structure */
00504     pDevice->pszName = strdup(pszDevice);
00505     if (pDevice->pszName == NULL) {
00506         rc = ERR_MEM_ALLOC_FAILED;
00507         goto end_of_function;
00508     }
00509 
00510     vectorCreate(&(pDevice->pObjectList));
00511 
00512     /* Return to the user */
00513     *ppDevice = pDevice;
00514 
00515 end_of_function:
00516 
00517     return rc;
00518 }
00519 
00520 
00521 
00522 
00523 int configDeviceUseObject(LPCONFIG_DEVICE pDevice, enum displayObjectType type, 
00524                           int physical_id, const char * pszName)
00525 {
00526     int rc = 0;
00527     LPCONFIG_OBJECT pObject = NULL;
00528 
00529     /* Create this new object */
00530     configObjectCreate(&pObject, type, physical_id, pszName);
00531 
00532     /* Check this sensor ID has not been used */
00533 
00534 
00535     /* Add this object to the device */
00536     vectorAdd(pDevice->pObjectList, (void *) pObject);
00537 
00538     return rc;
00539 }
00540 
00541 int configDeviceSetClass(LPCONFIG_DEVICE pDevice, const char * pszClass)
00542 {
00543     int rc = 0;
00544 
00545     pDevice->pszClass = strdup(pszClass);
00546 
00547     return rc;
00548 }
00549 
00550 int configDeviceSetPort(LPCONFIG_DEVICE pDevice, const char * pszPort)
00551 {
00552     int rc = 0;
00553 
00554     pDevice->pszPort = strdup(pszPort);
00555 
00556     return rc;
00557 }
00558 
00559 int configDeviceGetClass(LPCONFIG_DEVICE pDevice, char ** ppszClass)
00560 {
00561     int rc = 0;
00562 
00563     *ppszClass = pDevice->pszClass;
00564 
00565     return rc;
00566 }
00567 
00568 
00569 int configDeviceGetPort(LPCONFIG_DEVICE pDevice, char ** ppszPort)
00570 {
00571     int rc = 0;
00572 
00573     *ppszPort = pDevice->pszPort;
00574 
00575     return rc;
00576 }
00577 
00578 int configDeviceDispose(LPCONFIG_DEVICE * ppDevice)
00579 {
00580     int rc = 0;
00581     LPCONFIG_DEVICE pDevice = NULL;
00582 
00583     pDevice = *ppDevice;
00584 
00585     vectorDestroy(&(pDevice->pObjectList));
00586 
00587     if (pDevice->pszClass) free(pDevice->pszClass);
00588     if (pDevice->pszName)  free(pDevice->pszName);
00589     if (pDevice->pszPort)  free(pDevice->pszPort);
00590 
00591     free(pDevice);
00592 
00593     return rc;
00594 }
00595 
00596 /****************************************************************************/
00597 /*                                                                          */
00598 /* Config module functions                                                  */
00599 /*                                                                          */
00600 /****************************************************************************/
00601 
00602 int configModuleCreate(LPCONFIG_MODULE * ppModule, const char * pszModule)
00603 {
00604     int rc = 0;
00605     LPCONFIG_MODULE pModule = NULL;
00606 
00607     /* Create the new struct */
00608     pModule = (LPCONFIG_MODULE) calloc(1, sizeof(CONFIG_MODULE));
00609     if (pModule == NULL) {
00610         rc = ERR_MEM_ALLOC_FAILED;
00611         goto end_of_function;
00612     }
00613 
00614     /* Init */
00615     pModule->pszModuleName = strdup(pszModule);
00616     if (pModule->pszModuleName == NULL) {
00617         rc = ERR_MEM_ALLOC_FAILED;
00618         goto end_of_function;
00619     }
00620 
00621     vectorCreate(&(pModule->pControlList));
00622     vectorCreate(&(pModule->pReportList));
00623 
00624     /* Return to the user */
00625     *ppModule = pModule;
00626 
00627 end_of_function:
00628 
00629     return rc;
00630 }
00631 
00632 
00633 int configModuleGetLibrary(LPCONFIG_MODULE pModule, const char ** ppszName)
00634 {
00635     int rc = 0;
00636 
00637     IILC_TRACE_ENTRY(IILC_MODULE, T_configGetModuleName);
00638     traceDebug(IILC_TRACE_CONTEXT, "pModule %p, ppszName %p", pModule, ppszName);
00639 
00640     if (pModule == NULL) {
00641         traceError(IILC_TRACE_CONTEXT, "pModule == NULL");
00642         rc = ERR_BAD_PARAMETER;
00643         goto end_of_function;
00644     }
00645 
00646     if (ppszName == NULL) {
00647         traceError(IILC_TRACE_CONTEXT, "ppszName == NULL");
00648         rc = ERR_BAD_PARAMETER;
00649         goto end_of_function;
00650     }
00651 
00652     *ppszName = pModule->pszLibraryName;
00653 
00654 end_of_function:
00655 
00656     IILC_TRACE_EXIT_RC(rc);
00657     return rc;
00658 }
00659 
00660 
00661 int configModuleReportObject(LPCONFIG_MODULE pModule, enum displayObjectType type, 
00662                              int object_id, const char * pszReportAs)
00663 {
00664     int rc = 0;
00665     LPCONFIG_OBJECT pObject = NULL;
00666 
00667     /* Create a new object */
00668     configObjectCreate(&pObject, type, object_id, pszReportAs);
00669 
00670     /* Add this object to the list of reports the module requires */
00671     vectorAdd(pModule->pReportList, pObject);
00672 
00673     return rc;
00674 }
00675 
00676 
00677 int configModuleControlObject(LPCONFIG_MODULE pModule, enum displayObjectType type, int object_id)
00678 {
00679     int rc = 0;
00680     LPCONFIG_OBJECT pObject = NULL;
00681 
00682     /* Create a new object */
00683     configObjectCreate(&pObject, type, object_id, NULL);
00684 
00685     /* Add this object to the list of objects this module controls */
00686     vectorAdd(pModule->pControlList, pObject);
00687 
00688     return rc;
00689 }
00690 
00691 int configModuleVirtualObject(LPCONFIG_MODULE pModule, int module_id, int device_id, const char * pszObject)
00692 {
00693     int rc = 0;
00694 
00695     return rc;
00696 }
00697 
00698 
00699 int configModuleSetLibrary(LPCONFIG_MODULE pModule, const char * pszLibrary)
00700 {
00701     int rc = 0;
00702 
00703     pModule->pszLibraryName = strdup(pszLibrary);
00704 
00705     return rc;
00706 }
00707 
00708 
00709 int configModuleGetReportCount(LPCONFIG_MODULE pModule, int * pnCount)
00710 {
00711     int rc = 0;
00712 
00713     vectorGetSize(pModule->pReportList, pnCount);
00714 
00715     return rc;
00716 }
00717 
00718 int configModuleGetReportObject(LPCONFIG_MODULE pModule, int index, LPCONFIG_OBJECT * ppObject)
00719 {
00720     int rc = 0;
00721 
00722     vectorGetElementAt(pModule->pReportList, index, (void **) ppObject);
00723 
00724     return rc;
00725 }
00726 
00727 
00728 
00729 
00730 
00731 
00732 
00733 
00734 
00735 
00736 /****************************************************************************/
00737 /*                                                                          */
00738 /* Config screen functions                                                  */
00739 /*                                                                          */
00740 /****************************************************************************/
00741 
00742 
00743 int configScreenCreate(LPCONFIG_SCREEN * ppScreen, const char * pszScreen)
00744 {
00745     int rc = 0;
00746     LPCONFIG_SCREEN pScreen = NULL;
00747 
00748     pScreen = (LPCONFIG_SCREEN) calloc(1, sizeof(CONFIG_SCREEN));
00749     vectorCreate(&(pScreen->pWindowList));
00750     pScreen->pszScreen = strdup(pszScreen);
00751 
00752     *ppScreen = pScreen;
00753 
00754     return rc;
00755 }
00756 
00757 
00758 int configScreenShowModule(LPCONFIG_SCREEN pScreen, const char * pszModule, 
00759                            int size_x, int size_y, int pos_x, int pos_y)
00760 {
00761     int rc = 0;
00762     LPCONFIG_WINDOW pWindow = NULL;
00763 
00764     /* Create a new window using this data */
00765     configWindowCreate(&pWindow, size_x, size_y, pos_x, pos_y, pszModule);
00766 
00767     /* Add this window to the screen */
00768     vectorAdd(pScreen->pWindowList, pWindow);
00769 
00770     return rc;
00771 }
00772 
00773 int configScreenGetWindowCount(LPCONFIG_SCREEN pScreen, int * pnCount)
00774 {
00775     int rc = 0;
00776 
00777     vectorGetSize(pScreen->pWindowList, pnCount);
00778 
00779     return rc;
00780 }
00781 
00782 int configScreenGetWindow(LPCONFIG_SCREEN pScreen, int nIndex, LPCONFIG_WINDOW * ppWindow)
00783 {
00784     int rc = 0;
00785 
00786     vectorGetElementAt(pScreen->pWindowList, nIndex, (void **) ppWindow);
00787 
00788     return rc;
00789 }
00790 
00791 int configScreenDispose(LPCONFIG_SCREEN * ppScreen)
00792 {
00793     int rc = 0;
00794     LPCONFIG_SCREEN pScreen = NULL;
00795 
00796     pScreen = *ppScreen;
00797 
00798     if (pScreen->pszScreen != NULL) free(pScreen->pszScreen);
00799     if (pScreen->pWindowList != NULL) {
00800 
00801         int i, nCount = 0;
00802 
00803         /* Cleanly dispose of all child windows */
00804         vectorGetSize(pScreen->pWindowList, &nCount);
00805         for (i = 0; i < nCount; i++) {
00806             LPCONFIG_WINDOW pWindow = NULL;
00807             vectorGetElementAt(pScreen->pWindowList, i, (void **) &pWindow);
00808             configWindowDispose(&pWindow);
00809         }
00810 
00811         /* Clean up the internal list */
00812         vectorDestroy(&(pScreen->pWindowList));
00813     }
00814 
00815     free(pScreen);
00816 
00817     return rc;
00818 }
00819 
00820 
00821 
00822 /****************************************************************************/
00823 /*                                                                          */
00824 /* Config window functions                                                  */
00825 /*                                                                          */
00826 /****************************************************************************/
00827 
00828 int configWindowCreate(LPCONFIG_WINDOW * ppWindow, int width, int height, 
00829                        int x, int y, const char * pszModule)
00830 {
00831     int rc = 0;
00832     LPCONFIG_WINDOW pWindow = NULL;
00833 
00834     pWindow = (LPCONFIG_WINDOW) calloc(1, sizeof(CONFIG_WINDOW));
00835     pWindow->width     = width;
00836     pWindow->height    = height;
00837     pWindow->x         = x;
00838     pWindow->y         = y;
00839     pWindow->pszModule = strdup(pszModule);
00840 
00841     *ppWindow = pWindow;
00842 
00843     return rc;
00844 }
00845 
00846 int configWindowGetLocation(LPCONFIG_WINDOW pWindow, int * pnX, int * pnY)
00847 {
00848     int rc = 0;
00849 
00850     *pnX = pWindow->x;
00851     *pnY = pWindow->y;
00852 
00853     return rc;
00854 }
00855 
00856 int configWindowGetSize(LPCONFIG_WINDOW pWindow, int * pnWidth, int * pnHeight)
00857 {
00858     int rc = 0;
00859 
00860     *pnWidth  = pWindow->width;
00861     *pnHeight = pWindow->height;
00862 
00863     return rc;
00864 }
00865 
00866 int configWindowGetModuleName(LPCONFIG_WINDOW pWindow, const char ** ppszModuleName)
00867 {
00868     int rc = 0;
00869 
00870     *ppszModuleName = pWindow->pszModule;
00871 
00872     return rc;
00873 }
00874 
00875 int configWindowDispose(LPCONFIG_WINDOW * ppWindow)
00876 {
00877     int rc = 0;
00878 
00879     free(*ppWindow);
00880 
00881     return rc;
00882 }
00883 
00884 /****************************************************************************/
00885 /*                                                                          */
00886 /* Config object functions                                                  */
00887 /*                                                                          */
00888 /****************************************************************************/
00889 
00890 int configObjectCreate(LPCONFIG_OBJECT * ppObject, enum displayObjectType type, 
00891                        int physical_id, const char * pszName)
00892 {
00893     int rc = 0;
00894     LPCONFIG_OBJECT pObject = NULL;
00895 
00896     IILC_TRACE_ENTRY(IILC_MODULE, T_parserDeviceCreateObject);
00897 
00898     /* Alloc and init the structure */
00899     pObject = (LPCONFIG_OBJECT) calloc(1, sizeof(CONFIG_OBJECT));
00900     if (pObject == NULL) {
00901         rc = ERR_MEM_ALLOC_FAILED;
00902         goto end_of_function;
00903     }
00904 
00905     /* init */
00906     pObject->physical_id        = physical_id;
00907     pObject->pszName            = pszName;
00908     pObject->type               = type;
00909     pObject->nModuleControlAsID = 0;
00910     pObject->pControllingModule = NULL;
00911     pObject->pReportIDList      = NULL;
00912     pObject->pReportModulesList = NULL;
00913 
00914     /* Vector inits */
00915     rc = vectorCreate(&(pObject->pReportIDList));
00916     if (rc) { goto end_of_function; }
00917 
00918     rc = vectorCreate(&(pObject->pReportModulesList));
00919     if (rc) { goto end_of_function; }
00920 
00921     /* Return to the caller */
00922     *ppObject = pObject;
00923 
00924 end_of_function:
00925 
00926     IILC_TRACE_EXIT_RC(rc);
00927     return (rc);
00928 }
00929 
00930 int configObjectGetId(LPCONFIG_OBJECT pObject, unsigned int * pnId)
00931 {
00932     int rc = 0;
00933 
00934     *pnId = pObject->physical_id;
00935 
00936     return rc;
00937 }
00938 
00939 int configObjectGetName(LPCONFIG_OBJECT pObject, char ** pszName)
00940 {
00941     int rc = 0;
00942 
00943     if (pObject->pszName != NULL) {
00944         *pszName = strdup(pObject->pszName);
00945     }
00946     else {
00947         *pszName = NULL;
00948     }
00949 
00950     return rc;
00951 }
00952 
00953 int configObjectGetType(LPCONFIG_OBJECT pObject, enum displayObjectType * pType)
00954 {
00955     int rc = 0;
00956 
00957     *pType = pObject->type;
00958 
00959     return rc;
00960 }
00961 
00962 
00963 

Generated on Mon Jul 17 01:36:11 2006 for IILC by  doxygen 1.4.6