efl: add binary mode to f(re)open() calls
authorVincent Torri <vincent dot torri at gmail dot com>
Thu, 3 Dec 2015 08:32:39 +0000 (09:32 +0100)
committerCedric BAIL <cedric@osg.samsung.com>
Sat, 5 Dec 2015 20:04:36 +0000 (21:04 +0100)
This allows better compatibility with Windows

Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
30 files changed:
src/benchmarks/eina/evas_stringshare.c
src/bin/edje/edje_codegen.c
src/bin/edje/epp/cpplib.c
src/bin/edje/epp/cpplib.h
src/bin/edje/epp/cppmain.c
src/bin/efl/efl_debugd.c
src/examples/eina/eina_model_03.c
src/lib/ecore/ecore.c
src/lib/ecore_con/ecore_con_ssl.c
src/lib/ecore_x/xlib/ecore_x_vsync.c
src/lib/eet/Eet.h
src/lib/eet/eet_cipher.c
src/lib/efreet/efreet_menu.c
src/lib/efreet/efreet_mime.c
src/lib/efreet/efreet_trash.c
src/lib/eina/eina_benchmark.c
src/lib/elua/elua.c
src/lib/elua/io.c
src/lib/evas/canvas/evas_render.c
src/modules/evas/engines/fb/evas_fb_main.c
src/modules/evas/image_savers/tgv/evas_image_save_tgv.c
src/modules/evas/model_savers/obj/evas_model_save_obj.c
src/modules/evas/model_savers/ply/evas_model_save_ply.c
src/static_libs/dns/dns.c
src/static_libs/http-parser/contrib/parsertrace.c
src/tests/ecore/ecore_test_ecore_file.c
src/tests/eet/eet_suite.c
src/tests/eio/eio_test_monitor.c
src/tests/elua/elua_lib.c
src/utils/ecore/makekeys.c

index 6e8797c..ce0e6eb 100644 (file)
@@ -196,7 +196,7 @@ evas_stringshare_add(const char *str)
 //     {
 //     char bf[256];
 //     snprintf(bf, sizeof(bf), "strlog-%i", getpid());
-//     f = fopen(bf, "w");
+//     f = fopen(bf, "wb");
 //     }
    hash_num = _evas_stringshare_hash_gen(str, &slen);
    for (el = share.buckets[hash_num]; el; pel = el, el = el->next)
index f2ddc7f..0b2412f 100644 (file)
@@ -387,11 +387,11 @@ _standardizes_header(const char *filename)
 static Eina_Bool
 _open_file_descriptors(const char *source, const char *header)
 {
-   header_fd = fopen(header, "w");
+   header_fd = fopen(header, "wb");
    if (!header_fd)
      return EINA_FALSE;
 
-   source_fd = fopen(source, "w");
+   source_fd = fopen(source, "wb");
    if (!source_fd)
      goto err;
 
index b8e0ff2..0d2b503 100644 (file)
@@ -7492,7 +7492,7 @@ using_file(const char *filename, const char type)
    FILE *f = NULL;
 
    if (!options.watchfile) return;
-   f = fopen(options.watchfile, "a");
+   f = fopen(options.watchfile, "ab");
    if (!f) return;
    if (annotate)
      {
index c040ebd..18b6670 100644 (file)
@@ -345,7 +345,7 @@ struct cpp_options {
 
    char                print_deps_missing_files;
 
-   /* If true, fopen (deps_file, "a") else fopen (deps_file, "w"). */
+   /* If true, fopen (deps_file, "ab") else fopen (deps_file, "wb"). */
    char                print_deps_append;
 
    /* Nonzero means print names of header files (-H).  */
index 2e8059b..be04bac 100644 (file)
@@ -74,7 +74,7 @@ main(int argc, char **argv)
 
    if (!opts->out_fname || !strcmp(opts->out_fname, ""))
       opts->out_fname = "stdout";
-   else if (!freopen(opts->out_fname, "w", stdout))
+   else if (!freopen(opts->out_fname, "wb", stdout))
       cpp_pfatal_with_name(&parse_in, opts->out_fname);
 
    for (i = 0;; i++)
index a1025fb..a07fe3f 100644 (file)
@@ -129,7 +129,7 @@ _do(Client *c, char *op, unsigned char *d, int size)
                   c2->evlog_fetch_timer = ecore_timer_add(0.2, _cb_evlog, c2);
                   snprintf(buf, sizeof(buf), "%s/efl_debug_evlog-%ld.log",
                            getenv("HOME"), (long)c2->pid);
-                  c2->evlog_file = fopen(buf, "w");
+                  c2->evlog_file = fopen(buf, "wb");
                }
           }
      }
index a5e2562..61498da 100644 (file)
@@ -106,7 +106,7 @@ _address_book_load(Eina_Model *model)
 
    EINA_SAFETY_ON_NULL_RETURN_VAL(filename, EINA_FALSE);
 
-   f = fopen(filename, "r");
+   f = fopen(filename, "rb");
 
    // Now that we have used filename, we must free its memory holder:
    eina_value_flush(&val);
index f121258..d9fc9d9 100644 (file)
@@ -271,7 +271,7 @@ ecore_init(void)
        char tmp[1024];
 
        snprintf(tmp, sizeof(tmp), "ecore_mem_stat.%i", getpid());
-       _ecore_memory_statistic_file = fopen(tmp, "w");
+       _ecore_memory_statistic_file = fopen(tmp, "wb");
 #endif
         _ecore_memory_pid = getpid();
         ecore_animator_add(_ecore_memory_statistic, NULL);
index f16dd69..3c24afb 100644 (file)
@@ -1589,7 +1589,7 @@ _ecore_con_ssl_server_privkey_add_openssl(Ecore_Con_Server *obj,
    FILE *fp = NULL;
    EVP_PKEY *privkey = NULL;
 
-   if (!(fp = fopen(key_file, "r")))
+   if (!(fp = fopen(key_file, "rb")))
      goto error;
 
    SSL_ERROR_CHECK_GOTO_ERROR(!(privkey = PEM_read_PrivateKey(fp, NULL, NULL, NULL)));
@@ -1616,7 +1616,7 @@ _ecore_con_ssl_server_cert_add_openssl(Ecore_Con_Server *obj,
    FILE *fp = NULL;
    X509 *cert = NULL;
 
-   if (!(fp = fopen(cert_file, "r")))
+   if (!(fp = fopen(cert_file, "rb")))
      goto error;
 
    SSL_ERROR_CHECK_GOTO_ERROR(!(cert = PEM_read_X509(fp, NULL, NULL, NULL)));
index ea35b5a..bdf832c 100644 (file)
@@ -443,7 +443,7 @@ _drm_init(int *flags)
    if (stat("/sys/module/vboxvideo", &st) == 0)
      {
 /*
-        FILE *fp = fopen("/sys/module/vboxvideo/version", "r");
+        FILE *fp = fopen("/sys/module/vboxvideo/version", "rb");
         if (fp)
           {
              if (fgets(buf, sizeof(buf), fp))
@@ -462,7 +462,7 @@ _drm_init(int *flags)
    // only do this on new kernels = let's say 3.14 and up. 3.16 definitely
    // works
      {
-        FILE *fp = fopen("/proc/sys/kernel/osrelease", "r");
+        FILE *fp = fopen("/proc/sys/kernel/osrelease", "rb");
         if (fp)
           {
              if (fgets(buf, sizeof(buf), fp))
index 62074fd..c861165 100644 (file)
@@ -3224,7 +3224,7 @@ typedef void (*Eet_Dump_Callback)(void *data, const char *str);
  *   int len;
  *   void *data;
  *
- *   f = fopen(file, "r");
+ *   f = fopen(file, "rb");
  *   fseek(f, 0, SEEK_END);
  *   len = ftell(f);
  *   rewind(f);
@@ -4030,7 +4030,7 @@ eet_data_xattr_cipher_set(const char *filename,
  *   int len;
  *   void *data;
  *
- *   f = fopen(file, "r");
+ *   f = fopen(file, "rb");
  *   fseek(f, 0, SEEK_END);
  *   len = ftell(f);
  *   rewind(f);
index aa57e5c..a34fdff 100644 (file)
@@ -192,7 +192,7 @@ on_error:
    if (!emile_cipher_init()) return NULL;
 
    /* Load the X509 certificate in memory. */
-   fp = fopen(certificate_file, "r");
+   fp = fopen(certificate_file, "rb");
    if (!fp)
      return NULL;
 
@@ -207,7 +207,7 @@ on_error:
      goto on_error;
 
    /* Load the private key in memory. */
-   fp = fopen(private_key_file, "r");
+   fp = fopen(private_key_file, "rb");
    if (!fp)
      goto on_error;
 
index ada789b..b774460 100644 (file)
@@ -687,7 +687,7 @@ efreet_menu_save(Efreet_Menu *menu, const char *path)
     EINA_SAFETY_ON_NULL_RETURN_VAL(menu, 0);
     EINA_SAFETY_ON_NULL_RETURN_VAL(path, 0);
 
-    f = fopen(path, "w");
+    f = fopen(path, "wb");
     if (!f) return 0;
     fprintf(f, "<?xml version=\"1.0\"?>\n");
     fprintf(f, "<!DOCTYPE Menu PUBLIC \"-//freedesktop//DTD Menu 1.0//EN\" "
index 23d86cf..adfa790 100644 (file)
@@ -752,7 +752,7 @@ efreet_mime_fallback_check(const char *file)
    if (ecore_file_can_exec(file))
      return _mime_application_x_executable;
 
-   if (!(f = fopen(file, "r"))) return NULL;
+   if (!(f = fopen(file, "rb"))) return NULL;
 
    i = fread(buf, 1, sizeof(buf), f);
    fclose(f);
index 50a273b..5d9fd25 100644 (file)
@@ -215,7 +215,7 @@ efreet_trash_delete_uri(Efreet_Uri *uri, int force_delete)
     /* create info file */
     snprintf(dest, sizeof(dest), "%s/info/%s.trashinfo", trash_dir, fname);
 
-    if ((f = fopen(dest, "w")))
+    if ((f = fopen(dest, "wb")))
     {
         fputs("[Trash Info]\n", f);
 
index d018a0a..0159ddc 100644 (file)
@@ -239,7 +239,7 @@ eina_benchmark_run(Eina_Benchmark *bench)
             bench->name,
             bench->run);
 
-   main_script = fopen(buffer, "w");
+   main_script = fopen(buffer, "wb");
    if (!main_script)
       return NULL;
 
@@ -293,7 +293,7 @@ eina_benchmark_run(Eina_Benchmark *bench)
                bench->run,
                run->name);
 
-      current_data = fopen(buffer, "w");
+      current_data = fopen(buffer, "wb");
       if (!current_data)
          continue;
 
index 602e5d1..47bcd3f 100644 (file)
@@ -617,7 +617,7 @@ elua_util_script_run(Elua_State *es, int argc, char **argv, int n, int *quit)
    if (fname)
      {
         /* check if there is a file of that name */
-        FILE *f = fopen(fname, "r");
+        FILE *f = fopen(fname, "rb");
         if (f)
           {
              fclose(f);
index d5b8a0c..6835e99 100644 (file)
@@ -10,7 +10,7 @@ get_cmdline_from_argv(const char *fname, const char **argv)
    char         pbuf[PATH_MAX];
    const char  *arg = NULL;
 
-   FILE *testf = fopen(fname, "r");
+   FILE *testf = fopen(fname, "rb");
    if  (!testf)
       return NULL;
 
index 63749e8..1645ebc 100644 (file)
@@ -29,7 +29,7 @@ rend_dbg(const char *txt)
 #ifdef STDOUT_DBG
         dbf = stdout;
 #else
-        dbf = fopen("EVAS-RENDER-DEBUG.log", "w");
+        dbf = fopen("EVAS-RENDER-DEBUG.log", "wb");
 #endif
         if (!dbf) return;
      }
index 3b8b23b..aab4147 100644 (file)
@@ -345,7 +345,7 @@ fb_list_modes(unsigned int *num_return)
    int num;
    
    num = 0;
-   f = fopen("/etc/fb.modes","r");
+   f = fopen("/etc/fb.modes","rb");
    if (!f)
      {
         *num_return = 0;
index 44b38e0..aa0a82b 100644 (file)
@@ -111,7 +111,7 @@ _save_direct_tgv(RGBA_Image *im, const char *file, int compress)
    // header[7]: options (unused)
    header[7] = 0;
 
-   f = fopen(file, "w");
+   f = fopen(file, "wb");
    if (!f) return 0;
 
    // Write header
@@ -300,7 +300,7 @@ evas_image_save_file_tgv(RGBA_Image *im,
    // Note: consider extending the header instead of filling all the bits here
    header[7] = 0;
 
-   f = fopen(file, "w");
+   f = fopen(file, "wb");
    if (!f) return 0;
 
    // Write header
index 09e5c72..8789ce4 100644 (file)
@@ -163,7 +163,7 @@ _save_mesh(Evas_Canvas3D_Mesh_Data *pd,
 
    evas_model_save_data_from_mesh(pd, f, header, &data);
 
-   FILE * _obj_file = fopen(_obj_file_name, "w+");
+   FILE * _obj_file = fopen(_obj_file_name, "wb+");
    if (!_obj_file)
      {
         ERR("File open '%s' for save failed", _obj_file_name);
@@ -191,7 +191,7 @@ _save_material(Evas_Canvas3D_Mesh_Data *pd EINA_UNUSED,
                const char *_mtl_file_name,
                Evas_Canvas3D_Material_Data *mat)
 {
-   FILE * _mtl_file = fopen(_mtl_file_name, "w+");
+   FILE * _mtl_file = fopen(_mtl_file_name, "wb+");
    if (!_mtl_file)
      {
         ERR("File open '%s' for save failed", _mtl_file_name);
index 8da8f74..805f267 100644 (file)
@@ -75,7 +75,7 @@ evas_model_save_file_ply(const Evas_Canvas3D_Mesh *mesh,
    if (!evas_model_save_header_from_mesh(pd, f, &header)) return;
    evas_model_save_data_from_mesh(pd, f, header, &data);
 
-   FILE *_ply_file = fopen(file, "w+");
+   FILE *_ply_file = fopen(file, "wb+");
    if (!_ply_file)
      {
         ERR("File open '%s' for save failed", file);
index 0100550..a426a53 100644 (file)
@@ -3516,7 +3516,7 @@ int dns_hosts_loadpath(struct dns_hosts *hosts, const char *path) {
        FILE *fp;
        int error;
 
-       if (!(fp = fopen(path, "r")))
+       if (!(fp = fopen(path, "rb")))
                return dns_syerr();
 
        error   = dns_hosts_loadfile(hosts, fp);
@@ -4073,7 +4073,7 @@ int dns_resconf_loadpath(struct dns_resolv_conf *resconf, const char *path) {
        FILE *fp;
        int error;
 
-       if (!(fp = fopen(path, "r")))
+       if (!(fp = fopen(path, "rb")))
                return dns_syerr();
 
        error   = dns_resconf_loadfile(resconf, fp);
@@ -4456,7 +4456,7 @@ int dns_nssconf_loadpath(struct dns_resolv_conf *resconf, const char *path) {
        FILE *fp;
        int error;
 
-       if (!(fp = fopen(path, "r")))
+       if (!(fp = fopen(path, "rb")))
                return dns_syerr();
 
        error = dns_nssconf_loadfile(resconf, fp);
index c9bc71e..ed35f86 100644 (file)
@@ -108,7 +108,7 @@ int main(int argc, char* argv[]) {
   }
 
   char* filename = argv[2];
-  FILE* file = fopen(filename, "r");
+  FILE* file = fopen(filename, "rb");
   if (file == NULL) {
     perror("fopen");
     return EXIT_FAILURE;
index 93689ac..1e2d801 100644 (file)
@@ -20,9 +20,9 @@
 void
 _writeToFile(const char *filePath, char *text)
 {
-   FILE *f = fopen(filePath, "r+");
+   FILE *f = fopen(filePath, "rb+");
    if (f == NULL)
-     f = fopen(filePath, "w");
+     f = fopen(filePath, "wb");
    fail_if(f == NULL);
    fprintf(f, "%s\n", text);
    fclose(f);
index 9db0e9c..673294b 100644 (file)
@@ -1734,7 +1734,7 @@ START_TEST(eet_identity_simple)
 
    fail_if(-1 == (fd = mkstemp(file)));
    fail_if(!!close(fd));
-   fail_if(!(noread = fopen("/dev/null", "w")));
+   fail_if(!(noread = fopen("/dev/null", "wb")));
 
    /* Sign an eet file. */
    ef = eet_open(file, EET_FILE_MODE_WRITE);
index 7b93928..daf2a3f 100644 (file)
@@ -72,7 +72,7 @@ static Eina_Bool _create_directory(void *data)
 
 static Eina_Bool _create_file(void *data)
 {
-   FILE *fd = fopen((const char*)data, "w+");
+   FILE *fd = fopen((const char*)data, "wb+");
    ck_assert_ptr_ne(fd, NULL);
    fprintf(fd, "test test");
    fclose(fd);
@@ -88,7 +88,7 @@ static Eina_Bool _delete_file(void *data)
 
 static Eina_Bool _modify_file(void *data)
 {
-   FILE *fd = fopen((const char*)data, "a");
+   FILE *fd = fopen((const char*)data, "ab");
    ck_assert_ptr_ne(fd, NULL);
    fprintf(fd, "appened");
    fclose(fd);
index 43df108..aecc26a 100644 (file)
@@ -116,7 +116,7 @@ START_TEST(elua_api)
     fail_if(!elua_util_script_run(st, 2, cargv, 1, &quit));
     fail_if(quit != 1);
 
-    f = fopen(buf, "w");
+    f = fopen(buf, "wb");
     fail_if(!f);
     fprintf(f, "return false");
     fclose(f);
index 69383af..87b76c6 100644 (file)
@@ -66,7 +66,7 @@ main(int argc, char **argv)
 
    for (l = 1; l < argc; l++) 
      {
-        if (!(fptr = fopen(argv[l], "r"))) 
+        if (!(fptr = fopen(argv[l], "rb")))
           {
              fprintf(stderr, "Could not open %s\n", argv[l]);
              continue;