diff --git a/CMakeLists.txt b/CMakeLists.txt index eef0f31..4b88931 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,9 +25,11 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/") find_package( Threads REQUIRED ) find_package( CRYPT REQUIRED ) find_package( NetCDF REQUIRED ) +find_package( DDClient REQUIRED ) find_package( CDF REQUIRED ) get_filename_component(NETCDFLIB_DIR ${NETCDFLIBRARIES} PATH) +get_filename_component(DDCLIENTLIB_DIR ${DDCLIENTLIBRARIES} PATH) configure_file ( "${CMAKE_SOURCE_DIR}/scripts/StartServer.in" @@ -35,7 +37,6 @@ configure_file ( ) MESSAGE( STATUS "Build DD_Server Project" ) -add_subdirectory(src/CLIENT) add_subdirectory(src/SERVER) add_subdirectory(src/DECODERS/ascii2nc) add_subdirectory(src/DECODERS/cdf2nc) @@ -50,7 +51,6 @@ add_subdirectory(src/TIMESUPDATENODATA) add_subdirectory(tests) install(FILES "scripts/StartServer" DESTINATION . PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) -install(DIRECTORY "src/INCLUDE/" DESTINATION include) install(DIRECTORY "src/CALLEXT/" DESTINATION bin/CALLEXT) SET(CMAKE_VERBOSE_MAKEFILE ON) diff --git a/README b/README index 5871211..6a5ac65 100644 --- a/README +++ b/README @@ -1,20 +1,23 @@ 1. Set NETCDF_ROOT to use a specific netcdf installation directory : > export NETCDF_ROOT="/usr/lib/" -2. Make the build directory : +2. Set DDCLIENT_ROOT to define DDClient installation directory : +> export DDCLIENT_ROOT="/home/benjamin/DDClient/" + +3. Make the build directory : > cmake -E make_directory build -3. Configure the build. Set CMAKE_BUILD_TYPE to Debug or Release to configure the build type. Set CMAKE_INSTALL_PREFIX to configure the install directory : +4. Configure the build. Set CMAKE_BUILD_TYPE to Debug or Release to configure the build type. Set CMAKE_INSTALL_PREFIX to configure the install directory : > cmake -E chdir build cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/home/benjamin/DDServer .. -4. Build DDServer : +5. Build DDServer : > cmake --build build -5. Install DDServer : +6. Install DDServer : > make -C build install VERBOSE=1 -6. Configure DDServer : +7. Configure DDServer : In the install directory, open "StartServer" and set DDPATH and DDBASE. -7. Run DDServer: +8. Run DDServer: > ./StartServer diff --git a/cmake/modules/FindDDClient.cmake b/cmake/modules/FindDDClient.cmake new file mode 100644 index 0000000..54937b7 --- /dev/null +++ b/cmake/modules/FindDDClient.cmake @@ -0,0 +1,24 @@ +FIND_PATH(DDCLIENTINCLUDE_DIR DD.h + HINTS + $ENV{DDCLIENT_ROOT}/include/DDClientLibC + ${DDCLIENT_ROOT}/include/DDClientLibC +) +mark_as_advanced(DDCLIENTINCLUDE_DIR) + +find_library(DDCLIENTLIBRARY + NAMES DDClientLibC + HINTS + $ENV{DDCLIENT_ROOT} + ${DDCLIENT_ROOT} + PATH_SUFFIXES lib +) +mark_as_advanced(DDCLIENTLIBRARY) + +include(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(DDClient DEFAULT_MSG DDCLIENTLIBRARY DDCLIENTINCLUDE_DIR) + +if(DDCLIENT_FOUND) + set(DDCLIENTINCLUDE_DIRS ${DDCLIENTINCLUDE_DIR}) + set(DDCLIENTLIBRARIES ${DDCLIENTLIBRARY}) +endif() + diff --git a/scripts/StartServer.in b/scripts/StartServer.in index 0ed9fce..d4eceb9 100755 --- a/scripts/StartServer.in +++ b/scripts/StartServer.in @@ -4,7 +4,7 @@ #------------------------------------------------------------------- DDBASE=/home/budnik/AMDA-NG.core/DDBASE/DATA DDPATH=/home/budnik/AMDA-NG.core/DDBASE -DDLIB=@CMAKE_INSTALL_PREFIX@/lib +DDLIB=@DDCLIENTLIB_DIR@ DDBASEBIN=@CMAKE_INSTALL_PREFIX@/bin LD_LIBRARY_PATH=$DDLIB/:@NETCDFLIB_DIR@:@libcdf_LIBRARY_DIR@:@USRLIB_DIR@ export DDBASE DDPATH DDBASEBIN DDLIB LD_LIBRARY_PATH diff --git a/src/CLIENT/CMakeLists.txt b/src/CLIENT/CMakeLists.txt deleted file mode 100644 index f14dfb3..0000000 --- a/src/CLIENT/CMakeLists.txt +++ /dev/null @@ -1,22 +0,0 @@ - -PROJECT(DD_Client) - -include_directories( - ${CMAKE_HOME_DIRECTORY}/src/INCLUDE/ -) - -#Library configuration -file( - GLOB_RECURSE - source_files - ./* -) - -ADD_LIBRARY( DD_Client SHARED ${source_files} ) - -target_link_libraries( - DD_Client - ${CMAKE_THREAD_LIBS_INIT} -) - -install (TARGETS DD_Client DESTINATION lib) diff --git a/src/CLIENT/DD_client.c b/src/CLIENT/DD_client.c deleted file mode 100755 index 59286ab..0000000 --- a/src/CLIENT/DD_client.c +++ /dev/null @@ -1,931 +0,0 @@ -/* $Id: DD_client.c,v 1.4 2012/10/18 09:25:58 budnik Exp $ */ -/*============================================================== - * DD SYSTEM - * DD_client.c - * V.6.0 - * List of changes: - * November 1995, Version 1.0 - * August 1999 :Access security system was installed by Alexandr Grigoriev (v3.0) - * October 22, 2002 - Communication ideology is changed (V.4.0) - * Oct 29, 2002 - Add DD_GetVersion() and some bags are corrected (V.4.1) - * May 1, 2003 - Network error is developped. (The header receiving is changed): V.4.2 - * Nov 18, 2004 - Cach error is fixed. - * Jun 17, 2007 - Fedorov, V.4.5 Create new VI and Update data requests - * Sep 24, 2007 - Fedorov, V.4.6 Processing of return of Get_Data - * Dec 03, 2007 - Budnik, V.4.7 There may be several sessions with DD Server inside ONE - * Client session. Keep UserHost & UserName - * Oct 18, 2012 - Knizhnikova, V.4.8 new DD_SetTimeInfo() function - * Dec 15, 2012 - Fedorov, V.6.0. DD_GetMultiData(). Request structure is very changed, CurrentData is not a global structure - *===============================================================*/ - -#include -#include "DD.h" -#include "DD_comm.h" -#include "DD_Access.h" -#include -#include - -#define VERSION "V.6.0" - -/*------------------ GLOBAL STATIC VARIABLES --------------------------*/ -int SocketID = -1; /* Global socket id for this communication session */ -char UserName[USRLENGTH]="\0"; /* string for user name */ -char UserHost[MAXHOSTLENGTH] = "\0"; /* IP of user's host in a string form */ -int UserID; /* ID of user at the user's host */ -extern int errno; - -/*================== FUNCTIONS =================================*/ -/*----------------------- GET User Host-------------------------------*/ -int GetUserHost() -{ - char HostName[HOSTNAMELENGTH]; - struct hostent *Host; - unsigned int HostAddress; - int userid; - static unsigned int m1 = 0X000000FF; - static unsigned int m2 = 0X0000FF00; - static unsigned int m3 = 0X00FF0000; - static unsigned int m4 = 0XFF000000; - unsigned int b1,b2,b3,b4; - - userid = getuid(); /* Get a client user ID */ - -/* UserHost can be set by extern WEB function in case of WEB communicatio, - * or it should be defined as local host if DD_client is installed at USER - * computer - */ - if(UserHost[0] == '\0') - { - gethostname(HostName,HOSTNAMELENGTH); /* Get a client host name */ - - if((Host = gethostbyname(HostName)) == NULL) return NOHOST; - HostAddress = *((unsigned int *)Host->h_addr_list[0]); - - b1 = HostAddress & m1; - b2 = (HostAddress & m2) >> 8; - b3 = (HostAddress & m3) >> 16; - b4 = (HostAddress & m4) >> 24; - - sprintf(UserHost,"%03u.%03u.%03u.%03u\0",b1,b2,b3,b4); - } - return userid; -} -/*-------------------------------------------------------------------*/ - -/*------------------ MAKE_CONNECTION ---------------------------*/ -/* - * The function returns opened socket, ready to read and write - */ -int GetSocket() -/* - * Connect with remote server, and returns socket ID - * In case of error return error number according DD_comm.h - */ -{ -/*-------- Variables for resource file -----------------*/ - char rname[PATHLENGTH]; /* name of res file */ - char line[PATHLENGTH]; - char *path; - FILE *resfile; /* resource file */ - char *pline; - -/*---------- Variables for network ---------------------*/ - static struct hostent *Host; /* name & internet (32b) address for - remout hosts (see netdb.h) */ - static char RemSerName[PATHLENGTH]; /* name of remote server */ - - struct servent *serv; /* pointer to static structure of - port number of registrated service */ - - static struct sockaddr_in IntAFAddr; /* structure of internet address of type AF_INET - see - to get name of socket we should - to convert pointer to this structure - to pointer to "srtruct sockaddr" where - all fields are "char array". */ - - int AFAddrLen = sizeof(struct sockaddr_in); /* size of internet address, 18 bytes*/ - int ScAddrLen = sizeof(struct sockaddr); /* size of socket address, 18 bytes*/ - - int cc,i; - int arg = 0; - int normaddr; -/* - *---------- Getting socket and its address ---------------------*/ -/*---------------- HOST and PORT ------------------------------*/ - if((path = getenv("DDPATH")) == NULL) - { - strcpy(rname,"DD.res"); - } - else - { - strcpy(rname,path); - strcat(rname, "/DD.res"); - } -/* - (void *)strcpy(rname,"./DD.res"); -*/ - if((resfile = fopen(rname,"r")) == NULL) - { - fprintf(stderr,"No resource file, sorry\n"); - exit(1); - } - - pline = fgets(RemSerName, PATHLENGTH-1, resfile); - pline = fgets(line, PATHLENGTH-1, resfile); - fclose(resfile); - - RemSerName[strlen(RemSerName)-1] = '\0'; - sscanf(line,"%d",&(normaddr)); - - IntAFAddr.sin_port = htons((uint16_t)normaddr); /* Conversion of the port number to - universal net form */ -/*---------------- END of FILE READING --------------------------*/ -/* - *------- Trying to open socket with this address and name --------- - */ - if((Host = gethostbyname(RemSerName)) == NULL) /* Get address and other information by - host name, see netdb.h */ - { - fprintf(stderr,"Server %s not found\n",RemSerName); - return(-1); - } - - if((SocketID = socket(AF_INET,SOCK_STREAM,PROTOCOL)) < 0) - { - perror("Socket:"); return(-1); - } - -/* Filling full internet address for socket "name" - * this address will be used to get communication point */ - - IntAFAddr.sin_family = Host->h_addrtype; - memcpy(&IntAFAddr.sin_addr.s_addr,Host->h_addr_list[0],Host->h_length); - - /* Connection to server socket on remote computer */ - if(connect(SocketID,(struct sockaddr *)&IntAFAddr,AFAddrLen) < 0) - { perror("connect"); return(-1); } - -/* - * Get Host name and Host ID for security application - */ - if((UserID = GetUserHost()) < 0) return(NOHOST); - - return SocketID; -} -/*------------------- end of GetSocket ---------------------*/ - -/*==================== Receive From Net ======================*/ -/* - * Smart buffered receiver - */ -int ReceiveFromNet(char *buf, int PacketSize) -{ - int CurLength = 0; - int i,cc; - do - { - i = 0; - while(((cc = recv(SocketID,buf+ CurLength,PacketSize - CurLength,0)) < 0) && (i < TRY)) i++; - if(cc < 0) return -1; - CurLength = CurLength + cc; - } while(CurLength < PacketSize); - return 1; -} - -/*------------------ Open Virtual Instrument -----------------------*/ -/* - * If no connection, connect to server, then try to order data set and return - * ID if OK or ErrorNumber if not - */ -int DD_SetVariable(char *InstrName) -{ - static caddr_t buff = NULL; - static XDR xdrs; - int InstrID; /* Instrumnet ID to return */ - int cc,i; - int Request = OPENINSREQ; - int hostlen,userlen; - char *PUserHost = UserHost, *PUserName = UserName; - /* We need this because XDR works with adresses of pointers */ - -/* If there is no connection, try to get it */ - if(SocketID < 0) - if((SocketID = GetSocket()) < 0) return(NOCONNECTION); - -/* Encoding request by XDR to buf */ -/* Buffer and stream allocation */ - buff = (caddr_t)malloc(REQUESTLENGTH); - - xdrmem_create(&xdrs, buff, REQUESTLENGTH, XDR_ENCODE); - - xdr_int(&xdrs,&Request); - xdr_string(&xdrs, &InstrName, strlen(InstrName)); - -/* Send Open Virtual Instrument request */ - - if((cc = send(SocketID,buff,REQUESTLENGTH,0)) < 0) - { - perror("DD_SetVariable:"); - free(buff); - xdr_destroy(&xdrs); - return(REQSENDERR); - } - xdrmem_create(&xdrs, buff, REQUESTLENGTH, XDR_FREE); - -/*-------- preparation an authorization request ----------------*/ - if(UserName[0] == '\0') strcpy(UserName,NONAME); - hostlen = strlen(UserHost); - userlen = strlen(UserName); - - xdrmem_create(&xdrs, buff,REQUESTLENGTH, XDR_ENCODE); - - xdr_int(&xdrs,&UserID); - xdr_string(&xdrs, &PUserHost, hostlen); - xdr_string(&xdrs, &PUserName, userlen); -/* fprintf(stderr,"userid %d host %s DD_name %s\n",UserID,UserHost,UserName); */ - -/* Send request */ - if((cc = send(SocketID,buff,REQUESTLENGTH,0)) < 0) - { - perror("DD_Set_Variable:"); - free(buff); - xdr_destroy(&xdrs); - return(REQSENDERR); - } - - free(buff); - xdr_destroy(&xdrs); - -/* Get reply */ - buff = (caddr_t)malloc(REPLYLENGTH); -/* - i=0; - while(((cc = recv(SocketID,buff,REPLYLENGTH,0)) < 0) && (i < TRY)) i++; -*/ - if((cc = ReceiveFromNet(buff, REPLYLENGTH)) < 0) - { - perror("DD_SET_Variable:"); - free(buff); - return(REPLYRECERR); - } - - xdrmem_create(&xdrs, buff, REPLYLENGTH, XDR_DECODE); - xdr_int(&xdrs,&InstrID); - -/* Free all */ - free(buff); - xdr_destroy(&xdrs); - - return InstrID; -} - -/*----------------------- DD_GetInform -----------------------------*/ -/* - * Returns "OK" if OK, fill DD_Data structure - * Return negative value if error - */ - -int DD_GetInform(int VarID,char *AttrName,DD_data_t **data) -{ - static void *v = NULL; - static DD_data_t idd = {DD_CHAR, 0, NULL,1, &v}; - static caddr_t buf = NULL; - static XDR xdrs; - int id; - int cc; - int length; - int op = DATAINFOREQ; - int type; /* type of information or error */ - int DimNumbers; - int PacketSize; - int CurLength; - int i; - u_int count; - u_int MaxNumber; - -/*------------------- Empty static data ------------------------*/ - if(idd.Dimensions != NULL) - { - free(idd.Dimensions); - idd.Dimensions = NULL; - } - if(idd.Variables[0] != NULL) - { - free(idd.Variables[0]); - idd.Variables[0] = NULL; - } - -/*------------------ Check the Name length -----------------------*/ - if(strlen(AttrName) > MAXVARLENGTH) length = MAXVARLENGTH; - else length = strlen(AttrName); - -/*----------- Allocation of memory and stream --------------------*/ - buf = (caddr_t)malloc(REQUESTLENGTH); - xdrmem_create(&xdrs, buf, REQUESTLENGTH, XDR_ENCODE); - -/*------------------- Encoding the request ----------------------*/ - xdr_int(&xdrs,&op); - xdr_int(&xdrs,&VarID); - xdr_string(&xdrs, &AttrName, length); - -/*------------------------ Send request ---------------------------*/ - if((cc = send(SocketID,buf,REQUESTLENGTH,0)) < 0) - { - perror("DD_GetInform:"); - free(buf); - xdr_destroy(&xdrs); - return(REQSENDERR); - } - free(buf); - xdr_destroy(&xdrs); - -/*------------------------ Get reply header ------------------------*/ - - buf = (caddr_t)malloc(REPLYLENGTH); -/* - i=0; - while(((cc = recv(SocketID,buf,REPLYLENGTH,0)) < 0) && (i < TRY)) i++; - if(cc < 0) -*/ - if((cc = ReceiveFromNet(buf, REPLYLENGTH)) < 0) - { - perror("DD_GetInform:"); - free(buf); - return(REPLYRECERR); - } - - xdrmem_create(&xdrs, buf, REPLYLENGTH, XDR_DECODE); - xdr_int(&xdrs,&type); - if(type < 0) - { - free(buf); - xdr_destroy(&xdrs); - return(type); - } - xdr_int(&xdrs,&DimNumbers); - xdr_int(&xdrs,&PacketSize); - free(buf); - xdr_destroy(&xdrs); - - idd.DimNumber = DimNumbers; - idd.type = type; - -/*---------------------------- Get Data Packet ----------------------*/ - if(PacketSize > 0) buf = (caddr_t)malloc(PacketSize); - else return(REPLYRECERR); - - if((cc = ReceiveFromNet(buf, PacketSize)) < 0) - { - perror("DD_GetInform:"); - free(buf); - return(REPLYRECERR); - } - -/*--------------------- Decoding data packet ------------------------*/ - if(DimNumbers > 0) - { -/*----------- Memory allocation and xdr creating -----------------*/ - xdrmem_create(&xdrs, buf, (u_int)PacketSize, XDR_DECODE); - -/*----------------- Dimensions decoding -------------------------*/ - if(idd.Dimensions !=NULL) free(idd.Dimensions); - idd.Dimensions = (int *)malloc(DimNumbers*sizeof(int)); - - xdr_array(&xdrs, (caddr_t *)&(idd.Dimensions), - &count, - (u_int )DimNumbers, - unixlen[DD_INT], - (xdrproc_t)xdr_int); - - count = 1; - for(i=0; i < DimNumbers;i++) - count = count*idd.Dimensions[i]; - MaxNumber = count; - } - else - { - free(buf); - return(REPLYRECERR); - } - -/*---------------- Allocate memory for Variables and decoding ------------------*/ - if(idd.Variables[0] != NULL) free(idd.Variables[0]); - idd.Variables[0] = (int *)malloc(unixlen[type] * MaxNumber); - - xdr_array(&xdrs,((caddr_t*)(&idd.Variables[0])),&count, - MaxNumber, unixlen[type], (xdrproc_t)ConvFunc[type]); - -/*-------------------------- Free all ------------------------------*/ - free(buf); - xdr_destroy(&xdrs); - - *data = &idd; - return OK; -} - -/*==================================================== - * DD_SetTime() - *====================================================*/ -/*----------------------------------------------------- - * VarID - ID of Data Set - * Time - string in DD type - * Returns 1 if OK and negative in case of err - *---------------------------------------------------*/ - -int DD_SetTime(int VarID,char *Time) -{ - static caddr_t buf = NULL; - static XDR xdrs; - static int op = TIMESETREQ; - int type; - int cc,i; - int DoneFlag = 0; - - while(DoneFlag == 0) - { -/* Allocatein memory and stream */ - buf = (caddr_t)malloc(REQUESTLENGTH); - xdrmem_create(&xdrs, buf, REQUESTLENGTH, XDR_ENCODE); - -/* Encoding the request */ - xdr_int(&xdrs,&op); - xdr_int(&xdrs,&VarID); - xdr_string(&xdrs, &Time, TIMELENGTH); - -/* Send request */ - if((cc = send(SocketID,buf,REQUESTLENGTH,0)) < 0) - { - perror("DD_SetTime:"); - free(buf); - xdr_destroy(&xdrs); - return(REQSENDERR); - } - free(buf); - xdr_destroy(&xdrs); - -/* Get reply header */ - - buf = (caddr_t)malloc(REPLYLENGTH); - if((cc = ReceiveFromNet(buf, REPLYLENGTH)) < 0) - { - perror("DD_SetTime:"); - free(buf); - return(REPLYRECERR); - } - - xdrmem_create(&xdrs, buf, REPLYLENGTH, XDR_DECODE); - xdr_int(&xdrs,&type); - - free(buf); - xdr_destroy(&xdrs); - - if(type < 0) - { - if(type == CACHTOOREC) sleep((unsigned )(FILEACCMARG)); - else return type; - } - else DoneFlag = 1; - } - return 1 ; -} - -/*================================================================== - * DD_SetTimeInfo() - *=================================================================*/ -/*---------------------------------------------------------- - * VarID - ID of Data Set - * Time - string in DD type - * RealTime - double : time value pointer points to - * Returns 1 if OK and negative in case of err - *----------------------------------------------------------*/ - -int DD_SetTimeInfo(int VarID, char *Time, double *RealTime) -{ - int err; - static char TimeInt[17] = "0000000000001000\0"; - DD_data_t *data; - - err = DD_SetTime(VarID, Time); - if (err < 1) return err; - - err = DD_GetData(VarID, "Time", TimeInt, &data); - if (err < 0) return err; - if (data->VarNumber < 1) return OUTOFTIME; - - *RealTime = DD_Time2Double((char *)data->Variables[0]); - - return 1 ; -} - -/*========================================================= - * DD_GetData() - * Just an interface to the DD_GetMultiData() - *========================================================*/ -int DD_GetData(int VarID, char *VarName, char *TimeInt, DD_data_t **data) -{ - char *xxx=VarName; - int err; - err = DD_GetMultiData(VarID, 1, &xxx, TimeInt, data, 1); - return err; -} -/*========================================================= - * DD_GetMultiData() - *========================================================*/ -/*--------------------------------------------------------- - * VarID - ID of open virtual instrument - * VarSize - the size of the array names - * VarNames - araay of the variables names - * TimeInt - Time interval in DD_time style - * data - returned data - * Return values: - * positives: - * MOREDELAY - call this function again after delay - * MOREDATA - call this function again to complete request - * OK - all data received - * negative value - error (see DD.h) - *---------------------------------------------------------*/ - -int DD_GetMultiData(int VarID,size_t VarSize, char **VarNames,char *TimeInt,DD_data_t **data, int BackFlag) -{ - static DD_data_t *CurrentData = NULL; /* Data records array to keep until the next call */ - static size_t OldVarSize = 0; - static caddr_t buf = NULL; - static XDR xdrs; - static int LastPacketFlag = OK; - int id; - int cc; - int *NameLength = NULL; /* Array of lengths */ - int XDRStrLen; /* xdr length of a string */ - int XDRReqlength; // Length in bytes the XDR stream - int op = DATAGETREQ; - int type; /* type of information or error */ - int DimNumbers; - int PacketSize; - int CurLength; - u_int count, MaxSize; - int i; - - /* Empty static data */ - for(id = 0; id < OldVarSize; id++) - { - if(CurrentData[id].Dimensions != NULL) - { - free(CurrentData[id].Dimensions); - CurrentData[id].Dimensions = NULL; - } - if(CurrentData[id].Variables != NULL) - { - for(i = 0; i< CurrentData[id].VarNumber; i++) - free(CurrentData[id].Variables[i]); - free(CurrentData[id].Variables); - CurrentData[id].Variables = NULL; - } - } - free(CurrentData); - - /*-------------------------------------- - * Create a new Current Data empty array - *-------------------------------------*/ - OldVarSize = VarSize; - CurrentData = (DD_data_t *)malloc(sizeof(DD_data_t)*VarSize); - for(id = 0; id < VarSize; id++) - { - CurrentData[id].Dimensions = NULL; - CurrentData[id].Variables = NULL; - CurrentData[id].DimNumber = 0; - CurrentData[id].VarNumber = 0; - CurrentData[id].type = 0; - } - /*-------------------------------------------------------------- - * The follows request preparation and send is performed only - * if the priveous data packed is completely received - *--------------------------------------------------------------*/ - if((LastPacketFlag == OK) || (LastPacketFlag == MOREDELAY)) - { - /*--------------------------------------- - * Preparation of the array the name lengths - * Note that the names are cut down to the MAXVARLENGTH - * Calculation the packet size - *---------------------------------------*/ - NameLength = (int *)malloc(sizeof(int)*VarSize); - XDRReqlength = 8; /* the length of the first+last arguments */ - for(id = 0; id < VarSize; id++) - { - if(strlen(VarNames[id]) > MAXVARLENGTH) NameLength[id] = MAXVARLENGTH; - else NameLength[id] = strlen(VarNames[id]); - XDRStrLen = (NameLength[id] / 4) * 4; - if((NameLength[id] % 4) > 0) XDRStrLen += 4; - XDRReqlength += XDRStrLen + 4; // String length + 4 bytes length coding - //fprintf(stderr,"Variable %s, length %d, total %d\n",VarNames[id],XDRStrLen,XDRReqlength); - } - /*-------------------------------- - * The first packet of the request of the standard size - * Allocation corresponding memory and stream - *------------------------------*/ - buf = (caddr_t)malloc(REQUESTLENGTH); - xdrmem_create(&xdrs, buf, REQUESTLENGTH, XDR_ENCODE); - - /* Encoding the request */ - xdr_int(&xdrs,&op); - xdr_int(&xdrs,&VarID); - xdr_string(&xdrs,&TimeInt,TIMELENGTH); - xdr_int(&xdrs,&XDRReqlength); - - /* Send the first request */ - if((cc = send(SocketID,buf,REQUESTLENGTH,0)) < 0) - { - perror("DD_GetData: First Request"); - free(buf); - xdr_destroy(&xdrs); - return(REQSENDERR); - } - free(buf); - xdr_destroy(&xdrs); - - /*-------------------------------- - * The Second packet of XDRReqlength size - * Allocation corresponding memory and stream - *------------------------------*/ - buf = (caddr_t)malloc(XDRReqlength); - xdrmem_create(&xdrs, buf, XDRReqlength, XDR_ENCODE); - xdr_int(&xdrs,(int *)(&VarSize)); - for(id = 0; id < VarSize; id++) xdr_string(&xdrs, &VarNames[id], NameLength[id]); - xdr_int(&xdrs,&BackFlag); - - /* Send the second request */ - if((cc = send(SocketID,buf,XDRReqlength,0)) < 0) - { - perror("DD_GetData:Second Packet"); - free(buf); - xdr_destroy(&xdrs); - return(REQSENDERR); - } - free(buf); - xdr_destroy(&xdrs); - } - - /*----------------------------------------------------------- - * Get the VarSize reply headers and VarSize data - *----------------------------------------------------------*/ - for(id = 0; id < VarSize; id++) - { - /*------------------- - * The header - *-----------------*/ - buf = (caddr_t)malloc(REPLYLENGTH); - if((cc = ReceiveFromNet(buf, REPLYLENGTH)) < 0) - { - perror("DD_GetData:Error while header receive"); - free(buf); - return(REPLYRECERR); - } - - xdrmem_create(&xdrs, buf, REPLYLENGTH, XDR_DECODE); - xdr_int(&xdrs,&type); - xdr_int(&xdrs,&DimNumbers); - xdr_int(&xdrs,&PacketSize); - free(buf); - xdr_destroy(&xdrs); - - if((type < 0) && (type != NOVAR)) /* Server returns unrecoverable error */ - { - fprintf(stderr,"DD_GetData: Server returns %d, unrecovable error\n",type); - return type; - } - - /*----------- Header is received ----------------------*/ - CurrentData[id].DimNumber = DimNumbers - 1; - CurrentData[id].type = type; - - /*--------------- Receive Data Packet ------------------------------*/ - if(PacketSize > 0) buf = (caddr_t)malloc(PacketSize); - else return(REPLYRECERR); - if((cc = ReceiveFromNet(buf, PacketSize)) < 0) - { - perror("DD_GetData: Error while data packet receive"); - free(buf); - return(REPLYRECERR); - } - /*----------------- Decoding data packet --------------------*/ - if(DimNumbers > 1) - { - xdrmem_create(&xdrs, buf, (u_int)PacketSize, XDR_DECODE); - count = DimNumbers-1; - /* allocation memory for dimensions */ - CurrentData[id].Dimensions = (int *)malloc((DimNumbers-1)*sizeof(int)); - - xdr_int(&xdrs,&LastPacketFlag); /* Last Paket Indicatort*/ - xdr_int(&xdrs,&CurrentData[id].VarNumber); /* Variables number */ - - if(LastPacketFlag > 2) - { - LastPacketFlag = OK; - CurrentData[id].VarNumber = 0; - free(buf); - return(REPLYRECERR); - } - - /*----- Decoding dimensions array -------------------*/ - xdr_array(&xdrs, (caddr_t *)&(CurrentData[id].Dimensions), - &count, - (u_int )DimNumbers-1, - unixlen[DD_INT], - (xdrproc_t)xdr_int); - - count = 1; - for(i=0; i < DimNumbers-1;i++) - { - count = count*CurrentData[id].Dimensions[i]; - } - MaxSize = count; - } - else - { - if(type != NOVAR) - { - free(buf); - return(REPLYRECERR); - } - else - { - CurrentData[id].VarNumber = 0; - } - } - - /*---------- Decoding variables -------------------------*/ - if(CurrentData[id].VarNumber != 0) CurrentData[id].Variables = (void *)malloc(CurrentData[id].VarNumber*sizeof(void *)); - else CurrentData[id].Variables = NULL; - - for(i = 0; i < CurrentData[id].VarNumber; i++) - { - CurrentData[id].Variables[i] = (void *)malloc(unixlen[type]*MaxSize); - count = MaxSize; - xdr_array(&xdrs,(caddr_t *)(&(CurrentData[id].Variables[i])),&count,MaxSize,unixlen[type], (xdrproc_t)ConvFunc[type]); - } - - /* Free all */ - free(buf); - xdr_destroy(&xdrs); - } - *data = CurrentData; - return(LastPacketFlag); -} -/*===================================================================*/ - -/*-------------------------- DD_CLOSE --------------------------------*/ -/* - * - * VarID - entry point of ID table - * Returns 1 if OK or negative err - * Close Socket if no VarID more ( this information supplyed by server ) - */ - -int DD_Close(int VarID) -{ - static caddr_t buf = NULL; - static XDR xdrs; - static int op = CLOSEINSREQ; - int RemainedID; /* Server returns number of remained ID */ - int cc,i; -/* Allocatein memory and stream */ - buf = (caddr_t)malloc(REQUESTLENGTH); - xdrmem_create(&xdrs, buf, REQUESTLENGTH, XDR_ENCODE); - -/* Encoding the request */ - xdr_int(&xdrs,&op); - xdr_int(&xdrs,&VarID); - -/* Send request */ - if((cc = send(SocketID,buf,REQUESTLENGTH,0)) < 0) - { - perror("DD_Close:"); - free(buf); - xdr_destroy(&xdrs); - return(REQSENDERR); - } - free(buf); - xdr_destroy(&xdrs); - -/* Get reply header */ - - buf = (caddr_t)malloc(REPLYLENGTH); -/* - i = 0; - while(((cc = recv(SocketID,buf,REPLYLENGTH,0)) < 0) && (i < TRY)) i++; - if(cc < 0) -*/ - if((cc = ReceiveFromNet(buf, REPLYLENGTH)) < 0) - { - perror("DD_Close:"); - free(buf); - return(REPLYRECERR); - } - - xdrmem_create(&xdrs, buf, REPLYLENGTH, XDR_DECODE); - xdr_int(&xdrs,&RemainedID); - if(RemainedID< 0) - { - free(buf); - xdr_destroy(&xdrs); - return(RemainedID); - } - free(buf); - xdr_destroy(&xdrs); - - if(RemainedID == 0) - { - shutdown(SocketID,2); - close(SocketID); - SocketID = -1; -/* - UserHost[0] = '\0'; - UserName[0] = '\0'; -*/ - } - - return(1); -} -/*------------------------------------------------------------------------------*/ - -/*=============== DATABASE UPDATE FUNCTIONS ====================================*/ -/*------------------ DD_AddDataSet() -------------------------------------------*/ -int DD_AddDataSet(char *DataSetName, char *RemSetID, char *BaseName) -{ - static caddr_t buf = NULL; - static XDR xdrs; - static int op = ADDVIREQ; - int Err; /* Server returns OK or NOEXEC */ - int cc,i,length; - int CloseFlag = 0; - -/* If there is no connection, try to get it */ - if(SocketID < 0) - { - if((SocketID = GetSocket()) < 0) return(NOCONNECTION); - CloseFlag = 1; // To close Connection at the end - } - -/* Allocatein memory and stream */ - buf = (caddr_t)malloc(REQUESTLENGTH); - xdrmem_create(&xdrs, buf, REQUESTLENGTH, XDR_ENCODE); - -/* Encoding the request */ - xdr_int(&xdrs,&op); - -/* Coding DataSetName */ - if((length = strlen(DataSetName)) > MAXSETLENGTH) length = MAXSETLENGTH; - xdr_string(&xdrs, &DataSetName, length); -/* Coding RemSetID */ - if((length = strlen(RemSetID)) > MAXVARLENGTH) length = MAXVARLENGTH; - xdr_string(&xdrs, &RemSetID, length); -/* Coding BaseName */ - if((length = strlen(BaseName)) > MAXVARLENGTH) length = MAXVARLENGTH; - xdr_string(&xdrs, &BaseName, length); - -/* Send request */ - if((cc = send(SocketID,buf,REQUESTLENGTH,0)) < 0) - { - perror("DD_AddDataSet:"); - free(buf); - xdr_destroy(&xdrs); - return(REQSENDERR); - } - free(buf); - xdr_destroy(&xdrs); - -/* Get reply header */ - buf = (caddr_t)malloc(REPLYLENGTH); - if((cc = ReceiveFromNet(buf, REPLYLENGTH)) < 0) - { - perror("DD_AddDataSet:"); - free(buf); - return(REPLYRECERR); - } - - xdrmem_create(&xdrs, buf, REPLYLENGTH, XDR_DECODE); - xdr_int(&xdrs,&Err); - - if(CloseFlag) // Close everything if function established connection - { - shutdown(SocketID,2); - close(SocketID); - SocketID = -1; -/* Session with DD Server was closed, but User Session continues !!!!! */ - /* UserHost[0] = '\0'; - UserName[0] = '\0'; */ - } - return Err; -} -/*-----------------------------------------------------------------------------*/ - -/*---------------------- DD GET VERSION ---------------------------------------*/ -char *DD_GetVersion() -/* - * return static pointer to internal string with the DDLIB-SERVER package version - */ -{ - static char Version[] = VERSION; - return (char *)Version; -} -/*------------------------- End Library -------------------------------*/ diff --git a/src/CLIENT/DD_time.c b/src/CLIENT/DD_time.c deleted file mode 100755 index 946432a..0000000 --- a/src/CLIENT/DD_time.c +++ /dev/null @@ -1,321 +0,0 @@ -/* =================================================================== - * Name : DD_time.c - * Version: : 4.1 - * Author : Andrey Fedorov - * Institution : IRAP/UPS/CNRS Toulouse - * Modifications list: - * Oct 5, 2002: V.3.0, New functions DD_Time2Double and Double2DD_Time were added. - * March 26, 2010: V.3.1 YEARS up to 2025 - * May 17, 2011: V.4.0 Fedorov, completely revised version. - * There is no more confuse between Time and Time Interval - * Sept 05, 2011: V.4.1 SetIntNew => arg TimeKind => to work with 1970-1973 : BR - *==================================================================*/ - -#include "DD_time.h" -#include -#include -#include - -#define YEARS 56 -#define STARTYEAR 1970 - -/*---- Static array of days shift from Jan-1-1970 -------*/ -/* 1970 1971 1972 1973 1974 1975 1976 - * 1977 1978 1979 1980 1981 1982 1983 - * 1984 1985 1986 1987 1988 1989 1990 - * 1991 1992 1993 1994 1995 1996 1997 - * 1998 1999 2000 2001 2002 2003 2004 - * 2005 2006 2007 2008 2009 2010 2011 - * 2012 2013 2014 2015 2016 2017 2018 - * 2019 2020 2021 2022 2023 2024 2025 - */ -static double - YearDays[YEARS] = { 0.0, 365.0, 730.0, 1096.0, 1461.0, 1826.0, 2191.0, - 2557.0, 2922.0, 3287.0, 3652.0, 4018.0, 4383.0, 4748.0, - 5113.0, 5479.0, 5844.0, 6209.0, 6574.0, 6940.0, 7305.0, - 7670.0, 8035.0, 8401.0, 8766.0, 9131.0, 9496.0, 9862.0, - 10227.0, 10592.0, 10957.0, 11323.0, 11688.0, 12053.0, 12418.0, - 12784.0, 13149.0, 13514.0, 13879.0, 14245.0, 14610.0, 14975.0, - 15340.0, 15706.0, 16071.0, 16436.0, 16801.0, 17167.0, 17532.0, - 17897.0, 18262.0, 18628.0, 18993.0, 19358.0, 19723.0, 20089.0}; - -/*------------------------------------------------------------- - * DAY_OF_YEAR = monthday[*][month-1]+day_of_month -1 - *------------------------------------------------------------*/ -static int monthday[2][12] = -{ -{0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334}, -{0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335} -}; - -/*------------------------------------------------------------ - * Global static Flag to show the current state of the time - * processor. Is it Time interval (0), or DD Time (1) - *----------------------------------------------------------*/ -static int TimeFlag = 1; -/*================== INTERNAL FUNCTION ====================*/ -/*-------------------- SetInt ----------------------------*/ -void SetInt(dd_tmstr_t *UT) -{ - SetIntNew(UT,DD_TM_UNKNOWN); -} - -void SetIntNew(dd_tmstr_t *UT,t_DDTimeKind timeKind) /* Fill int values of dd_tmstr_t */ -/* If the double times field of UT structure is defined, - * this function fills remains fields of Year, day .... separately - */ -{ - static double msofday = 24.0*60.0*60.0; - static double msofhour = 60.0*60.0; - static double msofmin = 60.0; - long daynumber; - double msrest; - int i; - - daynumber = (long)(UT->times / msofday); - for(i=0;iyear = i+1970; - UT->day = (int)(daynumber - (long)YearDays[i]); - break; - } - case DD_TM_TIME_INTERVAL : - { - //it's a time interval - UT->year = 0; - UT->day = (int)(daynumber); - break; - } - default : - //compatibility mode - if(i > 3) - { - UT->year = i+1970; - UT->day = (int)(daynumber - (long)YearDays[i]); - } - else - { - UT->year = 0; - UT->day = (int)(daynumber); - } - break; - } - - msrest = UT->times - (double)daynumber * msofday; - UT->hour = (int)(msrest / msofhour); - msrest -= (double)(UT->hour)*msofhour; - UT->min = (int)(msrest / msofmin); - msrest -= (double)(UT->min)*msofmin; - UT->sec = (int)(msrest); - UT->msec = (int)((msrest - (double)(UT->sec))*1000.0); - return; -} - -/*---------------- end of SetInt -----------------------*/ - -/*------------------------------------------------------- - * SetDouble() - * Returns the double value of seconds since 1 Jan 1970 - * The calculations are made from already filled dd_tmstr_t. - * If UT->year - *------------------------------------------------------*/ -void SetDouble(dd_tmstr_t *UT) -{ - static double SecInMls = 1.0/1000.0; - static double SecImMin = 60.0; - static double SecInHour = 60.0*60.0; - static double SecInDay = 60.0*60.0*24.0; - if(UT->year >= STARTYEAR) // This is DD Time ! - UT->times = (double)UT->msec*SecInMls + - (double)UT->sec + - (double)UT->min*SecImMin + - (double)UT->hour*SecInHour + - (double)UT->day*SecInDay + - YearDays[(UT->year - 1970)]*SecInDay; - else if(UT->year < STARTYEAR) // This is Time Interval - UT->times = (double)UT->msec*SecInMls + - (double)UT->sec + - (double)UT->min*SecImMin + - (double)UT->hour*SecInHour + - (double)UT->day*SecInDay + - YearDays[UT->year]*SecInDay; - else - UT->times = 0.0; - return; -} -/*----------------- end of SetDouble ---------------------*/ - -/*=================== PUBLIC FUNCTIONS ==================*/ -/*------------------- DD_Time2Double --------------------*/ -double DD_Time2Double(dd_time_t UTstring) -{ - static dd_tmstr_t UT; - static char year[5] = "0000\0"; - static char day[4] = "000\0"; - static char hour[3]= "00\0"; - static char min[3] = "00\0"; - static char sec[3]= "00\0"; - static char msec[4] = "000\0"; - - strncpy(year,UTstring,4); - strncpy(day,UTstring+4,3); - strncpy(hour,UTstring+7,2); - strncpy(min,UTstring+9,2); - strncpy(sec,UTstring+11,2); - strncpy(msec,UTstring+13,3); - - sscanf(year,"%d",&(UT.year)); - sscanf(day,"%d",&(UT.day)); - sscanf(min,"%d",&(UT.min)); - sscanf(hour,"%d",&(UT.hour)); - sscanf(sec,"%d",&(UT.sec)); - sscanf(msec,"%d",&(UT.msec)); - if(UT.year < STARTYEAR) TimeFlag = 0; // Time Inetrval - - SetDouble(&UT); - return UT.times; -} -/*------------------------------------------------------*/ - -/*------------------- Double2DD_Time ---------------------*/ - char *Double2DD_Time(double Time) - { - static dd_time_t UTstring; - dd_tmstr_t UT; - - UT.times = Time; - SetInt(&UT); - sprintf(UTstring,"%04d%03d%02d%02d%02d%03d",(UT.year),(UT.day),(UT.hour), (UT.min), (UT.sec),(UT.msec)); - return &(UTstring[0]); - } -/*------------------------------------------------------------*/ - -/*================== BACKUP COMPABILITY FUNCTIONS =================*/ -/*----------------------------------------------------------------- - * ReadTime() - * Reads a standard DD time string as an argument - * and converts it into dd_tmstr_t structure. - * Function returns the pointer to the internal startic structure dd_tmstr_t. - * Function redefines TimeFlag. - *----------------------------------------------------------------*/ -dd_tmstr_t *ReadTime(char *UTstring) -{ - static dd_tmstr_t UT; - static char year[5] = "0000\0"; - static char day[4] = "000\0"; - static char hour[3]= "00\0"; - static char min[3] = "00\0"; - static char sec[3]= "00\0"; - static char msec[4] = "000\0"; - - strncpy(year,UTstring,4); - strncpy(day,UTstring+4,3); - strncpy(hour,UTstring+7,2); - strncpy(min,UTstring+9,2); - strncpy(sec,UTstring+11,2); - strncpy(msec,UTstring+13,3); - - sscanf(year,"%d",&(UT.year)); - sscanf(day,"%d",&(UT.day)); - sscanf(min,"%d",&(UT.min)); - sscanf(hour,"%d",&(UT.hour)); - sscanf(sec,"%d",&(UT.sec)); - sscanf(msec,"%d",&(UT.msec)); - - if(UT.year < STARTYEAR) TimeFlag = 0; // Time Inetrval - - SetDouble(&UT); - return(&UT); -} -/*-------------------- end of ReadTime ------------------------*/ - -/*---------------------- Write Time ---------------------------*/ -/* Function Write time convert use only double times field - * of dd_tmstr_t structure to print time in DD style - * in internal static string. The integer fields redefined. - * Function return string pointer. - */ - -char *WriteTime(dd_tmstr_t *UT) -{ - static dd_time_t UTstring; - - SetInt(UT); - sprintf(UTstring,"%04d%03d%02d%02d%02d%03d",(UT->year),(UT->day),(UT->hour), - (UT->min), (UT->sec),(UT->msec)); - return(UTstring); -} -/*------------------- end of WriteTime -------------------*/ - -void WriteFmtTime(dd_tmstr_t *UT,char *UTstring) -{ - SetInt(UT); - sprintf(UTstring,"%04d:%03d:%02d:%02d:%02d",(UT->year),(UT->day),(UT->hour), - (UT->min), (UT->sec)); -} -/*------------------- end of WriteFmtTime -------------------*/ - -/*========================================================= - * Functions for DECODERs - * These functions make conversion from/to DD double/DD_time_structure and - * a integer array as follows: - * {Year, Month, Day_Of_Month, Hour, Min, Sec, Mls} - *========================================================*/ -/*-------------------------------------------------------- - * UT2double() - * Fille the DD_time_structure with double fild from the - * integer array (see the section header) - *-------------------------------------------------------*/ -dd_tmstr_t *UT2double(unsigned *ut) -/* Fill the standard structure with double too using as - * argument 7 int length array in Gavrilova Passport Standard - */ -{ -static dd_tmstr_t UT; -int visocos; - -if(ut[0]%4 == 0) visocos = 1; else visocos = 0; -UT.year = ut[0]; -UT.day = monthday[visocos][ut[1] - 1]+ut[2] - 1; -UT.hour = ut[3]; -UT.min = ut[4]; -UT.sec = ut[5]; -UT.msec = ut[6]; - -SetDouble(&UT); -return(&UT); -} -/*-------------------------------------------------------*/ -/*------------------------------------------------------- - * Double2UT() - * Converts Standard DD double time to interger array (see - * the section header) - *--------------------------------------------------------*/ -unsigned *Double2UT(double t) -{ - static unsigned UT[7]; - dd_tmstr_t tm; - int i,visocos; - - tm.times = t; - SetInt(&tm); - if(tm.year % 4 == 0) visocos = 1; else visocos = 0; - i = 0; - while((i < 12) && (tm.day >= monthday[visocos][i])) i++; - UT[0] = tm.year; - UT[1] = i; - UT[2] = tm.day +1 - monthday[visocos][i-1]; - UT[3] = tm.hour; - UT[4] = tm.min; - UT[5] = tm.sec; - UT[6] = tm.msec; - - return( (unsigned *)UT); -} -/*=======================================================================*/ diff --git a/src/DECODERS/ascii2nc/CMakeLists.txt b/src/DECODERS/ascii2nc/CMakeLists.txt index cc3fba6..4697865 100644 --- a/src/DECODERS/ascii2nc/CMakeLists.txt +++ b/src/DECODERS/ascii2nc/CMakeLists.txt @@ -2,7 +2,7 @@ PROJECT(ascii2nc) include_directories( - ${CMAKE_HOME_DIRECTORY}/src/INCLUDE/ + ${DDCLIENTINCLUDE_DIR} ${NETCDFINCLUDE_DIR} ) @@ -17,7 +17,7 @@ ADD_EXECUTABLE (ascii2nc ${source_files} ) target_link_libraries( ascii2nc - DD_Client + ${DDCLIENTLIBRARY} ${NETCDFLIBRARY} ) diff --git a/src/DECODERS/cdf2nc/CMakeLists.txt b/src/DECODERS/cdf2nc/CMakeLists.txt index 8213f69..199beaf 100644 --- a/src/DECODERS/cdf2nc/CMakeLists.txt +++ b/src/DECODERS/cdf2nc/CMakeLists.txt @@ -2,7 +2,7 @@ PROJECT(cdf2nc) include_directories( - ${CMAKE_HOME_DIRECTORY}/src/INCLUDE/ + ${DDCLIENTINCLUDE_DIR} ${NETCDFINCLUDE_DIR} ${libcdf_INCLUDE_DIR} ) @@ -18,7 +18,7 @@ ADD_EXECUTABLE (cdf2nc ${source_files} ) target_link_libraries( cdf2nc - DD_Client + ${DDCLIENTLIBRARY} ${NETCDFLIBRARY} ${libcdf_LIBRARIES} ) diff --git a/src/DECODERS/nc2nc/CMakeLists.txt b/src/DECODERS/nc2nc/CMakeLists.txt index ced0d24..b0efc7e 100644 --- a/src/DECODERS/nc2nc/CMakeLists.txt +++ b/src/DECODERS/nc2nc/CMakeLists.txt @@ -2,7 +2,7 @@ PROJECT(nc2nc) include_directories( - ${CMAKE_HOME_DIRECTORY}/src/INCLUDE/ + ${DDCLIENTINCLUDE_DIR} ${NETCDFINCLUDE_DIR} ) @@ -17,7 +17,7 @@ ADD_EXECUTABLE (nc2nc ${source_files} ) target_link_libraries( nc2nc - DD_Client + ${DDCLIENTLIBRARY} ${NETCDFLIBRARY} ) diff --git a/src/DECODERS/themis/esa2nc/CMakeLists.txt b/src/DECODERS/themis/esa2nc/CMakeLists.txt index 0107ff7..f7c789c 100644 --- a/src/DECODERS/themis/esa2nc/CMakeLists.txt +++ b/src/DECODERS/themis/esa2nc/CMakeLists.txt @@ -2,7 +2,7 @@ PROJECT(themis_esa2nc) include_directories( - ${CMAKE_HOME_DIRECTORY}/src/INCLUDE/ + ${DDCLIENTINCLUDE_DIR} ${NETCDFINCLUDE_DIR} ${libcdf_INCLUDE_DIR} ) @@ -18,7 +18,7 @@ ADD_EXECUTABLE (themis_esa2nc ${source_files} ) target_link_libraries( themis_esa2nc - DD_Client + ${DDCLIENTLIBRARY} ${NETCDFLIBRARY} ${libcdf_LIBRARIES} ) diff --git a/src/DECODERS/themis/esafull2nc/CMakeLists.txt b/src/DECODERS/themis/esafull2nc/CMakeLists.txt index add9042..44424a2 100644 --- a/src/DECODERS/themis/esafull2nc/CMakeLists.txt +++ b/src/DECODERS/themis/esafull2nc/CMakeLists.txt @@ -2,7 +2,7 @@ PROJECT(themis_esafull2nc) include_directories( - ${CMAKE_HOME_DIRECTORY}/src/INCLUDE/ + ${DDCLIENTINCLUDE_DIR} ${NETCDFINCLUDE_DIR} ${libcdf_INCLUDE_DIR} ) @@ -18,7 +18,7 @@ ADD_EXECUTABLE (themis_esafull2nc ${source_files} ) target_link_libraries( themis_esafull2nc - DD_Client + ${DDCLIENTLIBRARY} ${NETCDFLIBRARY} ${libcdf_LIBRARIES} ) diff --git a/src/DECODERS/themis/esamom2nc/CMakeLists.txt b/src/DECODERS/themis/esamom2nc/CMakeLists.txt index e1cb4e0..8a96509 100644 --- a/src/DECODERS/themis/esamom2nc/CMakeLists.txt +++ b/src/DECODERS/themis/esamom2nc/CMakeLists.txt @@ -2,7 +2,7 @@ PROJECT(themis_esamom2nc) include_directories( - ${CMAKE_HOME_DIRECTORY}/src/INCLUDE/ + ${DDCLIENTINCLUDE_DIR} ${NETCDFINCLUDE_DIR} ${libcdf_INCLUDE_DIR} ) @@ -18,7 +18,7 @@ ADD_EXECUTABLE (themis_esamom2nc ${source_files} ) target_link_libraries( themis_esamom2nc - DD_Client + ${DDCLIENTLIBRARY} ${NETCDFLIBRARY} ${libcdf_LIBRARIES} ) diff --git a/src/DECODERS/themis/fgm2nc/CMakeLists.txt b/src/DECODERS/themis/fgm2nc/CMakeLists.txt index 6f4ed0d..3acec22 100644 --- a/src/DECODERS/themis/fgm2nc/CMakeLists.txt +++ b/src/DECODERS/themis/fgm2nc/CMakeLists.txt @@ -2,7 +2,7 @@ PROJECT(themis_fgm2nc) include_directories( - ${CMAKE_HOME_DIRECTORY}/src/INCLUDE/ + ${DDCLIENTINCLUDE_DIR} ${NETCDFINCLUDE_DIR} ${libcdf_INCLUDE_DIR} ) @@ -18,7 +18,7 @@ ADD_EXECUTABLE (themis_fgm2nc ${source_files} ) target_link_libraries( themis_fgm2nc - DD_Client + ${DDCLIENTLIBRARY} ${NETCDFLIBRARY} ${libcdf_LIBRARIES} ) diff --git a/src/DECODERS/themis/sst2nc/CMakeLists.txt b/src/DECODERS/themis/sst2nc/CMakeLists.txt index c97f625..6ff47d1 100644 --- a/src/DECODERS/themis/sst2nc/CMakeLists.txt +++ b/src/DECODERS/themis/sst2nc/CMakeLists.txt @@ -2,7 +2,7 @@ PROJECT(themis_sst2nc) include_directories( - ${CMAKE_HOME_DIRECTORY}/src/INCLUDE/ + ${DDCLIENTINCLUDE_DIR} ${NETCDFINCLUDE_DIR} ${libcdf_INCLUDE_DIR} ) @@ -18,7 +18,7 @@ ADD_EXECUTABLE (themis_sst2nc ${source_files} ) target_link_libraries( themis_sst2nc - DD_Client + ${DDCLIENTLIBRARY} ${NETCDFLIBRARY} ${libcdf_LIBRARIES} ) diff --git a/src/INCLUDE/DD.h b/src/INCLUDE/DD.h deleted file mode 100755 index 646ce63..0000000 --- a/src/INCLUDE/DD.h +++ /dev/null @@ -1,143 +0,0 @@ -/*================================================================================================= - * DD SYSTEM - * DD.h - * Version: 6.0 - * Description: The public header to use DD library libDD.a - * List of changes: - * Apr. 17, 2002 Fedorov, - New error constant to interrupt the - * transmission if data dimensions are changed from file - * to file - * Nov 18, 2004 - V.4.2 - Fedorov, New errors for CACH manipulating - * Jun 17, 2007 - V.4.6 Fedorov New requestes and external executables - * Aug 02, 2007 - V.4.7 Fedorov Modification of call external executables - * Sep 24, 2007 - V.5.0 Fedorov New status of Get Data: MOREDELAY - * May 21, 2008 - V.5.1 Fedorov New Status of SetTime: CTIMEISSHIFTED - * Oct 18, 2012 - V.5.2 Knizhnikova New DD_SetTimeInfo() function - *=================================================================================================*/ - -#include "DD_time.h" - -typedef struct { int type; /* Type of variable in netcdf style */ - int DimNumber; /* number of dimensions */ - int *Dimensions; /* Dimensions array - * fastest change is last */ - int VarNumber; /* Dimension of variable array */ - void **Variables;/* Variables array pointer - * It is static array refreshed - * each call - */ - } DD_data_t; - -/*------------------- FUNCTIONS ---------------------------*/ - -#ifdef __cplusplus -extern "C" { -#endif - -extern int DD_SetVariable(char *VarName); -/* - * VarName - full name of variable :: - * Returns VarID or negative in case of error (see bellow) - */ - -extern int DD_GetInform(int VarID,char *AttrName, DD_data_t **data); -/* - * VarID - Variable ID from DD_SetVariable - * AttrName - name of attribute ( defined by konvention ) - * data - address of data structure - * Returns 1 if OK and negative value in case of error (see bellow) - */ - -extern int DD_SetTime(int VarID, char *Time); -/* - * VarID - Variable ID from DD_SetVariable - * Time - string defined in DD_time.h - * Returns 1 if OK and negative value in case of error (see bellow) - */ - -extern int DD_SetTimeInfo(int VarID, char *Time, double *RealTime); -/* - * VarID - Variable ID from DD_SetVariable - * Time - string defined in DD_time.h - * RealTime - time pointer was set to - * Returns 1 if OK and negative value in case of error (see bellow) - */ - -extern int DD_GetMultiData(int VarID, size_t VarSize, char **VarNames, char *TimeInt, DD_data_t **data, int BackFlag); -/* - * VarID - Variable ID from DD_SetVariable - * VarSize - number of variables to return - * VarNames - the array of Names of the requested Variable - * TimeInt - String of Time interval in DD_time style - * data - Data structures array - * BackFlag - 0 - pointer is at the lasy position, 1 - pointer returns to the start point - * Returns 1 if OK and negative value in case of error (see bellow) - */ - -/* ---------------------------------------- - * This function below just call DD_GetMultiData - * for backup - *---------------------------------------*/ -extern int DD_GetData(int VarID, char *VarName, char *TimeInt, DD_data_t **data); - -extern int DD_MovePoint(int VarID, int RecordNumber); -/* - * VarID - Open virtual instrument ID - * int RecordNumber - +/- records to move - * Move pointer in the open instrument and return 1 or negative if error - */ - -extern int DD_Close(int VarID); -/* - * VarID - Variable ID from DD_SetVariable - * Returns 1 if OK and negative value in case of error (see bellow) - */ - -extern char *DD_GetVersion(); -/* - * return static pointer to internal string with the DDLIB-SERVER package version - */ - -/*----------- Data Update functions -----------------------------------*/ -extern int DD_AddDataSet(char *DataSetName, char *RemSetID, char *BaseName); -/* - * Request for new VI. See ../DOC/TECHDOC/DDServFunct.html - */ - -#ifdef __cplusplus -} -#endif - -/*--------------------- CONSTANTS -----------------------------------------*/ -#define MOREDATA 1 /* There is data, but we have to call GetData again right now*/ -#define MOREDELAY 2 /* There is data, but we have to call GetData again after delay */ -#define OK 0 /* It is last data packet */ -#define NOCONNECTION -1 -#define TOOMANYREQ -2 -#define REQSENDERR -3 -#define REPLYRECERR -4 -#define NOID -5 -#define NOREFFILE -6 -#define NOTIMESFILE -7 -#define NOINFOFILE -8 -#define NOVAR -9 -#define OUTOFTIME -10 -#define CACHERR -11 /* The error occured when program manipulated the cach */ -#define CACHTOOREC -33 /* Off files in the CASH are created less then 5 sec ago */ -#define WAITEXTCALL -34 /* Server Waits external call finish */ -#define TRYAGAIN -35 /* Times file is locked. This request should be repeated again */ -#define NODATAATTIME -36 /* Requested time is inside NODATA time interval */ -#define GAPISSMALL -37 /* Gap is too small to call external archive */ -#define CTIMEISSHIFTED -38 /* The request was in NoData interval, try again with time at the end */ -#define DATAFILEERR -12 /* The error while manipulate with data file */ -#define ENVIRERROR -13 /* Error in Environments */ -#define NOPOINTER -14 /* The pointer points nowhere, SetTime were failed */ -#define INTSERERR -15 /* Server internal error */ -#define TIMEINEMPTY -16 /* No data for specified time interval */ -#define NOEXEC -17 /* No executable */ - -#define DD_SHORT 4 -#define DD_INT 1 -#define DD_FLOAT 2 -#define DD_DOUBLE 3 -#define DD_CHAR 0 diff --git a/src/INCLUDE/DD_Access.h b/src/INCLUDE/DD_Access.h deleted file mode 100755 index a1d3b10..0000000 --- a/src/INCLUDE/DD_Access.h +++ /dev/null @@ -1,93 +0,0 @@ -/* ====================================================== - * - * DD_Access.h - * V.2.0 - * Last revision: Oct 7, 2002 - * List of revisions: 1997 - version 1.0 - * Oct 7, 2002 - version 2.0 (update a little ) - */ - -#define MAXHOSTLENGTH 16 /* IP-address: "255.255.255.255\0" */ -#define USRLENGTH 21 /* Length of UserName: + \0 */ -#define TICKETLENGTH 9 /* Length of passwd: 8 + \0 */ -#define HOSTNAMELENGTH 120 /* Length of the user host name */ -#define USERCASHLEN 100 /* Size of user_ticket.nc file must be 300 */ -#define NONAME "no_name\0" /* Name of user in case of non-WEB connection */ -#define ACCINSTR "iball:acc:all" /* Instrument which watch the access */ -#define TICKET_PATH "/ACC/user_ticket.nc" -#define USERREFNAME "/ACC/user_info.nc" -#define LOGFILE "/ACC/login.log" - -/*------------ Errors of ACCESS ---------------------*/ -#define NOPERMISSION -100 -#define NOHOST -101 -#define NOUSERSFILE -102 - -/*--------------- Extern global variables -------------------*/ -extern char UserName[USRLENGTH]; /* defined in DD_client.c */ -extern char UserHost[MAXHOSTLENGTH]; /* defined in DD_client.c */ -extern int UserID; /* defined in DD_client.c */ - -/*--------------- Extern Functions ---------------------------*/ -extern int FillStruct (int argc, void **argv); -/* This function used to set up the host address from IDL (when WWW access used) - * Arguments allocation is as follows: - * UserName - 0 - * UserHost - 1 - * Location: DD_idl.c -> DD_idl.so -*/ - -extern int GetTicket(int UID, char *HostName, int DD_user_id); -/* Description: This function find the user data in user_cash.nc - * If O'k rewrite the line with new time. - * In case of a new user, remove the first line with - * older time data then a current time + 4.5 hours. - * - Takes 3 arguments: UserId (id in the romote host) - Remote host address(string,like "193.232.6.60\0") - DD_user_id(can see in user_info.nc) - - Returns 0 if O'k or NOPERMISSIONS, or ERROR - - If DD_log_name equal NULL searching for UserId, IP-address - If DD_log_name nonequal NULL searching for IP-address,DD_log_name* - * - */ -extern int CheckTicket(char *NameUsr, char *Ticket); -/* Description: This function check if user exosts - * in user_info.nc file. Returns DD_id if O'k. - * It returns NOPERMISSION or other errors - */ - -extern int ShowTicket(int userid, char *hostname, char *DD_name); -/* - * Show if user has authorisation to work - */ - -extern int LoginRequest(char *UserPasswd, char *UserLogin, char *HostName); -/* Description: Library function for client-server using. - * Send ID, Password,UserLogin, and host to server. - * Compares the information with your {id,hostname and other}. - * Returns 0 if O'k, or a negative value in case - * of "NOPERMISSION" or error. - * - */ -extern int SetUser(int UserID, char *HostName, char *LogName); -/* Description: Library function for client-server using. - * Send UserID, HostName to server. - * Compares the information with your {id,hostname}. - * Returns 1 if O'k, or a NOPERMISSION, or error number - */ - -extern int CheckID(char *NameUsr); -/* Description: This function check the user name in user_info.nc file. - * Returns DD_id if exists. - * It returns NOPERMISSION or other errors - */ - -extern void Put2Log(int UID, char *Host, char *LogName, int error); -/* Description: This function logs a user's ID, IP-address of a local host, - * login name and permission information into log file. - * - */ - diff --git a/src/INCLUDE/DD_comm.h b/src/INCLUDE/DD_comm.h deleted file mode 100755 index 94a5037..0000000 --- a/src/INCLUDE/DD_comm.h +++ /dev/null @@ -1,412 +0,0 @@ -/*================================================================================= - * DD SYSTEM base package - * DD_Server DD_Client library - * DD_comm.h - * V. 6.0 - * Changes listing: - * Feb 27 1995 - V 1.0 - * 13 Apr. 2002 - changed for NetCDF 3.3 - * 03 Oct. 2002 - v.4.0 Fedorov, communication ideology is changed - * Oct 31, 2002 - V.4.1 Fedorov, UserName, UserHost and UserID transferred into DD_Access.h - * May 7, 2003 - V.4.2 Fedorov, The Cash structure is changed (flag of open file ) - * June 17, 2003 - V.4.3 Fedorov, The Maximal Packet Size is changed - * Nov 18, 2004 - V.4.4 Fedorov, Some changes - * Aug 17, 2005 - V.4.5 Fedorov, Cach Time constant is changed - * Jun 17, 2007 - V.4.6 Fedorov, New requestes and external executables - * Aug 01, 2007 - V.4.7 Fedorov, Cache length = 20, New DD_Var_t structure - * Sep 20, 2007 - V.5.0 Fedorov, Update Time Info library now in the separate file - * Sep 23, 2007 - V.5.1 Fedorov, New interface of SetTime - * Sep 25, 2007 - V.5.2 Fedorov, Individual minimal gap - * Oct 08, 2007 - V.5.3 Budnik, php createVI.php - * Jan 25, 2008 - V.5.3.1 Budnik, min data gap = 1 day!!!! - * May 22, 2008 - V.5.4 Fedorov, DD_Var_t has a LockStartTime value - * May 27, 2008 - V.5.5 Fedorov, Maximal tracnsmition buffer - * Sep 19, 2008 - V.5.6 MAXVARLENGTH=64 REQUESTLENGTH 184 - * Dec 15, 2012 - V.6.0 New multiparam Get_MultiData() function - *===================================================================================*/ - -#include -#include -#include -#include -#include -#include -#include -#include "DD_Access.h" - -#ifdef SOLARIS -#include -#include -#include /* internet stile addres */ -#include -#include -#include -#endif /* SOLARIS */ - -#ifdef HPUX -#include -#include -#include -#include -#include -#include -#endif - -#ifdef OSF1 -#include -#include -#include -#include -#endif /* OSF1 */ - -#ifdef LINUX -#include -#include -#include -#include -#include -#endif /* LINUX */ - -#ifdef SUNOS -#include -#include -#include -#include -#include -#endif /* SUNOS */ - -/*----------------- Defenitions of request and server replies --------------------*/ -/* 1. Data manipulation requests */ -#define OPENINSREQ 0 /* Open virtual instrument */ -#define DATAINFOREQ 1 /* Request of constant info */ -#define TIMESETREQ 2 /* Position of pointer by StartTime*/ -#define DATAGETREQ 3 /* Data request by time interval */ -#define CLOSEINSREQ 4 /* Request to close virtual instrument */ -#define MOVPOINTREQ 5 /* Move the pointer od data request*/ -#define ADDVIREQ 6 /* Add New virtual instrument */ - -/* 2. Security requests */ -#define GETTICKETREQ 10 -#define SHOWTICKETREQ 11 - -/*-------- Some constants ------------------*/ -#define EMPTY 0 /* Filler of the trailer */ -#define FILEACCMARG 1 /* The minimum time from the last access to remove this file */ - -/*------------ Important lengths and pathes ----------------*/ -#define PROTOCOL 0 /* protocol TCP */ -#define REPLYLENGTH 12 /* Length of header of reply packet */ -#define REQUESTLENGTH 196 /* Length of request packets MAXSETLENGTH + 2*MAXVARLENGTH + 16 */ -#define MAXVARLENGTH 64 /* Length (with \0) of Variable Name */ -#define MAXSETLENGTH 52 /* Max Length of VI name */ -#define PATHLENGTH 128 /* Length of complete path */ -#define MAXFILENAME 32 /* The maximal length of the data file (info, cach, times as well)*/ -#define REFNAME "/refer.nc" /* path name for databse refer file */ -#define CASHLEN 20 /* Length of cash array */ -#define TRY 100 /* How many tymes to ask the socket */ -#define MAXPACKSIZE 5000000 /* Maximal size of one packet of transmission in bytes */ -#define MAXCOMMANDL 300 /* Command in system() maximal length -/*------------------------------------------------- - * XDR length to calcolate the total len - *-------------------------------------------------*/ -#define XDRINTLEN 4 -#define XDRFLOATLEN 4 -#define XDRDOUBLELEN 8 -// String length is counted as 4B + N + r (to completed to 4 bytes) - -/*------------ List of External Call of DD_Server and ERRORS -------------------*/ -#define ADDDATASETCALL "php %s/CALLEXT/createVI.php %s %s %s" /* Format to call to create new VI */ -#define GETNEWDATACALL "php %s/CALLEXT/getData%s.php %s %s %s %s &" /* Format to call to get new data */ -#define NOPHP 32512 -#define NOSCRIPT 256 -#define PHPOK 0 - -/*------ Constant to understand data availabilities -------------------------------*/ -#define GLOBSTARTNAME "GlobalStart" -#define GLOBSTOPNAME "GlobalStop" -#define SAMPLNAME "MinSampling" -#define REMARCHNAME "DataBaseID" -#define REMINSTNAME "DataSetID" -#define MINGAP 86400.0 /*Seconds. The minimal time gap to set up the flag DATAGAP */ -#define REQTIMEINT 86400.0 /* One day, +/- of request time interval */ -#define ISOTIMEF "%4u%*1c%2u%*1c%2u%*1c%2u%*1c%2u%*1c%2u%*1c%3u" /* Format to READ time in ISO format */ -#define ISOTIMEP "%04u-%02u-%02uT%02u:%02u:%02u.%03uZ" /* Format to PRINT time in ISO format */ -#define NODATASTR "NODATA" -#define DIRLOCK "LOCK" - -#define QUANTOFFSET 0.01 -/*------------- More internal specifications -----------------------*/ -/* - * See ../DOC/TECHDOC/DDGenProt.html (lyx) - */ - -/* Reply variables: - * Error - negative value described in DD.h - * Type - int (see DD.h) - * Dim_Number - int ( the dimension (vector, matrix, cube, etc) ov the variable) - * Data_Size - int (the size of the data packet in bytes) - * RemID - int (number of virtual instruments still open in this session) - * Dim - int (the particular dimension ) - * LastPacketFlag - int ( == OK in this packet is last, or MOREDATA) - * Data - array of Type of Dim X Dim X....X Dim size - * -------------------- - * Dim_Number - * DataPacket: - * - * | - * | | - * <.....> | Dim_Number | Data_Size bytes - * | | - * | - * ..... | only for real data | - * | | - * - * Note is the value is scalar - the Dim = 0 (???) - */ - -/* REPLY SPECIFICATION - * - * Reply consists Header 12 bytes length and Data Block - * - * on Open Virtual instrument: - * - * on Constant Info request: - * - * on Set pointer by StartTime: - * - * on Get Data by TimeInt : - * - * on Move pointer with records number - * - * on Close Virtual Instrument - * - */ - -/*-------------------- TYPEDEF ---------------------------*/ -typedef struct { - char CacheFilePath[PATHLENGTH]; - char names[CASHLEN][MAXSETLENGTH]; - long times[CASHLEN]; - int FileOpen[CASHLEN]; /* 1 if file is open */ - int ID; /* ID of open cach file */ - int nameID; /* ID of names array */ - int timeID; /* ID of times array */ - int fopenID; /* ID of fopen flag */ - } DD_cash_t; /* The structure holding cash informaton - * of particular virtual instrument DataBase - */ - -/* - * This structure corresponds to ONE requested variable - * of some Virtual instrument - */ -typedef struct { char InstrName[MAXSETLENGTH]; /* Virtual Instrument Name */ - char path[PATHLENGTH]; /* Path to directory of open virtual instrument */ - /*--------------------------------------- - * Cache part - *--------------------------------------*/ - DD_cash_t Cash; /* Cash holder */ - int CurrCushN; /* Current cash pointer */ - /*-------------------------------------- - * This is the part of open data file and corresponding data set - *-------------------------------------*/ - int ncID; /* ID of open nc_file */ - size_t nc_rec; /* the current record number nc_file */ - size_t Maxnc_rec; /* Maximum of records number in in the current nc file */ - DD_data_t *VarData; /* Static pointer. Variables Holder */ - size_t ParamSize; /* Number or requested variables to save */ - /*--------------------------------------------- - * This is part of times file of given VI - *--------------------------------------------*/ - char TimesFileName[PATHLENGTH]; - double SDTime; /* Requested Start Time in double form */ - double FDTime; /* Requested Stop Time in double form */ - double CDTime; /* Current Time in double form */ - int tmID; /* ID of "times" file of this virtual instrument*/ - int NameID; /* ID of FileName variable in times file */ - int StartID; /* ID of Start variable in times file */ - int StopID; /* ID of Stop variable in times file */ - size_t TimeRecNumber; /* Current Record number in the "times" file */ - size_t MaxTimeRecNum; /* Maximum records number in the "times" file */ - int RValidMin; /* Minimal record with valid data */ - int RValidMax; /* Maximal record with valid data */ - double MinValidTime; - double MaxValidTime; /* Start of RValidMin, and stop of RValidMax */ - int CurrRmin; /* Sure that looking time is greater than stop; -1 if NOT */ - int CurrRmax; /* Sure that looking time is less than start; -1 if NOT */ - /*------- Working with external Data Base ------------------------------*/ - int VILocked; /* Flag to show that request to remote database has been sent */ - time_t LockStartTime; /* Value to calculate a time elapsed from lock made by THIS VI */ - /*---------- This is the part of Info file of given VI -----------------*/ - int attrID; /* ID of constant information nc_file */ - char AttrName[PATHLENGTH]; /* Name of constant information file */ - DD_data_t AttrData; /* Dimensions of Attributes */ - /*---- Part concerning External call ------------------*/ - double MinGap; /* The minimal gap between two files */ - double GlobalStart; /* The principal begin of data */ - double GlobalStop; /* The principal end of data */ - char BaseName[MAXSETLENGTH]; /* The name of external data archive */ - char RemSetID[MAXSETLENGTH]; /* The name of VI in exterval archiving */ - int ExtCallAllowed; /* 1 If Server can call external archiving */ - /*------------ Flow Control -----------------------------*/ - int LastPacketFlag; /* OK - request is completed, - * MOREDATA - one or several blocks expected, - * MOREDELAY - wait, system is blocked */ - int LastFileStatus; /* The file status after the last SetNewFile */ - int NewFile; /* 1 if File was changed, VI has to be refreshed*/ - int NewFileWasOpen; /* 1 if the original position of pointer - * (in data file, times file) was lost after open - * a new data file */ - } DD_Var_t; - -/*---------------- Usefull enumerations ---------------------*/ -enum SearchRet {REACHLEFT, REACHRIGHT, OKLEFT, OKRIGHT}; - /* - * enumerate of the status of time inteval searching - * NOONEDATA - no data at al in this VI - * INSIDE - CTime is inside valid data interval (tolerance is MINGAP) - * DATAATRIGHT, DATAATLEFT - Valid interval is on the right/left from CTime - */ -enum SearchIntRet {NOONEDATA, INSIDE, DATAATRIGHT, DATAATLEFT, IDLE}; - -/* Return function IsTimesLocked */ -enum LockStatus {NOLOCK, LOCKED, LOCKREMOVED}; - - -/*------------------ Function for Server ---------------------*/ -extern int OpenInstr(char *InstrName); - -/* - * Init shared memory for cache system - */ -extern void Cache_Init(); - -/* - * Free shared memory used for cache system - */ -extern void Cache_Free(); - -/* - * Free shared memory used for cache system - */ -extern int Cache_RequestDataFileAccess(DD_Var_t *D, char* dataFileName); - -/* - * Free shared memory used for cache system - */ -extern int Cache_ReleaseDataFileAccess(DD_Var_t *D); - -/* - * Close cache file - */ -extern int Cache_CloseFile(DD_Var_t *D); - -/* - * Open Virtual instrument by name and returns the ID - * Returns negative value in case of error (see DD.h)or OK - */ -extern int GetAttribute(int ID, char *Name); -/* - * Variable - address of structure with variable description - * Name - name of attribute - * Returns OK or an error (see DD.h) - */ -extern int GetMultiData(int ID, int VarSize, char **VarNames, char *TimeInterval, int BackFlag); -/* - * VarSize - size of the array of Names - * Names - array of strings with names of requested variables, - * TimeInterval - Time in DD_time.h style - * Returns negative value in case of error (see bellow) - * Returnes MOREDATA if "there is more data", and OK if data is finished. - */ - -extern int SetTime(DD_Var_t *D, double CTime); -/*################################################################# - * SET TIME - * Set time and try to open appropriate data file. If not try to - * call external archive - * D - address of VI holder - * Time - Time in DD_time.h style - * Return: - * OK - * NOID - call with uncorrect VI holder - * OUTOFTIME - Requested time is out of General time limitation - * WAITEXTCALL - Server sent request to external archive - * TRYAGAIN - VI is blocked by call to external database - * NODATAATTIME - request time is inside NODATA time interval - * some return of SetNewFile(); see ... - *#################################################################*/ - -extern int CloseID(int ID); -/* ID - integer identificator of opened Data Set - * Returns number of remained IDs of this communication seasson - * in case of 0 the server closes this comminication session - */ - -int SetNewFile(DD_Var_t *D, int N); -/* - * Function tries to get new data for the gap beetween files, or just - * open a new data file according to offset N referring to current position in the times file. - * The current position changed if file is succesefully open. - * Return values: - * OK - * OUTOFTIME - next interval exceeeds GlobalStart/Stop - * TIMEINEMPTY - next interval marked as "NODATA" - * TRYAGAIN - the VI is blocked while new data is arriving - * WAITEXTCALL - new data is requested - * CACHTOOREC - now free space in the CACH - * CHACHERR - unrecovable error in CACH - * DATAFILEERR - unrecovable error in data file - */ - -size_t MaxRecord(int ncID); -/* - * Inspect all variables and dimensions of the file (exept Time associated) and - * returm maximal record number to transmit - */ - -/*------------------ Global constants ----------------------------------*/ -static u_int xdrlen[] = {4,4,4,8,4}; -static size_t unixlen[] = {sizeof(char),sizeof(int),sizeof(float),sizeof(double),sizeof(short)}; -static bool_t ( *ConvFunc[5])() = {xdr_char, xdr_int, xdr_float, xdr_double, xdr_short}; - -/*------------------ Global data variable for entire session --------------------*/ -extern DD_Var_t **DD_Var ; /* Actually this variable is implimented - * in DD_GetData.c . The dimension of this array is defined - * by sysconf(_SC_OPEN_MAX)*/ -extern size_t MaxIDNumber; /* Size of DD_Var array. Defined actually in DD_GetData.c */ - -/* - * Fuctions prototypes in ExtDataRequest.c file - */ -/*====================================================================== - * IsTimesLocked - * Return 1 if there is LOCK in the VI directory - *======================================================================*/ -extern int IsTimesLocked(DD_Var_t *DD_Var); - -/*====================================================================== - * ExtDataRequest - * Return folowing values: - * OK - request is accepted SERVER has to wait when LOCK file is gone - * NOEXEC - error in external executable - * NODATAATTIME - time corresponds to the NODATA interval - * GAPISSMALL - Time is inside too small gap - *======================================================================*/ -extern int ExtDataRequest(DD_Var_t *DD_Var, double CurrTime); - -/*======================================================================= - * UpdateTimeInfo.c - * int SearchLeft(DD_Var_t *DD_VarL, size_t Rmin, size_t Rmax) - * int SearchRight(DD_Var_t *DD_VarL, size_t Rmin, size_t Rmax) - * Search the next to the left(right) non-empty time interval - * DD_VarL - common data structure corresponding to THIS open VI - * Rmin, Rmax - start points - * - * int UpdateTimeInfo(DD_Var_t *DD_VarL) - * Function reopen "times" file and update all time constants - *======================================================================*/ -extern int SearchLeft(DD_Var_t *DD_VarL, size_t Rmin, size_t Rmax); -extern int SearchRight(DD_Var_t *DD_VarL, size_t Rmin, size_t Rmax); -extern int UpdateTimeInfo(DD_Var_t *DD_VarL); - diff --git a/src/INCLUDE/DD_time.h b/src/INCLUDE/DD_time.h deleted file mode 100755 index 51c4720..0000000 --- a/src/INCLUDE/DD_time.h +++ /dev/null @@ -1,59 +0,0 @@ -/* This is header file for working with DD time */ -/* V.4.1 */ -/* name: DD_time.h - * Author: Andrey Fredorov - * Institution: IKI RAN - * Date: 21-Feb-1995 - * Last update Sept 05, 2011 - * Sept 05, 2011: V.3.2 SetIntNew => arg TimeKind => to work with 1970-1973 : BR - */ - -#define TIMELENGTH 17 - -typedef char dd_time_t[TIMELENGTH]; /* YYYYDDDHHMMSSMLS */ - -/* ---------------- Functions prototypes ----------------------*/ -extern double DD_Time2Double(dd_time_t DD_Time); -/* Convert string to double and return. - * Return negative value in case of error string format - */ -extern char *Double2DD_Time(double Time); -/* Convert double Time value into string form and return pointer to static string - * allocated INSIDE the library. Thus the value is renoveted each function call. - */ - -/*---------------- Backup compability with V.3.0 and earlier ----------*/ -typedef struct { double times; /* time sec from 1970 */ - int year; - int day; - int hour; - int min; - int sec; - int msec; - } dd_tmstr_t ; - - -extern dd_tmstr_t *ReadTime(char *UT); /* Read time from sring and fill static - * structure defined IN function. - * Returns pointer of strusture */ -extern char *WriteTime(dd_tmstr_t *UT); /* Get pointer of time structure - * and convert it into string - * Function returns pointer of - * internal string */ - -extern void WriteFmtTime(dd_tmstr_t *UT,char *UTstring); - -extern void SetDouble(dd_tmstr_t *UT); /* Fill double value of dd_tmstr_t */ - -typedef enum {DD_TM_UNKNOWN, DD_TM_TIME_INTERVAL, DD_TM_DATE} t_DDTimeKind; - -extern void SetInt(dd_tmstr_t *UT); /* Fill int values of dd_tmstr_t */ -extern void SetIntNew(dd_tmstr_t *UT,t_DDTimeKind timeKind); - -/*------- Functions for DECODERS ------------------------ - *These functions works with with Gavrilova's UT representation */ -extern dd_tmstr_t *UT2double(unsigned *UT); /* Set standard time - * structure and return - * its pointer - */ -extern unsigned *Double2UT(double Time); /*Converts Double to Gavrilova array */ diff --git a/src/SERVER/CMakeLists.txt b/src/SERVER/CMakeLists.txt index 2fbe06a..4516cc6 100644 --- a/src/SERVER/CMakeLists.txt +++ b/src/SERVER/CMakeLists.txt @@ -2,8 +2,8 @@ PROJECT(DD_Server) include_directories( - ${CMAKE_HOME_DIRECTORY}/src/INCLUDE/ ${NETCDFINCLUDE_DIR} + ${DDCLIENTINCLUDE_DIR} ) #Configuration de l'exécutable @@ -18,7 +18,7 @@ ADD_EXECUTABLE (DD_Server ${source_files} ) target_link_libraries( DD_Server ${CMAKE_THREAD_LIBS_INIT} - DD_Client + ${DDCLIENTLIBRARY} ${NETCDFLIBRARY} ${CRYPT_LIBRARY} ) diff --git a/src/TIMESUPDATE/CMakeLists.txt b/src/TIMESUPDATE/CMakeLists.txt index 04cad02..1713a7d 100644 --- a/src/TIMESUPDATE/CMakeLists.txt +++ b/src/TIMESUPDATE/CMakeLists.txt @@ -2,7 +2,7 @@ PROJECT(TimesUpdate) include_directories( - ${CMAKE_HOME_DIRECTORY}/src/INCLUDE/ + ${DDCLIENTINCLUDE_DIR} ${NETCDFINCLUDE_DIR} ) @@ -17,7 +17,7 @@ ADD_EXECUTABLE (TimesUpdate ${source_files} ) target_link_libraries( TimesUpdate - DD_Client + ${DDCLIENTLIBRARY} ${NETCDFLIBRARY} ) diff --git a/src/TIMESUPDATENODATA/CMakeLists.txt b/src/TIMESUPDATENODATA/CMakeLists.txt index 0628c35..9bdfe5c 100644 --- a/src/TIMESUPDATENODATA/CMakeLists.txt +++ b/src/TIMESUPDATENODATA/CMakeLists.txt @@ -2,7 +2,7 @@ PROJECT(TimesUpdateNoData) include_directories( - ${CMAKE_HOME_DIRECTORY}/src/INCLUDE/ + ${DDCLIENTINCLUDE_DIR} ${NETCDFINCLUDE_DIR} ) @@ -17,7 +17,7 @@ ADD_EXECUTABLE (TimesUpdateNoData ${source_files} ) target_link_libraries( TimesUpdateNoData - DD_Client + ${DDCLIENTLIBRARY} ${NETCDFLIBRARY} ) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 22f9163..905da56 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -2,7 +2,7 @@ PROJECT(testParallel) include_directories( - ${CMAKE_HOME_DIRECTORY}/src/INCLUDE/ + ${DDCLIENTINCLUDE_DIR} ) #Configuration de l'exécutable @@ -17,7 +17,7 @@ ADD_EXECUTABLE (testParallel ${source_files} ) target_link_libraries( testParallel ${CMAKE_THREAD_LIBS_INIT} - DD_Client + ${DDCLIENTLIBRARY} ) install (TARGETS testParallel DESTINATION tests) diff --git a/tests/testParallel.c b/tests/testParallel.c index 2cd9a75..ad3b5be 100644 --- a/tests/testParallel.c +++ b/tests/testParallel.c @@ -100,7 +100,7 @@ int runRequest(char* ViName, char* StartTime, char* TimeInt, int NbPar, char** P return 0; } - error = DD_SetTimeInfo(ID, StartTime, &RealTime); + error = DD_SetTimeInfo(ID, StartTime, &RealTime); if(error < 0) { error = DD_Close(ID); -- libgit2 0.21.2