154#include <netinet/in.h> 
  160#define MAX_LOG_FILE 64         
  166#include "error_mac.h" 
  169#include "f_ut_printm.h" 
  171#define fprintf  fprintm 
  199#define MAX_BUFSIZE 32768 
  224   {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL};
 
 
  226#ifdef __USE_LARGEFILE64 
  235int rfio_open64(
const char *pcFile,                     
 
  239   char cModule[32] = 
"rfio_open64";
 
  245      "\n-D- begin %s: file %s, flags %d, mode %d\n",
 
  246      cModule, pcFile, iFlags, iMode);
 
  252         "-E- 32 bit client: %s not supported\n", cModule);
 
  257   iFileId = 
rfio_open(pcFile, iFlags, iMode);
 
  260      "-D- end %s: iFileId(rfio_open) = %d\n\n", cModule, iFileId);
 
  279   char cModule[32] = 
"rfio_open";
 
  283   char *pcCopyPath = NULL;
 
  284   int iCopyFraction = 0;
 
  286   int iPathConvention = 0;
 
  289      printf(
"\n-D- begin %s: calling rfio_open_gsidaq\n", cModule);
 
  299      "-D- end %s, iFileId(rfio_open_gsidaq) = %d\n\n",
 
 
  359   char cModule[32] = 
"rfio_open_gsidaq";
 
  373   unsigned long *plFileSizeC;          
 
  386   int iDataMoverSelect = 0;
 
  400   char cServer[24] = 
"";
 
  401   int iSockMaster = -1;          
 
  422   char cAccess[16] = 
"";
 
  450   pDataMoverSelect = &(sDataMoverSelect.sDataMoverAttr);
 
  455   if (iFlags == O_RDONLY)
 
  458      strcpy(cAccess, 
"read");
 
  463      strcpy(cAccess, 
"write");
 
  469   else if (ii != 4) printf(
 
  470      "-W- unexpected size of long integer: %d byte\n", ii);
 
  475      printf(
"\n-D- begin %s (%d bit OS)", cModule, ii);
 
  477         printf(
", %d remote files currently open", 
iFileCount);
 
  487         pCommAPI = &(
pAPIFile[ii]->sCommAPI);
 
  488         strcpy(cObject, pCommAPI->
cNamefs);
 
  489         strcat(cObject, pCommAPI->
cNamehl);
 
  490         strcat(cObject, pCommAPI->
cNamell);
 
  493            printf(
"    %d: %s already open\n", ii, cObject);
 
  495         pcc = strstr(pcFile, cObject);
 
  500               printf(
"    %d: %s maps\n", ii, cObject);
 
  505         printf(
"    %d: no (more) open file found\n", ii);
 
  513         "-E- %s: requested file %s is already open\n",
 
  523         "-E- %s: max %d remote files may be open simultaneously\n",
 
  534         "-E- %s: allocating file control block no. %d (%d byte)\n",
 
  545      "    file control block no. %d allocated (%d byte)\n",
 
  556         printf(
"    query only, iOpenMode %d reset to 0\n", iOpenMode);
 
  561   pcurAPIFile->
iFileId = iFileId;
 
  562   pcurAPIFile->
iFlags = iFlags;
 
  563   pcurAPIFile->
iMode = iOpenMode;
 
  567   pcurAPIFile->
iOffset = iOffset;
 
  571   pcurAPIFile->
iAction = iAction;
 
  573   pCommAPI = &(pcurAPIFile->
sCommAPI);
 
  587   if ( (strchr(pcFile, *
pcStar) != NULL) ||
 
  588        (strchr(pcFile, *
pcQM) != NULL) ||
 
  589        (strchr(pcFile, *
pcPerc) != NULL) )
 
  592         "-E- %s: files with wildcard characters ('%s') not allowed using RFIO\n",
 
  604        "-E- %s(1): invalid remote file name '%s': node name missing\n",
 
  612   strcpy(cTemp, pcFile);
 
  615   strncpy(pcc, 
"\0", 1);       
 
  618   while (*pcc1 != 
'\0')
 
  620      *pcc1 = tolower(*pcc1);
 
  626      printf(
"    URL in small letters: '%s'\n", cTemp);
 
  629   pcc = strstr(cTemp, 
".gsi.de");
 
  632      strncpy(pcc++, 
":", 1);
 
  633      strncpy(pcc, 
"\0", 1);
 
  635         printf(
"    remove trailing '.gsi.de': %s\n", cTemp);
 
  639   if (strncmp(cTemp, 
"rfio", 4) == 0)
 
  647           "-E- %s(2): invalid prefix '%s' of remote file name: node name missing\n",
 
  653      strncpy(pcc1, 
"\0", 1);          
 
  656      if (strlen(pcc) == 0)
 
  659           "-E- %s(3): invalid remote file name '%s': node name missing\n",
 
  668         printf(
"    node name after prefix 'rfio': '%s'\n", 
cNodePrefix);
 
  670      if (strncmp(cTemp, 
"rfiodaq:", 8) == 0)
 
  674            fprintf(
fLogClient, 
"-E- %s: reading from DaqPool not allowed\n",
 
  676            fprintf(
fLogClient, 
"    correct object specification:\n");
 
  677            fprintf(
fLogClient, 
"    [rfio:]node:/archive/path/file\n");
 
  684         strcpy(cServer, 
"gStore entry server");
 
  687      else if (strncmp(cTemp, 
"rfio:", 5) == 0)
 
  690         strcpy(cServer, 
"gStore entry server");
 
  696         else if (iAction == 2)
 
  699      else if (strncmp(cTemp, 
"rfiocopy:", 9) == 0)
 
  702         strcpy(cServer, 
"RFIO server");
 
  710            "-E- %s: invalid remote file name '%s': unknown prefix\n",
 
  725            "-E- %s: invalid remote file name '%s': invalid prefix\n",
 
  732      if (strlen(pcc) == 0)
 
  735            "-E- %s(4): invalid remote file name '%s': node name missing\n",
 
  743      strcpy(cServer, 
"gStore entry server");
 
  749      else if (iAction == 2)
 
  752      strncpy(pcc, 
"\0", 1);           
 
  761      fprintf(
fLogClient, 
"-E- %s: gStore server %s no longer supported\n",
 
  771      if ( (iAction == 2) ||
 
  773         printf(
"    %s, request poolId %d\n", cServer, iPoolId);
 
  775         printf(
"    %s\n", cServer);
 
  783   if ( (strlen(pcc) == 0) || (strcmp(pcc, 
" ") == 0) )
 
  788            "-E- %s: missing remote object for read access\n", cModule);
 
  800            printf(
"    remote object will be initialized later\n");
 
  802            printf(
"    remote file will be initialized later\n");
 
  807      strcpy(pcNamefs, 
"");
 
  808      strcpy(pcNamehl, 
"");
 
  809      strcpy(pcNamell, 
"");
 
  818      pcc = (
char *) strchr(cTemp, *pcObjDelim);
 
  822            "-E- %s: invalid remote file name %s\n", cModule, cTemp);
 
  829      pcc1 = (
char *) strchr(pcc, *pcObjDelim);
 
  834            printf(
"    remote object %s\n", cTemp);
 
  836         if ( (pcc == NULL) || (pcc1 == NULL) )
 
  839               "-E- %s: invalid remote object name '%s': archive name missing\n",
 
  847         strncpy(pcc1, 
"\0", 1);          
 
  851            fprintf(
fLogClient, 
"-E- %s: archive name '%s' too long (max %d)\n",
 
  858         if (strlen(cTemp) < 2)
 
  860            fprintf(
fLogClient, 
"-E- %s: invalid archive name '%s'\n",
 
  867         strcpy(pcNamefs, cTemp);
 
  869            printf(
"    archive name %s\n", pcNamefs);
 
  871         strncpy(pcc, pcObjDelim, 1);          
 
  873         pcc1 = (
char *) strrchr(pcc, *pcObjDelim);
 
  877               "-E- %s: invalid remote object name '%s': path name missing\n",
 
  887            fprintf(
fLogClient, 
"-E- %s: file name '%s' too long (max %d)\n",
 
  894         if (strlen(pcc1) < 2)
 
  896            fprintf(
fLogClient, 
"-E- %s: invalid file name '%s'\n", cModule, pcc1);
 
  902         strcpy(pcNamell, pcc1);
 
  904            printf(
"    file name %s\n", pcNamell);
 
  907         strncpy(pcc1, 
"\0", 1);       
 
  911            fprintf(
fLogClient, 
"-E- %s: path name '%s' too long (max %d)\n",
 
  920            fprintf(
fLogClient, 
"-E- %s: invalid path name '%s'\n", cModule, pcc);
 
  926         strcpy(pcNamehl, pcc);
 
  928            printf(
"    path name %s\n", pcNamehl);
 
  934            fprintf(
fLogClient, 
"-E- %s: invalid gStore file name: %s\n",
 
  942         if (strcmp(pcNamehl, pCommAPI->
cNamehl))
 
  944            strcpy(pcNamehl, pCommAPI->
cNamehl);
 
  945            printf(
"    gStore path name corrected to %s\n", pcNamehl);
 
  947            strcpy((
char *) pcFile, 
cPrefix);
 
  948            strcat((
char *) pcFile, pCommAPI->
cNamefs);
 
  949            strcat((
char *) pcFile, pCommAPI->
cNamehl);
 
  950            strcat((
char *) pcFile, pCommAPI->
cNamell);
 
  952               "    new full file name: %s\n", pcFile);
 
  958            printf(
"    remote file %s\n", cTemp);
 
  960         strcpy(pcNamefs, 
"");
 
  963         pcc1 = (
char *) strrchr(cTemp, *pcObjDelim);
 
  966            fprintf(
fLogClient, 
"-E- %s: invalid remote file name '%s'\n",
 
  976            fprintf(
fLogClient, 
"-E- %s: file name '%s' too long (max %d)\n",
 
  983         if (strlen(pcc1) < 2)
 
  985            fprintf(
fLogClient, 
"-E- %s: invalid file name '%s'\n", cModule, pcc1);
 
  991         strcpy(pcNamell, pcc1);
 
  993            printf(
"    file name %s\n", pcNamell);
 
  995         strncpy(pcc1, 
"\0", 1);       
 
  999            fprintf(
fLogClient, 
"-E- %s: path name '%s' too long (max %d)\n",
 
 1000               cModule, cTemp, ii);
 
 1006         if (strlen(cTemp) < 2)
 
 1008            fprintf(
fLogClient, 
"-E- %s: invalid path name '%s'\n",
 
 1015         strcpy(pcNamehl, cTemp);
 
 1017            printf(
"    path name %s\n", pcNamehl);
 
 1019         strcpy(pCommAPI->
cNamefs, 
"\0");
 
 1020         strcpy(pCommAPI->
cNamehl, pcNamehl);
 
 1021         strcpy(pCommAPI->
cNamell, pcNamell);
 
 1033            "-E- copy from write cache only for write actions\n");
 
 1042            "-E- copy from write cache to lustre only when writing to DAQPool\n");
 
 1051            "-E- copy from write cache only supported with rfio_[f]newfile\n");
 
 1057      if ( (iCopyMode < 0) || (iCopyMode > 2) )
 
 1059         fprintf(
fLogClient, 
"-E- invalid copy mode: %d\n", iCopyMode);
 
 1065      if ( (strlen(pcCopyPath) == 0) || (pcCopyPath == NULL) )
 
 1067         fprintf(
fLogClient, 
"-E- copy path missing\n");
 
 1073      if (iCopyFraction < 0)
 
 1076            "-E- invalid fraction of files to copied: %d (must be > 0)\n",
 
 1083      if (iCopyFraction == 0)
 
 1086            "-W- fraction of files to copied: 0 specified, assume 1 (copy all)\n");
 
 1091      strcpy(cTemp, pcCopyPath);
 
 1095      while (*pcc != 
'\0')
 
 1097         *pcc = tolower(*pcc);
 
 1100      if (strcmp(cTemp, 
"rc") == 0)
 
 1103            "-E- copy to read cache not yet implemented\n");
 
 1109      strcpy(cTemp, pcCopyPath);           
 
 1117         pcc1 = strrchr(cTemp, 
'/');
 
 1118         ii = pcc1 - pcc + 1;
 
 1119         if (ii == strlen(pcc))
 
 1122            strncpy(pcc1, 
"\0", 1);
 
 1130         strcpy(pcCopyPath, cTemp);
 
 1132            "    %d trailing '/' ignored, use copy destination '%s'\n",
 
 1141            "-E- invalid copy destination %s\n", pcCopyPath);
 
 1150            "-E- invalid max file no. for copy destination: %d\n",
 
 1157      if ( (iPathConvention < 0) || (iPathConvention > 1) )
 
 1160            "-E- invalid convention no. for creation of new copy destination path: %d\n",
 
 1170            "-I- copy each file to %s", pcCopyPath);
 
 1172            "-I- copy each %d. file to %s", iCopyFraction, pcCopyPath);
 
 1173         if (iPathConvention == 1)
 
 1175         fprintf(
fLogClient, 
" before tape migration\n");
 
 1176         fprintf(
fLogClient, 
"    check success as asynchroneous copy process\n");
 
 1181            "-I- write data buffers of each file to gStore write cache and to %s",
 
 1184            "-I- for each %d. file write data buffers additionally to %s",
 
 1185            iCopyFraction, pcCopyPath);
 
 1186         if (iPathConvention == 1)
 
 1191      if ( (iMaxFile) && (strcmp(
"rc", pcCopyPath)) ) fprintf(
fLogClient,
 
 1192         "    if %d files are written, create new directory (convention no. %d)\n",
 
 1193         iMaxFile, iPathConvention);
 
 1197      pCopyCacheServ->
iCopyMode = htonl(iCopyMode);
 
 1198      pCopyCacheServ->
iCopyLen = htonl(0);    
 
 1200      strcpy(pCopyCacheServ->
cCopyPath, pcCopyPath);
 
 1202      pCopyCacheServ->
iMaxFile = htonl(iMaxFile);
 
 1206         "    parameters for write cache copy stored\n");
 
 1219      if (strcmp(pcc, 
"_d") == 0)
 
 1221         strncpy(pcc, 
"\0", 1);              
 
 1223            printf(
"    switch to test system\n");
 
 1239         "    gStore entry server %s (node in URL %s)\n",
 
 1272         if (iObjInit) printf(
 
 1273            "    %s node %s:%d, file %s%s",
 
 1280         if (iObjInit) printf(
 
 1281            "    %s %s:%d, TSM object %s%s%s",
 
 1283            pcNamefs, pcNamehl, pcNamell);
 
 1290            printf(
", request StagePool\n");
 
 1291         else if (iPoolId == 3)
 
 1292            printf(
", request ArchivePool\n");
 
 1293         else if (iPoolId == 4)
 
 1294            printf(
", request DaqPool\n");
 
 1299      if (iObjInit) printf(
 
 1300         "    FS name '%s', HL name '%s', LL name '%s', action %d\n",
 
 1304         "    action %d, object follows later\n", pCommAPI->
iAction);
 
 1311   iRC = gethostname(cliNode, 
MAX_NODE);
 
 1314      fprintf(
fLogClient, 
"-E- %s: getting client host name: %s\n",
 
 1315         cModule, strerror(iRC));
 
 1322      "    user %s on node %s, platform %s\n",
 
 1323      cOwner, cliNode, cOS);                   
 
 1334      sprintf(cstr, 
".t%d", (
int) tstr);
 
 1337      sprintf(cstr, 
".p%d", pstr);
 
 1344         printf(
"-E- %s: log file name %s too long (%d, max %d)\n",
 
 1350            printf(
"-W- can not open log file %s, write to stdout\n",
 
 1357      fprintf(
fLogClient, 
"*** log file: %s, client node: %s\n",
 
 1362      ptloc = localtime_r(&tcur, &buf_time);
 
 1364      ptloc->tm_year += 1900;
 
 1367         "    current date %d/%.2d/%.2d, time %.2d:%.2d:%.2d\n",
 
 1380   strcpy(pCommAPI->
cOwner,  cOwner);
 
 1381   strcpy(pCommAPI->
cliNode, cliNode);
 
 1382   strcpy(pCommAPI->
cOS, cOS);
 
 1383   strcpy(pCommAPI->
cDataFS, 
"");     
 
 1390      strcpy(pCommAPI->
cNodeRC, 
"");
 
 1408         printf(
"    request WC poolId %d, device %d\n",
 
 1411         printf(
"    request RC poolId %d, device %d\n",
 
 1426   strcpy(pCommServ->
cOS, pCommAPI->
cOS);
 
 1443      "    connecting to %s %s:%d\n",
 
 1449      fprintf(
fLogClient, 
"-E- %s: cannot connect to %s %s:%d\n",
 
 1461      printf(
"-I- successfully connected to %s %s:%d",
 
 1464         printf(
" after %ds", iMaxConnect);
 
 1465      printf(
" (socket %d)\n", iSockMaster);
 
 1486      iSockMover = iSockMaster;
 
 1510         pBufQuery = &sQuery;
 
 1515            printf(
"    query file %s in gStore\n", pcFile);
 
 1521         iRC = 
rawQueryFile(iSockMaster, ii, pCommServ, &pBufQuery);
 
 1535                  "-E- no %s access to archive %s in all ATL servers\n",
 
 1538                  "-E- no %s access to archive %s in ATL server %d\n",
 
 1542               "-E- no archive %s in ATL server %d found\n",
 
 1545                "-E- file %s: query in ATL server %d failed, rc = %d\n",
 
 1560                     "    file %s not available in gStore\n", pcFile);
 
 1563                     "-E- %s: file %s not available in gStore\n",
 
 1573               "    file %s not yet available in gStore\n", pcFile);
 
 1577            if ( (iAction == 1) &&                           
 
 1583                     "-E- filesize of %s >= 4 GB, cannot be read with 32 bit client\n",
 
 1592            else if (iAction == 2)                          
 
 1595                  "-E- file %s already available in gStore\n", pcFile);
 
 1603            memcpy(pQueryAPI, pQAttr, (
unsigned) 
iObjAttr);
 
 1607               printf(
"    file %s available in gStore (ATL server %d)\n",
 
 1610               if (iRC > 1) printf(
 
 1611                  "-W- %d versions of file %s exist\n", iRC, pcFile);
 
 1619               printf(
"    %s", cMsg);
 
 1621            iStage = ntohl(pQAttr->
iFS);
 
 1635                  printf(
"    file %s staged in FS %d of DM %s (poolId %d)",
 
 1638                     printf(
", still incomplete)\n");
 
 1640                     printf(
", already locked)\n");
 
 1651               strcpy(sFileSystemServ.
cOS, 
"Windows");  
 
 1652               strcpy(sFileSystemServ.
cNode, pQAttr->
cNode);
 
 1669                  printf(
"    file %s cached in FS %d of DM %s (poolId %d)",
 
 1672                     printf(
", still incomplete)\n");
 
 1674                     printf(
", already locked)\n");
 
 1682                  printf(
"    file %s not yet staged\n", pcFile);
 
 1694           "    send command buffer to %s: id: %d, action %d (ATL server %d), len %d\n",
 
 1695           cServer, ntohl(pCommServ->
iIdent),
 
 1706               "    keep entry server session for next query\n");
 
 1709         pcc = (
char *) pCommServ;
 
 1710         iRC = send(iSockMaster, pcc, (
unsigned) 
irawComm, 0);
 
 1714               "-E- %s: sending command buffer (action %d) to %s\n",
 
 1715               cModule, ntohl(pCommServ->
iAction), cServer);
 
 1726               "-E- %s: incomplete command buffer sent to %s (%d of %d bytes)\n",
 
 1735            "    command buffer (action %d) sent to %s (%d byte)\n",
 
 1745         if ( ( (iAction == 1) && ((iStage == 0) || (iCache == 1)) ) ||
 
 1749            "    receiving attributes of data mover selected by master\n");
 
 1751         iDataMoverSelect = 0;
 
 1753         while (iDataMoverSelect == 0)
 
 1755            pcc = (
char *) &sDataMoverSelect;
 
 1760            iIdent = ntohl(sDataMoverSelect.iIdent);
 
 1761            iStatus = ntohl(sDataMoverSelect.iStatus);
 
 1762            iStatusLen = ntohl(sDataMoverSelect.iStatusLen);
 
 1765               "    ident %d, status %d, len %d\n",
 
 1766               iIdent, iStatus, iStatusLen);
 
 1771                   "-E- %s: receiving data mover attr header\n%s",
 
 1780                        "-W- %s: write cache currently full (select) ... sleep %d s (%d of %d)\n",
 
 1786                        "-W- %s: write cache currently full, archive to tape\n",
 
 1790                        "    received DM name: %s\n", cMsg);
 
 1791                     iDataMoverSelect = 1;
 
 1793                     strcpy(pDataMoverSelect->
cNode, cMsg);
 
 1810                     "    send command buffer to %s: id: %d, action %d, len %d\n",
 
 1811                     cServer, pCommAPI->
iIdent,
 
 1815                  pcc = (
char *) pCommServ;
 
 1816                  iRC = send(iSockMaster, pcc, (
unsigned) 
irawComm, 0);
 
 1822                           "-E- %s: sending command buffer (action %d) to %s\n",
 
 1823                           cModule, ntohl(pCommServ->
iAction), cServer);
 
 1827                        "-E- %s: incomplete command buffer sent to %s (%d of %d bytes)\n",
 
 1836                     "    command buffer (action %d) sent to %s (%d byte)\n",
 
 1843               fprintf(
fLogClient, 
"-E- %s: received error status from %s",
 
 1846                  printf(
"\n%s" , cMsg);
 
 1857               "    header of data mover attr received (%d bytes)\n",
 
 1861            pcc = (
char *) &(sDataMoverSelect.sDataMoverAttr);
 
 1866               if ( (iRC = recv( iSockMaster, pcc, (
unsigned) iBuf, 0 )) < 0 )
 
 1869                     "-E- %s: receiving data part of data mover info\n",
 
 1871                  perror(
"-E- receiving data part of data mover info");
 
 1882                     "-E- %s: connection to sender broken, %d byte of data part of data mover info (%d byte) received\n",
 
 1883                     cModule, ii, iBufl);
 
 1893            pDataMoverSelect = &(sDataMoverSelect.sDataMoverAttr);
 
 1902                     "-E- %s: invalid ATL server no. %d received\n",
 
 1905                  "-W- %s: unexpected ATL server of selected DM: %d, expected %d\n",
 
 1916               printf(
"    data part of data mover info received (%d byte)\n",
 
 1918               printf(
"    %d data mover selected: %s for ATL server %d\n",
 
 1921            else if (iAction == 1) printf(
 
 1922              "-I- staging file to data mover %s (ATL server %d) ...\n",
 
 1927         if (iDataMoverSelect != 1)
 
 1930               "-W- expected 1 selected data mover, ignore remaining %d\n",
 
 1931               --iDataMoverSelect);
 
 1932             iDataMoverSelect = 1;
 
 1951         pCommServ->
iFSidWC = htonl(0);
 
 1952         if (iDebug) printf(
"    iMediaClass %d, disk FS %d\n",
 
 1973         pCommServ->
iObjLow = htonl(0);
 
 1975         pCommServ->
iFSidWC = htonl(0);
 
 2008            "    connecting to data mover %s:%d\n",
 
 2012                        &iMaxConnect, &iSockMover);
 
 2016               "-E- %s: cannot connect to data mover %s:%d (ATL server %d)\n",
 
 2024            "-I- successfully connected to data mover %s:%d (ATL server %d)",
 
 2029               fprintf(
fLogClient, 
" after %ds", iMaxConnect);
 
 2030            fprintf(
fLogClient, 
" (socket %d)\n", iSockMover);
 
 2037         strcpy(cServer, 
"data mover");
 
 2050      if ( (iSockMaster >= 0) && (iAction == 1) )
 
 2053            printf(
"-D- close connection %d to master\n", iSockMaster);
 
 2054         iRC = shutdown(iSockMaster, 2);
 
 2056            printf(
"    rc shutdown = %d\n", iRC);
 
 2057         iRC = close(iSockMaster);
 
 2059            printf(
"    rc close = %d\n", iRC);
 
 2104           "    send command buffer to %s: id: %d, action %d, data len %d\n",
 
 2105            cServer, pCommAPI->
iIdent,
 
 2112            plFileSizeC = (
unsigned long *) &(pCommServ->
iFileSize);
 
 2114            printf(
"    filesize %lu bytes, record size %d",
 
 2116            if (iAction == 1) printf(
 
 2117               ", poolIdRC %d, poolIdWC %d, obj id %d-%d\n",
 
 2121               printf(
", poolId %d\n", ntohl(pCommServ->
iPoolIdWC));
 
 2129      pcc = (
char *) pCommServ;
 
 2130      if ( (iRC = send(iSockMover, pcc, (
unsigned) 
irawComm, 0 )) < 0 )
 
 2132         fprintf(
fLogClient, 
"-E- %s: sending command buffer to %s (rc = %d)\n",
 
 2133            cModule, cServer, iRC);
 
 2144            "-E- %s: incomplete command buffer sent to %s (%d of %d bytes)\n",
 
 2153        "    command buffer sent to %s (%d byte)\n", cServer, 
irawComm);
 
 2158         pcc = (
char *) &sFileSystemServ;
 
 2165                  "-E- %s: sending filesystem buffer to data mover %s failed\n",
 
 2170               "-E- %s: incomplete filesystem buffer sent to data mover %s\n",
 
 2179           "    write cache info (%d bytes) sent to data mover %s\n",
 
 2186      pcc = (
char *) &sStatus;
 
 2189      while (iStatusOkay == 0)
 
 2200               fprintf(
fLogClient, 
"-E- %s: receiving status buffer from %s",
 
 2215                        "-W- %s: write cache currently full (create) ... sleep %d s (%d of %d)\n",
 
 2223                        "-W- %s: write cache currently full: archive to tape\n",
 
 2239                     "-W- write cache on DM %s full, switch to %s\n",
 
 2243                     "    close connection %d to data mover %s\n",
 
 2245                  iRC = shutdown(iSockMover, 2);
 
 2247                     printf(
"    rc shutdown = %d\n", iRC);
 
 2248                  iRC = close(iSockMover);
 
 2250                     printf(
"    rc close = %d\n", iRC);
 
 2255                     "    connecting to data mover %s:%d\n",
 
 2259                                 &iMaxConnect, &iSockMover);
 
 2263                        "-E- %s: cannot connect to new data mover %s:%d (ATL server %d)\n",
 
 2269                     "-I- successfully connected to new data mover %s:%d (ATL server %d)",
 
 2272                     fprintf(
fLogClient, 
" after %ds", iMaxConnect);
 
 2274                     printf(
"    (socket %d)\n", iSockMover);
 
 2286                  fprintf(
fLogClient, 
"-E- %s: message received from %s:\n",
 
 2303         printf(
"    status (%d) received from %s (%d bytes",
 
 2304                iStatus, cServer, iRC);
 
 2305         if (iStatusLoop > 1)
 
 2306            printf(
", iter %d)\n", iStatusLoop);
 
 2315   if ( (iSockMaster >= 0) &&
 
 2316        ((iAction == 1) || (iError)) )
 
 2324            "-E- %s: sending status buffer to entry server (EOS)\n", cModule);
 
 2325         else if (iDebug) printf(
 
 2326            "    status buffer (EOS) sent to entry server (%d bytes)\n", iRC);
 
 2330         printf(
"    close connection %d to entry server\n", iSockMaster);
 
 2331      iRC = shutdown(iSockMaster, 2);
 
 2333         printf(
"    irc shutdown = %d\n", iRC);
 
 2334      iRC = close(iSockMaster);
 
 2336         printf(
"    irc close = %d\n", iRC);
 
 2343      if (iSockMover >= 0)
 
 2351               "-E- %s: sending status buffer (EOS) to %s\n", cModule, cServer);
 
 2352            else if (iDebug) printf(
 
 2353               "    status buffer (EOS) sent to %s (%d bytes)\n",
 
 2358            "    close connection %d to %s\n", iSockMover, cServer);
 
 2359         iRC = shutdown(iSockMover, 2);
 
 2361            printf(
"    rc shutdown = %d\n", iRC);
 
 2362         iRC = close(iSockMover);
 
 2364            printf(
"    rc close = %d\n", iRC);
 
 2377      printf(
"-D- end %s\n\n", cModule);
 
 
 2397   char cModule[32] = 
"rfio_endfile";
 
 2404   char cServer[16] = 
"data mover";
 
 2415      "\n-D- begin %s: close remote file %d\n", cModule, iFileId);
 
 2421         "-E- %s: no remote file available for close\n", cModule);
 
 2429         if (
pAPIFile[ii]->iFileId == iFileId)
 
 2437      fprintf(
fLogClient, 
"-E- %s: remote file %d cannot be closed: not found\n",
 
 2443   pCommAPI = &(pcurAPIFile->
sCommAPI);
 
 2449   if (iSockMover >= 0)
 
 2455         fprintf(
fLogClient, 
"-E- %s: sending status buffer (EOF) to %s\n",
 
 2457      else if (iDebug) printf(
 
 2458         "    status buffer (EOF) sent to %s (%d bytes)\n",
 
 2462      pcc = (
char *) &sStatus;
 
 2466         fprintf(
fLogClient, 
"-E- %s: receiving status buffer\n", cModule);
 
 2473         "    status buffer (%d) received (%d byte)\n",
 
 2482               "-W- %s: message received from server:\n", cModule);
 
 2495         if ( (pcurAPIFile->
iOpMode != 2) &&      
 
 2498               "-I- gStore file %s%s%s closed\n",
 
 2502         "-I- remote output file %s%s%s closed\n",
 
 2510         "    remote file control block %d still active (overall %d)\n",
 
 2512      printf(
"-D- end %s\n\n", cModule);
 
 
 2533   char cModule[32] = 
"rfio_read";
 
 2558      printf(
"\n-D- begin %s: fileId %d\n", cModule, iFileId);
 
 2562      fprintf(
fLogClient, 
"-E- %s: no remote file open for read\n", cModule);
 
 2570         if (
pAPIFile[ii]->iFileId == iFileId)
 
 2578      fprintf(
fLogClient, 
"-E- %s: remote file %d cannot be read: not opened\n",
 
 2584      printf(
"    open buffer %d, fileId %d\n", ii, iFileId);
 
 2587   pCommAPI = &(pcurAPIFile->
sCommAPI);
 
 2596      printf(
"    remote file control block %d selected\n", ii);
 
 2597      printf(
"    file %d, buffer %d: read %d bytes\n",
 
 2598             iFileId, iBufnoServ, (
int) iItems);
 
 2604      if (iBufsizeRead != iItems)
 
 2605         printf( 
"    new buffer size %d\n", (
int) iItems);
 
 2606      printf(
"    send request for new buffer\n");
 
 2611   iOffset = pcurAPIFile->
iOffset;
 
 2612   iRC = 
rawSendRequest(iSockMover, iSeekMode, iOffset, (
int) iItems);
 
 2615      fprintf(
fLogClient, 
"-E- %s: sending request for next data buffer\n",
 
 2621   if (iSeekMode != -1)
 
 2632   pcc = (
char *) &iBufsizeRecv;
 
 2637      if ( (iRC = recv( iSockMover, pcc, (
unsigned) iBuf, 0 )) < 0 )
 
 2640            "-E- %s: receiving data length from server (buffer %d)",
 
 2641            cModule, iBufnoServ);
 
 2650            "-E- %s: connection to sender broken, %d byte of data length (%d byte) received (buffer %d)\n",
 
 2651            cModule, ii, 
iint, iBufnoServ);
 
 2666   iBufsizeRecv = ntohl(iBufsizeRecv);
 
 2668       printf(
"%d_", iBufsizeRecv);
 
 2670   if (iBufsizeRecv < 0)
 
 2674         fprintf(
fLogClient, 
"-E- %s: invalid status header received (%d)\n",
 
 2675            cModule, iBufsizeRecv);
 
 2679         printf(
"-D- status header found\n");
 
 2687         if ( (iRC = recv( iSockMover, pcc, (
unsigned) iBuf, 0 )) < 0 )
 
 2690              "-E- %s: receiving remainder of status header from server (buffer %d)",
 
 2691              cModule, iBufnoServ);
 
 2701               "-W- %s: connection to sender broken, %d byte of remainder of status header (%d byte) received (buffer %d)\n",
 
 2702               cModule, ii, iBufl, iBufnoServ);
 
 2714      pint = (
int *) pcBuffer;              
 
 2715      iStatus = ntohl(*pint);                     
 
 2721         fprintf(
fLogClient, 
"-E- %s: unexpected status from server: %d\n",
 
 2729         if (iDebug) printf(
"    EOF on input\n");
 
 2733            fprintf(
fLogClient, 
"-E- %s: %s%s%s empty\n",
 
 2743         iStatusLen = ntohl(*pint);
 
 2750                 "-E- %s: receiving status message from server, rc = %d\n",
 
 2759                  "-E- %s: received error status from server:\n",
 
 2766            printf(
"%s\n", pcc);
 
 2772   else if (iBufsizeRecv != iItems)
 
 2777            printf(
"-W- requested %d bytes, received buffer length %d bytes\n", (
int)iItems, iBufsizeRecv);
 
 2779            printf(
"-W- EOF reached\n");
 
 2781      iItems = (size_t) iBufsizeRecv;
 
 2785   iBuf = iBufsizeRecv;
 
 2790      if ( (iRC = recv( iSockMover, pcc, (
unsigned) iBuf, 0 )) < 0 )
 
 2793            "-E- %s: receiving data from server (buffer %d)\n",
 
 2794            cModule, iBufnoServ);
 
 2801         ii = iBufsizeRecv - iBuf;
 
 2803            "-W- %s: connection to sender broken, %d byte of data buffer (%d byte) received (buffer %d)\n",
 
 2804            cModule, ii, iBufsizeRecv, iBufnoServ);
 
 2825         printf(
" buffer %d received\n", pcurAPIFile->
iBufnoServ);
 
 2829      printf(
"-D- end %s\n\n", cModule);
 
 2831   return iBufsizeRecv;
 
 
 2843                   const char *pcBuffer,              
 
 2846   char cModule[32] = 
"rfio_write";
 
 2865      printf(
"\n-D- begin %s\n", cModule);
 
 2872         "-W- invalid no. of bytes to write: %d\n", (
int) iItems);
 
 2878      fprintf(
fLogClient, 
"-E- %s: no remote file open for write\n", cModule);
 
 2887         if (
pAPIFile[ii]->iFileId == iFileId)
 
 2896         "-E- %s: remote file %d cannot be written: not opened\n",
 
 2903   pCommAPI = &(pcurAPIFile->
sCommAPI);
 
 2910      printf(
"    remote file control block %d selected\n", ii);
 
 2911      printf(
"    file %d, buffer %d: write %d bytes\n",
 
 2912             iFileId, iBufnoServ, (
int) iItems);
 
 2924         printf( 
"    new buffer size %d\n", (
int) iItems);
 
 2925      printf(
"    send new buffer\n");
 
 2933   iBufsizeWrite = htonl( (
int) iItems);
 
 2935   pcc = (
char *) &iBufsizeWrite;
 
 2938      iRC = send( iSockMover, pcc, (
unsigned) iBuf, 0 );
 
 2942            "-E- %s: sending data length to server broken\n", cModule);
 
 2946               "-E- %s: sending data length to server (buffer %d)",
 
 2947               cModule, iBufnoServ);
 
 2958         printf(
"%d(%d)_", iRC, (
int) iItems);
 
 2964   iBuf = (int) iItems;
 
 2965   pcc = (
char *) pcBuffer;
 
 2968      iRC = send( iSockMover, pcc, (
unsigned) iBuf, 0 );
 
 2972            "-E- %s: sending data to server broken\n", cModule);
 
 2976               "-E- %s: sending data to server (buffer %d, %d bytes)",
 
 2977               cModule, iBufnoServ, iBuf);
 
 2999         printf(
" buffer %d sent\n", pcurAPIFile->
iBufnoServ);
 
 3003      printf(
"-D- end %s\n", cModule);
 
 3005   return (ssize_t) iItems;
 
 
 3019   char cModule[32] = 
"rfio_newfile";
 
 3028   int iCopyBuffer = 0;        
 
 3033   int iMaxConnect = 0;            
 
 3039   int iStatusOkay = 0;
 
 3040   int iStatusLoop = 0;
 
 3042   char *pcc, *pcc1, *pcc2;
 
 3065      printf(
"\n-D- begin %s\n", cModule);
 
 3070        "-E- %s: no open connection to server existing\n", cModule);
 
 3080         if (
pAPIFile[ii]->iFileId == iFileId)
 
 3088      fprintf(
fLogClient, 
"-E- %s: no open connection to server\n", cModule);
 
 3094      printf(
"    requested API control block %d\n", iFileId);
 
 3097   pCommAPI = &(pcurAPIFile->
sCommAPI);
 
 3101   if ( (pcurAPIFile->
iAction == 1) ||
 
 3105      fprintf(
fLogClient, 
"-E- %s for read not supported\n", cModule);
 
 3109   else if (pcurAPIFile->
iAction == 2)
 
 3112         printf(
"    connection is open for write\n");
 
 3116      fprintf(
fLogClient, 
"-E- %s: connection is open for unexpected action %d\n",
 
 3117         cModule, pcurAPIFile->
iAction);
 
 3123      printf(
"    check name parts in %s\n", pcFile);
 
 3125   pcc1 = (
char *) strrchr(pcFile, *
pcDevDelim);
 
 3129         "-E- %s: invalid remote file name %s: node name missing\n",
 
 3135   strcpy(cTemp, pcFile);      
 
 3136   pcc = (
char *) strchr(pcFile, *pcObjDelim);
 
 3139      fprintf(
fLogClient, 
"-E- %s: invalid remote file name %s\n",
 
 3151            "-E- %s: invalid remote file name %s - possibly leading '/' in archive name missing\n",
 
 3157   if (strncmp(cTemp, 
"rfiocopy:", 9) == 0)
 
 3161         printf(
"    copy via RFIO server\n");
 
 3163   else if (strncmp(cTemp, 
"rfiodaq:", 8) == 0)
 
 3167         printf(
"    copy to mass storage (DAQPool)\n");
 
 3169   else if (strncmp(cTemp, 
"rfio:", 5) == 0)
 
 3173         printf(
"    copy to mass storage (ArchivePool)\n");
 
 3179         printf(
"    copy to mass storage (ArchivePool)\n");
 
 3182   if (pcurAPIFile->
iMassSto != iMassSto)
 
 3185         "-E- %s: remote file %s incompatible with open server connection\n",
 
 3192      "    requested server consistent with open connection (%d)\n",
 
 3201         strcpy(pcNamefs, pcc);
 
 3205      pcc1 = (
char *) strchr(pcc, *pcObjDelim);
 
 3210            "-E- archive name starting with %s too long, max allowed %d chars\n",
 
 3213            "-E- %s: archive name starting with %s too long, max allowed %d chars\n",
 
 3214            cModule, pcNamefs, ii);
 
 3219      strncpy(pcc1, 
"\0", 1);             
 
 3220      if (strlen(pCommServ->
cNamefs))
 
 3222         if (strcmp(pCommServ->
cNamefs, pcNamefs))
 
 3225               "-E- %s: invalid archive name %s, expected %s\n",
 
 3226               cModule, pcNamefs, pCommServ->
cNamefs);
 
 3232      strcpy(pCommServ->
cNamefs, pcNamefs);
 
 3233      iArchLen = strlen(pcNamefs);
 
 3236         "    archive name: %s (len %d chars)\n", pcNamefs, iArchLen);
 
 3241            "-E- %s: invalid archive name '%s'\n", cModule, pcNamefs);
 
 3246      pcc = (
char *) strchr(cTemp, *pcObjDelim);        
 
 3248      pcc2 = (
char *) strchr(pcc, *pcObjDelim);
 
 3252            "-E- %s: invalid remote file name %s: missing path name\n",
 
 3259         printf(
"    path + file name: %s\n", pcc2);
 
 3263      pcc1 = (
char *) strrchr(pcc, *pcObjDelim);
 
 3267            "-E- %s: invalid remote file name %s: missing file name\n",
 
 3274         printf(
"    file name: %s\n", pcc1);
 
 3276      iPathLen = pcc2-pcc1;
 
 3278         iPathLen = -iPathLen;
 
 3280         printf(
"    length path name: %d\n", iPathLen);
 
 3286            printf(
"-E- path name too long, max allowed %d chars\n", ii);
 
 3288            "-E- %s: remote path name (%d chars) too long, max allowed %d\n",
 
 3289            cModule, iPathLen, ii);
 
 3294      strncpy(pcNamehl, pcc2, (
unsigned) iPathLen);
 
 3296         printf(
"    path name: %s\n", pcNamehl);
 
 3299      if (strcmp(pcNamehl, pCommAPI->
cNamehl))
 
 3301         strcpy(pcNamehl, pCommAPI->
cNamehl);
 
 3302         printf(
"    gStore path name corrected to %s\n", pcNamehl);
 
 3307         strcat(pcFile, pcc1);
 
 3309            "    new full file name: %s\n", pcFile);
 
 3312      iFileLen = strlen(pcc1);
 
 3314         printf(
"    length file name: %d\n", iFileLen);
 
 3317      if ((
int) strlen(pcc1) > ii)
 
 3320            printf(
"-E- file name too long, max allowed %d chars\n", ii);
 
 3322            "-E- %s: file name %s (%d chars) too long, max allowed %d\n",
 
 3323            cModule, pcc1, iFileLen, ii);
 
 3328      strcpy(pcNamell, pcc1);
 
 3330         printf(
"    file name: %s\n", pcNamell);
 
 3335      strcpy(pCommServ->
cNamefs, 
"");
 
 3340      pcc1 = (
char *) strrchr(pcc, *pcObjDelim);
 
 3343         fprintf(
fLogClient, 
"-E- %s: invalid remote file name %s\n",
 
 3353            "-E- %s: remote file name %s too long (max %d chars)\n",
 
 3359      strcpy(pcNamell, pcc1);
 
 3361         "    remote file name on RFIO server: %s\n", pcNamell);
 
 3363      strncpy(pcc1, 
"\0", 1);                
 
 3368            "-E- %s: remote path name %s too long (max %d chars)\n",
 
 3369            cModule, cTemp, ii);
 
 3374      strcpy(pcNamehl, cTemp);
 
 3376         "    remote path name on RFIO server: %s\n", pcNamehl);
 
 3380   if (strlen(pCommServ->
cNamehl))
 
 3382      if (strcmp(pCommServ->
cNamehl, pcNamehl))
 
 3384         fprintf(
fLogClient, 
"-W- new path name %s, previous %s\n",
 
 3385            pcNamehl, pCommServ->
cNamehl);
 
 3393      strcpy(pCommServ->
cNamehl, pcNamehl);
 
 3394      strcpy(pCommAPI->
cNamehl, pcNamehl);
 
 3397   if (strlen(pCommAPI->
cNamefs) < 3)
 
 3400   strcpy(pCommAPI->
cNamell, pcNamell);
 
 3401   strcpy(pCommServ->
cNamell, pcNamell);
 
 3404      strcpy(pCommServ->
cNamehl, pcNamehl);
 
 3405      strcpy(pCommAPI->
cNamehl, pcNamehl);
 
 3409      printf(
"    file name: %s\n", pcNamell);
 
 3419         "    query file %s in ATL server %d\n", pcFile, 
iATLServer);
 
 3421      pBufQuery = &sQuery;
 
 3427                         pCommServ, &pBufQuery);
 
 3436               "-E- no write access to archive %s in mass storage\n",
 
 3439               "-E- no archive %s in mass storage found\n",
 
 3442               "-E- file %s: query in mass storage failed, rc = %d\n",
 
 3446            "-E- file %s already available in mass storage\n",
 
 3450         if ( (iRC == -1001) || (iRC == -1000) )
 
 3459         "    file %s not yet available in mass storage\n", pcFile);
 
 3464   iCopyMode = ntohl(pCopyCacheServ->
iCopyMode);
 
 3467      iCopyLen = ntohl(pCopyCacheServ->
iCopyLen);
 
 3472         pCopyCacheServ->
iCopyLen = htonl(ii);
 
 3474            printf(
"    send copy parameters to DM\n");
 
 3477         printf(
"    copy parameters already sent to DM\n");
 
 3480      printf(
"    data are only written to WC\n");
 
 3484      printf(
"    send command buffer to server %s: id: %d, action %d, bufsize %d",
 
 3490         printf(
", data len %d\n",
 
 3493         printf(
", data len %d\n", pCommAPI->
iCommLen);
 
 3497   pcc = (
char *) pCommServ;
 
 3502   if ( (iRC = send(iSockMover, pcc, (
unsigned) 
irawComm, 0 )) < 0 )
 
 3505         "-E- %s: sending command buffer to server %s (rc = %d)\n",
 
 3515         "-E- %s: incomplete command buffer sent to server %s (%d of %d bytes)\n",
 
 3523      "    command buffer sent to server %s (%d byte)\n",
 
 3528      pcc = (
char *) pCopyCacheServ;
 
 3529      if ( (iRC = send(iSockMover, pcc, (
unsigned) 
irawCopyCache, 0 )) < 0 )
 
 3532            "-E- %s: sending copy buffer to server %s (rc = %d)\n",
 
 3542            "-E- %s: incomplete copy buffer sent to server %s (%d of %d bytes)\n",
 
 3550         "    copy buffer sent to server %s (%d byte)\n",
 
 3559   pcc = (
char *) &sStatus;
 
 3562   while (iStatusOkay == 0)
 
 3570         "    status %d received (%d byte)\n", iStatus, iRC);
 
 3574            "-E- %s: receiving status buffer from server\n",
 
 3584                     "-W- %s: write cache currently full ... sleep %d s (%d of %d)\n",
 
 3592                     "-W- %s: write cache currently full, archive to tape\n",
 
 3603                  goto gNextCmdNewFile;
 
 3611                  "-W- write cache on DM %s full or too much load, switch to %s\n",
 
 3615                  "    close connection %d to data mover %s\n",
 
 3617               iRC = shutdown(iSockMover, 2);
 
 3619                  printf(
"    rc shutdown = %d\n", iRC);
 
 3621               iRC = close(iSockMover);
 
 3623                  printf(
"    rc close = %d\n", iRC);
 
 3626                     "-I- connection to data mover %s closed\n",
 
 3632                  "    connecting to data mover %s:%d\n",
 
 3636                              &iMaxConnect, &iSockMover);
 
 3640                     "-E- %s: cannot connect to new data mover %s:%d (ATL server %d)\n",
 
 3646                 "-I- successfully connected to new data mover %s:%d (ATL server %d)",
 
 3649                  fprintf(
fLogClient, 
" after %ds", iMaxConnect);
 
 3651                  printf(
"    (socket %d)\n", iSockMover);
 
 3658               pCopyCacheServ->
iCopyLen = htonl(0);
 
 3660               goto gNextCmdNewFile;
 
 3665               fprintf(
fLogClient, 
"-E- message received from server:\n");
 
 3685      printf(
"    status (%d) received from server (%d bytes",
 
 3687      if (iStatusLoop > 1)
 
 3688         printf(
", iter %d)\n", iStatusLoop);
 
 3701      printf(
"-D- end %s\n\n", cModule);
 
 
 3718   char cModule[32] = 
"rfio_close";
 
 3732      "\n-D- begin %s: close remote file %d\n", cModule, iFileId);
 
 3737         "-E- %s: no remote file available for close\n", cModule);
 
 3745         if (
pAPIFile[ii]->iFileId == iFileId)
 
 3753      fprintf(
fLogClient, 
"-E- %s: remote file %d cannot be closed: not found\n",
 
 3759   pCommAPI = &(pcurAPIFile->
sCommAPI);
 
 3765      fprintf(
fLogClient, 
"-I- gStore file %s%s%s closed\n",
 
 3768   if (iSockMaster >= 0)
 
 3773         "-E- %s: sending status buffer (EOS) to master\n", cModule);
 
 3774      else if (iDebug) printf(
 
 3775         "    status buffer (EOS) sent to master (%d bytes)\n", iRC);
 
 3778         printf(
"    close connection %d to master\n", iSockMaster);
 
 3779      iRC = shutdown(iSockMaster, 2);
 
 3781         printf(
"    rc shutdown = %d\n", iRC);
 
 3782      iRC = close(iSockMaster);
 
 3784         printf(
"    rc close = %d\n", iRC);
 
 3789   if (iSockMover >= 0)
 
 3794         "-E- %s: sending status buffer (EOS) to data mover\n", cModule);
 
 3795      else if (iDebug) printf(
 
 3796        "    status buffer (EOS) sent to data mover (%d bytes)\n", iRC);
 
 3803         memset(&sStatusRecv, 0X00, 
sizeof(
srawStatus));
 
 3804         pcc = (
char *) &sStatusRecv;
 
 3808            "-E- %s: receiving confirmation of status buffer (EOS)\n",
 
 3810         else if (iDebug) printf(
 
 3811            "    status (%d) confirmed by server (%d bytes)\n",
 
 3816         printf(
"    close connection %d to data mover\n", iSockMover);
 
 3817      iRC = shutdown(iSockMover, 2);
 
 3819         printf(
"    rc shutdown = %d\n", iRC);
 
 3820      iRC = close(iSockMover);
 
 3822         printf(
"    rc close = %d\n", iRC);
 
 3824         "-I- connection to data mover %s closed\n",
 
 3836         "    remote file control block %d deleted (%d still active)\n",
 
 3838      printf(
"-D- end %s\n\n", cModule);
 
 
 3845#ifdef __USE_LARGEFILE64 
 3860   char cModule[32] = 
"rfio_preseek64";
 
 3865      "\n-D- begin %s: iFileId %d\n", cModule, iFileId);
 
 3867   int ii = 
sizeof(long);
 
 3871         "-E- 32 bit client: %s not supported\n", cModule);
 
 3877      "-W- %s not yet implemented for gStore\n", cModule);
 
 3880      fprintf(
fLogClient, 
"-D- end %s\n\n", cModule);
 
 3894int64_t rfio_lseek64(
 
 3896      int64_t i64locOffset,
 
 3899   char cModule[32] = 
"rfio_lseek64";
 
 3909         "-E- 32 bit client: %s not supported\n", cModule);
 
 3915      "\n-D- begin %s: iFileId %d, Offset %lld, SeekMode %d\n",
 
 3916      cModule, iFileId, (
unsigned long) i64locOffset, ilocSeekMode);
 
 3918   ilocOffset = (int) i64locOffset;
 
 3920   iRC = 
rfio_lseek(iFileId, ilocOffset, ilocSeekMode);
 
 3923      "-D- end %s: rc(rfio_lseek) = %d \n\n", cModule, iRC);
 
 3925   return (int64_t) iRC;
 
 3943   char cModule[32] = 
"rfio_lseek";
 
 3954      printf(
"\n-D- begin %s: file %d\n", cModule, iFileId);
 
 3955      if (ilocSeekMode == SEEK_SET)
 
 3956         printf(
"    position to %d bytes, \n", ilocOffset);
 
 3957      else if (ilocSeekMode == SEEK_CUR)
 
 3958         printf(
"    position to current + %d bytes, \n", ilocOffset);
 
 3959      else if (ilocSeekMode == SEEK_END)
 
 3960         printf(
"    position to file size + %d bytes, \n", ilocOffset);
 
 3963         fprintf(
fLogClient, 
"-E- %s: unexpected offset (%d)\n",
 
 3964            cModule, ilocSeekMode);
 
 3973   if (iSeekMode != -1)
 
 3976      iOffset = pcurAPIFile->
iOffset;
 
 3980         fprintf(
fLogClient, 
"-E- %s: sending request for seek\n", cModule);
 
 3986   pcurAPIFile->
iOffset = ilocOffset;
 
 3989      printf(
"-D- end %s\n\n", cModule);
 
 
 4005   char cModule[32] = 
"rfio_fopen";
 
 4007   RFILE *fRemoteFile = NULL;
 
 4009   char *pcCopyPath = NULL;
 
 4010   int iCopyFraction = 0;
 
 4012   int iPathConvention = 0;
 
 4015      printf(
"\n-D- begin %s: calling rfio_fopen_gsidaq\n", cModule);
 
 4027      printf(
"-D- end %s\n\n", cModule);
 
 
 4080        int iPathConvention)
 
 4091   char cModule[32] = 
"rfio_fopen_gsidaq_dm";
 
 4099      printf(
"\n-D- begin %s: calling rfio_open_gsidaq\n", cModule);
 
 4101   if (*pcOptions == 
'r')
 
 4104         pcFile, O_RDONLY, 0,
 
 4105         iCopyMode, pcCopyPath, iCopyFraction, iMaxFile,
 
 4108   if (*pcOptions == 
'w')
 
 4111         pcFile, O_WRONLY | O_CREAT, 0,
 
 4112         iCopyMode, pcCopyPath, iCopyFraction, iMaxFile,
 
 4121         "    connected with data mover %s\n", pcDataMover);
 
 4125      iDataMover = atoi(pcc);
 
 4126      *piDataMover = iDataMover;
 
 4129         "    running number data mover: %d\n", iDataMover);
 
 4133      "-D- end %s: iFileId(rfio_open_gsidaq) = %d\n\n",
 
 
 4187        int iPathConvention)
 
 4198   char cModule[32] = 
"rfio_fopen_gsidaq";
 
 4203      printf(
"\n-D- begin %s: calling rfio_open_gsidaq\n", cModule);
 
 4205   if (*pcOptions == 
'r')
 
 4208         pcFile, O_RDONLY, 0,
 
 4209         iCopyMode, pcCopyPath, iCopyFraction, iMaxFile,
 
 4212   if (*pcOptions == 
'w')
 
 4215         pcFile, O_WRONLY | O_CREAT, 0,
 
 4216         iCopyMode, pcCopyPath, iCopyFraction, iMaxFile,
 
 4221      "-D- end %s: iFileId(rfio_open_gsidaq) = %d\n\n",
 
 
 4241   char cModule[32] = 
"rfio_fnewfile";
 
 4249      printf(
"\n-D- begin %s\n", cModule);
 
 4255      fprintf(
fLogClient, 
"-E- %s: still no connection to server opened\n",
 
 4260   if (pRemFile == NULL)
 
 4262      fprintf(
fLogClient, 
"-E- %s: invalid file ptr (NULL) specified\n", cModule);
 
 4266   if ( (pcFile == NULL) || (strlen(pcFile) < 5) )
 
 4268      fprintf(
fLogClient, 
"-E- %s: invalid file '%s' specified\n",
 
 4283      fprintf(
fLogClient, 
"-E- %s: invalid file ptr specified\n", cModule);
 
 4287   iFileId = pRemFile->iFileId;
 
 4291      printf(
"-D- end %s\n\n", cModule);
 
 
 4312   char cModule[32]=
"rfio_fread";
 
 4319      printf(
"\n-D- begin %s\n", cModule);
 
 4321   if (pRemFile == NULL)
 
 4323      fprintf(
fLogClient, 
"-E- %s: remote file not open for read\n", cModule);
 
 4327   iFileId = pRemFile->iFileId;
 
 4328   iBytes = iSize*iItems;
 
 4329   iRC = (int) 
rfio_read(iFileId, pcBuffer, iBytes);
 
 4332      printf(
"-D- end %s\n", cModule);
 
 4334   return (
unsigned) iRC;
 
 
 4350   char cModule[32]=
"rfio_fwrite";
 
 4357      printf(
"\n-D- begin %s\n", cModule);
 
 4359   if (pRemFile == NULL)
 
 4361      fprintf(
fLogClient, 
"-E- %s: remote file not open for write\n", cModule);
 
 4365   iFileId = pRemFile->iFileId;
 
 4366   iBytes = iSize*iItems;
 
 4367   iRC = (int) 
rfio_write(iFileId, pcBuffer, iBytes);
 
 4370      printf(
"-D- end %s\n", cModule);
 
 4372   return (
unsigned) iRC;
 
 
 4387   char cModule[32] = 
"rfio_fendfile";
 
 4393      printf(
"\n-D- begin %s\n", cModule);
 
 4395   iFileId = pRemFile->iFileId;
 
 4399      printf(
"-D- end %s\n", cModule);
 
 
 4416   char cModule[32] = 
"rfio_fclose";
 
 4422      printf(
"\n-D- begin %s\n", cModule);
 
 4424   iFileId = pRemFile->iFileId;
 
 4428      printf(
"-D- end %s\n", cModule);
 
 
 4445   char cModule[32] = 
"rfio_access";
 
 4452      printf(
"\n-D- begin %s\n", cModule);
 
 4458         printf(
"    check if executable - not supported\n");
 
 4466         printf(
"    check for existence\n");
 
 4468      iFileId = 
rfio_open(pcFile, O_RDONLY, -1);
 
 4474            printf(
"-E- closing remote file %s\n", pcFile);
 
 4478            printf(
"-D- remote file %s closed\n", pcFile);
 
 4486               printf(
"    file %s must not be overwritten\n",
 
 4490         else if (iMode == R_OK)
 
 4493               printf(
"    file %s is readable\n", pcFile);
 
 4499               printf(
"    file %s exists\n", pcFile);
 
 4509               printf(
"    file %s may be written\n", pcFile);
 
 4515               printf(
"    file %s not existing\n", pcFile);
 
 4525         printf(
"    file %s is readable\n", pcFile);
 
 4531         printf(
"    file %s may be written\n", pcFile);
 
 4537      printf(
"-D- end %s\n", cModule);
 
 
 4543#ifdef __USE_LARGEFILE64 
 4553int rfio_fstat64(
int iFileId,
 
 4554                 struct stat64 *pStatBuf64)
 
 4556   char cModule[32] = 
"rfio_fstat64";
 
 4561   unsigned long *plFileSizeC;          
 
 4566      fprintf(
fLogClient, 
"\n-D- begin %s: file %d\n", cModule, iFileId);
 
 4577         "-E- 32 bit client: %s not supported\n", cModule);
 
 4587         if (
pAPIFile[ii]->iFileId == iFileId)
 
 4596      fprintf(
fLogClient, 
"-E- %s: specified remote fileId %d not found\n",
 
 4599         fprintf(
fLogClient, 
"-D- end %s\n\n", cModule);
 
 4605   plFileSizeC = (
unsigned long *) &(pComm->
iFileSize);
 
 4609      fprintf(
fLogClient, 
"    specified remote fileId %d found:\n", iFileId);
 
 4610      fprintf(
fLogClient, 
"    object %s%s%s, filesize %lu byte\n",
 
 4615   iRC = fstat64(0, pStatBuf64);
 
 4618      fprintf(
fLogClient, 
"-E- %s: fstat64() failed, rc = %d\n", cModule, iRC);
 
 4620         printf(
"-D- end %s\n\n", cModule);
 
 4626   pStatBuf64->st_size = *plFileSizeC;
 
 4629      "-D- end %s: irc(fstat64) = %d\n", cModule, iRC);
 
 4646               struct stat *pStatBuf) 
 
 4648   char cModule[32] = 
"rfio_fstat";
 
 4657      printf(
"\n-D- begin %s", cModule);
 
 4659         printf(
", %d remote files currently open\n", 
iFileCount);
 
 4669         if (
pAPIFile[ii]->iFileId == iFileId)
 
 4678      fprintf(
fLogClient, 
"-E- %s: specified remote fileId %d not found\n",
 
 4681         printf(
"-D- end %s\n\n", cModule);
 
 4689      printf(
"    specified remote fileId %d found:\n", iFileId);
 
 4690      printf(
"    object %s%s%s, filesize %u byte\n",
 
 4698   iRC = fstat(0, pStatBuf);
 
 4701      fprintf(
fLogClient, 
"-E- %s: fstat() failed, rc = %d\n", cModule, iRC);
 
 4703         printf(
"-D- end %s\n\n", cModule);
 
 4712      printf(
"-D- end %s\n\n", cModule);
 
 
 4730   char cModule[32] = 
"rfio_parse";
 
 4734      printf(
"\n-D- begin %s\n", cModule);
 
 4737      printf(
"-D- end %s\n", cModule);
 
 
 4753   char cModule[32] = 
"rfio_perror";
 
 4757      printf(
"\n-D- begin %s\n", cModule);
 
 4760      fprintf(stderr, 
"%s : No error message\n", pUMsg);
 
 4765      printf(
"-D- end %s\n", cModule);
 
 
 4781   char cModule[32] = 
"rfio_serror";
 
 4785      "\n-D- begin %s: error (len %d byte):\n",
 
 4792      printf(
"-D- end %s\n", cModule);
 
 
 4810   char cModule[32] = 
"rfio_unlink";
 
 4814      printf(
"\n-D- begin %s\n", cModule);
 
 4817      "-W- %s not yet implemented for gStore\n", cModule);
 
 4820      printf(
"-D- end %s\n", cModule);
 
 
 4835   char cModule[32] = 
"rfiosetopt";
 
 4839      printf(
"\n-D- begin %s\n", cModule);
 
 4842      printf(
"-D- end %s\n", cModule);
 
 
 4857   char cModule[32] = 
"rfio_mkdir";
 
 4861      printf(
"\n-D- begin %s\n", cModule);
 
 4864      "-W- %s not yet implemented for gStore\n", cModule);
 
 4867      printf(
"-D- end %s\n", cModule);
 
 
 4882   char cModule[32] = 
"rfio_opendir";
 
 4886      printf(
"\n-D- begin %s\n", cModule);
 
 4889      "-W- %s not yet implemented for gStore\n", cModule);
 
 4892      printf(
"-D- end %s\n", cModule);
 
 
 4907   char cModule[32] = 
"rfio_readdir";
 
 4911      printf(
"\n-D- begin %s\n", cModule);
 
 4914      "-W- %s not yet implemented for gStore\n", cModule);
 
 4917      printf(
"-D- end %s\n", cModule);
 
 
 4932   char cModule[32] = 
"rfio_closedir";
 
 4936      printf(
"\n-D- begin %s\n", cModule);
 
 4939      "-W- %s not yet implemented for gStore\n", cModule);
 
 4942      printf(
"-D- end %s\n", cModule);
 
 
 4948#ifdef __USE_LARGEFILE64 
 4958int rfio_stat64(
const char *pcFile, 
struct stat64 *pStatBuf64)
 
 4960   char cModule[32] = 
"rfio_stat64";
 
 4971   unsigned long *plFileSizeC;          
 
 4974      fprintf(
fLogClient, 
"\n-D- begin %s: file %s\n", cModule, pcFile);
 
 4980         "-E- 32 bit client: %s not supported\n", cModule);
 
 4993         strcpy(cObject, pComm->
cNamefs);
 
 4994         strcat(cObject, pComm->
cNamehl);
 
 4995         strcat(cObject, pComm->
cNamell);
 
 4998            "    %d: %s already open\n", ii, cObject);
 
 5000         pcc = strstr(pcFile, cObject);
 
 5005               fprintf(
fLogClient, 
"    %d: %s maps\n", ii, cObject);
 
 5010         "    %d: no (more) open file found\n", ii);
 
 5018         "    remote file %s not yet open\n", pcFile);
 
 5020      iFileId = 
rfio_open( (
char *) pcFile, O_RDONLY, -1);
 
 5022         "-E- %s: open for remote file %s failed\n", cModule, pcFile);
 
 5028         "-E- %s: invalid handle (%d) for remote file %s found\n",
 
 5029         cModule, iFileId, pcFile);
 
 5036      plFileSizeC = (
unsigned long *) &(pComm->
iFileSize);
 
 5040         fprintf(
fLogClient, 
"    remote fileId %d:\n", iFileId);
 
 5041         fprintf(
fLogClient, 
"    object %s%s%s, filesize %lu byte\n",
 
 5047      pStatBuf64->st_size = *plFileSizeC;
 
 5056      fprintf(
fLogClient, 
"-D- end %s\n\n", cModule);
 
 5074   char cModule[32] = 
"rfio_stat";
 
 5087      printf(
"\n-D- begin %s\n", cModule);
 
 5097         strcpy(cObject, pComm->
cNamefs);
 
 5098         strcat(cObject, pComm->
cNamehl);
 
 5099         strcat(cObject, pComm->
cNamell);
 
 5102            printf(
"    %d: %s already open\n", ii, cObject);
 
 5104         pcc = strstr(pcFile, cObject);
 
 5109               printf(
"    %d: %s maps\n", ii, cObject);
 
 5114         printf(
"    %d: no (more) open file found\n", ii);
 
 5122         "    remote file %s not yet open\n", pcFile);
 
 5124      iFileId = 
rfio_open( (
char *) pcFile, O_RDONLY, -1);
 
 5126         "-E- %s: open for remote file %s failed\n", cModule, pcFile);
 
 5132         "-E- %s: invalid handle (%d) for remote file %s found\n",
 
 5133         cModule, iFileId, pcFile);
 
 5142         printf(
"    remote fileId %d:\n", iFileId);
 
 5143         printf(
"    object %s%s%s, filesize %u byte\n",
 
 5157      printf(
"-D- end %s\n\n", cModule);
 
 
 5183   char cModule[32] = 
"rfio_cache_stat";
 
 5198      printf(
"\n-D- begin %s: %d files open\n", cModule, 
iFileCount);
 
 5199      printf(
"    get cache status of file %s\n", pcFile);
 
 5210         strcpy(cObject, pComm->
cNamefs);
 
 5211         strcat(cObject, pComm->
cNamehl);
 
 5212         strcat(cObject, pComm->
cNamell);
 
 5215            printf(
"    %d: %s already open\n", ii, cObject);
 
 5217         pcc = strstr(pcFile, cObject);
 
 5222               printf(
"    %d: %s maps\n", ii, cObject);
 
 5227         printf(
"    %d: no (more) open file found\n", ii);
 
 5235         "    remote file %s not yet open\n", pcFile);
 
 5237      iFileId = 
rfio_open( (
char *) pcFile, O_RDONLY, -1);
 
 5241            "-E- remote file %s not in gStore or unavailable\n",
 
 5249         "    remote file %s successfully opened for query and closed\n", pcFile);
 
 5257            "-E- %s: invalid handle (%d) for remote file %s found\n",
 
 5258            cModule, iFileId, pcFile);
 
 5278         printf(
"    remote fileId %d:\n", iFileId);
 
 5279         printf(
"    object %s%s%s, size %u byte, cache status %d\n",
 
 5283            printf(
"    read cache FS %d\n", pComm->
iStageFSid);
 
 5285            printf(
"    write cache FS %d\n", pComm->
iFSidWC);
 
 5296      printf(
"-D- end %s\n\n", cModule);
 
 
 5314   char cModule[32] = 
"rfio_gsi_query";
 
 5323      printf(
"\n-D- begin %s\n", cModule);
 
 5327      printf(
"-E- %s: no remote file available\n", cModule);
 
 5336         if (
pAPIFile[ii]->iFileId == iFileId)
 
 5344      printf(
"-E- %s: remote file %d not found\n", cModule, iFileId);
 
 5354      printf(
"    %s\n", pInfo);
 
 5355      if (iRC != iOut) printf(
 
 5356         "    (used %d byte, avail %d byte)\n", iRC, iOut);
 
 5361      printf(
"-D- end %s\n\n", cModule);
 
 
int rawQueryString(srawObjAttr *pQAttr, int ipMode, int iOut, char *pcOut)
 
static char cNamefs[MAX_OBJ_FS]
 
static char cNamehl[MAX_OBJ_HL]
 
char * rawGetFSpName(char *)
 
int rfio_open(const char *pcFile, int iFlags, int iOpenMode)
 
int rfio_mkdir(const char *path, int mode)
 
RFILE * rfio_fopen_gsidaq_dm(char *pcFile, char *pcOptions, char *pcDataMover, int *piDataMover, int iCopyMode, char *pcCopyPath, int iCopyFraction, int iMaxFile, int iPathConvention)
 
ssize_t rfio_write(int iFileId, const char *pcBuffer, size_t iItems)
 
ssize_t rfio_read(int iFileId, char *pcBuffer, size_t iItems)
 
int rfio_unlink(const char *pcFile)
 
void rfio_perror(const char *pUMsg)
 
size_t rfio_fwrite(const char *pcBuffer, size_t iSize, size_t iItems, RFILE *pRemFile)
 
int rfio_newfile(int iFileId, char *pcFile)
 
int rfio_parse(char *pcFile, char **pcNode, char **pcPath)
 
int rfio_access(const char *pcFile, int iMode)
 
static char cNodePrefix[MAX_NODE]
 
static char cNodeMaster[MAX_NODE]
 
RFILE * rfio_fopen_gsidaq(char *pcFile, char *pcOptions, int iCopyMode, char *pcCopyPath, int iCopyFraction, int iMaxFile, int iPathConvention)
 
int rfio_lseek(int iFileId, int ilocOffset, int ilocSeekMode)
 
int rfio_fclose(RFILE *pRemFile)
 
static int iStatusLoopMax
 
void * rfio_opendir(const char *dirpath)
 
int rfiosetopt(int iopt, int *pival, int ilen)
 
int rfio_stat(const char *pcFile, struct stat *pStatBuf)
 
RFILE * rfio_fopen(char *pcFile, char *pcOptions)
 
int rfio_fstat(int iFileId, struct stat *pStatBuf)
 
static RFILE * pAPIFile[10]
 
int rfio_open_gsidaq(const char *pcFile, int iFlags, int iOpenMode, int iCopyMode, char *pcCopyPath, int iCopyFraction, int iMaxFile, int iPathConvention)
 
static char cNodeMover[MAX_NODE]
 
void * rfio_readdir(void *dirp)
 
int rfio_closedir(void *dirp)
 
static int irawFileSystem
 
int rfio_fendfile(RFILE *pRemFile)
 
int rfio_gsi_query(int iFileId, int iFull, int iOut, char *pInfo)
 
int rfio_fnewfile(RFILE *pRemFile, char *pcFile)
 
size_t rfio_fread(char *pcBuffer, size_t iSize, size_t iItems, RFILE *pRemFile)
 
int rfio_endfile(int iFileId)
 
static char rfio_errmsg[STATUS_LEN]
 
int rfio_cache_stat(const char *pcFile)
 
static char cPrefix[MAX_FULL_FILE]
 
int rfio_close(int iFileId)
 
static int iSleepCacheFull
 
static char cLogClient[MAX_LOG_FILE]
 
#define GSI_CACHE_INCOMPLETE
 
#define GSI_MEDIA_INCOMPLETE
 
#define DSM_MAX_OWNER_LENGTH
 
static char cApplType[MAX_APPLTYPE]
 
#define ATLSERVER_ARCHIVE
 
static char cDataFSHigh2[16]
 
#define PORT_MOVER_DATAFS
 
static char cDataFSHigh1[16]
 
#define MAXLOOP_CACHE_FULL
 
static char cNodeMaster0[MAX_NODE]
 
static const char * pcDevDelim
 
static const char * pcPerc
 
static const char * pcStar
 
int rawRecvHeadC(int, char *, int, int, char *)
 
int rawGetLLName(char *, const char *, char *)
 
int rconnect(char *, int, int *, int *)
 
int rawRecvStatus(int, char *)
 
char * rawGetHLName(char *)
 
int rawSendStatus(int, int, char *)
 
int rawRecvError(int, int, char *)
 
int rawSendRequest(int, int, int, int)
 
int rawQueryFile(int, int, srawComm *, void **)
 
char cNodeMaster[MAX_NODE]
 
char cNodeMover[MAX_NODE]
 
srawCopyCache sCopyCacheServ
 
char cDataFS[MAX_FULL_FILE]
 
char cApplType[MAX_APPLTYPE]
 
char cNodeCacheMgr[MAX_NODE]
 
char cCopyPath[MAX_FULL_FILE]
 
char cArchiveUser[MAX_OWNER]
 
char cArchiveDate[MAX_DATE]
 
char cDateCreate[MAX_DATE]