Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

rawCliProcn.c

Go to the documentation of this file.
00001 //-------------------------------------------------------------
00002 //        Go4 Release Package v3.04-01 (build 30401)
00003 //                      28-November-2008
00004 //---------------------------------------------------------------
00005 //   The GSI Online Offline Object Oriented (Go4) Project
00006 //   Experiment Data Processing at EE department, GSI
00007 //---------------------------------------------------------------
00008 //
00009 //Copyright (C) 2000- Gesellschaft f. Schwerionenforschung, GSI
00010 //                    Planckstr. 1, 64291 Darmstadt, Germany
00011 //Contact:            http://go4.gsi.de
00012 //----------------------------------------------------------------
00013 //This software can be used under the license agreements as stated
00014 //in Go4License.txt file which is part of the distribution.
00015 //----------------------------------------------------------------
00016 /**********************************************************************
00017  * Copyright:
00018  *   GSI, Gesellschaft fuer Schwerionenforschung mbH
00019  *   Planckstr. 1
00020  *   D-64291 Darmstadt
00021  *   Germany
00022  * created 28. 8.1996 by Horst Goeringer
00023  **********************************************************************
00024  * rawCliProcn.c:
00025  *    utility programs for GSI mass storage: clients only
00026  *    new version
00027  **********************************************************************
00028  * rawCheckFilelist: remove objects already archived from file list
00029  * rawCheckObjlist:  remove existing files from object and file list,
00030  *                   reorder according to restore parameter
00031  * rawDelFile:     delete single file in GSI mass storage
00032  * rawDelList:     delete list of files in GSI mass storage
00033  * rawGetFilelistEntries: get filelist entries from input file
00034  * rawGetWSInfo:   get workspace and pool info from master
00035  * rawQueryFile:   get query information for single file
00036  * rawQueryList:   get query information from list of files
00037  * rawScanObjbuf:  check if obj already available in obj buffer chain
00038  * ielpst:         AIX only: elapsed (wall-clock) time measurement
00039  **********************************************************************
00040  * 26. 3.1996, H.G.: rawCheckObjlist: work on ptr-linked object buffers
00041  * 21.11.1997, H.G.: rawDelFile: only warning (rc=1) if obj not found
00042  * 19.12.2000, H.G.: rawCheckObjlist: remove unused code, better doc
00043  * 21. 2.2001, H.G.: renamed file rawQueryFile.c -> rawProcQuery.c
00044  *                   function rawQueryList added
00045  * 18. 5.2001, H.G.: merge into new file rawcliproc.c:
00046  *                   rawProcQuery.c
00047  *                   rawDelFile.c
00048  *                   rawDelList (rawDelFilelist from rawproc.c)
00049  *                   rawTapeFile.c
00050  *                   ielpst.c
00051  * 20. 7.2001, H.G.: rawCheckObjlist: mover node in srawRetrList
00052  * 24. 8.2001, H.G.: rawCheckObjlist: stage status in srawRetrList
00053  * 24. 1.2002, H.G.: created from rawcliproc.c, ACTION DELETE -> REMOVE
00054  * 13. 2.2002, H.G.: rawDelFile: handle also stage file
00055  * 25. 4.2002, H.G.: move rawTapeFile to new file rawProcTape.c
00056  *  5. 8.2002, H.G.: rawQueryFile: handle QUERY_RETRIEVE, QUERY_STAGE
00057  * 13. 1.2003, H.G.: rawCheckFilelist: reset cFilell before calling
00058  *                   rawGetLLName
00059  * 31. 1.2003, H.G.: use rawdefn.h
00060  *  4. 2.2003, H.G.: rawDelList, obj list: srawArchList -> srawRetrList
00061  *                   rawCheckFilelist, obj list: change type from
00062  *                   srawArchList -> srawRetrList
00063  * 14. 2.2003, H.G.: rawDelList: handles list of data movers
00064  *                   rawCheckFilelist: new arg pcNodeMaster
00065  * 17. 2.2003, H.G.: rawCheckFilelist, rawCheckObjlist from rawprocn.c
00066  * 17. 2.2003, H.G.: rawCheckFilelist: return in filelist ptr
00067  * 22. 5.2003, H.G.: renamed to rawCliProcn.c, new rawGetFilelistEntries
00068  * 27. 6.2003, H.G.: new function rawGetWSInfo
00069  * 18. 7.2003, H.G.: handle action QUERY_RETRIEVE_API
00070  * 23. 2.2004, H.G.: rawCheckObjlist: StageFS, ArchiveFS in srawRetrList
00071  *  5. 3.2004, H.G.: rawCheckObjlist: cArchiveDate, cOwner in srawRetrList
00072  **********************************************************************
00073  */
00074 
00075 #ifdef WIN32
00076 #include <winsock.h>
00077 #else
00078 #include <sys/socket.h>
00079 #endif
00080 
00081 #include <stdlib.h>
00082 #include <stdio.h>
00083 #include <string.h>
00084 #include <time.h>
00085 
00086 #ifdef Linux
00087 #include <linux/in.h>
00088 #endif
00089 
00090 #include "rawapitd.h"
00091 #include "rawapitd-gsi.h"
00092 #include "rawcommn.h"
00093 #include "rawdefn.h"
00094 #include "rawclin.h"
00095 #include "rawentn.h"
00096 #include "rawapplcli.h"
00097 
00098 extern FILE *fLogFile;
00099 extern int *piEntryList;                /* for rawGetFilelistEntries */
00100 
00101 static int iqueryMax = 0;       /* max no. of files per query buffer */
00102 static int iQueryCount = 0;            /* overall no. of files found */
00103 static char *pQueryBuffer;                /* pointer to query buffer */
00104 static srawQueryResult *pQueryResult;
00105 static srawObjAttr *pQueryObj, *pQueryObj0;
00106 
00107 /********************************************************************
00108  * rawCheckFilelist: remove objects already archived from file list
00109  *    returns number of removed objects
00110  *
00111  * created 15. 3.96, Horst Goeringer
00112  * 25. 3.1996, H.G.: work on ptr-linked object buffers
00113  ********************************************************************
00114  */
00115 
00116 int rawCheckFilelist(char **pcFileList, char **pcObjList,
00117                      char *pcNodeMaster)
00118 {
00119    char cModule[32] = "rawCheckFilelist";
00120    int iDebug = 0;
00121 
00122    char cDelimiter[1] = "";
00123    char *pcfl, *pcol;
00124    int *pifl, *piol;
00125    int ifile0, ifile;
00126    int iobj0, iobj, iobjf = 0;
00127 
00128    srawArchList *psFile, *psFile0;        /* files to be archived */
00129    srawRetrList *psObj, *psObj0;      /* objects already archived */
00130 
00131    char cFilell[MAX_OBJ_LL];
00132    char *pcFilell;             /* temp obj ll name from file name */
00133 
00134    bool_t bLastBuf;
00135    int iobjBuf;
00136    int **piptr;               /* points to pointer to next buffer */
00137    int *pinext;               /* points to next buffer */
00138 
00139    int ii, jj, iif;
00140    int iRC, idel;
00141 
00142    pcfl = *pcFileList;
00143    pifl = (int *) pcfl;
00144    ifile0 = pifl[0];                   /* initial number of files */
00145    ifile = ifile0;
00146    psFile = (srawArchList *) ++pifl;  /* points now to first file */
00147    psFile0 = psFile;
00148    pifl--;                     /* points again to number of files */
00149 
00150    pcol = *pcObjList;
00151    piol = (int *) pcol;
00152    iobj0 = piol[0];                  /* number of archived objects */
00153    iobj = iobj0;
00154    psObj = (srawRetrList *) ++piol;  /* points now to first object */
00155    psObj0 = psObj;
00156    piol--;                    /* points again to number of objects */
00157 
00158    pcFilell = cFilell;
00159 
00160    if (iDebug)
00161    {
00162       fprintf(fLogFile,
00163          "\n-D- begin %s: initial %d files, %d objects (1st buffer)\n",
00164          cModule, ifile0, iobj0);
00165       fprintf(fLogFile, "    first file %s, first obj %s\n",
00166              (char *) psFile, (char *) psObj);
00167    }
00168 
00169    iRC = strncmp( (char *) psObj, pcObjDelim, 1);
00170    if (iRC)
00171    {
00172       iRC = strncmp( (char *) psObj, pcObjDelimAlt, 1);
00173       if (iRC)
00174       {
00175          fprintf(fLogFile,
00176                 "-E- %s: invalid object delimiter %1s found\n",
00177                 cModule, (char *) psObj);
00178          return -1;
00179       }
00180       else
00181          strcpy(cDelimiter, pcObjDelimAlt);
00182    }
00183    else
00184       strcpy(cDelimiter, pcObjDelim);
00185 
00186    for (ii = 1; ii <= ifile0; ii++)                     /* file loop */
00187    {
00188       psObj = psObj0;                          /* first object again */
00189       iobj = iobj0;                     /* first object number again */
00190       strcpy(cFilell, "");
00191       iRC = rawGetLLName( (char *) psFile, cDelimiter, cFilell);
00192 
00193       if (iDebug)
00194          fprintf(fLogFile, "DDD cFilell: |%s|\n", cFilell);
00195 
00196       bLastBuf = bFalse;
00197       iobjBuf = 1;
00198       if (iDebug > 1)
00199          fprintf(fLogFile, "\n*** buffer %d: %d objs\n", iobjBuf, iobj);
00200 
00201       while (!bLastBuf)
00202       {
00203 
00204          for (jj = 1; jj <= iobj; jj++)         /* object loop */
00205          {
00206 
00207             iRC = strcmp(cFilell, (char *) psObj);
00208             if (iRC == 0)                      /* file archived */
00209             {
00210               if (iDebug) fprintf(fLogFile,
00211                  "-E- %s-%d: file %s already archived at specified path\n",
00212                  cModule, ii, ++pcFilell);
00213               else
00214                  fprintf(fLogFile, "-E- file %s already archived at specified path on server %s\n",
00215                         ++pcFilell, pcNodeMaster);
00216                pcFilell--;
00217 
00218                strncpy( (char *) psFile, "\n", 1);
00219                ifile--;
00220                if (ifile == 0)
00221                {
00222                   if (iDebug) fprintf(fLogFile,
00223                       "-D- %s: last file, comparison finished\n",
00224                       cModule);
00225                   goto gEndCompare;
00226                }
00227                goto gNextFile;
00228 
00229             } /* iRC == 0: file already archived */
00230 
00231             psObj++;
00232          } /* object loop */
00233 
00234          piptr = (int **) psObj;
00235          if (*piptr == NULL)
00236          {
00237             bLastBuf = bTrue;
00238             if (iDebug > 1)
00239                fprintf(fLogFile, "    %d: last obj buffer\n", iobjBuf);
00240             if (iDebug)
00241                fprintf(fLogFile, "*** %d: %s (%s) to be archived\n",
00242                       ii, (char *) psFile, cFilell);
00243          }
00244          else
00245          {
00246             iobjBuf++;
00247             pinext = *piptr;
00248             iobj = *pinext++;
00249             psObj = (srawRetrList *) pinext;
00250             if (iDebug > 1) fprintf(fLogFile,
00251                "\n*** new buffer %d: %d objs, first obj %s|\n",
00252                iobjBuf, iobj, (char *) psObj);
00253          }
00254 
00255       } /* while (!bLastBuf) */
00256 
00257 gNextFile:
00258       psFile++;
00259    } /* file loop */
00260 
00261 gEndCompare:
00262    idel = ifile0-ifile;
00263    if (iDebug) fprintf(fLogFile,
00264       "-D- %s: %d of %d files removed: %d remaining\n",
00265       cModule, idel, ifile0, ifile);
00266 
00267    pifl[0] = ifile;
00268    *pcFileList = (char *) pifl;
00269 
00270    if ( (ifile > 0) && (idel > 0) )        /* compress filelist */
00271    {
00272       if (iDebug) fprintf(fLogFile,
00273          "-D- compress file list: search %d files\n", ifile);
00274       iif = 1;
00275       psFile = psFile0;
00276       for (ii = 1; ii <= ifile0; ii++)             /* file loop */
00277       {
00278          /* fprintf(fLogFile, "%d: %s\n", ii, (char *) psFile); */
00279          iRC = strncmp( (char *) psFile, "\n", 1);
00280          if (iRC != 0)                            /* file found */
00281          {
00282             if (iif == ifile0) goto gEndCompress;
00283             psFile0++;
00284             psFile++;
00285             iif++;
00286          }
00287          else
00288          {                                    /* compress action */
00289             for (jj = ii+1; jj <= ifile0; jj++)
00290             {
00291                psFile++;
00292                iif++;
00293                iRC = strncmp( (char *) psFile, "\n", 1);
00294                if (iRC == 0)
00295                {
00296                   if (iif == ifile0) goto gEndCompress;
00297                }
00298                else
00299                {
00300                   strcpy( (char *) psFile0, (char *) psFile);
00301                   if (iDebug > 1) fprintf(fLogFile,
00302                      "*** %d: %s\n", iif, (char *) psFile0);
00303                   if (iif == ifile0) goto gEndCompress;
00304                   psFile0++;
00305                }
00306             } /* for (jj...) */
00307 
00308          } /* compress action */
00309       } /* for (ii...) */
00310    } /* ifile > 0 && idel > 0 */
00311 
00312 gEndCompress:
00313 
00314    if (iDebug)
00315       fprintf(fLogFile, "-D- end %s\n\n", cModule);
00316    return idel ;
00317 
00318 } /* rawCheckFilelist */
00319 
00320 /********************************************************************
00321  * rawCheckObjlist:
00322  *    on input:
00323  *       FileComp: no. of valid files/objs
00324  *       pcObjList: chain of ptr-linked buffers with obj lists
00325  *       pcFileList: corresponding file list (one buffer)
00326  *    on output:
00327  *       pcFileList: compressed and sorted file list
00328  *       pcObjListall: corresponding compressed and sorted obj list
00329  *                     (one buffer)
00330  *    remove files/objs with zero length ll names from both lists,
00331  *    reorder remaining files/objs according to restore parameter
00332  *
00333  * created 18. 3.96, Horst Goeringer
00334  ********************************************************************
00335  */
00336 
00337 int rawCheckObjlist(int iFileComp,
00338                     char **pcObjList,
00339                     char **pcFileList,
00340                     char **pcObjListall)
00341 {
00342    int iDebug = 0;
00343    char cModule[32]="rawCheckObjlist";
00344    int iRC;
00345 
00346    char *pcfl, *pcol, *pcolall;
00347    int  *pifl, *piol;
00348    int ifile0;
00349    int iobj0, iobj;
00350 
00351    char *pcFileBuf, *pcObjBuf;
00352    int iFileBuf, iObjBuf;
00353    int  *piflcopy, *piolcopy;
00354 
00355    int iiObj, iiBuf;
00356    int **piptr;               /* points to pointer to next buffer */
00357    int *pinext;               /* points to next buffer */
00358 
00359    srawArchList *psFile, *psFile0;        /* files to be written   */
00360 
00361    srawRetrList *psObj, *psObj0;        /* objects to be retrieved */
00362    srawRetrList *psObjMin;       /* object with min restore number */
00363 
00364    srawArchList *psFileCopy;              /* files to be written   */
00365    srawRetrList *psObjCopy;             /* objects to be retrieved */
00366 
00367    int ii, jj, jjMin;
00368    int icount;
00369 
00370    unsigned int irestoHLmin, irestoLLmin;
00371    bool_t bInit;
00372 
00373    pcfl = *pcFileList;
00374    pifl = (int *) pcfl;
00375    ifile0 = pifl[0];                       /* number of all files */
00376    psFile = (srawArchList *) ++pifl;  /* points now to first file */
00377    psFile0 = psFile;
00378    pifl--;                     /* points again to number of files */
00379 
00380    pcolall = *pcObjListall;
00381    pcol = *pcObjList;
00382    piol = (int *) pcol;
00383    iobj0 = piol[0];        /* number of archived objects in buffer */
00384    psObj = (srawRetrList *) ++piol;  /* points now to first object */
00385    psObj0 = psObj;
00386    piol--;                    /* points again to number of objects */
00387 
00388    if (iDebug)
00389    {
00390       fprintf(fLogFile,
00391          "\n-D- begin %s: initial %d files, %d objects (1st buffer)\n",
00392          cModule, ifile0, iobj0);
00393       fprintf(fLogFile,
00394          "    compressed: %d files/objects\n", iFileComp);
00395    }
00396    if (iDebug > 1)
00397       fprintf(fLogFile, "    first file %s, first obj %s\n",
00398               (char *) psFile, psObj->cNamell);
00399 
00400    iFileBuf = sizeof(int) + iFileComp*sizeof(srawArchList);
00401    if ((pcFileBuf = (char *) calloc(iFileBuf, sizeof(char) ) ) == NULL)
00402    {
00403       perror("-E- rawCheckObjlist: allocating filelist buffer");
00404       return(-2);
00405    }
00406    if (iDebug) fprintf(fLogFile,
00407       "    filelist buffer allocated for retrieve (size %d)\n",
00408       iFileBuf);
00409 
00410    piflcopy = (int *) pcFileBuf;
00411    piflcopy[0] = iFileComp;           /* compressed number of files */
00412    psFileCopy = (srawArchList *) ++piflcopy;
00413                                       /* points now to first file */
00414 
00415    iObjBuf = sizeof(int) + iFileComp*sizeof(srawRetrList);
00416    if ( ( pcObjBuf = (char *) calloc(iObjBuf, sizeof(char) ) ) == NULL )
00417    {
00418       perror("-E- rawCheckObjlist: allocating objlist buffer");
00419       return(-3);
00420    }
00421    if (iDebug) fprintf(fLogFile,
00422       "    objlist buffer allocated for retrieve (size %d)\n", iObjBuf);
00423 
00424    piolcopy = (int *) pcObjBuf;
00425    piolcopy[0] = iFileComp;           /* compressed number of files */
00426    psObjCopy = (srawRetrList *) ++piolcopy;
00427                                         /* points now to first file */
00428 
00429    iiObj = 0;                   /* no. of objects in current buffer */
00430    iiBuf = 1;                       /* no. of current object buffer */
00431    icount = 0;                      /* no. of files/objects copied  */
00432    for (ii = 1; ii <= iFileComp; ii++)
00433    {                   /* loop over COMPRESSED no. of files/objects */
00434       if (iDebug > 1)
00435          fprintf(fLogFile, "\nDDD object %d:\n", ii);
00436       bInit = bTrue;
00437       iobj = iobj0;         /* no. of arch. objects in first buffer */
00438 
00439       for (jj = 1; jj <= ifile0; jj++)
00440       {                              /* loop over ALL files/objects */
00441          iiObj++;
00442          if (iDebug > 1) fprintf(fLogFile,
00443             "*** buffer %d, obj %d: %s\n",
00444             iiBuf, iiObj, psObj->cNamell);
00445          iRC = strncmp(psObj->cNamell, "\0", 1);
00446          if (iDebug > 1) fprintf(fLogFile,
00447             "DDD %d,%d: %s, iRC %d\n", ii, jj, psObj->cNamell, iRC);
00448          if (iRC != 0)
00449          {
00450             if (bInit)
00451             {
00452                jjMin = jj;
00453                psObjMin  = psObj;            /* default min: 1st obj */
00454                irestoHLmin = psObj->iRestoHigh;
00455                irestoLLmin = psObj->iRestoLow;
00456                bInit = bFalse;
00457                if (iDebug > 1) fprintf(fLogFile,
00458                   "DDD0 new min %s: %d-%d\n", (char *) psObjMin,
00459                   irestoHLmin, irestoLLmin);
00460                if (ii == iFileComp)             /* last file/object */
00461                   goto gStore;
00462             }
00463             if (iDebug > 1) fprintf(fLogFile,
00464                "DDD found: %d-%d\n",
00465                psObj->iRestoHigh, psObj->iRestoLow);
00466             if (psObj->iRestoHigh < irestoHLmin)
00467             {
00468                jjMin = jj;
00469                psObjMin  = psObj;                       /* keep obj */
00470                irestoHLmin = psObj->iRestoHigh;
00471                irestoLLmin = psObj->iRestoLow;
00472                if (iDebug > 1) fprintf(fLogFile,
00473                   "DDD1 new min %s: %d-%d\n", (char *) psObjMin,
00474                   irestoHLmin,
00475                   irestoLLmin);
00476                if (ii == iFileComp)             /* last file/object */
00477                   goto gStore;
00478             }
00479             else
00480             {
00481                if (psObj->iRestoHigh == irestoHLmin)
00482                {
00483                   if (psObj->iRestoLow < irestoLLmin)
00484                   {
00485                      jjMin = jj;
00486                      psObjMin  = psObj;                /* keep obj */
00487                      irestoHLmin = psObj->iRestoHigh;
00488                      irestoLLmin = psObj->iRestoLow;
00489                      if (iDebug > 1) fprintf(fLogFile,
00490                         "DDD2 new min %s: %d-%d\n",
00491                         (char *) psObjMin,
00492                         irestoHLmin,
00493                         irestoLLmin);
00494                      if (ii == iFileComp)      /* last file/object */
00495                         goto gStore;
00496 
00497                   } /* psObj->iRestoLow < irestoLLmin */
00498                } /* psObj->iRestoHigh == irestoHLmin */
00499 
00500             } /* psObj->iRestoHigh >= irestoHLmin */
00501          } /* iRC != 0 */
00502 
00503          psObj++;
00504          if (iiObj == iobj)
00505          {
00506             if (iDebug > 1) fprintf(fLogFile,
00507                "    buffer %d: last obj (no. %d) handled\n",
00508                iiBuf, iiObj);
00509             piptr = (int **) psObj;
00510             if (*piptr == NULL)
00511             {
00512                if (iDebug > 1) fprintf(fLogFile,
00513                   "    %d: last obj buffer\n", iiBuf);
00514             }
00515             else
00516             {
00517                iiObj = 0;
00518                iiBuf++;
00519                pinext = *piptr;
00520                iobj = *pinext++;
00521                psObj = (srawRetrList *) pinext;
00522                if (iDebug > 1) fprintf(fLogFile,
00523                   "    %d: new buffer, %d objs, first: %s|\n",
00524                   iiBuf, iobj, psObj->cNamell);
00525             }
00526 
00527          } /* iiObj == iobj */
00528 
00529 
00530       } /* for (jj...) */
00531 
00532 gStore:
00533       icount++;
00534       psObj = psObjMin;
00535       if (iDebug)
00536       {
00537          fprintf(fLogFile, "-D- copy %d-%d\n",
00538                  irestoHLmin, irestoLLmin);
00539          fprintf(fLogFile, "    obj %s, %d-%d\n", psObj->cNamell,
00540                  psObj->iObjHigh, psObj->iObjLow);
00541       }
00542 
00543       /* write obj items to temp structure */
00544       strcpy(psObjCopy->cNamell, psObj->cNamell);
00545       psObjCopy->iObjHigh = psObj->iObjHigh;
00546       psObjCopy->iObjLow =  psObj->iObjLow;
00547       psObjCopy->iRestoHigh = psObj->iRestoHigh;
00548       psObjCopy->iRestoLow = psObj->iRestoLow;
00549       psObjCopy->iFileType = psObj->iFileType;
00550       psObjCopy->iBufsizeFile = psObj->iBufsizeFile;
00551       psObjCopy->iFileSize = psObj->iFileSize;
00552       psObjCopy->iStageFS = psObj->iStageFS;
00553       strcpy(psObjCopy->cNodeMover, psObj->cNodeMover);
00554       psObjCopy->iArchiveFS = psObj->iArchiveFS;
00555       strcpy(psObjCopy->cArchiveDate, psObj->cArchiveDate);
00556       strcpy(psObjCopy->cOwner, psObj->cOwner);
00557 
00558       strncpy(psObj->cNamell, "\0", 1);      /* make it invalid */
00559 
00560       psFile = psFile0;
00561       psFile += (jjMin-1);
00562       if (iDebug)
00563          fprintf(fLogFile, "    file %s\n", (char *) psFile->cFile);
00564       iRC = strncmp(psFile->cFile, "\0", 1);
00565       if (iRC == 0)
00566       {
00567          fprintf(fLogFile,
00568             "-E- %s: file and object lists inconsistent\n", cModule);
00569          return(-4);
00570       }
00571       else if (iDebug)
00572          fprintf(fLogFile, "    write file %s to temp structure\n",
00573                  (char *) psFile->cFile);
00574 
00575       /* write file to temp structure */
00576       strcpy(psFileCopy->cFile, psFile->cFile);
00577 
00578       strncpy(psFile->cFile, "\0", 1);       /* make it invalid */
00579 
00580       /* set ptrs for next iteration */
00581       psObj = psObj0;
00582       psObjCopy++;
00583       psFile = psFile0;
00584       psFileCopy++;
00585 
00586       iiObj = 0;
00587       iiBuf = 1;
00588 
00589    } /* for (ii..) */
00590 
00591    if (icount != iFileComp)
00592    /* if (iRC != 0) */
00593    {
00594       fprintf(fLogFile,
00595          "-E- %s: unexpected no. of objects (%d) found\n",
00596          cModule, icount);
00597       return -5;
00598    }
00599    else if (iDebug)
00600       fprintf(fLogFile, "    obj no. %d okay\n", icount);
00601 
00602    /* memset(pcol, 0x00, iObjBuf); */
00603    memcpy(pcolall, pcObjBuf, iObjBuf);
00604    memset(pcfl, 0x00, iFileBuf);
00605    memcpy(pcfl, pcFileBuf, iFileBuf);
00606 
00607    if (iDebug) fprintf(fLogFile,
00608       "-D- end %s\n\n", cModule);
00609    return 0;
00610 
00611 } /* rawCheckObjlist */
00612 
00613 /*********************************************************************
00614  * rawDelFile: delete single file in GSI mass storage
00615  *
00616  * created  8.10.1996, Horst Goeringer
00617  *********************************************************************
00618  */
00619 
00620 int rawDelFile( int iSocket,
00621                 srawComm *pCommBuf)
00622 {
00623    int iDebug = 0;
00624    char cModule[32] = "rawDelFile";
00625 
00626    int iStage = 0;
00627    int iRC;
00628    int iIdent;
00629    int iStatus, iStatusLen;
00630    int iBuf, iBufComm;
00631    char *pc, *pBuf;
00632 
00633    srawComm *pComm;
00634    srawStatus sStatus;
00635    srawQueryResult sQuery;
00636    srawObjAttr *pQAttr;
00637 
00638    pComm = pCommBuf;
00639    iBufComm = ntohl(pComm->iCommLen) + HEAD_LEN;
00640    if (iDebug) printf(
00641       "\n-D- begin %s: delete file %s\n", cModule, pComm->cNamell);
00642 
00643    /* make query to get object ids (unavailable in archive lists) */
00644    pBuf = (char *) &sQuery;
00645    pQAttr = &(sQuery.objAttr);
00646    pComm->iAction = htonl(QUERY_REMOVE);
00647    iRC = rawQueryFile(iSocket, pComm, (void *) &pBuf);
00648 
00649    if (iDebug)
00650       printf("    after rawQueryFile, rc = %d\n", iRC);
00651 
00652    if (iRC <= 0)
00653    {
00654       if (iRC < 0)
00655          return iRC;                                /* error occured */
00656 
00657       printf("-W- object %s%s%s not found\n",
00658              pComm->cNamefs, pComm->cNamehl, pComm->cNamell);
00659       return 1;
00660    }
00661 
00662    if ( (ntohl(pQAttr->iMediaClass) == GSI_MEDIA_STAGE) ||
00663         (ntohl(pQAttr->iMediaClass) == GSI_MEDIA_LOCKED) )
00664       iStage = ntohl(pQAttr->iFS);
00665    else
00666       iStage = 0;
00667    pComm->iStageFSid = htonl(iStage);
00668 
00669    if (iDebug)
00670    {
00671       printf("    file %s found (obj-id %d-%d)",
00672              pComm->cNamell,
00673              ntohl(pQAttr->iObjHigh),
00674              ntohl(pQAttr->iObjLow));
00675       if (iStage)
00676          printf( ", on %s in StageFS %d\n", pQAttr->cNode, iStage);
00677       else
00678          printf( "\n");
00679    }
00680 
00681    pComm->iAction = htonl(REMOVE);
00682    pComm->iObjHigh = pQAttr->iObjHigh;
00683    pComm->iObjLow = pQAttr->iObjLow;
00684 
00685    pc = (char *) pComm;
00686    if ( (iRC = send( iSocket, pc, iBufComm, 0 )) < 0 )
00687    {
00688       perror("-E- sending command buffer");
00689       printf("-E- %s: sending delete request %s\n",
00690              cModule, pComm->cNamell);
00691       return -1;
00692    }
00693 
00694    if (iDebug) printf(
00695       "-D- delete command sent to server (%d bytes), look for reply\n",
00696       iBufComm);
00697 
00698    /*********** look for reply from server *****************/
00699 
00700    pc = (char *) &sStatus;
00701    iRC = rawRecvStatus(iSocket, &pc);
00702    if (iRC < HEAD_LEN)
00703    {
00704       printf("-E- receiving status buffer with delete information\n");
00705       return(-1);
00706    }
00707    if (iRC > HEAD_LEN)
00708    {
00709       printf("-E- message received from server:\n");
00710       printf("%s", sStatus.cStatus);
00711       return(-1);
00712    }
00713 
00714    if (iDebug)
00715       printf("    status (%d) received from server (%d bytes)\n",
00716              sStatus.iStatus, iRC);
00717 
00718    printf("-I- Object %s%s%s successfully deleted",
00719           pComm->cNamefs, pComm->cNamehl, pComm->cNamell);
00720    if (iStage)
00721       printf( " (staged)\n");
00722    else
00723       printf( "\n");
00724 
00725    if (iDebug)
00726       printf("-D- end %s\n\n", cModule);
00727 
00728    return 0;
00729 
00730 } /* end rawDelFile */
00731 
00732 /*********************************************************************
00733  * rawDelList:  delete list of files in GSI mass storage
00734  *
00735  * created 22.10.1997, Horst Goeringer
00736  *********************************************************************
00737  */
00738 
00739 int rawDelList( int iDataMover,
00740                 srawDataMoverAttr *pDataMover0,
00741                 srawComm *psComm,
00742                 char **pcFileList,
00743                 char **pcObjList)
00744 {
00745    char cModule[32] = "rawDelList";
00746    int iDebug = 0;
00747 
00748    int iSocket;
00749    char *pcfl, *pcol;
00750    int *pifl, *piol;
00751    int ifile;
00752    int iobj0, iobj, iobjf = 0;
00753    int iobjBuf;
00754 
00755    srawArchList *psFile, *psFile0;           /* files to be archived */
00756    srawRetrList *psObj;                  /* objects already archived */
00757    srawDataMoverAttr *pDataMover;              /* current data mover */
00758 
00759    char cFilell[MAX_OBJ_LL];
00760    char *pc, *pdelim;
00761 
00762    bool_t bDelete, bDelDone;
00763    int **piptr;                  /* points to pointer to next buffer */
00764 
00765    int ii, jj, kk;
00766    int iRC, idel;
00767 
00768    pcfl = *pcFileList;
00769    pifl = (int *) pcfl;
00770    ifile = pifl[0];                            /* number of files */
00771    psFile = (srawArchList *) ++pifl;  /* points now to first file */
00772    psFile0 = psFile;
00773    pifl--;                     /* points again to number of files */
00774 
00775    if (iDebug)
00776    {
00777       printf("\n-D- begin %s\n", cModule);
00778       printf("    initial %d files, first file %s\n",
00779              ifile, psFile0->cFile);
00780    }
00781 
00782    pDataMover = pDataMover0;
00783    if (iDataMover == 1)
00784    {
00785       iSocket = pDataMover->iSocket;
00786       if (iDebug) printf(
00787          "    one data mover %s, socket %d\n",
00788          pDataMover->cNode, iSocket);
00789    }
00790 
00791    pcol = *pcObjList;
00792    piol = (int *) pcol;
00793    iobj0 = 0;                     /* total no. of archived objects */
00794 
00795    iobjBuf = 0;                             /* count query buffers */
00796    idel = 0;                                /* count deleted files */
00797    bDelDone = bFalse;
00798    while (!bDelDone)
00799    {
00800       iobjBuf++;
00801       iobj = piol[0];            /* no. of objects in query buffer */
00802       psObj = (srawRetrList *) ++piol;
00803                                      /* points now to first object */
00804       if (iDebug)
00805          printf("    buffer %d: %d objects, first obj %s (server %d)\n",
00806                 iobjBuf, iobj, psObj->cNamell, psObj->iMaster);
00807 
00808       psComm->iAction = htonl(REMOVE);
00809       for (ii=1; ii<=iobj; ii++)    /* loop over objects in buffer */
00810       {
00811          iobj0++;
00812          pc = (char *) psObj;
00813          pc++;                           /* skip object delimiter  */
00814 
00815          bDelete = bFalse;
00816          psFile = psFile0;
00817          for (jj=1; jj<=ifile; jj++)                  /* file loop */
00818          {
00819             pdelim = strrchr(psFile->cFile, *pcFileDelim);
00820             if (pdelim == NULL)
00821             {
00822 #ifdef VMS
00823                pdelim = strrchr(psFile->cFile, *pcFileDelim2);
00824                if (pdelim != NULL) pdelim++;
00825                else
00826 #endif
00827                pdelim = psFile->cFile;
00828             }
00829             else pdelim++;                 /* skip file delimiter  */
00830 
00831             iRC = strcmp(pdelim, pc);
00832             if ( iRC == 0 )
00833             {
00834                bDelete = bTrue;
00835                break;
00836             }
00837             psFile++;
00838          } /* file loop (jj) */
00839 
00840          if (bDelete)
00841          {
00842             if (iDebug)
00843             {
00844                printf("    found file %d: %s, obj %d: %s",
00845                       jj, psFile->cFile, ii, psObj->cNamell);
00846                if (psObj->iStageFS)
00847                   printf(", on DM %s in StageFS %s\n",
00848                          psObj->cNodeMover, psObj->iStageFS);
00849                else if (psObj->iArchiveFS)
00850                {
00851                   printf(", on DM %s in ArchiveFS %s\n",
00852                          psObj->cNodeMover, psObj->iArchiveFS);
00853                   printf("    archived at %s by %s\n",
00854                          psObj->cArchiveDate, psObj->cOwner);
00855                }
00856                else
00857                   printf(" (not in disk pool)\n");
00858             }
00859 
00860             iRC = rawGetLLName(psFile->cFile,
00861                                 pcObjDelim, psComm->cNamell);
00862 
00863             if (iDataMover > 1)
00864             {
00865                if ((strcmp(pDataMover->cNode,psObj->cNodeMover) == 0) ||
00866                    (strlen(psObj->cNodeMover) == 0))   /* not staged */
00867                {
00868                   iSocket = pDataMover->iSocket;
00869                   if (iDebug) printf(
00870                      "    current data mover %s, socket %d\n",
00871                      pDataMover->cNode, iSocket);
00872                }
00873                else
00874                {
00875                   pDataMover = pDataMover0;
00876                   for (kk=1; kk<=iDataMover; kk++)
00877                   {
00878                      if (strcmp(pDataMover->cNode,
00879                                 psObj->cNodeMover) == 0)
00880                         break;
00881                      pDataMover++;
00882                   }
00883 
00884                   if (kk > iDataMover)
00885                   {
00886                      printf("-E- %s: data mover %s not found in list\n",
00887                             cModule, psObj->cNodeMover);
00888                      return -1;
00889                   }
00890 
00891                   iSocket = pDataMover->iSocket;
00892                   if (iDebug) printf(
00893                      "    new data mover %s, socket %d\n",
00894                      pDataMover->cNode, iSocket);
00895                }
00896             } /* (iDataMover > 1) */
00897 
00898             iRC = rawDelFile(iSocket, psComm);
00899             if (iRC)
00900             {
00901                if (iDebug)
00902                   printf("    rawDelFile: rc = %d\n", iRC);
00903                if (iRC < 0)
00904                {
00905                   printf("-E- %s: file %s could not be deleted\n",
00906                          cModule, psFile->cFile);
00907                   return -1;
00908                }
00909                /* else: object not found, ignore */
00910 
00911             } /* (iRC) */
00912             idel++;
00913 
00914          } /* if (bDelete) */
00915          psObj++;
00916 
00917       } /* loop over objects in query buffer (ii) */
00918 
00919       piptr = (int **) psObj;
00920       if (*piptr == NULL) bDelDone = bTrue;
00921       else piol = *piptr;
00922 
00923    } /* while (!bDelDone) */
00924 
00925    if (iDebug) printf("-D- end %s\n\n", cModule);
00926 
00927    return(idel);
00928 
00929 } /* rawDelList */
00930 
00931 /**********************************************************************
00932  * rawGetFilelistEntries:
00933  *    get filelist entries from input file
00934  *    uses external buffer ptr piEntryList provided by caller
00935  *    removes tape file specifications
00936  *    replaces '%' (historical) by '?' (supported by TSM)
00937  *    removes tape file specifications
00938  *    removes duplicate entries
00939  *    orders: generic file names first
00940  *
00941  * created 22. 5.2003 by Horst Goeringer
00942  **********************************************************************
00943  */
00944 
00945 int rawGetFilelistEntries( char *pcFileName,
00946                            int *piEntries)
00947 {
00948    char cModule[32] = "rawGetFilelistEntries";
00949    int iDebug = 0;
00950 
00951    int ii, jj;
00952    int imax = MAX_FILE;
00953    char cEntry[MAX_FILE] = "", *pcEntry;
00954    char cFileName[MAX_FILE] = "";
00955    char cQualifier[16] = ".filelist";
00956    char *pcLeading = "@";
00957    char *pcc;
00958    char *ploc;
00959 
00960    int iRemove;
00961    int iGeneric = 0;                 /* = 1: generic file name found */
00962    int iSingle = 0;   /* = 1: file name without wildcard chars found */
00963    int iRC;
00964    int iError;
00965 
00966    int iGenericEntries = 0;
00967    int iSingleEntries = 0;
00968    int iEntries = -1;
00969    FILE *fiFile = NULL;
00970 
00971    int iMaxEntries;
00972    int iSizeBuffer;
00973    int *piFilelist, *piFilelisto;
00974    srawArchList *pFilelist,                  /* first filelist entry */
00975                 *pFilelistc,               /* current filelist entry */
00976                 *pFilelistco,   /* current filelist entry old buffer */
00977                 *pFilelistc0;   /* current filelist entry for remove */
00978 
00979    if (iDebug)
00980       printf("\n-D- begin %s\n", cModule);
00981 
00982    piFilelist = piEntryList;             /* copy of external pointer */
00983 
00984    if (strlen(pcFileName) >= imax)
00985    {
00986       fprintf(fLogFile,
00987          "-E- %s: file name too long (max %d)\n",
00988          cModule, --imax);
00989       iError = -1;
00990       goto gErrorFilelist;
00991    }
00992    strcpy(cFileName, pcFileName);                      /* local copy */
00993 
00994    iRC = strncmp(cFileName, pcLeading, 1);
00995    if (iRC)
00996    {
00997       if (iDebug) fprintf(fLogFile,
00998          "    no leading %s\n", pcLeading);
00999       goto gEndFilelist;
01000    }
01001 
01002    pcc = cQualifier;
01003    ploc = strrchr(cFileName, pcc[0]);
01004    if (ploc != NULL)
01005    {
01006       ploc++;
01007       pcc++;
01008       if (strcmp(ploc, pcc) != 0)
01009       {
01010          if (iDebug) fprintf(fLogFile,
01011             "    no trailing %s\n", cQualifier);
01012          goto gEndFilelist;
01013       }
01014    }
01015    else
01016    {
01017       if (iDebug) fprintf(fLogFile,
01018          "    no trailing %s\n", cQualifier);
01019       goto gEndFilelist;
01020    }
01021 
01022    if (iDebug) fprintf(fLogFile,
01023       "    %s is a filelist\n", cFileName);
01024 
01025    fiFile = fopen(pcFileName, "r");
01026    if (fiFile == NULL)
01027    {
01028       fprintf(fLogFile, "-E- %s: opening filelist %s\n",
01029               cModule, pcFileName);
01030       perror("    ");
01031       iError = -1;
01032       goto gErrorFilelist;
01033    }
01034    if (iDebug) fprintf(fLogFile,
01035       "    filelist %s opened\n", pcFileName);
01036 
01037    piFilelisto = piFilelist;
01038    iMaxEntries = *piFilelist;
01039    if (iDebug) fprintf(fLogFile,
01040       "    max no. of entries in filelist buffer: %d\n", iMaxEntries);
01041    if (iDebug == 2) fprintf(fLogFile,
01042       "DDD piFilelist %d, *piFilelist %d\n",
01043       piFilelist, *piFilelist);
01044 
01045    pFilelist = (srawArchList *) &(piFilelist[1]);
01046                                           /* skip max no. of entries */
01047    pFilelistc = pFilelist;                          /* current entry */
01048    pcEntry = cEntry;
01049    iEntries = 0;
01050    for(;;)
01051    {
01052       pcEntry = fgets(cEntry, imax, fiFile);
01053 
01054       if ( (pcEntry != NULL) && (strlen(pcEntry) > 1) )
01055       {
01056          ploc = strchr(pcEntry, '\n');
01057          if (ploc != NULL)
01058             *ploc = '\0';
01059 
01060          ploc = strchr(pcEntry, *pcDevDelim);
01061          if (ploc != NULL)
01062          {
01063             fprintf(fLogFile,
01064                "-W- no local tape support in filelist, %s ignored\n",
01065                pcEntry);
01066             continue;
01067          }
01068 
01069          /* replace '%' (historical) by '?' (supported by TSM) */
01070          while ( (ploc = strchr(pcEntry, *pcPerc)) != NULL)
01071          {
01072             if (iDebug)
01073                fprintf(fLogFile, "-W- replace %s", pcEntry);
01074             *ploc = *pcQM;
01075             if (iDebug)
01076                fprintf(fLogFile, " by %s\n", pcEntry);
01077          }
01078 
01079          if (iEntries == iMaxEntries)    /* reallocate for new entry */
01080          {
01081             iMaxEntries += iMaxEntries;
01082             if (iDebug) fprintf(fLogFile,
01083                "    entry buffer full, reallocate: max %d entries\n",
01084                iMaxEntries);
01085 
01086             iSizeBuffer = iMaxEntries*MAX_FILE + sizeof(int);
01087             piFilelisto = piFilelist;
01088             piFilelist = (int *) calloc(iSizeBuffer, sizeof(char) );
01089             if (piFilelist == NULL)
01090             {
01091                fprintf(fLogFile,
01092                   "-E- reallocating filelist buffer (size %d)\n",
01093                   iSizeBuffer);
01094                perror("-E- reallocating filelist buffer");
01095                iError = -1;
01096                goto gErrorFilelist;
01097             }
01098 
01099             if (iDebug) fprintf(fLogFile,
01100                "    filelist entry buffer reallocated (size %d)\n",
01101                iSizeBuffer);
01102 
01103             *piFilelist = iMaxEntries;
01104             if (iDebug == 2) fprintf(fLogFile,
01105                "DDD piFilelist %d, *piFilelist %d\n",
01106                 piFilelist, *piFilelist);
01107 
01108             pFilelistc = (srawArchList *) &(piFilelist[1]);   /* new */
01109             pFilelistco = pFilelist;                   /* old buffer */
01110             pFilelist = pFilelistc;              /* first new buffer */
01111 
01112             for (ii=1; ii<=iEntries; ii++)
01113             {
01114                if (iDebug == 2) fprintf(fLogFile,
01115                   "DDD pFilelistc %d\n", pFilelistc);
01116                strcpy(pFilelistc->cFile, pFilelistco->cFile);
01117                pFilelistc++;
01118                pFilelistco++;
01119             }
01120 
01121             if (iDebug) fprintf(fLogFile,
01122                "    %d old entries copied to new buffer, next:\n",
01123                iEntries);
01124 
01125             if (iDebug == 2) fprintf(fLogFile,
01126                "DDD free piFilelisto %d\n", piFilelisto);
01127             free(piFilelisto);
01128             piFilelisto = piFilelist;
01129          } /* (iEntries == iMaxEntries) */
01130 
01131          if (iDebug == 2) fprintf(fLogFile,
01132             "DDD pFilelistc %d\n", pFilelistc);
01133          strcpy(pFilelistc->cFile, pcEntry);
01134          iEntries++;
01135 
01136          if (iDebug) fprintf(fLogFile,
01137             "    %3d: %s \n", iEntries, pFilelistc->cFile);
01138 
01139          pFilelistc++;
01140       }
01141       else
01142          break;
01143 
01144    } /* read loop */
01145 
01146    pFilelistc = pFilelist;
01147    if (iDebug)
01148       for (ii=1; ii<=iEntries; ii++)
01149    {
01150       fprintf(fLogFile,
01151          "    %3da: %s \n", ii, pFilelistc->cFile);
01152       pFilelistc++;
01153    }
01154 
01155    /* check if duplicate entries */
01156    if (iEntries)
01157    {
01158       pFilelistc = pFilelist;
01159       iRemove = 0;
01160       for (ii=1; ii<iEntries; ii++)
01161       {
01162          if (strlen(pFilelistc->cFile) == 0)      /* already removed */
01163          {
01164             pFilelistc++;
01165             continue;
01166          }
01167 
01168          pFilelistco = pFilelistc;
01169          pFilelistco++;
01170          for (jj=ii+1; jj<=iEntries; jj++)
01171          {
01172             if (strcmp(pFilelistc->cFile, pFilelistco->cFile) == 0)
01173             {
01174                if (iDebug)
01175                   fprintf(fLogFile, "-W- duplicate entry %s removed\n",
01176                           pFilelistco->cFile);
01177                strcpy(pFilelistco->cFile, "");
01178                iRemove++;
01179             }
01180             pFilelistco++;
01181          }
01182 
01183          pFilelistc++;
01184       }
01185 
01186       if (iDebug)
01187       {
01188          if (iRemove) fprintf(fLogFile,
01189             "    %d duplicate entries found in list\n", iRemove);
01190          else fprintf(fLogFile,
01191             "    no duplicate entries found in list\n");
01192       }
01193    } /* (iEntries) */
01194    else if (iDebug)
01195       fprintf(fLogFile, "    no entries found in list\n");
01196 
01197    pFilelistc = pFilelist;
01198    if (iDebug)
01199       for (ii=1; ii<=iEntries; ii++)
01200    {
01201       fprintf(fLogFile,
01202          "    %3db: %s \n", ii, pFilelistc->cFile);
01203       pFilelistc++;
01204    }
01205 
01206    /* reorder remaining entries */
01207    if (iRemove)
01208    {
01209       pFilelistc = pFilelist;
01210       for (ii=1; ii<iEntries; ii++)
01211       {
01212          if (strlen(pFilelistc->cFile) == 0)              /* removed */
01213          {
01214             pFilelistco = pFilelistc;
01215             pFilelistco++;
01216             pFilelistc0 = pFilelistc;
01217             for (jj=ii+1; jj<=iEntries; jj++)
01218             {
01219                strcpy(pFilelistc0->cFile, pFilelistco->cFile);
01220                pFilelistc0++;
01221                pFilelistco++;
01222             }
01223             continue;
01224                 /* no ptr incr, as same location to be checked again */
01225          }
01226          pFilelistc++;
01227       }
01228       iEntries -= iRemove;
01229    }
01230 
01231    /* check if sorting necessary */
01232    pFilelistc = pFilelist;
01233    for (ii=1; ii<=iEntries; ii++)
01234    {
01235       ploc = strchr(pFilelistc->cFile, *pcStar);
01236       if (ploc != NULL)
01237          iGeneric = 1;
01238       else
01239       {
01240          ploc = strchr(pFilelistc->cFile, *pcQM);
01241          if (ploc != NULL)
01242             iGeneric = 1;
01243          else
01244          {
01245             ploc = strchr(pFilelistc->cFile, *pcPerc);
01246             if (ploc != NULL)
01247                iGeneric = 1;
01248             else
01249                iSingle = 1;
01250          }
01251       }
01252       if ( (iGeneric) && (iSingle) )
01253          break;
01254 
01255       pFilelistc++;
01256    }
01257 
01258    pFilelistc = pFilelist;
01259    if (iDebug)
01260       for (ii=1; ii<=iEntries; ii++)
01261    {
01262       fprintf(fLogFile,
01263          "    %3dc: %s \n", ii, pFilelistc->cFile);
01264       pFilelistc++;
01265    }
01266 
01267    /* reorder: generic names first */
01268    if ( (iGeneric) && (iSingle) )
01269    {
01270       piFilelisto = piFilelist;
01271 
01272       /* create buffer for sorted entries */
01273       iSizeBuffer = iEntries*MAX_FILE + sizeof(int);
01274       piFilelist = (int *) calloc(iSizeBuffer, sizeof(char) );
01275       if (piFilelist == NULL)
01276       {
01277          fprintf(fLogFile,
01278             "-E- allocating ordered filelist buffer (size %d)\n",
01279             iSizeBuffer);
01280          perror("-E- allocating ordered filelist buffer");
01281          iError = -1;
01282          goto gErrorFilelist;
01283       }
01284 
01285       if (iDebug) fprintf(fLogFile,
01286          "    ordered filelist buffer allocated (size %d)\n",
01287          iSizeBuffer);
01288 
01289       *piFilelist = iEntries;
01290       if (iDebug == 2) fprintf(fLogFile,
01291          "DDD piFilelist %d, *piFilelist %d\n",
01292          piFilelist, *piFilelist);
01293 
01294       pFilelistc = (srawArchList *) &(piFilelist[1]);
01295       pFilelist = pFilelistc;
01296       pFilelistco = (srawArchList *) &(piFilelisto[1]);
01297       iGenericEntries = 0;
01298 
01299       /* copy generic entries */
01300       for (ii=1; ii<=iEntries; ii++)
01301       {
01302          iGeneric = 0;
01303          iSingle = 0;
01304          ploc = strchr(pFilelistco->cFile, *pcStar);
01305          if (ploc != NULL)
01306             iGeneric = 1;
01307          else
01308          {
01309             ploc = strchr(pFilelistco->cFile, *pcQM);
01310             if (ploc != NULL)
01311                iGeneric = 1;
01312             else
01313             {
01314                ploc = strchr(pFilelistco->cFile, *pcPerc);
01315                if (ploc != NULL)
01316                   iGeneric = 1;
01317                else
01318                   iSingle = 1;
01319             }
01320          }
01321 
01322          if (iGeneric)
01323          {
01324             strcpy(pFilelistc->cFile, pFilelistco->cFile);
01325             strcpy(pFilelistco->cFile, "");
01326             pFilelistc++;
01327             iGenericEntries++;
01328          }
01329          pFilelistco++;
01330 
01331       } /* loop pFilelistco */
01332 
01333       pFilelistco = (srawArchList *) &(piFilelisto[1]);
01334       iSingleEntries = 0;
01335 
01336       /* copy non-generic entries */
01337       for (ii=1; ii<=iEntries; ii++)
01338       {
01339          if (strlen(pFilelistco->cFile) != 0)
01340          {
01341             strcpy(pFilelistc->cFile, pFilelistco->cFile);
01342             pFilelistc++;
01343             iSingleEntries++;
01344          }
01345          pFilelistco++;
01346       }
01347 
01348       if (iDebug) fprintf(fLogFile,
01349          "    %d generic file names, followed by %d non-generic file names\n",
01350          iGenericEntries, iSingleEntries);
01351 
01352    } /* (iGeneric) && (iSingle) */
01353 
01354    pFilelistc = pFilelist;
01355    if (iDebug)
01356       for (ii=1; ii<=iEntries; ii++)
01357    {
01358       fprintf(fLogFile,
01359          "    %3dd: %s \n", ii, pFilelistc->cFile);
01360       pFilelistc++;
01361    }
01362 
01363 gEndFilelist:
01364    *piEntries = iEntries;
01365    iError = 0;
01366 
01367    if (iDebug == 2) fprintf(fLogFile,
01368       "DDD piFilelist %d, *piFilelist %d\n", piFilelist, *piFilelist);
01369 
01370 gErrorFilelist:
01371    if (fiFile)
01372    {
01373       iRC = fclose(fiFile);
01374       if (iRC)
01375       {
01376          fprintf(fLogFile, "-E- %s: closing filelist %s\n",
01377                  cModule, pcFileName);
01378          perror("    ");
01379       }
01380    }
01381 
01382    piEntryList = piFilelist;             /* pass to external pointer */
01383 
01384    if (iDebug)
01385       printf("-D- end %s\n\n", cModule);
01386 
01387    return iError;
01388 
01389 } /* rawGetFilelistEntries */
01390 
01391 /********************************************************************
01392  * rawGetWSInfo: get workspace and pool info from master server
01393  *
01394  * created 30. 6.2003 by Horst Goeringer
01395  ********************************************************************
01396  */
01397 
01398 int rawGetWSInfo( srawCliActionComm *pCliActionComm,
01399                   srawPoolStatus *pPoolInfo,
01400                   srawWorkSpace **ppWorkSpace)
01401 {
01402    int iDebug = 0;
01403    char cModule[32] = "rawGetWSInfo";
01404    int iRC;
01405    int iSocket;
01406    int iPoolInfo;               /* =1: provide info on stage pool(s) */
01407    int iPrintPoolInfo;            /* =1: print info on stage pool(s) */
01408    int iWorkSpaceInfo;              /* =1: provide info on workspace */
01409 
01410    int iAction;
01411 
01412    int iBuf;
01413    int ii;
01414    int iIdent;
01415    int iStatus;
01416    int iAttrLen;
01417 
01418    int iPoolId;            /* identifier of requested pool, = 0: all */
01419    int iPoolMode = 0;        /* =1: retrieve, =2: stage, =3: archive */
01420    int iSleepClean = 0;          /* sleep if clean job needs started */
01421 
01422    int iPoolmax;
01423    int iPoolcur;
01424    int iBufPool;
01425 
01426    char cPoolNameRand[32] = "RetrievePool";
01427    char cPoolNameTemp[32] = "StagePool";
01428    int iHardwareFree = 0;          /* free space in hardware (MByte) */
01429    int iPoolRandFree;           /* free space of random pool (MByte) */
01430    int iPoolRandUsed;           /* used space of random pool (MByte) */
01431    int iRandomExcess = 0;
01432           /* unused space of other pools used in random pool (MByte) */
01433    int iPoolTempAvail = 0;
01434    int iPoolTempMax;            /* overall size of temp pool (MByte) */
01435    int iPoolTempMaxWS;           /* max WS size in temp pool (MByte) */
01436    int iPoolTempFree;             /* free space of temp pool (MByte) */
01437    int iPoolTempUsed;             /* used space of temp pool (MByte) */
01438    int iPoolTempCheck;
01439                   /* min work space check size for temp pool (MByte) */
01440    int iTempSizeUnavail = 0;
01441                /* temp pool space currently allocated by other pools */
01442 
01443    int iWorkSizeNew;
01444               /* still to be staged for requested work space (MByte) */
01445    int iWorkSizeAll;         /* size of requested work space (MByte) */
01446    int iWorkFilesAll;            /* total no. of files in work space */
01447    int iWorkSizeSta = 0;  /* part of requ. work space already staged */
01448    int iWorkFilesSta = 0;
01449                         /* no. of files in work space already staged */
01450    int iWorkSizeStaTemp = 0;
01451                            /* part of staged work space in temp pool */
01452    int iWorkFilesStaTemp = 0;    /* no. of staged files in temp pool */
01453    int iWorkSizeStaRand = 0;
01454                          /* part of staged work space in random pool */
01455    int iWorkFilesStaRand = 0;  /* no. of staged files in random pool */
01456    int iWorkSizeEst = 0;  /* part of requ. work space size estimated */
01457    int iWorkFilesEst = 0;
01458                    /* no. of files in work space with size estimated */
01459    int iWorkSizeIncompl = 0;
01460                      /* part of work space not yet completely staged */
01461    int iWorkFilesIncompl = 0;
01462              /* no. of files in work space not yet completely staged */
01463    int iWorkStatus = 0;       /* status of work space sent by server */
01464 
01465 
01466    int *piBuffer;
01467    char *pcc;
01468    char cMsg[256] = "";
01469    char cMsgPref[8] = "";
01470    char cMisc[128] = "";
01471    char pcGenFile[MAX_FILE] = "";        /* full (generic) file name */
01472 
01473    srawWorkSpace *pWorkSpace;
01474    srawPoolStatusData *pPoolInfoData, *pPoolInfoData0;
01475 
01476    if (iDebug)
01477       printf("\n-D- begin %s\n", cModule);
01478 
01479    piBuffer = pCliActionComm->piBuffer;      /* area to receive data */
01480    iSocket = pCliActionComm->iSocket;
01481    iAction = pCliActionComm->iAction;
01482 
01483    iPoolInfo = 1;
01484    if (iAction == QUERY_POOL)
01485    {
01486       iPoolId = pCliActionComm->iStatus;
01487       iPrintPoolInfo = 1;
01488       iWorkSpaceInfo = 0;
01489    }
01490    else
01491    {
01492       strcpy(pcGenFile, pCliActionComm->pcFile);
01493       iPoolId = 2;
01494       if (pCliActionComm->iStatus)
01495          iPrintPoolInfo = 1;
01496       else
01497          iPrintPoolInfo = 0;
01498       iWorkSpaceInfo = 1;
01499    }
01500 
01501    if (iDebug)
01502    {
01503       printf("    action %d", iAction);
01504       if (iPrintPoolInfo)
01505          printf(", print pool info");
01506       if (iAction == QUERY_POOL)
01507          printf(", poolId  %d\n", iPoolId);
01508       else
01509          printf("\n");
01510    }
01511 
01512    if (iPoolInfo)
01513    {
01514       pcc = (char *) piBuffer;               /* header for pool info */
01515       pPoolInfo = (srawPoolStatus *) piBuffer;         /* for caller */
01516       iRC = rawRecvHead(iSocket, &pcc);
01517       if (iRC <= 0)
01518       {
01519         printf("-E- receiving header pool status from master server\n");
01520         return -1;
01521       }
01522 
01523       if (iDebug)
01524          printf("    header pool status received (%d bytes)\n", iRC);
01525 
01526       iIdent = ntohl(pPoolInfo->iIdent);
01527       iStatus = ntohl(pPoolInfo->iPoolNo);
01528       iAttrLen = ntohl(pPoolInfo->iStatusLen);
01529 
01530       /* expect IDENT_POOL */
01531       if (iIdent != IDENT_POOL)
01532       {
01533          if (iIdent == IDENT_STATUS)
01534          {
01535             if ( (iStatus == STA_ERROR) || (iStatus == STA_ERROR_EOF) )
01536             {
01537                printf("-E- received error status from server");
01538                if (iDebug)
01539                   printf(" instead of pool info:\n");
01540                else printf(":\n");
01541 
01542                if (iAttrLen > 0)
01543                {
01544                   pcc = cMsg;
01545                   iRC = rawRecvError(iSocket, iAttrLen, &pcc);
01546                   if (iRC < 0) printf(
01547                      "-E- receiving error msg from server, rc = %d\n",
01548                      iRC);
01549                   else printf("    %s\n", pcc);
01550                }
01551                else printf("    no error message available\n");
01552 
01553             } /* (iStatus == STA_ERROR) || (iStatus == STA_ERROR_EOF) */
01554             else
01555             {
01556                printf(
01557                   "-E- unexpected status (type %d) received from server\n",
01558                   iStatus);
01559             }
01560          } /* iIdent == IDENT_STATUS */
01561          else
01562          {
01563             printf(
01564                "-E- unexpected header (%d) received from server\n",
01565                iIdent);
01566          }
01567 
01568          return -1;
01569 
01570       } /* (iIdent != IDENT_POOL) ) */
01571 
01572       iPoolmax = iStatus;
01573       iBufPool = iAttrLen;        /* size pool buffer without header */
01574 
01575       pcc += HEAD_LEN;
01576       pPoolInfoData = (srawPoolStatusData *) pcc;
01577       pPoolInfoData0 = pPoolInfoData;             /* first pool info */
01578 
01579       /* receive staging pool info */
01580       iBuf = iBufPool;
01581       while(iBuf > 0)
01582       {
01583          if ( (iRC = recv( iSocket, pcc, iBuf, 0 )) < 0 )
01584          {
01585             perror("-E- receiving pool info");
01586             return -1;
01587          }
01588          iBuf -= iRC;
01589          pcc += iRC;
01590       } /* while(iBuf > 0) */
01591 
01592       if (iDebug) printf(
01593          "    stage pool status received (%d bytes)\n", iBufPool);
01594 
01595       /* get pool names first for info messages */
01596       if ( (iAction == QUERY_POOL) || (iAction == QUERY_WORKSPACE) ||
01597            (iAction == STAGE) )
01598          for (iPoolcur=1; iPoolcur<=iPoolmax; iPoolcur++)
01599       {
01600          if (iPoolcur == 1)
01601          {
01602             iHardwareFree = ntohl(pPoolInfoData->iFreeSizeHW);
01603             iPoolRandFree = ntohl(pPoolInfoData->iFreeSize);
01604          }
01605          if (iPoolcur == 2)
01606             iPoolTempFree = ntohl(pPoolInfoData->iFreeSize);
01607 
01608          if (strcmp(pPoolInfoData->cPoolName, "RetrievePool") == 0)
01609             iPoolMode = 1;
01610          if (strcmp(pPoolInfoData->cPoolName, "StagePool") == 0)
01611             iPoolMode = 2;
01612 
01613          if ( (iAction == QUERY_POOL) || (iAction == QUERY_WORKSPACE) )
01614          {
01615             if (iPoolMode == 1)
01616             {
01617                if (iPrintPoolInfo) printf(
01618                   "-I- overall space %s %7d MByte, free %7d MByte\n",
01619                   pPoolInfoData->cPoolOS,
01620                   ntohl(pPoolInfoData->iMaxSizeHW), iHardwareFree);
01621 
01622                if ( (iPoolId == iPoolMode) || (iPoolId == 0) )
01623                {
01624                   printf("    %s: used for 'tsmcli retrieve'\n",
01625                      pPoolInfoData->cPoolName);
01626 
01627                   iPoolRandUsed = ntohl(pPoolInfoData->iMaxSize) -
01628                                   iHardwareFree;
01629                   if (iPoolRandFree < 0)
01630                      iRandomExcess = -iPoolRandFree;
01631 
01632                   printf(
01633                      "          used space  %7d MByte, free %7d MByte, %d files stored\n",
01634                      iPoolRandUsed, iHardwareFree,
01635                      ntohl(pPoolInfoData->iFiles));
01636 
01637                   if (iAction == QUERY_POOL)
01638                   {
01639                      if (iRandomExcess > 0)
01640                         printf("       %7d MByte lent from StagePool\n",
01641                                iRandomExcess);
01642                      else if (iHardwareFree > 0)
01643                         printf("       unused space also usable for StagePool\n");
01644                   }
01645 
01646                } /* (iPoolId == iPoolMode) || (iPoolId == 0) */
01647             } /* (iPoolMode == 1) */
01648 
01649             if (iPoolMode == 2)
01650             {
01651                if ( (iPoolId == iPoolMode) || (iPoolId == 0) )
01652                {
01653                   if (iPrintPoolInfo) printf(
01654                      "    %s: used for 'tsmcli stage'\n",
01655                      pPoolInfoData->cPoolName);
01656                   iPoolTempAvail = ntohl(pPoolInfoData->iFileAvail);
01657 
01658                   iPoolTempUsed = ntohl(pPoolInfoData->iMaxSize) -
01659                                   iPoolTempFree;
01660                   if (iPoolTempFree < 0)
01661                      iPoolTempFree = 0;
01662 
01663                   if (iHardwareFree < iPoolTempFree)
01664                      iTempSizeUnavail = iPoolTempFree - iHardwareFree;
01665 
01666                   if ( (iPoolTempFree >= 0) && (iPrintPoolInfo) )
01667                   {
01668                      printf( "          used space  %7d MByte, free %7d MByte, %d files stored\n",
01669                         iPoolTempUsed, iPoolTempFree,
01670                         ntohl(pPoolInfoData->iFiles));
01671                      if (iTempSizeUnavail)
01672                      {
01673                         printf( "       thereof currently %7d MByte free, remainder can be freed\n",
01674                            iHardwareFree);
01675                      }
01676                      else
01677                         if ( (iAction == QUERY_POOL) &&
01678                              (iPoolTempFree > 0) )
01679                            printf("       unused space also usable for RetrievePool\n");
01680                   }
01681                   if (iPrintPoolInfo) printf(
01682                      "       min availability of %d days guaranteed\n",
01683                      ntohl(pPoolInfoData->iFileAvail));
01684 
01685                } /* (iPoolId == iPoolMode) || (iPoolId == 0) */
01686             } /* (iPoolMode == 2) */
01687          } /* (iAction == QUERY_POOL) || (iAction == QUERY_WORKSPACE) */
01688 
01689          if ( (iPoolMode == 2) &&
01690               ((iAction == STAGE) || (iAction == QUERY_WORKSPACE)) )
01691          {
01692             iPoolTempMax = ntohl(pPoolInfoData->iMaxSize);
01693             iPoolTempMaxWS = ntohl(pPoolInfoData->iMaxWorkSize);
01694             iPoolTempCheck = ntohl(pPoolInfoData->iCheckSize);
01695          }
01696 
01697          pPoolInfoData++;
01698 
01699       } /* loop pools */
01700       pPoolInfoData = pPoolInfoData0;              /* 1st pool again */
01701 
01702    } /* (iPoolInfo) */
01703 
01704    /********************* get work space info ************************/
01705 
01706    if (iWorkSpaceInfo)
01707    {
01708       pWorkSpace = (srawWorkSpace *) pcc;
01709       *ppWorkSpace = pWorkSpace;                       /* for caller */
01710 
01711       iRC = rawRecvHead(iSocket, &pcc);
01712       if (iRC <= 0)
01713       {
01714          printf("-E- receiving work space buffer header\n");
01715          return -1;
01716       }
01717       if (iDebug)
01718          printf("-D- header work space buffer received (%d bytes)\n",
01719                 iRC);
01720 
01721       iIdent = ntohl(pWorkSpace->iIdent);
01722       iStatus = ntohl(pWorkSpace->iWorkId);
01723       iAttrLen = ntohl(pWorkSpace->iStatusLen);
01724 
01725       /* expect IDENT_WORKSPACE */
01726       if (iIdent != IDENT_WORKSPACE)
01727       {
01728          if (iIdent == IDENT_STATUS)
01729          {
01730             if ( (iStatus == STA_ERROR) || (iStatus == STA_ERROR_EOF) )
01731             {
01732                if (iDebug) printf("\n");
01733                printf("-E- received error status from server");
01734                if (iDebug)
01735                   printf(" instead of work space info:\n");
01736                else printf(":\n");
01737 
01738                if (iAttrLen > 0)
01739                {
01740                   pcc = (char *) piBuffer;
01741                   iRC = rawRecvError(iSocket, iAttrLen, &pcc);
01742                   if (iRC < 0) printf(
01743                      "-E- receiving error msg from server, rc = %d\n",
01744                      iRC);
01745                   else printf("    %s\n", pcc);
01746                }
01747                else printf("    no error message available\n");
01748 
01749             } /* (iStatus == STA_ERROR) || (iStatus == STA_ERROR_EOF) */
01750             else
01751             {
01752                printf(
01753                   "-E- unexpected status (%d) received from server\n",
01754                   iStatus);
01755             }
01756          } /* iIdent == IDENT_WORKSPACE */
01757          else
01758          {
01759             printf(
01760                "-E- unexpected header (%d) received from server\n",
01761                iIdent);
01762          }
01763 
01764          return -1;
01765 
01766       } /* (iIdent != IDENT_WORKSPACE) ) */
01767 
01768       /* receive work space info */
01769       iBuf = iAttrLen;
01770       pcc += HEAD_LEN;
01771       while(iBuf > 0)
01772       {
01773          if ( (iRC = recv( iSocket, pcc, iBuf, 0 )) < 0 )
01774          {
01775             perror("-E- receiving work space info");
01776             return -1;
01777          }
01778          iBuf -= iRC;
01779          pcc += iRC;
01780       } /* while(iBuf > 0) */
01781 
01782       if (iDebug)
01783          printf("    remainder work space buffer received (%d byte)\n",
01784                 iAttrLen);
01785 
01786       iWorkSizeAll = ntohl(pWorkSpace->iWorkSizeAll);
01787       iWorkFilesAll = ntohl(pWorkSpace->iWorkFilesAll);
01788       iWorkStatus = ntohl(pWorkSpace->iStatus);
01789       iWorkSizeSta = ntohl(pWorkSpace->iWorkSizeSta);
01790       iWorkFilesSta = ntohl(pWorkSpace->iWorkFilesSta);
01791       iWorkSizeStaTemp = ntohl(pWorkSpace->iWorkSizeStaTemp);
01792       iWorkFilesStaTemp = ntohl(pWorkSpace->iWorkFilesStaTemp);
01793       iWorkSizeEst = ntohl(pWorkSpace->iWorkSizeEst);
01794       iWorkFilesEst = ntohl(pWorkSpace->iWorkFilesEst);
01795 
01796       iWorkSizeStaRand = iWorkSizeSta - iWorkSizeStaTemp;
01797       iWorkFilesStaRand = iWorkFilesSta - iWorkFilesStaTemp;
01798 
01799       /* provide infos if stage of large workspace or if ws_query */
01800       if (iPoolInfo || (iAction == QUERY_WORKSPACE) || (iDebug) )
01801       {
01802          if (iDebug)
01803          {
01804             printf("    %d files, overall size %d MByte",
01805                    iWorkFilesAll, iWorkSizeAll);
01806             if (iWorkFilesEst)
01807                printf(", size estimated for %d files (%d MByte)\n",
01808                       iWorkFilesEst, iWorkSizeEst);
01809          }
01810 
01811          if (iWorkSizeSta == iWorkSizeAll)
01812          {
01813             if (iDebug)
01814             {
01815                printf(
01816                   "\n    all files already available on central disk\n");
01817                if ( (iPoolId == 2) &&
01818                     iWorkSizeStaRand &&
01819                     (iAction == QUERY_WORKSPACE) )
01820                   printf(
01821                      "    to get a guaranteed availability of %d days on disk pool use 'tsmcli stage'\n",
01822                      iPoolTempAvail);
01823             }
01824          }
01825          else if (iWorkSizeSta)
01826          {
01827             if (iDebug)
01828             {
01829                printf(
01830                   "\n    %d files already available on central disk (%d MByte)\n",
01831                   iWorkFilesSta, iWorkSizeSta);
01832                if (iWorkFilesStaTemp)
01833                   printf(
01834                      "    %d files already in %s (%d MByte)\n",
01835                      iWorkFilesStaTemp, cPoolNameTemp, iWorkSizeStaTemp);
01836                printf(
01837                   "    %d files still to be staged or currently being staged (%d MByte)\n",
01838                   iWorkFilesAll-iWorkFilesSta,
01839                   iWorkSizeAll - iWorkSizeSta);
01840             }
01841          }
01842          else if (iDebug)
01843             printf(", all to be staged\n");
01844 
01845          /* handle problems or limitations indicated by iWorkStatus:
01846             = 0: needed size ws available
01847             = 1: overall size ws > free size StagePool
01848             = 2: overall size ws > allowed size of ws
01849             = 3: needed size ws > size StagePool
01850             = 9: needed size ws > clean limit, but available: no sleep
01851             =10: needed size ws partially available,
01852                  sleep 10 min before start staging
01853             =20: needed size ws partially available,
01854                  sleep 20 min before start staging
01855          */
01856          if ( (iWorkStatus < 9) && (iWorkStatus != 0) )
01857          {
01858             if (iAction == QUERY_WORKSPACE)
01859                strcpy(cMsgPref, "-W-");
01860             else
01861                strcpy(cMsgPref, "-E-");
01862             printf("%s requested workspace '%s' cannot be staged:\n",
01863                    cMsgPref, pcGenFile);
01864 
01865             if (iWorkStatus < 0)
01866                printf("%s staging disk pool currently unavailable\n",
01867                       cMsgPref);
01868             else if (iWorkStatus == 1)
01869             {
01870                printf("    currently free in %s:   %d MByte\n",
01871                       cPoolNameTemp, iPoolTempFree);
01872                printf(
01873                   "    still needed:                  %d MByte (%d files)\n",
01874                   iWorkSizeAll-iWorkSizeSta,
01875                   iWorkFilesAll-iWorkFilesSta);
01876                if (iAction == QUERY_WORKSPACE)
01877                   printf( "-I- Check later again!\n");
01878                else printf(
01879                   "-I- Query work space status before retrying later!\n");
01880             }
01881             else if ( (iWorkStatus == 2) || (iWorkStatus == 3) )
01882             {
01883                if (iWorkStatus == 2) printf(
01884                   "%s max work space allowed in '%s' is currently limited to %d MByte\n",
01885                   cMsgPref, cPoolNameTemp, iPoolTempMaxWS);
01886                else printf(
01887                   "%s overall size of %s is limited to %d MByte\n",
01888                   cMsgPref, cPoolNameTemp, iPoolTempMax);
01889                printf(
01890                   "-I- Please reduce your work space requirements\n");
01891             }
01892             else if (iWorkStatus < 9)
01893                printf(
01894                   "-E- unexpected workspace status received from server (%d)\n",
01895                   iWorkStatus);
01896 
01897             if (iDebug)
01898                printf("-D- end %s\n\n", cModule);
01899             return -1;
01900 
01901          } /* (iWorkStatus < 9) && (iWorkStatus != 0) */
01902 
01903          if ( (iDebug) && (iWorkSizeSta != iWorkSizeAll) )
01904          {
01905             if (iAction == QUERY_WORKSPACE)
01906             {
01907                iWorkSizeNew = iWorkSizeAll - iWorkSizeSta;
01908                if (iRandomExcess)
01909                {
01910                   if (iWorkSizeNew > iHardwareFree)
01911                   {
01912                      printf("-D- currently unused in %s: %d MByte\n",
01913                             cPoolNameTemp, iPoolTempFree);
01914                      printf("    currently free in %s:   %d MByte, remainder temporarily used by other pools\n",
01915                             cPoolNameTemp, iHardwareFree);
01916                   }
01917                   else
01918                      printf("-D- currently free in %s:   %d MByte\n",
01919                             cPoolNameTemp, iHardwareFree);
01920                }
01921                else
01922                   printf("-D- currently free in %s:   %d MByte\n",
01923                          cPoolNameTemp, iPoolTempFree);
01924                printf(
01925                   "    to get all files on disk pool with a guaranteed availability of %d days:\n",
01926                   iPoolTempAvail);
01927                printf("    -> use 'tsmcli stage'\n");
01928 
01929             } /* (iAction == QUERY_WORKSPACE) */
01930         /*  else
01931                printf("-D- currently free in %s:   %d MByte\n",
01932                       cPoolNameTemp, iPoolTempFree);
01933          */
01934          } /* (iDebug) && (iWorkSizeSta != iWorkSizeAll) */
01935 
01936          /* server set clean request */
01937          if (iWorkStatus >= 9)
01938          {
01939             if (iDebug)
01940             {
01941                /* if (ntohl(pPoolInfoData->iFreeSize) >= 0)
01942                   does not work in Linux:
01943                   negative values are not recognized!            */
01944                ii = ntohl(pPoolInfoData0->iFreeSize);
01945 
01946                printf("-D- currently free (HW): %d MByte\n",
01947                       iHardwareFree);
01948                printf(
01949                   "    currently %d MByte unused in %s are allocated by other pools\n",
01950                   ii*(-1), cPoolNameTemp);
01951             }
01952 
01953             if (iAction == QUERY_WORKSPACE)
01954                strcpy(cMisc, "must be initiated (tsmcli stage)");
01955             else
01956                strcpy(cMisc, "is initiated");
01957             printf(
01958                "-I- a clean job %s to provide the requested space\n",
01959                cMisc);
01960 
01961             if (iWorkStatus > 9)
01962             {
01963                /* iSleepClean = iWorkStatus*60;     */     /* in sec */
01964                iSleepClean = iWorkStatus;
01965            /*  if (iDebug)
01966                   printf("-D- sleep for %ds\n", iSleepClean);
01967                sleep(iSleepClean);
01968             */
01969             }
01970 
01971          } /* (iWorkStatus >= 9) */
01972 
01973       } /* (iPoolInfo) || (iAction == QUERY_WORKSPACE) */
01974    } /* (iWorkSpaceInfo) */
01975 
01976    if (iDebug)
01977       printf("-D- end %s\n\n", cModule);
01978 
01979    return 0;
01980 
01981 } /* rawGetWSInfo */
01982 
01983 /********************************************************************
01984  * rawQueryFile: get query information for single file
01985  *
01986  * used for tape input handled sequentially
01987  * buffers for communication and query info allocated in calling
01988  *    procedure
01989  ********************************************************************
01990  */
01991 
01992 int rawQueryFile( int iSocket,
01993                   srawComm *pCommBuf,
01994                   void **pQueryBuf)
01995 {
01996    int iDebug = 0;
01997    char cModule[32] = "rawQueryFile";
01998    int iRC;
01999    int iIdent, iquery = -1, iAttrLen;
02000    int iStatus, iStatusLen;
02001    int iBuf, iBufComm;
02002    int ii;
02003    char *pc;
02004 
02005    srawComm *pComm;
02006    srawQueryResult *pQuery;
02007    srawObjAttr *pObjAttr;
02008 
02009    pComm = pCommBuf;
02010    pQuery = (srawQueryResult *) (*pQueryBuf);
02011 
02012    iBufComm = ntohl(pComm->iCommLen) + HEAD_LEN;
02013    if (iDebug) printf(
02014       "\n-D- begin %s: query file %s, action %d\n",
02015       cModule, pComm->cNamell, ntohl(pComm->iAction));
02016 
02017    switch( ntohl(pComm->iAction) )
02018    {
02019       case QUERY:
02020       case QUERY_ARCHIVE:
02021       case QUERY_ARCHIVE_RECORD:
02022       case QUERY_ARCHIVE_MGR:
02023       case QUERY_REMOVE:
02024       case QUERY_REMOVE_MGR:
02025       case QUERY_RETRIEVE:
02026       case QUERY_RETRIEVE_API:
02027       case QUERY_STAGE:
02028          ;                          /* okay */
02029          break;
02030       default:
02031          printf("-E- %s: invalid action %d\n",
02032                 cModule, ntohl(pComm->iAction));
02033          return -1;
02034    }
02035 
02036    pc = (char *) pComm;
02037    if ( (iRC = send( iSocket, pc, iBufComm, 0 )) < 0 )
02038    {
02039       printf("-E- %s: query file %s\n", cModule, pComm->cNamell);
02040       perror("    sending command buffer");
02041       return(-1);
02042    }
02043 
02044    if (iDebug) printf(
02045       "    query command sent to server (%d bytes), look for reply\n",
02046       iBufComm);
02047 
02048    /*********** look for reply from server *****************/
02049 
02050 gNextReply:
02051    pc = (char *) pQuery;
02052    iRC = rawRecvHead(iSocket, &pc);
02053    if (iRC <= 0)
02054    {
02055       printf("-E- %s: receiving buffer header with query information\n",
02056              cModule);
02057       return(-1);
02058    }
02059    else if (iDebug)
02060       printf("    %d bytes received\n", iRC);
02061 
02062    pc += HEAD_LEN;
02063    iIdent = ntohl(pQuery->iIdent);
02064    iquery = ntohl(pQuery->iObjCount);
02065    iAttrLen = ntohl(pQuery->iAttrLen);
02066 
02067    if ( (iIdent != IDENT_QUERY) && (iIdent != IDENT_QUERY_ARCHDB) )
02068    {
02069       if (iIdent == IDENT_STATUS)
02070       {
02071          iStatus = iquery;
02072          iStatusLen = iAttrLen;
02073          if ( (iStatus == STA_ERROR) || (iStatus == STA_ERROR_EOF) )
02074          {
02075             if (iDebug)
02076                printf("\n");
02077             printf("-E- %s: received error status from server",
02078                    cModule);
02079             if (iDebug)
02080                printf(" instead of query data:\n");
02081             else
02082                printf(":\n");
02083 
02084             if (iStatusLen > 0)
02085             {
02086                iRC = rawRecvError(iSocket, iStatusLen, &pc);
02087                if (iRC < 0) printf(
02088                   "-E- receiving error msg from server, rc = %d\n",
02089                   iRC);
02090                else printf("    %s\n", pc);
02091             }
02092             else printf("    no error message available\n");
02093 
02094          } /* iStatus == STA_ERROR || (iStatus == STA_ERROR_EOF) */
02095          else printf(
02096            "-E- %s: unexpected status (type %d) received from server\n",
02097            cModule, iStatus);
02098 
02099       } /* iIdent == IDENT_STATUS */
02100       else printf(
02101          "-E- %s: unexpected header (type %d) received from server\n",
02102          cModule, iIdent);
02103 
02104       return(-1);
02105 
02106    } /* iIdent != IDENT_QUERY  && != IDENT_QUERY_ARCHDB */
02107 
02108    if (iquery > 0)
02109    {
02110       for (ii=1; ii<=iquery; ii++)
02111       {
02112          pc = (char *) pQuery + HEAD_LEN;
02113          pObjAttr = (srawObjAttr *) pc;
02114          iBuf = iAttrLen;        /* only space for one object buffer */
02115          while(iBuf > 0)
02116          {
02117             if ( (iRC = recv( iSocket, pc, iBuf, 0 )) < 0 )
02118             {
02119                printf("-E- %s: receiving object buffer\n", cModule);
02120                perror("-E- receiving query results");
02121                return -1;
02122             }
02123             iBuf -= iRC;
02124             pc += iRC;
02125          } /* while(iBuf > 0) */
02126 
02127          if (iDebug)
02128          {
02129             if (ii == 1) printf(
02130                "    query buffer received (%d bytes)\n", iAttrLen);
02131             else printf(
02132                "    query buffer overlaid (%d bytes)\n", iAttrLen);
02133             printf("    cNamell %s, iObjLow %d",
02134                    pObjAttr->cNamell, ntohl(pObjAttr->iObjLow));
02135             if (iIdent == IDENT_QUERY)
02136                printf(" (TSM DB)\n");
02137             else
02138                printf(" (ArchivePool)\n");
02139          }
02140       } /* object loop */
02141    } /* (iquery > 0) */
02142    else if (iIdent == IDENT_QUERY)        /* nothing found in TSM DB */
02143          goto gNextReply;                   /* check for ArchivePool */
02144 
02145    switch (iquery)
02146    {
02147       case 0:
02148          if (iDebug)
02149             printf("    no matching object %s found\n", pComm->cNamell);
02150          break;
02151       case 1:
02152          if (iDebug)
02153             printf("    file %s already archived\n", pComm->cNamell);
02154          break;
02155       default:
02156          if ( (iquery > 1) && (strcmp(pComm->cOwner, "goeri") == 0) )
02157             printf("-W- %d versions of %s exist!\n",
02158                    iquery, pComm->cNamell);
02159          else
02160          {
02161             printf("-E- %s: invalid number %d of objects %s found\n",
02162                    cModule, iquery, pComm->cNamell);
02163             iquery = -1;
02164          }
02165    } /* switch (iquery) */
02166 
02167    if (iDebug) printf(
02168       "-D- end %s\n\n", cModule);
02169 
02170    return iquery;
02171 
02172 } /* end rawQueryFile */
02173 
02174 /********************************************************************
02175  * rawQueryList: get query information from list of files
02176  *
02177  * created 21. 2.2001 by Horst Goeringer
02178  ********************************************************************
02179  */
02180 
02181 int rawQueryList( int iSocket,
02182     char *pFile,                       /* generic name of file list */
02183     int iFilenoReq,          /* no. of requ. file (1 .. n), init: 0 */
02184     int iFull,                                   /* verbosity level */
02185     char *pInfo) /* query info of requested file (init: first file) */
02186 {
02187    int iDebug = 0;
02188    char cModule[32] = "rawQueryList";
02189    int iRC;
02190    int iIdent;
02191    int iAttrLen;
02192 
02193    int iFileno;                               /* no. of files found */
02194    int iquery = -1;         /* no. of files in current query buffer */
02195    int iqueryBuf = 0;              /* no. of query buffers received */
02196 
02197    int iBuffer;                       /* size query buffer in bytes */
02198 
02199    int iStatus, iStatusLen;
02200    int iBuf, iBufComm;
02201 
02202    int ii;
02203    char *pcc;
02204    bool_t bQDone = bFalse;
02205 
02206    char cNamefs[MAX_OBJ_FS] = "", *pcNamefs;      /* filespace name */
02207    char cNamehl[MAX_OBJ_HL] = "", *pcNamehl;     /* high level name */
02208    char cNamell[MAX_OBJ_LL] = "", *pcNamell;     /* low  level name */
02209 
02210    char cOwner[DSM_MAX_OWNER_LENGTH] = "";
02211    char cliNode[MAX_NODE] = "";
02212 
02213    int iCommSize = sizeof(srawComm); /* client/server communication */
02214    srawComm *pComm, sComm;
02215 
02216    pComm = &sComm;
02217 
02218    pcNamefs = cNamefs;
02219    pcNamehl = cNamehl;
02220    pcNamell = cNamell;
02221 
02222    if (iDebug)
02223       printf("\n-D- this is %s\n", cModule);
02224 
02225    pComm->iIdent = htonl(IDENT_COMM);
02226    pComm->iAction = htonl(QUERY);
02227    pComm->iCommLen = htonl(iCommSize - HEAD_LEN);
02228    pComm->iBufsizeFile = htonl(0);
02229 
02230    /******************** allocate query buffer **********************/
02231 
02232    if (iFilenoReq > 0)
02233    {
02234       if (pQueryBuffer == 0)
02235       {
02236          printf("-W- assume initial call for file list %s\n", pFile);
02237          iFilenoReq = 0;
02238       }
02239    }
02240 
02241    if (iFilenoReq <= 0)
02242    {
02243       iBuffer = MBUF_SOCK;
02244       iqueryMax = (iBuffer - HEAD_LEN)/sizeof(srawObjAttr);
02245       /* iqueryMax = 3;        DDD must be synchronized with server */
02246 
02247       if ( (pQueryBuffer =
02248            (char *) calloc(iBuffer, sizeof(char))) == NULL )
02249       {
02250          perror("-E- allocating data buffer");
02251          printf("-E- allocating data buffer (size %d)\n", iBuffer);
02252          return 1;
02253       }
02254       if (iDebug)
02255       {
02256          printf("-D- data buffer allocated (size %d)\n", iBuffer);
02257          printf("    max %d queries per buffer\n", iqueryMax);
02258       }
02259       pQueryResult = (srawQueryResult *) pQueryBuffer;
02260       pQueryObj = &(pQueryResult->objAttr);
02261       pQueryObj0 = pQueryObj;  /* keep ptr to attributes first file */
02262 
02263    } /* iFilenoReq <= 0 */
02264    else
02265    {
02266       if (iFilenoReq > iqueryMax)
02267       {
02268          printf("-E- max %d file infos kept, please restrict your filelist %s\n",
02269                 iqueryMax, pFile);
02270          return -9;
02271       }
02272 
02273       pQueryObj = pQueryObj0;   /* set ptr to attributes first file */
02274       for (ii=1; ii<iFilenoReq; ii++)
02275       {
02276          pQueryObj++;
02277       }
02278 
02279       iRC = rawQueryString(pQueryObj, iFull, pInfo);
02280       if (iDebug) printf(
02281          "-D- requested file no %d found:\n    %s", iFilenoReq, pInfo);
02282       goto gDone;
02283    }
02284 
02285    /******************** get ADSM representation ********************/
02286 
02287    strcpy(pcNamefs, pFile);
02288    pcc = (char *) strchr(pcNamefs, *pcObjDelim);
02289    if (pcc == NULL)
02290    {
02291       printf("-E- invalid remote file name '%s'\n", pFile);
02292       return -1;
02293    }
02294 
02295    if (strncmp(pcc, pFile, 1) == 0)      /* skip leading delimiter */
02296       pcc++;
02297    pcc = (char *) strchr(pcc, *pcObjDelim);
02298    if (pcc == NULL)
02299    {
02300       printf("-E- invalid remote file name '%s'\n", pFile);
02301       return -1;
02302    }
02303    strcpy(pcNamehl, pcc);     /* starts with high level object name */
02304    strncpy(pcc, "\0", 1);                     /* terminates FS name */
02305 
02306    pcc = pcNamehl;
02307    pcc++;                                 /* skip leading delimiter */
02308    pcc = (char *) strrchr(pcc, *pcObjDelim);
02309    if (pcc == NULL)
02310    {
02311       printf("-E- invalid remote file name '%s'\n", pFile);
02312       return -1;
02313    }
02314    strcpy(pcNamell, pcc);      /* starts with low level object name */
02315    strncpy(pcc, "\0", 1);      /* terminates high level object name */
02316 
02317    if (iDebug)
02318       printf("    FS name '%s', HL name '%s', LL name '%s'\n",
02319              pcNamefs, pcNamehl, pcNamell);
02320 
02321    strcpy(pComm->cNamefs, (char *) rawGetFSName(pcNamefs));
02322    if (strlen(pComm->cNamefs) == 0)
02323       return -1;
02324 
02325    strcpy(pComm->cNamehl, (char *) rawGetHLName(pcNamehl));
02326    /* strcpy(pComm->cNamell, (char *) rawGetLLName(pcNamell)); */
02327    iRC = rawGetLLName(pcNamell, pcObjDelim, pComm->cNamell);
02328 
02329    if (iDebug)
02330       printf("    FS name '%s', HL name '%s', LL name '%s'\n",
02331              pComm->cNamefs, pComm->cNamehl, pComm->cNamell);
02332 
02333    /***************** get client info, contact server ***************/
02334 
02335    strcpy(cOwner, (char *) rawGetUserid());
02336    iRC = gethostname(cliNode, MAX_NODE);
02337    if (iRC)
02338    {
02339       printf("-E- getting client host name: %s\n", strerror(iRC));
02340       return -1;
02341    }
02342 
02343    if (iDebug)
02344       printf("    user %s on node %s, platform %s\n",
02345              cOwner, cliNode, cOS);            /* cOS from rawcli.h */
02346 
02347    strcpy(pComm->cApplType, cApplType);
02348    strcpy(pComm->cOwner,  cOwner);
02349    strcpy(pComm->cliNode, cliNode);
02350    strcpy(pComm->cOS, cOS);
02351 
02352    pcc = (char *) pComm;
02353    if ( (iRC = send( iSocket, pcc, iCommSize, 0 )) < 0 )
02354    {
02355       printf("-E- %s: query file %s\n", cModule, pComm->cNamell);
02356       perror("    sending command buffer");
02357       return -1;
02358    }
02359 
02360    if (iDebug) printf(
02361       "-D- query command sent to server (%d bytes), look for reply\n",
02362       iCommSize);
02363 
02364    /******************** look for reply from server *****************/
02365 
02366    while (!bQDone)                       /* loop over query buffers */
02367    {
02368       pcc = (char *) pQueryResult;
02369       iRC = rawRecvHead(iSocket, &pcc);
02370       if (iRC <= 0)
02371       {
02372          printf("-E- receiving buffer header with query information\n");
02373          return(-1);
02374       }
02375       else if (iDebug > 0) printf("    %d bytes received\n", iRC);
02376 
02377       pcc += HEAD_LEN;
02378       iIdent = ntohl(pQueryResult->iIdent);
02379       iquery = ntohl(pQueryResult->iObjCount);
02380       iAttrLen = ntohl(pQueryResult->iAttrLen);
02381 
02382       if (iIdent != IDENT_QUERY)
02383       {
02384          if (iIdent == IDENT_STATUS)
02385          {
02386             iStatus = iquery;
02387             iStatusLen = iAttrLen;
02388             if ( (iStatus == STA_ERROR) || (iStatus == STA_ERROR_EOF) )
02389             {
02390                if (iDebug) printf("\n");
02391                printf("-E- received error status from server");
02392                if (iDebug)
02393                   printf(" instead of query data:\n");
02394                else printf(":\n");
02395 
02396                if (iStatusLen > 0)
02397                {
02398                   iRC = rawRecvError(iSocket, iStatusLen, &pcc);
02399                   if (iRC < 0) printf(
02400                      "-E- receiving error msg from server, rc = %d\n",
02401                      iRC);
02402                   else printf("    %s\n", pcc);
02403                }
02404                else printf("    no error message available\n");
02405 
02406             } /* iStatus == STA_ERROR || (iStatus == STA_ERROR_EOF) */
02407             else printf(
02408               "-E- unexpected status (type %d) received from server\n",
02409               iStatus);
02410 
02411          } /* iIdent == IDENT_STATUS */
02412          else printf(
02413             "-E- unexpected header (type %d) received from server\n",
02414             iIdent);
02415 
02416          return -1;
02417 
02418       } /* iIdent != IDENT_QUERY */
02419 
02420       if (iquery == 0)
02421       {
02422          bQDone = bTrue;
02423          if (iQueryCount == 0)
02424             printf("-I- no matching objects found\n");
02425          else
02426             if (iDebug) printf("    no more objects\n");
02427 
02428       } /* (iquery == 0) */
02429       else
02430       {
02431          iBuf = iquery*iAttrLen;
02432          iBufComm = iBuf;
02433          while(iBuf > 0)
02434          {
02435             if ( (iRC = recv( iSocket, pcc, iBuf, 0 )) < 0 )
02436             {
02437                perror("-E- receiving query results");
02438                return -1;
02439             }
02440             iBuf -= iRC;
02441             pcc += iRC;
02442          } /* while(iBuf > 0) */
02443 
02444          iqueryBuf++;
02445 
02446          if (iDebug) printf(
02447             "*** query buffer %d (%d bytes): %d objects\n",
02448                             iqueryBuf, iBufComm, iquery);
02449 
02450          if (iquery < iqueryMax)
02451          {
02452             bQDone = bTrue;
02453             if (iDebug)
02454                printf("    query finished\n");
02455          }
02456          else if (iDebug)
02457             printf("    possibly more query buffers outstanding\n");
02458 
02459          /************** handle buffer with query results ************/
02460 
02461          /* loop over objects of current query buffer */
02462          pQueryObj = pQueryObj0; /* set ptr to first object in buffer */
02463          for (ii=1; ii<=iquery; ii++)
02464          {
02465             iQueryCount++;                  /* no. of current object */
02466             if (iDebug)
02467             {
02468                iRC = rawQueryString(pQueryObj, iFull, pInfo);
02469                printf("%d: %s", iQueryCount, pInfo);
02470             }
02471             pQueryObj++;                /* points now to next object */
02472 
02473          } /* loop over objects of current query buffer */
02474       } /* (iquery > 0) */
02475 
02476    } /* while (!bQDone) */
02477 
02478 gDone:
02479    if (iDebug)
02480    {
02481       if (iFilenoReq == 0)
02482          printf("-D- %d matching objects %s%s%s found\n",
02483                 iQueryCount,
02484                 pComm->cNamefs,
02485                 pComm->cNamehl,
02486                 pComm->cNamell);
02487 
02488       printf("-D- end %s\n\n", cModule);
02489    }
02490 
02491    if ( (iQueryCount) && (iFilenoReq == 0) )
02492       iRC = rawQueryString(pQueryObj0, iFull, pInfo);
02493 
02494    return iQueryCount;
02495 
02496 } /* end rawQueryList */
02497 
02498 /**********************************************************************
02499  * rawScanObjbuf:
02500  *   check if obj already available in obj buffer chain
02501  * created 10. 7.2003 by Horst Goeringer
02502  **********************************************************************
02503  */
02504 
02505 int rawScanObjbuf(char *pcFile, int iObjnoMax, int *piObjBuf0)
02506 {
02507    int iDebug = 0;
02508    char cModule[32] = "rawScanObjbuf";
02509    int ii, jj = 0;
02510    int iFound = 0;   /* =1: specified file already available in list */
02511    int iObjnoBuf;                /* no. of objects in current buffer */
02512    int iObjnoAll = 0;               /* sum of objects in all buffers */
02513    int iBufno = 0;                          /* no. of object buffers */
02514    int *piObjBuf;                    /* ptr to current object buffer */
02515    int **ppiNextBuf;
02516 
02517    srawRetrList *psRetrList;     /* points to object in buffer chain */
02518 
02519    if (iDebug)
02520       printf("\n-D- begin %s: check for %s\n", cModule, pcFile);
02521 
02522    piObjBuf = piObjBuf0;
02523    /* loop over object buffers */
02524    for (;;)
02525    {
02526       iObjnoBuf = *piObjBuf;
02527       psRetrList = (srawRetrList *) &(piObjBuf[1]);
02528       iBufno++;
02529 
02530       /* loop over objects in current buffer */
02531       for (ii=1; ii<=iObjnoBuf; ii++)
02532       {
02533          jj++;
02534          if (iDebug == 2)
02535             printf("    %d: %s\n", jj, psRetrList->cNamell);
02536 
02537          if (strcmp(pcFile, psRetrList->cNamell) == 0)
02538          {
02539             if (iDebug) printf(
02540                "    file %s already available in list\n", pcFile);
02541             iFound = 1;
02542             goto gEndScan;
02543          }
02544 
02545          psRetrList++;
02546 
02547       } /* loop over objects in current buffer */
02548 
02549       if (iObjnoBuf < iObjnoMax)                      /* last buffer */
02550          break;
02551 
02552       if (psRetrList)
02553       {
02554          ppiNextBuf = (int **) psRetrList;
02555          piObjBuf = *ppiNextBuf;
02556          psRetrList = (srawRetrList *) &(piObjBuf[1]);
02557       }
02558       else                                            /* last buffer */
02559          break;
02560 
02561    } /* loop over buffers */
02562 
02563 gEndScan:
02564    if (iDebug)
02565       printf("-D- end %s: %d buffers scanned\n\n", cModule, iBufno);
02566 
02567    if (iFound)
02568       return 1;
02569    else
02570       return 0;
02571 
02572 } /* end rawScanObjbuf */
02573 
02574 #ifdef _AIX
02575 /*********************************************************************
02576  * ielpst: Elapsed (wall-clock) time measurement
02577  *
02578  *    Usage examples:
02579  *
02580  *  ielpst( 1, iBuf[0..1] );
02581  *  ... code ...
02582  *  ElapsedTime(in microsecs) = ielpst( 1, iBuf[0..1] );
02583  *
02584  *  ielpst( 1000, iBuf[0..1] );
02585  *  ... code ...
02586  *  ElapsedTime(in millisecs) = ielpst( 1000, iBuf[0..1] );
02587  *
02588  *********************************************************************
02589  * created 17.11.1992, Michael Kraemer
02590  *********************************************************************
02591  */
02592 
02593 unsigned long ielpst( unsigned long iScale,
02594                       unsigned long *iBuf )
02595 {
02596    int iDebug = 0;
02597    char cModule[32] = "ielpst";
02598    struct timestruc_t stv;
02599    unsigned long iTemp[2];
02600 
02601    gettimer( TIMEOFDAY, &stv );
02602 
02603    if ( iScale <= 0 ) iScale = 1;
02604    iTemp[1] = stv.tv_sec  - iBuf[1];
02605    if ( ( iTemp[0] = stv.tv_nsec - iBuf[0] ) & 0x80000000 ) {
02606       iTemp[0] += 1000000000L; iTemp[1] -= 1;
02607    }
02608    iBuf[1] = stv.tv_sec; iBuf[0] = stv.tv_nsec;
02609    return( iTemp[1] * ( 1000000L / iScale ) + ( iTemp[0] / 1000 ) / iScale );
02610 
02611 } /* ielpst */
02612 
02613 /* FORTRAN entry */
02614 unsigned long ielpst_( unsigned long *iScale,
02615                        unsigned long *iBuf )
02616 {
02617    return( ielpst( *iScale, iBuf ) );
02618 } /* ielpst_ */
02619 #endif
02620 
02621 
02622 //----------------------------END OF GO4 SOURCE FILE ---------------------

Generated on Fri Nov 28 12:59:34 2008 for Go4-v3.04-1 by  doxygen 1.4.2