char* arg_to_spade_json(struct arg_struct* n) {
  int i;
  char* tmp;
  NODE_START("Entity");
  for(i=0; i<n->length; i++){
    if(n->value[i]=='\\')
      n->value[i]='/';
    if(n->value[i]=='\n')
      n->value[i]=' ';
    if(n->value[i]=='\t')
      n->value[i]=' ';
  }
  tmp = repl_str(n->value, "\"", "\\\"");
  if(tmp==NULL)
    tmp = n->value;
  __add_string_attribute("value", tmp, true);
  if(n->truncated==PROV_TRUNCATED)
    __add_string_attribute("truncated", "true", true);
  else
    __add_string_attribute("truncated", "false", true);
  NODE_END();
  if(tmp != n->value)
    free(tmp);
  return buffer;
}
Esempio n. 2
0
static void
pout(char *channel, char *fmt, ...) {
    static char timestr[18];
    time_t t;
    va_list ap;

    va_start(ap, fmt);
    vsnprintf(bufout, sizeof bufout, fmt, ap);
    va_end(ap);
    t = time(NULL);
    strftime(timestr, sizeof timestr, "%D %R", localtime(&t));
    char *rep1 = repl_str(bufout, "^", "^^");
    char *rep2 = repl_str(rep1, "\"", "^\"");
    fprintf(stdout, "IRC %s \"%s\"\n", channel, rep2);
    free(rep2);
    free(rep1);
}