summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar waker <wakeroid@gmail.com>2013-08-18 16:47:43 +0200
committerGravatar waker <wakeroid@gmail.com>2013-08-18 16:47:43 +0200
commit4b3d9b3dbf50cf65b690099047b6f0f8cbb380d2 (patch)
tree82d5158eac8bf97778fa71943d480a63e568db67
parentb81070152bb7a13c50a936ed9b1cf3d734583b2f (diff)
moved parser into separate lib
-rw-r--r--Makefile.am2
-rw-r--r--plugins/gtkui/Makefile.am2
-rw-r--r--plugins/gtkui/callbacks.c2
-rw-r--r--plugins/gtkui/ctmapping.c2
-rw-r--r--plugins/gtkui/gtkui.c2
-rw-r--r--plugins/gtkui/hotkeys.c2
-rw-r--r--plugins/gtkui/mainplaylist.c2
-rw-r--r--plugins/gtkui/parser.c107
-rw-r--r--plugins/gtkui/parser.h39
-rw-r--r--plugins/gtkui/plcommon.c2
-rw-r--r--plugins/gtkui/pluginconf.c2
-rw-r--r--plugins/gtkui/widgets.c2
-rw-r--r--plugins/gtkui/widgets.h3
-rw-r--r--plugins/hotkeys/Makefile.am2
-rw-r--r--plugins/hotkeys/hotkeys.c2
-rw-r--r--plugins/hotkeys/parser.c107
-rw-r--r--plugins/hotkeys/parser.h39
-rw-r--r--plugins/libparser/parser.c (renamed from parser.c)0
-rw-r--r--plugins/libparser/parser.h (renamed from parser.h)0
-rw-r--r--po/deadbeef.pot2
-rw-r--r--streamer.c2
21 files changed, 17 insertions, 306 deletions
diff --git a/Makefile.am b/Makefile.am
index 8640bcc7..8e4a6bf3 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -39,7 +39,7 @@ deadbeef_SOURCES =\
replaygain.c replaygain.h\
fft.c fft.h\
handler.c handler.h\
- parser.c parser.h
+ plugins/libparser/parser.c plugins/libparser/parser.h
# ConvertUTF/ConvertUTF.c ConvertUTF/ConvertUTF.h
diff --git a/plugins/gtkui/Makefile.am b/plugins/gtkui/Makefile.am
index d6de80e8..d59ad784 100644
--- a/plugins/gtkui/Makefile.am
+++ b/plugins/gtkui/Makefile.am
@@ -22,7 +22,7 @@ GTKUI_SOURCES = gtkui.c gtkui.h\
search.c search.h\
fileman.c\
pluginconf.c\
- parser.c parser.h\
+ ../libparser/parser.c ../libparser/parser.h\
ddbtabstrip.c ddbtabstrip.h\
ddbvolumebar.c ddbvolumebar.h\
trkproperties.c trkproperties.h\
diff --git a/plugins/gtkui/callbacks.c b/plugins/gtkui/callbacks.c
index 3bb0fe2c..d65e26b7 100644
--- a/plugins/gtkui/callbacks.c
+++ b/plugins/gtkui/callbacks.c
@@ -41,7 +41,7 @@
#include "search.h"
#include "progress.h"
#include "gtkui.h"
-#include "parser.h"
+#include "../libparser/parser.h"
#include "drawing.h"
#include "eq.h"
#include "wingeom.h"
diff --git a/plugins/gtkui/ctmapping.c b/plugins/gtkui/ctmapping.c
index 4bf3bb95..c486805b 100644
--- a/plugins/gtkui/ctmapping.c
+++ b/plugins/gtkui/ctmapping.c
@@ -33,7 +33,7 @@
#include "support.h"
#include "interface.h"
#include "callbacks.h"
-#include "parser.h"
+#include "../libparser/parser.h"
#include "ctmapping.h"
static GtkWidget *ctmapping_dlg;
diff --git a/plugins/gtkui/gtkui.c b/plugins/gtkui/gtkui.c
index 16e7c47d..328181d0 100644
--- a/plugins/gtkui/gtkui.c
+++ b/plugins/gtkui/gtkui.c
@@ -38,7 +38,7 @@
#include "interface.h"
#include "callbacks.h"
#include "support.h"
-#include "parser.h"
+#include "../libparser/parser.h"
#include "drawing.h"
#include "trkproperties.h"
#include "../artwork/artwork.h"
diff --git a/plugins/gtkui/hotkeys.c b/plugins/gtkui/hotkeys.c
index 3556ed35..6fa28994 100644
--- a/plugins/gtkui/hotkeys.c
+++ b/plugins/gtkui/hotkeys.c
@@ -54,7 +54,7 @@ typedef struct
#include "../../gettext.h"
#include "support.h"
#include "gtkui.h"
-#include "parser.h"
+#include "../libparser/parser.h"
#include "../hotkeys/hotkeys.h"
#include <X11/Xlib.h> // only for the KeySym type
diff --git a/plugins/gtkui/mainplaylist.c b/plugins/gtkui/mainplaylist.c
index 3dfb8005..e093cee6 100644
--- a/plugins/gtkui/mainplaylist.c
+++ b/plugins/gtkui/mainplaylist.c
@@ -22,7 +22,7 @@
#include <stdlib.h>
#include <string.h>
#include "../../gettext.h"
-#include "parser.h"
+#include "../libparser/parser.h"
#include "gtkui.h"
#include "ddblistview.h"
#include "mainplaylist.h"
diff --git a/plugins/gtkui/parser.c b/plugins/gtkui/parser.c
deleted file mode 100644
index c49eeb72..00000000
--- a/plugins/gtkui/parser.c
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- DeaDBeeF - ultimate music player for GNU/Linux systems with X11
- Copyright (C) 2009-2012 Alexey Yakovenko <waker@users.sourceforge.net>
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include <stdlib.h>
-#include <assert.h>
-#include <string.h>
-#include <stdio.h>
-#include "parser.h"
-
-// very basic parser, ripped from psynth, optimized, and extended to support
-// quoted strings and extra special chars
-int parser_line;
-
-void
-parser_init (void) {
- parser_line = 1;
-}
-
-const char *
-skipws (const char *p) {
- while (*p <= ' ' && *p) {
- if (*p == '\n') {
- parser_line++;
- }
- p++;
- }
- if (!*p) {
- return NULL;
- }
- return p;
-}
-
-const char *
-gettoken (const char *p, char *tok) {
- const char *c;
- assert (p);
- assert (tok);
- int n = MAX_TOKEN-1;
- char specialchars[] = "{}();";
- if (!(p = skipws (p))) {
- return NULL;
- }
- if (*p == '"') {
- p++;
- c = p;
- while (n > 0 && *c && *c != '"') {
- if (*c == '\n') {
- parser_line++;
- }
- *tok++ = *c++;
- n--;
- }
- if (*c) {
- c++;
- }
- *tok = 0;
- return c;
- }
- if (strchr (specialchars, *p)) {
- *tok = *p;
- tok[1] = 0;
- return p+1;
- }
- c = p;
- while (n > 0 && *c > ' ' && !strchr (specialchars, *c)) {
- *tok++ = *c++;
- n--;
- }
- *tok = 0;
- return c;
-}
-
-const char *
-gettoken_warn_eof (const char *p, char *tok) {
- p = gettoken (p, tok);
- if (!p) {
- fprintf (stderr, "parser: unexpected eof at line %d", parser_line);
- }
- return p;
-}
-
-const char *
-gettoken_err_eof (const char *p, char *tok) {
- p = gettoken (p, tok);
- if (!p) {
- fprintf (stderr, "parser: unexpected eof at line %d", parser_line);
- exit (-1);
- }
- return p;
-}
-
-
diff --git a/plugins/gtkui/parser.h b/plugins/gtkui/parser.h
deleted file mode 100644
index b0f95169..00000000
--- a/plugins/gtkui/parser.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- DeaDBeeF - ultimate music player for GNU/Linux systems with X11
- Copyright (C) 2009-2012 Alexey Yakovenko <waker@users.sourceforge.net>
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-#ifndef __PARSER_H
-#define __PARSER_H
-
-#define MAX_TOKEN 256
-extern int parser_line;
-
-void
-parser_init (void);
-
-const char *
-skipws (const char *p);
-
-const char *
-gettoken (const char *p, char *tok);
-
-const char *
-gettoken_warn_eof (const char *p, char *tok);
-
-const char *
-gettoken_err_eof (const char *p, char *tok);
-
-#endif
diff --git a/plugins/gtkui/plcommon.c b/plugins/gtkui/plcommon.c
index 65734752..dcfbcf8d 100644
--- a/plugins/gtkui/plcommon.c
+++ b/plugins/gtkui/plcommon.c
@@ -28,7 +28,7 @@
#include "mainplaylist.h"
#include "support.h"
#include "interface.h"
-#include "parser.h"
+#include "../libparser/parser.h"
#include "actions.h"
#include "search.h"
#include "actionhandlers.h"
diff --git a/plugins/gtkui/pluginconf.c b/plugins/gtkui/pluginconf.c
index 33532f67..b73a9a86 100644
--- a/plugins/gtkui/pluginconf.c
+++ b/plugins/gtkui/pluginconf.c
@@ -28,7 +28,7 @@
#include "../../gettext.h"
#include "../../deadbeef.h"
#include "gtkui.h"
-#include "parser.h"
+#include "../libparser/parser.h"
#include "support.h"
#include "pluginconf.h"
diff --git a/plugins/gtkui/widgets.c b/plugins/gtkui/widgets.c
index 894ee0c6..364c5c58 100644
--- a/plugins/gtkui/widgets.c
+++ b/plugins/gtkui/widgets.c
@@ -27,7 +27,7 @@
#include "ddblistview.h"
#include "mainplaylist.h"
#include "../../gettext.h"
-#include "parser.h"
+#include "../libparser/parser.h"
#include "trkproperties.h"
#include "coverart.h"
//#define USE_OPENGL 1
diff --git a/plugins/gtkui/widgets.h b/plugins/gtkui/widgets.h
index d0672ff4..ac26d071 100644
--- a/plugins/gtkui/widgets.h
+++ b/plugins/gtkui/widgets.h
@@ -21,6 +21,9 @@
#include "gtkui_api.h"
+// widget config string must look like that:
+// type key1=value1 key2=value2... { child widgets }
+
void
w_init (void);
diff --git a/plugins/hotkeys/Makefile.am b/plugins/hotkeys/Makefile.am
index 8b89bfe6..b9624917 100644
--- a/plugins/hotkeys/Makefile.am
+++ b/plugins/hotkeys/Makefile.am
@@ -1,7 +1,7 @@
if HAVE_HOTKEYS
hotkeysdir = $(libdir)/$(PACKAGE)
pkglib_LTLIBRARIES = hotkeys.la
-hotkeys_la_SOURCES = hotkeys.c hotkeys.h parser.c parser.h actionhandlers.c actionhandlers.h
+hotkeys_la_SOURCES = hotkeys.c hotkeys.h ../libparser/parser.c ../libparser/parser.h actionhandlers.c actionhandlers.h
hotkeys_la_LDFLAGS = -module
EXTRA_hotkeys_la_SOURCES = keysyms.inc
diff --git a/plugins/hotkeys/hotkeys.c b/plugins/hotkeys/hotkeys.c
index a7a1096c..9450e36c 100644
--- a/plugins/hotkeys/hotkeys.c
+++ b/plugins/hotkeys/hotkeys.c
@@ -26,7 +26,7 @@
#include <sys/prctl.h>
#endif
-#include "parser.h"
+#include "../libparser/parser.h"
#include "hotkeys.h"
#include "../../deadbeef.h"
#include "actionhandlers.h"
diff --git a/plugins/hotkeys/parser.c b/plugins/hotkeys/parser.c
deleted file mode 100644
index c49eeb72..00000000
--- a/plugins/hotkeys/parser.c
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- DeaDBeeF - ultimate music player for GNU/Linux systems with X11
- Copyright (C) 2009-2012 Alexey Yakovenko <waker@users.sourceforge.net>
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include <stdlib.h>
-#include <assert.h>
-#include <string.h>
-#include <stdio.h>
-#include "parser.h"
-
-// very basic parser, ripped from psynth, optimized, and extended to support
-// quoted strings and extra special chars
-int parser_line;
-
-void
-parser_init (void) {
- parser_line = 1;
-}
-
-const char *
-skipws (const char *p) {
- while (*p <= ' ' && *p) {
- if (*p == '\n') {
- parser_line++;
- }
- p++;
- }
- if (!*p) {
- return NULL;
- }
- return p;
-}
-
-const char *
-gettoken (const char *p, char *tok) {
- const char *c;
- assert (p);
- assert (tok);
- int n = MAX_TOKEN-1;
- char specialchars[] = "{}();";
- if (!(p = skipws (p))) {
- return NULL;
- }
- if (*p == '"') {
- p++;
- c = p;
- while (n > 0 && *c && *c != '"') {
- if (*c == '\n') {
- parser_line++;
- }
- *tok++ = *c++;
- n--;
- }
- if (*c) {
- c++;
- }
- *tok = 0;
- return c;
- }
- if (strchr (specialchars, *p)) {
- *tok = *p;
- tok[1] = 0;
- return p+1;
- }
- c = p;
- while (n > 0 && *c > ' ' && !strchr (specialchars, *c)) {
- *tok++ = *c++;
- n--;
- }
- *tok = 0;
- return c;
-}
-
-const char *
-gettoken_warn_eof (const char *p, char *tok) {
- p = gettoken (p, tok);
- if (!p) {
- fprintf (stderr, "parser: unexpected eof at line %d", parser_line);
- }
- return p;
-}
-
-const char *
-gettoken_err_eof (const char *p, char *tok) {
- p = gettoken (p, tok);
- if (!p) {
- fprintf (stderr, "parser: unexpected eof at line %d", parser_line);
- exit (-1);
- }
- return p;
-}
-
-
diff --git a/plugins/hotkeys/parser.h b/plugins/hotkeys/parser.h
deleted file mode 100644
index b0f95169..00000000
--- a/plugins/hotkeys/parser.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- DeaDBeeF - ultimate music player for GNU/Linux systems with X11
- Copyright (C) 2009-2012 Alexey Yakovenko <waker@users.sourceforge.net>
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-#ifndef __PARSER_H
-#define __PARSER_H
-
-#define MAX_TOKEN 256
-extern int parser_line;
-
-void
-parser_init (void);
-
-const char *
-skipws (const char *p);
-
-const char *
-gettoken (const char *p, char *tok);
-
-const char *
-gettoken_warn_eof (const char *p, char *tok);
-
-const char *
-gettoken_err_eof (const char *p, char *tok);
-
-#endif
diff --git a/parser.c b/plugins/libparser/parser.c
index c49eeb72..c49eeb72 100644
--- a/parser.c
+++ b/plugins/libparser/parser.c
diff --git a/parser.h b/plugins/libparser/parser.h
index b0f95169..b0f95169 100644
--- a/parser.h
+++ b/plugins/libparser/parser.h
diff --git a/po/deadbeef.pot b/po/deadbeef.pot
index 2c5ea01f..3075d157 100644
--- a/po/deadbeef.pot
+++ b/po/deadbeef.pot
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2013-08-18 10:28+0200\n"
+"POT-Creation-Date: 2013-08-18 16:47+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
diff --git a/streamer.c b/streamer.c
index 143f5bbd..50ab9bfc 100644
--- a/streamer.c
+++ b/streamer.c
@@ -49,7 +49,7 @@
#include "replaygain.h"
#include "fft.h"
#include "handler.h"
-#include "parser.h"
+#include "plugins/libparser/parser.h"
//#define trace(...) { fprintf(stderr, __VA_ARGS__); }
#define trace(fmt,...)