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 *----------------------------------------------------------------------
48 static DFA mtable
[9][6] =
91 {0, 0}}, /* final state */
112 {0, 0}}, /* final state */
115 char * next_token (char *word
, char **next
)
121 t
= ret
= malloc (strlen (word
) + 1);
130 else if (*ptr
== '\\')
132 else if (*ptr
== '"')
134 else if (*ptr
== '\'')
136 else if (*ptr
== ' ' || *ptr
== '\t')
141 if (mtable
[state
][ctype
].output
)
147 state
= mtable
[state
][ctype
].nstate
;
149 if (mtable
[state
][0].output
< 0)
162 if (ctype
== PRC_EOS
)
171 extern void parse_command (char *command
, char ***argv
, int *argc
)
173 LinkedList
*list
= NULL
;
180 token
= next_token (line
, &line
);
183 list
= list_cons (token
, list
);
186 while (token
!= NULL
&& line
!= NULL
);
188 count
= list_length (list
);
189 *argv
= malloc (sizeof (char *) * count
);
193 (*argv
)[--i
] = list
->head
;
194 list_remove_head (&list
);
199 extern pid_t
execCommand (char *command
)
205 parse_command (command
, &argv
, &argc
);
212 if ((pid
= fork ()) == 0)
217 args
= malloc (sizeof (char *) * (argc
+ 1));
220 for (i
= 0; i
< argc
; i
++)
225 execvp (argv
[0], args
);