File: bitmap.c

package info (click to toggle)
twin 0.4.0-4
  • links: PTS
  • area: main
  • in suites: woody
  • size: 3,804 kB
  • ctags: 23,904
  • sloc: ansic: 61,860; cpp: 1,023; makefile: 777; sh: 552; lex: 302; yacc: 231
file content (37 lines) | stat: -rw-r--r-- 574 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37

#include <stdio.h>


unsigned long bitmap; /* support at least up to 32 config entries */
int conf_n;
char **conf_list;

static int print_conf(void) {
    unsigned long b;
    int i;
    
    for (b = bitmap, i = conf_n - 1; i >= 0; i--) {
	if (b & 1)
	    printf("-D%s ", conf_list[i]);
	b >>= 1;
    }
    printf("\n");
    if (b)
	/* overflow : we have finished */
	return 0;
    return 1;
}
    
int main(int argc, char *argv[]) {

    conf_n = --argc;
    conf_list = ++argv; 

    while (++bitmap) {
	if (print_conf() == 0)
	    return 0;
    }
    
    return 1;
}