void compressor::lzo_compress_buffer_and_write() { #if LIBLZO2_AVAILABLE lzo_block_header lzo_bh; lzo_uint compr_size = LZO_COMPRESSED_BUFFER_SIZE; S_I status; //compressing data to lzo_compress buffer status = lzo1x_999_compress_level((lzo_bytep)lzo_write_buffer, lzo_write_size, (lzo_bytep)lzo_compressed, &compr_size, lzo_wrkmem, NULL, 0, 0, current_level); switch(status) { case LZO_E_OK: break; // all is fine default: throw Erange("compressor::lzo_compress_buffer_and_write", tools_printf(gettext("Probable bug in liblzo2: lzo1x_*_compress returned unexpected code %d"), status)); } // writing down the TL(V) before the compressed data lzo_bh.type = BLOCK_HEADER_LZO; lzo_bh.size = compr_size; if(compressed == NULL) throw SRC_BUG; lzo_bh.dump(*compressed); compressed->write(lzo_compressed, compr_size); lzo_write_size = 0; #else throw Efeature(gettext("lzo compression")); #endif }
static gpgme_error_t read_passphrase(void *hook, const char *uid_hint, const char *passphrase_info, int prev_was_bad, int fd) { crypto_asym *obj = (crypto_asym *)(hook); const char * precision = gettext("Passphrase required for key %s :"); string message; secu_string pass; ssize_t wrote; gpgme_error_t ret = GPG_ERR_NO_ERROR; thread_cancellation th; if(obj == NULL) throw SRC_BUG; if(uid_hint != NULL) message = tools_printf(precision, uid_hint); else { if(passphrase_info != NULL) message = tools_printf(precision, passphrase_info); else message = tools_printf(precision, ""); } if(prev_was_bad) obj->get_ui().warning(gettext("Error, invalid passphrase given, try again:")); pass = obj->get_ui().get_secu_string(message, false); th.check_self_cancellation(); wrote = write(fd, pass.c_str(), pass.size()); if(wrote < 0 || (U_I)(wrote) != pass.size()) { if(wrote == -1) obj->get_ui().warning(string(gettext("Error, while sending the passphrase to GPGME:")) + tools_strerror_r(errno)); else obj->get_ui().warning(gettext("Failed sending the totality of the passphrase to GPGME")); ret = GPG_ERR_CANCELED; } else { wrote = write(fd, "\n", 1); if(wrote != 1) obj->get_ui().warning(gettext("Failed sending CR after the passphrase")); ret = GPG_ERR_NO_ERROR; } return ret; }
void fichier_local::copy_from(const fichier_local & ref) { filedesc = dup(ref.filedesc); if(filedesc <0) { string tmp = tools_strerror_r(errno); throw Erange("fichier_local::copy_from", tools_printf(gettext("Cannot dup() filedescriptor while copying \"fichier_local\" object: %s"), tmp.c_str())); } }
compression string2compression(const std::string & a) { if(a == "gzip" || a == "gz") return gzip; if(a == "bzip2" || a == "bzip" || a == "bz") return bzip2; if(a == "lzo" || a == "lz" || a == "l") return lzo; throw Erange("string2compression", tools_printf(gettext("unknown compression algorithm: %S"), &a)); }
void user_interaction::listing(const std::string & flag, const std::string & perm, const std::string & uid, const std::string & gid, const std::string & size, const std::string & date, const std::string & filename, bool is_dir, bool has_children) { // stupid code to stop having compiler complaining against unused arguments throw Elibcall("user_interaction::listing", tools_printf("Not overwritten listing() method called with: (%S, %S, %S, %S, %S, %S, %S, %s, %s)", &flag, &perm, &uid, &gid, &size, &date, &filename, is_dir ? "true" : "false", has_children ? "true" : "false")); }