summaryrefslogtreecommitdiff
path: root/utils/wpseditor/libwps/src/proxy.c
diff options
context:
space:
mode:
authorFrank Gevaerts <frank@gevaerts.be>2008-08-29 21:08:38 +0000
committerFrank Gevaerts <frank@gevaerts.be>2008-08-29 21:08:38 +0000
commit5d22e3cbdd251819a4d2d07b9a12994d5aef778d (patch)
tree4c6a81187ccf065a5f296a903b9f7da88503e403 /utils/wpseditor/libwps/src/proxy.c
parentcc31b1fbdae455f975b69dd6bffc23d8bd021566 (diff)
downloadrockbox-5d22e3cbdd251819a4d2d07b9a12994d5aef778d.zip
rockbox-5d22e3cbdd251819a4d2d07b9a12994d5aef778d.tar.gz
rockbox-5d22e3cbdd251819a4d2d07b9a12994d5aef778d.tar.bz2
rockbox-5d22e3cbdd251819a4d2d07b9a12994d5aef778d.tar.xz
Add wpseditor, the Google Summer of Code 2008 project of Rostislav Chekan. Closes FS#9327
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18362 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'utils/wpseditor/libwps/src/proxy.c')
-rw-r--r--utils/wpseditor/libwps/src/proxy.c132
1 files changed, 132 insertions, 0 deletions
diff --git a/utils/wpseditor/libwps/src/proxy.c b/utils/wpseditor/libwps/src/proxy.c
new file mode 100644
index 0000000..3a3b8ce
--- /dev/null
+++ b/utils/wpseditor/libwps/src/proxy.c
@@ -0,0 +1,132 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include "dummies.h"
+#include "proxy.h"
+#include "api.h"
+#include "gwps.h"
+#include "gwps-common.h"
+#include <string.h>
+
+struct screen screens[NB_SCREENS];
+struct wps_data wpsdata;
+struct gui_wps gwps;
+struct mp3entry id3;
+struct mp3entry nid3;
+
+extern void test_api(struct proxy_api *api);
+
+bool debug_wps = true;
+int wps_verbose_level = 0;
+int errno_;
+pfdebugf dbgf = 0;
+
+static char pluginbuf[PLUGIN_BUFFER_SIZE];
+
+const char* get_model_name(){
+#ifdef TARGET_MODEL
+ return TARGET_MODEL;
+#else
+ return "unknown";
+#endif
+}
+
+int read_line(int fd, char* buffer, int buffer_size)
+{
+ int count = 0;
+ int num_read = 0;
+
+ errno_ = 0;
+
+ while (count < buffer_size)
+ {
+ unsigned char c;
+
+ if (1 != read(fd, &c, 1))
+ break;
+
+ num_read++;
+
+ if ( c == '\n' )
+ break;
+
+ if ( c == '\r' )
+ continue;
+
+ buffer[count++] = c;
+ }
+
+ buffer[MIN(count, buffer_size - 1)] = 0;
+
+ return errno_ ? -1 : num_read;
+}
+
+void* plugin_get_buffer(size_t *buffer_size)
+{
+ *buffer_size = PLUGIN_BUFFER_SIZE;
+ return pluginbuf;
+}
+
+int checkwps(const char *filename, int verbose){
+ int res;
+ int fd;
+
+ struct wps_data wps;
+ wps_verbose_level = verbose;
+
+ fd = open(filename, O_RDONLY);
+ if (fd < 0) {
+ DEBUGF1("Failed to open %s\n",filename);
+ return 2;
+ }
+ close(fd);
+
+ res = wps_data_load(&wps, &screens[0], filename, true);
+
+ if (!res) {
+ DEBUGF1("WPS parsing failure\n");
+ return 3;
+ }
+
+ DEBUGF1("WPS parsed OK\n");
+ return 0;
+}
+
+int wps_init(const char* filename,struct proxy_api *api, bool isfile){
+ int res;
+ if (!api)
+ return 4;
+ dummies_init();
+ test_api(api);
+ set_api(api);
+ wps_data_init(&wpsdata);
+ wps_verbose_level = api->verbose;
+ res = wps_data_load(&wpsdata, &screens[0], filename, isfile);
+ if (!res)
+ {
+ DEBUGF1("ERR: WPS parsing failure\n");
+ return 3;
+ }
+ DEBUGF1("WPS parsed OK\n");
+ DEBUGF1("\n-------------------------------------------------\n");
+ wps_state.paused = true;
+ gwps.data = &wpsdata;
+ gwps.display = &screens[0];
+ gwps.state = &wps_state;
+ gwps.state->id3 = &id3;
+ gwps.state->nid3 = &nid3;
+ gui_wps[0] = gwps;
+ return res;
+}
+
+int wps_display(){
+ DEBUGF3("wps_display(): begin\n");
+ int res = gui_wps_display();
+ DEBUGF3("\nWPS %sdisplayed\n", (res ? "" : "not "));
+ return res;
+}
+int wps_refresh(){
+ DEBUGF3("-----------------<wps_refresh(): begin>-----------------\n");
+ int res = gui_wps_refresh(&gwps, 0, WPS_REFRESH_ALL);
+ DEBUGF3("\nWPS %srefreshed\n", (res ? "" : "not "));
+ return res;
+}