Permalink
Browse files

adding ini settings for cache_location and settings_location

  • Loading branch information...
1 parent 8352d04 commit d77043162fa7a27aa6e1298ec8d48c62b9025be6 @vilhelmk committed Sep 22, 2011
Showing with 21 additions and 3 deletions.
  1. +4 −0 README.md
  2. +17 −3 spotify.c
View
@@ -16,6 +16,10 @@
## Usage
+ // These two lines are only required if you want to use non-default paths.
+ ini_set("spotify.cache_location", "cache_location/");
+ ini_set("spotify.settings_location", "settings_location/");
+
$spotify = new Spotify("/path/to/key.file", "username", "password");
$coolTrack = $spotify->getTrackByURI('spotify:track:6JEK0CvvjDjjMUBFoXShNZ');
View
@@ -65,8 +65,8 @@ PHP_METHOD(Spotify, __construct)
memset(&config, 0, sizeof(config));
config.api_version = SPOTIFY_API_VERSION;
- config.cache_location = "tmp";
- config.settings_location = "tmp";
+ config.cache_location = INI_STR("spotify.cache_location");
+ config.settings_location = INI_STR("spotify.settings_location");
config.user_agent = "libspotify-php";
key_filename = Z_STRVAL_P(z_key);
@@ -382,8 +382,15 @@ zend_object_value spotify_create_handler(zend_class_entry *type TSRMLS_DC)
return retval;
}
+PHP_INI_BEGIN()
+PHP_INI_ENTRY("spotify.cache_location", "spotify_cache/", PHP_INI_ALL, NULL)
+PHP_INI_ENTRY("spotify.settings_location", "spotify_settings/", PHP_INI_ALL, NULL)
+PHP_INI_END()
+
PHP_MINIT_FUNCTION(spotify)
{
+ REGISTER_INI_ENTRIES();
+
zend_class_entry ce;
INIT_CLASS_ENTRY(ce, "Spotify", spotify_methods);
spotify_ce = zend_register_internal_class(&ce TSRMLS_CC);
@@ -400,14 +407,21 @@ PHP_MINIT_FUNCTION(spotify)
return SUCCESS;
}
+PHP_MSHUTDOWN_FUNCTION(spotify)
+{
+ UNREGISTER_INI_ENTRIES();
+
+ return SUCCESS;
+}
+
zend_module_entry spotify_module_entry = {
#if ZEND_MODULE_API_NO >= 20010901
STANDARD_MODULE_HEADER,
#endif
PHP_SPOTIFY_EXTNAME,
NULL, /* Functions */
PHP_MINIT(spotify), /* MINIT */
- NULL, /* MSHUTDOWN */
+ PHP_MSHUTDOWN(spotify), /* MSHUTDOWN */
NULL, /* RINIT */
NULL, /* RSHUTDOWN */
NULL, /* MINFO */

0 comments on commit d770431

Please sign in to comment.