From: hades Date: Thu, 18 May 2000 21:22:44 +0000 (+0000) Subject: Put into hwtapelabel.c X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=1bba43d5159729a14b3393443a45befa0e409f9b;p=daqdata.git Put into hwtapelabel.c --- diff --git a/hadaq/hwtapeal.c b/hadaq/hwtapeal.c deleted file mode 100644 index 267480d..0000000 --- a/hadaq/hwtapeal.c +++ /dev/null @@ -1,163 +0,0 @@ -/* For msglog() */ -#include -#include - -/* For time() */ -#include - -/* For gethostname() */ -#include - -/* For getpwent() */ -#include -#include - -/* For getuid() */ -#include -#include - -#include "hwtapeal.h" - -int writeHeader(int tape, int fileSeqNum, const char *filename) { - int stat; - int i; - int blockSize = BLOCKSIZE; - char *hostname; - char *creaCent; - char *label; -#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, first_uid; - time_t tim; - struct passwd *pwentry; - struct tm *cd; - - gethostname(hostname, 20); - - tim = time(0); - cd = gmtime(&tim); - if ((cd->tm_year)/100 == 19) { - *creaCent = ' '; - } else { - *creaCent = '0'; - } - - label = allocMem(80*sizeof(char)); - - sprintf(label, "HDR1 %s0000010001%04d000100%s%02d%03d 99366 000000%s ", ansichar(filename, 17), fileSeqNum, creaCent, (cd->tm_year)%100, cd->tm_yday, impId); - stat = write(tape, label, 80); - if(stat == -1) { - msglog(LOG_ERR, "Could not write ANSI label on tape!\n"); - exit(-3); - } - - sprintf(label, "HDR2F%05d%05d010664 bin 33000 ", blockSize, blockSize); - stat = write(tape, label, 80); - if(stat == -1) { - msglog(LOG_ERR, "Could not write ANSI label on tape!\n"); - exit(-3); - } - - uid = getuid(); - pwentry = getpwent(); - first_uid = pwentry->pw_uid; - do { - pwentry = getpwent(); - } while (pwentry->pw_uid != uid && pwentry->pw_uid != first_uid); - - if (pwentry->pw_name == "root") { - pwentry->pw_name = "hades"; - } - - sprintf(label, "HDR3%010d%s%s%s", tim, unixchar(pwentry->pw_name, 10), unixchar(hostname, 20), unixchar(filename, 36)); - stat = write(tape, label, 80); - if(stat == -1) { - msglog(LOG_ERR, "Could not write ANSI label on tape!\n"); - exit(-3); - } - - freeMem(label); - return 0; -} - - -int writeTrailer(int tape, int fileSeqNum, int numBlocks, const char *filename) { - int stat; - int i; - int blockSize = BLOCKSIZE; - char *hostname; - char *creaCent; - char *label; -#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, first_uid; - time_t tim; - struct passwd *pwentry; - struct tm *cd; - - gethostname(hostname, 20); - - tim = time(0); - cd = gmtime(&tim); - if ((cd->tm_year)/100 == 19) { - *creaCent = ' '; - } else { - *creaCent = '0'; - } - - label = allocMem(80*sizeof(char)); - - sprintf(label, "HDR1 %s0000010001%04d000100%s%02d%03d 99366 %06d%s ", ansichar(filename, 17), fileSeqNum, creaCent, (cd->tm_year)%100, cd->tm_yday, numBlocks, impId); - stat = write(tape, label, 80); - if(stat == -1) { - msglog(LOG_ERR, "Could not write ANSI label on tape!\n"); - exit(-3); - } - - sprintf(label, "HDR2F%05d%05d010664 bin %010d33000 ", blockSize, blockSize, numBlocks*blockSize); - stat = write(tape, label, 80); - if(stat == -1) { - msglog(LOG_ERR, "Could not write ANSI label on tape!\n"); - exit(-3); - } - - uid = getuid(); - pwentry = getpwent(); - first_uid = pwentry->pw_uid; - do { - pwentry = getpwent(); - } while (pwentry->pw_uid != uid && pwentry->pw_uid != first_uid); - - if (pwentry->pw_name == "root") { - pwentry->pw_name = "hades"; - } - - sprintf(label, "HDR3%010d%s%s%s", tim, unixchar(pwentry->pw_name, 10), unixchar(hostname, 20), unixchar(filename, 36)); - stat = write(tape, label, 80); - if(stat == -1) { - msglog(LOG_ERR, "Could not write ANSI label on tape!\n"); - exit(-3); - } - - freeMem(label); - return 0; -} - diff --git a/hadaq/hwtapevol.c b/hadaq/hwtapevol.c deleted file mode 100644 index 5963b91..0000000 --- a/hadaq/hwtapevol.c +++ /dev/null @@ -1,72 +0,0 @@ -/* For read(), write() */ -#include - -/* For allocMem(), freeMem() */ -#include - -/* For msglog() */ -#include -#include - -/* For memcpy() */ -#include - -#include "hwtapevol.h" - -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; - 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)); - - sprintf(vol, "VOL1HADAQ %s%s 4", impId, ansichar(ownerId, 14)); - - 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; -} -