summaryrefslogtreecommitdiffabout
path: root/lib/libeclat.h
blob: 5f37cc900849ca97ae99003a95c5fdb553e933a3 (plain)
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/* This file is part of Eclat.
   Copyright (C) 2012 Sergey Poznyakoff.
 
   Eclat 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, or (at your option)
   any later version.
 
   Eclat 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 Eclat.  If not, see <http://www.gnu.org/licenses/>. */

#include <stddef.h>
#include <expat.h>
#include "grecs.h"

extern const char *program_name;

struct debug_category {
	const char *name;
	size_t length;
	int level;
};

extern struct debug_category debug_category[];
#define LIBECLAT_DBG_MAX 64

#define debug_level(cat) ((cat >= 0 && cat < LIBECLAT_DBG_MAX) ?	\
			   debug_category[cat].level : 0)
#define debug(cat, lev, s)					\
	do {							\
		if (debug_level(cat) >= (lev))			\
			debug_printf s;				\
	} while(0)

void set_program_name(const char *arg);

void die(int status, const char *fmt, ...);
void vdiag(grecs_locus_t const *locus, const char *qual, const char *fmt,
	   va_list ap);
void diag(grecs_locus_t const *locus, const char *qual, const char *fmt, ...);
void err(const char *fmt, ...);
void warn(const char *fmt, ...);
void debug_printf(const char *fmt, ...);

int parse_debug_level(const char *arg);
int debug_register(char *name);


void hmac_sha1(const void *text, size_t textlen,
	       const void *key, size_t keylen,
	       void *digest);
void urlencode(const char *input, size_t len,
	       char **poutput, size_t *poutlen);

void eclat_base64_encode(const unsigned char *input, size_t input_len,
			 unsigned char **output, size_t *output_len);
int eclat_base64_decode(const unsigned char *input, size_t input_len,
			unsigned char **output, size_t *output_len);


struct ec2_param {
	char *name;
	char *value;
};

#define EC2_API_VERSION "2012-08-15"

#define EC2_QF_HTTPS 0x01
#define EC2_QF_POST  0x02

struct ec2_query {
	int flags;       /* Composed from EC2_QF_* bits */
	char *endpoint;  /* endpoint  */
	char *uri;       /* URI without parameters */
	struct grecs_symtab *params; /* Query parameters */
	char *signature;
	unsigned long ttl; /* Time-to-live in seconds */
};

struct ec2_query *eclat_query_create(int flags, const char *endpoint,
				     const char *uri);
void eclat_query_free(struct ec2_query *);

int eclat_query_signature(struct ec2_query *req, char *secret);

char *eclat_query_to_url(struct ec2_query *req, char **post_params);

void eclat_query_encode(struct ec2_query *q);

typedef struct eclat_partial_tree *eclat_partial_tree_t;

eclat_partial_tree_t eclat_partial_tree_create(void);
void eclat_partial_tree_destroy(eclat_partial_tree_t);
struct grecs_node *eclat_partial_tree_finish(eclat_partial_tree_t);
void eclat_partial_tree_data_handler(void *data, const XML_Char *s, int len);
void eclat_partial_tree_start_handler(void *data, const XML_Char *name,
				      const XML_Char **atts);
void eclat_partial_tree_end_handler(void *data, const XML_Char *name);



Return to:

Send suggestions and report system problems to the System administrator.