static void print_attr(struct html *h, const char *key, const char *val) { printf(" %s=\"", key); (void)print_encode(h, val, 1); putchar('\"'); }
void print_text(struct html *h, const char *word) { if ( ! (HTML_NOSPACE & h->flags)) { /* Manage keeps! */ if ( ! (HTML_KEEP & h->flags)) { if (HTML_PREKEEP & h->flags) h->flags |= HTML_KEEP; putchar(' '); } else printf(" "); } assert(NULL == h->metaf); if (HTMLFONT_NONE != h->metac) h->metaf = HTMLFONT_BOLD == h->metac ? print_otag(h, TAG_B, 0, NULL) : print_otag(h, TAG_I, 0, NULL); assert(word); if ( ! print_encode(h, word, 0)) if ( ! (h->flags & HTML_NONOSPACE)) h->flags &= ~HTML_NOSPACE; if (h->metaf) { print_tagq(h, h->metaf); h->metaf = NULL; } h->flags &= ~HTML_IGNDELIM; }
void print_text(struct html *h, const char *word) { if ( ! (HTML_NOSPACE & h->flags)) { /* Manage keeps! */ if ( ! (HTML_KEEP & h->flags)) { if (HTML_PREKEEP & h->flags) h->flags |= HTML_KEEP; putchar(' '); } else printf(" "); } assert(NULL == h->metaf); switch (h->metac) { case HTMLFONT_ITALIC: h->metaf = print_otag(h, TAG_I, 0, NULL); break; case HTMLFONT_BOLD: h->metaf = print_otag(h, TAG_B, 0, NULL); break; case HTMLFONT_BI: h->metaf = print_otag(h, TAG_B, 0, NULL); print_otag(h, TAG_I, 0, NULL); break; default: break; } assert(word); if ( ! print_encode(h, word, 0)) { if ( ! (h->flags & HTML_NONOSPACE)) h->flags &= ~HTML_NOSPACE; h->flags &= ~HTML_NONEWLINE; } else h->flags |= HTML_NOSPACE | HTML_NONEWLINE; if (h->metaf) { print_tagq(h, h->metaf); h->metaf = NULL; } h->flags &= ~HTML_IGNDELIM; }
void print_text(struct html *h, const char *word) { if (word[0] && '\0' == word[1]) switch (word[0]) { case('.'): /* FALLTHROUGH */ case(','): /* FALLTHROUGH */ case(';'): /* FALLTHROUGH */ case(':'): /* FALLTHROUGH */ case('?'): /* FALLTHROUGH */ case('!'): /* FALLTHROUGH */ case(')'): /* FALLTHROUGH */ case(']'): if ( ! (HTML_IGNDELIM & h->flags)) h->flags |= HTML_NOSPACE; break; default: break; } if ( ! (HTML_NOSPACE & h->flags)) { /* Manage keeps! */ if ( ! (HTML_KEEP & h->flags)) { if (HTML_PREKEEP & h->flags) h->flags |= HTML_KEEP; putchar(' '); } else printf(" "); } assert(NULL == h->metaf); if (HTMLFONT_NONE != h->metac) h->metaf = HTMLFONT_BOLD == h->metac ? print_otag(h, TAG_B, 0, NULL) : print_otag(h, TAG_I, 0, NULL); assert(word); if ( ! print_encode(h, word, 0)) if ( ! (h->flags & HTML_NONOSPACE)) h->flags &= ~HTML_NOSPACE; if (h->metaf) { print_tagq(h, h->metaf); h->metaf = NULL; } h->flags &= ~HTML_IGNDELIM; /* * Note that we don't process the pipe: the parser sees it as * punctuation, but we don't in terms of typography. */ if (word[0] && '\0' == word[1]) switch (word[0]) { case('('): /* FALLTHROUGH */ case('['): h->flags |= HTML_NOSPACE; break; default: break; } }
static void event_print(telnet_t *telnet, telnet_event_t *ev, void *ud) { size_t i; switch (ev->type) { case TELNET_EV_DATA: printf("DATA [%zi] ==> ", ev->data.size); print_encode(ev->data.buffer, ev->data.size); printf("\n"); break; case TELNET_EV_SEND: break; case TELNET_EV_IAC: printf("IAC %d (%s)\n", (int)ev->iac.cmd, get_cmd(ev->iac.cmd)); break; case TELNET_EV_WILL: printf("WILL %d (%s)\n", (int)ev->neg.telopt, get_opt(ev->neg.telopt)); break; case TELNET_EV_WONT: printf("WONT %d (%s)\n", (int)ev->neg.telopt, get_opt(ev->neg.telopt)); break; case TELNET_EV_DO: printf("DO %d (%s)\n", (int)ev->neg.telopt, get_opt(ev->neg.telopt)); break; case TELNET_EV_DONT: printf("DONT %d (%s)\n", (int)ev->neg.telopt, get_opt(ev->neg.telopt)); break; case TELNET_EV_SUBNEGOTIATION: switch (ev->sub.telopt) { case TELNET_TELOPT_ENVIRON: case TELNET_TELOPT_NEW_ENVIRON: case TELNET_TELOPT_TTYPE: case TELNET_TELOPT_ZMP: case TELNET_TELOPT_MSSP: /* print nothing */ break; default: printf("SUB %d (%s) [%zi]\n", (int)ev->sub.telopt, get_opt(ev->sub.telopt), ev->sub.size); break; } break; case TELNET_EV_ZMP: printf("ZMP (%s) [%zi]\n", ev->zmp.argv[0], ev->zmp.argc); break; case TELNET_EV_TTYPE: printf("TTYPE %s %s\n", ev->ttype.cmd ? "SEND" : "IS", ev->ttype.name ? ev->ttype.name : ""); break; /* ENVIRON/NEW-ENVIRON commands */ case TELNET_EV_ENVIRON: printf("ENVIRON [%zi parts] ==> %s", ev->environ.size, ev->environ.cmd == TELNET_ENVIRON_IS ? "IS" : (ev->environ.cmd == TELNET_ENVIRON_SEND ? "SEND" : "INFO")); for (i = 0; i != ev->environ.size; ++i) { printf(" %s \"", ev->environ.values[i].type == TELNET_ENVIRON_VAR ? "VAR" : "USERVAR"); if (ev->environ.values[i].var != 0) { print_encode(ev->environ.values[i].var, strlen(ev->environ.values[i].var)); } printf("\""); if (ev->environ.cmd != TELNET_ENVIRON_SEND) { printf("=\""); if (ev->environ.values[i].value != 0) { print_encode(ev->environ.values[i].value, strlen(ev->environ.values[i].value)); } printf("\""); } } printf("\n"); break; case TELNET_EV_MSSP: printf("MSSP [%zi] ==>", ev->mssp.size); for (i = 0; i != ev->mssp.size; ++i) { printf(" \""); print_encode(ev->mssp.values[i].var, strlen(ev->mssp.values[i].var)); printf("\"=\""); print_encode(ev->mssp.values[i].value, strlen(ev->mssp.values[i].value)); printf("\""); } printf("\n"); break; case TELNET_EV_COMPRESS: printf("COMPRESSION %s\n", ev->compress.state ? "ON" : "OFF"); break; case TELNET_EV_WARNING: printf("WARNING: %s\n", ev->error.msg); break; case TELNET_EV_ERROR: printf("ERROR: %s\n", ev->error.msg); break; } }