make this the right way

SVN revision: 8525
This commit is contained in:
tsauerbeck 2004-01-17 15:58:40 +00:00 committed by tsauerbeck
parent 5402f1bcc2
commit f9f8ba198e
3 changed files with 30 additions and 8 deletions

View File

@ -69,6 +69,8 @@ main(int argc, char **argv)
"Big text string here compared to others",
"Eet is cool"
};
eet_init();
// blindly open an file for output and write strings with their NUL char
ef = eet_open("test.eet", EET_FILE_MODE_WRITE);
@ -86,6 +88,8 @@ main(int argc, char **argv)
ret = eet_read(ef, "Entry 3", &size);
printf("%s\n", ret);
eet_close(ef);
eet_shutdown();
}
@endcode

View File

@ -42,7 +42,21 @@ extern "C" {
typedef struct _Eet_Data_Descriptor Eet_Data_Descriptor;
/***************************************************************************/
/*
* Initialize the EET library.
*
* @return The new init count.
*/
void eet_init();
/**
* Shut down the EET library.
*
* @return The new init count.
*/
void eet_shutdown();
/**
* Open an eet file on disk, and returns a handle to it.
* @param file The file path to the eet file. eg: "/tmp/file.eet".
@ -684,11 +698,6 @@ extern "C" {
0, NULL, subtype); \
}
/**
* Shut down the EET library.
*/
void eet_shutdown();
/***************************************************************************/
#ifdef __cplusplus
}

View File

@ -83,6 +83,7 @@ static int eet_writers_num = 0;
static Eet_File **eet_writers = NULL;
static int eet_readers_num = 0;
static Eet_File **eet_readers = NULL;
static int eet_initcount = 0;
/* find an eet file in the currently in use cache */
static Eet_File *
@ -903,7 +904,15 @@ eet_list(Eet_File *ef, char *glob, int *count_ret)
return list_ret;
}
void eet_shutdown()
int eet_init(void)
{
_eet_memfile_shutdown();
return ++eet_initcount;
}
int eet_shutdown(void)
{
if (--eet_initcount == 0)
_eet_memfile_shutdown();
return eet_initcount;
}