1
by Matt Kraai
Import upstream version 0.6.3 |
1 |
/*
|
2 |
cdcd - Command Driven CD player
|
|
3 |
Copyright (C) 1998-99 Tony Arcieri
|
|
1.1.1
by Tomas Guemes
Import upstream version 0.6.5 |
4 |
Copyright (C) 2001, 2002, 2003 Fabrice Bauzac
|
1
by Matt Kraai
Import upstream version 0.6.3 |
5 |
|
6 |
This program is free software; you can redistribute it and/or modify
|
|
7 |
it under the terms of the GNU General Public License as published by
|
|
8 |
the Free Software Foundation; either version 2 of the License, or
|
|
9 |
(at your option) any later version.
|
|
10 |
||
11 |
This program is distributed in the hope that it will be useful,
|
|
12 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14 |
GNU General Public License for more details.
|
|
15 |
||
16 |
You should have received a copy of the GNU General Public License
|
|
17 |
along with this program; if not, write to the Free Software
|
|
18 |
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
19 |
*/
|
|
20 |
||
21 |
#include "cmdline.h" |
|
22 |
#include "cmd_access.h" |
|
23 |
#include "str.h" |
|
24 |
#include "rlhist.h" |
|
25 |
||
26 |
Execfunc cmd_access_remote, cmd_access_local, cmd_access_proxy, |
|
27 |
cmd_access_display, cmd_access_help, cmd_access_display, cmd_access_quit, |
|
28 |
cmd_access_cdcd; |
|
29 |
||
30 |
struct Command access_cmds[] = { |
|
1.1.1
by Tomas Guemes
Import upstream version 0.6.5 |
31 |
ALIAS ("?", "help"), |
32 |
{"help", 0, "That's a stupid joke.", cmd_access_help, NULL, 0}, |
|
33 |
{"display", "", "Display the current access method.", |
|
34 |
cmd_access_display, NULL, 1}, |
|
35 |
{"remote", "", "Set the access method to REMOTE.", |
|
36 |
cmd_access_remote, NULL, 1}, |
|
37 |
{"local", "", "Set the access method to LOCAL.", |
|
38 |
cmd_access_local, NULL, 1}, |
|
39 |
{"proxy", "[ URL | \"off\" ]", "Sets the proxy to URL, or turn it off.", |
|
40 |
cmd_access_proxy, NULL, 1}, |
|
41 |
{"quit", "", "Quit cdcd.", cmd_access_quit, NULL, 0}, |
|
42 |
ALIAS ("exit", "quit"), |
|
43 |
{"..", "", "Return to the main cdcd prompt.", cmd_access_cdcd, NULL, 0}, |
|
44 |
{0, 0, 0, 0, 0, 0} |
|
1
by Matt Kraai
Import upstream version 0.6.3 |
45 |
};
|
46 |
||
47 |
int
|
|
48 |
cmd_access_local (char **argv) |
|
49 |
{
|
|
50 |
struct cddb_conf conf; |
|
51 |
struct cddb_serverlist list; |
|
52 |
struct cddb_server proxy; |
|
53 |
||
1.1.1
by Tomas Guemes
Import upstream version 0.6.5 |
54 |
if (argv[1]) |
55 |
{
|
|
56 |
puts ("Too many arguments"); |
|
57 |
return 0; |
|
58 |
}
|
|
59 |
||
1
by Matt Kraai
Import upstream version 0.6.3 |
60 |
cddb_read_serverlist (&conf, &list, &proxy); |
61 |
conf.conf_access = CDDB_ACCESS_LOCAL; |
|
62 |
cddb_write_serverlist (conf, list, proxy); |
|
63 |
||
64 |
return 0; |
|
65 |
}
|
|
66 |
||
67 |
int
|
|
68 |
cmd_access_remote (char **argv) |
|
69 |
{
|
|
70 |
struct cddb_conf conf; |
|
71 |
struct cddb_serverlist list; |
|
72 |
struct cddb_server proxy; |
|
73 |
||
1.1.1
by Tomas Guemes
Import upstream version 0.6.5 |
74 |
if (argv[1]) |
75 |
{
|
|
76 |
puts ("Too many arguments"); |
|
77 |
return 0; |
|
78 |
}
|
|
79 |
||
1
by Matt Kraai
Import upstream version 0.6.3 |
80 |
cddb_read_serverlist (&conf, &list, &proxy); |
81 |
conf.conf_access = CDDB_ACCESS_REMOTE; |
|
82 |
cddb_write_serverlist (conf, list, proxy); |
|
83 |
||
84 |
return 0; |
|
85 |
}
|
|
86 |
||
87 |
int
|
|
88 |
cmd_access_proxy (char **argv) |
|
89 |
{
|
|
90 |
struct cddb_conf conf; |
|
91 |
struct cddb_serverlist list; |
|
92 |
struct cddb_server proxy; |
|
93 |
struct cddb_host host; |
|
94 |
||
1.1.1
by Tomas Guemes
Import upstream version 0.6.5 |
95 |
if (!argv[1] || argv[2]) |
96 |
{
|
|
97 |
puts ("You must supply one argument."); |
|
98 |
return 0; |
|
99 |
}
|
|
1
by Matt Kraai
Import upstream version 0.6.3 |
100 |
|
101 |
cddb_read_serverlist (&conf, &list, &proxy); |
|
102 |
||
1.1.1
by Tomas Guemes
Import upstream version 0.6.5 |
103 |
if (!strcasecmp (argv[1], "off")) |
1
by Matt Kraai
Import upstream version 0.6.3 |
104 |
conf.conf_proxy = CDDB_PROXY_DISABLED; |
1.1.1
by Tomas Guemes
Import upstream version 0.6.5 |
105 |
else
|
106 |
{
|
|
107 |
cddb_process_url (&host, argv[1]); |
|
108 |
conf.conf_proxy = CDDB_PROXY_ENABLED; |
|
109 |
}
|
|
1
by Matt Kraai
Import upstream version 0.6.3 |
110 |
|
111 |
cddb_write_serverlist (conf, list, host.host_server); |
|
112 |
||
113 |
return 0; |
|
114 |
}
|
|
115 |
||
116 |
int
|
|
117 |
cmd_access_help (char **argv) |
|
118 |
{
|
|
119 |
cmdhelp (access_cmds, argv, 0); |
|
120 |
return 0; |
|
121 |
}
|
|
122 |
||
123 |
int
|
|
124 |
cmd_access_quit (char **argv) |
|
125 |
{
|
|
126 |
return XRET_QUIT; |
|
127 |
}
|
|
128 |
||
129 |
int
|
|
130 |
cmd_access_cdcd (char **argv) |
|
131 |
{
|
|
132 |
return XRET_BACK; |
|
133 |
}
|
|
134 |
||
135 |
int
|
|
136 |
cmd_access_display (char **argv) |
|
137 |
{
|
|
138 |
struct cddb_conf conf; |
|
139 |
struct cddb_serverlist list; |
|
140 |
struct cddb_server proxy; |
|
141 |
||
142 |
cddb_read_serverlist (&conf, &list, &proxy); |
|
143 |
||
144 |
printf ("cddb access is set to %s.\n", |
|
1.1.1
by Tomas Guemes
Import upstream version 0.6.5 |
145 |
conf.conf_access ? "remote" : "local"); |
1
by Matt Kraai
Import upstream version 0.6.3 |
146 |
if (conf.conf_proxy == CDDB_PROXY_ENABLED) |
147 |
printf ("http proxy is enabled and set to http://%s:%d/.\n", |
|
148 |
proxy.server_name, proxy.server_port); |
|
149 |
else
|
|
150 |
puts ("http proxy is disabled."); |
|
151 |
||
152 |
return 0; |
|
153 |
}
|
|
154 |
||
155 |
char * |
|
156 |
access_command_matcher (const char *text, int state) |
|
157 |
{
|
|
158 |
return command_matcher (access_cmds, text, state); |
|
159 |
}
|
|
160 |
||
161 |
int
|
|
162 |
cmd_access_mainloop () |
|
163 |
{
|
|
1.1.1
by Tomas Guemes
Import upstream version 0.6.5 |
164 |
return cmd_mainloop (access_command_matcher, "cdcd/access> ", access_cmds); |
1
by Matt Kraai
Import upstream version 0.6.3 |
165 |
}
|
166 |
||
167 |
void
|
|
168 |
init_cmd_access () |
|
169 |
{
|
|
170 |
sort_commands (access_cmds); |
|
171 |
}
|