"Fossies" - the Fresh Open Source Software Archive

Member "dosemu-1.4.0/src/plugin/commands/cmdline.c" (4 May 2007, 964 Bytes) of package /linux/misc/old/dosemu-1.4.0.tgz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "cmdline.c" see the Fossies "Dox" file reference documentation.

    1 /*
    2  * (C) Copyright 1992, ..., 2007 the "DOSEMU-Development-Team".
    3  *
    4  * for details see file COPYING.DOSEMU in the DOSEMU distribution
    5  */
    6 
    7 /* a port of CMDLINE.AWK */
    8 
    9 #include <stdio.h>
   10 #include <stdlib.h>
   11 #include <string.h>
   12 
   13 
   14 #include "config.h"
   15 #include "emu.h"
   16 #include "memory.h"
   17 #include "doshelpers.h"
   18 #include "builtins.h"
   19 #include "msetenv.h"
   20 
   21 #include "cmdline.h"
   22 
   23 #define printf  com_printf
   24 #define perror  com_printf
   25 #define read    com_dosread
   26 
   27 #define CMDBUFFSIZE 256
   28 /* This program just reads stdin... */
   29 int cmdline_main(int argc, char **argv)
   30 {
   31     char *buff = malloc(CMDBUFFSIZE), *p, *q, *endb;
   32 
   33 
   34     if (!buff) {
   35         perror("malloc failure");
   36         return(1);
   37     }
   38     *(endb = buff + read(0,buff,CMDBUFFSIZE)) = '\0';
   39     for (p = buff; p < endb; p = q + strlen(q)+1)
   40          if (*p != '-' && ((q = strchr(p,'='))!=0)) {
   41              *q++ = '\0';
   42              if (msetenv(p,q)) {
   43                  free(buff);
   44              return (1);
   45              }
   46          }
   47          else q = p;
   48     free(buff);
   49     return 0;
   50 }