Reformat everything
[nci.git] / util.h
blob13045ee013af21055b1a7141d0218586312fc41f
1 #define BUCKET_NUM 32
3 typedef struct {
4 /* */
5 uint_fast8_t skipped_chars;
6 yajl_handle yh;
7 } curl_to_yajl_ctx;
8 typedef struct {
9 /* */
10 char *name;
11 char *value;
12 } grading_standard_entry;
15 * Note that the map structure doesn't dup anything, yet does free
16 * everything. Once something is added as a key or value to the map,
17 * consider it freed. This is true even if the add was for a redundant
18 * key.
20 typedef struct {
21 /* */
22 char *k;
23 char **vs;
24 } entry;
25 typedef struct {
26 /* */
27 size_t es[BUCKET_NUM];
28 entry *e[BUCKET_NUM];
29 size_t num_values_per_entry;
30 } map;
31 typedef struct {
32 /* */
33 uint_fast8_t saw_id_key;
34 char **id_str;
35 uint_fast8_t saw_message_key;
36 char *error_message;
37 } ie_y_ctx;
38 typedef struct {
39 /* */
40 int idx_of_next_entry;
41 const char **field_names;
42 char *field0;
43 char **otherfields;
44 map *m;
45 unsigned int depth;
46 char *enclosing_id;
47 uint_fast8_t saw_id_key;
48 unsigned int enclosing_id_depth;
49 uint_fast8_t exhausted_enclosing_id;
50 uint_fast8_t saw_message_key;
51 char *error_message;
52 } kve_y_ctx;
54 char *
55 get_auth_token(void);
56 char *
57 get_url_base(void);
59 int
60 key_value_extract(const char *path, const char *cookiejar_path, const
61 char **field_names, char *enclosing_id, map *m);
63 int
64 make_gse_post(grading_standard_entry *cutoffs, size_t cutoffs_num, struct
65 curl_httppost **out_post);
67 int
68 make_course_post(const char *hgs, const char *aagw, int
69 disable_grading_standard, const char *start_date, const
70 char *end_date, const
71 char *gse_id, struct curl_httppost **out_post);
73 struct curl_httppost *
74 make_agroup_post(const char *name, const char *weight, const char *drop_lowest,
75 const char *drop_highest);
76 struct curl_httppost *
77 make_assignment_post(const char *name, const char *max_points, const
78 char *due_date, const char *group_id);
79 struct curl_httppost *
80 make_update_grade_post(char ***csv, size_t col, size_t rows);
82 int
83 map_add(map *m, char *k, char **vs);
85 void
86 map_clean(map *m);
88 char **
89 map_get(map *m, char *k);
91 void
92 map_get_keys(map *m, char ***out_k, size_t *out_num);
94 void
95 print_esc_0x22(const char *s);
97 int
98 read_csv(FILE *f, char ****out_csv, size_t *out_rows, size_t *out_cols);
101 send_and_id_scan(const char *uri, const char *auth_token, struct
102 curl_httppost *post, const char *method, char **id);