예제 #1
0
static Bool
finiBackend (CCSContext * context)
{
    IniPrivData *data;

    data = findPrivFromContext (context);

    if (!data)
        return FALSE;

    if (data->iniFile)
        ccsIniClose (data->iniFile);

    if (data->iniWatchId)
        ccsRemoveFileWatch (data->iniWatchId);

    if (data->lastProfile)
        free (data->lastProfile);

    privDataSize--;

    if (privDataSize)
        privData = realloc (privData, privDataSize * sizeof (IniPrivData));
    else
    {
        free (privData);
        privData = NULL;
    }

    return TRUE;
}
예제 #2
0
static void
setProfile (IniPrivData *data,
	    char        *profile)
{
    char        *fileName;
    struct stat fileStat;

    if (data->iniFile)
	ccsIniClose (data->iniFile);

    if (data->iniWatchId)
	ccsRemoveFileWatch (data->iniWatchId);

    data->iniFile = NULL;

    data->iniWatchId = 0;

    /* first we need to find the file name */
    fileName = getIniFileName (profile);

    if (!fileName)
	return;

    /* if the file does not exist, we have to create it */
    if (stat (fileName, &fileStat) == -1)
    {
	if (errno == ENOENT)
	{
	    FILE *file;
	    file = fopen (fileName, "w");

	    if (!file)
	    {
		free (fileName);
		return;
	    }
	    fclose (file);
	}
	else
	{
	    free (fileName);
	    return;
	}
    }

    data->iniWatchId = ccsAddFileWatch (fileName, TRUE,
					processFileEvent, data);

    /* load the data from the file */
    data->iniFile = ccsIniOpen (fileName);

    free (fileName);
}
예제 #3
0
static Bool
finiBackend (CCSBackend * backend)
{
    IniPrivData *data;

    data = (IniPrivData *) ccsObjectGetPrivate (backend);

    if (!data)
	return FALSE;

    if (data->iniFile)
	ccsIniClose (data->iniFile);

    if (data->iniWatchId)
	ccsRemoveFileWatch (data->iniWatchId);

    if (data->lastProfile)
	free (data->lastProfile);

    free (data);
    ccsObjectSetPrivate (backend, NULL);

    return TRUE;
}