Deleted Added
full compact
command.c (8584) command.c (8589)
1/*
2 * The new sysinstall program.
3 *
4 * This is probably the last program in the `sysinstall' line - the next
5 * generation being essentially a complete rewrite.
6 *
1/*
2 * The new sysinstall program.
3 *
4 * This is probably the last program in the `sysinstall' line - the next
5 * generation being essentially a complete rewrite.
6 *
7 * $Id: command.c,v 1.4 1995/05/16 11:37:07 jkh Exp $
7 * $Id: command.c,v 1.5 1995/05/18 02:42:31 jkh Exp $
8 *
9 * Copyright (c) 1995
10 * Jordan Hubbard. All rights reserved.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright

--- 116 unchanged lines hidden (view full) ---

132 if (numCommands == MAX_CMDS)
133 msgFatal("More than %d commands accumulated??", MAX_CMDS);
134
135 /* If we fell to here, it's a new key */
136 commandStack[numCommands] = safe_malloc(sizeof(Command));
137 strcpy(commandStack[numCommands]->key, key);
138 commandStack[numCommands]->ncmds = 1;
139 commandStack[numCommands]->cmds[0].type = CMD_FUNCTION;
8 *
9 * Copyright (c) 1995
10 * Jordan Hubbard. All rights reserved.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright

--- 116 unchanged lines hidden (view full) ---

132 if (numCommands == MAX_CMDS)
133 msgFatal("More than %d commands accumulated??", MAX_CMDS);
134
135 /* If we fell to here, it's a new key */
136 commandStack[numCommands] = safe_malloc(sizeof(Command));
137 strcpy(commandStack[numCommands]->key, key);
138 commandStack[numCommands]->ncmds = 1;
139 commandStack[numCommands]->cmds[0].type = CMD_FUNCTION;
140 commandStack[numCommands++]->cmds[0].ptr = (void *)func;
140 commandStack[numCommands]->cmds[0].ptr = (void *)func;
141 commandStack[numCommands++]->cmds[0].data = data;
141}
142
143/* arg to sort */
144static int
145sort_compare(const void *p1, const void *p2)
146{
147 return strcmp(((Command *)p1)->key, ((Command *)p2)->key);
148}

--- 10 unchanged lines hidden (view full) ---

159{
160 int i, j, ret;
161 commandFunc func;
162
163 for (i = 0; i < numCommands; i++) {
164 for (j = 0; j < commandStack[i]->ncmds; j++) {
165 /* If it's a shell command, run system on it */
166 if (commandStack[i]->cmds[j].type == CMD_SHELL) {
142}
143
144/* arg to sort */
145static int
146sort_compare(const void *p1, const void *p2)
147{
148 return strcmp(((Command *)p1)->key, ((Command *)p2)->key);
149}

--- 10 unchanged lines hidden (view full) ---

160{
161 int i, j, ret;
162 commandFunc func;
163
164 for (i = 0; i < numCommands; i++) {
165 for (j = 0; j < commandStack[i]->ncmds; j++) {
166 /* If it's a shell command, run system on it */
167 if (commandStack[i]->cmds[j].type == CMD_SHELL) {
167 msgNotify("Executing command: %s",
168 commandStack[i]->cmds[j].ptr);
168 msgNotify("Executing command: %s", commandStack[i]->cmds[j].ptr);
169 ret = vsystem((char *)commandStack[i]->cmds[j].ptr);
169 ret = vsystem((char *)commandStack[i]->cmds[j].ptr);
170 msgDebug("Command `%s' returns status %d\n",
171 commandStack[i]->cmds[j].ptr, ret);
170 msgDebug("Command `%s' returns status %d\n", commandStack[i]->cmds[j].ptr, ret);
172 }
173 else {
174 /* It's a function pointer - call it with the key and the data */
175 func = (commandFunc)commandStack[i]->cmds[j].ptr;
176 msgNotify("Executing internal command @ %0x", func);
171 }
172 else {
173 /* It's a function pointer - call it with the key and the data */
174 func = (commandFunc)commandStack[i]->cmds[j].ptr;
175 msgNotify("Executing internal command @ %0x", func);
177 ret = (*func)(commandStack[i]->key,
178 commandStack[i]->cmds[j].data);
179 msgDebug("Function @ %x returns status %d\n",
180 commandStack[i]->cmds[j].ptr, ret);
176 ret = (*func)(commandStack[i]->key, commandStack[i]->cmds[j].data);
177 msgDebug("Function @ %x returns status %d\n", commandStack[i]->cmds[j].ptr, ret);
181 }
182 }
183 }
184}
178 }
179 }
180 }
181}