VirtualBox

Changeset 199 in kBuild


Ignore:
Timestamp:
Dec 17, 2004 4:51:58 AM (20 years ago)
Author:
bird
Message:

...

Location:
trunk/src
Files:
4 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kShell/kShell.c

    r49 r199  
    158158 *
    159159 * <b>Syntax: chdir <directory> </b>
    160  *
    161  *
    162  *
    163  * @subsubsection       mkdir
    164  * Create directory.
    165  *
    166  * <b>Syntax:  mkdir <directory> </b>
    167  *
    168  * Specify one directory to create.
    169160 *
    170161 *
     
    311302int             kshellError(const char *pszCmd, const char *pszMessage, ...);
    312303
     304int             kshellCmd_echo(const char *pszCmd, PKSHELLWORDS pWords);
     305int             kshellCmd_log(const char *pszCmd, PKSHELLWORDS pWords);
    313306int             kshellCmd_copy(const char *pszCmd, PKSHELLWORDS pWords);
    314307int             kshellCmd_copytree(const char *pszCmd, PKSHELLWORDS pWords);
     
    324317int             kshellCmd_pushenv(const char *pszCmd, PKSHELLWORDS pWords);
    325318int             kshellCmd_popenv(const char *pszCmd, PKSHELLWORDS pWords);
    326 int             kshellCmd_echo(const char *pszCmd, PKSHELLWORDS pWords);
    327319int             kshellCmd_write(const char *pszCmd, PKSHELLWORDS pWords);
    328320int             kshellCmd_ExecuteProgram(const char *pszCmd, PKSHELLWORDS pWords);
     
    410402    } aCmds[] =
    411403    {
     404        {"echo",        MAX_WORDS,  kshellCmd_echo},
     405        {"log",         2,          kshellCmd_log},
    412406        {"copy",        MAX_WORDS,  kshellCmd_copy},
    413407        {"copytree",    3,          kshellCmd_copytree},
     
    423417        {"pushenv",     MAX_WORDS,  kshellCmd_pushenv},
    424418        {"popenv",      1,          kshellCmd_popenv},
    425         {"echo",        2,          kshellCmd_echo},
    426419        {"write",       2,          kshellCmd_write},
    427420
     
    698691
    699692
     693
    700694/*
    701695 *
     
    704698 *
    705699 */
     700
     701
     702/** @subsubsection      echo
     703 * Prints a message to stdout.
     704 *
     705 * <b>Syntax: echo <level> <message>
     706 *
     707 * The message is printed word for word normalize with a single space between
     708 * the words. It's therefore a good thing to quote the message.
     709 *
     710 * The message can be empty. Then a blank line will be printed.
     711 */
     712int             kshellCmd_echo(const char *pszCmd, PKSHELLWORDS pWords)
     713{
     714    int         i;
     715
     716    /* output all the words forcing one space separation */
     717    for (i = 2; i < pWords->cWords; i++)
     718    {
     719        if (i != 2)
     720            fputc(' ', stdout);
     721        fwrite(pWords->aWords[i].pszWord, pWords->aWords[i].cchWord, 1, stdout);
     722    }
     723
     724    /* new line */
     725    fputc('\n', stdout);
     726    fflush(stdout);
     727
     728    return 0;
     729}
     730
     731
     732/** @subsubsection      log
     733 * Prints a message to stdout.
     734 *
     735 * <b>Syntax: log <level> <message>
     736 *
     737 * Level is verbosity level of the message. This is compared with the
     738 * KBUILD_MSG_LEVEL environment variable. The message is suppressed if the
     739 * level is lower that KBUILD_MSG_LEVEL.
     740 *
     741 * The message is printed word for word normalize with a single space between
     742 * the words. It's therefore a good thing to quote the message.
     743 *
     744 * The message can be empty. Then a blank line will be printed.
     745 */
     746int             kshellCmd_log(const char *pszCmd, PKSHELLWORDS pWords)
     747{
     748    int         rc = KSHELL_ERROR_SYNTAX_ERROR;
     749
     750    /*
     751     * Get the message level from the message.
     752     */
     753    if (pWords->cWords >= 2)
     754    {
     755        unsigned uMsgLevel = kStrToUDef(pWords->aWords[1].pszWord, -2, 0);
     756        if (uMsgLevel != -2)
     757        {
     758            if (uMsgLevel <= kEnvGetUDef("KBUILD_MSG_LEVEL", 0, 0))
     759            {
     760                /* output all the words forcing one space separation */
     761                pWords = kshellWordsParse(pszCmd, -1, pWords);
     762                if (pWords)
     763                {
     764                    int i;
     765                    for (i = 2; i < pWords->cWords; i++)
     766                    {
     767                        if (i != 2)
     768                            fputc(' ', stdout);
     769                        fwrite(pWords->aWords[i].pszWord, pWords->aWords[i].cchWord, 1, stdout);
     770                    }
     771                }
     772
     773                /* new line */
     774                fputc('\n', stdout);
     775                fflush(stdout);
     776            }
     777        }
     778        else
     779            kshellSyntaxError("log", "invalid message level!");
     780    }
     781    else
     782        kshellSyntaxError("log", "requires at least one argument!");
     783
     784    return -1;
     785}
     786
    706787
    707788
     
    820901}
    821902
    822 
     903/** @subsubsection      mkdir
     904 * Create directory.
     905 *
     906 * <b>Syntax:  mkdir <directory> [directory2[..]] </b>
     907 *
     908 * Specify zero or more directories to create. Necessary parent directories
     909 * will be created.
     910 *
     911 * If the directory exist no error is reported.
     912 * The command fails on the first failure, processing directories left to right.
     913 *
     914 * Mkdir is hence not suitable for making locks. Should such be needed a
     915 * dedicated command should be created for that purpose.
     916 *
     917 */
    823918int             kshellCmd_mkdir(const char *pszCmd, PKSHELLWORDS pWords)
    824919{
    825     return -1;
     920    int     rc = 0;
     921    int     i;
     922
     923    for (i = 1; i < pWords->cWords; i++)
     924    {
     925        /*
     926         * Allocate a buffer for canonizing the directory name and work in.
     927         */
     928        char *pszDir = kHeapAlloc(pWords->aWords[i].cchWord + KFILE_LENGTH);
     929        if (pszDir)
     930        {
     931            /*
     932             * Canonify the path to local default slash etc.
     933             */
     934            rc = kPathCanonifyEx(pWords->aWords[i].pszWord, NULL, KSHELL_SLASH, 0, psz);
     935            if (!rc)
     936            {
     937                kFileState
     938                /*
     939                 * Now we will enumerate the path towards the root and
     940                 * find the first existing directory. We need the mode
     941                 * of that directory.
     942                 */
     943
     944                char *psz =
     945            }
     946        }
     947
     948        rc = kDirCreate(
     949    }
     950
     951    return rc;
    826952}
    827953
     
    857983
    858984
    859 /** @subsubsection      echo
    860  * Prints a message to stdout.
    861  *
    862  * <b>Syntax: echo <level> <message>
    863  *
    864  * Level is verbosity level of the message. This is compared with the
    865  * KBUILD_MSG_LEVEL environment variable. The message is suppressed if the
    866  * level is lower that KBUILD_MSG_LEVEL.
    867  *
    868  * The message is printed word for word normalize with a single space between
    869  * the words. It's therefore a good thing to quote the message.
    870  *
    871  * The message can be empty. Then a blank line will be printed.
    872  */
    873 int             kshellCmd_echo(const char *pszCmd, PKSHELLWORDS pWords)
    874 {
    875     int         rc = KSHELL_ERROR_SYNTAX_ERROR;
    876 
    877     /*
    878      * Get the message level from the message.
    879      */
    880     if (pWords->cWords >= 2)
    881     {
    882         unsigned uMsgLevel = kStrToUDef(pWords->aWords[1].pszWord, -2, 0);
    883         if (uMsgLevel != -2)
    884         {
    885             if (uMsgLevel <= kEnvGetUDef("KBUILD_MSG_LEVEL", 0, 0))
    886             {
    887                 /* output all the words forcing one space separation */
    888                 pWords = kshellWordsParse(pszCmd, -1, pWords);
    889                 if (pWords)
    890                 {
    891                     int i;
    892                     for (i = 2; i < pWords->cWords; i++)
    893                         fwrite(pWords->aWords[i].pszWord, pWords->aWords[i].cchWord, 1, stdout);
    894                 }
    895 
    896                 /* new line */
    897                 fputc('\n', stdout);
    898                 fflush(stdout);
    899             }
    900         }
    901         else
    902             kshellSyntaxError("echo", "invalid message level!");
    903     }
    904     else
    905         kshellSyntaxError("echo", "requires at least one argument!");
    906 
    907     return -1;
    908 }
    909985
    910986
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette