static int speak_buffer (const char *buf, int (*should_stop)()) { ISpVoice *v = NULL; WCHAR *w; char line[2048]; v = get_sapi_voice(); if (v == NULL) return 1; bufgets_init(buf); while (bufgets(line, sizeof line, buf)) { if (should_stop()) { ISpVoice_Speak(v, L"OK, stopping", 0, NULL); break; } tailstrip(line); w = wide_string(line); ISpVoice_Speak(v, w, 0, NULL); free(w); } bufgets_finalize(buf); release_sapi_voice(v); return 0; }
void gretl_print_get_size (PRN *prn, int *width, int *height) { int w = 0, h = 0; if (prn != NULL && prn->buf != NULL) { char line[128]; int lw; bufgets_init(prn->buf); while (bufgets(line, sizeof line, prn->buf)) { lw = g_utf8_strlen(line, -1) - 1; if (lw > 120) { w = h = 0; break; } if (lw > w) { w = lw; } h++; } bufgets_finalize(prn->buf); } if (width != NULL) { *width = w; } if (height != NULL) { *height = h; } }
/*------------------------------------------------------------------------ Parse the http header already received for this connection. Return 0 on success. ------------------------------------------------------------------------*/ static int parse_request(bhttp_conn_t *pc) { char *line; pc->ipos = 0; line = bufgets(pc); pc->pmethod = strtok(line, "\040\t"); pc->purl = strtok(NULL, "\040\t"); pc->pprotocol = strtok(NULL, "\040\t"); if (pc->pprotocol) return 0; else return -1; }
static int speak_buffer (const char *buf, int (*should_stop)()) { cst_voice *v; char line[2048]; flite_init(); v = register_cmu_us_kal(); bufgets_init(buf); while (bufgets(line, sizeof line, buf)) { if (should_stop()) { flite_text_to_speech("OK, stopping", v, "play"); break; } tailstrip(line); flite_text_to_speech(line, v, "play"); } bufgets_finalize(buf); return 0; }