Esempio n. 1
0
static int s1AssemblerCalltf(char*user_data)
{
  s_vpi_value value_s;
  vpiHandle systf_handle;
  vpiHandle arg_itr;
  vpiHandle arg_handle;
  char *s;

  systf_handle = vpi_handle(vpiSysTfCall, NULL);
  if ((arg_itr = vpi_iterate(vpiArgument, systf_handle)) == NULL) {
    vpi_printf("ERROR: $s1Assembler failed to obtain systf arg handle\n");
    return(0);
  }

  arg_handle = vpi_scan(arg_itr);
  value_s.format = vpiStringVal;
  vpi_get_value(arg_handle, &value_s);
  
  //vpi_printf("hello string size: %0d\n", (int)strlen(value_s.value.str));
  s = calloc(strlen(value_s.value.str), sizeof(char));
  memset(s, '\0',strlen(value_s.value.str));
  strncpy(s,value_s.value.str, strlen(value_s.value.str));
  vpi_printf("[ s1Assembler ] argument: %s\n", s);

  {
    parserData *parser;
    parser = ParserNew(s);
    ParserStart(parser);
    ParserDelete(&parser);
  }

  free(s);  
  return 0;
}
Esempio n. 2
0
void main (int argc, char *argv[])
{
  Parser *p;
  Document *d;
  char *t;
  char *text;
  int h;
  struct stat stats;

  d = DocumentNew ();
  d->root = ElementNew ();
  d->root->anonymous = ANON_BOX;
  d->root->document = d;
  DocumentAddTagHandler (d, tagHandler, NULL);
  DocumentAddLinkHandler (d, linkHandler, NULL);

  p = ParserNew ();
  p->document = d;
  p->startElement = d->root;
  if (argc > 1)
  {
    lstat (argv[1], &stats);
    text = malloc (stats.st_size + 1);
    h = open (argv[1], O_RDONLY);
    read (h, text, stats.st_size);
    close (h);
    text[stats.st_size] = '\0';
  }
  else
  {
    text = XkNewString ("<h1>Hello World <![CDATA[Hello, world]]></h1>");
  }
  ParserProcessData (p, "text/html", text);
  free (text);

  NodePrint (d->root, 0);

  t = NodeToText (d);
  puts (t);
  free (t);
  NodeDelete ((Node *) d);
  ParserDelete (p);
}