1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2010 Robert Bieber
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.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
27 #include "skin_scan.h"
28 #include "skin_debug.h"
30 #include "skin_parser.h"
32 /* Scanning Functions */
34 /* Simple function to advance a char* past a comment */
35 void skip_comment(char** document
)
37 for(/*NO INIT*/;**document
!= '\n' && **document
!= '\0'; (*document
)++);
38 if(**document
== '\n')
42 void skip_whitespace(char** document
)
44 for(/*NO INIT*/; **document
== ' ' || **document
== '\t'; (*document
)++);
47 char* scan_string(char** document
)
50 char* cursor
= *document
;
55 while(*cursor
!= ARGLISTSEPERATESYM
&& *cursor
!= ARGLISTCLOSESYM
&&
58 if(*cursor
== COMMENTSYM
)
60 skip_comment(&cursor
);
69 skin_error(UNEXPECTED_NEWLINE
);
77 /* Copying the string */
79 buffer
= skin_alloc_string(length
);
80 buffer
[length
] = '\0';
81 for(i
= 0; i
< length
; i
++)
86 if(*cursor
== COMMENTSYM
)
88 skip_comment(&cursor
);
101 int scan_int(char** document
)
104 char* cursor
= *document
;
110 while(isdigit(*cursor
) || *cursor
== COMMENTSYM
)
112 if(*cursor
== COMMENTSYM
)
114 skip_comment(&cursor
);
122 buffer
= skin_alloc_string(length
);
124 /* Copying to the buffer while avoiding comments */
126 buffer
[length
] = '\0';
127 for(i
= 0; i
< length
; i
++)
129 if(*cursor
== COMMENTSYM
)
131 skip_comment(&cursor
);
140 retval
= atoi(buffer
);
147 int check_viewport(char* document
)
149 if(strlen(document
) < 3)
152 if(document
[0] != TAGSYM
)
155 if(document
[1] != 'V')
158 if(document
[2] != ARGLISTOPENSYM
159 && document
[2] != 'l'
160 && document
[2] != 'i')