"Fossies" - the Fresh Open Source Software Archive

Member "xorriso-1.5.4/libjte/jte.h" (30 Jan 2021, 5294 Bytes) of package /linux/misc/xorriso-1.5.4.pl02.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "jte.h" see the Fossies "Dox" file reference documentation and the last Fossies "Diffs" side-by-side code changes report: 1.5.2_vs_1.5.4.

    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 {
   52     JTE_TEMP_GZIP = 0,
   53     JTE_TEMP_BZIP2
   54 } jtc_t;
   55 
   56 struct _checksum_data
   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,
   86         HEX_MD5_BYTES,
   87         BASE64_MD5_BYTES
   88     },
   89     {
   90         CHECK_SHA256,
   91         "sha256",
   92         SHA256_BYTES,
   93         HEX_SHA256_BYTES,
   94         BASE64_SHA256_BYTES
   95     },
   96     {
   97         NUM_CHECKSUMS,
   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 */
  112 struct path_match
  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 */
  120 struct path_mapping
  121 {
  122     char                *from;
  123     char                *to;
  124     struct path_mapping *next;
  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;
  135 } file_entry_t;
  136 
  137 typedef struct _unmatched_entry
  138 {
  139     off_t uncompressed_length;
  140 } unmatched_entry_t;    
  141 
  142 typedef struct _entry
  143 {
  144     int entry_type; /* JTET_TYPE as above */
  145     struct _entry *next;
  146     union
  147     {
  148         file_entry_t      file;
  149         unmatched_entry_t chunk;
  150     } data;
  151 } entry_t;
  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];
  159 } jigdo_file_entry_md5_t;
  160 
  161 typedef struct _jigdo_file_entry_sha256
  162 {
  163     unsigned char type;
  164     unsigned char fileLen[6];
  165     unsigned char fileRsync[8];
  166     unsigned char fileSHA256[SHA256_BYTES];
  167 } jigdo_file_entry_sha256_t;
  168 
  169 typedef struct _jigdo_chunk_entry
  170 {
  171     unsigned char type;
  172     unsigned char skipLen[6];
  173 } jigdo_chunk_entry_t;
  174 
  175 typedef struct _jigdo_image_entry_md5
  176 {
  177     unsigned char type;
  178     unsigned char imageLen[6];
  179     unsigned char imageMD5[MD5_BYTES];
  180     unsigned char blockLen[4];
  181 } jigdo_image_entry_md5_t;
  182 
  183 typedef struct _jigdo_image_entry_sha256
  184 {
  185     unsigned char type;
  186     unsigned char imageLen[6];
  187     unsigned char imageSHA256[SHA256_BYTES];
  188     unsigned char blockLen[4];
  189 } jigdo_image_entry_sha256_t;
  190 
  191 typedef struct _checksum_list_entry
  192 {
  193     struct _checksum_list_entry *next;
  194     unsigned char      *checksum;
  195     uint64_t            size;
  196     char               *filename;
  197 } checksum_list_entry_t;
  198 
  199 
  200 typedef struct _jigdo_msg_entry
  201 {
  202     struct _jigdo_msg_entry *next;
  203     char *message;
  204 } jigdo_msg_entry_t;
  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_*/