3 * Copyright (c) 2006 acmesystems.it - john@acmesystems.it
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA02111-1307USA
19 * Feedback, Bugs... info@acmesystems.it
30 #define TOKEN_SIZE 256
32 static unsigned char mp3_parser_tokens
[TOKEN_MAX
][TOKEN_SIZE
];
34 int mp3_parser_tokenize(unsigned char *in
){
39 tmp
= strstr(token
, " ");
42 strcpy(mp3_parser_tokens
[i
], token
);
46 strcpy(mp3_parser_tokens
[i
], token
);
49 }while((i
< TOKEN_MAX
) && (tmp
));
53 extern int state_current
;
54 void mp3_parser_incoming(unsigned char *in
, unsigned char *out
){
55 int c
= mp3_parser_tokenize(in
);
59 printf("Parsing command from frontend app -> %s --- %d tokens\n", in
, c
);
60 if((!strcmp(mp3_parser_tokens
[0], "PLAY")) && (c
== 2)){
61 state_event(MP3_EVENT_FILE
, state_new_event(mp3_parser_tokens
[1], 0));
63 } else if((!strcmp(mp3_parser_tokens
[0], "STREAM"))
65 if(!strcmp(mp3_parser_tokens
[1], "pls")){
66 state_event(MP3_EVENT_STREAM
, state_new_event(mp3_parser_tokens
[2], STREAM_PLS
));
68 } else if(!strcmp(mp3_parser_tokens
[1], "url")){
69 state_event(MP3_EVENT_STREAM
, state_new_event(mp3_parser_tokens
[2], STREAM_URL
));
72 } else if((!strcmp(mp3_parser_tokens
[0], "VOLUME"))
74 t1
= atoi(mp3_parser_tokens
[1]);
75 state_generic_event(MP3_EVENT_GENERIC_VOLUME
, t1
, NULL
);
77 } else if((!strcmp(mp3_parser_tokens
[0], "STOP"))
79 state_event(MP3_EVENT_STOP
, NULL
);
81 } else if((!strcmp(mp3_parser_tokens
[0], "STATE"))
83 state_generic_event(MP3_EVENT_GENERIC_STATE
, 0, out
);
85 } else if((!strcmp(mp3_parser_tokens
[0], "BASS"))
87 t1
= atoi(mp3_parser_tokens
[1]);
88 state_generic_event(MP3_EVENT_GENERIC_BASS
, t1
, NULL
);
93 printf("Command parsed ok.\n");
96 sprintf(out
, "ERROR\n");
97 printf("Command parsed with error.\n");
100 printf("Got command from frontend with 0 tokens.\n");
This page took 0.046615 seconds and 5 git commands to generate.