]> jspc29.x-matter.uni-frankfurt.de Git - daqdata.git/commitdiff
Replaced by Files called ansiTape*.[ch].
authorhades <hades>
Sun, 21 May 2000 18:08:44 +0000 (18:08 +0000)
committerhades <hades>
Sun, 21 May 2000 18:08:44 +0000 (18:08 +0000)
hadaq/tape.c [deleted file]
hadaq/tape.h [deleted file]
hadaq/tapechar.c [deleted file]
hadaq/tapechar.h [deleted file]
hadaq/tapelabel.c [deleted file]
hadaq/tapelabel.h [deleted file]

diff --git a/hadaq/tape.c b/hadaq/tape.c
deleted file mode 100644 (file)
index cefee9c..0000000
+++ /dev/null
@@ -1,170 +0,0 @@
-/* For allocMem(), freeMem() */
-#include <hadesstd.h>
-/* For msglog() */
-#include <hadesstd.h>
-#include <errno.h>
-
-/* For fdopen(), fclose(), sscanf(), printf() */
-#include <stdio.h>
-/* For open() */
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-/* For read(), close() */
-#include <unistd.h>
-/* For st */
-#include <sys/ioctl.h>
-#include <sys/mtio.h>
-
-#include "tapelabel.h"
-#include "tape.h"
-
-FILE *openTape(const char* filename) {
-#ifdef MTIOCTOP
-       int tape;
-       int fileSeqNum;
-       int stat;
-       int i = 0;
-
-       char *vol;
-       char *label;
-
-       FILE *outFile;
-
-       struct mtop mtoperS, *mtoper = &mtoperS;
-
-       tape = open("/dev/tape", O_RDWR);
-       if(tape == -1) {
-               msglog(LOG_ERR, "Could not open tape!\n");
-               exit(-2);
-       }
-
-       mtoper->mt_op = MTEOM;
-       mtoper->mt_count = 1;
-       stat = ioctl(tape, MTIOCTOP, mtoper);
-       if (stat == -1) {
-                       msglog(LOG_ERR, "Could not go to the eon of the tape!\n");
-                       perror("What went wrong going to the EOM via ioctl?");
-               exit(-2);
-       }
-
-       mtoper->mt_op = MTBSF;
-       mtoper->mt_count = 3;
-       stat = ioctl(tape, MTIOCTOP, mtoper);
-       if (stat == -1) {
-
-               mtoper->mt_op = MTREW;
-               mtoper->mt_count = 1;
-               stat = ioctl(tape, MTIOCTOP, mtoper);
-               if (stat == -1) {
-                       msglog(LOG_ERR, "Could not rewind tape!\n");
-                       exit(-2);
-               }
-
-               vol = readVolumeLabel(tape);
-
-               stat = ioctl(tape, MTIOCTOP, mtoper);
-               if (stat == -1) {
-                       msglog(LOG_ERR, "Could not rewind tape!\n");
-                       exit(-2);
-               }
-
-               writeVolumeLabel(vol, tape);
-               fileSeqNum = 1;
-       } else {
-               mtoper->mt_op = MTFSF;
-               mtoper->mt_count = 1;
-               stat = ioctl(tape, MTIOCTOP, mtoper);
-               if (stat == -1) {
-                       msglog(LOG_ERR, "Could not jump over the filemark!\n");
-                       exit(-2);
-               }
-               label = allocMem(80*sizeof(char));
-               do {
-                       stat = read(tape, label, 80);
-                       if (i == 0) {
-                               sscanf(label, "%*31c%4d", &fileSeqNum);
-                               printf("File Sequence Number: %04i\n", fileSeqNum);
-                       }
-                       i++;
-               } while (stat != -1);
-               freeMem(label);
-       }
-
-       writeHeader(tape, fileSeqNum, filename);
-
-       mtoper->mt_op = MTWEOF;
-       mtoper->mt_count = 1;
-       stat = ioctl(tape, MTIOCTOP, mtoper);
-       if (stat == -1) {
-                       msglog(LOG_ERR, "Could not write tapemark!\n");
-               exit(-2);
-       }
-       mtoper->mt_op = MTSETBLK;
-       mtoper->mt_count = BLOCKSIZE;
-       stat = ioctl(tape, MTIOCTOP, mtoper);
-       if (stat == -1) {
-                       msglog(LOG_ERR, "Could not set the correct blocksize!\n");
-               exit(-2);
-       }
-
-       if (NULL == (outFile = fdopen(tape, "wb"))) {
-               msglog(LOG_ERR, "fdopen: %\n", strerror(errno));
-               exit(-2);
-       }
-
-       setvbuf(outFile, 0, _IOFBF, BLOCKSIZE);
-
-       return outFile;
-#else
-       return NULL;
-#endif
-}
-
-int closeTape(FILE *openTape, unsigned long numBytes, const char *filename) {
-#ifdef MTIOCTOP
-       int stat;
-       int tape;
-       struct mtop mtoperS, *mtoper = &mtoperS;
-
-       stat = fflush(openTape);
-       if (stat != 0) {
-               msglog(LOG_ERR, "Could not flush file on tape!\n");
-               exit(-2);
-       }
-       tape = fileno(openTape);
-       if (tape == -1) {
-               msglog(LOG_ERR, "Could not get file file descriptor of file opened on tape!\n");
-               exit(-2);
-       }
-       mtoper->mt_op = MTWEOF;
-       mtoper->mt_count = 1;
-       stat = ioctl(tape, MTIOCTOP, mtoper);
-       if (stat == -1) {
-                       msglog(LOG_ERR, "Could not write tapemark!\n");
-               exit(-2);
-       }
-       mtoper->mt_op = MTSETBLK;
-       mtoper->mt_count = 80;
-       stat = ioctl(tape, MTIOCTOP, mtoper);
-       if (stat == -1) {
-                       msglog(LOG_ERR, "Could not set blocksize to 80!\n");
-               exit(-2);
-       }
-
-
-       writeTrailer(tape, 0, numBytes, filename);
-
-       stat = fclose(openTape);
-       if (stat == -1) {
-               msglog(LOG_ERR, "Could not close file on tape, stat return %d!\n", stat);
-               exit(-2);
-       }
-
-       return 0;
-#else
-       return -1;
-#endif
-}
-
diff --git a/hadaq/tape.h b/hadaq/tape.h
deleted file mode 100644 (file)
index e56e3cd..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-#ifndef HWTAPE_H
-#define HWTAPE_H
-
-/* For FILE */
-#include <stdio.h>
-
-FILE *openTape(const char *);
-
-int closeTape(FILE *, unsigned long, const char *);
-
-#endif
-
diff --git a/hadaq/tapechar.c b/hadaq/tapechar.c
deleted file mode 100644 (file)
index 250b07b..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-#include <hadesstd.h>
-
-#include "tapechar.h"
-
-char *ansichar(char *s, int length) {
-       int i, end = 0;
-       for(i=0 ; i<length ; i++) {
-               if (end == 0) {
-                       if(isupper(s[i]) || isdigit(s[i])) {
-                       } else if(islower(s[i])) {
-                               s[i] = toupper(s[i]);
-                       } else {
-                               switch (s[i]) {
-                                       case (' '):
-                                       case ('!'):
-                                       case ('"'):
-                                       case ('%'):
-                                       case ('&'):
-                                       case ('\''):
-                                       case ('('):
-                                       case (')'):
-                                       case ('*'):
-                                       case ('+'):
-                                       case (','):
-                                       case ('-'):
-                                       case ('_'):
-                                       case ('.'):
-                                       case ('/'):
-                                       case (':'):
-                                       case (';'):
-                                       case ('<'):
-                                       case ('='):
-                                       case ('>'):
-                                       case ('?'):
-                                               break;
-                                       case ('\0'):
-                                               s[i] = ' ';
-                                               end = 1;
-                                               break;
-                                       default:
-                                               s[i] = 'Z';
-                                               break;
-                               }
-                       }
-               } else {
-                       s[i] = ' ';
-               }
-       }
-       s[length] = '\0';
-
-       return s;
-}
-
-char *unixchar(char *s, int length) {
-       int i, end = 0;
-       for(i=0 ; i<length ; i++) {
-               if (end == 0) {
-                       if(s[i] == '\0') {
-                               s[i] = ' ';
-                               end = 1;
-                       }
-               } else {
-                       s[i] = ' ';
-               }
-       }
-       s[length] = '\0';
-
-       return s;
-}
-
diff --git a/hadaq/tapechar.h b/hadaq/tapechar.h
deleted file mode 100644 (file)
index 5a0a201..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-#ifndef HWTAPECHAR_H
-#define HWTAPECHAR_H
-
-char *ansichar(char *, int);
-char *unixchar(char *, int);
-
-#endif
-
diff --git a/hadaq/tapelabel.c b/hadaq/tapelabel.c
deleted file mode 100644 (file)
index 9814588..0000000
+++ /dev/null
@@ -1,212 +0,0 @@
-/* For msglog() */
-#include <hadesstd.h>
-#include <errno.h>
-/* For allocMem(), freeMem() */
-#include <hadesstd.h>
-/* For memcpy() */
-#include <string.h>
-
-/* For read(), write(), gethostname() */
-#include <unistd.h>
-
-/* For time() */
-#include <time.h>
-/* For getpwent() */
-#include <pwd.h>
-#include <sys/types.h>
-/* For getuid() */
-#include <unistd.h>
-#include <sys/types.h>
-
-#include "tapechar.h"
-#include "tapelabel.h"
-
-/* Functions concerning the volume label */
-
-char *readVolumeLabel(int tape) {
-       char *vol;
-       int stat;
-       vol = allocMem(80*sizeof(char));
-       stat = read(tape, vol, 80);
-       if(stat == -1) {
-               msglog(LOG_ERR, "Could not read volume label from tape!\n");
-               exit(-3);
-       }
-
-       return vol;
-       freeMem(vol);
-}
-
-int writeVolumeLabel(const char *vol, int tape) {
-       char *v;
-       int stat;
-       v = allocMem(80*sizeof(char));
-       memcpy(v, vol, 80);
-       stat = write(tape, v, 80);
-       if(stat == -1) {
-               msglog(LOG_ERR, "Could not write volume label to tape!\n");
-               exit(-3);
-       }
-
-       freeMem(v);
-       return 0;
-}
-
-int writeNewVolumeLabel(const char *volId, const char *ownerId, int tape) {
-       char *vol, *oid;
-       int stat;
-
-#ifdef LINUX
-       const char *impId = "LINUXHADAQ023";
-#endif
-#ifdef UNIX
-       const char *impId = "UNIXHADAQ0023";
-#endif
-#ifndef LINUX
-#ifndef UNIX
-       const char *impId = "    HADAQ0023";
-#endif
-#endif
-
-       vol = allocMem(80*sizeof(char));
-
-       oid = allocMem(15*sizeof(char));
-       if (80 != sprintf(vol, "VOL1HADAQ               %s%s                            4", impId, ansichar(oid, 14))) {
-               msglog(LOG_ERR, "LabelV not 80 char!\n");
-               exit(-3);
-       }
-       freeMem(oid);
-
-       stat = write(tape, vol, 80);
-       if(stat == -1) {
-               msglog(LOG_ERR, "Could not write volume label to tape!\n");
-               exit(-3);
-       }
-
-       freeMem(vol);
-       return 0;
-}
-
-/* Functions concerning the hdr-label and the eof-label */
-
-int writeLabel(const char *hdreof, int tape, int fileSeqNum, int bytes, const char *filename) {
-       int stat;
-       int i;
-       int blockSize = BLOCKSIZE;
-       char hostname[21];
-       char *creaCent;
-       char label[81];
-       char fn[37];
-#ifdef LINUX
-       const char *impId = "LINUXHADAQ023";
-#endif
-#ifdef UNIX
-       const char *impId = "UNIXHADAQ0023";
-#endif
-#ifndef LINUX
-  #ifndef UNIX
-       const char *impId = "    HADAQ0023";
-  #endif
-#endif
-       uid_t uid;
-       char *user;
-       time_t tim;
-       struct passwd pwentryS, *pwentry = &pwentryS;
-       struct tm cdS, *cd = &cdS;
-
-       tim = time(0);
-       cd = gmtime(&tim);
-       if ((cd->tm_year)/100 == 19) {
-               creaCent = " ";
-       } else {
-               creaCent = "0";
-       }
-
-       strcpy(fn, filename);
-       if (80 != sprintf(label, "%-3s%1d%-17s%06d%04d%04d%04d%02d%1s%02d%03d%6d%1s%06d%-13s%-7s",
-               hdreof,
-               1,
-               ansichar(fn, 17),
-               1,
-               1,
-               fileSeqNum,
-               1,
-               0,
-               creaCent, (cd->tm_year)%100, cd->tm_yday,
-               99366,
-               " ",
-               (bytes + BLOCKSIZE -1) / BLOCKSIZE,
-               impId,
-               "")
-       ) {
-               msglog(LOG_ERR, "Label1 not 80 char!\n");
-               exit(-3);
-       }
-
-       stat = write(tape, label, 80);
-       if(stat == -1) {
-               msglog(LOG_ERR, "Could not write ANSI label on tape!\n");
-               exit(-3);
-       }
-
-       if (80 != sprintf(label, "%-3s%1d%1s%05d%05d%-21s%1s%010d%-3s%02d%28s",
-               hdreof,
-               2,
-               "F",
-               blockSize,
-               blockSize,
-               "",
-               "M",
-               bytes,
-               "",
-               0,
-               "")
-       ) {
-               msglog(LOG_ERR, "Label2 not 80 char!\n");
-               exit(-3);
-       }
-       stat = write(tape, label, 80);
-       if(stat == -1) {
-               msglog(LOG_ERR, "Could not write ANSI label on tape!\n");
-               exit(-3);
-       }
-
-       uid = getuid();
-       while (NULL != (pwentry = getpwent()) && pwentry->pw_uid != uid) {
-       }
-
-       if (NULL != pwentry) {
-               user = pwentry->pw_name;
-       } else {
-               user = "hades";
-       }
-
-       gethostname(hostname, 20);
-
-       if (80 != sprintf(label, "%-3s%1d%010d%-10s%-20s%-36s",
-               hdreof,
-               3,
-               tim,
-               user,
-               hostname,
-               filename)
-       ) {
-               msglog(LOG_ERR, "Label3 not 80 char!\n");
-               exit(-3);
-       }
-
-       stat = write(tape, label, 80);
-       if(stat == -1) {
-               msglog(LOG_ERR, "Could not write ANSI label on tape!\n");
-               exit(-3);
-       }
-       return 0;
-}
-
-int writeHeader(int tape, int fileSeqNum, const char *filename) {
-       return writeLabel("HDR", tape, fileSeqNum, 0, filename);
-}
-
-int writeTrailer(int tape, int fileSeqNum, unsigned long numBytes, const char *filename) {
-       return writeLabel("EOF", tape, fileSeqNum, numBytes, filename);
-}
diff --git a/hadaq/tapelabel.h b/hadaq/tapelabel.h
deleted file mode 100644 (file)
index 9f36d78..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef HWTAPELABEL_H
-#define HWTAPELABEL_H
-
-#define BLOCKSIZE 8192
-
-char *readVolumeLabel(int);
-int writeVolumeLabel(const char *, int);
-int writeNewVolumeLabel(const char *, const char *, int);
-
-int writeHeader(int, int, const char *);
-int writeTrailer(int, int, unsigned long, const char *);
-
-#endif
-