ug4
tar.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013-2015: G-CSC, Goethe University Frankfurt
3  * Author: Martin Rupp
4  *
5  * This file is part of UG4.
6  *
7  * UG4 is free software: you can redistribute it and/or modify it under the
8  * terms of the GNU Lesser General Public License version 3 (as published by the
9  * Free Software Foundation) with the following additional attribution
10  * requirements (according to LGPL/GPL v3 §7):
11  *
12  * (1) The following notice must be displayed in the Appropriate Legal Notices
13  * of covered and combined works: "Based on UG4 (www.ug4.org/license)".
14  *
15  * (2) The following notice must be displayed at a prominent place in the
16  * terminal output of covered works: "Based on UG4 (www.ug4.org/license)".
17  *
18  * (3) The following bibliography is recommended for citation and must be
19  * preserved in all covered files:
20  * "Reiter, S., Vogel, A., Heppner, I., Rupp, M., and Wittum, G. A massively
21  * parallel geometric multigrid solver on hierarchically distributed grids.
22  * Computing and visualization in science 16, 4 (2013), 151-164"
23  * "Vogel, A., Reiter, S., Rupp, M., Nägel, A., and Wittum, G. UG4 -- a novel
24  * flexible software system for simulating pde based models on high performance
25  * computers. Computing and visualization in science 16, 4 (2013), 165-179"
26  *
27  * This program is distributed in the hope that it will be useful,
28  * but WITHOUT ANY WARRANTY; without even the implied warranty of
29  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30  * GNU Lesser General Public License for more details.
31  */
32 
33 #ifndef __H__TAR_H_
34 #define __H__TAR_H_
35 
36 #include <stdio.h>
37 namespace ug{
38 struct TarHeader
39 {
40  char filename[100];
41  char filemode[8];
42  char userID[8];
43  char groupID[8];
44  char octalFileSize[12];
46  char checksum[8];
48  char linkedFilename[100];
49 
50  char ustarIndicator[6];
51  char ustarVersion[2];
57  char padding[12];
58 
59 
60  //char padding[512 - (100+8+8+8+12+12+8+1+100)];
61 
63  {
64  memset(this, 0, sizeof(TarHeader));
65  strcpy(filemode, "000644 ");
66  strcpy(userID, "000765 ");
67  strcpy(groupID, "000024 ");
68  strcpy(ustarIndicator, "ustar");
69  memcpy(ustarVersion, "00", 2);
70  strcpy(ustarOwnerUserName, "");
71  strcpy(ustarOwnerGroupName, "");
72  strcpy(ustarDeviceMajorNumber, "000000 ");
73  strcpy(ustarDeviceMinorNumber, "000000 ");
74 
75  sprintf(octalModificationTimeStamp, "%o", ((unsigned int)time(NULL)));
76 // strncpy(octalModificationTimeStamp, "12253557334 ", 12);
77  linkIndicator = '0';
78  }
79  void set_filename(std::string name)
80  {
81  strcpy(filename, name.c_str());
82  }
83  void set_filesize(size_t size)
84  {
85  char buf[13];
86  sprintf(buf, "%011o ", (unsigned int)size);
87  memcpy(octalFileSize, buf, 12);
88  }
89 
90  void set_checksum()
91  {
92  memset(checksum, 32, sizeof(checksum));
93  unsigned char *p = (unsigned char *) this;
94  unsigned int cs = 0;
95  for(size_t i=0; i<sizeof(TarHeader); i++)
96  cs += p[i];
97  sprintf(checksum, "%06o", ((unsigned int)cs));
98  // std:: cout << "checksum = " << checksum << "\n";
99  }
100 };
101 
102 }
103 #endif /* TAR_H_ */
parameterString p
location name
Definition: checkpoint_util.lua:128
function common sprintf(s,...)
the ug namespace
Definition: tar.h:39
void set_filesize(size_t size)
Definition: tar.h:83
char linkedFilename[100]
Definition: tar.h:48
char linkIndicator
Definition: tar.h:47
void set_filename(std::string name)
Definition: tar.h:79
char ustarOwnerGroupName[32]
Definition: tar.h:53
char ustarIndicator[6]
Definition: tar.h:50
char padding[12]
Definition: tar.h:57
char filename[100]
Definition: tar.h:40
char ustarVersion[2]
Definition: tar.h:51
char ustarDeviceMinorNumber[8]
Definition: tar.h:55
char groupID[8]
Definition: tar.h:43
void set_checksum()
Definition: tar.h:90
char octalModificationTimeStamp[12]
Definition: tar.h:45
char ustarFilenamePrefix[155]
Definition: tar.h:56
char ustarOwnerUserName[32]
Definition: tar.h:52
char filemode[8]
Definition: tar.h:41
char checksum[8]
Definition: tar.h:46
char userID[8]
Definition: tar.h:42
TarHeader()
Definition: tar.h:62
char octalFileSize[12]
Definition: tar.h:44
char ustarDeviceMajorNumber[8]
Definition: tar.h:54