4577154 [rkeene@sledge /home/rkeene/devel/dact]$ cat -n dact.h
  1 /*
  2  * Copyright (C) 2001, 2002, and 2003  Roy Keene
  3  *
  4  * This program is free software; you can redistribute it and/or
  5  * modify it under the terms of the GNU General Public License
  6  * as published by the Free Software Foundation; either version 2
  7  * of the License, or (at your option) any later version.
  8  *
  9  * This program is distributed in the hope that it will be useful,
 10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 12  * GNU General Public License for more details.
 13  *
 14  * You should have received a copy of the GNU General Public License
 15  * along with this program; if not, write to the Free Software
 16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 17  *
 18  *      email: dact@rkeene.org
 19  */
 20 
 21 #ifndef _DACT_H
 22 #define _DACT_H
 23 
 24 #ifdef HAVE_CONFIG_H
 25 #include "config.h"
 26 #endif
 27 #include "win32.h"
 28 #include "comp_fail.h"
 29 
 30 #ifndef DACT_CONTACT
 31 #define DACT_CONTACT "<dact@rkeene.org>"
 32 #endif
 33 
 34 #ifndef DACT_KEY_SIZE
 35 #define DACT_KEY_SIZE 2048
 36 #endif
 37 
 38 #define DACT_VER_MAJOR 0
 39 #define DACT_VER_MINOR 8
 40 #define DACT_VER_REVISION 37
 41 #define DACT_VERSION "0.8.37"
 42 #ifdef DEBUG
 43 #define DACT_VER_SUB    "dev"
 44 #else
 45 #define DACT_VER_SUB    "rel"
 46 #endif
 47 
 48 #define DACT_MODE_COMPR 1
 49 #define DACT_MODE_DECMP 2
 50 #define DACT_MODE_STAT  3
 51 #define DACT_MODE_RET   4
 52 #define DACT_MODE_CINIT 5
 53 #define DACT_MODE_CENC  6
 54 #define DACT_MODE_CDEC  7
 55 #define DACT_MODE_CIENC 11   /* CINIT+CENC */
 56 #define DACT_MODE_DIDEC 12   /* CINIT+CDEC */
 57 
 58 #define DACT_OPT_FORCE  0
 59 #define DACT_OPT_STDOUT 1
 60 #define DACT_OPT_VERB   2
 61 #define DACT_OPT_COMPLN 3
 62 #define DACT_OPT_VERCHK 4
 63 #define DACT_OPT_BINCHK 5
 64 #define DACT_OPT_TIME   6
 65 #define DACT_OPT_PERM   7
 66 #define DACT_OPT_ORIG   8
 67 #define DACT_OPT_HDONLY 9
 68 #define DACT_OPT_SZSPD  10
 69 #define DACT_OPT_NOCRC  11
 70 #define DACT_OPT_NETWORK    12
 71 #define DACT_OPT_URL    13
 72 #define DACT_OPT_UPGRADE    14
 73 
 74 /* These should only be changed at the risk of breaking files. 
 75  * (in other words, they should not be changed if possible.
 76  *  Adding on to them is fine.)
 77  */
 78 #define DACT_HDR_CRC0   0
 79 #define DACT_HDR_CRC1   1
 80 #define DACT_HDR_TIME   2
 81 #define DACT_HDR_PERM   3
 82 #define DACT_HDR_NAME   4
 83 #define DACT_HDR_MD5SUM 5
 84 #define DACT_HDR_DESC   6
 85 #define DACT_HDR_URL    7
 86 #define DACT_HDR_URLFILE    8
 87 #define DACT_HDR_CIPHER 9
 88 #define DACT_HDR_NOP    10
 89 #define DACT_HDR_IDXDATA    11
 90 
 91 #ifndef DACT_BLK_SIZE_MAX
 92 #define DACT_BLK_SIZE_MAX 2147483647
 93 #endif
 94 
 95 #ifndef DACT_BLK_SIZE_DEF
 96 #define DACT_BLK_SIZE_DEF 8192
 97 #endif
 98 
 99 #ifdef HAVE_GETOPT_H
100 #include <getopt.h>
101 #else
102 #include "getopt.h"
103 #endif
104 
105 #ifndef HAVE_STRSEP
106 #include "strsep.h"
107 #endif
108 #ifndef HAVE_GETPASS
109 #include "getpass.h"
110 #endif
111 #ifndef HAVE_MKSTEMP
112 #include "mkstemp.h"
113 #endif
114 #ifndef HAVE_UNAME
115 #include "uname.h"
116 #endif
117 
118 #ifdef HAVE_STDINT_H
119 #include <stdint.h>
120 #endif
121 #ifdef HAVE_INTTYPES_H
122 #include <inttypes.h>
123 #endif
124 #ifdef HAVE_STRING_H
125 #include <string.h>
126 #endif
127 #ifdef HAVE_STDIO_H
128 #include <stdio.h>
129 #endif
130 #ifdef HAVE_ERRNO_H
131 #include <errno.h>
132 #endif
133 
134 
135 #define DACT_MAGIC_NUMBER 0x444354C3
136 #define DACT_MAGIC_OFFSET 0
137 #define DACT_MAGIC_SIZE   4
138 #define DACT_MAGIC_PEOF   0xFF3FDE08
139 
140 #define DACT_HDR_REG_SIZE 24
141 
142 extern char dact_nonetwork;
143 struct dact_header {
144     uint32_t size;
145     unsigned char algo;
146 };
147 
148 #if defined(__FILE__) && defined(__LINE__) && defined(DEBUG)
149 #define PRINT_LINE fprintf(stderr, "%s:%07i:%s(): ", __FILE__, __LINE__, __func__)
150 #else
151 #define PRINT_LINE /**/
152 #endif
153 
154 #define PERROR_L(errnum, error) { PRINT_LINE; fprintf(stderr, "dact: %s: %s\n", error, strerror(abs(errnum))); }
155 #define PRINTERR(error) { PRINT_LINE; fprintf(stderr, "dact: " error "\n"); }
156 #define PERROR(error) PERROR_L(errno, error)
157 /* #define PERROR(error) { PRINT_LINE; perror("dact: " error); } */
158 
159 #ifdef DEBUG
160 #define SPOTVAR_NUM(x) { PRINT_LINE; fprintf(stderr, "dact: %s=%li\n", #x, (long) x); }
161 #define SPOTVAR_STR(x) { PRINT_LINE; fprintf(stderr, "dact: %s=\"%s\"\n", #x, x); }
162 #define CHECKPOINT PRINTERR("Checkpoint reached.")
163 #else
164 #define SPOTVAR_NUM(x) /**/
165 #define SPOTVAR_STR(x) /**/
166 #define CHECKPOINT /**/
167 #endif
168 
169 #ifndef DACT_FAILED_ALGO
170 #define DACT_FAILED_ALGO comp_fail_algo
171 #endif
172 
173 #ifdef HAVE_DEV_URANDOM
174 #define RANDOM_DEV "/dev/urandom"
175 #endif
176 
177 #ifndef DACT_VER_PARTS
178 #define DACT_VER_PARTS(x) ((x&0xff0000)>>16),((x&0xff00)>>8),(x&0xff)
179 #endif
180 
181 #ifndef DACT_BIN_URL
182 #define DACT_BIN_URL "http://www.rkeene.org/projects/compression/dact/@@OSNM@@-@@ARCH@@/dact.bin"
183 #endif
184 #ifndef DACT_BIN_URL_VER
185 #define DACT_BIN_URL_VER "http://www.rkeene.org/projects/compression/dact/@@OSNM@@-@@ARCH@@/dact.ver"
186 #endif
187 #ifndef DACT_BIN_DIR
188 #define DACT_BIN_DIR "@@HOME@@/.dact/@@OSNM@@-@@ARCH@@/"
189 #endif
190 #ifndef DACT_BIN
191 #ifdef EXEEXT
192 #define DACT_BIN DACT_BIN_DIR "dact" EXEEXT
193 #else
194 #define DACT_BIN DACT_BIN_DIR "dact.bin"
195 #endif
196 #endif
197 #define DACT_BIN_VER ((DACT_VER_MAJOR<<16)|(DACT_VER_MINOR<<8)|DACT_VER_REVISION)
198 
199 /* We need to determine when we have network support */
200 #if !defined(HAVE_SOCKET) || !defined(HAVE_GETHOSTBYNAME) || (!defined(HAVE_INET_ATON) && !defined(HAVE_INET_ADDR))
201 #ifndef NO_NETWORK
202 #define NO_NETWORK 1
203 #endif
204 #endif
205 
206 
207 int print_help(int argc, char **argv);
208 int dact_blksize_calc(int fsize);
209 int dact_upgrade_file_checkver(const char *name, const char *url_ver, const char *options);
210 int dact_upgrade_file(const char *name, const char *url_get, const char *url_ver, uint32_t version, const char *dest,
	const char *options);
211 int dact_shutdown(int retval);
212 char *dact_getoutfilename(const char *orig, const int mode);
213 uint32_t dact_process_other(int src, const int dest, const uint32_t magic, const char *options);
214 int main(int argc, char **argv);
215 
216 #endif/*_DACT_H*/
4577155 [rkeene@sledge /home/rkeene/devel/dact]$

Click here to go back to the directory listing.
Click here to download this file.
last modified: 2004-04-04 07:01:51