comparison toys/posix/od.c @ 674:7e846e281e38

New build infrastructure to generate FLAG_ macros and TT alias, #define FOR_commandname before #including toys.h to trigger it. Rename DEFINE_GLOBALS() to just GLOBALS() (because I could never remember if it was DECLARE_GLOBALS). Convert existing commands to use new infrastructure, and replace optflag constants with FLAG_ macros where appropriate.
author Rob Landley <rob@landley.net>
date Mon, 08 Oct 2012 00:02:30 -0500
parents 6df4ccc0acbe
children 786841fdb1e0
comparison
equal deleted inserted replaced
673:c102f31a753e 674:7e846e281e38
17 17
18 -A Address base (decimal, octal, hexdecimal, none) 18 -A Address base (decimal, octal, hexdecimal, none)
19 -t output type(s) a (ascii) c (char) d (decimal) foux 19 -t output type(s) a (ascii) c (char) d (decimal) foux
20 */ 20 */
21 21
22 #define FOR_od
22 #include "toys.h" 23 #include "toys.h"
23 24
24 #define FLAG_t (1 << 0) 25 GLOBALS(
25 #define FLAG_A (1 << 1)
26 #define FLAG_b (1 << 2)
27 #define FLAG_c (1 << 3)
28 #define FLAG_d (1 << 4)
29 #define FLAG_o (1 << 5)
30 #define FLAG_s (1 << 6)
31 #define FLAG_x (1 << 7)
32 #define FLAG_N (1 << 8)
33 #define FLAG_v (1 << 9)
34
35 DEFINE_GLOBALS(
36 struct arg_list *output_base; 26 struct arg_list *output_base;
37 char *address_base; 27 char *address_base;
38 long max_count; 28 long max_count;
39 long jump_bytes; 29 long jump_bytes;
40 30
41 unsigned types, leftover, star, address_idx; 31 unsigned types, leftover, star, address_idx;
42 char *buf; 32 char *buf;
43 uint64_t bufs[4]; // force 64-bit alignment 33 uint64_t bufs[4]; // force 64-bit alignment
44 off_t pos; 34 off_t pos;
45 ) 35 )
46
47 #define TT this.od
48 36
49 static char *ascii = "nulsohstxetxeotenqackbel bs ht nl vt ff cr so si" 37 static char *ascii = "nulsohstxetxeotenqackbel bs ht nl vt ff cr so si"
50 "dledc1dc2dc3dc4naksynetbcan emsubesc fs gs rs us sp"; 38 "dledc1dc2dc3dc4naksynetbcan emsubesc fs gs rs us sp";
51 39
52 struct odtype { 40 struct odtype {