From 3eabd14ace6523781473486b533b8e4ac355fc14 Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Mon, 11 Nov 2002 06:24:56 +0000 Subject: Use g_strerror when setting an exception string (we need it to be in 2002-11-11 Jeffrey Stedfast * providers/local/camel-spool-summary.c (spool_summary_sync_full): Use g_strerror when setting an exception string (we need it to be in UTF-8). (spool_summary_check): Here too. * providers/local/camel-spool-store.c (construct): Use g_strerror when setting an exception string (we need it to be in UTF-8). (get_folder): Same. (scan_dir): Here too. * providers/local/camel-spool-folder.c (spool_lock): Use g_strerror when setting an exception string (we need it to be in UTF-8). * providers/local/camel-mh-summary.c (mh_summary_check): Use g_strerror when setting an exception string (we need it to be in UTF-8). * providers/local/camel-mh-store.c (delete_folder): Use g_strerror when setting an exception string (we need it to be in UTF-8). * providers/local/camel-mbox-summary.c (summary_update): Use g_strerror when setting an exception string (we need it to be in UTF-8). (mbox_summary_sync_full): Here too. (mbox_summary_sync_quick): Same. (mbox_summary_sync): Also here. (camel_mbox_summary_sync_mbox): Again here. * providers/local/camel-mbox-folder.c (mbox_lock): Use g_strerror when setting an exception string (we need it to be in UTF-8). (mbox_append_message): Same. (mbox_get_message): Here too. * providers/local/camel-maildir-summary.c (maildir_summary_load): Use g_strerror when setting an exception string (we need it to be in UTF-8). (maildir_summary_check): Same. * providers/local/camel-maildir-store.c (get_folder): Use g_strerror when setting an exception string (we need it to be in UTF-8). (delete_folder): Same. (delete_folder): Here too. * providers/local/camel-local-summary.c (local_summary_sync): Use g_strerror when setting an exception string (we need it to be in UTF-8). * providers/local/camel-local-store.c (get_folder): Use g_strerror when setting an exception string (we need it to be in UTF-8). (create_folder): Same. (xrename): Here too. (rename_folder): And here. (delete_folder): Also here. * camel-provider.c (camel_provider_init): For debugging printfs, we want to use normal strerror (we want locale charset, not UTF-8). * camel-movemail.c (camel_movemail): Use g_strerror when setting an exception string (we need it to be in UTF-8). (movemail_external): Same. (camel_movemail_copy_file): Here too. (camel_movemail_solaris): Also here. * camel-mime-utils.c (rfc2047_decode_word): For debugging printfs, we want to use normal strerror (we want locale charset, not UTF-8). (header_encode_param): Same. * camel-mime-part-utils.c (convert_buffer): For debugging printfs, we want to use normal strerror (we want locale charset, not UTF-8). * camel-lock-client.c (camel_lock_helper_init): Use g_strerror when setting an exception string (we need it to be in UTF-8). * camel-data-cache.c (camel_data_cache_remove): Use g_strerror when setting an exception string (we need it to be in UTF-8). * camel-tcp-stream-raw.c (flaky_tcp_write): For debugging printfs, we want to use normal strerror (we want locale charset, not UTF-8). (flaky_tcp_read): Same. * camel-gpg-context.c (gpg_ctx_op_step): For debugging printfs, we want to use normal strerror (we want locale charset, not UTF-8). * camel-service.c (camel_gethostbyname): Use g_strerror when setting an exception string (we need it to be in UTF-8). * camel-lock.c (camel_lock_dot): Use g_strerror when setting an exception string (we need it to be in UTF-8). (camel_lock_fcntl): Same. svn path=/trunk/; revision=18689 --- camel/camel-tcp-stream-ssl.c | 57 ++++++++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 28 deletions(-) (limited to 'camel/camel-tcp-stream-ssl.c') diff --git a/camel/camel-tcp-stream-ssl.c b/camel/camel-tcp-stream-ssl.c index e2604adbc0..3aa841d9df 100644 --- a/camel/camel-tcp-stream-ssl.c +++ b/camel/camel-tcp-stream-ssl.c @@ -503,34 +503,34 @@ camel_certdb_nss_cert_get(CamelCertDB *certdb, CERTCertificate *cert) int fd; ssize_t len; struct stat st; - - fingerprint = cert_fingerprint(cert); - ccert = camel_certdb_get_cert(certdb, fingerprint); + + fingerprint = cert_fingerprint (cert); + ccert = camel_certdb_get_cert (certdb, fingerprint); if (ccert == NULL) { - g_free(fingerprint); + g_free (fingerprint); return ccert; } - + if (ccert->rawcert == NULL) { - path = g_strdup_printf("%s/.camel_certs/%s", getenv("HOME"), fingerprint); - if (stat(path, &st) == -1 - || (fd = open(path, O_RDONLY)) == -1) { - g_warning("could not load cert %s: %s", path, strerror(errno)); - g_free(fingerprint); - g_free(path); - camel_cert_set_trust(certdb, ccert, CAMEL_CERT_TRUST_UNKNOWN); - camel_certdb_touch(certdb); - + path = g_strdup_printf ("%s/.camel_certs/%s", getenv ("HOME"), fingerprint); + if (stat (path, &st) == -1 + || (fd = open (path, O_RDONLY)) == -1) { + g_warning ("could not load cert %s: %s", path, strerror (errno)); + g_free (fingerprint); + g_free (path); + camel_cert_set_trust (certdb, ccert, CAMEL_CERT_TRUST_UNKNOWN); + camel_certdb_touch (certdb); + return ccert; } g_free(path); - ccert->rawcert = g_byte_array_new(); + ccert->rawcert = g_byte_array_new (); g_byte_array_set_size(ccert->rawcert, st.st_size); len = read(fd, ccert->rawcert->data, st.st_size); close(fd); if (len != st.st_size) { - g_warning("cert size read truncated %s: %d != %ld", path, len, st.st_size); + g_warning ("cert size read truncated %s: %d != %ld", path, len, st.st_size); g_byte_array_free(ccert->rawcert, TRUE); ccert->rawcert = NULL; g_free(fingerprint); @@ -586,11 +586,12 @@ camel_certdb_nss_cert_set(CamelCertDB *certdb, CamelCert *ccert, CERTCertificate struct stat st; fingerprint = ccert->fingerprint; - + if (ccert->rawcert == NULL) - ccert->rawcert = g_byte_array_new(); - g_byte_array_set_size(ccert->rawcert, cert->derCert.len); - memcpy(ccert->rawcert->data, cert->derCert.data, cert->derCert.len); + ccert->rawcert = g_byte_array_new (); + + g_byte_array_set_size (ccert->rawcert, cert->derCert.len); + memcpy (ccert->rawcert->data, cert->derCert.data, cert->derCert.len); dir = g_strdup_printf ("%s/.camel_certs", getenv ("HOME")); if (stat (dir, &st) == -1 && mkdir (dir, 0700) == -1) { @@ -602,19 +603,19 @@ camel_certdb_nss_cert_set(CamelCertDB *certdb, CamelCert *ccert, CERTCertificate path = g_strdup_printf ("%s/%s", dir, fingerprint); g_free (dir); - stream = camel_stream_fs_new_with_name(path, O_WRONLY|O_CREAT|O_TRUNC, 0600); + stream = camel_stream_fs_new_with_name (path, O_WRONLY | O_CREAT | O_TRUNC, 0600); if (stream != NULL) { - if (camel_stream_write(stream, ccert->rawcert->data, ccert->rawcert->len) != ccert->rawcert->len) { - g_warning("Could not save cert: %s: %s", path, strerror(errno)); - unlink(path); + if (camel_stream_write (stream, ccert->rawcert->data, ccert->rawcert->len) == -1) { + g_warning ("Could not save cert: %s: %s", path, strerror (errno)); + unlink (path); } - camel_stream_close(stream); - camel_object_unref(stream); + camel_stream_close (stream); + camel_object_unref (stream); } else { - g_warning("Could not save cert: %s: %s", path, strerror(errno)); + g_warning ("Could not save cert: %s: %s", path, strerror (errno)); } - g_free(path); + g_free (path); } -- cgit