Ignore:
Timestamp:
Feb 12, 2015, 5:01:11 PM (9 years ago)
Author:
djay
Message:

Add initial doxygen comments in some C files, for future documentation generation.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/zoo-project/zoo-kernel/service_internal.c

    r578 r579  
    1 /**
     1/*
    22 * Author : Gérald FENOY
    33 *
     
    4343#define ERROR_MSG_MAX_LENGTH 1024
    4444
     45/**
     46 * Verify if a given language is listed in the lang list defined in the [main]
     47 * section of the main.cfg file.
     48 *
     49 * @param conf the map containing the settings from the main.cfg file
     50 * @param str the specific language
     51 * @return 1 if the specific language is listed, -1 in other case.
     52 */
    4553int isValidLang(maps* conf,const char *str){
    4654  map *tmpMap=getMapFromMaps(conf,"main","lang");
     
    5967}
    6068
     69/**
     70 * Print the HTTP headers based on a map.
     71 *
     72 * @param m the map containing the headers informations
     73 */
    6174void printHeaders(maps* m){
    6275  maps *_tmp=getMaps(m,"headers");
     
    7083}
    7184
     85/**
     86 * Add a land attribute to a XML node
     87 *
     88 * @param n the XML node to add the attribute
     89 * @param m the map containing the language key to add as xml:lang
     90 */
    7291void addLangAttr(xmlNodePtr n,maps *m){
    7392  map *tmpLmap=getMapFromMaps(m,"main","language");
     
    7897}
    7998
    80 /* Converts a hex character to its integer value */
     99/**
     100 * Converts a hex character to its integer value
     101 *
     102 * @param ch the char to convert
     103 * @return the converted char
     104 */
    81105char from_hex(char ch) {
    82106  return isdigit(ch) ? ch - '0' : tolower(ch) - 'a' + 10;
    83107}
    84108
    85 /* Converts an integer value to its hex character*/
     109/**
     110 * Converts an integer value to its hec character
     111 *
     112 * @param code the char to convert
     113 * @return the converted char
     114 */
    86115char to_hex(char code) {
    87116  static char hex[] = "0123456789abcdef";
     
    89118}
    90119
     120/**
     121 * Get the ongoing status of a running service
     122 *
     123 * @param conf the maps containing the setting of the main.cfg file
     124 * @param pid the service identifier (usid key from the [lenv] section)
     125 * @return the reported status char* (MESSAGE|POURCENTAGE)
     126 */
    91127char* _getStatus(maps* conf,int pid){
    92128  char lid[1024];
     
    131167
    132168size_t getKeyValue(maps* conf, char* key, size_t length){
    133  
    134169  if(conf==NULL) {
    135         strncpy(key, "700666", length);
    136         return strlen(key);
     170    strncpy(key, "700666", length);
     171    return strlen(key);
    137172  }
    138173 
     
    148183  }
    149184  return strlen(key);
    150 }
     185}
     186
     187
    151188semid getShmLockId(maps* conf, int nsems){
    152189    semid sem_id;
     
    336373
    337374#else
    338 
     375/**
     376 * Number of time to try to access a semaphores set
     377 * @see getShmLockId
     378 */
    339379#define MAX_RETRIES 10
    340380
     
    347387#endif
    348388
     389/**
     390 * Set in the pre-allocated key the zoo_sem_[SID] string
     391 * where [SID] is the lid (if any) or usid value from the [lenv] section.
     392 *
     393 * @param conf the map containing the setting of the main.cfg file
     394 */
    349395int getKeyValue(maps* conf){
    350396  if(conf==NULL)
     
    359405}
    360406
     407/**
     408 * Try to create or access a semaphore set.
     409 *
     410 * @see getKeyValue
     411 * @param conf the map containing the setting of the main.cfg file
     412 * @param nsems number of semaphores
     413 * @return a semaphores set indentifier on success, -1 in other case
     414 */
    361415int getShmLockId(maps* conf, int nsems){
    362416    int i;
     
    422476}
    423477
     478/**
     479 * Try to remove a semaphore set.
     480 *
     481 * @param conf the map containing the setting of the main.cfg file
     482 * @param nsems number of semaphores
     483 * @return 0 if the semaphore can be removed, -1 in other case.
     484 */
    424485int removeShmLock(maps* conf, int nsems){
    425486  union semun arg;
     
    432493}
    433494
     495/**
     496 * Lock a semaphore set.
     497 *
     498 * @param id the semaphores set indetifier
     499 * @return 0 if the semaphore can be locked, -1 in other case.
     500 */
    434501int lockShm(int id){
    435502  struct sembuf sb;
     
    444511}
    445512
     513/**
     514 * unLock a semaphore set.
     515 *
     516 * @param id the semaphores set indetifier
     517 * @return 0 if the semaphore can be locked, -1 in other case.
     518 */
    446519int unlockShm(int id){
    447520  struct sembuf sb;
     
    456529}
    457530
     531/**
     532 * Stop handling status repport.
     533 *
     534 * @param conf the map containing the setting of the main.cfg file
     535 */
    458536void unhandleStatus(maps *conf){
    459537  int shmid;
     
    481559}
    482560
     561/**
     562 * Update the current of the running service.
     563 *
     564 * @see getKeyValue, getShmLockId, lockShm
     565 * @param conf the map containing the setting of the main.cfg file
     566 * @return 0 on success, -2 if shmget failed, -1 if shmat failed
     567 */
    483568int _updateStatus(maps *conf){
    484569  int shmid;
     
    528613}
    529614
     615/**
     616 * Update the current of the running service.
     617 *
     618 * @see getKeyValue, getShmLockId, lockShm
     619 * @param pid the semaphores
     620 * @return 0 on success, -2 if shmget failed, -1 if shmat failed
     621 */
    530622char* getStatus(int pid){
    531623  int shmid;
     
    594686
    595687
    596 
    597 /* Returns a url-encoded version of str */
    598 /* IMPORTANT: be sure to free() the returned string after use */
     688/**
     689 * URLEncode an url
     690 *
     691 * @param str the url to encode
     692 * @return a url-encoded version of str
     693 * @warning be sure to free() the returned string after use
     694 */
    599695char *url_encode(char *str) {
    600696  char *pstr = str, *buf = (char*) malloc(strlen(str) * 3 + 1), *pbuf = buf;
     
    612708}
    613709
    614 /* Returns a url-decoded version of str */
    615 /* IMPORTANT: be sure to free() the returned string after use */
     710/**
     711 * Decode an URLEncoded url
     712 *
     713 * @param str the URLEncoded url to decode
     714 * @return a url-decoded version of str
     715 * @warning be sure to free() the returned string after use
     716 */
    616717char *url_decode(char *str) {
    617718  char *pstr = str, *buf = (char*) malloc(strlen(str) + 1), *pbuf = buf;
     
    633734}
    634735
     736/**
     737 * Replace the first letter by its upper case version in a new char array
     738 *
     739 * @param tmp the char*
     740 * @return a new char* with first letter in upper case
     741 * @warning be sure to free() the returned string after use
     742 */
    635743char *zCapitalize1(char *tmp){
    636744  char *res=zStrdup(tmp);
     
    640748}
    641749
     750/**
     751 * Replace all letters by their upper case version in a new char array
     752 *
     753 * @param tmp the char*
     754 * @return a new char* with first letter in upper case
     755 * @warning be sure to free() the returned string after use
     756 */
    642757char *zCapitalize(char *tmp){
    643758  int i=0;
     
    649764}
    650765
    651 
     766/**
     767 * Search for an existing XML namespace in usedNS.
     768 *
     769 * @param name the name of the XML namespace to search
     770 * @return the index of the XML namespace found or -1 if not found.
     771 */
    652772int zooXmlSearchForNs(const char* name){
    653773  int i;
     
    661781}
    662782
     783/**
     784 * Add an XML namespace to the usedNS if it was not already used.
     785 *
     786 * @param nr the xmlNodePtr to attach the XML namspace (can be NULL)
     787 * @param url the url of the XML namespace to add
     788 * @param name the name of the XML namespace to add
     789 * @return the index of the XML namespace added.
     790 */
    663791int zooXmlAddNs(xmlNodePtr nr,const char* url,const char* name){
    664792#ifdef DEBUG
     
    683811}
    684812
     813/**
     814 * Free allocated memory to store used XML namespace.
     815 */
    685816void zooXmlCleanupNs(){
    686817  int j;
     
    700831}
    701832
    702 
     833/**
     834 * Add a XML document to the iDocs.
     835 *
     836 * @param value the string containing the XML document
     837 * @return the index of the XML document added.
     838 */
    703839int zooXmlAddDoc(const char* value){
    704840  int currId=0;
     
    709845}
    710846
     847/**
     848 * Free allocated memort to store XML documents
     849 */
    711850void zooXmlCleanupDocs(){
    712851  int j;
     
    716855  nbDocs=0;
    717856}
    718 
    719 
    720 /************************************************************************/
    721 /*                             soapEnvelope()                           */
    722 /************************************************************************/
    723857
    724858/**
     
    755889}
    756890
    757 /************************************************************************/
    758 /*                            printWPSHeader()                          */
    759 /************************************************************************/
    760 
    761891/**
    762892 * Generate a WPS header.
     
    794924  return n;
    795925}
    796 
    797 /************************************************************************/
    798 /*                     printGetCapabilitiesHeader()                     */
    799 /************************************************************************/
    800926
    801927/**
     
    10951221}
    10961222
    1097 
     1223/**
     1224 * Add prefix to the service name.
     1225 *
     1226 * @param conf the conf maps containing the main.cfg settings
     1227 * @param level the map containing the level information
     1228 * @param serv the service structure created from the zcfg file
     1229 */
    10981230void addPrefix(maps* conf,map* level,service* serv){
    10991231  if(level!=NULL){
     
    11281260}
    11291261
     1262/**
     1263 * Generate a wps:Process node for a servie and add it to a given node.
     1264 *
     1265 * @param m the conf maps containing the main.cfg settings
     1266 * @param nc the XML node to add the Process node
     1267 * @param serv the service structure created from the zcfg file
     1268 * @return the generated wps:ProcessOfferings xmlNodePtr
     1269 */
    11301270void printGetCapabilitiesForProcess(maps* m,xmlNodePtr nc,service* serv){
    11311271  xmlNsPtr ns,ns_ows,ns_xlink;
     
    11611301}
    11621302
     1303/**
     1304 * Generate a ProcessDescription node for a servie and add it to a given node.
     1305 *
     1306 * @param m the conf maps containing the main.cfg settings
     1307 * @param nc the XML node to add the Process node
     1308 * @param serv the servive structure created from the zcfg file
     1309 * @return the generated wps:ProcessOfferings xmlNodePtr
     1310 */
    11631311void printDescribeProcessForProcess(maps* m,xmlNodePtr nc,service* serv){
    11641312  xmlNsPtr ns,ns_ows,ns_xlink;
     
    12301378}
    12311379
     1380/**
     1381 * Generate the required XML tree for the detailled metadata informations of
     1382 * inputs or outputs
     1383 *
     1384 * @param in 1 in case of inputs, 0 for outputs
     1385 * @param elem the elements structure containing the metadata informations
     1386 * @param type the name ("Input" or "Output") of the XML node to create
     1387 * @param ns_ows the ows XML namespace
     1388 * @param nc1 the XML node to use to add the created tree
     1389 */
    12321390void printFullDescription(int in,elements *elem,const char* type,xmlNsPtr ns_ows,xmlNodePtr nc1){
    12331391  const char *orderedFields[13];
     
    16861844}
    16871845
     1846/**
     1847 * Generate a wps:Execute XML document.
     1848 *
     1849 * @param m the conf maps containing the main.cfg settings
     1850 * @param request the map representing the HTTP request
     1851 * @param pid the process identifier linked to a service
     1852 * @param serv the serv structure created from the zcfg file
     1853 * @param service the service name
     1854 * @param status the status returned by the service
     1855 * @param inputs the inputs provided
     1856 * @param outputs the outputs generated by the service
     1857 */
    16881858void printProcessResponse(maps* m,map* request, int pid,service* serv,const char* service,int status,maps* inputs,maps* outputs){
    16891859  xmlNsPtr ns,ns_ows,ns_xlink;
     
    19662136}
    19672137
    1968 
     2138/**
     2139 * Print a XML document.
     2140 *
     2141 * @param m the conf maps containing the main.cfg settings
     2142 * @param doc the XML document
     2143 * @param pid the process identifier linked to a service
     2144 */
    19692145void printDocument(maps* m, xmlDocPtr doc,int pid){
    19702146  char *encoding=getEncoding(m);
     
    19922168}
    19932169
     2170/**
     2171 * Print a XML document.
     2172 *
     2173 * @param doc the XML document (unused)
     2174 * @param nc the XML node to add the output definition
     2175 * @param ns_wps the wps XML namespace
     2176 * @param ns_ows the ows XML namespace
     2177 * @param e the output elements
     2178 * @param m the conf maps containing the main.cfg settings
     2179 * @param type the type (unused)
     2180 */
    19942181void printOutputDefinitions(xmlDocPtr doc,xmlNodePtr nc,xmlNsPtr ns_wps,xmlNsPtr ns_ows,elements* e,maps* m,const char* type){
    19952182  xmlNodePtr nc1;
     
    20242211}
    20252212
     2213/**
     2214 * Generate XML nodes describing inputs or outputs metadata.
     2215 *
     2216 * @param doc the XML document
     2217 * @param nc the XML node to add the definition
     2218 * @param ns_wps the wps namespace
     2219 * @param ns_ows the ows namespace
     2220 * @param ns_xlink the xlink namespace
     2221 * @param e the output elements
     2222 * @param m the conf maps containing the main.cfg settings
     2223 * @param type the type
     2224 */
    20262225void printIOType(xmlDocPtr doc,xmlNodePtr nc,xmlNsPtr ns_wps,xmlNsPtr ns_ows,xmlNsPtr ns_xlink,elements* e,maps* m,const char* type){
    20272226  xmlNodePtr nc1,nc2,nc3;
     
    22582457}
    22592458
     2459/**
     2460 * Create XML node with basic ows metadata informations (Identifier,Title,Abstract)
     2461 *
     2462 * @param root the root XML node to add the description
     2463 * @param ns_ows the ows XML namespace
     2464 * @param identifier the identifier to use
     2465 * @param amap the map containing the ows metadata informations
     2466 */
    22602467void printDescription(xmlNodePtr root,xmlNsPtr ns_ows,const char* identifier,map* amap){
    22612468  xmlNodePtr nc2 = xmlNewNode(ns_ows, BAD_CAST "Identifier");
     
    22782485}
    22792486
     2487/**
     2488 * Access the value of the encoding key in a maps
     2489 *
     2490 * @param m the maps to search for the encoding key
     2491 * @return the value of the encoding key in a maps if encoding key exists,
     2492 *  "UTF-8" in other case.
     2493 */
    22802494char* getEncoding(maps* m){
    22812495  if(m!=NULL){
     
    22912505}
    22922506
     2507/**
     2508 * Access the value of the version key in a maps
     2509 *
     2510 * @param m the maps to search for the version key
     2511 * @return the value of the version key in a maps if encoding key exists,
     2512 *  "1.0.0" in other case.
     2513 */
    22932514char* getVersion(maps* m){
    22942515  if(m!=NULL){
     
    23042525}
    23052526
    2306 /************************************************************************/
    2307 /*                    printExceptionReportResponse()                    */
    2308 /************************************************************************/
    2309 
    23102527/**
    23112528 * Print an OWS ExceptionReport Document and HTTP headers (when required)
     
    23132530 * Set hasPrinted value to true in the [lenv] section.
    23142531 *
    2315  * @param m the conf maps
     2532 * @param m the maps containing the settings of the main.cfg file
    23162533 * @param s the map containing the text,code,locator keys
    23172534 */
     
    23752592    setMapInMaps(m,"lenv","hasPrinted","true");
    23762593}
    2377 
    2378 /************************************************************************/
    2379 /*                      createExceptionReportNode()                     */
    2380 /************************************************************************/
    23812594
    23822595/**
     
    24482661}
    24492662
    2450 /************************************************************************/
    2451 /*                           errorException()                           */
    2452 /************************************************************************/
    2453 
    24542663/**
    24552664 * Print an OWS ExceptionReport.
     
    24742683}
    24752684
    2476 /************************************************************************/
    2477 /*                          readGeneratedFile()                         */
    2478 /************************************************************************/
    2479 
    24802685/**
    24812686 * Read a file generated by a service.
     
    25112716}
    25122717
     2718/**
     2719 * Generate the output response (RawDataOutput or ResponseDocument)
     2720 *
     2721 * @param s the service structure containing the metadata informations
     2722 * @param request_inputs the inputs provided to the service for execution
     2723 * @param request_outputs the outputs updated by the service execution
     2724 * @param request_inputs1 the map containing the HTTP request
     2725 * @param cpid the process identifier attached to a service execution
     2726 * @param m the conf maps containing the main.cfg settings
     2727 * @param res the value returned by the service execution
     2728 */
    25132729void outputResponse(service* s,maps* request_inputs,maps* request_outputs,
    25142730                    map* request_inputs1,int cpid,maps* m,int res){
     
    27953011}
    27963012
     3013
     3014/**
     3015 * Base64 encoding of a char*
     3016 *
     3017 * @param input the value to encode
     3018 * @param length the value length
     3019 * @return the buffer containing the base64 value
     3020 * @warning make sure to free the returned value
     3021 */
    27973022char *base64(const char *input, int length)
    27983023{
     
    28173042}
    28183043
     3044/**
     3045 * Base64 decoding of a char*
     3046 *
     3047 * @param input the value to decode
     3048 * @param length the value length
     3049 * @param red the value length
     3050 * @return the buffer containing the base64 value
     3051 * @warning make sure to free the returned value
     3052 */
    28193053char *base64d(const char *input, int length,int* red)
    28203054{
     
    28363070}
    28373071
     3072/**
     3073 * Make sure that each value encoded in base64 in a maps is decoded.
     3074 *
     3075 * @param in the maps containing the values
     3076 */
    28383077void ensureDecodedBase64(maps **in){
    28393078  maps* cursor=*in;
     
    28563095}
    28573096
     3097/**
     3098 * Add the default values defined in the zcfg to a maps.
     3099 *
     3100 * @param out the maps containing the inputs or outputs given in the initial
     3101 *  HTTP request
     3102 * @param in the description of all inputs or outputs available for a service
     3103 * @param m the maps containing the settings of the main.cfg file
     3104 * @param type 0 for inputs and 1 for outputs
     3105 * @param err the map to store potential missing mandatory input parameters or
     3106 *  wrong output names depending on the type.
     3107 * @return "" if no error was detected, the name of last input or output causing
     3108 *  an error.
     3109 */
    28583110char* addDefaultValues(maps** out,elements* in,maps* m,int type,map** err){
    28593111  map *res=*err;
     
    30953347
    30963348/**
    3097  * parseBoundingBox : parse a BoundingBox string
    3098  *
    3099  * OGC 06-121r3 : 10.2 Bounding box
    3100  *
    3101  * value is provided as : lowerCorner,upperCorner,crs,dimension
    3102  * exemple : 189000,834000,285000,962000,urn:ogc:def:crs:OGC:1.3:CRS84
    3103  *
    3104  * Need to create a map to store boundingbox informations :
     3349 * Parse a BoundingBox string
     3350 *
     3351 * [OGC 06-121r3](http://portal.opengeospatial.org/files/?artifact_id=20040):
     3352 *  10.2 Bounding box
     3353 *
     3354 *
     3355 * Value is provided as : lowerCorner,upperCorner,crs,dimension
     3356 * Exemple : 189000,834000,285000,962000,urn:ogc:def:crs:OGC:1.3:CRS84
     3357 *
     3358 * A map to store boundingbox informations should contain:
    31053359 *  - lowerCorner : double,double (minimum within this bounding box)
    31063360 *  - upperCorner : double,double (maximum within this bounding box)
     
    31093363 *
    31103364 * Note : support only 2D bounding box.
     3365 *
     3366 * @param value the char* containing the KVP bouding box
     3367 * @return a map containing all the bounding box keys
    31113368 */
    31123369map* parseBoundingBox(const char* value){
     
    31563413
    31573414/**
    3158  * printBoundingBox : fill a BoundingBox node (ows:BoundingBox or
    3159  * wps:BoundingBoxData). Set crs and dimensions attributes, add
    3160  * Lower/UpperCorner nodes to a pre-existing XML node.
     3415 * Create required XML nodes for boundingbox and update the current XML node
     3416 *
     3417 * @param ns_ows the ows XML namespace
     3418 * @param n the XML node to update
     3419 * @param boundingbox the map containing the boundingbox definition
    31613420 */
    31623421void printBoundingBox(xmlNsPtr ns_ows,xmlNodePtr n,map* boundingbox){
     
    31913450}
    31923451
     3452/**
     3453 * Print an ows:BoundingBox XML document
     3454 *
     3455 * @param m the maps containing the settings of the main.cfg file
     3456 * @param boundingbox the maps containing the boundingbox definition
     3457 * @param file the file to print the BoundingBox (if NULL then print on stdout)
     3458 * @see parseBoundingBox, printBoundingBox
     3459 */
    31933460void printBoundingBoxDocument(maps* m,maps* boundingbox,FILE* file){
    31943461  if(file==NULL)
     
    32433510}
    32443511
    3245 
     3512/**
     3513 * Compute md5
     3514 *
     3515 * @param url the char*
     3516 * @return a char* representing the md5 of the url
     3517 * @warning make sure to free ressources returned by this function
     3518 */
    32463519char* getMd5(char* url){
    32473520  EVP_MD_CTX md5ctx;
     
    32673540
    32683541/**
    3269  * Cache a file for a given request
     3542 * Cache a file for a given request.
     3543 * For each cached file, the are two files stored, a .zca and a .zcm containing
     3544 * the downloaded content and the mimeType respectively.
     3545 *
     3546 * @param conf the maps containing the settings of the main.cfg file
     3547 * @param request the url used too fetch the content
     3548 * @param content the downloaded content
     3549 * @param mimeType the content mimeType
     3550 * @param length the content size
    32703551 */
    32713552void addToCache(maps* conf,char* request,char* content,char* mimeType,int length){
     
    33003581}
    33013582
     3583/**
     3584 * Verify if a url is available in the cache
     3585 *
     3586 * @param conf the maps containing the settings of the main.cfg file
     3587 * @param request the url
     3588 * @return the full name of the cached file if any, NULL in other case
     3589 * @warning make sure to free ressources returned by this function (if not NULL)
     3590 */
    33023591char* isInCache(maps* conf,char* request){
    33033592  map* tmpM=getMapFromMaps(conf,"main","cacheDir");
     
    33213610}
    33223611
     3612/**
     3613 * Effectively run all the HTTP requests in the queue
     3614 *
     3615 * @param m the maps containing the settings of the main.cfg file
     3616 * @param inputs the maps containing the inputs (defined in the requests+added
     3617 *  per default based on the zcfg file)
     3618 * @param hInternet the HINTERNET pointer
     3619 * @return 0 on success
     3620 */
    33233621int runHttpRequests(maps** m,maps** inputs,HINTERNET* hInternet){
    33243622  if(hInternet->nb>0){
     
    34273725
    34283726/**
    3429  * loadRemoteFile:
    34303727 * Try to load file from cache or download a remote file if not in cache
     3728 *
     3729 * @param m the maps containing the settings of the main.cfg file
     3730 * @param content the map to update
     3731 * @param hInternet the HINTERNET pointer
     3732 * @param url the url to fetch
     3733 * @return 0
    34313734 */
    34323735int loadRemoteFile(maps** m,map** content,HINTERNET* hInternet,char *url){
     
    35233826}
    35243827
     3828/**
     3829 * Read a file using the GDAL VSI API
     3830 *
     3831 * @param conf the maps containing the settings of the main.cfg file
     3832 * @param dataSource the datasource name to read
     3833 * @warning make sure to free ressources returned by this function
     3834 */
    35253835char *readVSIFile(maps* conf,const char* dataSource){
    35263836    VSILFILE * fichier=VSIFOpenL(dataSource,"rb");
     
    35423852}
    35433853
     3854/**
     3855 * Extract the service identifier from the full service identifier
     3856 * ie:
     3857 *  - Full service name: OTB.BandMath
     3858 *  - Service name: BandMath
     3859 *
     3860 * @param conf the maps containing the settings of the main.cfg file
     3861 * @param conf_dir the full path to the ZOO-Kernel directory
     3862 * @param identifier the full service name (potentialy including a prefix, ie:
     3863 *  Prefix.MyService)
     3864 * @param buffer the resulting service identifier (without any prefix)
     3865 */
    35443866void parseIdentifier(maps* conf,char* conf_dir,char *identifier,char* buffer){
    35453867  setMapInMaps(conf,"lenv","oIdentifier",identifier);
     
    36073929}
    36083930
     3931/**
     3932 * Update the status of an ongoing service
     3933 *
     3934 * @param conf the maps containing the settings of the main.cfg file
     3935 * @param percentCompleted percentage of completude of execution of the service
     3936 * @param message information about the current step executed
     3937 * @return the value of _updateStatus
     3938 * @see _updateStatus
     3939 */
    36093940int updateStatus( maps* conf, const int percentCompleted, const char* message ){
    36103941  char tmp[4];
     
    36153946}
    36163947
     3948/**
     3949 * Access an input value
     3950 *
     3951 * @param inputs the maps to search for the input value
     3952 * @param parameterName the input name to fetch the value
     3953 * @param numberOfBytes the resulting size of the value to add (for binary
     3954 *  values), -1 for basic char* data
     3955 * @return a pointer to the input value if found, NULL in other case.
     3956 */
    36173957char* getInputValue( maps* inputs, const char* parameterName, size_t* numberOfBytes){
    36183958  map* res=getMapFromMaps(inputs,parameterName,"value");
     
    36303970}
    36313971
     3972/**
     3973 * Set an output value
     3974 *
     3975 * @param outputs the maps to define the output value
     3976 * @param parameterName the output name to set the value
     3977 * @param data the value to set
     3978 * @param numberOfBytes size of the value to add (for binary values), -1 for
     3979 *  basic char* data
     3980 * @return 0
     3981 */
    36323982int  setOutputValue( maps* outputs, const char* parameterName, char* data, size_t numberOfBytes ){
    36333983  if(numberOfBytes==-1){
     
    36493999}
    36504000
    3651 /************************************************************************/
    3652 /*                           checkValidValue()                          */
    3653 /************************************************************************/
    3654 
    36554001/**
    36564002 * Verify if a parameter value is valid.
     
    36584004 * @param request the request map
    36594005 * @param res the error map potentially generated
     4006 * @param toCheck the parameter to use
    36604007 * @param avalues the acceptable values (or null if testing only for presence)
    36614008 * @param mandatory verify the presence of the parameter if mandatory > 0
     
    37404087}
    37414088
    3742 /*
    3743  * The character string returned from getLastErrorMessage resides
     4089/**
     4090 * Access the last error message returned by the OS when trying to dynamically
     4091 * load a shared library.
     4092 *
     4093 * @return the last error message
     4094 * @warning The character string returned from getLastErrorMessage resides
    37444095 * in a static buffer. The application should not write to this
    37454096 * buffer or attempt to free() it.
    37464097 */
    3747 char* getLastErrorMessage() {                                                                                                                                                   
    3748 #ifdef WIN32   
    3749         LPVOID lpMsgBuf;
    3750         DWORD errCode = GetLastError();
    3751         static char msg[ERROR_MSG_MAX_LENGTH];
    3752         size_t i;
    3753 
    3754         DWORD length = FormatMessage(
    3755                                          FORMAT_MESSAGE_ALLOCATE_BUFFER |
    3756                                          FORMAT_MESSAGE_FROM_SYSTEM |
    3757                                          FORMAT_MESSAGE_IGNORE_INSERTS,
    3758                                          NULL,
    3759                                          errCode,
    3760                                          MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
    3761                                          (LPTSTR) &lpMsgBuf,
    3762                                          0, NULL );     
    3763        
    3764         #ifdef UNICODE         
    3765                 wcstombs_s( &i, msg, ERROR_MSG_MAX_LENGTH,
    3766                                         (wchar_t*) lpMsgBuf, _TRUNCATE );
    3767         #else
    3768                 strcpy_s( msg, ERROR_MSG_MAX_LENGTH,
    3769                       (char *) lpMsgBuf );             
    3770         #endif 
    3771         LocalFree(lpMsgBuf);
    3772        
    3773         return msg;
     4098char* getLastErrorMessage() {                                             
     4099#ifdef WIN32
     4100  LPVOID lpMsgBuf;
     4101  DWORD errCode = GetLastError();
     4102  static char msg[ERROR_MSG_MAX_LENGTH];
     4103  size_t i;
     4104 
     4105  DWORD length = FormatMessage(
     4106                               FORMAT_MESSAGE_ALLOCATE_BUFFER |
     4107                               FORMAT_MESSAGE_FROM_SYSTEM |
     4108                               FORMAT_MESSAGE_IGNORE_INSERTS,
     4109                               NULL,
     4110                               errCode,
     4111                               MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
     4112                               (LPTSTR) &lpMsgBuf,
     4113                               0, NULL );       
     4114 
     4115#ifdef UNICODE         
     4116  wcstombs_s( &i, msg, ERROR_MSG_MAX_LENGTH,
     4117              (wchar_t*) lpMsgBuf, _TRUNCATE );
    37744118#else
    3775         return dlerror();
    3776 #endif
    3777 }
     4119  strcpy_s( msg, ERROR_MSG_MAX_LENGTH,
     4120            (char *) lpMsgBuf );               
     4121#endif 
     4122  LocalFree(lpMsgBuf);
     4123 
     4124  return msg;
     4125#else
     4126  return dlerror();
     4127#endif
     4128}
Note: See TracChangeset for help on using the changeset viewer.

Search

Context Navigation

ZOO Sponsors

http://www.zoo-project.org/trac/chrome/site/img/geolabs-logo.pnghttp://www.zoo-project.org/trac/chrome/site/img/neogeo-logo.png http://www.zoo-project.org/trac/chrome/site/img/apptech-logo.png http://www.zoo-project.org/trac/chrome/site/img/3liz-logo.png http://www.zoo-project.org/trac/chrome/site/img/gateway-logo.png

Become a sponsor !

Knowledge partners

http://www.zoo-project.org/trac/chrome/site/img/ocu-logo.png http://www.zoo-project.org/trac/chrome/site/img/gucas-logo.png http://www.zoo-project.org/trac/chrome/site/img/polimi-logo.png http://www.zoo-project.org/trac/chrome/site/img/fem-logo.png http://www.zoo-project.org/trac/chrome/site/img/supsi-logo.png http://www.zoo-project.org/trac/chrome/site/img/cumtb-logo.png

Become a knowledge partner

Related links

http://zoo-project.org/img/ogclogo.png http://zoo-project.org/img/osgeologo.png