authme-unix/src/cnffile.c
authme_err_t
authme_save_user_cnf(authme_service_config_t * psc, int flags, char * username)
{

	char * n = username;
	bfr_t * b;

	char * base_dir;

	base_dir = get_user_dir(NULL);
	if (base_dir == NULL)
		return AUTHME_ERR_FILE_OPEN;

	b = new_bfr();
	append_bfr(b, base_dir);
#if defined WIN32
	append_bfr(b, "\\.authme");
#else
	append_bfr(b, "/.authme");
#endif

	FILE *out = fopen(b->b, "wt");
	free_bfr(b);

	if (out == NULL)
		return AUTHME_ERR_FILE_OPEN;

	/* Default output */
	fprintf(out, "# Authme %s configuration file\n\n", AUTHME_LIBRARY_VERSION);
	if (psc->psc_url != NULL && !(flags & AUTHME_CNF_IGNORE_SERVICE_URL))
		fprintf(out, "ServiceURL %s\n", psc->psc_url);
	if (psc->psc_user_id != NULL && !(flags & AUTHME_CNF_IGNORE_USER_ID))
		fprintf(out, "ServiceUserId %s\n", psc->psc_user_id);
	if (psc->psc_key_file != NULL && !(flags & AUTHME_CNF_IGNORE_KEY_FILENAME))
		fprintf(out, "KeyFileName %s\n", psc->psc_key_file);

	/* The password for the key file if it exists */
	if (psc->psc_key_file_pass.password_data != NULL && !(flags & AUTHME_CNF_IGNORE_KEY_FILE_PASS))
	{
		fprintf(out, "KeyFilePass %c!%s", '0' + psc->psc_key_file_pass.password_format, psc->psc_key_file_pass.password_data);
	}

	fclose(out);

	return AUTHME_ERR_OK;

}
/* Save the file back to the user's directory - really for use by
 * GUI on Windows */
Save the file back to the user's directory - really for use by
GUI on Windows
Save the file back to the user ' s directory - really for use by GUI on Windows
authme_err_t
authme_save_user_cnf(authme_service_config_t * psc, int flags, char * username)
{
	char * n = username;
	bfr_t * b;
	char * base_dir;
	base_dir = get_user_dir(NULL);
	if (base_dir == NULL)
		return AUTHME_ERR_FILE_OPEN;
	b = new_bfr();
	append_bfr(b, base_dir);
#if defined WIN32
	append_bfr(b, "\\.authme");
#else
	append_bfr(b, "/.authme");
#endif
	FILE *out = fopen(b->b, "wt");
	free_bfr(b);
	if (out == NULL)
		return AUTHME_ERR_FILE_OPEN;
	fprintf(out, "# Authme %s configuration file\n\n", AUTHME_LIBRARY_VERSION);
	if (psc->psc_url != NULL && !(flags & AUTHME_CNF_IGNORE_SERVICE_URL))
		fprintf(out, "ServiceURL %s\n", psc->psc_url);
	if (psc->psc_user_id != NULL && !(flags & AUTHME_CNF_IGNORE_USER_ID))
		fprintf(out, "ServiceUserId %s\n", psc->psc_user_id);
	if (psc->psc_key_file != NULL && !(flags & AUTHME_CNF_IGNORE_KEY_FILENAME))
		fprintf(out, "KeyFileName %s\n", psc->psc_key_file);
	if (psc->psc_key_file_pass.password_data != NULL && !(flags & AUTHME_CNF_IGNORE_KEY_FILE_PASS))
	{
		fprintf(out, "KeyFilePass %c!%s", '0' + psc->psc_key_file_pass.password_format, psc->psc_key_file_pass.password_data);
	}
	fclose(out);
	return AUTHME_ERR_OK;
}
authme_err_t authme_save_user_cnf ( authme_service_config_t * psc , int flags , char * username ) { char * n = username ; bfr_t * b ; char * base_dir ; base_dir = get_user_dir ( NULL ) ; if ( base_dir == NULL ) return AUTHME_ERR_FILE_OPEN ; b = new_bfr ( ) ; append_bfr ( b , base_dir ) ; #if defined WIN32 append_bfr ( b , " \\ " ) ; #else append_bfr ( b , " " ) ; #endif FILE * out = fopen ( b -> b , " " ) ; free_bfr ( b ) ; if ( out == NULL ) return AUTHME_ERR_FILE_OPEN ; fprintf ( out , " \n \n " , AUTHME_LIBRARY_VERSION ) ; if ( psc -> psc_url != NULL && ! ( flags & AUTHME_CNF_IGNORE_SERVICE_URL ) ) fprintf ( out , " \n " , psc -> psc_url ) ; if ( psc -> psc_user_id != NULL && ! ( flags & AUTHME_CNF_IGNORE_USER_ID ) ) fprintf ( out , " \n " , psc -> psc_user_id ) ; if ( psc -> psc_key_file != NULL && ! ( flags & AUTHME_CNF_IGNORE_KEY_FILENAME ) ) fprintf ( out , " \n " , psc -> psc_key_file ) ; if ( psc -> psc_key_file_pass . password_data != NULL && ! ( flags & AUTHME_CNF_IGNORE_KEY_FILE_PASS ) ) { fprintf ( out , " " , ' ' + psc -> psc_key_file_pass . password_format , psc -> psc_key_file_pass . password_data ) ; } fclose ( out ) ; return AUTHME_ERR_OK ; }
Save the file back to the user's directory - really for use by
 GUI on Windows
Save the file back to the user ' s directory - really for use by GUI on Windows
/* Default output */ /* The password for the key file if it exists */