1 /* dock.c- built-in Dock module for WindowMaker
3 * WindowMaker window manager
5 * Copyright (c) 1997 Alfredo K. Kojima
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 *----------------------------------------------------------------------
30 * Divides a command line into a argv/argc pair.
31 *----------------------------------------------------------------------
46 static DFA mtable
[9][6] = {
47 {{3,1},{0,0},{4,0},{1,0},{8,0},{6,0}},
48 {{1,1},{1,1},{2,0},{3,0},{5,0},{1,1}},
49 {{1,1},{1,1},{1,1},{1,1},{5,0},{1,1}},
50 {{3,1},{5,0},{4,0},{1,0},{5,0},{6,0}},
51 {{3,1},{3,1},{3,1},{3,1},{5,0},{3,1}},
52 {{-1,-1},{0,0},{0,0},{0,0},{0,0},{0,0}}, /* final state */
53 {{6,1},{6,1},{7,0},{6,1},{5,0},{3,0}},
54 {{6,1},{6,1},{6,1},{6,1},{5,0},{6,1}},
55 {{-1,-1},{0,0},{0,0},{0,0},{0,0},{0,0}}, /* final state */
59 next_token(char *word
, char **next
)
65 t
= ret
= malloc(strlen(word
)+1);
79 else if (*ptr
==' ' || *ptr
=='\t')
84 if (mtable
[state
][ctype
].output
) {
88 state
= mtable
[state
][ctype
].nstate
;
90 if (mtable
[state
][0].output
<0) {
112 parse_command(char *command
, char ***argv
, int *argc
)
114 LinkedList
*list
= NULL
;
120 token
= next_token(line
, &line
);
122 list
= list_cons(token
, list
);
124 } while (token
!=NULL
&& line
!=NULL
);
126 count
= list_length(list
);
127 *argv
= malloc(sizeof(char*)*count
);
130 (*argv
)[--i
] = list
->head
;
131 list_remove_head(&list
);
137 execCommand(char *command
)
143 parse_command(command
, &argv
, &argc
);
149 if ((pid
=fork())==0) {
153 args
= malloc(sizeof(char*)*(argc
+1));
156 for (i
=0; i
<argc
; i
++) {
160 execvp(argv
[0], args
);