| 1 | /* $Id: kShellMain.c 19 2002-10-17 23:02:18Z bird $
|
|---|
| 2 | *
|
|---|
| 3 | * kShell - Mainprogram (intented for testing)
|
|---|
| 4 | *
|
|---|
| 5 | * Copyright (c) 2002 knut st. osmundsen <bird@anduin.net>
|
|---|
| 6 | *
|
|---|
| 7 | *
|
|---|
| 8 | * This file is part of kBuild.
|
|---|
| 9 | *
|
|---|
| 10 | * kBuild is free software; you can redistribute it and/or modify
|
|---|
| 11 | * it under the terms of the GNU Lesser General Public License as published
|
|---|
| 12 | * by the Free Software Foundation; either version 2 of the License, or
|
|---|
| 13 | * (at your option) any later version.
|
|---|
| 14 | *
|
|---|
| 15 | * kBuild is distributed in the hope that it will be useful,
|
|---|
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 18 | * GNU Lesser General Public License for more details.
|
|---|
| 19 | *
|
|---|
| 20 | * You should have received a copy of the GNU Lesser General Public License
|
|---|
| 21 | * along with kBuild; if not, write to the Free Software
|
|---|
| 22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|---|
| 23 | *
|
|---|
| 24 | */
|
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 | /*******************************************************************************
|
|---|
| 28 | * Header Files *
|
|---|
| 29 | *******************************************************************************/
|
|---|
| 30 | #include "kShell.h"
|
|---|
| 31 | #include <string.h>
|
|---|
| 32 |
|
|---|
| 33 |
|
|---|
| 34 | /**
|
|---|
| 35 | * Simple main program which will execute any arguments or
|
|---|
| 36 | * start in interactive mode if no parameters.
|
|---|
| 37 | */
|
|---|
| 38 | int main(int argc, char **argv)
|
|---|
| 39 | {
|
|---|
| 40 | static char szCmd[4096];
|
|---|
| 41 | int argi;
|
|---|
| 42 | int rc;
|
|---|
| 43 |
|
|---|
| 44 | /*
|
|---|
| 45 | * init the shell.
|
|---|
| 46 | */
|
|---|
| 47 | rc = kshellInit(1);
|
|---|
| 48 | if (rc)
|
|---|
| 49 | return rc;
|
|---|
| 50 |
|
|---|
| 51 |
|
|---|
| 52 | /*
|
|---|
| 53 | * If any arguments we'll execute them as a command.
|
|---|
| 54 | */
|
|---|
| 55 | if (argc > 1)
|
|---|
| 56 | {
|
|---|
| 57 | for (argi = 2, strcpy(&szCmd[0], argv[1]); argi < argc; argi++)
|
|---|
| 58 | strcat(strcat(&szCmd[0], " "), argv[argi]);
|
|---|
| 59 | rc = kshellExecute(szCmd);
|
|---|
| 60 | }
|
|---|
| 61 |
|
|---|
| 62 | /*
|
|---|
| 63 | * Interactive mode.
|
|---|
| 64 | */
|
|---|
| 65 | else
|
|---|
| 66 | {
|
|---|
| 67 | rc = kshellInteractive();
|
|---|
| 68 | }
|
|---|
| 69 |
|
|---|
| 70 |
|
|---|
| 71 | /*
|
|---|
| 72 | * Terminate the shell and exit.
|
|---|
| 73 | */
|
|---|
| 74 | kshellTerm();
|
|---|
| 75 |
|
|---|
| 76 | return rc;
|
|---|
| 77 | }
|
|---|