コード例 #1
0
ファイル: init.c プロジェクト: LolHens/mikrOS
int main(int argc, char* args[])
{
    printf("[ibin/init] Init process started... :) Thats so good!\n");
    printf("[ibin/init] Switching into TTY to VGA mode.\nIf you see this something probably went wrong.\n");

    HANDLE cntrl = fmkfifo("/var/cntrl/init");

    texec("/ibin/ttytovga", 0);
    waitResp(cntrl);

    setstdout("/dev/tty0");
    setstdin ("/dev/keyboard");
    setstderr("/dev/tty0");

    printf("[init] now working on tty0\n");

    print_memstat();

    printf("[init] executing virtual file drivers\n");
    texec("/ibin/urnd_prov", 0);
    waitResp(cntrl);

    printf("[init] switching to shell\n");

    char* testparams[] = {
        "test1",
        "test2",
        0
    };

    texec("/ibin/csh", 0);

    while(1);

    return 0;
}
コード例 #2
0
ファイル: rpcc.C プロジェクト: gildafnai82/craq
int
main (int argc, char **argv)
{
  pid_t child;
  int an;
  vec<const char *> av;
  char *fname = NULL;
  char *basename;
  enum { BAD, HEADER, CFILE, PYTHON, PYL, PYH, PYS } mode = BAD;
  void (*fn) (str) = NULL;
  int len;

  av.push_back (PATH_CPP);
  av.push_back ("-DRPCC");
  av.push_back (NULL);

  for (an = 1; an < argc; an++) {
    char *arg = argv[an];
    int arglen = strlen (arg);

    if (arg[0] == '-' && (arg[1] == 'D' || arg[1] == 'I'))
      av.push_back (arg);
    else if (!fname && arglen > 2 && arg[0] != '-'
	     && arg[arglen-1] == 'x' && arg[arglen-2] == '.')
      fname = arg;
    else if (!strcmp (arg, "-h") && mode == BAD)
      mode = HEADER;
    else if (!strcmp (arg, "-c") && mode == BAD)
      mode = CFILE;
    else if (!strcmp (arg, "-python") && mode == BAD)
      mode = PYTHON;
    else if (!strcmp (arg, "-pyl") && mode == BAD)
      mode = PYL;
    else if (!strcmp (arg, "-pyh") && mode == BAD)
      mode = PYH;
    else if (!strcmp (arg, "-pys") && mode == BAD)
      mode = PYS;
    else if (!strcmp (arg, "-o") && !outfile && ++an < argc)
      outfile = argv[an];
    else if (!strncmp (arg, "-o", 2) && !outfile && arg[2])
      outfile = arg + 2;
    else if (!strcmp (arg, "-P") && !idprefix && ++an < argc)
      idprefix = argv[an];
    else if (!strncmp (arg, "-P", 2) && !idprefix && arg[2])
      idprefix = arg + 2;
    else if (!strcmp (arg, "-n") &&  !python_module_name && ++an < argc)
      python_module_name = argv[an];
    else if (!strncmp (arg, "-n", 2) && !python_module_name && arg[2])
      python_module_name = arg + 2;
    else 
      usage ();
  }
  if (python_module_name && !(mode == PYL || mode == PYS)) {
    warn << "-n parameter only valid with -pyl or -pys\n";
    usage ();
  }
  if (!fname)
    usage ();

  if (idprefix)
    idprefix = idprefix << "_";

  av.push_back (fname);
  av.push_back (NULL);

  if ((basename = strrchr (fname, '/')))
    basename++;
  else
    basename = fname;
  len = strlen (basename);

  switch (mode) {
  case HEADER:
    av[2] = "-DRPCC_H";
    fn = genheader;
    if (!outfile)
      outfile = strbuf ("%.*sh", len - 1, basename);
    break;
  case CFILE:
    av[2] = "-DRPCC_C";
    fn = gencfile;
    if (!outfile)
      outfile = strbuf ("%.*sC", len - 1, basename);
    break;
  case PYTHON:
    av[2] = "-DRPCC_P";
    fn = genpython;
    if (!outfile)
      outfile = strbuf ("%.*spy", len - 1, basename);
     break;
  case PYL:
    av[2] = "-DRPCC_PYL";
    fn = genpyc_lib;
    // foo.x -> foo_lib.C
    if (!outfile)
      outfile = strbuf ("%.*s_lib.C", len - 2, basename);
    break;
  case PYH:
    av[2] = "-DRPCC_PYH";
    fn = genpyh;
    if (!outfile)
      outfile = strbuf ("%.*sh", len -1, basename);
    break;
  case PYS:
    av[2] = "-DRPCC_PYS";
    fn = genpyc_so;
    // foo.x -> foo_so.C
    if (!outfile)
      outfile = strbuf ("%.*s_so.C", len -2, basename);
    break;
  default:
    usage ();
    break;
  }

  child = runcpp (av.base ());

  if (outfile != "-") {
    if (outfile[0] != '|')
      atexit (cleanup);
    setstdout ();
  }

  make_sync (0);
  yyparse ();
  checkliterals ();
  if (outfile != "-" && outfile[0] != '|')
    fn (outfile);
  else
    fn (fname);
#if 0
  chldcb (child, wrap (reapcpp));
  amain ();
#else
  int status;
  if (waitpid (child, &status, 0) < 0)
    fatal ("waitpid: %m\n");
  reapcpp (status);
#endif
  return 0;
}