Enlightenment CVS committal

Author  : sebastid
Project : e17
Module  : libs/ecore

Dir     : e17/libs/ecore/src/lib/ecore_file


Modified Files:
        ecore_file.c ecore_file_download.c ecore_file_monitor.c 
        ecore_file_path.c 


Log Message:
init count

===================================================================
RCS file: 
/cvsroot/enlightenment/e17/libs/ecore/src/lib/ecore_file/ecore_file.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -3 -r1.12 -r1.13
--- ecore_file.c        27 Aug 2005 04:17:36 -0000      1.12
+++ ecore_file.c        7 Sep 2005 08:50:25 -0000       1.13
@@ -3,29 +3,41 @@
  */
 #include "ecore_file_private.h"
 
+static int init = 0;
+
 /* externally accessible functions */
 int
 ecore_file_init()
 {
+   if (++init > 1) return init;
+
    if (!ecore_file_monitor_init())
-     return 0;
+     goto error;
    if (!ecore_file_path_init())
-     return 0;
+     goto error;
    if (!ecore_file_download_init())
-     return 0;
-   return 1;
+     goto error;
+   return init;
+
+error:
+
+   ecore_file_monitor_shutdown();
+   ecore_file_path_shutdown();
+   ecore_file_download_shutdown();
+
+   return --init;
 }
 
 int
 ecore_file_shutdown()
 {
-   if (!ecore_file_monitor_shutdown())
-     return 0;
-   if (!ecore_file_path_shutdown())
-     return 0;
-   if (!ecore_file_download_shutdown())
-     return 0;
-   return 1;
+   if (--init > 0) return init;
+
+   ecore_file_monitor_shutdown();
+   ecore_file_path_shutdown();
+   ecore_file_download_shutdown();
+
+   return init;
 }
 
 time_t
===================================================================
RCS file: 
/cvsroot/enlightenment/e17/libs/ecore/src/lib/ecore_file/ecore_file_download.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -3 -r1.5 -r1.6
--- ecore_file_download.c       22 Jun 2005 14:51:37 -0000      1.5
+++ ecore_file_download.c       7 Sep 2005 08:50:25 -0000       1.6
@@ -3,6 +3,8 @@
  */
 #include "ecore_file_private.h"
 
+static int init = 0;
+
 #ifdef HAVE_CURL
 #include <curl/curl.h>
 
@@ -31,10 +33,12 @@
 int
 ecore_file_download_init(void)
 {
+   if (++init > 1) return init;
+
 #ifdef HAVE_CURL
    FD_ZERO(&_current_fd_set);
    _job_list = ecore_list_new();
-   if (!_job_list) return 0;
+   if (!_job_list) return --init;
 
    if (curl_global_init(CURL_GLOBAL_NOTHING)) return 0;
 
@@ -43,15 +47,16 @@
      {
        ecore_list_destroy(_job_list);
        _job_list = NULL;
-       return 0;
+       return --init;
      }
 #endif
-   return 1;
+   return init;
 }
 
 int
 ecore_file_download_shutdown(void)
 {
+   if (--init > 0) return init;
 #ifdef HAVE_CURL
    Ecore_File_Download_Job *job;
 
@@ -72,7 +77,7 @@
    curl_multi_cleanup(curlm);
    curl_global_cleanup();
 #endif
-   return 1;
+   return init;
 }
 
 int
===================================================================
RCS file: 
/cvsroot/enlightenment/e17/libs/ecore/src/lib/ecore_file/ecore_file_monitor.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -3 -r1.4 -r1.5
--- ecore_file_monitor.c        27 Aug 2005 12:25:22 -0000      1.4
+++ ecore_file_monitor.c        7 Sep 2005 08:50:25 -0000       1.5
@@ -3,6 +3,8 @@
  */
 #include "ecore_file_private.h"
 
+static int init = 0;
+
 typedef enum {
      ECORE_FILE_MONITOR_TYPE_NONE,
 #ifdef HAVE_INOTIFY
@@ -21,48 +23,55 @@
 int
 ecore_file_monitor_init(void)
 {
+   if (++init > 1) return init;
+
 #ifdef HAVE_INOTIFY
    monitor_type = ECORE_FILE_MONITOR_TYPE_INOTIFY;
    if (ecore_file_monitor_inotify_init())
-     return 1;
+     return init;
 #endif
 #ifdef HAVE_FAM
 #if 0
    monitor_type = ECORE_FILE_MONITOR_TYPE_FAM;
    if (ecore_file_monitor_fam_init())
-     return 1;
+     return init;
 #endif
 #endif
 #ifdef HAVE_POLL
    monitor_type = ECORE_FILE_MONITOR_TYPE_POLL;
    if (ecore_file_monitor_poll_init())
-     return 1;
+     return init;
 #endif
    monitor_type = ECORE_FILE_MONITOR_TYPE_NONE;
-   return 0;
+   return --init;
 }
 
 int
 ecore_file_monitor_shutdown(void)
 {
+   if (--init > 0) return init;
+
    switch (monitor_type)
      {
       case ECORE_FILE_MONITOR_TYPE_NONE:
-        return 1;
+        break;
 #ifdef HAVE_INOTIFY
       case ECORE_FILE_MONITOR_TYPE_INOTIFY:
-        return ecore_file_monitor_inotify_shutdown();
+        ecore_file_monitor_inotify_shutdown();
+        break;
 #endif
 #ifdef HAVE_FAM
       case ECORE_FILE_MONITOR_TYPE_FAM:
-        return ecore_file_monitor_fam_shutdown();
+        ecore_file_monitor_fam_shutdown();
+        break;
 #endif
 #ifdef HAVE_POLL
       case ECORE_FILE_MONITOR_TYPE_POLL:
-        return ecore_file_monitor_poll_shutdown();
+        ecore_file_monitor_poll_shutdown();
+        break;
 #endif
      }
-   return 0;
+   return init;
 }
 
 Ecore_File_Monitor *
===================================================================
RCS file: 
/cvsroot/enlightenment/e17/libs/ecore/src/lib/ecore_file/ecore_file_path.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -3 -r1.2 -r1.3
--- ecore_file_path.c   12 Jun 2005 14:08:46 -0000      1.2
+++ ecore_file_path.c   7 Sep 2005 08:50:25 -0000       1.3
@@ -3,22 +3,25 @@
  */
 #include "ecore_file_private.h"
 
-Ecore_List *__ecore_file_path_bin;
+static int init = 0;
+static Ecore_List *__ecore_file_path_bin;
 
 static Ecore_List *_ecore_file_path_from_env(const char *env);
 
 int
 ecore_file_path_init(void)
 {
+   if (++init > 1) return init;
    __ecore_file_path_bin = _ecore_file_path_from_env("PATH");
-   return 1;
+   return init;
 }
 
 int
 ecore_file_path_shutdown(void)
 {
+   if (--init > 0) return init;
    ecore_list_destroy(__ecore_file_path_bin);
-   return 1;
+   return init;
 }
 
 Ecore_List *




-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to