void MainWindow::addTranslate() { QString word = ui->textEdit->textCursor().selectedText(); AddTranslateDialog die_log(word, this); if(die_log.exec()) { word = die_log.getWord(); //если поля со словом и перевода не пустые if(!word.isEmpty() && !die_log.getTranslation().text.isEmpty()) { bptr->addTranslatedWord(word, die_log.getTranslation()); } } }
void resp_recvfile(struct reqinfo *req) { struct fsfd h; lx_s dest_dir = {0}, dest_file = {0}, data = {0}; lx_s *value; char *endlen; int length; if (!OPT_WRITABL) { die_html(HTERR_FORBID, 0, "Write access forbidden", err_perm_denied); } fs_ready(); fs_parseout(&dest_dir, &dest_file, &req->location); if (lx_check0(&dest_dir) || lx_check0(&dest_file) || lx_check0(&req->location)) die_nomem(); log_debug(DEBUG_NOISE, dest_dir.s, "destination directory"); log_debug(DEBUG_NOISE, dest_file.s, "destination file"); value = blob_get(blob_header_recv, "content-length", 14); if (!value) { die_html(HTERR_NEEDLEN, 0, "POST request without Content-Length", "Content-Length header required"); } lx_check0(value); length = strtoul(value->s, &endlen, 10); if (endlen == value->s || *endlen) { die_html(HTERR_NEEDLEN, 0, "POST request with invalid Content-Length", "Content-Length header required"); } fs_chdir_write(dest_dir.s); #if 0 if (!chdir(dest_dir.s)) { if (opt_p.v_opt.opt_toggle) { fs_mkpath(dest_dir.s); } else { die_html(HTERR_NOTFOUND|ERRNO, req->location.s, "chdir to target directory", "Invalid target directory"); } } fs_okay_write_dir(); #endif /* XXX: address if lx_check0 is modified to not increment len! */ fs_open_file_write(&h, dest_file.s, dest_file.len-1); fs_slurp_gd2h(&h, gd_in, length); log_debug(DEBUG_NOISE, h.dest, "received file from feed"); fs_close_file_write(&h); if (h.status & ST_INCOMPLETE) { die_log(0, dest_file.s, "short read from input stream", 0); } if (lx_striset(&data, "0", 1)) die_nomem(); header_setstr(blob_header_send, "Content-Length", data.s, data.len); resp_sendprefix(req, (h.status & ST_CREATED) ? HTERR_OK_CREAT : HTERR_OK_NOCNT); resp_sendheaders(req, blob_header_send); lx_free(&dest_dir); lx_free(&dest_file); lx_free(&data); }
void die_outerr(void) { die_log(ERRNO, 0, "output error", 0); }
void die_nomem(void) { die_log(0, 0, "out of memory", 0); }