[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Path and argument problem... solution?
From: |
Jan-Henrik Haukeland |
Subject: |
Re: Path and argument problem... solution? |
Date: |
28 Aug 2002 16:58:40 +0200 |
User-agent: |
Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Civil Service) |
Christian Hopp <address@hidden> writes:
> I thought a bit about the thread flying around last month about
> parsing paths and arguments.
>
> Solution(?)... we use start conditions.
Flex start conditions is a good idea for doing this and probably the
best method. But it's not trivial. But first allow me to lay out the
premises:
- Arguments are only parsed for start and stop program statements
- A (program, argument) tuple is always enclosed with quotes, if not
it's only a program statement. For instance:
start program = /sbin/myserver
or with arguments
start program = "/sbin/myserver arg1 arg2... argN"
- Thus we must start a condition after and only after a START or STOP
token is read and the next char we hit is a '"' char.
- So far so good, but things starts to be slightly complicated
because an argument tuple can span over several lines and be a
script. For instance this should be a legal start statement entry:
start = "/bin/sh -c {
echo $$> /tmp/pid;
/sbin/myserver -x -y -z;
}"
If we say that the program is /bin/sh and that there are only two
arguments, namely "-c" and "{..}" it actually doesn't have to be so
complicated.
- Hm, this may not be so difficult after all, unless you see other
complications?
- Finally we should change the Process_T object to use a Command_T
object for the start and stop programs. That is:
typedef struct myprocess {
..
Command_T start;
Command_T stop;
..
} *Process_T;
And where the Command_T object layout is as follows;
typedef struct mycommand {
char *program;
char **arguments;
} *Command_T;
Where the program entry is the command to start the program and
arguments are a NULL terminated string array with program as the
first argument. In this way the command object can be used
directely in spawn to execute a program:
void spawn(Command_T C) {
...
(void) execv(C->program, C->arguments);
...
}
- In fact this simplifies the code a great deal and is something we
should try to implement I belive.
> I think it would be even useful to clean up the whole language a
> little, tiny bit. (-:
Absolutely. Do you have time and would you like to give yours and this
proposal a try? If not it looks interesting and something I could do
to get my mind of the zervlet stuff I'm working with now.
> PS: Hauk, I hope you had a nice swim.
Well, actually not, the weather suddenly turned for the worse, and now
when I'm back it looks good again, of course.
--
Jan-Henrik Haukeland
- Path and argument problem... solution?, Christian Hopp, 2002/08/27
- Re: Path and argument problem... solution?,
Jan-Henrik Haukeland <=
- Re: Path and argument problem... solution?, Christian Hopp, 2002/08/29
- Re: Path and argument problem... solution?, Jan-Henrik Haukeland, 2002/08/29
- Re: Path and argument problem... solution?, Christian Hopp, 2002/08/30
- Re: Path and argument problem... solution?, Jan-Henrik Haukeland, 2002/08/30
- Re: Path and argument problem... solution?, Christian Hopp, 2002/08/30
- Re: Path and argument problem... solution?, Christian Hopp, 2002/08/30
- Re: Path and argument problem... solution?, Jan-Henrik Haukeland, 2002/08/30
- Re: Path and argument problem... solution?, Christian Hopp, 2002/08/30
- Re: Path and argument problem... solution?, Jan-Henrik Haukeland, 2002/08/30
- Re: Path and argument problem... solution?, Rory Toma, 2002/08/30