DABC (Data Acquisition Backbone Core)  2.9.9
rawProcn.c
Go to the documentation of this file.
1 /**********************************************************************
2  * Copyright:
3  * GSI, Gesellschaft fuer Schwerionenforschung mbH
4  * Planckstr. 1
5  * D-64291 Darmstadt
6  * Germany
7  * created 14. 2.1996, Horst Goeringer
8  **********************************************************************
9  * rawProcn.c
10  * utility programs for gStore package: client and server
11  **********************************************************************
12  * rawAddStrings: add 2 messages avoiding overflows
13  * rawCheckClientFile: check gStore naming conventions for client file
14  * rawDelFile: delete single file in GSI mass storage
15  * rawDelList: delete list of files in GSI mass storage
16  * rawGetFSpName: get file space name from user specification
17  * rawGetHLName: get high level object name from path
18  * rawGetLLName: get low level object name from file name
19  * rawGetFileSize: get file size (byte) via Posix call stat
20  * rawGetPathName: get path name from high level object name
21  * rawQueryFile: get query information for single file
22  * rawRecvError: receive error message
23  * rawRecvHead: receive common buffer header
24  * rawRecvHeadC: receive common buffer header and check
25  * rawRecvRequest: receive request for next buffer
26  * rawRecvStatus: receive status buffer
27  * rawSendRequest: send request for next buffer
28  * rawSendStatus: send status buffer
29  * rawTestFileName: verify that specified name is a valid file name
30  **********************************************************************
31  * 23. 4.1996., H.G: rawGetHLName: remove device dependency in hl-name,
32  * as in ADSM 213 class may be set in dsmSendObj
33  * 16. 5.1997, H.G.: keep only modules for all clients here
34  * 16. 6.1997, H.G.: ported to Linux
35  * 15.10.1997, H.G.: rawCheckAuth moved to rawCheckAuth.c
36  * 22.10.1997, H.G.: rawDelFilelist added
37  * 8. 7.1998, H.G.: new filetype STREAM
38  * 19.10.1998, H.G.: rawapitd.h introduced, dsmapitd.h removed
39  * 1.12.2000, H.G.: rawSendStatus: send also buffer request headers
40  * 7. 2.2001, H.G.: new function rawQueryString
41  * 21. 2.2001, H.G.: renamed file rawQueryFile.c -> rawProcQuery.c
42  * function rawQueryList added
43  * 18. 5.2001, H.G.: function rawDelFilelist -> rawcliproc.c
44  * merge into new file rawcliproc.c: rawProcQuery.c
45  * 18. 6.2001, H.G.: function rawTestFile: renamed to rawTestFileName,
46  * handle mixed case
47  * 2.11.2001, H.G.: ported to W2000
48  * 14.11.2001, H.G.: take alternate delimiter for Windows into account
49  * 9. 1.2002, H.G.: rawGetLLName: pass object and delimiter as argument
50  * 19. 2.2002, H.G.: rawGetFileSize added
51  * 20. 2.2002, H.G.: rawGetCmdParms removed (unused)
52  * 7. 3.2002, H.G.: rawQueryPrint: new type GSI_MEDIA_INCOMPLETE
53  * rawRecvHeadC added
54  * 7. 6.2002, H.G.: rawRecvHeadC: check always for error status
55  * 23. 7.2002, H.G.: replace old printf() -> fprintf(fLogFile)
56  * 5. 8.2002, H.G.: rawQueryFile: handle QUERY_RETRIEVE, QUERY_STAGE
57  * 14.10.2002, H.G.: ported to Lynx
58  * 31. 1.2003, H.G.: use rawdefn.h
59  * 17. 2.2003, H.G.: rawCheckFileList, rawCheckObjList -> rawcliprocn.c
60  * 3. 6.2003, H.G.: renamed from rawprocn to rawProcn
61  * 9. 7.2003, H.G.: rawTestFileName: call rawGetFileSize to identify
62  * directories
63  * 13. 8.2003, H.G.: rawQueryPrint: add user who staged file in output
64  * 5.12.2003, H.G.: rawRecvStatus: convert status header to host format
65  * 28. 1.2004, H.G.: GSI_MEDIA_CACHE: rawQueryPrint, rawQueryString
66  * GSI_MEDIA_INCOMPLETE: in rawQueryString
67  * 26. 5.2004, H.G.: rawQueryPrint, rawQueryString: new print modes:
68  * stage status not checked
69  * 29. 6.2004, H.G.: rawRecvHeadC: recv error msg, if write cache full
70  * 24.11.2004, H.G.: rawQueryFile: handle status values
71  * STA_NO_ACCESS, STA_ARCHIVE_NOT_AVAIL
72  * 25. 1.2005, H.G.: use rawapitd-gsin.h, new media names:
73  * GSI_..._LOCKED, GSI_..._INCOMPLETE
74  * 1. 2.2005, H.G.: ported to Linux and gcc322
75  * 25.11.2005, H.G.: rename rawGetFSName to rawGetFSpName (file space),
76  * rawGetFSName in rawProcPooln (get file system name)
77  * 3. 4.2006, H.G.: ported to sarge
78  * 29. 9.2006, H.G.: rawQueryPrint: handle ATL server
79  * 4.10.2006, H.G.: rawQueryPrint: handle cacheDB entry V4
80  * 2.11.2006, H.G.: rawQueryString: handle ATL server, cacheDB entry V4
81  * 8.12.2006, H.G.: rawQueryFile: handle query on several ATL Servers
82  * 8. 5.2008, H.G.: rawGetFullFile: move -> rawCliProcn.c
83  * rawQueryFile: moved from rawCliProcn.c, repl printf
84  * rawQueryList: moved from rawCliProcn.c, repl printf
85  * 16. 5.2008, H.G.: rawGetHLName: remove './' and trailing '/.' in path
86  * 28. 8.2008, H.G.: rawQueryPrint, rawQueryString:
87  * remove ATL server no. in query output
88  * 6.10.2008, H.G.: replace perror by strerr(errno), improve msgs
89  * rawRecvRequest: better handling rc=0 from recv()
90  * 30.10.2008, H.G.: rawQueryFile,rawQueryList: better: rc=0 from recv()
91  * 5.11.2008, H.G.: rawRecvError: better handling rc=0 from recv()
92  * arg 3: char ** -> char *
93  * rawRecvHead: better handling rc=0 from recv()
94  * arg 3: char ** -> char *
95  * rawRecvStatus: better handling rc=0 from recv()
96  * arg 3: char ** -> char *
97  * 11.11.2008, H.G.: add suggestions of Hakan
98  * 3.12.2008, H.G.: add suggestions of Hakan, part II
99  * 12.12.2008, H.G.: handle CUR_QUERY_LIMIT
100  * 4. 5.2009, H.G.: rawRecvHeadC: improve debug output
101  * 7. 5.2009, H.G.: new entry rawAddStrings
102  * 22. 6.2008, H.G.: replace long->int if 64bit client (ifdef SYSTEM64)
103  * 8. 7.2008, H.G.: rawQueryPrint/String: print filesize with %10d
104  * 23.11.2009, H.G.: rawTestFileName: inhibit '*', '?' as file name part
105  * 10.12.2009, H.G.: rawQueryFile, rawQueryPrint, rawQueryString:
106  * handle enhanced structure srawObjAttr
107  * old version info also available in new structure
108  * rawQueryList not upgraded, obviously unused???
109  * 29. 1.2010, H.G.: replace MAX_FILE -> MAX_FULL_FILE in:
110  * static string cPath,
111  * rawTestFilePath: cTemp
112  * enhance cMsg: 256 -> STATUS_LEN in:
113  * rawRecvHeadC, rawRecvRequest
114  * 5. 2.2010, H.G.: move rawQueryPrint,rawQueryString -> rawCliProcn.c
115  * move rawQueryList -> Unused.c
116  * 11. 2.2010, H.G.: rename rawTestFilePath -> rawCheckClientFile
117  * rawCheckClientFile: all checks of local file name
118  * concerning gStore conventions are done here
119  * 3. 5.2010, H.G.: rawGetFileSize: specific error msg if filesize>2GB
120  * 23. 8.2010, H.G.: rawGetFileSize, rawTestFileName:
121  * remove SYSTEM64, allow "long"
122  * 5.11.2010, H.G.: reset errno after error,
123  * better error handling after recv/send
124  * 18.11.2010, H.G.: rawRecvError: provide also incomplete msg
125  * 25.08.2011, H.G.: rawRecv..., some broken connections: -E- -> -W-
126  * 5.09.2011, H.G.: rawCheckClientFile: allow wildcard chars in dirname
127  * 1.12.2011, H.G.: rawGetFileSize: better msg handling
128  * 24.12.2012, H.G.: rawQueryFile: enable query with variable hl
129  * 4.12.2013, H.G.: rawRecvStatus: modify last arg to 'srawStatus *'
130  * 23. 1.2014, H.G.: rawQueryFile: handle broken connection to master
131  * 29. 1.2014, H.G.: rawCheckClientFile: adapted arg types, better names
132  * 12. 9.2014, H.G.: rawDelFile, rawDelList: added from rawCliProcn.c,
133  * as also needed on DMs for ARCHIVE_OVER from lustre
134  * 15. 9.2014, H.G.: rawDelFile, rawDelList: replace old printf()
135  * -> fprintf(fLogFile)
136  * rawQueryFile: provide storage info (for rawDelFile)
137  * 20.11.2014, H.G.: rawQueryFile: improve checks for file meta data
138  * consistency
139  * 9. 1.2015, H.G.: rawQueryFile: correct handling of WC files
140  * staged in GRC
141  **********************************************************************
142  */
143 
144 #include <stdio.h>
145 #include <string.h>
146 #include <errno.h>
147 
148 #ifdef WIN32 /* Windows */
149 #include <sys\types.h>
150 #include <winsock.h>
151 #include <windows.h>
152 #include <process.h>
153 #include <sys\stat.h>
154 #else /* all Unix */
155 #include <sys/stat.h>
156 #include <ctype.h>
157 #include <stdlib.h>
158 #include <unistd.h>
159 #include <netinet/in.h>
160 
161 #ifdef Lynx /* Lynx */
162 #include <sys/types.h>
163 #include <socket.h>
164 #elif Linux /* Linux */
165 #include <sys/socket.h>
166 #else /* AIX */
167 #include <sys/socket.h>
168 #endif
169 
170 #endif /* all Unix */
171 
172 #include "rawapitd.h"
173 #include "rawapitd-gsin.h"
174 #include "rawcommn.h"
175 #include "rawdefn.h"
176 #include "rawclin.h"
177 #include "rawentn.h"
178 #include "rawapplcli.h"
179 
180 extern FILE *fLogFile;
181 
182 static char cPath[MAX_FULL_FILE] = "";
183 static char cNamefs[MAX_OBJ_FS] = "";
184 static char cNamehl[MAX_OBJ_HL] = "";
185 static char *pcNull = (char *) "";/* to be returned in case of error */
186  /* return(NULL) works in AIX, but not in VMS */
187 
188 static int iObjAttr = sizeof(srawObjAttr);
189 static int ichar = sizeof(char);
190 
191 /*********************************************************************
192  * rawAddStrings
193  * add 2 messages avoiding string overflows
194  * created 7.5.2009, Horst Goeringer
195  *********************************************************************
196  */
197 
198 int rawAddStrings(char *pcMsg1, /* 1st string, always complete */
199  int iMaxLength1, /* max length of string1 */
200  char *pcMsg2, /* added string, possibly cut */
201  int iMaxLength2, /* max length of string2 */
202  int iErrno, /* = 0: add contents of string2
203  > 0: add system error msg (errno) */
204  char *pcMsgE, /* error msg in case of problem */
205  int iMaxLengthE) /* max length of error string */
206 {
207  char cModule[32]="rawAddStrings";
208  int iDebug = 0;
209 
210  int iRC = 0; /* = 0: okay
211  < 0: problem:
212  =-1: specified string too large
213  =-2: string without contents provided
214  =-3: max length <=0 provided
215  =-4: iErrno, but string2 < STATUS_LEN byte
216  =-5: error string < STATUS_LEN byte provided
217  > 0: no. of chars cut from the 2nd string */
218  int iString1 = 0;
219  int iString2 = 0;
220  int iStringE = 0;
221  int iString = 0; /* sum of string1 + string2 */
222  int iMinLen = STATUS_LEN; /* for pcMsgE, if needed */
223  char cMsg[STATUS_LEN] = ""; /* internal copy */
224  char *pcc;
225 
226  iString1 = strlen(pcMsg1);
227  iString2 = strlen(pcMsg2);
228  iString = iString1 + iString2;
229 
230  if (iDebug)
231  {
232  fprintf(fLogFile, "\n-D- begin %s\n", cModule);
233  fprintf(fLogFile, " string1 (%d byte, max %d byte):\n %s",
234  iString1, iMaxLength1, pcMsg1);
235  if (iErrno)
236  fprintf(fLogFile, " add msg for errno=%d\n", errno);
237  else
238  fprintf(fLogFile, " add string2 (%d byte, max %d byte):\n %s",
239  iString2, iMaxLength2, pcMsg2);
240  }
241 
242  if ( (iString1 <= iMaxLength1) &&
243  (iString2 <= iMaxLength2) )
244  {
245  if (iErrno)
246  {
247  if (iMaxLength2 >= iMinLen)
248  {
249  sprintf(pcMsg2, " %s\n", strerror(errno));
250  iString2 = strlen(pcMsg2);
251  iString = iString1 + iString2;
252  }
253  else
254  {
255  iRC = -4;
256  sprintf(cMsg,
257  "-E- %s: 2nd string (%d byte) possibly too small for system error: requ. %d byte\n",
258  cModule, iMaxLength2, iMinLen);
259 
260  goto gErrorMsg;
261  }
262  } /* (iErrno) */
263 
264  if (iString < iMaxLength1)
265  {
266  strcat(pcMsg1, pcMsg2);
267  if (iDebug) fprintf(fLogFile,
268  " returned msg (%d byte):\n %s", iString, pcMsg1);
269  }
270  else
271  {
272  strncat(pcMsg1, pcMsg2, iMaxLength1-iString1-1);
273  strncat(pcMsg1, "\n", 1);
274  iRC = iString -iMaxLength1;
275  if (iDebug)
276  {
277  fprintf(fLogFile, " returned msg:\n %s", pcMsg1);
278  pcc = pcMsg2;
279  pcc+= iMaxLength1-iString1-1;
280  fprintf(fLogFile, " skipped msg part:\n %s", pcc);
281  }
282  }
283  }
284  else
285  {
286  if (iMaxLength1 <= 0)
287  {
288  iRC = -3;
289  sprintf(cMsg, "-E- %s: 1st string length (%d byte) invalid\n",
290  cModule, iMaxLength1);
291  }
292  if (iMaxLength2 <= 0)
293  {
294  iRC = -3;
295  sprintf(cMsg, "-E- %s: 2nd string length (%d byte) invalid\n",
296  cModule, iMaxLength2);
297  }
298  else if (iString == 0)
299  {
300  iRC = -2;
301  sprintf(cMsg, "-E- %s: empty strings provided\n", cModule);
302  }
303  else if (iString1 > iMaxLength1)
304  {
305  iRC = -1;
306  sprintf(cMsg, "-E- %s: 1st string longer (%d byte) than length provided (%d)\n",
307  cModule, iString1, iMaxLength1);
308  }
309  else if ( (iString2 > iMaxLength2) && (iErrno == 0) )
310  {
311  iRC = -1;
312  sprintf(cMsg, "-E- %s: 2nd string longer (%d byte) than length provided (%d)\n",
313  cModule, iString2, iMaxLength2);
314  }
315  }
316 
317  if (iRC >= 0)
318  {
319  strcpy(pcMsgE, "");
320  goto gEndAddStrings;
321  }
322 
323 gErrorMsg:
324  iStringE = strlen(cMsg);
325  if (iDebug) fprintf(fLogFile,
326  " error string (%d byte, max %d byte):\n %s\n",
327  iStringE, iMaxLengthE, cMsg);
328 
329  if (iMaxLengthE < iStringE)
330  {
331  iRC = -5;
332  fprintf(fLogFile, "-E- %s: size error string too small: max %d byte (needed %d)",
333  cModule, iMaxLengthE, iStringE);
334  strncat(pcMsgE, cMsg, iMaxLengthE);
335  fprintf(fLogFile, ", provided: %s\n", pcMsgE);
336  }
337  else
338  {
339  if (iDebug)
340  fprintf(fLogFile, "%s", cMsg);
341  strcpy(pcMsgE, cMsg);
342  }
343 
344 gEndAddStrings:
345  if (iDebug)
346  fprintf(fLogFile, "-D- end %s: rc=%d\n\n", cModule, iRC);
347 
348  return iRC;
349 
350 } /* rawAddStrings */
351 
352 /********************************************************************
353  * rawCheckClientFile:
354  * check client file name for gStore naming conventions
355  * verify that file path not generic
356  * if tape specified get tape drive name
357  * returns 0 if valid disk file name
358  * returns >0 if valid tape file name
359  *
360  * created 15. 3.96, Horst Goeringer
361  ********************************************************************
362  */
363 
365  char *pcFullFile, char *pcFile, char *pcTape)
366 {
367 
368  char cModule[32]="rawCheckClientFile";
369  int iDebug = 0;
370 
371  int iloc, iRC, ii;
372  int iDevType = 1; /* default: disk */
373 
374  bool_t bup = bFalse;
375 
376  char cText[12] = "";
377  char cTemp[MAX_FULL_FILE] = "";
378  char *plocd = NULL, *plocs = NULL;
379  char *pdelim = NULL, *pgen = NULL;
380  const char *pcSemi = ";";
381  char *pcc = NULL;
382 
383  if (iDebug) fprintf(fLogFile,
384  "\n-D- begin %s: test file %s\n", cModule, pcFullFile);
385 
386  strcpy(cTemp, pcFullFile);
387 
388  /* check if device name specified */
389  plocd = strchr(cTemp, *pcDevDelim);
390  if (plocd != NULL)
391  {
392  iRC = strncmp(cTemp, "/dev", 4);
393  {
394  fprintf(fLogFile,
395  "-E- invalid file name: %s\n path names must not contain '%s'\n",
396  pcFullFile, pcDevDelim);
397  return(-2);
398  }
399 
400  if (iRC)
401  pdelim = strrchr(cTemp, *pcFileDelim);
402  if ( (pdelim == NULL) || (pdelim > plocd) )
403  {
404  fprintf(fLogFile,
405  "-E- invalid disk file name: %s\n path names must not contain '%s'\n",
406  pcFullFile, pcDevDelim);
407  return(-2);
408  }
409 
410  pcc = plocd;
411  pcc++;
412  if (strlen(pcc) > MAX_TAPE_FILE)
413  {
414  ii = MAX_TAPE_FILE;
415  fprintf(fLogFile,
416  "-E- invalid tape file name: %s\n name too long: max %d byte after dev name\n",
417  pcFullFile, ii);
418  return(-2);
419  }
420 
421  iDevType = 2; /* tape, if Unix; if VMS: get it later */
422  iRC = strncmp(++pcc, "\0", 1);
423  if (iRC == 0)
424  {
425 #ifdef VMS
426  fprintf(fLogFile,
427  "-E- file name must be specified explicitly\n");
428 #else
429  fprintf(fLogFile, "-E- file name missing in %s\n", pcFullFile);
430 #endif
431  return(-2);
432  }
433  } /* (plocd != NULL) */
434 
435 #ifdef VMS
436  /* eliminate version number */
437  plocs = strchr(cTemp, *pcSemi);
438  if (plocs)
439  {
440  ++plocs;
441  iRC = isalnum(*plocs);
442  if (iRC) /* char after semicolon alphanum. */
443  {
444  iRC = isalpha(*plocs);
445  if (iRC == 0) /* char after semicolon no letter */
446  fprintf(fLogFile,
447  "-W- version number in file specification removed\n");
448  else
449  fprintf(fLogFile,
450  "-W- invalid version in file specification removed\n");
451  }
452  else
453  fprintf(fLogFile,
454  "-W- semicolon in file specification removed\n");
455  strncpy(--plocs, "\0", 1);
456  strcpy(pcFullFile, cTemp);
457  }
458 
459  iDevType = rawCheckDevice(cTemp, &pcFile, &pcTape);
460  switch(iDevType)
461  {
462  case 0:
463  if (iDebug) fprintf(fLogFile,
464  " no device name specified\n");
465  break;
466  case 1:
467  if (iDebug)
468  {
469  if (strlen(pcFile) == 0)
470  fprintf(fLogFile, " disk device %s\n", pcTape);
471  else
472  fprintf(fLogFile,
473  " file %s on disk %s\n", pcFile, pcTape);
474  }
475  break;
476  case 2:
477  if (iDebug)
478  {
479  if (strlen(pcFile) == 0)
480  fprintf(fLogFile, " tape device %s\n", pcTape);
481  else
482  fprintf(fLogFile, " file %s on tape %s\n", pcFile, pcTape);
483  }
484  break;
485  default:
486  fprintf(fLogFile, "-E- invalid file name %s\n", pcFullFile);
487  return(-1);
488 
489  } /* switch(iDevType) */
490 #endif /* VMS */
491 
492  if (iDevType == 2) /* tape */
493  {
494 #ifndef VMS
495  /* check string after 1st device delimiter */
496  iRC = strncmp(pcc, pcDevDelim, 1);
497  if (iRC == 0)
498  {
499  fprintf(fLogFile,
500  "-E- node specification not allowed in file name: %s\n",
501  pcFullFile);
502  return(-2);
503  }
504 #endif /* Unix */
505 
506  strncpy(plocd++, "\0", 1); /* cut string at colon */
507  strcpy(pcTape, cTemp);
508 #ifdef VMS
509  strncat(pcTape, pcDevDelim, 1); /* append colon in VMS */
510 
511 #else
512  pgen = strchr(pcTape, *pcStar);
513  if (pgen != NULL)
514  {
515  fprintf(fLogFile,
516  "-E- specified device %s has generic path\n", pcTape);
517  fprintf(fLogFile,
518  " only the relative file name may be generic\n");
519  return(-1);
520  }
521 #endif
522 
523  strcpy(pcFile, plocd);
524  if (iDebug) fprintf(fLogFile,
525  " file %s on tape %s\n", pcFile, pcTape);
526  strcpy(cText, "tape");
527  iRC = 1;
528 
529  } /* (iDevType == 2) */
530  else
531  {
532  strcpy(pcFile, cTemp);
533  strcpy(cText, "disk");
534  iRC = 0;
535  }
536 
537  if (iDebug) fprintf(fLogFile,
538  " %s file %s\n", cText, pcFile);
539 
540  pdelim = strrchr(pcFile, *pcFileDelim);
541  if (pdelim != NULL) /* path specified */
542  {
543 #ifndef VMS
544  if (iDevType == 2) /* file on tape */
545  {
546  fprintf(fLogFile,
547  "-E- path in tape file name not allowed: %s\n", pcFile);
548  return(-1);
549  }
550 #endif
551 
552  /* disk file prefixed with path */
553  pgen = strchr(pcFile, *pcStar);
554  if (pgen == NULL)
555  pgen = strchr(pcFile, *pcQM);
556  if ( (pgen != NULL) && (pgen < pdelim) && (iDebug) )
557  fprintf(fLogFile,
558  " specified %s file %s has wildcard chars in path name\n",
559  cText, pcFile);
560 
561  pdelim++; /* points to rel. file name */
562 
563  } /* (pdelim != NULL) */
564  else pdelim = pcFile;
565 
566  ii = MAX_OBJ_LL - 2;
567  if (strlen(pdelim) > ii)
568  {
569  fprintf(fLogFile,
570  "-E- rel file name %s too long:\n has %d chars, max allowed %d\n",
571  pdelim, (int) strlen(pdelim), ii);
572  return(-1);
573  }
574 
575 #ifndef VMS
576  /* tape: convert file name from uppercase if necessary */
577  if (iDevType == 2)
578  {
579  pcc = pdelim;
580  while (*pcc != '\0')
581  {
582  iloc = isupper(*pcc);
583  if (iloc != 0)
584  {
585  if (!bup) fprintf(fLogFile,
586  "-W- upper case in (relative) file name not supported: %s\n",
587  pdelim);
588  bup = bTrue;
589  *pcc = tolower(*pcc); /* change to lower case */
590  }
591  pcc++;
592  } /* while (*pcc != '\0') */
593  }
594 
595  if (bup)
596  fprintf(fLogFile, " instead assumed: %s\n", pdelim);
597 #endif
598 
599  if (iDebug) fprintf(fLogFile,
600  "-D- end %s: file name %s okay\n\n", cModule, pcFullFile);
601 
602  return(iRC);
603 
604 } /* rawCheckClientFile */
605 
606 /*********************************************************************
607  * rawDelFile: delete single file in GSI mass storage
608  *
609  * created 8.10.1996, Horst Goeringer
610  *********************************************************************
611  */
612 
613 int rawDelFile( int iSocket, srawComm *psComm)
614 {
615  char cModule[32] = "rawDelFile";
616  int iDebug = 0;
617 
618  int iFSidRC = 0;
619  int iFSidWC = 0;
620 
621  int iRC;
622  int iBufComm;
623  char *pcc;
624  void *pBuf;
625  char cMsg[STATUS_LEN] = "";
626 
627  srawStatus sStatus;
628 
629  iBufComm = ntohl(psComm->iCommLen) + HEAD_LEN;
630  if (iDebug) fprintf(fLogFile,
631  "\n-D- begin %s: delete file %s%s%s\n",
632  cModule, psComm->cNamefs, psComm->cNamehl, psComm->cNamell);
633 
634  if (psComm->iStageFSid)
635  iFSidRC = ntohl(psComm->iStageFSid);
636  if (psComm->iFSidWC)
637  iFSidWC = ntohl(psComm->iFSidWC);
638 
639  if (iDebug)
640  {
641  fprintf(fLogFile,
642  " object %s%s%s found (objId %u-%u)",
643  psComm->cNamefs, psComm->cNamehl, psComm->cNamell,
644  ntohl(psComm->iObjHigh), ntohl(psComm->iObjLow));
645  if (iFSidRC) fprintf(fLogFile,
646  ", on %s in read cache FS %d\n", psComm->cNodeRC, iFSidRC);
647  else
648  fprintf(fLogFile, "\n");
649  if (iFSidWC) fprintf(fLogFile,
650  " on %s in write cache FS %d\n", psComm->cNodeWC, iFSidWC);
651  }
652 
653  psComm->iAction = htonl(REMOVE);
654 
655  pcc = (char *) psComm;
656  if ( (iRC = send( iSocket, pcc, (unsigned) iBufComm, 0 )) < iBufComm)
657  {
658  if (iRC < 0) fprintf(fLogFile,
659  "-E- %s: sending delete request for file %s (%d byte)\n",
660  cModule, psComm->cNamell, iBufComm);
661  else fprintf(fLogFile,
662  "-E- %s: delete request for file %s (%d byte) incompletely sent (%d byte)\n",
663  cModule, psComm->cNamell, iBufComm, iRC);
664  if (errno)
665  fprintf(fLogFile, " %s\n", strerror(errno));
666  perror("-E- sending delete request");
667 
668  return -1;
669  }
670 
671  if (iDebug) fprintf(fLogFile,
672  " delete command sent to server (%d bytes), look for reply\n",
673  iBufComm);
674 
675  /******************* look for reply from server *******************/
676 
677  iRC = rawRecvStatus(iSocket, &sStatus);
678  if (iRC != HEAD_LEN)
679  {
680  if (iRC < HEAD_LEN) fprintf(fLogFile,
681  "-E- %s: receiving status buffer\n", cModule);
682  else
683  {
684  fprintf(fLogFile,
685  "-E- %s: message received from server:\n", cModule);
686  fprintf(fLogFile, "%s", sStatus.cStatus);
687  }
688 
689  if (iDebug)
690  fprintf(fLogFile, "\n-D- end %s\n\n", cModule);
691 
692  return(-1);
693  }
694 
695  if (iDebug) fprintf(fLogFile,
696  " status (%d) received from server (%d bytes)\n",
697  sStatus.iStatus, iRC);
698 
699  /* delete in this proc only if WC and RC, 2nd step WC */
700  if (iDebug)
701  {
702  fprintf(fLogFile,
703  "-I- gStore object %s%s%s successfully deleted",
704  psComm->cNamefs, psComm->cNamehl, psComm->cNamell);
705  if (iFSidWC)
706  fprintf(fLogFile, " from write cache\n");
707  else
708  fprintf(fLogFile, "\n");
709 
710  fprintf(fLogFile, "-D- end %s\n\n", cModule);
711  }
712 
713  return 0;
714 
715 } /* end rawDelFile */
716 
717 /*********************************************************************
718  * rawDelList: delete list of files in GSI mass storage
719  *
720  * created 22.10.1997, Horst Goeringer
721  *********************************************************************
722  */
723 
724 int rawDelList( int iSocketMaster,
725  /* socket for connection to entry server */
726  int iDataMover, /* no. of data movers */
727  srawDataMoverAttr *pDataMover0,
728  srawComm *psComm,
729  char **pcFileList,
730  char **pcObjList)
731 {
732  char cModule[32] = "rawDelList";
733  int iDebug = 0;
734 
735  int iSocket;
736  char *pcfl, *pcol;
737  int *pifl, *piol;
738  int ifile;
739  int iobj0, iobj;
740  int iobjBuf;
741 
742  srawFileList *psFile, *psFile0; /* files to be archived */
743  srawRetrList *psObj; /* objects already archived */
744  srawDataMoverAttr *pDataMover; /* current data mover */
745 
746  char *pcc, *pdelim;
747 
748  bool_t bDelete, bDelDone;
749  int **piptr; /* points to pointer to next buffer */
750 
751  int ii, jj, kk;
752  int iRC, idel;
753 
754  pcfl = *pcFileList;
755  pifl = (int *) pcfl;
756  ifile = pifl[0]; /* number of files */
757  psFile = (srawFileList *) ++pifl; /* points now to first file */
758  psFile0 = psFile;
759  pifl--; /* points again to number of files */
760 
761  if (iDebug)
762  {
763  fprintf(fLogFile, "\n-D- begin %s\n", cModule);
764  fprintf(fLogFile, " initial %d files, first file %s\n",
765  ifile, psFile0->cFile);
766  }
767 
768  pDataMover = pDataMover0;
769  pcol = *pcObjList;
770  piol = (int *) pcol;
771  iobj0 = 0; /* total no. of archived objects */
772 
773  iobjBuf = 0; /* count query buffers */
774  idel = 0; /* count deleted files */
775  bDelDone = bFalse;
776  while (!bDelDone)
777  {
778  iobjBuf++;
779  iobj = piol[0]; /* no. of objects in query buffer */
780  psObj = (srawRetrList *) ++piol;
781  /* points now to first object */
782  if (iDebug) fprintf(fLogFile,
783  " buffer %d: %d objects, first obj %s%s (server %d)\n",
784  iobjBuf, iobj, psObj->cNamehl, psObj->cNamell,
785  psObj->iATLServer);
786 
787  psComm->iAction = htonl(REMOVE);
788  for (ii=1; ii<=iobj; ii++) /* loop over objects in buffer */
789  {
790  iobj0++;
791  pcc = (char *) psObj->cNamell;
792  pcc++; /* skip object delimiter */
793 
794  if (iDebug) fprintf(fLogFile,
795  " obj %d: %s%s, objId %d-%d\n",
796  ii, psObj->cNamehl, psObj->cNamell,
797  psObj->iObjHigh, psObj->iObjLow);
798 
799  bDelete = bFalse;
800  psFile = psFile0;
801  for (jj=1; jj<=ifile; jj++) /* file loop */
802  {
803  if (iDebug) fprintf(fLogFile,
804  " file %d: %s\n", jj, psFile->cFile);
805 
806  pdelim = strrchr(psFile->cFile, *pcFileDelim);
807  if (pdelim == NULL)
808  {
809 #ifdef VMS
810  pdelim = strrchr(psFile->cFile, *pcFileDelim2);
811  if (pdelim != NULL) pdelim++;
812  else
813 #endif
814  pdelim = psFile->cFile;
815  }
816  else pdelim++; /* skip file delimiter */
817 
818  iRC = strcmp(pdelim, pcc);
819  if ( iRC == 0 )
820  {
821  bDelete = bTrue;
822  break;
823  }
824  psFile++;
825  } /* file loop (jj) */
826 
827  if (bDelete)
828  {
829  if (iDebug)
830  {
831  fprintf(fLogFile, " matching file %d: %s, obj %d: %s%s",
832  jj, psFile->cFile, ii, psObj->cNamehl, psObj->cNamell);
833 
834  if (psObj->iStageFS) fprintf(fLogFile,
835  ", on DM %s in StageFS %d\n",
836  psObj->cMoverStage, psObj->iStageFS);
837  else if (psObj->iCacheFS)
838  {
839  fprintf(fLogFile, ", on DM %s in ArchiveFS %d\n",
840  psObj->cMoverStage, psObj->iCacheFS);
841  fprintf(fLogFile, " archived at %s by %s\n",
842  psObj->cArchiveDate, psObj->cOwner);
843  }
844  else
845  fprintf(fLogFile," (not in disk pool)\n");
846  }
847 
848  psComm->iObjHigh = htonl(psObj->iObjHigh);
849  psComm->iObjLow = htonl(psObj->iObjLow);
850  psComm->iATLServer = htonl(psObj->iATLServer);
851 
852  if (psObj->iStageFS)
853  {
854  psComm->iPoolIdRC = htonl(psObj->iPoolIdRC);
855  psComm->iStageFSid = htonl(psObj->iStageFS);
856  strcpy(psComm->cNodeRC, psObj->cMoverStage);
857  }
858  else
859  {
860  psComm->iPoolIdRC = htonl(0);
861  psComm->iStageFSid = htonl(0);
862  strcpy(psComm->cNodeRC, "");
863  }
864 
865  if (psObj->iCacheFS)
866  {
867  if (psObj->iStageFS)
868  psComm->iPoolIdWC = htonl(0); /* WC poolId unavail */
869  else
870  psComm->iPoolIdWC = htonl(psObj->iPoolIdRC);
871  psComm->iFSidWC = htonl(psObj->iCacheFS);
872  strcpy(psComm->cNodeWC, psObj->cMoverCache);
873  }
874  else
875  {
876  psComm->iPoolIdWC = htonl(0);
877  psComm->iFSidWC = htonl(0);
878  strcpy(psComm->cNodeWC, "");
879  }
880 
881  iRC = rawGetLLName(psFile->cFile,
882  pcObjDelim, psComm->cNamell);
883 
884  if (iDataMover > 1)
885  {
886  if ((strcmp(pDataMover->cNode, psObj->cMoverStage) == 0) ||
887  (strlen(psObj->cMoverStage) == 0)) /* not staged */
888  {
889  iSocket = pDataMover->iSocket;
890  if (iDebug) fprintf(fLogFile,
891  " current data mover %s, socket %d\n",
892  pDataMover->cNode, iSocket);
893  }
894  else
895  {
896  pDataMover = pDataMover0;
897  for (kk=1; kk<=iDataMover; kk++)
898  {
899  if (strcmp(pDataMover->cNode,
900  psObj->cMoverStage) == 0)
901  break;
902  pDataMover++;
903  }
904 
905  if (kk > iDataMover)
906  {
907  fprintf(fLogFile,
908  "-E- %s: data mover %s not found in list\n",
909  cModule, psObj->cMoverStage);
910 
911  return -1;
912  }
913 
914  iSocket = pDataMover->iSocket;
915  if (iDebug) fprintf(fLogFile,
916  " new data mover %s, socket %d\n",
917  pDataMover->cNode, iSocket);
918  }
919  } /* (iDataMover > 1) */
920 
921  iRC = rawDelFile(iSocketMaster, psComm);
922  if (iRC)
923  {
924  if (iDebug)
925  fprintf(fLogFile, " rawDelFile: rc = %d\n", iRC);
926  if (iRC < 0)
927  {
928  fprintf(fLogFile,
929  "-E- %s: file %s could not be deleted\n",
930  cModule, psFile->cFile);
931  if (iDebug)
932  fprintf(fLogFile, "-D- end %s\n\n", cModule);
933 
934  return -1;
935  }
936  /* else: object not found, ignore */
937 
938  } /* (iRC) */
939 
940  idel++;
941 
942  } /* if (bDelete) */
943  else if (iDebug) fprintf(fLogFile,
944  " file %s: obj %s%s not found in gStore\n",
945  psFile0->cFile, psObj->cNamehl, psObj->cNamell);
946 
947  psObj++;
948 
949  } /* loop over objects in query buffer (ii) */
950 
951  piptr = (int **) psObj;
952  if (*piptr == NULL) bDelDone = bTrue;
953  else piol = *piptr;
954 
955  } /* while (!bDelDone) */
956 
957  if (iDebug)
958  fprintf(fLogFile, "-D- end %s\n\n", cModule);
959 
960  return(idel);
961 
962 } /* rawDelList */
963 
964 /**********************************************************************
965  * rawGetFSpName
966  * get file space name from user specification
967  * created 22.3.1996, Horst Goeringer
968  **********************************************************************
969  */
970 
971 char *rawGetFSpName( char *pcUser )
972 {
973  char cModule[32]="rawGetFSpName";
974  int iDebug = 0;
975 
976  char *pc;
977 
978  if (iDebug)
979  fprintf(fLogFile, "\n-D- begin %s\n", cModule);
980 
981  pc = pcUser;
982  if ( (strchr(pcUser, *pcStar) != NULL) ||
983  (strchr(pcUser, *pcQM) != NULL) )
984  {
985  fprintf(fLogFile,
986  "-E- %s: generic archive name '%s' not allowed\n",
987  cModule, pcUser);
988  return(pcNull);
989  }
990 
991  strcpy(cNamefs, ""); /* initialize */
992  if (iDebug)
993  fprintf(fLogFile, "-D- %s: FS %s, in %s-%s, delim %s\n",
994  cModule, cNamefs, pcUser, pc, pcObjDelim);
995  if (strncmp(pc, pcObjDelim, 1) == 0)
996  pc++;
997  else
998  /* strncpy(cNamefs, pcObjDelim, 1); */
999  /* in adsmcli session: beginning with 2nd invocation,
1000  gives incorrect results due to missing \0 ! H.G. 27.10.97 */
1001  strcpy(cNamefs, pcObjDelim);
1002 
1003  if (isalpha(*pc) == 0)
1004  {
1005  fprintf(fLogFile,
1006  "-E- archive name '%s' must start with a letter\n", pc);
1007  return(pcNull);
1008  }
1009 
1010  strcat(cNamefs, pcUser);
1011  if (iDebug) fprintf(fLogFile,
1012  "-D- end %s: FS %s\n", cNamefs, cModule);
1013 
1014  return( (char *) cNamefs);
1015 
1016 } /* rawGetFSpName */
1017 
1018 /*********************************************************************
1019  * rawGetHLName: get high level object name from path
1020  *
1021  * insert name part at beginning depending on device
1022  * PLATFORM DEPENDENT
1023  *
1024  * created 16. 2.96, Horst Goeringer
1025  *********************************************************************
1026  */
1027 
1028 char *rawGetHLName( char *pcPath)
1029 {
1030  char cModule[32]="rawGetHLName";
1031  int iDebug = 0;
1032 
1033  char *pcc;
1034  char *pdelim;
1035  char cNameTemp[MAX_OBJ_HL] = "";
1036  int ii = 0, ii1 = 0;
1037 
1038  if (iDebug) fprintf(fLogFile,
1039  "\n-D- begin %s\n path specified: %s\n", cModule, pcPath);
1040 
1041  pdelim = strchr(pcPath, *pcObjDelim);
1042  if (pdelim != pcPath)
1043  {
1044  strcpy(cNamehl, pcObjDelim);
1045  if (iDebug) fprintf(fLogFile,
1046  " delimiter '%s' inserted at begin of archive path\n",
1047  pcObjDelim);
1048  strcat(cNamehl, pcPath);
1049  }
1050  else strcpy(cNamehl, pcPath);
1051 
1052  pdelim = strstr(cNamehl, "/./");
1053  if (pdelim != NULL)
1054  {
1055  strcpy(cNameTemp, cNamehl);
1056  pdelim = strstr(cNameTemp, "/./");
1057 
1058  while (pdelim != NULL)
1059  {
1060  ii++;
1061  strncpy(pdelim, "\0", 1);
1062  strcpy(cNamehl, cNameTemp);
1063  pdelim++;
1064  pdelim++;
1065  strcat(cNamehl, pdelim);
1066 
1067  strcpy(cNameTemp, cNamehl);
1068  pdelim = strstr(cNameTemp, "/./");
1069  }
1070  if (iDebug) fprintf(fLogFile,
1071  " %d unnecessary './' removed\n", ii);
1072  }
1073 
1074  pdelim = strstr(cNamehl, "/.");
1075  if (pdelim != NULL)
1076  {
1077  pcc= cNamehl;
1078  ii = strlen(cNamehl);
1079  ii1 = pdelim - pcc;
1080  if (ii1 < 0)
1081  ii1 = -ii1;
1082  if (ii1+2 == ii)
1083  {
1084  strncpy(pdelim, "\0", 1);
1085  if (iDebug) fprintf(fLogFile,
1086  " trailing '/.' removed\n");
1087  }
1088  }
1089 
1090  if (iDebug) fprintf(fLogFile,
1091  " hl name: %s\n-D- end %s\n\n", cNamehl, cModule);
1092 
1093  return(cNamehl);
1094 
1095 } /* rawGetHLName */
1096 
1097 /*********************************************************************
1098  * rawGetLLName: get low level object name from file name
1099  * PLATFORM DEPENDENT
1100  *
1101  * created 16. 2.1996, Horst Goeringer
1102  *********************************************************************
1103  * 9. 1.2002, H.G.: pass object and delimiter as argument
1104  *********************************************************************
1105  */
1106 
1107 int rawGetLLName( char *pcFile, const char *pcDelimiter,
1108  char *pcObject)
1109 {
1110  char cModule[32] = "rawGetLLName";
1111  int iDebug = 0;
1112 
1113  char cNamell[MAX_OBJ_LL] = "";
1114  char *ploc = NULL;
1115 
1116  if (iDebug) fprintf(fLogFile,
1117  "\n-D- begin %s\n file %s, object delimiter %s\n",
1118  cModule, pcFile, pcDelimiter);
1119 
1120  strcpy(cNamell, pcDelimiter);
1121 
1122  ploc = strrchr(pcFile, *pcFileDelim);
1123  if (ploc != NULL)
1124  strcat(cNamell, ++ploc); /* begin copy after file delimiter */
1125  else
1126  {
1127  ploc = strrchr(pcFile, *pcObjDelimAlt);
1128  if (ploc != NULL)
1129  strcat(cNamell, ++ploc);/* begin copy after file delimiter */
1130  else
1131  {
1132 #ifdef VMS
1133  ploc = strrchr(pcFile, *pcDevDelim); /* look for disk device */
1134  if (ploc != NULL)
1135  strcat(cNamell, ++ploc);
1136  /* begin copy after device delimiter */
1137  else
1138 #endif
1139  strcat(cNamell, pcFile);
1140  }
1141  }
1142  strcpy(pcObject, cNamell);
1143 
1144  if (iDebug) fprintf(fLogFile,
1145  " ll name %s\n-D- end %s\n\n", pcObject, cModule);
1146 
1147  return 0;
1148 
1149 } /* rawGetLLName */
1150 
1151 /**********************************************************************
1152  * rawGetFileSize
1153  * get file size (bytes)
1154  * created 19.2.2002, Horst Goeringer
1155  **********************************************************************
1156  */
1157 
1158 int rawGetFileSize(char *pcFile,
1159  unsigned long *piSize,
1160  unsigned int *piRecl) /* needed only for VMS */
1161 {
1162  char cModule[32] = "rawGetFileSize";
1163  int iDebug = 0;
1164 
1165  int iRC;
1166  int iRecl = 0;
1167  unsigned long iSize = 0;
1168 
1169 #ifdef WIN32 /* Windows */
1170  struct _stat sFileStatus, *pFileStatus;
1171 #else /* Unix or VMS */
1172  struct stat sFileStatus, *pFileStatus;
1173 #endif
1174 
1175  if (iDebug) fprintf(fLogFile,
1176  "\n-D- begin %s: file %s\n", cModule, pcFile);
1177 
1178  pFileStatus = &sFileStatus;
1179 
1180 #ifdef WIN32 /* Windows */
1181  iRC = _stat(pcFile, pFileStatus);
1182 #else /* Unix or VMS */
1183  iRC = stat(pcFile, pFileStatus);
1184 #endif
1185  if (iRC)
1186  {
1187  if (iDebug) fprintf(fLogFile,
1188  "-E- %s: file %s unavailable (stat)\n", cModule, pcFile);
1189  if (errno)
1190  {
1191  if (strcmp(strerror(errno),
1192  "No such file or directory") != 0)
1193  fprintf(fLogFile, " %s\n", strerror(errno));
1194 
1195  /* valid only for 32 bit OS */
1196  if (strcmp(strerror(errno),
1197  "Value too large for defined data type") == 0)
1198  {
1199  fprintf(fLogFile,
1200  "-E- file size %s > 2 GByte: use 64 bit gStore client\n",
1201  pcFile);
1202 
1203  errno = 0;
1204  return -99;
1205  }
1206  errno = 0;
1207  }
1208 
1209  return -1;
1210  }
1211 
1212 #ifdef VMS
1213  iRecl = pFileStatus->st_fab_mrs;
1214 #else
1215 #ifdef WIN32
1216  iRecl = 0; /* not available in Windows */
1217 #else
1218  iRecl = pFileStatus->st_blksize;
1219 #endif
1220 #endif
1221  iSize = pFileStatus->st_size;
1222  if (pFileStatus->st_mode & S_IFREG)
1223  {
1224  iRC = 0;
1225  if (iDebug) fprintf(fLogFile,
1226  " file %s: size %lu, recl %d (byte)\n",
1227  pcFile, iSize, iRecl);
1228  }
1229  else
1230  {
1231  if (pFileStatus->st_mode & S_IFDIR)
1232  {
1233  iRC = 1;
1234  if (iDebug) fprintf(fLogFile,
1235  "-W- %s is a directory, size %lu\n", pcFile, iSize);
1236  }
1237 #ifndef WIN32
1238 #ifndef VMS
1239  else if (pFileStatus->st_mode & S_IFLNK)
1240  {
1241  iRC = 2;
1242  if (iDebug) fprintf(fLogFile,
1243  "-W- %s is a symbolic link, size %lu\n", pcFile, iSize);
1244  }
1245 #endif
1246 #endif
1247  else
1248  {
1249  iRC = 3;
1250  if (iDebug) fprintf(fLogFile,
1251  "-W- unexpected item %s, size %lu\n", pcFile, iSize);
1252  }
1253  }
1254 
1255  *piRecl = iRecl;
1256  *piSize = iSize;
1257  if (iDebug)
1258  fprintf(fLogFile, "-D- end %s\n\n", cModule);
1259 
1260  return iRC;
1261 
1262 } /* rawGetFileSize */
1263 
1264 /*********************************************************************
1265  * rawGetPathName: get path name from high level object name
1266  *
1267  * created 21. 3.1996, Horst Goeringer
1268  *********************************************************************
1269  * 23. 4.1996, H.G: no more device dependency in hl-name, as with
1270  * ADSM V213 management class can be set in dsmSendObj
1271  *********************************************************************
1272  */
1273 
1274 char *rawGetPathName( char *pcNamehl)
1275 {
1276  char cModule[32] = "rawGetPathName";
1277  int iDebug = 0;
1278 
1279  char *ploc = NULL, *ploc1 = NULL;
1280  char *pcc;
1281 
1282  if (iDebug)
1283  fprintf(fLogFile, "-D- begin %s: hl: %s\n", cModule, pcNamehl);
1284 
1285  if (strlen(pcNamehl) == 0)
1286  {
1287  fprintf(fLogFile, "-E- %s: high level name empty\n", cModule);
1288  return(pcNull);
1289  }
1290 
1291  pcc = pcNamehl;
1292  ploc = strchr(pcNamehl, *pcObjDelim);
1293  ploc1 = strchr(pcNamehl, *pcObjDelimAlt);
1294  if ( (ploc != pcc) && (ploc1 != pcc) )
1295  {
1296  fprintf(fLogFile,
1297  "-E- %s: invalid prefix in high level name %s\n",
1298  cModule, pcNamehl);
1299  return(pcNull);
1300  }
1301 
1302  strcpy(cPath, pcc);
1303  if (iDebug) fprintf(fLogFile,
1304  "-D- end %s: path %s\n\n", cModule, cPath);
1305 
1306  return cPath;
1307 
1308 } /* rawGetPathName */
1309 
1310 /********************************************************************
1311  * rawQueryFile: get query information for single file
1312  *
1313  * used for tape input handled sequentially
1314  * buffers for communication and query info allocated in calling
1315  * procedure
1316  ********************************************************************
1317  */
1318 
1320  int iSocket,
1321  int iAltMaster, /* currently unused */
1322  srawComm *pCommBuf,
1323  void **pQueryBuf)
1324 {
1325  char cModule[32] = "rawQueryFile";
1326  int iDebug = 0;
1327 
1328  int iATLServer = 0; /* =1: prod TSM server, =2: test TSM server */
1329  int iNameVar = -1; /* = 1: path/file contains wildcard chars */
1330  int iRC;
1331  int iAction = 0;
1332  int iIdent = 0;
1333  int iQuery = -1;
1334  int iAttrLen = 0;
1335  int iQueryAll = 0;
1336  int iStatus = 0, iStatusLen = 0;
1337  int iBuf = 0, iBufComm = 0;
1338  int ii, jj;
1339  char *pcc;
1340 
1341  int iVersionObjAttr = 0;
1342  /* version no. of srawObjAttr:
1343  =3: 288 byte cache buffer, 2 restore fields
1344  =4: 304 byte, 5 restore fields, ATL server no.
1345  =5: 384 byte, maior enhancement */
1346  int iPoolId = 0;
1347  int iObjLow = 0;
1348  int iFS = 0;
1349  int iMediaClass = 0;
1350 
1351  srawComm *pComm;
1352  srawQueryResult *pQuery;
1353  srawObjAttr *pObjAttr;
1354 
1355  /* query data space to be allocated, if several objects found */
1356  char *pcQueryBuffer;
1357  int iQueryBuffer = 0;
1358 
1359  pComm = pCommBuf;
1360  iAction = ntohl(pComm->iAction);
1361  iATLServer = ntohl(pComm->iATLServer);
1362  pQuery = (srawQueryResult *) (*pQueryBuf);
1363 
1364  iBufComm = ntohl(pComm->iCommLen) + HEAD_LEN;
1365  if (iDebug)
1366  {
1367  fprintf(fLogFile,
1368  "\n-D- begin %s: query file %s%s in ATL Server %d (socket %d, action %d)\n",
1369  cModule, pComm->cNamehl, pComm->cNamell, iATLServer, iSocket, iAction);
1370  fflush(fLogFile);
1371  }
1372 
1373  switch(iAction)
1374  {
1375  case QUERY:
1376  case QUERY_ARCHIVE:
1377  case QUERY_ARCHIVE_RECORD:
1378  case QUERY_ARCHIVE_OVER:
1380  case QUERY_ARCHIVE_MGR:
1381  case QUERY_REMOVE:
1382  case QUERY_REMOVE_MGR:
1383  case QUERY_RETRIEVE:
1384  case QUERY_RETRIEVE_RECORD:
1385  case QUERY_STAGE:
1386  ; /* okay */
1387  break;
1388  default:
1389  fprintf(fLogFile,
1390  "-E- %s: invalid action %d\n", cModule, iAction);
1391  iQueryAll = -1;
1392  goto gEndQueryFile;
1393  }
1394 
1395  pcc = (char *) pComm;
1396  iRC = send(iSocket, pcc, (unsigned) iBufComm, 0);
1397  if (iRC < iBufComm)
1398  {
1399  if (iRC < 0) fprintf(fLogFile,
1400  "-E- %s: sending command buffer for query file %s%s\n",
1401  cModule, pComm->cNamehl, pComm->cNamell);
1402  else fprintf(fLogFile,
1403  "-E- %s: query command buffer incompletely sent (%d of %d byte)\n",
1404  cModule, iRC, iBufComm);
1405 
1406  if (errno)
1407  {
1408  fprintf(fLogFile, " %s\n", strerror(errno));
1409  errno = 0;
1410  }
1411 
1412  iQueryAll = -1;
1413  goto gEndQueryFile;
1414  }
1415 
1416  if (iDebug) fprintf(fLogFile,
1417  " query command sent to entry server (%d bytes), look for reply\n",
1418  iBufComm);
1419  fflush(fLogFile);
1420 
1421  /******************* look for reply from server *******************/
1422 
1423 gNextReply:
1424  pcc = (char *) pQuery;
1425  iRC = rawRecvHead(iSocket, pcc);
1426  if (iRC <= 0)
1427  {
1428  fprintf(fLogFile,
1429  "-E- %s: receiving buffer header with query information\n",
1430  cModule);
1431  iQueryAll = -1;
1432  goto gEndQueryFile;
1433  }
1434 
1435  pcc += HEAD_LEN;
1436  iIdent = ntohl(pQuery->iIdent);
1437  iQuery = ntohl(pQuery->iObjCount);
1438  iAttrLen = ntohl(pQuery->iAttrLen);
1439 
1440  if (iDebug) fprintf(fLogFile,
1441  " %d bytes received: iIdent %d, iQuery %d, iAttrLen %d\n",
1442  iRC, iIdent, iQuery, iAttrLen);
1443  fflush(fLogFile);
1444 
1445  iQueryAll += iQuery;
1446  if ( (iIdent != IDENT_QUERY) && (iIdent != IDENT_QUERY_DONE) &&
1447  (iIdent != IDENT_QUERY_ARCHDB) )
1448  {
1449  iStatus = iQuery;
1450  iQueryAll = -1; /* query failed */
1451 
1452  if (iIdent == IDENT_STATUS)
1453  {
1454  iStatusLen = iAttrLen;
1455  if ( (iStatus == STA_ERROR) || (iStatus == STA_ERROR_EOF) ||
1456  (iStatus == STA_ARCHIVE_NOT_AVAIL) ||
1457  (iStatus == STA_NO_ACCESS) )
1458  {
1459  if ( (iStatus == STA_ERROR) || (iStatus == STA_ERROR_EOF) )
1460  fprintf(fLogFile,
1461  "-E- %s: error status from entry server instead of query data:\n",
1462  cModule);
1463 
1464  if (iStatusLen > 0)
1465  {
1466  iRC = rawRecvError(iSocket, iStatusLen, pcc);
1467  if (iRC < 0) fprintf(fLogFile,
1468  "-E- receiving error msg from server, rc = %d\n",
1469  iRC);
1470  else if ( (iDebug) || (iStatus == STA_ERROR) ||
1471  (iStatus == STA_ERROR_EOF) )
1472  fprintf(fLogFile, "%s", pcc);
1473  }
1474  else
1475  fprintf(fLogFile," no error message available\n");
1476 
1477  if (iStatus == STA_ARCHIVE_NOT_AVAIL)
1478  iQueryAll = -1000;
1479  else if (iStatus == STA_NO_ACCESS)
1480  iQueryAll = -1001;
1481 
1482  } /* (iStatus == STA_ERROR || STA_ERROR_EOF ||
1483  STA_ARCHIVE_NOT_AVAIL || STA_NO_ACCESS) */
1484  else fprintf(fLogFile,
1485  "-E- %s: unexpected status (type %d) received from server\n",
1486  cModule, iStatus);
1487 
1488  } /* iIdent == IDENT_STATUS */
1489  else fprintf(fLogFile,
1490  "-E- %s: unexpected header (type %d) received from server\n",
1491  cModule, iIdent);
1492 
1493  goto gEndQueryFile;
1494 
1495  } /* iIdent != IDENT_QUERY && != IDENT_QUERY_DONE &&
1496  != IDENT_QUERY_ARCHDB */
1497 
1498  if (iQuery > 0)
1499  {
1500  if (iQuery > 1)
1501  {
1502  iQueryBuffer = iQuery * iAttrLen;
1503  if ( (pcQueryBuffer =
1504  (char *) calloc(iQueryBuffer, ichar) ) == NULL)
1505  {
1506  fprintf(fLogFile,
1507  "-E- %s: allocating query info buffer for %d objs (%d byte)\n",
1508  cModule, iQuery, iQueryBuffer);
1509  if (errno)
1510  fprintf(fLogFile, " %s\n", strerror(errno));
1511 
1512  goto gEndQueryFile;
1513  }
1514  pcc = pcQueryBuffer;
1515 
1516  if (iDebug) fprintf(fLogFile,
1517  " query info buffer for %d objs allocated (%d byte)\n",
1518  iQuery, iQueryBuffer);
1519 
1520  } /* (iQuery > 1) */
1521  else
1522  {
1523  pcc = (char *) pQuery + HEAD_LEN;
1524  iQueryBuffer = iAttrLen;
1525  }
1526 
1527  pObjAttr = (srawObjAttr *) pcc;
1528  iBuf = iQueryBuffer;
1529  while(iBuf > 0)
1530  {
1531  if ( (iRC = recv( iSocket, pcc, (unsigned) iBuf, 0 )) <= 0 )
1532  {
1533  if (iRC < 0)
1534  {
1535  fprintf(fLogFile,
1536  "-E- %s: receiving buffer with query results (%d byte)\n",
1537  cModule, iQueryBuffer);
1538 
1539  iQueryAll = -1;
1540  }
1541  else
1542  {
1543  jj = iQueryBuffer - iBuf;
1544  fprintf(fLogFile,
1545  "-E- %s: connection to server broken, only %d bytes of query result (%d byte) received\n",
1546  cModule, jj, iQueryBuffer);
1547  }
1548 
1549  if (errno)
1550  {
1551  fprintf(fLogFile, " %s\n", strerror(errno));
1552  errno = 0;
1553  }
1554 
1555  goto gEndQueryFile;
1556  }
1557 
1558  iBuf -= iRC;
1559  pcc += iRC;
1560 
1561  } /* while(iBuf > 0) */
1562 
1563  if (iDebug) fprintf(fLogFile,
1564  " query data of %d objs received (%d byte)\n",
1565  iQuery, iQueryBuffer);
1566 
1567  if (iQuery > 1)
1568  pObjAttr = (srawObjAttr *) pcQueryBuffer;
1569  else
1570  {
1571  pcc = (char *) pQuery + HEAD_LEN;
1572  pObjAttr = (srawObjAttr *) pcc;
1573  }
1574 
1575  for (ii=1; ii<=iQuery; ii++)
1576  {
1577  iPoolId = ntohl(pObjAttr->iPoolId);
1578 
1579  if (iDebug)
1580  {
1581  fprintf(fLogFile, "%d: %s%s%s (poolId %d)\n",
1582  ii, pObjAttr->cNamefs, pObjAttr->cNamehl,
1583  pObjAttr->cNamell, iPoolId);
1584  }
1585 
1586  /* fill comm. buffer values */
1587  if (iQuery == 1)
1588  {
1589  pComm->iObjHigh = pObjAttr->iObjHigh; /* net format */
1590  pComm->iObjLow = pObjAttr->iObjLow;
1591  iMediaClass = ntohl(pObjAttr->iMediaClass);
1592 
1593  if ( (ntohl(pObjAttr->iObjHigh) == 0) &&
1594  (ntohl(pObjAttr->iObjLow) == 0) )
1595  {
1596  if ( (iMediaClass == GSI_MEDIA_CACHE) ||
1597  (iMediaClass == GSI_CACHE_LOCKED) ||
1598  (iMediaClass == GSI_CACHE_COPY) ||
1599  (iMediaClass == GSI_CACHE_INCOMPLETE) )
1600  {
1601  pComm->iPoolIdWC = pObjAttr->iPoolId;
1602  pComm->iFSidWC = pObjAttr->iFS;
1603  strcpy(pComm->cNodeWC, pObjAttr->cNode);
1604 
1605  } /* file in write cache and not staged */
1606  else
1607  {
1608  if ( (iPoolId == 1) || (iPoolId == 2) ||
1609  (iPoolId == 5) )
1610  {
1611  /* historically: ObjHigh/Low not available */
1612  if ( (iMediaClass == GSI_MEDIA_STAGE) ||
1613  (iMediaClass == GSI_MEDIA_LOCKED) ||
1614  (iMediaClass == GSI_MEDIA_INCOMPLETE) )
1615  {
1616  /* also in read cache */
1617  pComm->iPoolIdRC = pObjAttr->iPoolId;
1618  pComm->iStageFSid = pObjAttr->iFS;
1619  strcpy(pComm->cNodeRC, pObjAttr->cNode);
1620  }
1621  else fprintf(fLogFile,
1622  "-E- %s: unexpected meta data for file %s%s%s: objId High/Low %d-%d, poolId %d, iMediaClass %d\n",
1623  cModule, pObjAttr->cNamefs, pObjAttr->cNamehl,
1624  pObjAttr->cNamell, pObjAttr->iObjHigh,
1625  pObjAttr->iObjLow, iPoolId,
1626  iMediaClass);
1627  }
1628  else fprintf(fLogFile,
1629  "-E- %s: inconsistent meta data for file %s%s%s: objId High/Low %d-%d, poolId %d, iMediaClass %d\n",
1630  cModule, pObjAttr->cNamefs, pObjAttr->cNamehl,
1631  pObjAttr->cNamell, pObjAttr->iObjHigh,
1632  pObjAttr->iObjLow, iPoolId, iMediaClass);
1633 
1634  /* in GRC objIds should be available) */
1635 
1636  } /* file not in write cache */
1637  } /* (iObjHigh == 0) && (iObjLow == 0) */
1638  else
1639  {
1640  /* file in TSM storage */
1641  if ( (iMediaClass == GSI_MEDIA_STAGE) ||
1642  (iMediaClass == GSI_MEDIA_LOCKED) ||
1643  (iMediaClass == GSI_MEDIA_INCOMPLETE) )
1644  {
1645  /* also in read cache */
1646  pComm->iPoolIdRC = pObjAttr->iPoolId;
1647  pComm->iStageFSid = pObjAttr->iFS;
1648  strcpy(pComm->cNodeRC, pObjAttr->cNode);
1649  }
1650  else
1651  {
1652  pComm->iPoolIdRC = htonl(0);
1653  pComm->iStageFSid = htonl(0);
1654  strcpy(pComm->cNodeRC, "");
1655  }
1656  }
1657  } /* (iQuery == 1) */
1658 
1659  iVersionObjAttr = ntohl(pObjAttr->iVersion);
1660  if ( (iVersionObjAttr != VERSION_SRAWOBJATTR) &&
1661  (iVersionObjAttr != VERSION_SRAWOBJATTR-1) )
1662  {
1663  fprintf(fLogFile,
1664  "-E- %d: %s%s%s has invalid cacheDB entry version %d\n",
1665  ii, pObjAttr->cNamefs, pObjAttr->cNamehl,
1666  pObjAttr->cNamell, iVersionObjAttr);
1667 
1668  continue;
1669  }
1670 
1671  pObjAttr++;
1672 
1673  } /* object loop */
1674  } /* (iQuery > 0) */
1675  else if ( (iQuery == 0) && (iDebug) )
1676  fprintf(fLogFile, " no objs found\n");
1677 
1678  /* if object explicitly specified, stop query if found */
1679  if ( (strchr(pComm->cNamell, *pcStar) == NULL) &&
1680  (strchr(pComm->cNamell, *pcQM) == NULL) &&
1681  (strchr(pComm->cNamell, *pcPerc) == NULL) &&
1682  (strchr(pComm->cNamehl, *pcStar) == NULL) &&
1683  (strchr(pComm->cNamehl, *pcQM) == NULL) &&
1684  (strchr(pComm->cNamehl, *pcPerc) == NULL) )
1685  iNameVar = 0;
1686  else
1687  iNameVar = 1;
1688 
1689  if ( (iNameVar == 0) && (iQueryAll > 0) ) /* fixed name, found */
1690  goto gEndQueryFile;
1691 
1692  if ( (iIdent == IDENT_QUERY) || (iIdent == IDENT_QUERY_ARCHDB) )
1693  goto gNextReply;
1694 
1695 gEndQueryFile:
1696  switch (iQueryAll)
1697  {
1698  case 0:
1699  if (iDebug) fprintf(fLogFile,
1700  " no matching object %s%s%s in gStore found\n",
1701  pComm->cNamefs, pComm->cNamehl, pComm->cNamell);
1702  break;
1703  case 1:
1704  if (iDebug) fprintf(fLogFile,
1705  " file %s%s%s available in gStore\n",
1706  pObjAttr->cNamefs, pComm->cNamehl, pComm->cNamell);
1707  break;
1708  case -1:
1709  fprintf(fLogFile,
1710  "-E- %s: query in gStore could not be executed\n",
1711  cModule);
1712  break;
1713  case -1000:
1714  if (iDebug) fprintf(fLogFile,
1715  " requested archive %s not existing in gStore\n",
1716  pComm->cNamefs);
1717  break;
1718  case -1001:
1719  if (iDebug) fprintf(fLogFile,
1720  " access to requested file %s%s%s not allowed\n",
1721  pObjAttr->cNamefs, pComm->cNamehl, pComm->cNamell);
1722  break;
1723  default:
1724  if ( (iQueryAll > 1) && (iNameVar == 0) )
1725  {
1726  fprintf(fLogFile, " %d versions of %s%s exist!\n",
1727  iQueryAll, pComm->cNamehl, pComm->cNamell);
1728  }
1729  } /* switch (iQueryAll) */
1730 
1731  if (iDebug)
1732  {
1733  fprintf(fLogFile, "-D- end %s\n\n", cModule);
1734  fflush(fLogFile);
1735  }
1736 
1737  return iQueryAll;
1738 
1739 } /* end rawQueryFile */
1740 
1741 /*********************************************************************/
1742 /* rawRecvError: receive error message */
1743 /* returns length of error message */
1744 /* */
1745 /* created 14. 3.96, Horst Goeringer */
1746 /*********************************************************************/
1747 
1748 int rawRecvError(int iSocket, int iLen, char *pcMsg)
1749 {
1750  char cModule[32]="rawRecvError";
1751  int iDebug = 0;
1752 
1753  int iRC = 0, ii;
1754  int iBuf, iBufs;
1755  char *pcc;
1756 
1757  if (iDebug)
1758  fprintf(fLogFile, "\n-D- begin %s\n", cModule);
1759 
1760  strcpy(pcMsg, "");
1761  pcc = pcMsg; /* points now to buffer in calling procedure */
1762 
1763  iBuf = iLen; /* length of error message */
1764  iBufs = iBuf;
1765  while(iBuf > 0)
1766  {
1767  if ( (iRC = recv(iSocket, pcc, (unsigned) iBuf, 0 )) <= 0 )
1768  {
1769  if (iRC < 0)
1770  {
1771  fprintf(fLogFile,
1772  "-E- %s: receiving error message\n", cModule);
1773 
1774  if (errno)
1775  {
1776  fprintf(fLogFile, " %s\n", strerror(errno));
1777  errno = 0;
1778  }
1779 
1780  iRC = -9;
1781  break;
1782  }
1783  else
1784  {
1785  ii = iLen - iBuf;
1786  if (ii) /* append delimiters after part of message received */
1787  {
1788  *pcc = '\0'; /* delimit message string */
1789  pcc++;
1790  *pcc = '\n';
1791  pcc++;
1792  if (iDebug) fprintf(fLogFile,
1793  "-E- incomplete error message received:\n %s", pcMsg);
1794  }
1795  fprintf(fLogFile,
1796  "-E- %s: connection to sender broken, %d byte of error message (%d byte) received\n",
1797  cModule, ii, iLen);
1798 
1799  if (errno)
1800  {
1801  fprintf(fLogFile, " %s\n", strerror(errno));
1802  errno = 0;
1803  }
1804 
1805  iRC = -8;
1806  break;
1807  }
1808  }
1809 
1810  iBuf -= iRC;
1811  pcc += iRC;
1812 
1813  } /* while(iBuf > 0) */
1814 
1815  if (iBuf < 0)
1816  {
1817  fprintf(fLogFile,
1818  "-E- %s: more error data received than expected:\n %s",
1819  pcMsg, cModule);
1820  iRC = -2;
1821  }
1822 
1823  if (iRC == -9)
1824  {
1825  if (iDebug)
1826  fprintf(fLogFile, "-D- end %s\n\n", cModule);
1827 
1828  return iRC;
1829  }
1830  else
1831  {
1832  /* also okay if no message (iLen = 0) */
1833  *pcc = '\0'; /* delimit message string */
1834 
1835  /* only msg part received */
1836  if (iRC == -8)
1837  iBufs = ii;
1838 
1839  if (iDebug)
1840  {
1841  fprintf(fLogFile,
1842  " error message received (%d bytes):\n %s",
1843  iBufs, pcMsg);
1844  fprintf(fLogFile, "-D- end %s\n\n", cModule);
1845  }
1846 
1847  return iBufs;
1848  }
1849 
1850 } /* rawRecvError */
1851 
1852 /*********************************************************************
1853  * rawRecvHead: receive common buffer header
1854  * returns no. of bytes received or error (< 0)
1855  *
1856  * created 5. 3.96, Horst Goeringer
1857  *********************************************************************
1858  */
1859 
1860 int rawRecvHead( int iSocket, char *pcBuf)
1861 {
1862  char cModule[32]="rawRecvHead";
1863  int iDebug = 0;
1864 
1865  int iBuf, iBufs;
1866  int iRC, ii;
1867  int iIdent;
1868  int iStatus;
1869  int iDataLen;
1870  char *pcc;
1871  int *pint;
1872 
1873  if (iDebug)
1874  {
1875  fprintf(fLogFile, "\n-D- begin %s: socket %d\n", cModule, iSocket);
1876  fflush(fLogFile);
1877  }
1878 
1879  strcpy(pcBuf, "");
1880  pcc = pcBuf; /* points now to buffer in calling procedure */
1881  pint = (int *) pcc;
1882 
1883  iBuf = HEAD_LEN;
1884  iBufs = iBuf;
1885  while(iBuf > 0)
1886  {
1887  iRC = recv(iSocket, pcc, (unsigned) iBuf, 0);
1888  if (iRC <= 0)
1889  {
1890  if (iRC < 0) fprintf(fLogFile,
1891  "-E- %s: receiving buffer header\n", cModule);
1892  else
1893  {
1894  ii = iBufs - iBuf;
1895  fprintf(fLogFile,
1896  "-W- %s: connection to sender broken, %d byte of buffer header (%d byte) received\n",
1897  cModule, ii, iBufs);
1898  }
1899 
1900  if (errno)
1901  {
1902  fprintf(fLogFile, " %s\n", strerror(errno));
1903  errno = 0;
1904  }
1905 
1906  return -1;
1907  }
1908 
1909  iBuf -= iRC;
1910  pcc += iRC;
1911 
1912  } /* while(iBuf > 0) */
1913 
1914  iIdent = ntohl(*pint);
1915  pint++;
1916  iStatus = ntohl(*pint);
1917  pint++;
1918  iDataLen = ntohl(*pint);
1919  if (iDebug) fprintf(fLogFile,
1920  " ident %d, status %d, datalen %d\n",
1921  iIdent, iStatus, iDataLen);
1922 
1923  if ( (iIdent == IDENT_STATUS) &&
1924  ((iStatus == STA_ERROR) || (iStatus == STA_ERROR_EOF)) &&
1925  (iDataLen > 0) )
1926  {
1927  if (iDebug) fprintf(fLogFile,
1928  "-W- %s: error message available for receive (%d byte)\n",
1929  cModule, iDataLen);
1930  return iDataLen;
1931  }
1932 
1933  if (iDebug)
1934  {
1935  fprintf(fLogFile,
1936  "-D- end %s: buffer header received (%d bytes)\n\n",
1937  cModule, iBufs);
1938  fflush(fLogFile);
1939  }
1940 
1941  return iBufs;
1942 
1943 } /* rawRecvHead */
1944 
1945 /*********************************************************************
1946  * rawRecvHeadC: receive common buffer header and check
1947  * return values:
1948  * >= 0: no error occurred:
1949  * = HEAD_LEN: header received (and okay)
1950  * > HEAD_LEN: status message of this size in pcMsg
1951  * = 0: error status received, but no message
1952  *
1953  * < 0: error occurred:
1954  * = -1: recv failed
1955  * = -2: connection to sender lost
1956  * = -3: receiving error msg failed
1957  * = -4: unexpected identifier received
1958  * = -5: unexpected status received
1959  *
1960  * created 7. 3.2002, Horst Goeringer
1961  *********************************************************************
1962  */
1963 
1964 int rawRecvHeadC(int iSocket,
1965  char *pcBuf,
1966  int iIdentReq, /* < 0 => check, >= 0 => no check */
1967  int iStatusReq, /* >= 0 => check, < 0 => no check */
1968  char *pcMsg)
1969 {
1970  char cModule[32] = "rawRecvHeadC";
1971  int iDebug = 0;
1972 
1973  /* header to be received */
1974  int iIdent;
1975  int iStatus;
1976  int iDataLen;
1977 
1978  char cMsg1[STATUS_LEN] = "";
1979 
1980  int iRC, ii;
1981  int iBuf, iBufs;
1982  char *pcc;
1983  int *pint;
1984 
1985  if (iDebug)
1986  {
1987  fprintf(fLogFile, "\n-D- begin %s\n", cModule);
1988 
1989  if (iIdentReq < 0) fprintf(fLogFile,
1990  " check Ident, expect %d\n", iIdentReq);
1991  else
1992  fprintf(fLogFile, " no check of Ident\n");
1993  if (iStatusReq >= 0) fprintf(fLogFile,
1994  " check Status, expect %d\n", iStatusReq);
1995  else
1996  fprintf(fLogFile, " no check of Status\n");
1997  }
1998 
1999  strcpy(pcMsg, "");
2000  strcpy(pcBuf, "");
2001  pcc = pcBuf; /* points now to buffer in calling procedure */
2002 
2003  iBuf = HEAD_LEN;
2004  iBufs = iBuf;
2005  while(iBuf > 0)
2006  {
2007  if ( (iRC = recv( iSocket, pcc, (unsigned) iBuf, 0 )) <= 0 )
2008  {
2009  if (iRC < 0)
2010  {
2011  sprintf(pcMsg, "-E- %s: receiving buffer header\n",
2012  cModule);
2013  iRC = -1;
2014  }
2015  else
2016  {
2017  ii = iBufs - iBuf;
2018  sprintf(pcMsg,
2019  "-W- %s: connection to sender broken, %d byte of buffer header (%d byte) received\n",
2020  cModule, ii, iBufs);
2021  iRC = -2;
2022  }
2023 
2024  if (errno)
2025  {
2026  sprintf(cMsg1, " %s\n", strerror(errno));
2027  strcat(pcMsg, cMsg1);
2028  errno = 0;
2029  }
2030 
2031  if (iDebug)
2032  fprintf(fLogFile, "%s", pcMsg);
2033 
2034  goto gEndRecvHeadC;
2035  }
2036 
2037  iBuf -= iRC;
2038  pcc += iRC;
2039 
2040  } /* while(iBuf > 0) */
2041 
2042  if (iDebug) fprintf(fLogFile,
2043  " buffer header received (%d bytes)\n", iBufs);
2044 
2045  pint = (int *) pcBuf;
2046  iIdent = ntohl(*pint);
2047  pint++;
2048  iStatus = ntohl(*pint);
2049  pint++;
2050  iDataLen = ntohl(*pint);
2051 
2052  if (iDebug) fprintf(fLogFile,
2053  " ident %d, status %d, datalen %d\n",
2054  iIdent, iStatus, iDataLen);
2055 
2056  if (iIdent == IDENT_STATUS)
2057  {
2058  if (iDebug)
2059  {
2060  fprintf(fLogFile, " status received");
2061  if ( (iDataLen) &&
2062  ((iStatus == STA_ERROR) || (iStatus == STA_ERROR_EOF)) )
2063  fprintf(fLogFile, " with error message\n");
2064  else
2065  fprintf(fLogFile, "\n");
2066  }
2067 
2068  if ( (iDataLen) &&
2069  ((iStatus == STA_ERROR) || (iStatus == STA_ERROR_EOF) ||
2070  (iStatus == STA_CACHE_FULL)) )
2071  {
2072  pcc = cMsg1;
2073  iRC = rawRecvError(iSocket, iDataLen, pcc);
2074  if (iRC < 0)
2075  {
2076  sprintf(pcMsg, "-E- %s: receiving error msg, rc=%d\n",
2077  cModule, iRC);
2078  if (iDebug)
2079  fprintf(fLogFile, "%s", pcMsg);
2080 
2081  iRC = -3;
2082  goto gEndRecvHeadC;
2083  }
2084 
2085  if (iDebug) fprintf(fLogFile,
2086  " msg (%d byte): %s\n", iDataLen, pcc);
2087  strcat(pcMsg, pcc);
2088  iRC = strlen(pcMsg);
2089  goto gEndRecvHeadC;
2090  }
2091 
2092  if ( (iDataLen == 0) &&
2093  ((iStatus == STA_ERROR) || (iStatus == STA_ERROR_EOF)) )
2094  {
2095  strcat(pcMsg,
2096  "-W- error status received, but no error message\n");
2097  iRC = 0;
2098  goto gEndRecvHeadC;
2099  }
2100  } /* (iIdent == IDENT_STATUS) */
2101 
2102  if (iIdentReq < 0) /* test for expected identifier, values < 0 */
2103  {
2104  if (iDebug)
2105  fprintf(fLogFile, " check identifier\n");
2106 
2107  if (iIdent != iIdentReq)
2108  {
2109  sprintf(pcMsg,
2110  "-E- %s: unexpected header (ident %d) received\n",
2111  cModule, iIdent);
2112  if (iDebug)
2113  fprintf(fLogFile, "%s", pcMsg);
2114 
2115  iRC = -4;
2116  goto gEndRecvHeadC;
2117 
2118  } /* unexpected ident) */
2119  else
2120  {
2121  if (iStatusReq >= 0) /* test for expected status */
2122  {
2123  if (iDebug)
2124  fprintf(fLogFile, " check status\n");
2125 
2126  if (iStatusReq != iStatus)
2127  {
2128  sprintf(pcMsg,
2129  "-E- %s: unexpected header (status %d) received\n",
2130  cModule, iStatus);
2131  if (iDebug)
2132  fprintf(fLogFile, "%s", pcMsg);
2133 
2134  iRC = -5;
2135  goto gEndRecvHeadC;
2136  }
2137  }
2138  } /* expected ident */
2139  } /* check ident requested */
2140 
2141  iRC = HEAD_LEN;
2142 
2143 gEndRecvHeadC:
2144  if (iDebug)
2145  fprintf(fLogFile, "-D- end %s\n\n", cModule);
2146 
2147  return iRC;
2148 
2149 } /* rawRecvHeadC */
2150 
2151 /*********************************************************************
2152  * rawRecvRequest:
2153  * receive request for next buffer and convert to host format
2154  * returns 0: request received
2155  * 2: EOF status received
2156  * 3: EOS status received
2157  * 4, 5: error status received
2158  * < 0: error occured
2159  *
2160  * created 21.12.2000, Horst Goeringer
2161  *********************************************************************
2162  */
2163 
2164 int rawRecvRequest(int iSocket,
2165  int *piSeekMode,
2166  int *piOffset,
2167  int *piBufferSize)
2168 {
2169  char cModule[32]="rawRecvRequest";
2170  int iDebug = 0;
2171 
2172  int iRC;
2173  int iError = 0;
2174  int iRequSize = sizeof(srawRequest);
2175  int iBuf, iBuf0;
2176  int ii, iimax;
2177  char *pcc;
2178  char cMsg[STATUS_LEN] = ""; /* error msg received */
2179 
2180  srawRequest sRequest, *pRequest;
2181 
2182  if (iDebug) fprintf(fLogFile,
2183  "\n-D- begin %s: receive request buffer\n", cModule);
2184 
2185  pRequest = &sRequest;
2186  pcc = (char *) pRequest;
2187  iBuf = HEAD_LEN;
2188  iimax = HEAD_LEN;
2189  while(iBuf > 0)
2190  {
2191  if ( (iRC = recv( iSocket, pcc, (unsigned) iBuf, 0 )) <= 0 )
2192  {
2193  if (iRC < 0)
2194  {
2195  fprintf(fLogFile,
2196  "-E- %s: receiving buffer header\n", cModule);
2197  iError = -1;
2198  }
2199  else
2200  {
2201  ii = iimax - iBuf;
2202  fprintf(fLogFile,
2203  "-W- %s: connection to sender broken, %d byte of buffer header (%d byte) received\n",
2204  cModule, ii, iimax);
2205  iError = -5;
2206  }
2207 
2208  goto gErrorRecvRequest;
2209  }
2210 
2211  iBuf -= iRC;
2212  pcc += iRC;
2213 
2214  } /* while(iBuf > 0) */
2215 
2216  if (iBuf < 0)
2217  {
2218  fprintf(fLogFile,
2219  "-E- %s: more buffer header data received than expected\n",
2220  cModule);
2221 
2222  iError = -2;
2223  goto gErrorRecvRequest;
2224  }
2225 
2226  pRequest->iIdent = ntohl(pRequest->iIdent);
2227  if (iDebug) fprintf(fLogFile,
2228  " buffer header received (%d bytes, id %d)\n",
2229  iimax, pRequest->iIdent);
2230 
2231  if ( (pRequest->iIdent != IDENT_NEXT_BUFFER) &&
2232  (pRequest->iIdent != IDENT_STATUS) )
2233  {
2234  fprintf(fLogFile, "-E- %s: invalid buffer received (id %d)\n",
2235  cModule, pRequest->iIdent);
2236  iError = -3;
2237  goto gErrorRecvRequest;
2238  }
2239 
2240  pRequest->iStatus = ntohl(pRequest->iStatus);
2241  pRequest->iStatusLen = ntohl(pRequest->iStatusLen);
2242  iBuf0 = pRequest->iStatusLen;
2243  iBuf = iBuf0;
2244  if (pRequest->iIdent != IDENT_NEXT_BUFFER)
2245  pcc = cMsg; /* more space needed */
2246 
2247  while(iBuf > 0)
2248  {
2249  if ( (iRC = recv( iSocket, pcc, (unsigned) iBuf, 0 )) <= 0 )
2250  {
2251  if (iRC < 0)
2252  {
2253  fprintf(fLogFile,
2254  "-E- %s: receiving buffer data\n", cModule);
2255  iError = -1;
2256  }
2257  else
2258  {
2259  ii = iBuf0 - iBuf;
2260  fprintf(fLogFile,
2261  "-W- %s: connection to sender broken, %d byte of data (%d byte) received\n",
2262  cModule, ii, iBuf0);
2263  iError = -5;
2264  }
2265 
2266  if (errno)
2267  {
2268  fprintf(fLogFile, " %s\n", strerror(errno));
2269  errno = 0;
2270  }
2271 
2272  goto gErrorRecvRequest;
2273  }
2274 
2275  iBuf -= iRC;
2276  pcc += iRC;
2277 
2278  } /* while(iBuf > 0) */
2279 
2280  if (iBuf < 0)
2281  {
2282  fprintf(fLogFile, "-E- %s: more data received than expected\n",
2283  cModule);
2284  iError = -2;
2285  goto gErrorRecvRequest;
2286  }
2287 
2288  if (pRequest->iIdent == IDENT_NEXT_BUFFER)
2289  {
2290  if (iDebug) fprintf(fLogFile,
2291  " %s: request data received (%d bytes)\n", cModule, iBuf0);
2292 
2293  if (iBuf0 + HEAD_LEN != iRequSize)
2294  {
2295  fprintf(fLogFile,
2296  "-E- %s: invalid data size (%d) in request buffer (expected %d byte)\n",
2297  cModule, iBuf0, iRequSize-HEAD_LEN);
2298  iError = -4;
2299  goto gErrorRecvRequest;
2300  }
2301 
2302  *piSeekMode = ntohl(pRequest->iSeekMode);
2303  *piOffset = ntohl(pRequest->iOffset);
2304  *piBufferSize = ntohl(pRequest->iBufferSize);
2305 
2306  if (iDebug)
2307  fprintf(fLogFile, "-D- end %s\n\n", cModule);
2308 
2309  return 0;
2310 
2311  } /* (pRequest->iIdent == IDENT_NEXT_BUFFER) */
2312  else if (pRequest->iIdent == IDENT_STATUS)
2313  {
2314  if ( (pRequest->iStatus == STA_END_OF_FILE) ||
2315  (pRequest->iStatus == STA_END_OF_SESSION) )
2316  {
2317  if (iDebug) fprintf(fLogFile,
2318  " %s: status info received: end session\n", cModule);
2319  }
2320  else if ( (pRequest->iStatus == STA_ERROR) ||
2321  (pRequest->iStatus == STA_ERROR_EOF) )
2322 
2323  {
2324  if (iDebug) fprintf(fLogFile,
2325  "-W- %s: error status received: end session\n", cModule);
2326  if (iBuf0 > 0) fprintf(fLogFile,
2327  "-W- %s: error message from client:\n %s\n",
2328  cModule, cMsg);
2329  iError = -4;
2330  goto gErrorRecvRequest;
2331  }
2332  else
2333  {
2334  fprintf(fLogFile,
2335  "-E- %s: invalid status buffer received (id %d)\n",
2336  cModule, pRequest->iStatus);
2337  iError = -3;
2338  goto gErrorRecvRequest;
2339  }
2340 
2341  iError = pRequest->iStatus;
2342  goto gErrorRecvRequest;
2343 
2344  } /* (pRequest->iIdent == IDENT_STATUS) */
2345  else
2346  {
2347  fprintf(fLogFile, "-E- %s: invalid buffer received (ident %d)\n",
2348  cModule, pRequest->iIdent);
2349  iError = -2;
2350  goto gErrorRecvRequest;
2351  }
2352 
2353 gErrorRecvRequest:
2354  if (iDebug)
2355  fprintf(fLogFile, "-D- end %s\n\n", cModule);
2356 
2357  if (iError)
2358  return iError;
2359 
2360  return 0;
2361 
2362 } /* rawRecvRequest */
2363 
2364 /*********************************************************************
2365  * rawRecvStatus: receive status header
2366  * returns no. of bytes received or error (< 0)
2367  * status header will be converted to host format
2368  *
2369  * created 18. 3.96, Horst Goeringer
2370  *********************************************************************
2371  */
2372 
2373 int rawRecvStatus(int iSocket, srawStatus *psStatus)
2374 {
2375  char cModule[32]="rawRecvStatus";
2376  int iDebug = 0;
2377 
2378  int iRC, ii;
2379  int iBuf, iBufs;
2380  int iLen;
2381  char *pcc;
2382 
2383  if (iDebug)
2384  fprintf(fLogFile, "\n-D- begin %s\n", cModule);
2385 
2386  /* clear status structure */
2387  memset(psStatus, 0X00, sizeof(srawStatus));
2388 
2389  pcc = (char *) psStatus;
2390  iBuf = HEAD_LEN;
2391  iBufs = iBuf;
2392 
2393  while(iBuf > 0)
2394  {
2395  iRC = recv( iSocket, pcc, (unsigned) iBuf, 0 );
2396  if (iRC <= 0 )
2397  {
2398  if (iRC < 0) fprintf(fLogFile,
2399  "-E- %s: receiving status header\n", cModule);
2400  else
2401  {
2402  ii = iBufs - iBuf;
2403  fprintf(fLogFile,
2404  "-W- %s: connection to sender broken, %d byte of status header (%d byte) received\n",
2405  cModule, ii, iBufs);
2406  }
2407 
2408  if (errno)
2409  {
2410  fprintf(fLogFile, " %s\n", strerror(errno));
2411  errno = 0;
2412  }
2413 
2414  return -1;
2415  }
2416 
2417  iBuf -= iRC;
2418  pcc += iRC;
2419  fflush(fLogFile);
2420 
2421  } /* while(iBuf > 0) */
2422 
2423  if (iBuf < 0)
2424  {
2425  fprintf(fLogFile,
2426  "-E- %s: more status header data received than expected\n",
2427  cModule);
2428  return -2;
2429  }
2430 
2431  psStatus->iIdent = ntohl(psStatus->iIdent);
2432  psStatus->iStatus = ntohl(psStatus->iStatus);
2433  psStatus->iStatusLen = ntohl(psStatus->iStatusLen);
2434 
2435  if (iDebug)
2436  {
2437  fprintf(fLogFile, " status header received (%d bytes)\n",
2438  iBufs);
2439  fprintf(fLogFile, " ident %d, status %d, status len %d\n",
2440  psStatus->iIdent, psStatus->iStatus, psStatus->iStatusLen);
2441  fflush(fLogFile);
2442  }
2443 
2444  if (psStatus->iIdent != IDENT_STATUS)
2445  {
2446  fprintf(fLogFile, "-E- %s: invalid status header received (%d)\n",
2447  cModule, psStatus->iIdent);
2448  return -3;
2449  }
2450 
2451  iLen = psStatus->iStatusLen;
2452  if (iLen > 0)
2453  {
2454  iBuf = iLen; /* length of status message */
2455  iBufs += iBuf;
2456  while(iBuf > 0)
2457  {
2458  if ( (iRC = recv( iSocket, pcc, (unsigned) iBuf, 0 )) <= 0 )
2459  {
2460  if (iRC < 0) fprintf(fLogFile,
2461  "-E- %s: receiving status message\n", cModule);
2462  else
2463  {
2464  ii = iLen - iBuf;
2465  fprintf(fLogFile,
2466  "-W- %s: connection to sender broken, %d byte of status message (%d byte) received\n",
2467  cModule, ii, iLen);
2468  }
2469 
2470  if (errno)
2471  {
2472  fprintf(fLogFile, " %s\n", strerror(errno));
2473  errno = 0;
2474  }
2475 
2476  return -4;
2477  }
2478 
2479  iBuf -= iRC;
2480  pcc += iRC;
2481 
2482  } /* while(iBuf > 0) */
2483 
2484  if (iBuf < 0)
2485  {
2486  fprintf(fLogFile,
2487  "-E- %s: more status data received than expected\n",
2488  cModule);
2489  return -5;
2490  }
2491 
2492  if (iDebug) fprintf(fLogFile,
2493  " status message received (%d bytes):\n%s\n",
2494  iLen, psStatus->cStatus);
2495  fflush(fLogFile);
2496 
2497  } /* iLen > 0 */
2498 
2499  if (iDebug)
2500  fprintf(fLogFile, "-D- end %s\n\n", cModule);
2501 
2502  return iBufs;
2503 
2504 } /* rawRecvStatus */
2505 
2506 /*********************************************************************
2507  * rawSendRequest: send request buffer
2508  * returns 0 or error (< 0)
2509  * status header will be converted to net format
2510  *
2511  * created 21.12.2000, Horst Goeringer
2512  *********************************************************************
2513  */
2514 
2515 int rawSendRequest(int iSocket,
2516  int iSeekMode,
2517  int iOffset,
2518  int iBufferSize)
2519 {
2520  char cModule[32]="rawSendRequest";
2521  int iDebug = 0;
2522 
2523  int iBuf, iRC;
2524  char *pcc;
2525 
2526  srawRequest sRequest;
2527  int iRequSize = sizeof(srawRequest);
2528 
2529  if (iDebug) fprintf(fLogFile,
2530  "\n-D- begin %s: send request buffer\n", cModule);
2531 
2532  sRequest.iIdent = htonl((unsigned int) IDENT_NEXT_BUFFER);
2533  if (iSeekMode < 0)
2534  sRequest.iStatus = htonl(STA_NEXT_BUFFER);
2535  else
2536  sRequest.iStatus = htonl(STA_SEEK_BUFFER);
2537  sRequest.iStatusLen = htonl(iRequSize - HEAD_LEN);
2538 
2539  sRequest.iSeekMode = htonl(iSeekMode);
2540  sRequest.iOffset = htonl(iOffset);
2541  if (iBufferSize < 0)
2542  {
2543  fprintf(fLogFile,
2544  "-E- %s: invalid buffer size %d\n", cModule, iBufferSize);
2545  return -1;
2546  }
2547  sRequest.iBufferSize = htonl(iBufferSize);
2548 
2549  iBuf = iRequSize;
2550  pcc = (char *) &sRequest;
2551  iRC = send(iSocket, pcc, (unsigned) iBuf, 0);
2552  if (iRC < iBuf)
2553  {
2554  if (iRC < 0) fprintf(fLogFile,
2555  "-E- %s: sending request buffer\n", cModule);
2556  else fprintf(fLogFile,
2557  "-E- %s: request buffer incompletely sent (%d of %d byte)\n",
2558  cModule, iRC, iBuf);
2559 
2560  if (errno)
2561  {
2562  fprintf(fLogFile, " %s\n", strerror(errno));
2563  errno = 0;
2564  }
2565 
2566  return -1;
2567  }
2568 
2569  if (iDebug) fprintf(fLogFile,
2570  "-D- end %s: request buffer sent\n\n", cModule);
2571 
2572  return 0;
2573 
2574 } /* rawSendRequest */
2575 
2576 /*********************************************************************
2577  * rawSendStatus: send status buffer
2578  * returns no. of bytes sent or error (< 0)
2579  * status header will be converted to net format
2580  *
2581  * created 5. 3.96, Horst Goeringer
2582  *********************************************************************
2583  */
2584 
2585 int rawSendStatus( int iSocket, int iStatus, char *pcMsg)
2586 {
2587  char cModule[32]="rawSendStatus";
2588  int iDebug = 0;
2589 
2590  int iBuf = HEAD_LEN;
2591  int iRC, iMsgLen;
2592  char *pcc;
2593  srawStatus sStatus;
2594 
2595  if (iDebug) fprintf(fLogFile,
2596  "\n-D- begin %s: send status buffer (%d) to socket %d\n",
2597  cModule, iStatus, iSocket);
2598 
2599  sStatus.iIdent = htonl((unsigned int) IDENT_STATUS);
2600  sStatus.iStatus = htonl(iStatus);
2601  sStatus.iStatusLen = htonl(0);
2602 
2603  if (pcMsg == NULL)
2604  iMsgLen = 0;
2605  else
2606  iMsgLen = strlen(pcMsg);
2607  if (iMsgLen)
2608  {
2609  iBuf += iMsgLen;
2610  sStatus.iStatusLen = htonl(iMsgLen);
2611  strcpy(sStatus.cStatus, pcMsg);
2612  if (iDebug) fprintf(fLogFile,
2613  " status message (%d bytes):\n %s\n", iMsgLen, pcMsg);
2614  }
2615 
2616  pcc = (char *) &sStatus;
2617  if (iDebug)
2618  {
2619  fprintf(fLogFile,
2620  " now send (iIdent %d, iStatus %d, iStatusLen %d), %d byte:\n",
2621  ntohl(sStatus.iIdent), ntohl(sStatus.iStatus),
2622  ntohl(sStatus.iStatusLen), iBuf);
2623  fflush(fLogFile);
2624  }
2625 
2626  iRC = send(iSocket, pcc, (unsigned) iBuf, 0);
2627  if (iRC < iBuf)
2628  {
2629  if (iRC < 0) fprintf(fLogFile,
2630  "-E- %s: sending status buffer\n", cModule);
2631  else fprintf(fLogFile,
2632  "-E- %s: status buffer incompletely sent (%d of %d byte)\n",
2633  cModule, iRC, iBuf);
2634 
2635  if (errno)
2636  {
2637  fprintf(fLogFile, " %s\n", strerror(errno));
2638  errno = 0;
2639  }
2640 
2641  return -1;
2642  }
2643 
2644  if (iDebug) fprintf(fLogFile,
2645  "-D- end %s: status buffer sent (%d byte)\n\n", cModule, iBuf);
2646 
2647  return(iBuf);
2648 
2649 } /* rawSendStatus */
2650 
2651 /*********************************************************************
2652  * rawTestFileName:
2653  * verify that specified name is a valid file name
2654  * and has no wildcards
2655  * created 15.3.1996, Horst Goeringer
2656  *********************************************************************
2657  */
2658 
2659 int rawTestFileName( char *pcFile)
2660 {
2661  char cModule[32] = "rawTestFileName";
2662  int iDebug = 0;
2663 
2664  int iRC;
2665  int ilen;
2666  int iError = 0;
2667  unsigned long lFileSize = 0; /* dummy for rawGetFileSize */
2668  unsigned int iSize = 0; /* dummy for rawGetFileSize */
2669  char *pdir;
2670 
2671  if (iDebug) fprintf(fLogFile,
2672  "-D- begin %s: input file name %s\n", cModule, pcFile);
2673 
2674  if ( (pdir = strrchr(pcFile, '*')) != NULL)
2675  {
2676  fprintf(fLogFile,
2677  "-E- invalid file name '%s': '*' not allowed as part of file name\n",
2678  pcFile);
2679  iError = 3;
2680  goto gErrorTest;
2681  }
2682 
2683  if ( (pdir = strrchr(pcFile, '?')) != NULL)
2684  {
2685  fprintf(fLogFile,
2686  "-E- invalid file name '%s': '?' not allowed as part of file name\n",
2687  pcFile);
2688  iError = 3;
2689  goto gErrorTest;
2690  }
2691 
2692  if ( (pdir = strrchr(pcFile, '/')) == NULL)
2693  {
2694  if (iDebug)
2695  fprintf(fLogFile, " name %s okay\n", pcFile);
2696  }
2697  else /* name contains '/' */
2698  {
2699  ilen = strlen(pdir);
2700  if (iDebug) fprintf(fLogFile,
2701  " trailor %s (len %d)\n", pdir, ilen);
2702  if (ilen == 1)
2703  {
2704  strncpy(pdir, "\0", 1);
2705  if (iDebug)
2706  fprintf(fLogFile, " %s is a directory\n", pcFile);
2707  iError = 2;
2708  goto gErrorTest;
2709  }
2710  else if (iDebug)
2711  fprintf(fLogFile, " rel name %s okay\n", pcFile);
2712  }
2713 
2714  iRC = rawGetFileSize(pcFile, &lFileSize, &iSize);
2715  if (iDebug) fprintf(fLogFile,
2716  " after rawGetFileSize, rc = %d\n", iRC);
2717 
2718  if (iRC)
2719  {
2720  if (iDebug)
2721  {
2722  fprintf(fLogFile, "-W- %s NOT archived", pcFile);
2723  if (iRC == 1)
2724  fprintf(fLogFile, " - is a directory\n");
2725  else if (iRC == 2)
2726  fprintf(fLogFile, " - is a symbolic link\n");
2727  else if (iRC == 3)
2728  fprintf(fLogFile, " - is not a regular file\n");
2729  else
2730  fprintf(fLogFile, "\n");
2731  }
2732 
2733  iError = 2;
2734  goto gErrorTest;
2735  }
2736 
2737  if (iDebug) fprintf(fLogFile,
2738  " %s is a regular file\n", pcFile);
2739 
2740 gErrorTest:
2741  if (iDebug)
2742  fprintf(fLogFile, "-D- end %s\n\n", cModule);
2743 
2744  return iError;
2745 
2746 } /* rawTestFileName */
2747 
static int ichar
Definition: rawProcn.c:189
int rawTestFileName(char *pcFile)
Definition: rawProcn.c:2659
int rawAddStrings(char *pcMsg1, int iMaxLength1, char *pcMsg2, int iMaxLength2, int iErrno, char *pcMsgE, int iMaxLengthE)
Definition: rawProcn.c:198
static char cPath[MAX_FULL_FILE]
Definition: rawProcn.c:182
int rawRecvError(int iSocket, int iLen, char *pcMsg)
Definition: rawProcn.c:1748
static int iObjAttr
Definition: rawProcn.c:188
int rawRecvHeadC(int iSocket, char *pcBuf, int iIdentReq, int iStatusReq, char *pcMsg)
Definition: rawProcn.c:1964
FILE * fLogFile
Definition: rawapin.c:217
int rawRecvRequest(int iSocket, int *piSeekMode, int *piOffset, int *piBufferSize)
Definition: rawProcn.c:2164
static char cNamefs[MAX_OBJ_FS]
Definition: rawProcn.c:183
int rawRecvHead(int iSocket, char *pcBuf)
Definition: rawProcn.c:1860
int rawSendStatus(int iSocket, int iStatus, char *pcMsg)
Definition: rawProcn.c:2585
int rawSendRequest(int iSocket, int iSeekMode, int iOffset, int iBufferSize)
Definition: rawProcn.c:2515
int rawDelFile(int iSocket, srawComm *psComm)
Definition: rawProcn.c:613
int rawGetFileSize(char *pcFile, unsigned long *piSize, unsigned int *piRecl)
Definition: rawProcn.c:1158
static char * pcNull
Definition: rawProcn.c:185
int rawCheckClientFile(char *pcFullFile, char *pcFile, char *pcTape)
Definition: rawProcn.c:364
char * rawGetPathName(char *pcNamehl)
Definition: rawProcn.c:1274
int rawQueryFile(int iSocket, int iAltMaster, srawComm *pCommBuf, void **pQueryBuf)
Definition: rawProcn.c:1319
char * rawGetHLName(char *pcPath)
Definition: rawProcn.c:1028
char * rawGetFSpName(char *pcUser)
Definition: rawProcn.c:971
int rawDelList(int iSocketMaster, int iDataMover, srawDataMoverAttr *pDataMover0, srawComm *psComm, char **pcFileList, char **pcObjList)
Definition: rawProcn.c:724
int rawGetLLName(char *pcFile, const char *pcDelimiter, char *pcObject)
Definition: rawProcn.c:1107
int rawRecvStatus(int iSocket, srawStatus *psStatus)
Definition: rawProcn.c:2373
static char cNamehl[MAX_OBJ_HL]
Definition: rawProcn.c:184
static int iATLServer
Definition: rawapin.c:246
#define GSI_CACHE_COPY
Definition: rawapitd-gsin.h:31
#define GSI_CACHE_LOCKED
Definition: rawapitd-gsin.h:28
#define GSI_CACHE_INCOMPLETE
Definition: rawapitd-gsin.h:29
#define GSI_MEDIA_STAGE
Definition: rawapitd-gsin.h:23
#define GSI_MEDIA_INCOMPLETE
Definition: rawapitd-gsin.h:25
#define GSI_MEDIA_CACHE
Definition: rawapitd-gsin.h:27
#define GSI_MEDIA_LOCKED
Definition: rawapitd-gsin.h:24
bool_t
Definition: rawapitd.h:29
@ bFalse
Definition: rawapitd.h:30
@ bTrue
Definition: rawapitd.h:31
#define IDENT_QUERY
Definition: rawcommn.h:363
@ STA_NEXT_BUFFER
Definition: rawcommn.h:548
@ STA_ARCHIVE_NOT_AVAIL
Definition: rawcommn.h:564
@ STA_SEEK_BUFFER
Definition: rawcommn.h:555
@ STA_ERROR_EOF
Definition: rawcommn.h:552
@ STA_END_OF_FILE
Definition: rawcommn.h:549
@ STA_NO_ACCESS
Definition: rawcommn.h:565
@ STA_END_OF_SESSION
Definition: rawcommn.h:550
@ STA_CACHE_FULL
Definition: rawcommn.h:561
@ STA_ERROR
Definition: rawcommn.h:551
#define MAX_FULL_FILE
Definition: rawcommn.h:327
#define IDENT_STATUS
Definition: rawcommn.h:362
#define IDENT_QUERY_ARCHDB
Definition: rawcommn.h:374
#define MAX_OBJ_LL
Definition: rawcommn.h:338
#define VERSION_SRAWOBJATTR
Definition: rawcommn.h:331
#define HEAD_LEN
Definition: rawcommn.h:355
#define MAX_OBJ_HL
Definition: rawcommn.h:337
#define STATUS_LEN
Definition: rawcommn.h:356
#define IDENT_QUERY_DONE
Definition: rawcommn.h:379
#define MAX_OBJ_FS
Definition: rawcommn.h:335
#define IDENT_NEXT_BUFFER
Definition: rawcommn.h:366
@ QUERY
Definition: rawcommn.h:432
@ QUERY_REMOVE
Definition: rawcommn.h:435
@ QUERY_RETRIEVE_RECORD
Definition: rawcommn.h:452
@ QUERY_REMOVE_MGR
Definition: rawcommn.h:436
@ REMOVE
Definition: rawcommn.h:428
@ QUERY_STAGE
Definition: rawcommn.h:445
@ QUERY_ARCHIVE_OVER
Definition: rawcommn.h:449
@ QUERY_ARCHIVE
Definition: rawcommn.h:433
@ QUERY_ARCHIVE_TO_CACHE
Definition: rawcommn.h:450
@ QUERY_ARCHIVE_MGR
Definition: rawcommn.h:434
@ QUERY_RETRIEVE
Definition: rawcommn.h:448
@ QUERY_ARCHIVE_RECORD
Definition: rawcommn.h:455
#define MAX_TAPE_FILE
Definition: rawcommn.h:329
static const char * pcQM
Definition: rawdefn.h:65
static const char * pcDevDelim
Definition: rawdefn.h:31
static const char * pcPerc
Definition: rawdefn.h:66
static const char * pcStar
Definition: rawdefn.h:64
char cNamefs[MAX_OBJ_FS]
Definition: rawcommn.h:492
int iATLServer
Definition: rawcommn.h:518
char cNodeWC[MAX_NODE]
Definition: rawcommn.h:526
int iFSidWC
Definition: rawcommn.h:527
unsigned int iObjHigh
Definition: rawcommn.h:503
int iPoolIdRC
Definition: rawcommn.h:522
unsigned int iObjLow
Definition: rawcommn.h:504
char cNamehl[MAX_OBJ_HL]
Definition: rawcommn.h:493
int iStageFSid
Definition: rawcommn.h:524
int iPoolIdWC
Definition: rawcommn.h:525
char cNamell[MAX_OBJ_LL]
Definition: rawcommn.h:494
int iAction
Definition: rawcommn.h:490
char cNodeRC[MAX_NODE]
Definition: rawcommn.h:523
int iCommLen
Definition: rawcommn.h:491
char cNode[MAX_NODE]
Definition: rawcommn.h:752
char cFile[MAX_FULL_FILE]
Definition: rawcommn.h:483
char cNamefs[MAX_OBJ_FS]
Definition: rawcommn.h:633
char cNamehl[MAX_OBJ_HL]
Definition: rawcommn.h:634
unsigned int iObjHigh
Definition: rawcommn.h:645
int iVersion
Definition: rawcommn.h:631
int iMediaClass
Definition: rawcommn.h:644
int iPoolId
Definition: rawcommn.h:656
char cNode[MAX_NODE]
Definition: rawcommn.h:667
char cNamell[MAX_OBJ_LL]
Definition: rawcommn.h:635
unsigned int iObjLow
Definition: rawcommn.h:646
int iOffset
Definition: rawcommn.h:594
int iStatus
Definition: rawcommn.h:588
int iBufferSize
Definition: rawcommn.h:595
int iIdent
Definition: rawcommn.h:587
int iSeekMode
Definition: rawcommn.h:590
int iStatusLen
Definition: rawcommn.h:589
char cMoverStage[MAX_NODE]
Definition: rawclin.h:148
char cNamell[MAX_OBJ_LL]
Definition: rawclin.h:134
int iStageFS
Definition: rawclin.h:149
char cMoverCache[MAX_NODE]
Definition: rawclin.h:151
int iATLServer
Definition: rawclin.h:146
unsigned int iObjLow
Definition: rawclin.h:136
char cOwner[MAX_OWNER]
Definition: rawclin.h:154
int iCacheFS
Definition: rawclin.h:152
unsigned int iObjHigh
Definition: rawclin.h:135
char cArchiveDate[MAX_DATE]
Definition: rawclin.h:153
int iPoolIdRC
Definition: rawclin.h:147
char cNamehl[MAX_OBJ_HL]
Definition: rawclin.h:133
int iStatus
Definition: rawcommn.h:580
int iStatusLen
Definition: rawcommn.h:581
int iIdent
Definition: rawcommn.h:579
char cStatus[STATUS_LEN]
Definition: rawcommn.h:582