1 /* xlockgen --- generates launcher include file */
2 /* @(#)xlockgen.lex 5.0 2000/11/01 xlockmore"
3 /*
4 /* Copyright (c) Charles Vidal */
5
6 /*
7 * to help adminitration and utils for launcher(s)
8 * this file replace token by all modes token :
9 * LISTMOTIF, LISTTCL, LISTGTK
10 * utils :
11 * If you want all modes of xlock:
12 * xlockgen -allmodes
13 * to see all mode : in bash
14 * for i in `./xlockgen -allmodes`
15 * do
16 * xlock -mode $i
17 * done
18 *
19 * REVISION HISTORY:
20 * 99/10/10: fixes from Eric Lassauge <lassauge AT users.sourceforge.net> :
21 * - include "config.h"
22 * - new lmode.h
23 * - new token LISTGTK
24 * - header
25 *
26 */
27
28 %{
29 #include <stdio.h>
30 #include <string.h>
31
32 /* #include "../../config.h" */
33 #include "lmode.h"
34
35 char *Begin="\"";
36 char *Sep="\",";
37 char *End="\"";
38 %}
39
40 %%
41 "$%LISTMOTIF" {
42 int i;
43 int numprocs = sizeof (LockProcs) / sizeof (LockProcs[0]);
44
45 for (i = 0; i < numprocs; i++) {
46 if (LockProcs[i].define != NULL)
47 printf("%s\n", LockProcs[i].define);
48 if (i != numprocs - 1) {
49 printf("{(char *) \"%s\", ", LockProcs[i].cmdline_arg);
50 printf("(char *) \"%s\"},\n", LockProcs[i].desc);
51 } else {
52 printf("{(char *) \"%s\", ", LockProcs[i].cmdline_arg);
53 printf("(char *) \"%s\"},\n", LockProcs[i].desc);
54 }
55 if (LockProcs[i].define != NULL)
56 printf("#endif\n");
57 }
58 }
59 "$%LISTGTK" {
60 int i;
61 int numprocs = sizeof (LockProcs) / sizeof (LockProcs[0]);
62
63 for (i = 0; i < numprocs; i++) {
64 if (LockProcs[i].define != NULL)
65 printf("%s\n", LockProcs[i].define);
66 printf("\t{\"%s\",\n", LockProcs[i].cmdline_arg);
67 printf("\t %d, %d, %d, %d, %2.2f,\n",
68 LockProcs[i].def_delay,
69 LockProcs[i].def_count,
70 LockProcs[i].def_cycles,
71 LockProcs[i].def_size,
72 LockProcs[i].def_saturation);
73 printf("\t \"%s\", (void *) NULL},\n", LockProcs[i].desc);
74 if (LockProcs[i].define != NULL)
75 printf("#endif\n");
76 }
77 }
78 "$%LISTTCL" {
79 int i;
80 int numprocs = sizeof (LockProcs) / sizeof (LockProcs[0]);
81
82 for (i = 0; i < numprocs; i++) {
83 printf("%s\\\n", LockProcs[i].cmdline_arg);
84 }
85 }
86 "$%LISTJAVA" {
87 int i;
88 int numprocs = sizeof (LockProcs) / sizeof (LockProcs[0]);
89
90 for (i = 0; i < numprocs; i++) {
91 printf(" list.add(\"%s\");\n", LockProcs[i].cmdline_arg);
92 }
93 }
94 %%
95 void usage() {
96 printf("xlockgen :\n");
97 printf("\t-allmodes\n");
98 printf("or to be used in \n");
99 }
100
main(int argc,char * argv[])101 int main(int argc, char *argv[])
102 {
103 if (argc>1) {
104 if (!strcmp("-allmodes", argv[1])) {
105 int i;
106 int numprocs = sizeof (LockProcs) / sizeof (LockProcs[0]);
107
108 for (i = 0; i < numprocs; i++)
109 printf("%s\n", LockProcs[i].cmdline_arg);
110 exit(0);
111 }
112 if (!strcmp("--help", argv[1]) ||
113 !strcmp("-help", argv[1]) ||
114 !strcmp("-?", argv[1]) ||
115 !strcmp("-h", argv[1])) {
116 usage();
117 exit(0);
118 }
119 }
120 yylex();
121 }
122