diff options
Diffstat (limited to 'utils/wpseditor/libwps/src/proxy.c')
-rw-r--r-- | utils/wpseditor/libwps/src/proxy.c | 152 |
1 files changed, 0 insertions, 152 deletions
diff --git a/utils/wpseditor/libwps/src/proxy.c b/utils/wpseditor/libwps/src/proxy.c deleted file mode 100644 index 315cf971ab..0000000000 --- a/utils/wpseditor/libwps/src/proxy.c +++ /dev/null | |||
@@ -1,152 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * | ||
9 | * Copyright (C) 2007 by Rostilav Checkan | ||
10 | * $Id$ | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #include <stdio.h> | ||
23 | #include <stdlib.h> | ||
24 | #include "dummies.h" | ||
25 | #include "proxy.h" | ||
26 | #include "api.h" | ||
27 | #include "gwps.h" | ||
28 | #include "gwps-common.h" | ||
29 | #include <string.h> | ||
30 | |||
31 | struct screen screens[NB_SCREENS]; | ||
32 | struct wps_data wpsdata; | ||
33 | struct gui_wps gwps; | ||
34 | struct mp3entry id3; | ||
35 | struct mp3entry nid3; | ||
36 | |||
37 | extern void test_api(struct proxy_api *api); | ||
38 | |||
39 | bool debug_wps = true; | ||
40 | int wps_verbose_level = 0; | ||
41 | int errno_; | ||
42 | pfdebugf dbgf = 0; | ||
43 | |||
44 | static char pluginbuf[PLUGIN_BUFFER_SIZE]; | ||
45 | |||
46 | const char* get_model_name(){ | ||
47 | #ifdef MODEL_NAME | ||
48 | return MODEL_NAME; | ||
49 | #else | ||
50 | return "unknown"; | ||
51 | #endif | ||
52 | } | ||
53 | |||
54 | int read_line(int fd, char* buffer, int buffer_size) | ||
55 | { | ||
56 | int count = 0; | ||
57 | int num_read = 0; | ||
58 | |||
59 | errno_ = 0; | ||
60 | |||
61 | while (count < buffer_size) | ||
62 | { | ||
63 | unsigned char c; | ||
64 | |||
65 | if (1 != read(fd, &c, 1)) | ||
66 | break; | ||
67 | |||
68 | num_read++; | ||
69 | |||
70 | if ( c == '\n' ) | ||
71 | break; | ||
72 | |||
73 | if ( c == '\r' ) | ||
74 | continue; | ||
75 | |||
76 | buffer[count++] = c; | ||
77 | } | ||
78 | |||
79 | buffer[MIN(count, buffer_size - 1)] = 0; | ||
80 | |||
81 | return errno_ ? -1 : num_read; | ||
82 | } | ||
83 | |||
84 | void* plugin_get_buffer(size_t *buffer_size) | ||
85 | { | ||
86 | *buffer_size = PLUGIN_BUFFER_SIZE; | ||
87 | return pluginbuf; | ||
88 | } | ||
89 | |||
90 | int checkwps(const char *filename, int verbose){ | ||
91 | int res; | ||
92 | int fd; | ||
93 | |||
94 | struct wps_data wps; | ||
95 | wps_verbose_level = verbose; | ||
96 | |||
97 | fd = open(filename, O_RDONLY); | ||
98 | if (fd < 0) { | ||
99 | DEBUGF1("Failed to open %s\n",filename); | ||
100 | return 2; | ||
101 | } | ||
102 | close(fd); | ||
103 | |||
104 | res = wps_data_load(&wps, &screens[0], filename, true); | ||
105 | |||
106 | if (!res) { | ||
107 | DEBUGF1("WPS parsing failure\n"); | ||
108 | return 3; | ||
109 | } | ||
110 | |||
111 | DEBUGF1("WPS parsed OK\n"); | ||
112 | return 0; | ||
113 | } | ||
114 | |||
115 | int wps_init(const char* filename,struct proxy_api *api, bool isfile){ | ||
116 | int res; | ||
117 | if (!api) | ||
118 | return 4; | ||
119 | dummies_init(); | ||
120 | test_api(api); | ||
121 | set_api(api); | ||
122 | wps_data_init(&wpsdata); | ||
123 | wps_verbose_level = api->verbose; | ||
124 | res = wps_data_load(&wpsdata, &screens[0], filename, isfile); | ||
125 | if (!res) | ||
126 | { | ||
127 | DEBUGF1("ERR: WPS parsing failure\n"); | ||
128 | } else | ||
129 | DEBUGF1("WPS parsed OK\n"); | ||
130 | DEBUGF1("\n-------------------------------------------------\n"); | ||
131 | wps_state.paused = true; | ||
132 | gwps.data = &wpsdata; | ||
133 | gwps.display = &screens[0]; | ||
134 | gwps.state = &wps_state; | ||
135 | gwps.state->id3 = &id3; | ||
136 | gwps.state->nid3 = &nid3; | ||
137 | gui_wps[0] = gwps; | ||
138 | return (res?res:3); | ||
139 | } | ||
140 | |||
141 | int wps_display(){ | ||
142 | DEBUGF3("wps_display(): begin\n"); | ||
143 | int res = gui_wps_display(); | ||
144 | DEBUGF3("\nWPS %sdisplayed\n", (res ? "" : "not ")); | ||
145 | return res; | ||
146 | } | ||
147 | int wps_refresh(){ | ||
148 | DEBUGF3("-----------------<wps_refresh(): begin>-----------------\n"); | ||
149 | int res = gui_wps_refresh(&gwps, 0, WPS_REFRESH_ALL); | ||
150 | DEBUGF3("\nWPS %srefreshed\n", (res ? "" : "not ")); | ||
151 | return res; | ||
152 | } | ||