Ejemplo n.º 1
0
int main(int argc, char *argv[])
{
  Vstr_base *s2 = NULL;
  Vstr_base *s1 = ex_init(&s2);
  int count = 1;
  int use_mmap = CONF_USE_MMAP_DEF;

  /* parse command line arguments... */
  while (count < argc)
  { /* quick hack getopt_long */
    if (!strcmp("--", argv[count]))
    {
      ++count;
      break;
    }
    else if (!strcmp("--mmap", argv[count])) /* toggle use of mmap */
      use_mmap = !use_mmap;
    else if (!strcmp("--version", argv[count]))
    { /* print version and exit */
      vstr_add_fmt(s1, 0, "%s", "\
jsock_filter 1.0.0\n\
Written by James Antill\n\
\n\
Uses Vstr string library.\n\
");
      goto out;
    }
    else if (!strcmp("--help", argv[count]))
Ejemplo n.º 2
0
/* This is "dir_list", without any command line options */
int main(int argc, char *argv[])
{
  Vstr_base *tmp = NULL;
  Vstr_base *s1 = ex_init(&tmp); /* init the library etc. */
  int count = 1; /* skip the program name */
  DIR *dir = NULL;
  struct dirent *ent = NULL;
  int sizes = FALSE;
  int follow = FALSE;
  
  /* parse command line arguments... */
  while (count < argc)
  { /* quick hack getopt_long */
    if (!strcmp("--", argv[count]))
    {
      ++count;
      break;
    }
    else if (!strcmp("--size", argv[count]))
      sizes = !sizes;
    else if (!strcmp("--follow", argv[count]))
      follow = !follow;
    else if (!strcmp("--version", argv[count]))
    { /* print version and exit */
      vstr_add_fmt(s1, 0, "%s", "\
jdir_list 1.0.0\n\
Written by James Antill\n\
\n\
Uses Vstr string library.\n\
");
      goto out;
    }
    else if (!strcmp("--help", argv[count]))
Ejemplo n.º 3
0
int main(void)
{
	
  ex_init( ) ;
  char buf[16] ;
  while ( scanf( "%16s", buf )>0 ) {
    if ( strncmp( "quit", buf, 4 )==0 )
      break ;
    ex_sleep( 200 ) ;
  }
  ex_uninit( ) ;
  return 0 ;
}
Ejemplo n.º 4
0
int main(int argc, char *argv[])
{
  Vstr_base *s2 = NULL;
  Vstr_base *s1 = ex_init(&s2);
  int count = 1;

  /* if no arguments are given just do stdin to stdout */
  if (count >= argc)
  {
    io_fd_set_o_nonblock(STDIN_FILENO);
    ex_phones_name_read_fd_write_stdout(s1, s2, STDIN_FILENO);
  }

  /* loop through all arguments, open the file specified
   * and do the read/write loop */
  while (count < argc)
  {
    unsigned int ern = 0;

    if (s2->len <= EX_MAX_R_DATA_INCORE)
      vstr_sc_mmap_file(s2, s2->len, argv[count], 0, 0, &ern);

    if ((ern == VSTR_TYPE_SC_MMAP_FILE_ERR_FSTAT_ERRNO) ||
        (ern == VSTR_TYPE_SC_MMAP_FILE_ERR_MMAP_ERRNO) ||
        (ern == VSTR_TYPE_SC_MMAP_FILE_ERR_TOO_LARGE))
    {
      int fd = io_open(argv[count]);

      ex_phones_name_read_fd_write_stdout(s1, s2, fd);

      if (close(fd) == -1)
        warn("close(%s)", argv[count]);
    }
    else if (ern && (ern != VSTR_TYPE_SC_MMAP_FILE_ERR_CLOSE_ERRNO))
      err(EXIT_FAILURE, "add");
    else
      ex_phones_name_process_limit(s1, s2, EX_MAX_R_DATA_INCORE);
    
    ++count;
  }

  ex_phones_name_process_limit(s1, s2, 0);

  io_put_all(s1, STDOUT_FILENO);

  exit (ex_exit(s1, s2));
}
Ejemplo n.º 5
0
KPROXY_API f8_bool kproxy_init(int leakDetect)
{
	ITcpAdapter *a;	

	_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
	_CrtSetBreakAlloc(leakDetect);
	
	/* initialize and start kernel */
	ex_init();
	
	/* KERN_F_ENABLE_INPUT */

	x_buffer = (char *)__malloc__(LARGE_BUF_SIZE);
	x_buf_len = LARGE_BUF_SIZE;
	b_ShellExit = __false;	

	__new__(ITcpAdapter, a);
	proxy_adapter = __ucast__(ITcpAdapter, IKAdapter, a);

	sections = ke_get_blk(proxy_adapter->kernel, 0);
	assert(sections->uuid == BLK_ID_ROOT);

	create_resource(&sections->uuid);
	create_f8_uuid(&sections->h.uuid);
	create_resource(&sections->h.uuid);

	memset(fileName, 0 , sizeof(fileName));

	g_shell = shell_create(commands);
	
	reset_reg_map();
	init_blklib();
	init_clipboard();

	g_bDirty = __false;


	init_network(RTK_INIT_AS_SERVER, 0);
	vbus = connect_vbus(0xf8, VBUS_CONNECT_AS_SERVER, sr, 0);
	
	return __true;
}
Ejemplo n.º 6
0
int main(int argc, char *argv[])
{
  Vstr_base *s1 = NULL;
  Vstr_base *s2 = ex_init(&s1); /* init the library etc. */
  int count = 1; /* skip the program name */
  const char *def_name = "&lt;stdin&gt;";
  const char *output_tname = "html";
  
  if (!vstr_cntl_conf(s1->conf, VSTR_CNTL_CONF_SET_FMT_CHAR_ESC, '$') ||
      !vstr_sc_fmt_add_all(s1->conf))
    errno = ENOMEM, err(EXIT_FAILURE, "init");
    
  /* parse command line arguments... */
  while (count < argc)
  { /* quick hack getopt_long */
    if (!strcmp("--", argv[count]))
    {
      ++count;
      break;
    }
    EX_UTILS_GETOPT_CSTR("prefix-path",  def_prefix);
    EX_UTILS_GETOPT_CSTR("css-file",     css_fname);
    EX_UTILS_GETOPT_CSTR("cssfile",      css_fname);
    EX_UTILS_GETOPT_CSTR("css-filename", css_fname);
    EX_UTILS_GETOPT_CSTR("cssfilename",  css_fname);
    EX_UTILS_GETOPT_CSTR("name",         def_name);
    EX_UTILS_GETOPT_CSTR("output",       output_fname);
    EX_UTILS_GETOPT_TOGGLE("mtime",      output_mtime);
    EX_UTILS_GETOPT_TOGGLE("permissions",output_perms);
    EX_UTILS_GETOPT_TOGGLE("perms",      output_perms);
        /*      EX_UTILS_GETOPT_CSTR("style",        output_tname); */
    EX_UTILS_GETOPT_NUM("filemode",      output_fmode);
    else if (!strcmp("--version", argv[count]))
    { /* print version and exit */
      vstr_add_fmt(s1, 0, "%s", "\
and-dir_list2html 1.0.0\n\
Written by James Antill\n\
\n\
Uses Vstr string library.\n\
");
      goto out;
    }
Ejemplo n.º 7
0
int main(int argc, char *argv[])
{ /* This is "hexdump", as it should be by default */
  Vstr_base *s2 = NULL;
  Vstr_base *s1 = ex_init(&s2); /* init the library, and create two strings */
  int count = 1; /* skip the program name */
  unsigned int use_mmap = CONF_USE_MMAP_DEF;

  /* parse command line arguments... */
  while (count < argc)
  { /* quick hack getopt_long */
    if (!strcmp("--", argv[count]))
    {
      ++count;
      break;
    }
    else if (!strcmp("--mmap", argv[count])) /* toggle use of mmap */
      use_mmap = !use_mmap;
    
    else if (!strcmp("--none", argv[count])) /* choose what is displayed */
      prnt_high_chars = PRNT_NONE; /* just simple 7 bit ASCII, no spaces */
    else if (!strcmp("--space", argv[count]))
      prnt_high_chars = PRNT_SPAC; /* allow spaces */
    else if (!strcmp("--high", argv[count]))
      prnt_high_chars = PRNT_HIGH; /* allow high bit characters */
    
    else if (!strcmp("--version", argv[count]))
    { /* print version and exit */
      vstr_add_fmt(s1, 0, "%s", "\
jhexdump 1.0.0\n\
Written by James Antill\n\
\n\
Uses Vstr string library.\n\
");
      goto out;
    }
    else if (!strcmp("--help", argv[count]))
Ejemplo n.º 8
0
int main(int argc, char *argv[])
{
  Vstr_base *s1 = ex_init(NULL);
  mpz_t bignum;
  const char *loc_num_name = NULL;
  Vstr_ref *ref = NULL;
  const unsigned int num_flags = (VSTR_FLAG_PARSE_NUM_SEP |
                                  VSTR_FLAG_PARSE_NUM_SPACE);
  
  if (argc < 2)
    errx(EXIT_FAILURE, "No count specified");

  vstr_cntl_conf(s1->conf, VSTR_CNTL_CONF_SET_FMT_CHAR_ESC, '$');
  vstr_fmt_add(s1->conf, "<dMPZ:%p>", ex_usr_dmpz_cb,
               VSTR_TYPE_FMT_PTR_VOID, VSTR_TYPE_FMT_END);
  vstr_fmt_add(s1->conf, "<oMPZ:%p>", ex_usr_ompz_cb,
               VSTR_TYPE_FMT_PTR_VOID, VSTR_TYPE_FMT_END);
  vstr_fmt_add(s1->conf, "<xMPZ:%p>", ex_usr_xmpz_cb,
               VSTR_TYPE_FMT_PTR_VOID, VSTR_TYPE_FMT_END);
  vstr_fmt_add(s1->conf, "<bMPZ:%p>", ex_usr_bmpz_cb,
               VSTR_TYPE_FMT_PTR_VOID, VSTR_TYPE_FMT_END);

  setlocale(LC_ALL, "");
  loc_num_name = setlocale(LC_NUMERIC, NULL);
  
  if (!vstr_cntl_conf(s1->conf, VSTR_CNTL_CONF_SET_LOC_CSTR_AUTO_NAME_NUMERIC,
                      loc_num_name))
    errx(EXIT_FAILURE, "Couldn't change numeric locale info");

  mpz_init(bignum);
  
  if (!vstr_add_cstr_ptr(s1, 0, argv[1]) ||
      !vstr_parse_num(s1, 1, s1->len, num_flags, NULL, NULL, vmpz_num, bignum))
    errno = ENOMEM, err(EXIT_FAILURE, "Couldn't init number");

  vstr_del(s1, 1, s1->len);
    
#if (EX_GMP_NUMS_USE_TST)
  {
    mpz_abs(bignum, bignum);
    mpz_neg(bignum, bignum);
  do
  {
    mpz_neg(bignum, bignum);

    vstr_add_fmt(s1, s1->len, "%%'20.40d = <$'20.40<dMPZ:%p>>\n",
                 (void *)bignum);
    if (mpz_fits_slong_p(bignum))
    vstr_add_fmt(s1, s1->len, "%%'20.40d = <%'20.40ld>\n",
                 mpz_get_si(bignum));
    vstr_add_fmt(s1, s1->len, "%%'40.20d = <$'40.20<dMPZ:%p>>\n",
                 (void *)bignum);
    if (mpz_fits_slong_p(bignum))
    vstr_add_fmt(s1, s1->len, "%%'40.20d = <%'40.20ld>\n",
                 mpz_get_si(bignum));
    vstr_add_fmt(s1, s1->len, "%%'20.40o = <$'20.40<oMPZ:%p>>\n",
                 (void *)bignum);
    if ((mpz_sgn(bignum) != -1) && mpz_fits_slong_p(bignum))
    vstr_add_fmt(s1, s1->len, "%%'20.40o = <%'20.40lo>\n",
                 mpz_get_si(bignum));
    vstr_add_fmt(s1, s1->len, "%%'40.20o = <$'40.20<oMPZ:%p>>\n",
                 (void *)bignum);
    if ((mpz_sgn(bignum) != -1) && mpz_fits_slong_p(bignum))
    vstr_add_fmt(s1, s1->len, "%%'40.20o = <%'40.20lo>\n",
                 mpz_get_si(bignum));
    vstr_add_fmt(s1, s1->len, "%%'20.40x = <$'20.40<xMPZ:%p>>\n",
                 (void *)bignum);
    if ((mpz_sgn(bignum) != -1) && mpz_fits_slong_p(bignum))
    vstr_add_fmt(s1, s1->len, "%%'20.40x = <%'20.40lx>\n",
                 mpz_get_si(bignum));
    vstr_add_fmt(s1, s1->len, "%%'40.20x = <$'40.20<xMPZ:%p>>\n",
                 (void *)bignum);
    if ((mpz_sgn(bignum) != -1) && mpz_fits_slong_p(bignum))
    vstr_add_fmt(s1, s1->len, "%%'40.20x = <%'40.20lx>\n",
                 mpz_get_si(bignum));

    vstr_add_fmt(s1, s1->len, "%%#'40d   = <$#'40<dMPZ:%p>>\n",
                 (void *)bignum);
    if (mpz_fits_slong_p(bignum))
    vstr_add_fmt(s1, s1->len, "%%#'40d   = <%#'40ld>\n",
                 mpz_get_si(bignum));
    vstr_add_fmt(s1, s1->len, "%%#'-40d  = <$#'-40<dMPZ:%p>>\n",
                 (void *)bignum);
    if (mpz_fits_slong_p(bignum))
    vstr_add_fmt(s1, s1->len, "%%#'-40d  = <%#'-40ld>\n",
                 mpz_get_si(bignum));
    vstr_add_fmt(s1, s1->len, "%%#'40o   = <$#'40<oMPZ:%p>>\n",
                 (void *)bignum);
    if ((mpz_sgn(bignum) != -1) && mpz_fits_slong_p(bignum))
    vstr_add_fmt(s1, s1->len, "%%#'40o   = <%#'40lo>\n",
                 mpz_get_si(bignum));
    vstr_add_fmt(s1, s1->len, "%%#'-40o  = <$#'-40<oMPZ:%p>>\n",
                 (void *)bignum);
    if ((mpz_sgn(bignum) != -1) && mpz_fits_slong_p(bignum))
    vstr_add_fmt(s1, s1->len, "%%#'-40o  = <%#'-40lo>\n",
                 mpz_get_si(bignum));
    vstr_add_fmt(s1, s1->len, "%%#'40x   = <$#'40<xMPZ:%p>>\n",
                 (void *)bignum);
    if ((mpz_sgn(bignum) != -1) && mpz_fits_slong_p(bignum))
    vstr_add_fmt(s1, s1->len, "%%#'40x   = <%#'40lx>\n",
                 mpz_get_si(bignum));
    vstr_add_fmt(s1, s1->len, "%%#'-40x  = <$#'-40<xMPZ:%p>>\n",
                 (void *)bignum);
    if ((mpz_sgn(bignum) != -1) && mpz_fits_slong_p(bignum))
    vstr_add_fmt(s1, s1->len, "%%#'-40x  = <%#'-40lx>\n",
                 mpz_get_si(bignum));

    vstr_add_fmt(s1, s1->len, "%%#'b  = <$#'<bMPZ:%p>>\n",
                 (void *)bignum);
    
    vstr_add_rep_chr(s1, s1->len, '-', 79);
    vstr_add_rep_chr(s1, s1->len, '\n', 1);
    
  } while (mpz_sgn(bignum) > 0);
    mpz_abs(bignum, bignum);
  }
#endif
  
  if (!(ref = vstr_ref_make_strdup("_")))
    errno = ENOMEM, err(EXIT_FAILURE, "Ref seperator");

  if (!vstr_cntl_conf(NULL, VSTR_CNTL_CONF_SET_LOC_REF_THOU_SEP,  2, ref, 1) ||
      !vstr_cntl_conf(NULL, VSTR_CNTL_CONF_SET_LOC_REF_THOU_SEP,  8, ref, 1) ||
      !vstr_cntl_conf(NULL, VSTR_CNTL_CONF_SET_LOC_REF_THOU_SEP, 16, ref, 1) ||
      FALSE)
    errno = ENOMEM, err(EXIT_FAILURE, "Add seperator");
  vstr_ref_del(ref);
  
  if (!(ref = vstr_ref_make_strdup("\4")))
    errno = ENOMEM, err(EXIT_FAILURE, "Ref grouping");

  if (!vstr_cntl_conf(NULL, VSTR_CNTL_CONF_SET_LOC_REF_THOU_GRP,  2, ref) ||
      !vstr_cntl_conf(NULL, VSTR_CNTL_CONF_SET_LOC_REF_THOU_GRP, 16, ref) ||
      FALSE)
    errno = ENOMEM, err(EXIT_FAILURE, "Add grouping");
  vstr_ref_del(ref);
  
  vstr_add_fmt(s1, s1->len, " Input: %s\n", argv[1]);
  vstr_add_fmt(s1, s1->len, "    %%#'x = $#'<xMPZ:%p>\n",
               (void *)bignum);
  vstr_add_fmt(s1, s1->len, "    %%#'d = $#'<dMPZ:%p>\n",
               (void *)bignum);
  vstr_add_fmt(s1, s1->len, "    %%#'o = $#'<oMPZ:%p>\n",
               (void *)bignum);
  vstr_add_fmt(s1, s1->len, "    %%#'b = $#'<bMPZ:%p>\n",
               (void *)bignum);
  
  if (s1->conf->malloc_bad)
    errno = ENOMEM, err(EXIT_FAILURE, "Add string data");
  
  io_put_all(s1, STDOUT_FILENO);

  exit (ex_exit(s1, NULL));
}
Ejemplo n.º 9
0
int main(int argc, char *argv[])
{
  Vstr_base *s1 = ex_init(NULL);
  mpz_t bignum;
  
  if (argc < 2)
    errx(EXIT_FAILURE, "No count specified");

  vstr_cntl_conf(s1->conf, VSTR_CNTL_CONF_SET_FMT_CHAR_ESC, '$');
  if (!vstr_sc_fmt_add_vstr(s1->conf, "{vstr:%p%zu%zu%u}") ||
      !vstr_fmt_add(s1->conf, "<words:%p>", ex_usr_words_cb,
                    VSTR_TYPE_FMT_PTR_VOID, VSTR_TYPE_FMT_END))
    errno = ENOMEM, err(EXIT_FAILURE, "Custom formatters");

#if EX_WORDS_USE_TST
  {
    struct Words_tst_conv
    {
     const char *i;
     const char *o;
    }
    tsts[] =
      {
       {"0",   "Zero"},
       {"1",   "One"},
       {"2",   "Two"},
       {"3",   "Three"},
       {"4",   "Four"},
       {"5",   "Five"},
       {"6",   "Six"},
       {"7",   "Seven"},
       {"8",   "Eight"},
       {"9",   "Nine"},
       {"10",  "Ten"},
       {"11",  "Eleven"},
       {"12",  "Twelve"},
       {"13",  "Thirteen"},
       {"14",  "Fourteen"},
       {"15",  "Fifteen"},
       {"16",  "Sixteen"},
       {"17",  "Seventeen"},
       {"18",  "Eighteen"},
       {"19",  "Nineteen"},
       {"20",  "Twenty"},
       {"21",  "Twenty one"},
       {"29",  "Twenty nine"},
       {"30",  "Thirty"},
       {"34",  "Thirty four"},
       {"40",  "Forty"},
       {"50",  "Fifty"},
       {"60",  "Sixty"},
       {"70",  "Seventy"},
       {"80",  "Eighty"},
       {"90",  "Ninety"},
       {"100", "One hundred"},
       {"190", "One hundred and ninety"},
       {"200", "Two hundred"},
       {"1000", "One thousand"},
       {"2000", "Two thousand"},
       {"3210", "Three thousand two hundred and ten"},
                                                                                
       {"9876543210", "Nine billion eight hundred and seventy six million five hundred and forty three thousand two hundred and ten"},
       {"9876543210" VAL0_9(), "Nine quintillion eight hundred and seventy six quadrillion five hundred and forty three trillion two hundred and ten billion"},
       {"-3210", "Minus three thousand two hundred and ten"},
      };
    unsigned int alen = sizeof(tsts) / sizeof(tsts[0]);
    struct Words_tst_conv *scan = tsts;
    

    while (alen)
    {
      mpz_init_set_str(bignum, scan->i, 0);

      vstr_del(s1, 1, s1->len);
      vstr_add_fmt(s1, s1->len, "$<words:%p>", (void *)bignum);
      
      if (!vstr_cmp_cstr_eq(s1, 1, s1->len, scan->o))
        errx(EXIT_FAILURE, "Tst failed(%s): %s",
             scan->o, vstr_export_cstr_ptr(s1, 1, s1->len));

      --alen;
      ++scan;
    }
  }
#endif
  
  mpz_init_set_str(bignum, argv[1], 0);

  vstr_del(s1, 1, s1->len);
  vstr_add_fmt(s1, s1->len, " Input: %s\n", argv[1]);
  vstr_add_fmt(s1, s1->len, " Words: $<words:%p>\n", (void *)bignum);
  
  if (s1->conf->malloc_bad)
    errno = ENOMEM, err(EXIT_FAILURE, "Add string data");
  
  io_put_all(s1, STDOUT_FILENO);

  exit (ex_exit(s1, NULL));
}
Ejemplo n.º 10
0
Archivo: main.c Proyecto: inaddy/random
int main(int argc, char **argv) {
    int sockfd, lsockfd;
    char *output;
    pid_t pid, sid;
    struct sockaddr_in local, remote;
    socklen_t socksize = sizeof (struct sockaddr_in);

    pid = fork();
    if (pid < 0)
        ERR_EXIT_ERRNO("fork error");

    if (pid > 0)
        exit(0);

    sid = setsid();
    if (sid < 0)
        ERR_EXIT_ERRNO("setsid error");

    //close(2), close(1), close(0);

    memset(&local, 0, sizeof (local));
    local.sin_family = AF_INET;
    local.sin_addr.s_addr = htonl(INADDR_ANY);
    local.sin_port = htons(6969);

    sockfd = socket(AF_INET, SOCK_STREAM, 0);
    if (!sockfd)
        ERR_EXIT_ERRNO("socket error");

    prog = argv[0];

    ex_init();

    int_init();

    lpar_init();

    bind(sockfd, (struct sockaddr *) &local, sizeof (struct sockaddr));
    if (!sockfd)
        ERR_EXIT_ERRNO("bind error");

    listen(sockfd, 1);

    lsockfd = accept(sockfd, (struct sockaddr *) &remote, &socksize);
    if (!lsockfd)
        ERR_EXIT_ERRNO("accept error");

    while (lsockfd) {
        lpar_update();
        //output_raw(&output);
        output_zperf_compat(&output);
        write(lsockfd, output, strlen(output));
        close(lsockfd);
        lsockfd = accept(sockfd, (struct sockaddr *) &remote, &socksize);
        if (!lsockfd)
            ERR_EXIT_ERRNO("accept error");
    }

    close(lsockfd);
    close(sockfd);

    return 0;
}
Ejemplo n.º 11
0
/*
 * vs_msg --
 *	Display ex output or error messages for the screen.
 *
 * This routine is the default editor interface for all ex output, and all ex
 * and vi error/informational messages.  It implements the standard strategy
 * of stealing lines from the bottom of the vi text screen.  Screens using an
 * alternate method of displaying messages, e.g. dialog boxes, should set their
 * scr_msg function to the correct function before calling the editor.
 *
 * PUBLIC: void vs_msg __P((SCR *, mtype_t, char *, size_t));
 */
void
vs_msg(SCR *sp, mtype_t mtype, char *line, size_t len)
{
	GS *gp;
	VI_PRIVATE *vip;
	size_t maxcols, oldx, oldy, padding;
	const char *e, *s, *t;

	gp = sp->gp;
	vip = VIP(sp);

	/*
	 * Ring the bell if it's scheduled.
	 *
	 * XXX
	 * Shouldn't we save this, too?
	 */
	if (F_ISSET(sp, SC_TINPUT_INFO) || F_ISSET(gp, G_BELLSCHED)) {
		if (F_ISSET(sp, SC_SCR_VI)) {
			F_CLR(gp, G_BELLSCHED);
			(void)gp->scr_bell(sp);
		} else
			F_SET(gp, G_BELLSCHED);
	}

	/*
	 * If vi is using the error line for text input, there's no screen
	 * real-estate for the error message.  Nothing to do without some
	 * information as to how important the error message is.
	 */
	if (F_ISSET(sp, SC_TINPUT_INFO))
		return;

	/*
	 * Ex or ex controlled screen output.
	 *
	 * If output happens during startup, e.g., a .exrc file, we may be
	 * in ex mode but haven't initialized the screen.  Initialize here,
	 * and in this case, stay in ex mode.
	 *
	 * If the SC_SCR_EXWROTE bit is set, then we're switching back and
	 * forth between ex and vi, but the screen is trashed and we have
	 * to respect that.  Switch to ex mode long enough to put out the
	 * message.
	 *
	 * If the SC_EX_WAIT_NO bit is set, turn it off -- we're writing to
	 * the screen, so previous opinions are ignored.
	 */
	if (F_ISSET(sp, SC_EX | SC_SCR_EXWROTE)) {
		if (!F_ISSET(sp, SC_SCR_EX)) {
			if (F_ISSET(sp, SC_SCR_EXWROTE)) {
				if (sp->gp->scr_screen(sp, SC_EX))
					return;
			} else
				if (ex_init(sp))
					return;
		}

		if (mtype == M_ERR)
			(void)gp->scr_attr(sp, SA_INVERSE, 1);
		(void)printf("%.*s", (int)len, line);
		if (mtype == M_ERR)
			(void)gp->scr_attr(sp, SA_INVERSE, 0);
		(void)fflush(stdout);

		F_CLR(sp, SC_EX_WAIT_NO);

		if (!F_ISSET(sp, SC_SCR_EX))
			(void)sp->gp->scr_screen(sp, SC_VI);
		return;
	}

	/* If the vi screen isn't ready, save the message. */
	if (!F_ISSET(sp, SC_SCR_VI)) {
		(void)vs_msgsave(sp, mtype, line, len);
		return;
	}

	/* Save the cursor position. */
	(void)gp->scr_cursor(sp, &oldy, &oldx);

	/* If it's an ex output message, just write it out. */
	if (mtype == M_NONE) {
		vs_output(sp, mtype, line, len);
		goto ret;
	}

	/*
	 * If it's a vi message, strip the trailing <newline> so we can
	 * try and paste messages together.
	 */
	if (line[len - 1] == '\n')
		--len;

	/*
	 * If a message won't fit on a single line, try to split on a <blank>.
	 * If a subsequent message fits on the same line, write a separator
	 * and output it.  Otherwise, put out a newline.
	 *
	 * Need up to two padding characters normally; a semi-colon and a
	 * separating space.  If only a single line on the screen, add some
	 * more for the trailing continuation message.
	 *
	 * XXX
	 * Assume that periods and semi-colons take up a single column on the
	 * screen.
	 *
	 * XXX
	 * There are almost certainly pathological cases that will break this
	 * code.
	 */
	if (IS_ONELINE(sp))
		(void)msg_cmsg(sp, CMSG_CONT_S, &padding);
	else
		padding = 0;
	padding += 2;

	maxcols = sp->cols - 1;
	if (vip->lcontinue != 0) {
		if (len + vip->lcontinue + padding > maxcols)
			vs_output(sp, vip->mtype, ".\n", 2);
		else  {
			vs_output(sp, vip->mtype, ";", 1);
			vs_output(sp, M_NONE, " ", 1);
		}
	}
	vip->mtype = mtype;
	for (s = line;; s = t) {
		for (; len > 0 && isblank((unsigned char)*s); --len, ++s);
		if (len == 0)
			break;
		if (len + vip->lcontinue > maxcols) {
			for (e = s + (maxcols - vip->lcontinue);
			    e > s && !isblank((unsigned char)*e); --e);
			if (e == s)
				 e = t = s + (maxcols - vip->lcontinue);
			else
				for (t = e; isblank((unsigned char)e[-1]); --e);
		} else
			e = t = s + len;

		/*
		 * If the message ends in a period, discard it, we want to
		 * gang messages where possible.
		 */
		len -= t - s;
		if (len == 0 && (e - s) > 1 && s[(e - s) - 1] == '.')
			--e;
		vs_output(sp, mtype, s, e - s);

		if (len != 0)
			vs_output(sp, M_NONE, "\n", 1);

		if (INTERRUPTED(sp))
			break;
	}

ret:	(void)gp->scr_move(sp, oldy, oldx);
	(void)gp->scr_refresh(sp, 0);
}
Ejemplo n.º 12
0
/*
	in WIN32, the executive can run in two mode, i.e., the SoftPLC
	mode or the simulator mode. in SoftPLC mode, the executive will
	try to probe additional IO drivers and perform IOs during execution,
	while in simulator mode, no IO is performed.
*/
KSERVER_API int kserver_main2(int c, char **v)
{
	int flags;
	char * mode = 0;
	int port = 0;
	__bool dbgMode;
	int leakDetect = 0;
	
	BEGIN_ARGS
		ARG("mode=", mode, "char *", "mode specifiers")
		ARG("port=", port, "int", "agent port")
		ARG("leak=", leakDetect, "int", "detect memory leakage")
		ARG("--debug", dbgMode, "tbool", "debug mode")
	END_ARGS

	if(process_args_1(c, v)<0){
		print_usage_1();
		return F8_SYNTAX;
	}
	
	if(leakDetect){
		_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
		_CrtSetBreakAlloc(leakDetect);
	}
	
	if(mode){
		CArgs a;
		parse_arg_ex(mode, &a, "+/|-= ,;:");
		int i;
		flags = 0;
		for(i=0; i<a.argc; i++){
			if(!strcmp(a.argv[i], "sched")){
				flags |= KERN_F_ENABLE_SCHEDULER;
			}else if(!strcmp(a.argv[i], "standby")){
				flags |= KERN_F_ENABLE_STANDBY;
			}else if(!strcmp(a.argv[i], "io")){
				flags |= KERN_F_ENABLE_IO;
			}else if(!strcmp(a.argv[i], "sio")){
				flags |= KERN_F_SERIALIZED_IO;
			}else if(!strcmp(a.argv[i], "agent")){
				flags |= KERN_F_ENABLE_AGENT;
			}else if(!strcmp(a.argv[i], "single")){
				flags = KERN_F_ENABLE_SCHEDULER | KERN_F_ENABLE_IO | KERN_F_ENABLE_AGENT;
				break;
			}else if(!strcmp(a.argv[i], "all")){
				flags = KERN_F_ENABLE_SCHEDULER | KERN_F_ENABLE_IO | KERN_F_ENABLE_AGENT
					| KERN_F_ENABLE_STANDBY;
				break;
			}else if(!strcmp(a.argv[i], "headless")){
				flags = KERN_F_ENABLE_SCHEDULER | KERN_F_ENABLE_AGENT | KERN_F_ENABLE_STANDBY;
				break;
			}
		}
	}else{
		flags = KERN_F_ENABLE_SCHEDULER | KERN_F_ENABLE_IO | KERN_F_ENABLE_AGENT
			| KERN_F_ENABLE_STANDBY;
	}

	ex_init();
	g_kernel = ke_get_default_kernel();
	ex_start(flags, port);
	sections = ke_get_blk(g_kernel, NULL);

	return F8_SUCCESS;
}
Ejemplo n.º 13
0
int
EtherInit(unsigned char *myadr)
{
	uint32_t pcicsr;
	uint16_t val;
	volatile struct ex_upd *upd;
#ifndef _STANDALONE
	uint32_t id;
#endif

	if (pcicheck()) {
		printf("pcicheck failed\n");
		return 0;
	}
#ifndef _STANDALONE
	pcicfgread(&mytag, 0, &id);
#endif
	for (excard = &excards[0]; excard->did != -1; excard++) {
#ifdef _STANDALONE
		if (pcifinddev(0x10b7, excard->did, &mytag) == 0)
			goto found;
#else
		if (id == (0x10b7 | (excard->did << 16)))
			goto found;
#endif
	}
	printf("no ex\n");
	return 0;

found:
	pcicfgread(&mytag, 0x10, &iobase);
	iobase &= ~3;

#ifndef _STANDALONE
	dmamem = mapmem(DMABASE, DMASIZE);
	if (!dmamem)
		return 0;
#endif

	/* enable bus mastering in PCI command register */
	if (pcicfgread(&mytag, 0x04, (int *)&pcicsr)
	    || pcicfgwrite(&mytag, 0x04, pcicsr | 4)) {
		printf("cannot enable DMA\n");
		return 0;
	}

	ex_reset();

	if (excard->mii)
		ether_medium = ETHERMEDIUM_MII;
	else {
		ex_probemedia();
		if (ether_medium < 0)
			return 0;
	}

	val = ex_read_eeprom(EEPROM_OEM_ADDR0);
	myethaddr[0] = val >> 8;
	myethaddr[1] = val & 0xff;
	val = ex_read_eeprom(EEPROM_OEM_ADDR1);
	myethaddr[2] = val >> 8;
	myethaddr[3] = val & 0xff;
	val = ex_read_eeprom(EEPROM_OEM_ADDR2);
	myethaddr[4] = val >> 8;
	myethaddr[5] = val & 0xff;
	memcpy(myadr, myethaddr, 6);

	upd = RECVBUF_VIRT;
	upd->upd_nextptr = RECVBUF_PHYS;
	upd->upd_pktstatus = 1500;
	upd->upd_frags[0].fr_addr = RECVBUF_PHYS + 100;
	upd->upd_frags[0].fr_len = 1500 | EX_FR_LAST;

	ex_init();

#if defined(_STANDALONE) && !defined(SUPPORT_NO_NETBSD)
	strncpy(bi_netif.ifname, "ex", sizeof(bi_netif.ifname));
	bi_netif.bus = BI_BUS_PCI;
	bi_netif.addr.tag = mytag;

	BI_ADD(&bi_netif, BTINFO_NETIF, sizeof(bi_netif));
#endif

	return 1;
}
Ejemplo n.º 14
0
Archivo: test3.c Proyecto: irov/movie
int main( int argc, char *argv[] ) {
    AE_UNUSED( argc );
    AE_UNUSED( argv );

    //
    // Initialize library instance, movie & composition names.
    //

    ex_init( ex_example_license_hash, ex_example_movie_path, ex_example_composition_name );

    //
    // Set pointer to resource loader callback.
    //

    ex.resource_provider = &ex_callback_resource_provider;
    ex.resource_deleter = &ex_callback_resource_deleter_empty;

    //
    // Load movie data structure, which in particular contains info about all compositions in the movie.
    //

    ex_load_movie_data();

    //
    // Set composition data provider callbacks here.
    //

    ae_clear_movie_composition_providers( &ex.comp_providers );    
    ex.comp_providers.node_provider = &ex_callback_node_provider;
    ex.comp_providers.node_deleter = &ex_callback_node_destroyer;
    ex.comp_providers.node_update = &ex_callback_node_update;
    ex.comp_providers.camera_provider = &ex_callback_camera_provider;
    ex.comp_providers.track_matte_update = &ex_callback_track_matte_update;
    ex.comp_providers.composition_event = &ex_callback_composition_event;
    ex.comp_providers.composition_state = &ex_callback_composition_state;

    //
    // Select the composition & load its data (nodes, cameras etc.).
    //

    ex_set_composition();

    //
    // Play the movie.
    //

    EX_LOG( "The movie is playing in loop now. Press Ctrl-C to break...\n" );

    ae_play_movie_composition( ex.composition, 0.f );

    ae_float_t last = ex_get_time();

    while( ae_is_play_movie_composition( ex.composition ) == AE_TRUE ) {
        ae_float_t t = ex_get_time();
        ae_float_t dt = t - last;
        last = t;

        ex_update( dt );
        ex_render();
    }

    //
    // Shutdown.
    //

    ex_shutdown();

    return 0;
}
Ejemplo n.º 15
0
void		_main(void)
{
  uint32_t i;

  /**
   *
   *	Basic setup
   */

  /* enable the A20 line */
 
  /* disable the PIC (8259A chip) */
  pic_enable(false);

  /* disable the local APIC */
  //apic_enable(false);
  //apic_local_enable(false)

  /**
   *
   *	Protection
   */

  /* init and enable segmentation */
  //gdt_init();

  seg_init();
  //  INFINITE_LOOP();

  /* init and enable paging */
  //mmu_init();
  console_clear();
  mmu_init();

  /* init the system-call facilities */
  sc_init();

  /**
   *
   *	Interrupts
   */
  // INFINITE_LOOP();
  /* init and enable interrupts */
  idt_init();

  //INFINITE_LOOP();

  /* bind stage2 isrs */
  //isr_init();
  int_init();
  ex_init();

  //INFINITE_LOOP();

  /* configure the Local-APIC timer */
  //apic_local_timer_init(0x2ffffff);
  //apic_local_timer_init(0xffffff);

  /* configure the PIT timer */
  pit_init();

  printf("Local-APIC init...\n");
  /* Init the Local-APIC. */
  apic_local_init();
  apic_local_set_task_priority(0);
  printf("Local-APIC timer config...\n");
  apic_local_timer_config(0x2ffffff);
  printf("IO-APIC init...\n");
  apic_io_init();
  /* enable the local APIC */
  //apic_enable(true);
  apic_local_enable(true);

  printf("OK\n");

  /* configure the I/O APIC in charge of the PIT, keyboard, ... */
  //apic_io_init();
  /* STI(); */
/*   INFINITE_LOOP(); */

  /* clear the screen */
  console_clear();
  console_init();

  /* init the basic I/O services */
  stdio_init();
  //tty_init();
  //tty_activate(0);

 /*  sysenter(); */
  /*   vmx_supported(1); */
  test_malloc();

  /* init the serial number facility */
  serial_init();
  /*   printf("UID %d\n", serial_generate()); */
  /*   printf("UID %d\n", serial_generate()); */
  /*   printf("UID %d\n", serial_generate()); */

  /* init the task manager */
  thread_init();

  /* init the scheduler manager */
  sched_init();

  /* dump the memory */
  mem_dump();

  /* test the mmu. */
  //mmu_test();
  /* while (1) */
/*     ; */

  //video_init();

/*   msr = rdmsr(MSR_IA32_APIC_BASE); */
/*   printf("msr hi: %x\n", (uint32_t)(msr >> 32)); */
/*   printf("msr lo: %x\n", (uint32_t) msr); */
/*   msr = rdmsr(MSR_IA32_CR_PAT); */
/*   printf("msr hi: %x\n", (uint32_t)(msr >> 32)); */
/*   printf("msr lo: %x\n", (uint32_t) msr); */
/*   msr = rdmsr(MSR_IA32_PERF_GLOBAL_STATUS); */
/*   printf("msr hi: %x\n", (uint32_t)(msr >> 32)); */
/*   printf("msr lo: %x\n", (uint32_t) msr); */
/*   msr = rdmsr(MSR_IA32_PLATFORM_ID); */
/*   printf("msr hi: %x\n", (uint32_t)(msr >> 32)); */
/*   printf("msr lo: %x\n", (uint32_t) msr); */
/*   printf("Macrotest\n"); */
/*   MACROTEST(&msr); */
/*   printf("msr hi: %x\n", (uint32_t)(msr >> 32)); */
 /*  printf("apic-io ver: %x\n", apic_io_get_version()); */
/*   printf("apic-io id: %x\n", apic_io_get_id()); */

/*   printf("New GDT:\n"); */
/*   seg_init(); */
/*   printf("Old GDT:\n"); */
/*   for (i = 0; i < SEG_DESC_N; i++) */
/*     { */
/*       printf("%x - %x\n", gdt[i].high, gdt[i].low); */
/*     } */
  //INFINITE_LOOP();

  i = 1 << 5 | 1 << 9;
  printf("bsf(i) = %d\n", bsf(i));
  printf("bsr(i) = %d\n", bsr(i));
  i = 0;
  printf("bsr(i) = %d\n", bsr(i));

  printf("MSR_IA32_SYSENTER_CS high = %x\n", (uint32_t)(rdmsr(MSR_IA32_SYSENTER_CS) >> 32));
  printf("MSR_IA32_SYSENTER_CS low = %x\n", (uint32_t) rdmsr(MSR_IA32_SYSENTER_CS));

  printf("IA32_CR_PAT high = %x\n", (uint32_t)(rdmsr(MSR_IA32_CR_PAT) >> 32));
  printf("IA32_CR_PAT low = %x\n", (uint32_t) rdmsr(MSR_IA32_CR_PAT));

  /* jump to background task - code after this function is never reached */
  sched_launch();


  /*   test_multiline(); */
  /*   test_println(); */
  /*   test_interrupts(); */
  /*   test_itoa(); */
  /*   test_msr(); */
  //test_apic();
  //test_ide_dma();

  //printf("+ Bus 0\n", BG_BLACK | FG_RED | FG_INTENSITY);
  //pci_list(0, 2, 64);
  /*   printf("Bus 1\n", BG_BLACK | FG_RED | FG_INTENSITY); */
  /*   pci_list(1); */
  //test_ide_dma();
  //test_apic();

  //fprintf(0, "Protos v%d.%d - id:%x\n", 0, 12, 0xbe01);
  //fprintf(0, "\tid reg:\t%r\n", 0xbe01);
  //fprintf(0, "Ok!\n");
  // printf("Helo %% %d-%x-%r\n", 45, 0xabc78, 0xabc78);
  //printf("Helo %r\n", 0xbe01);

  //r = fprintf(stdout, "Almost %x years :)\n", 26);
  //fprintf(stdout, "size:%d\n", strlen("hello!"));

  //printf("fprintf result = %d\n", r);
  //printf(&((&stdio_filedes[0])->buffer[0]));

  //__asm__ ("rdtsc");


  // Halt the system
  while (1)
    HLT();
}
Ejemplo n.º 16
0
/*
 * ex_visual -- :[line] vi[sual] [^-.+] [window_size] [flags]
 *	Switch to visual mode.
 *
 * PUBLIC: int ex_visual(SCR *, EXCMD *);
 */
int
ex_visual(SCR *sp, EXCMD *cmdp)
{
	SCR *tsp;
	size_t len;
	int pos;
	char buf[256];

	/* If open option off, disallow visual command. */
	if (!O_ISSET(sp, O_OPEN)) {
		msgq(sp, M_ERR,
	    "The visual command requires that the open option be set");
		return (1);
	}

	/* Move to the address. */
	sp->lno = cmdp->addr1.lno == 0 ? 1 : cmdp->addr1.lno;

	/*
	 * Push a command based on the line position flags.  If no
	 * flag specified, the line goes at the top of the screen.
	 */
	switch (FL_ISSET(cmdp->iflags,
	    E_C_CARAT | E_C_DASH | E_C_DOT | E_C_PLUS)) {
	case E_C_CARAT:
		pos = '^';
		break;
	case E_C_DASH:
		pos = '-';
		break;
	case E_C_DOT:
		pos = '.';
		break;
	case E_C_PLUS:
		pos = '+';
		break;
	default:
		sp->frp->lno = sp->lno;
		sp->frp->cno = 0;
		(void)nonblank(sp, sp->lno, &sp->cno);
		F_SET(sp->frp, FR_CURSORSET);
		goto nopush;
	}

	if (FL_ISSET(cmdp->iflags, E_C_COUNT))
		len = snprintf(buf, sizeof(buf),
		     "%luz%c%lu", (ulong)sp->lno, pos, cmdp->count);
	else
		len = snprintf(buf, sizeof(buf), "%luz%c", (ulong)sp->lno, pos);
	if (len >= sizeof(buf))
		len = sizeof(buf) - 1;
	(void)v_event_push(sp, NULL, buf, len, CH_NOMAP | CH_QUOTED);

	/*
	 * !!!
	 * Historically, if no line address was specified, the [p#l] flags
	 * caused the cursor to be moved to the last line of the file, which
	 * was then positioned as described above.  This seems useless, so
	 * I haven't implemented it.
	 */
	switch (FL_ISSET(cmdp->iflags, E_C_HASH | E_C_LIST | E_C_PRINT)) {
	case E_C_HASH:
		O_SET(sp, O_NUMBER);
		break;
	case E_C_LIST:
		O_SET(sp, O_LIST);
		break;
	case E_C_PRINT:
		break;
	}

nopush:	/*
	 * !!!
	 * You can call the visual part of the editor from within an ex
	 * global command.
	 *
	 * XXX
	 * Historically, undoing a visual session was a single undo command,
	 * i.e. you could undo all of the changes you made in visual mode.
	 * We don't get this right; I'm waiting for the new logging code to
	 * be available.
	 *
	 * It's explicit, don't have to wait for the user, unless there's
	 * already a reason to wait.
	 */
	if (!F_ISSET(sp, SC_SCR_EXWROTE))
		F_SET(sp, SC_EX_WAIT_NO);

	if (F_ISSET(sp, SC_EX_GLOBAL)) {
		/*
		 * When the vi screen(s) exit, we don't want to lose our hold
		 * on this screen or this file, otherwise we're going to fail
		 * fairly spectacularly.
		 */
		++sp->refcnt;
		++sp->ep->refcnt;

		/*
		 * Fake up a screen pointer -- vi doesn't get to change our
		 * underlying file, regardless.
		 */
		tsp = sp;
		if (vi(&tsp))
			return (1);

		/*
		 * !!!
		 * Historically, if the user exited the vi screen(s) using an
		 * ex quit command (e.g. :wq, :q) ex/vi exited, it was only if
		 * they exited vi using the Q command that ex continued.  Some
		 * early versions of nvi continued in ex regardless, but users
		 * didn't like the semantic.
		 *
		 * Reset the screen.
		 */
		if (ex_init(sp))
			return (1);

		/* Move out of the vi screen. */
		(void)ex_puts(sp, "\n");
	} else {
		F_CLR(sp, SC_EX | SC_SCR_EX);
		F_SET(sp, SC_VI);
	}
	return (0);
}