-
Notifications
You must be signed in to change notification settings - Fork 0
/
parse.h
87 lines (73 loc) · 1.93 KB
/
parse.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/*
* parse.h - Definitions for parsing the input file
* Copyright (C) 2017 Simon Kaufmann, HeKa
*
* This file is part of Bitmap Drawing.
*
* Bitmap Drawing is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Bitmap Drawing is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PARSE_H
#define PARSE_H
#include <stdint.h>
#include "linked_list.h"
#define PARSE_SUCCESS 0
#define PARSE_ERR_OUT_OF_MEM 1
#define PARSE_ERR_INDEX_OUT_OF_BOUND 2
#define PARSE_ERR_LIST 3
#define PARSE_ERR_PASSED_NULL_POINTER 4
#define PARSE_ERR_PROPERTY_NAME_TOO_LONG 5
#define PARSE_ERR_INVALID_INPUT 6
#define PARSE_ERR_EOF 7
#define PARSE_MAX_PROPERTY_NAME_LENGTH 20
#define PARSE_MAX_VALUE_STRING_LENGTH 400
typedef uint32_t id_t;
typedef enum _Shape_ {SH_RECTANGLE, SH_CIRCLE, SH_TRIANGLE} Shape;
typedef struct _Rectangle_ {
id_t id;
int color;
int x;
int y;
int width;
int height;
} Rectangle;
typedef struct _Circle_ {
id_t id;
int color;
int x;
int y;
int radius;
} Circle;
typedef struct _Triangle_ {
id_t id;
int color;
int ax;
int ay;
int bx;
int by;
int cx;
int cy;
} Triangle;
/*
* element contains information about which object it is and the union
* with the data itself
*/
typedef struct _Command_ {
Shape shape;
id_t id;
void *obj;
} Command;
int parse_line(char *line, Command **com);
int parse_file(char *input_path, LinkedList **list);
void parse_delete_command_list(LinkedList *command_list);
#endif