[hashcash] more getopt -- let's fix it (Re: minting with "-z")

  • From: Adam Back <adam@xxxxxxxxxxxxxxx>
  • To: hashcash@xxxxxxxxxxxxx
  • Date: Wed, 1 Sep 2004 04:53:02 -0400

Yes more of the same -- the same getopt(3) difference on BSD vs linux;
the BSD one simply can't cope with ordered args -- it shuffles them
all to the end where they lose their context and meaning as far as
hashcash is concerned.

I think it's quite straight-forward to put some #ifdefs in a file
gnut_getopt.c which #includes getopt.c only on architectures with
incompatible getopt.  What is the #define for BSD+MAC?

__MACH__ jonathan mentioned for OSX
__BSD what is the thing for BSD?

actually a perhaps simpler way to do it is look for GNU, but I didn't
see an option for that in Jonathan's output.  Is __GNUC__ a good
indication of having a GNU glibc?  Maybe a rough approximation.

I tried: 

$ cat /usr/include/getopt.h | gcc -E -dD - 

looking at that maybe #include <features.h> -- on linux this defines
POSIX levels -- does BSD claim to support POSIX?  As far as I could
tell, the getopt optionstring leading "-" for positional argument
parsing (returns 1 for arguments as they occure between flags) is a
POSIX feature, but not completely clear.  <features.h> also defines
__GNU_LIBRARY_ which might be a better bet.  What will DOS, OSX and
BSD think of including <features.h>?

$ echo "" | gcc -E -dD -
#define __i386 1
#define __i386__ 1
#define i386 1
#define __tune_i586__ 1
#define __tune_pentium__ 1
#define __linux 1
#define __linux__ 1
#define linux 1
#define __unix 1
#define __unix__ 1
#define unix 1
#define __ELF__ 1
#define __gnu_linux__ 1
# 1 "<command line>"
#define __GNUC__ 3
#define __GNUC_MINOR__ 3
#define __GNUC_PATCHLEVEL__ 4
# 1 "<stdin>"

Adam

On Tue, Aug 31, 2004 at 09:30:26PM -0400, Atom 'Smasher' wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
> 
> on my freeBSD box (i haven't tested on linux), minting with "-z" has no 
> effect. hashcash will mint stamps with a 6 digit date field regardless of 
> what value i provide for "-z"... as long as it's an even number between 2 
> and 12... outside of that range (or an odd number) will produce an error.
> 
> $ hashcash -qb 2 -mXr FOO-BAR -z 2
> X-Hashcash: 1:2:040901:foo-bar::18d4e01c31afe03b:7
> 
> $ hashcash -qb 2 -mXr FOO-BAR -z 4
> X-Hashcash: 1:2:040901:foo-bar::2790ab8ac63bde92:4
> 
> $ hashcash -qb 2 -mXr FOO-BAR -z 6
> X-Hashcash: 1:2:040901:foo-bar::85b3d32d4636247f:1
> 
> $ hashcash -qb 2 -mXr FOO-BAR -z 8
> X-Hashcash: 1:2:040901:foo-bar::da7c7cad2d0330a8:1
> 
> $ hashcash -qb 2 -mXr FOO-BAR -z 10
> X-Hashcash: 1:2:040901:foo-bar::2e93e4008002ace3:6
> 
> $ hashcash -qb 2 -mXr FOO-BAR -z 12
> X-Hashcash: 1:2:040901:foo-bar::3ed77d109d192346:0

Other related posts: