aboutsummaryrefslogtreecommitdiffstats
path: root/plugin_xmms.c
diff options
context:
space:
mode:
authorreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>2005-05-08 04:32:45 +0000
committerreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>2005-05-08 04:32:45 +0000
commitdbf5d92605a9db10e3e3cb154d03a515c5d5c5af (patch)
tree501d5dda3ce90fe924b893e487d9ef9f0683382b /plugin_xmms.c
parenta1c471e9fb7cadb68bb182ab2e9715a0aa092386 (diff)
downloadlcd4linux-dbf5d92605a9db10e3e3cb154d03a515c5d5c5af.tar.gz
[lcd4linux @ 2005-05-08 04:32:43 by reinelt]
CodingStyle added and applied git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@547 3ae390bd-cb1e-0410-b409-cd5a39f66f1f
Diffstat (limited to 'plugin_xmms.c')
-rw-r--r--plugin_xmms.c132
1 files changed, 72 insertions, 60 deletions
diff --git a/plugin_xmms.c b/plugin_xmms.c
index 52ade96..b07919e 100644
--- a/plugin_xmms.c
+++ b/plugin_xmms.c
@@ -1,4 +1,4 @@
-/* $Id: plugin_xmms.c,v 1.13 2005/01/18 06:30:23 reinelt Exp $
+/* $Id: plugin_xmms.c,v 1.14 2005/05/08 04:32:45 reinelt Exp $
*
* XMMS-Plugin for LCD4Linux
* Copyright (C) 2003 Markus Keil <markus_keil@t-online.de>
@@ -21,6 +21,9 @@
*
*
* $Log: plugin_xmms.c,v $
+ * Revision 1.14 2005/05/08 04:32:45 reinelt
+ * CodingStyle added and applied
+ *
* Revision 1.13 2005/01/18 06:30:23 reinelt
* added (C) to all copyright statements
*
@@ -115,75 +118,84 @@
static HASH xmms;
-static int parse_xmms_info (void)
+static int parse_xmms_info(void)
{
- int age;
- FILE *xmms_stream;
- char zeile[200];
-
- /* reread every 100msec only */
- age=hash_age(&xmms, NULL);
- if (age>=0 && age<=200) return 0;
- /* Open Filestream for '/tmp/xmms-info' */
- xmms_stream = fopen("/tmp/xmms-info","r");
-
- /* Check for File */
- if( !xmms_stream ) {
- error("Error: Cannot open XMMS-Info Stream! Is XMMS started?");
- return -1;
- }
-
- /* Read Lines from the Stream */
- while(fgets(zeile,sizeof(zeile),xmms_stream)) {
- char *c, *key, *val;
- c=strchr(zeile, ':');
- if (c==NULL) continue;
- key=zeile; val=c+1;
- /* strip leading blanks from key */
- while (isspace(*key)) *key++='\0';
- /* strip trailing blanks from key */
- do *c='\0'; while (isspace(*--c));
- /* strip leading blanks from value */
- while (isspace(*val)) *val++='\0';
- /* strip trailing blanks from value */
- for (c=val; *c!='\0';c++);
- while (isspace(*--c)) *c='\0';
- hash_put (&xmms, key, val);
- }
-
- fclose(xmms_stream);
- return 0;
-
+ int age;
+ FILE *xmms_stream;
+ char zeile[200];
+
+ /* reread every 100msec only */
+ age = hash_age(&xmms, NULL);
+ if (age >= 0 && age <= 200)
+ return 0;
+ /* Open Filestream for '/tmp/xmms-info' */
+ xmms_stream = fopen("/tmp/xmms-info", "r");
+
+ /* Check for File */
+ if (!xmms_stream) {
+ error("Error: Cannot open XMMS-Info Stream! Is XMMS started?");
+ return -1;
+ }
+
+ /* Read Lines from the Stream */
+ while (fgets(zeile, sizeof(zeile), xmms_stream)) {
+ char *c, *key, *val;
+ c = strchr(zeile, ':');
+ if (c == NULL)
+ continue;
+ key = zeile;
+ val = c + 1;
+ /* strip leading blanks from key */
+ while (isspace(*key))
+ *key++ = '\0';
+ /* strip trailing blanks from key */
+ do
+ *c = '\0';
+ while (isspace(*--c));
+ /* strip leading blanks from value */
+ while (isspace(*val))
+ *val++ = '\0';
+ /* strip trailing blanks from value */
+ for (c = val; *c != '\0'; c++);
+ while (isspace(*--c))
+ *c = '\0';
+ hash_put(&xmms, key, val);
+ }
+
+ fclose(xmms_stream);
+ return 0;
+
}
-static void my_xmms (RESULT *result, RESULT *arg1)
-{
- char *key, *val;
-
- if (parse_xmms_info()<0) {
- SetResult(&result, R_STRING, "");
- return;
- }
-
- key=R2S(arg1);
- val=hash_get(&xmms, key, NULL);
- if (val==NULL) val="";
-
- SetResult(&result, R_STRING, val);
+static void my_xmms(RESULT * result, RESULT * arg1)
+{
+ char *key, *val;
+
+ if (parse_xmms_info() < 0) {
+ SetResult(&result, R_STRING, "");
+ return;
+ }
+
+ key = R2S(arg1);
+ val = hash_get(&xmms, key, NULL);
+ if (val == NULL)
+ val = "";
+
+ SetResult(&result, R_STRING, val);
}
-int plugin_init_xmms (void)
+int plugin_init_xmms(void)
{
- hash_create(&xmms);
+ hash_create(&xmms);
- /* register xmms info */
- AddFunction ("xmms", 1, my_xmms);
+ /* register xmms info */
+ AddFunction("xmms", 1, my_xmms);
- return 0;
+ return 0;
}
-void plugin_exit_xmms(void)
+void plugin_exit_xmms(void)
{
- hash_destroy(&xmms);
+ hash_destroy(&xmms);
}