Ignore:
Timestamp:
Jun 24, 2015, 1:58:17 AM (9 years ago)
Author:
djay
Message:

Various fixes for Windows support: generate uuid using UuidCreate?, pass usid to the created process, call TerminateProcess? on dismiss request.

File:
1 edited

Legend:

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

    r676 r680  
    2929#ifndef WIN32
    3030#include <dlfcn.h>
    31 #endif
    3231#include <uuid/uuid.h>
     32#else
     33#include <rpc.h>
     34#define ERROR_MSG_MAX_LENGTH 1024
     35#endif
    3336#include <signal.h>
    3437
     
    5760char *get_uuid(){
    5861  char *res=(char*)malloc(37*sizeof(char));
     62#ifdef WIN32
     63  UUID uuid;
     64  UuidCreate(&uuid);
     65  RPC_CSTR rest = NULL;
     66  UuidToString(&uuid,&rest);
     67#else
    5968  uuid_t uuid;
    6069  uuid_generate_time(uuid);
    6170  char rest[128];
    6271  uuid_unparse(uuid,rest);
    63   sprintf(res,"%s", rest);
     72#endif
     73  sprintf(res,"%s",rest);
    6474  return res;
    6575}
     
    780790#endif 
    781791  LocalFree(lpMsgBuf);
    782  
     792
    783793  return msg;
    784794#else
     
    950960      fcontent[flen]=0;
    951961      fclose(f0);
     962#ifndef WIN32
    952963      kill(atoi(fcontent),SIGKILL);
     964#else
     965      HANDLE myZooProcess=OpenProcess(PROCESS_ALL_ACCESS,false,atoi(fcontent));
     966      TerminateProcess(myZooProcess,1);
     967      CloseHandle(myZooProcess);
     968#endif
    953969      free(fcontent);
    954970    }
     
    10891105  return 0;
    10901106}
     1107
     1108#ifdef WIN32
     1109/**
     1110 * Create a KVP request for executing background task.
     1111 * TODO: use the XML request in case of input POST request.
     1112 *
     1113 * @param m the maps containing the parameters from the main.cfg file
     1114 * @param length the total length of the KVP parameters
     1115 * @param type
     1116 */
     1117char* getMapsAsKVP(maps* m,int length,int type){
     1118  char *dataInputsKVP=(char*) malloc(length*sizeof(char));
     1119  char *dataInputsKVPi=NULL;
     1120  maps* curs=m;
     1121  int i=0;
     1122  while(curs!=NULL){
     1123    map *inRequest=getMap(curs->content,"inRequest");
     1124    map *hasLength=getMap(curs->content,"length");
     1125    if((inRequest!=NULL && strncasecmp(inRequest->value,"true",4)==0) ||
     1126       inRequest==NULL){
     1127      if(i==0)
     1128        if(type==0){
     1129          sprintf(dataInputsKVP,"%s=",curs->name);
     1130          if(hasLength!=NULL){
     1131            dataInputsKVPi=(char*)malloc((strlen(curs->name)+2)*sizeof(char));
     1132            sprintf(dataInputsKVPi,"%s=",curs->name);
     1133          }
     1134        }
     1135        else
     1136          sprintf(dataInputsKVP,"%s",curs->name);
     1137      else{
     1138        char *temp=zStrdup(dataInputsKVP);
     1139        if(type==0)
     1140          sprintf(dataInputsKVP,"%s;%s=",temp,curs->name);
     1141        else
     1142          sprintf(dataInputsKVP,"%s;%s",temp,curs->name);
     1143      }
     1144      map* icurs=curs->content;
     1145      if(type==0){
     1146        char *temp=zStrdup(dataInputsKVP);
     1147        if(getMap(curs->content,"xlink:href")!=NULL)
     1148          sprintf(dataInputsKVP,"%sReference",temp);
     1149        else{
     1150          if(hasLength!=NULL){
     1151            int j;
     1152            for(j=0;j<atoi(hasLength->value);j++){
     1153              map* tmp0=getMapArray(curs->content,"value",j);
     1154              if(j==0)
     1155                free(temp);
     1156              temp=zStrdup(dataInputsKVP);
     1157              if(j==0)
     1158                sprintf(dataInputsKVP,"%s%s",temp,tmp0->value);
     1159              else
     1160                sprintf(dataInputsKVP,"%s;%s%s",temp,dataInputsKVPi,tmp0->value);
     1161            }
     1162          }
     1163          else
     1164            sprintf(dataInputsKVP,"%s%s",temp,icurs->value);
     1165        }
     1166        free(temp);
     1167      }
     1168      while(icurs!=NULL){
     1169        if(strncasecmp(icurs->name,"value",5)!=0 &&
     1170           strncasecmp(icurs->name,"mimeType_",9)!=0 &&
     1171           strncasecmp(icurs->name,"dataType_",9)!=0 &&
     1172           strncasecmp(icurs->name,"size",4)!=0 &&
     1173           strncasecmp(icurs->name,"length",4)!=0 &&
     1174           strncasecmp(icurs->name,"isArray",7)!=0 &&
     1175           strcasecmp(icurs->name,"Reference")!=0 &&
     1176           strcasecmp(icurs->name,"minOccurs")!=0 &&
     1177           strcasecmp(icurs->name,"maxOccurs")!=0 &&
     1178           strncasecmp(icurs->name,"fmimeType",9)!=0 &&
     1179           strcasecmp(icurs->name,"inRequest")!=0){
     1180          char *itemp=zStrdup(dataInputsKVP);
     1181          if(strcasecmp(icurs->name,"xlink:href")!=0)
     1182            sprintf(dataInputsKVP,"%s@%s=%s",itemp,icurs->name,icurs->value);
     1183          else
     1184            sprintf(dataInputsKVP,"%s@%s=%s",itemp,icurs->name,url_encode(icurs->value));
     1185          free(itemp);
     1186        }
     1187        icurs=icurs->next;
     1188      }
     1189    }
     1190    curs=curs->next;
     1191    i++;
     1192  }
     1193  return dataInputsKVP;
     1194}
     1195#endif
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