From 91444d360ab5b57b6c02423b925b1b2b46788bbc Mon Sep 17 00:00:00 2001
From: Martin Storsjo <martin@martin.st>
Date: Mon, 31 Oct 2011 16:51:48 +0200
Subject: [PATCH] Rename the read_file function family

Add a leading underscore to the function names. These function
names are very generic, and might clash with functions in
calling application code, if linking statically.
---
 gl/read-file.c               |    8 ++++----
 gl/read-file.h               |    6 +++---
 gl/tests/test-read-file.c    |    4 ++--
 lib/gnutls_x509.c            |   10 +++++-----
 lib/openpgp/gnutls_openpgp.c |    6 +++---
 src/certtool-common.c        |   12 ++++++------
 src/certtool.c               |   22 +++++++++++-----------
 src/cli.c                    |    2 +-
 8 files changed, 35 insertions(+), 35 deletions(-)

diff --git a/gl/read-file.c b/gl/read-file.c
index bcbfbbb..881df10 100644
--- a/gl/read-file.c
+++ b/gl/read-file.c
@@ -41,7 +41,7 @@
    *LENGTH.  On errors, *LENGTH is undefined, errno preserves the
    values set by system functions (if any), and NULL is returned.  */
 char *
-fread_file (FILE *stream, size_t *length)
+_fread_file (FILE *stream, size_t *length)
 {
   char *buf = NULL;
   size_t alloc = BUFSIZ;
@@ -145,7 +145,7 @@ internal_read_file (const char *filename, size_t *length, const char *mode)
   if (!stream)
     return NULL;
 
-  out = fread_file (stream, length);
+  out = _fread_file (stream, length);
 
   save_errno = errno;
 
@@ -170,7 +170,7 @@ internal_read_file (const char *filename, size_t *length, const char *mode)
    undefined, errno preserves the values set by system functions (if
    any), and NULL is returned.  */
 char *
-read_file (const char *filename, size_t *length)
+_read_file (const char *filename, size_t *length)
 {
   return internal_read_file (filename, length, "r");
 }
@@ -183,7 +183,7 @@ read_file (const char *filename, size_t *length)
    preserves the values set by system functions (if any), and NULL is
    returned.  */
 char *
-read_binary_file (const char *filename, size_t *length)
+_read_binary_file (const char *filename, size_t *length)
 {
   return internal_read_file (filename, length, "rb");
 }
diff --git a/gl/read-file.h b/gl/read-file.h
index 42663ef..5b82413 100644
--- a/gl/read-file.h
+++ b/gl/read-file.h
@@ -25,10 +25,10 @@
 /* Get FILE.  */
 #include <stdio.h>
 
-extern char *fread_file (FILE * stream, size_t * length);
+extern char *_fread_file (FILE * stream, size_t * length);
 
-extern char *read_file (const char *filename, size_t * length);
+extern char *_read_file (const char *filename, size_t * length);
 
-extern char *read_binary_file (const char *filename, size_t * length);
+extern char *_read_binary_file (const char *filename, size_t * length);
 
 #endif /* READ_FILE_H */
diff --git a/gl/tests/test-read-file.c b/gl/tests/test-read-file.c
index de7a0bb..57deedb 100644
--- a/gl/tests/test-read-file.c
+++ b/gl/tests/test-read-file.c
@@ -37,7 +37,7 @@ main (void)
   if (stat (FILE1, &statbuf) >= 0)
     {
       size_t len;
-      char *out = read_file (FILE1, &len);
+      char *out = _read_file (FILE1, &len);
 
       if (!out)
         {
@@ -79,7 +79,7 @@ main (void)
   if (stat (FILE2, &statbuf) >= 0)
     {
       size_t len;
-      char *out = read_file (FILE2, &len);
+      char *out = _read_file (FILE2, &len);
 
       if (!out)
         {
diff --git a/lib/gnutls_x509.c b/lib/gnutls_x509.c
index 37ba539..741bec0 100644
--- a/lib/gnutls_x509.c
+++ b/lib/gnutls_x509.c
@@ -691,7 +691,7 @@ read_cert_file (gnutls_certificate_credentials_t res,
     }
 #endif /* ENABLE_PKCS11 */
 
-  data = read_binary_file (certfile, &size);
+  data = _read_binary_file (certfile, &size);
 
   if (data == NULL)
     {
@@ -726,7 +726,7 @@ read_key_file (gnutls_certificate_credentials_t res,
     }
 #endif /* ENABLE_PKCS11 */
 
-  data = read_binary_file (keyfile, &size);
+  data = _read_binary_file (keyfile, &size);
 
   if (data == NULL)
     {
@@ -1316,7 +1316,7 @@ gnutls_certificate_set_x509_trust_file (gnutls_certificate_credentials_t res,
     }
 #endif
 
-  data = read_binary_file (cafile, &size);
+  data = _read_binary_file (cafile, &size);
   if (data == NULL)
     {
       gnutls_assert ();
@@ -1538,7 +1538,7 @@ gnutls_certificate_set_x509_crl_file (gnutls_certificate_credentials_t res,
 {
   int ret;
   size_t size;
-  char *data = read_binary_file (crlfile, &size);
+  char *data = _read_binary_file (crlfile, &size);
 
   if (data == NULL)
     {
@@ -1903,7 +1903,7 @@ int
   size_t size;
   int ret;
 
-  p12blob.data = read_binary_file (pkcs12file, &size);
+  p12blob.data = _read_binary_file (pkcs12file, &size);
   p12blob.size = (unsigned int) size;
   if (p12blob.data == NULL)
     {
diff --git a/lib/openpgp/gnutls_openpgp.c b/lib/openpgp/gnutls_openpgp.c
index 433a352..7804fe5 100644
--- a/lib/openpgp/gnutls_openpgp.c
+++ b/lib/openpgp/gnutls_openpgp.c
@@ -429,7 +429,7 @@ gnutls_certificate_set_openpgp_key_file2 (gnutls_certificate_credentials_t
       return GNUTLS_E_FILE_ERROR;
     }
 
-  cert.data = read_binary_file (certfile, &size);
+  cert.data = _read_binary_file (certfile, &size);
   cert.size = (unsigned int) size;
   if (cert.data == NULL)
     {
@@ -437,7 +437,7 @@ gnutls_certificate_set_openpgp_key_file2 (gnutls_certificate_credentials_t
       return GNUTLS_E_FILE_ERROR;
     }
 
-  key.data = read_binary_file (keyfile, &size);
+  key.data = _read_binary_file (keyfile, &size);
   key.size = (unsigned int) size;
   if (key.data == NULL)
     {
@@ -526,7 +526,7 @@ gnutls_certificate_set_openpgp_keyring_file (gnutls_certificate_credentials_t
       return GNUTLS_E_INVALID_REQUEST;
     }
 
-  ring.data = read_binary_file (file, &size);
+  ring.data = _read_binary_file (file, &size);
   ring.size = (unsigned int) size;
   if (ring.data == NULL)
     {
diff --git a/src/certtool-common.c b/src/certtool-common.c
index 1482d34..808c47c 100644
--- a/src/certtool-common.c
+++ b/src/certtool-common.c
@@ -282,7 +282,7 @@ load_private_key (int mand, common_info_st * info)
     return _load_pkcs11_privkey(info->privkey);
 #endif
 
-  dat.data = read_binary_file (info->privkey, &size);
+  dat.data = _read_binary_file (info->privkey, &size);
   dat.size = size;
 
   if (!dat.data)
@@ -316,7 +316,7 @@ load_x509_private_key (int mand, common_info_st * info)
   if (ret < 0)
     error (EXIT_FAILURE, 0, "privkey_init: %s", gnutls_strerror (ret));
 
-  dat.data = read_binary_file (info->privkey, &size);
+  dat.data = _read_binary_file (info->privkey, &size);
   dat.size = size;
 
   if (!dat.data)
@@ -452,7 +452,7 @@ load_request (common_info_st * info)
   if (ret < 0)
     error (EXIT_FAILURE, 0, "crq_init: %s", gnutls_strerror (ret));
 
-  dat.data = read_binary_file (info->request, &size);
+  dat.data = _read_binary_file (info->request, &size);
   dat.size = size;
 
   if (!dat.data)
@@ -490,7 +490,7 @@ load_ca_private_key (common_info_st * info)
     return _load_pkcs11_privkey(info->ca_privkey);
 #endif
 
-  dat.data = read_binary_file (info->ca_privkey, &size);
+  dat.data = _read_binary_file (info->ca_privkey, &size);
   dat.size = size;
 
   if (!dat.data)
@@ -521,7 +521,7 @@ load_ca_cert (common_info_st * info)
   if (ret < 0)
     error (EXIT_FAILURE, 0, "crt_init: %s", gnutls_strerror (ret));
 
-  dat.data = read_binary_file (info->ca, &size);
+  dat.data = _read_binary_file (info->ca, &size);
   dat.size = size;
 
   if (!dat.data)
@@ -563,7 +563,7 @@ load_pubkey (int mand, common_info_st * info)
   if (ret < 0)
     error (EXIT_FAILURE, 0, "privkey_init: %s", gnutls_strerror (ret));
 
-  dat.data = read_binary_file (info->pubkey, &size);
+  dat.data = _read_binary_file (info->pubkey, &size);
   dat.size = size;
 
   if (!dat.data)
diff --git a/src/certtool.c b/src/certtool.c
index cf831d3..e2edda7 100644
--- a/src/certtool.c
+++ b/src/certtool.c
@@ -1214,7 +1214,7 @@ certificate_info (int pubkey, common_info_st * cinfo)
   gnutls_datum_t pem;
   unsigned int crt_num;
 
-  pem.data = fread_file (infile, &size);
+  pem.data = _fread_file (infile, &size);
   pem.size = size;
 
   crt_num = MAX_CRTS;
@@ -1277,7 +1277,7 @@ pgp_certificate_info (void)
   gnutls_datum_t pem, out_data;
   unsigned int verify_status;
 
-  pem.data = fread_file (infile, &size);
+  pem.data = _fread_file (infile, &size);
   pem.size = size;
 
   ret = gnutls_openpgp_crt_init (&crt);
@@ -1464,7 +1464,7 @@ pgp_ring_info (void)
   int ret, i, count;
   gnutls_datum_t pem;
 
-  pem.data = fread_file (infile, &size);
+  pem.data = _fread_file (infile, &size);
   pem.size = size;
 
   ret = gnutls_openpgp_keyring_init (&ring);
@@ -1585,7 +1585,7 @@ crl_info (void)
   if (ret < 0)
     error (EXIT_FAILURE, 0, "crl_init: %s", gnutls_strerror (ret));
 
-  pem.data = fread_file (infile, &size);
+  pem.data = _fread_file (infile, &size);
   pem.size = size;
 
   if (!pem.data)
@@ -1641,7 +1641,7 @@ crq_info (void)
   if (ret < 0)
     error (EXIT_FAILURE, 0, "crq_init: %s", gnutls_strerror (ret));
 
-  pem.data = fread_file (infile, &size);
+  pem.data = _fread_file (infile, &size);
   pem.size = size;
 
   if (!pem.data)
@@ -2218,7 +2218,7 @@ verify_chain (void)
   char *buf;
   size_t size;
 
-  buf = fread_file (infile, &size);
+  buf = _fread_file (infile, &size);
   if (buf == NULL)
     error (EXIT_FAILURE, errno, "reading chain");
 
@@ -2239,13 +2239,13 @@ verify_certificate (common_info_st * cinfo)
   if (ca_file == NULL)
     error (EXIT_FAILURE, errno, "opening CA file");
 
-  cert = fread_file (infile, &cert_size);
+  cert = _fread_file (infile, &cert_size);
   if (cert == NULL)
     error (EXIT_FAILURE, errno, "reading certificate chain");
 
   cert[cert_size] = 0;
 
-  cas = fread_file (ca_file, &ca_size);
+  cas = _fread_file (ca_file, &ca_size);
   if (cas == NULL)
     error (EXIT_FAILURE, errno, "reading CA list");
 
@@ -2285,7 +2285,7 @@ verify_crl (common_info_st * cinfo)
   if (ret < 0)
     error (EXIT_FAILURE, 0, "crl_init: %s", gnutls_strerror (ret));
 
-  pem.data = fread_file (infile, &size);
+  pem.data = _fread_file (infile, &size);
   pem.size = size;
 
   ret = gnutls_x509_crl_import (crl, &pem, info.incert_format);
@@ -2660,7 +2660,7 @@ pkcs12_info (void)
   if (result < 0)
     error (EXIT_FAILURE, 0, "p12_init: %s", gnutls_strerror (result));
 
-  data.data = fread_file (infile, &size);
+  data.data = _fread_file (infile, &size);
   data.size = size;
 
   result = gnutls_pkcs12_import (pkcs12, &data, info.incert_format, 0);
@@ -2735,7 +2735,7 @@ pkcs7_info (void)
   if (result < 0)
     error (EXIT_FAILURE, 0, "p7_init: %s", gnutls_strerror (result));
 
-  data.data = fread_file (infile, &size);
+  data.data = _fread_file (infile, &size);
   data.size = size;
 
   result = gnutls_pkcs7_import (pkcs7, &data, info.incert_format);
diff --git a/src/cli.c b/src/cli.c
index 7cf87cb..4d5d204 100644
--- a/src/cli.c
+++ b/src/cli.c
@@ -120,7 +120,7 @@ load_file (const char *file)
   gnutls_datum_t loaded_file = { NULL, 0 };
   size_t length;
 
-  loaded_file.data = read_binary_file (file, &length);
+  loaded_file.data = _read_binary_file (file, &length);
   if (loaded_file.data)
     loaded_file.size = (unsigned int) length;
 
-- 
1.7.3.1

