Changeset 192
- Timestamp:
- 06/29/05 15:36:11
- Files:
-
- openpgpsdk/trunk/configure (modified) (9 diffs)
- openpgpsdk/trunk/examples/Makefile.template (modified) (1 diff)
- openpgpsdk/trunk/include/packet.h (modified) (1 diff)
- openpgpsdk/trunk/src/Makefile.template (modified) (1 diff)
- openpgpsdk/trunk/src/packet-parse.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
openpgpsdk/trunk/configure
r189 r192 9 9 use IO::File; 10 10 11 $|=1; 12 11 13 our $Log; 12 14 our $LogFile='/dev/null'; … … 20 22 21 23 our %Subst=( 22 'CRYPTO_LIBS' => '-lcrypto', 23 'INCLUDES' => '', 24 CRYPTO_LIBS => '-lcrypto', 25 ZLIB => '-lz', 26 INCLUDES => '', 27 24 28 ); 25 29 … … 38 42 my $loc=shift; 39 43 $Subst{INCLUDES}.=" -I $loc"; 44 $Subst{ZLIB}="$loc/libz.a"; 40 45 }, 41 46 '--log=' => sub { … … 43 48 $Log=new IO::File(">$LogFile"); 44 49 $Log->autoflush(1); 50 }, 51 '--64' => sub { 52 $Subst{CFLAGS}.=' -m64'; 45 53 } 46 54 ); 55 56 my %Functions=( 57 'socket' => { headers => ['sys/socket.h'], 58 call => 'socket(0,0,0)', 59 libs => [[],['socket','nsl']] }, 60 ); 47 61 48 62 my @Headers=qw(alloca.h); … … 76 90 findHeaders(\@Headers); 77 91 investigateTypes(\@Types); 92 my $libs=findLibraries(\%Functions); 93 $Subst{'LIBS'}=join(' ',map { "-l$_" } @$libs); 94 #exit; 78 95 79 96 fixSubst(); … … 186 203 sub build { 187 204 my $code=shift; 205 my $link=shift; 188 206 189 207 my $cc=getKnowledge('cc'); … … 198 216 $fh->close(); 199 217 200 my $cmd="$cc $Subst{INCLUDES} -Wall -Werror -c ".$f; 201 trace("$cmd\n--code--\n$code\n--------\n"); 218 my $cflag=''; 219 $cflag='-c' if !defined $link; 220 my $cmd="$cc $Subst{CFLAGS} $Subst{INCLUDES} -Wall -Werror $cflag ".$f; 221 $cmd.=" $link" if defined $link; 222 trace("$cmd\n--code--\n$code--------\n"); 202 223 my $ret=system("$cmd >> $LogFile 2>&1"); 203 224 … … 205 226 $obj =~ s/\.c$/.o/; 206 227 unlink($obj) || $! == ENOENT || croak "unlink($obj): $!"; 228 unlink('a.out') || $! == ENOENT || croak "unlink(a.out): $!"; 207 229 208 230 chdir($cur) || croak "chdir($cur): $!"; … … 246 268 247 269 foreach my $h (@$headers) { 270 print "Check required header $h\n"; 248 271 build("#include <$h>\n") || croak "Can't find required header $h"; 249 272 } 250 273 } 274 275 sub findLibraries { 276 my $funcs=shift; 277 278 my @libs; 279 func: 280 foreach my $func (keys %$funcs) { 281 print "Checking libraries for $func()\n"; 282 my $code=join("\n",map { "#include <$_>" } 283 @{$funcs->{$func}->{headers}}); 284 $code.="\nint main() { $funcs->{$func}->{call}; return 0; }\n"; 285 foreach my $lgroup (@{$funcs->{$func}->{libs}}) { 286 print " trying ",@$lgroup ? join(', ',@$lgroup) : 'no libraries'; 287 if(build($code,join(' ',map { "-l$_" } @$lgroup))) { 288 push @libs,@$lgroup; 289 print " ... OK\n"; 290 next func; 291 } 292 print " ... no\n"; 293 } 294 } 295 return \@libs; 296 } 297 openpgpsdk/trunk/examples/Makefile.template
r140 r192 3 3 CC=%CC% 4 4 5 CFLAGS=-Wall -Werror -g $(DM_FLAGS) -I../include %INCLUDES% 6 LDFLAGS=-g 5 CFLAGS=-Wall -Werror -g $(DM_FLAGS) -I../include %INCLUDES% %CFLAGS% 6 LDFLAGS=-g %CFLAGS% 7 7 LIBDEPS=../src/libops.a 8 LIBS=$(LIBDEPS) %CRYPTO_LIBS% -lz $(DM_LIB)8 LIBS=$(LIBDEPS) %CRYPTO_LIBS% %ZLIB% $(DM_LIB) %LIBS% 9 9 10 10 all: Makefile lib .depend packet-dump verify create-key create-signed-key openpgpsdk/trunk/include/packet.h
r178 r192 639 639 typedef struct 640 640 { 641 size_tlength;641 unsigned length; 642 642 unsigned char data[8192]; 643 643 } ops_literal_data_body_t; openpgpsdk/trunk/src/Makefile.template
r186 r192 3 3 CC=%CC% 4 4 5 CFLAGS=-Wall -Werror -g $(DM_FLAGS) -I../include %INCLUDES% 5 CFLAGS=-Wall -Werror -g $(DM_FLAGS) -I../include %INCLUDES% %CFLAGS% 6 6 LDFLAGS=-g 7 7 LIBS=libops.a -lcrypto -lz $(DM_LIB) openpgpsdk/trunk/src/packet-parse.c
r176 r192 242 242 /** Read a scalar. 243 243 * 244 * Read a Big Endian scalar of length bytes, respecting packet244 * Read a big-endian scalar of length bytes, respecting packet 245 245 * boundaries (by calling limited_read() to read the raw data). 246 246 * … … 248 248 * 249 249 * \param *dest The scalar value is stored here 250 * \param length How many bytes make up this scalar 250 * \param length How many bytes make up this scalar (at most 4) 251 251 * \param *region Pointer to current packet region 252 252 * \param *opt Pointer to parse options to be used … … 264 264 int n; 265 265 266 assert(length <= 4); 267 assert(sizeof(*dest) >= 4); 266 268 if(!ops_limited_read(c,length,region,opt)) 267 269 return 0; … … 271 273 *dest=t; 272 274 275 return 1; 276 } 277 278 /** Read a scalar. 279 * 280 * Read a big-endian scalar of length bytes, respecting packet 281 * boundaries (by calling limited_read() to read the raw data). 282 * 283 * The value read is stored in a size_t, which is a different size 284 * from an unsigned on some platforms. 285 * 286 * This function makes sure to respect packet boundaries. 287 * 288 * \param *dest The scalar value is stored here 289 * \param length How many bytes make up this scalar (at most 4) 290 * \param *region Pointer to current packet region 291 * \param *opt Pointer to parse options to be used 292 * \param *cb The callback 293 * \return 1 on success, 0 on error (calls the cb with OPS_PARSER_ERROR in limited_read()). 294 * 295 * \see RFC2440bis-12 3.1 296 */ 297 static int limited_read_size_t_scalar(size_t *dest,unsigned length, 298 ops_region_t *region, 299 ops_parse_options_t *opt) 300 { 301 unsigned tmp; 302 303 assert(sizeof(*dest) >= 4); 304 305 /* Note that because the scalar is at most 4 bytes, we don't care 306 if size_t is bigger than usigned */ 307 if(!limited_read_scalar(&tmp,length,region,opt)) 308 return 0; 309 310 *dest=tmp; 273 311 return 1; 274 312 } … … 1000 1038 /* 2 octets of name length */ 1001 1039 1002 if (!limited_read_s calar(&C.ss_notation_data.name.len, 2,1003 &subregion, opt))1040 if (!limited_read_size_t_scalar(&C.ss_notation_data.name.len, 2, 1041 &subregion, opt)) 1004 1042 return 0; 1005 1043 1006 1044 /* 2 octets of value length */ 1007 1045 1008 if (!limited_read_s calar(&C.ss_notation_data.value.len, 2,1009 &subregion, opt))1046 if (!limited_read_size_t_scalar(&C.ss_notation_data.value.len, 2, 1047 &subregion, opt)) 1010 1048 return 0; 1011 1049
