xorriso  1.5.4.pl02
About: GNU xorriso creates, loads, manipulates and writes ISO 9660 filesystem images with Rock Ridge extensions. It is suitable for incremental data backup and for production of bootable ISO 9660 images. GNU xorriso is a statical compilation of the libraries libburn, libisofs, libisoburn, and libjte.
  Fossies Dox: xorriso-1.5.4.pl02.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

jte.h
Go to the documentation of this file.
1 /*
2  * jte.c
3  *
4  * Copyright (c) 2004-2006 Steve McIntyre <steve@einval.com>
5  * Copyright (c) 2010 Thomas Schmitt <scdbackup@gmx.net>
6  * Copyright (c) 2010 George Danchev <danchev@spnet.net>
7  *
8  * Prototypes and declarations for JTE
9  *
10  * GNU GPL v2
11  */
12 
13 #ifndef _JTE_JTE_H_
14 #define _JTE_JTE_H_
15 
16 /* The API environment handle which replaces the old global variables */
17 struct libjte_env;
18 
19 #include <stdio.h>
20 #include <unistd.h>
21 #include <regex.h>
22 #include "checksum.h"
23 
24 typedef int BOOL;
25 
26 
27 extern int write_jt_header(struct libjte_env *o,
28  FILE *template_file, FILE *jigdo_file);
29 extern int write_jt_footer(struct libjte_env *o);
30 extern int jtwrite(struct libjte_env *o,
31  void *buffer, int size, int count);
32 extern int write_jt_match_record(struct libjte_env *o,
33  char *filename, char *mirror_name, int sector_size,
34  off_t size, unsigned char *checksum);
35 extern int list_file_in_jigdo(struct libjte_env *o,
36  char *filename, off_t size, char **realname,
37  unsigned char *checksum);
38 extern int jte_add_exclude(struct libjte_env *o, char *pattern);
39 extern int jte_add_include(struct libjte_env *o, char *pattern);
40 extern int jte_add_mapping(struct libjte_env *o, char *arg);
41 
42 int libjte_destroy_path_match_list(struct libjte_env *o, int flag);
43 int libjte_destroy_path_mapping(struct libjte_env *o, int flag);
44 int libjte_destroy_entry_list(struct libjte_env *o, int flag);
45 int libjte_destroy_checksum_list(struct libjte_env *o, int flag);
46 
47 int libjte_report_no_mem(struct libjte_env *o, size_t size, int flag);
48 
49 
50 typedef enum _jtc_e
51 {
55 
57 {
58  enum checksum_types type;
59  char *name; /* the name of the checksum algorithm */
60  int raw_bytes; /* how many bytes needed to store the raw
61  * checksum */
62  int hex_bytes; /* how many chars needed to store it as a hex
63  * string, *not including* the NULL terminator */
64  int b64_bytes; /* how many chars needed to store it as a base64
65  * string, *not including* the NULL terminator */
66 };
67 
68 #define ROUND_UP(N, S) ((((N) + (S) - 1) / (S)) * (S))
69 
70 #define MD5_BITS 128
71 #define MD5_BYTES (MD5_BITS / 8)
72 #define HEX_MD5_BYTES (MD5_BITS / 4)
73 #define BASE64_MD5_BYTES ((ROUND_UP (MD5_BITS, 6)) / 6)
74 
75 #define SHA256_BITS 256
76 #define SHA256_BYTES (SHA256_BITS / 8)
77 #define HEX_SHA256_BYTES (SHA256_BITS / 4)
78 #define BASE64_SHA256_BYTES ((ROUND_UP (SHA256_BITS, 6)) / 6)
79 
80 static const struct _checksum_data check_algos[] =
81 {
82  {
83  CHECK_MD5,
84  "md5",
85  MD5_BYTES,
88  },
89  {
91  "sha256",
95  },
96  {
98  NULL,
99  0,
100  0,
101  0
102  }
103 };
104 
105 #define MIN_JIGDO_FILE_SIZE 1024
106 
107 /*
108  Simple list to hold the results of -jigdo-exclude and
109  -jigdo-force-match command line options. Seems easiest to do this
110  using regexps.
111 */
113 {
114  regex_t match_pattern;
115  char *match_rule;
116  struct path_match *next;
117 };
118 
119 /* List of mappings e.g. Debian=/mirror/debian */
121 {
122  char *from;
123  char *to;
125 };
126 
127 /* List of files that we've seen, ready to write into the template and
128  jigdo files */
129 typedef struct _file_entry
130 {
131  unsigned char *checksum;
132  off_t file_length;
133  uint64_t rsyncsum;
134  char *filename;
136 
137 typedef struct _unmatched_entry
138 {
141 
142 typedef struct _entry
143 {
144  int entry_type; /* JTET_TYPE as above */
145  struct _entry *next;
146  union
147  {
150  } data;
152 
153 typedef struct _jigdo_file_entry_md5
154 {
155  unsigned char type;
156  unsigned char fileLen[6];
157  unsigned char fileRsync[8];
158  unsigned char fileMD5[MD5_BYTES];
160 
162 {
163  unsigned char type;
164  unsigned char fileLen[6];
165  unsigned char fileRsync[8];
166  unsigned char fileSHA256[SHA256_BYTES];
168 
169 typedef struct _jigdo_chunk_entry
170 {
171  unsigned char type;
172  unsigned char skipLen[6];
174 
176 {
177  unsigned char type;
178  unsigned char imageLen[6];
179  unsigned char imageMD5[MD5_BYTES];
180  unsigned char blockLen[4];
182 
184 {
185  unsigned char type;
186  unsigned char imageLen[6];
187  unsigned char imageSHA256[SHA256_BYTES];
188  unsigned char blockLen[4];
190 
191 typedef struct _checksum_list_entry
192 {
194  unsigned char *checksum;
195  uint64_t size;
196  char *filename;
198 
199 
200 typedef struct _jigdo_msg_entry
201 {
203  char *message;
205 int libjte_add_msg_entry(struct libjte_env *o, char *message, int flag);
206 /* Destructor is API call libjte_clear_msg_list() */
207 
208 #endif
209 /*_JTE_JTE_H_*/
checksum_types
Definition: checksum.h:17
@ NUM_CHECKSUMS
Definition: checksum.h:22
@ CHECK_MD5
Definition: checksum.h:18
@ CHECK_SHA256
Definition: checksum.h:20
int BOOL
Definition: jte.h:17
int libjte_add_msg_entry(struct libjte_env *o, char *message, int flag)
Definition: jte.c:1463
int write_jt_match_record(struct libjte_env *o, char *filename, char *mirror_name, int sector_size, off_t size, unsigned char *checksum)
Definition: jte.c:1397
struct _jigdo_msg_entry jigdo_msg_entry_t
enum _jtc_e jtc_t
int libjte_destroy_checksum_list(struct libjte_env *o, int flag)
Definition: jte.c:566
struct _checksum_list_entry checksum_list_entry_t
#define SHA256_BYTES
Definition: jte.h:76
struct _jigdo_image_entry_sha256 jigdo_image_entry_sha256_t
struct _entry entry_t
int libjte_destroy_path_match_list(struct libjte_env *o, int flag)
Definition: jte.c:150
int list_file_in_jigdo(struct libjte_env *o, char *filename, off_t size, char **realname, unsigned char *checksum)
Definition: jte.c:266
int jte_add_include(struct libjte_env *o, char *pattern)
Definition: jte.c:202
#define HEX_SHA256_BYTES
Definition: jte.h:77
int write_jt_header(struct libjte_env *o, FILE *template_file, FILE *jigdo_file)
Definition: jte.c:736
#define HEX_MD5_BYTES
Definition: jte.h:72
int jte_add_mapping(struct libjte_env *o, char *arg)
Definition: jte.c:349
#define BASE64_SHA256_BYTES
Definition: jte.h:78
struct _jigdo_chunk_entry jigdo_chunk_entry_t
struct _unmatched_entry unmatched_entry_t
int jtwrite(struct libjte_env *o, void *buffer, int size, int count)
Definition: jte.c:1372
int jte_add_exclude(struct libjte_env *o, char *pattern)
Definition: jte.c:171
static const struct _checksum_data check_algos[]
Definition: jte.h:80
_jtc_e
Definition: jte.h:51
@ JTE_TEMP_GZIP
Definition: jte.h:52
@ JTE_TEMP_BZIP2
Definition: jte.h:53
#define BASE64_MD5_BYTES
Definition: jte.h:73
struct _jigdo_file_entry_sha256 jigdo_file_entry_sha256_t
#define MD5_BYTES
Definition: jte.h:71
int libjte_destroy_path_mapping(struct libjte_env *o, int flag)
Definition: jte.c:414
int libjte_destroy_entry_list(struct libjte_env *o, int flag)
Definition: jte.c:210
struct _jigdo_image_entry_md5 jigdo_image_entry_md5_t
struct _file_entry file_entry_t
struct _jigdo_file_entry_md5 jigdo_file_entry_md5_t
int write_jt_footer(struct libjte_env *o)
Definition: jte.c:1292
int libjte_report_no_mem(struct libjte_env *o, size_t size, int flag)
Definition: jte.c:107
int hex_bytes
Definition: jte.h:62
enum checksum_types type
Definition: jte.h:58
int b64_bytes
Definition: jte.h:64
int raw_bytes
Definition: jte.h:60
char * name
Definition: jte.h:59
Definition: jte.h:192
uint64_t size
Definition: jte.h:195
char * filename
Definition: jte.h:196
unsigned char * checksum
Definition: jte.h:194
struct _checksum_list_entry * next
Definition: jte.h:193
Definition: jte.h:143
int entry_type
Definition: jte.h:144
file_entry_t file
Definition: jte.h:148
struct _entry * next
Definition: jte.h:145
union _entry::@7 data
unmatched_entry_t chunk
Definition: jte.h:149
Definition: jte.h:130
unsigned char * checksum
Definition: jte.h:131
off_t file_length
Definition: jte.h:132
char * filename
Definition: jte.h:134
uint64_t rsyncsum
Definition: jte.h:133
Definition: jte.h:170
unsigned char type
Definition: jte.h:171
unsigned char skipLen[6]
Definition: jte.h:172
Definition: jte.h:154
unsigned char fileMD5[(128/8)]
Definition: jte.h:158
unsigned char fileLen[6]
Definition: jte.h:156
unsigned char fileRsync[8]
Definition: jte.h:157
unsigned char type
Definition: jte.h:155
Definition: jte.h:162
unsigned char fileSHA256[(256/8)]
Definition: jte.h:166
unsigned char fileLen[6]
Definition: jte.h:164
unsigned char fileRsync[8]
Definition: jte.h:165
unsigned char type
Definition: jte.h:163
Definition: jte.h:176
unsigned char blockLen[4]
Definition: jte.h:180
unsigned char imageMD5[(128/8)]
Definition: jte.h:179
unsigned char imageLen[6]
Definition: jte.h:178
unsigned char type
Definition: jte.h:177
Definition: jte.h:184
unsigned char imageLen[6]
Definition: jte.h:186
unsigned char imageSHA256[(256/8)]
Definition: jte.h:187
unsigned char type
Definition: jte.h:185
unsigned char blockLen[4]
Definition: jte.h:188
Definition: jte.h:201
struct _jigdo_msg_entry * next
Definition: jte.h:202
char * message
Definition: jte.h:203
Definition: jte.h:138
off_t uncompressed_length
Definition: jte.h:139
char * to
Definition: jte.h:123
char * from
Definition: jte.h:122
struct path_mapping * next
Definition: jte.h:124
char * match_rule
Definition: jte.h:115
struct path_match * next
Definition: jte.h:116
regex_t match_pattern
Definition: jte.h:114