Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 3173 → Rev 3174

/branches/dynload/uspace/app/cli/cli.c
41,7 → 41,10
#define LINE_BUFFER_SIZE 128
static char line_buffer[LINE_BUFFER_SIZE];
 
void read_line(char *buffer, int n)
#define MAX_ARGS 16
static char *argv_buf[MAX_ARGS + 1];
 
static void read_line(char *buffer, int n)
{
char c;
int chars;
69,7 → 72,35
buffer[chars] = '\0';
}
 
static void program_run(void)
{
char *p;
int n;
 
p = line_buffer;
n = 0;
 
while (n < MAX_ARGS) {
argv_buf[n++] = p;
p = strchr(p, ' ');
if (p == NULL) break;
 
*p++ = '\0';
}
argv_buf[n] = NULL;
 
printf("spawn task '%s' with %d args\n", argv_buf[0], n);
printf("args:");
int i;
for (i = 0; i < n; ++i) {
printf(" '%s'", argv_buf[i]);
}
printf("\n");
 
task_spawn_ex(argv_buf[0], argv_buf);
}
 
 
int main(int argc, char *argv[])
{
printf("This is CLI\n");
79,9 → 110,9
printf("'%s'\n", line_buffer);
if (strcmp(line_buffer, "exit") == 0)
break;
printf("spawn task\n");
if (line_buffer[0] != '\0')
task_spawn_ex(line_buffer, NULL);
program_run();
}
 
printf("Bye\n");