[repo.or.cz] iwhd.git branch dyn-provider created: v0.0-287-g7b312ae
by Jim Meyering
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project iwhd.git.
The branch, dyn-provider has been created
at 7b312ae175275f44da7922103c28220c85dbb55e (commit)
- Log -----------------------------------------------------------------
http://repo.or.cz/w/iwhd.git/commit/7b312ae175275f44da7922103c28220c85dbb55e
commit 7b312ae175275f44da7922103c28220c85dbb55e
Author: Jim Meyering <meyering(a)redhat.com>
Date: Thu Dec 23 22:04:41 2010 +0100
remove functions and struct members that are no longer needed
* rest.c (free_ms): Remove function and all uses.
* setup.c (delete_provider): Remove function and sole use.
* setup.h (refcnt): Remove struct member and all uses.
* state_defs.h (cleanup, refcnt): Remove struct members.
Remove all uses.
* replica.c: Remove uses of the above.
diff --git a/replica.c b/replica.c
index 1910747..266da20 100644
--- a/replica.c
+++ b/replica.c
@@ -205,7 +205,6 @@ repl_worker (void *notused ATTRIBUTE_UNUSED)
error(0,0,"bad repl type %d (url=%s) skipped",
item->type, item->path);
}
- free_ms(item->ms);
free(item->path);
free(item);
/* No atomic dec without test? Lame. */
@@ -338,7 +337,6 @@ replicate (const char *url, size_t size, const char *policy, my_state *ms)
item->server = prov;
item->size = size;
item->ms = ms;
- g_atomic_int_inc(&ms->refcnt);
pthread_mutex_lock(&queue_lock);
if (queue_tail) {
item->next = queue_tail->next;
@@ -388,7 +386,6 @@ replicate_namespace_action (const char *name, repl_t action, my_state *ms)
}
item->server = (provider_t *)value;
item->ms = ms;
- g_atomic_int_inc(&ms->refcnt);
pthread_mutex_lock(&queue_lock);
if (queue_tail) {
item->next = queue_tail->next;
diff --git a/rest.c b/rest.c
index 059d7bf..dfa84b4 100644
--- a/rest.c
+++ b/rest.c
@@ -75,44 +75,6 @@ static const char *const (reserved_name[]) = {"_default", "_new", "_policy", "_q
static const char *const (reserved_attr[]) = {"_bucket", "_date", "_etag", "_key", "_loc", "_size", NULL};
static const char *const (reserved_bucket_name[]) = {"_new", "_providers", NULL};
-void
-free_ms (my_state *ms)
-{
- if (!g_atomic_int_dec_and_test(&ms->refcnt)) {
- return;
- }
-
- if (ms->cleanup & CLEANUP_BUF_PTR) {
- free(ms->pipe.data_ptr);
- }
-
- if (ms->cleanup & CLEANUP_POST) {
- MHD_destroy_post_processor(ms->post);
- }
-
- if (ms->cleanup & CLEANUP_DICT) {
- g_hash_table_destroy(ms->dict);
- }
-
- if (ms->cleanup & CLEANUP_QUERY) {
- meta_query_stop(ms->query);
- }
-
- if (ms->cleanup & CLEANUP_TMPL) {
- free(ms->gen_ctx);
- }
-
- if (ms->cleanup & CLEANUP_URL) {
- free(ms->url);
- }
-
- if (ms->cleanup & CLEANUP_AQUERY) {
- meta_attr_stop(ms->aquery);
- }
-
- free(ms);
-}
-
static int
validate_put (struct MHD_Connection *conn)
{
@@ -203,7 +165,6 @@ simple_closer (void *ctx)
my_state *ms = ctx;
DPRINTF("%s: cleaning upn",__func__);
- free_ms(ms);
}
static void
@@ -266,7 +227,6 @@ proxy_get_cons (void *ctx, uint64_t pos, char *buf, size_t max)
pthread_join(ms->cache_th,NULL);
/* TBD: do something about cache failure? */
}
- free_ms(ms);
}
return done;
@@ -297,7 +257,6 @@ proxy_get_data (void *cctx, struct MHD_Connection *conn, const char *url,
if (!ms->url) {
return MHD_NO;
}
- ms->cleanup |= CLEANUP_URL;
my_etag = meta_has_copy(ms->bucket,ms->key,me);
if (!my_etag) {
@@ -326,7 +285,6 @@ proxy_get_data (void *cctx, struct MHD_Connection *conn, const char *url,
MHD_NO,MHD_NO);
MHD_queue_response(conn,MHD_HTTP_NOT_FOUND,resp);
MHD_destroy_response(resp);
- free_ms(ms);
return MHD_YES;
}
DPRINTF(" will fetch from %s:%un", master_host,master_port);
@@ -448,7 +406,6 @@ proxy_put_data (void *cctx, struct MHD_Connection *conn, const char *url,
}
MHD_queue_response(conn,MHD_HTTP_FORBIDDEN,resp);
MHD_destroy_response(resp);
- free_ms(ms);
return MHD_YES;
}
ms->state = MS_NORMAL;
@@ -456,7 +413,6 @@ proxy_put_data (void *cctx, struct MHD_Connection *conn, const char *url,
if (!ms->url) {
return MHD_NO;
}
- ms->cleanup |= CLEANUP_URL;
ms->size = 0;
pipe_init_shared(&ms->pipe,ms,1);
pp = pipe_init_private(&ms->pipe);
@@ -539,7 +495,6 @@ proxy_put_data (void *cctx, struct MHD_Connection *conn, const char *url,
recheck_replication(ms,NULL);
rc = MHD_HTTP_OK;
}
- free_ms(ms);
resp = MHD_create_response_from_data(0,NULL,MHD_NO,MHD_NO);
if (!resp) {
free(etag);
@@ -587,7 +542,6 @@ proxy_get_attr (void *cctx, struct MHD_Connection *conn, const char *url,
MHD_queue_response(conn,rc,resp);
MHD_destroy_response(resp);
- free_ms(ms);
return MHD_YES;
}
@@ -613,7 +567,6 @@ proxy_put_attr (void *cctx, struct MHD_Connection *conn, const char *url,
if (!ms->url) {
return MHD_NO;
}
- ms->cleanup |= CLEANUP_URL;
attrval = MHD_lookup_connection_value(conn,MHD_HEADER_KIND,
"X-redhat-value");
if (attrval) {
@@ -638,7 +591,6 @@ proxy_put_attr (void *cctx, struct MHD_Connection *conn, const char *url,
return MHD_NO;
}
((char *)ms->pipe.data_ptr)[0] = '0';
- ms->cleanup |= CLEANUP_BUF_PTR;
}
(void)strncat(ms->pipe.data_ptr,data,*data_size);
/* TBD: check return value */
@@ -657,22 +609,15 @@ proxy_put_attr (void *cctx, struct MHD_Connection *conn, const char *url,
MHD_queue_response(conn,MHD_HTTP_BAD_REQUEST,
resp);
MHD_destroy_response(resp);
- free_ms(ms);
return MHD_YES;
}
meta_set_value(ms->bucket,ms->key,ms->attr,ms->pipe.data_ptr);
- /* This might get stomped by replication. */
- if (ms->cleanup & CLEANUP_BUF_PTR) {
- free(ms->pipe.data_ptr);
- ms->cleanup &= ~CLEANUP_BUF_PTR;
- }
/*
* We should always re-replicate, because the replication
* policy might refer to this attr.
*/
DPRINTF("rereplicate (attr PUT)n");
recheck_replication(ms,NULL);
- free_ms(ms);
send_resp = 1;
}
@@ -744,7 +689,6 @@ proxy_query_func (void *ctx, uint64_t pos, char *buf, size_t max)
if (!ms->gen_ctx) {
return -1;
}
- ms->cleanup |= CLEANUP_TMPL;
len = tmpl_list_header(ms->gen_ctx);
if (!len) {
return -1;
@@ -787,7 +731,6 @@ proxy_query_func (void *ctx, uint64_t pos, char *buf, size_t max)
}
memcpy(buf,ms->gen_ctx->buf,len);
free(ms->gen_ctx);
- ms->cleanup &= ~CLEANUP_TMPL;
ms->gen_ctx = TMPL_CTX_DONE;
return len;
}
@@ -810,7 +753,6 @@ proxy_query (void *cctx, struct MHD_Connection *conn, const char *url,
ms->state = MS_NORMAL;
ms->post = MHD_create_post_processor(conn,4096,
query_iterator,ms);
- ms->cleanup |= CLEANUP_POST;
}
else if (*data_size) {
MHD_post_process(ms->post,data,*data_size);
@@ -829,7 +771,6 @@ proxy_query (void *cctx, struct MHD_Connection *conn, const char *url,
return MHD_NO;
}
((char *)ms->pipe.data_ptr)[0] = '0';
- ms->cleanup |= CLEANUP_BUF_PTR;
}
(void)strncat(ms->pipe.data_ptr,data,*data_size);
/* TBD: check return value */
@@ -840,7 +781,6 @@ proxy_query (void *cctx, struct MHD_Connection *conn, const char *url,
return MHD_NO;
}
ms->query = meta_query_new(ms->bucket,NULL,ms->pipe.data_ptr);
- ms->cleanup |= CLEANUP_QUERY;
resp = MHD_create_response_from_callback(MHD_SIZE_UNKNOWN,
65536, proxy_query_func, ms, simple_closer);
if (!resp) {
@@ -850,7 +790,6 @@ proxy_query (void *cctx, struct MHD_Connection *conn, const char *url,
}
MHD_queue_response(conn,MHD_HTTP_OK,resp);
MHD_destroy_response(resp);
- free_ms(ms);
}
return MHD_YES;
@@ -872,7 +811,6 @@ proxy_list_objs (void *cctx, struct MHD_Connection *conn, const char *url,
(void)data_size;
ms->query = meta_query_new((char *)ms->bucket,NULL,NULL);
- ms->cleanup |= CLEANUP_QUERY;
resp = MHD_create_response_from_callback(MHD_SIZE_UNKNOWN,
65536, proxy_query_func, ms, simple_closer);
@@ -925,14 +863,12 @@ proxy_delete (void *cctx, struct MHD_Connection *conn, const char *url,
resp = MHD_create_response_from_data(0,NULL,MHD_NO,MHD_NO);
if (!resp) {
- free_ms(ms);
return MHD_NO;
}
error (0, 0, "DELETE BUCKET: rc=%d", rc);
MHD_queue_response(conn,rc,resp);
MHD_destroy_response(resp);
- free_ms(ms);
return MHD_YES;
}
@@ -971,7 +907,6 @@ root_blob_generator (void *ctx, uint64_t pos, char *buf, size_t max)
if (!ms->gen_ctx) {
return -1;
}
- ms->cleanup |= CLEANUP_TMPL;
ms->gen_ctx->base = host;
len = tmpl_root_header(ms->gen_ctx,"image_warehouse",VERSION);
if (!len) {
@@ -1022,7 +957,6 @@ root_blob_generator (void *ctx, uint64_t pos, char *buf, size_t max)
}
memcpy(buf,ms->gen_ctx->buf,len);
free(ms->gen_ctx);
- ms->cleanup &= ~CLEANUP_TMPL;
ms->gen_ctx = TMPL_CTX_DONE;
return len;
}
@@ -1045,11 +979,8 @@ proxy_api_root (void *cctx, struct MHD_Connection *conn, const char *url,
ms->query = meta_query_new(NULL,"_default",NULL);
if (!ms->query) {
- free_ms(ms);
return MHD_NO;
}
- ms->cleanup |= CLEANUP_QUERY;
-
resp = MHD_create_response_from_callback(MHD_SIZE_UNKNOWN,
65536, root_blob_generator, ms, simple_closer);
if (!resp) {
@@ -1188,10 +1119,8 @@ control_api_root (void *cctx, struct MHD_Connection *conn, const char *url,
ms->url = (char *)url;
ms->dict = g_hash_table_new_full(
g_str_hash,g_str_equal,NULL,NULL);
- ms->cleanup |= CLEANUP_DICT;
ms->post = MHD_create_post_processor(conn,4096,
post_iterator,ms->dict);
- ms->cleanup |= CLEANUP_POST;
return MHD_YES;
}
@@ -1231,7 +1160,6 @@ control_api_root (void *cctx, struct MHD_Connection *conn, const char *url,
MHD_queue_response(conn,rc,resp);
MHD_destroy_response(resp);
- free_ms(ms);
return MHD_YES;
}
@@ -1256,10 +1184,8 @@ proxy_bucket_post (void *cctx, struct MHD_Connection *conn, const char *url,
ms->url = (char *)url;
ms->dict = g_hash_table_new_full(
g_str_hash,g_str_equal,NULL,NULL);
- ms->cleanup |= CLEANUP_DICT;
ms->post = MHD_create_post_processor(conn,4096,
post_iterator,ms->dict);
- ms->cleanup |= CLEANUP_POST;
}
else if (*data_size) {
MHD_post_process(ms->post,data,*data_size);
@@ -1294,7 +1220,6 @@ proxy_bucket_post (void *cctx, struct MHD_Connection *conn, const char *url,
}
MHD_queue_response(conn,rc,resp);
MHD_destroy_response(resp);
- free_ms(ms);
}
return MHD_YES;
@@ -1369,7 +1294,6 @@ parts_callback (void *ctx, uint64_t pos, char *buf, size_t max)
if (!ms->gen_ctx) {
return -1;
}
- ms->cleanup |= CLEANUP_TMPL;
ms->gen_ctx->base = host;
len = tmpl_obj_header(ms->gen_ctx,ms->bucket,ms->key);
if (!len) {
@@ -1415,7 +1339,6 @@ parts_callback (void *ctx, uint64_t pos, char *buf, size_t max)
}
memcpy(buf,ms->gen_ctx->buf,len);
free(ms->gen_ctx);
- ms->cleanup &= ~CLEANUP_TMPL;
ms->gen_ctx = TMPL_CTX_DONE;
return len;
}
@@ -1429,7 +1352,6 @@ show_parts (struct MHD_Connection *conn, my_state *ms)
if (!ms->aquery) {
return MHD_HTTP_NOT_FOUND;
}
- ms->cleanup |= CLEANUP_AQUERY;
resp = MHD_create_response_from_callback(MHD_SIZE_UNKNOWN,
65536, parts_callback, ms, simple_closer);
@@ -1464,10 +1386,8 @@ proxy_object_post (void *cctx, struct MHD_Connection *conn, const char *url,
ms->url = (char *)url;
ms->dict = g_hash_table_new_full(
g_str_hash,g_str_equal,NULL,NULL);
- ms->cleanup |= CLEANUP_DICT;
ms->post = MHD_create_post_processor(conn,4096,
post_iterator,ms->dict);
- ms->cleanup |= CLEANUP_POST;
}
else if (*data_size) {
MHD_post_process(ms->post,data,*data_size);
@@ -1511,12 +1431,10 @@ proxy_object_post (void *cctx, struct MHD_Connection *conn, const char *url,
MHD_NO,MHD_NO);
if (!resp) {
fprintf(stderr,"MHD_crfd failedn");
- free_ms(ms);
return MHD_NO;
}
MHD_queue_response(conn,rc,resp);
MHD_destroy_response(resp);
- free_ms(ms);
}
}
@@ -1544,7 +1462,6 @@ prov_list_generator (void *ctx, uint64_t pos, char *buf, size_t max)
if (!ms->gen_ctx) {
return -1;
}
- ms->cleanup |= CLEANUP_TMPL;
init_prov_iter(&ms->prov_iter);
len = tmpl_prov_header(ms->gen_ctx);
if (!len) {
@@ -1585,7 +1502,6 @@ prov_list_generator (void *ctx, uint64_t pos, char *buf, size_t max)
}
memcpy(buf,ms->gen_ctx->buf,len);
free(ms->gen_ctx);
- ms->cleanup &= ~CLEANUP_TMPL;
ms->gen_ctx = TMPL_CTX_DONE;
return len;
}
@@ -1657,10 +1573,8 @@ proxy_update_prov (void *cctx, struct MHD_Connection *conn, const char *url,
ms->url = (char *)url;
ms->dict = g_hash_table_new_full(
g_str_hash,g_str_equal,NULL,NULL);
- ms->cleanup |= CLEANUP_DICT;
ms->post = MHD_create_post_processor(conn,4096,
prov_iterator,ms->dict);
- ms->cleanup |= CLEANUP_POST;
}
else if (*data_size) {
MHD_post_process(ms->post,data,*data_size);
@@ -1681,12 +1595,10 @@ proxy_update_prov (void *cctx, struct MHD_Connection *conn, const char *url,
resp = MHD_create_response_from_data(0,NULL,MHD_NO,MHD_NO);
if (!resp) {
fprintf(stderr,"MHD_crfd failedn");
- free_ms(ms);
return MHD_NO;
}
MHD_queue_response(conn,rc,resp);
MHD_destroy_response(resp);
- free_ms(ms);
}
return MHD_YES;
@@ -1813,7 +1725,6 @@ proxy_delete_prov (void *cctx, struct MHD_Connection *conn, const char *url,
struct MHD_Response *resp
= MHD_create_response_from_data(0,NULL,MHD_NO,MHD_NO);
if (!resp) {
- free_ms(ms);
return MHD_NO;
}
@@ -1829,19 +1740,13 @@ proxy_delete_prov (void *cctx, struct MHD_Connection *conn, const char *url,
DPRINTF("PROXY DELETE PROVIDER prov=%s rc=%dn", prov_name, rc);
if (prov) {
- /* Delete for real if no one is using it.
- Otherwise, just mark it as deleted. */
- if (g_atomic_int_get (&prov->refcnt) == 0)
- delete_provider (prov);
- else
- prov->deleted = 1;
+ prov->deleted = 1;
}
free (prov_name);
MHD_queue_response(conn,rc,resp);
MHD_destroy_response(resp);
- free_ms(ms);
return MHD_YES;
}
@@ -1863,10 +1768,8 @@ proxy_add_prov (void *cctx, struct MHD_Connection *conn, const char *url,
ms->url = (char *)url;
ms->dict = g_hash_table_new_full(
g_str_hash,g_str_equal,NULL,NULL);
- ms->cleanup |= CLEANUP_DICT;
ms->post = MHD_create_post_processor(conn,4096,
prov_iterator,ms->dict);
- ms->cleanup |= CLEANUP_POST;
}
else if (*data_size) {
MHD_post_process(ms->post,data,*data_size);
@@ -1916,7 +1819,6 @@ proxy_add_prov (void *cctx, struct MHD_Connection *conn, const char *url,
}
MHD_queue_response(conn,rc,resp);
MHD_destroy_response(resp);
- free_ms(ms);
}
return MHD_YES;
@@ -1949,7 +1851,6 @@ proxy_create_bucket (void *cctx, struct MHD_Connection *conn, const char *url,
MHD_queue_response(conn,rc,resp);
MHD_destroy_response(resp);
- free_ms(ms);
return MHD_YES;
}
@@ -2077,7 +1978,6 @@ access_handler (void *cctx, struct MHD_Connection *conn, const char *url,
if (!ms) {
return MHD_NO;
}
- ms->refcnt = 1;
utype = parse_url(url,ms);
@@ -2101,9 +2001,6 @@ access_handler (void *cctx, struct MHD_Connection *conn, const char *url,
data,data_size,rctx);
}
- /* Don't need this after all. Free before the next check. */
- free_ms(ms);
-
if (!strcmp(method,"QUIT")) {
(void)sem_post((sem_t *)cctx);
return MHD_NO;
diff --git a/setup.c b/setup.c
index b3173ff..505c9cb 100644
--- a/setup.c
+++ b/setup.c
@@ -331,7 +331,6 @@ convert_provider (int i, provider_t *out)
out->token = NULL;
out->deleted = 0;
- out->refcnt = 0;
return 1;
}
@@ -595,19 +594,6 @@ find_provider (const char *name)
return p;
}
-void
-delete_provider (provider_t *prov)
-{
- // Remove from prov_hash, then free
-
- g_hash_table_destroy(prov->attrs);
- // FIXME: free other members, too?
-
- // FIXME: unchecked strdup
- char *name = strdup (prov->name);
- g_hash_table_remove(prov_hash, prov->name);
-}
-
const char *
get_provider_value (const provider_t *prov, const char *fname)
{
diff --git a/setup.h b/setup.h
index 54a4ca3..fb50944 100644
--- a/setup.h
+++ b/setup.h
@@ -27,7 +27,6 @@ typedef struct _provider {
const char *host;
int port;
int deleted;
- gint refcnt;
const char *username;
const char *password;
const char *path;
@@ -51,7 +50,6 @@ const char *auto_config (void);
int validate_provider (GHashTable *h);
provider_t *find_provider (const char *name);
int add_provider (GHashTable *h);
-void delete_provider (provider_t *prov);
provider_t *get_main_provider (void);
void set_main_provider (provider_t *prov);
diff --git a/state_defs.h b/state_defs.h
index 1443236..a35cd8d 100644
--- a/state_defs.h
+++ b/state_defs.h
@@ -44,8 +44,6 @@ typedef struct {
} backend_thunk_t;
typedef struct _my_state {
- volatile gint refcnt;
- int cleanup;
/* for everyone */
MHD_AccessHandlerCallback handler;
ms_state state;
@@ -90,6 +88,4 @@ typedef struct _my_state {
#define BACKEND_GET_SIZE 0x01 /* used in put_child_func */
-void free_ms (my_state *ms);
-
#endif
http://repo.or.cz/w/iwhd.git/commit/2b64c1ad809e9b657a7a52d8d49e2f3604f526fc
commit 2b64c1ad809e9b657a7a52d8d49e2f3604f526fc
Author: Jim Meyering <meyering(a)redhat.com>
Date: Thu Dec 23 18:36:38 2010 +0100
garbage-collection fix-up
Do not instruct libraries to free things that they do not allocate,
since they would use the system "free" function.
* setup.c, rest.c: Do not tell g_hash_table_new_full to free anything.
* rest.c (proxy_get_attr): Do not tell MHD to free anything.
diff --git a/rest.c b/rest.c
index 3585020..059d7bf 100644
--- a/rest.c
+++ b/rest.c
@@ -316,7 +316,6 @@ proxy_get_data (void *cctx, struct MHD_Connection *conn, const char *url,
MHD_destroy_response(resp);
return MHD_YES;
}
- free(my_etag);
ms->from_master = 0;
}
else {
@@ -384,7 +383,6 @@ static void
recheck_replication (my_state * ms, char *policy)
{
int rc;
- int free_it = FALSE;
char fixed[MAX_FIELD_LEN];
if (is_reserved(ms->key,reserved_name)) {
@@ -398,8 +396,6 @@ recheck_replication (my_state * ms, char *policy)
}
if (!policy) {
- /* If we get a policy here or below, we have to free it. */
- free_it = TRUE;
DPRINTF("fetching policy for %s/%sn",ms->bucket,ms->key);
rc = meta_get_value(ms->bucket,ms->key, "_policy", &policy);
}
@@ -418,9 +414,6 @@ recheck_replication (my_state * ms, char *policy)
*/
snprintf(fixed,sizeof(fixed),"%s/%s",ms->bucket,ms->key);
replicate(fixed,0,policy,ms);
- if (free_it) {
- free(policy);
- }
}
else {
DPRINTF(" could not find a policy anywhere!n");
@@ -554,7 +547,6 @@ proxy_put_data (void *cctx, struct MHD_Connection *conn, const char *url,
}
if (etag) {
MHD_add_response_header(resp,"ETag",etag);
- free(etag);
}
MHD_queue_response(conn,rc,resp);
MHD_destroy_response(resp);
@@ -583,7 +575,7 @@ proxy_get_attr (void *cctx, struct MHD_Connection *conn, const char *url,
if (meta_get_value(ms->bucket,ms->key,ms->attr,&fixed) == 0) {
resp = MHD_create_response_from_data(strlen(fixed),fixed,
- MHD_YES,MHD_NO);
+ MHD_NO,MHD_NO);
rc = MHD_HTTP_OK;
}
else {
@@ -1195,7 +1187,7 @@ control_api_root (void *cctx, struct MHD_Connection *conn, const char *url,
ms->state = MS_NORMAL;
ms->url = (char *)url;
ms->dict = g_hash_table_new_full(
- g_str_hash,g_str_equal,free,free);
+ g_str_hash,g_str_equal,NULL,NULL);
ms->cleanup |= CLEANUP_DICT;
ms->post = MHD_create_post_processor(conn,4096,
post_iterator,ms->dict);
@@ -1263,7 +1255,7 @@ proxy_bucket_post (void *cctx, struct MHD_Connection *conn, const char *url,
ms->state = MS_NORMAL;
ms->url = (char *)url;
ms->dict = g_hash_table_new_full(
- g_str_hash,g_str_equal,free,free);
+ g_str_hash,g_str_equal,NULL,NULL);
ms->cleanup |= CLEANUP_DICT;
ms->post = MHD_create_post_processor(conn,4096,
post_iterator,ms->dict);
@@ -1471,7 +1463,7 @@ proxy_object_post (void *cctx, struct MHD_Connection *conn, const char *url,
ms->state = MS_NORMAL;
ms->url = (char *)url;
ms->dict = g_hash_table_new_full(
- g_str_hash,g_str_equal,free,free);
+ g_str_hash,g_str_equal,NULL,NULL);
ms->cleanup |= CLEANUP_DICT;
ms->post = MHD_create_post_processor(conn,4096,
post_iterator,ms->dict);
@@ -1664,7 +1656,7 @@ proxy_update_prov (void *cctx, struct MHD_Connection *conn, const char *url,
ms->state = MS_NORMAL;
ms->url = (char *)url;
ms->dict = g_hash_table_new_full(
- g_str_hash,g_str_equal,free,free);
+ g_str_hash,g_str_equal,NULL,NULL);
ms->cleanup |= CLEANUP_DICT;
ms->post = MHD_create_post_processor(conn,4096,
prov_iterator,ms->dict);
@@ -1870,7 +1862,7 @@ proxy_add_prov (void *cctx, struct MHD_Connection *conn, const char *url,
ms->state = MS_NORMAL;
ms->url = (char *)url;
ms->dict = g_hash_table_new_full(
- g_str_hash,g_str_equal,free,free);
+ g_str_hash,g_str_equal,NULL,NULL);
ms->cleanup |= CLEANUP_DICT;
ms->post = MHD_create_post_processor(conn,4096,
prov_iterator,ms->dict);
diff --git a/setup.c b/setup.c
index d1daa19..b3173ff 100644
--- a/setup.c
+++ b/setup.c
@@ -307,7 +307,7 @@ convert_provider (int i, provider_t *out)
out->func_tbl = &bad_func_tbl;
}
- out->attrs = g_hash_table_new_full(g_str_hash,g_str_equal,free,free);
+ out->attrs = g_hash_table_new_full(g_str_hash,g_str_equal,NULL,NULL);
iter = json_object_iter(server);
while (iter) {
key = json_object_iter_key(iter);
@@ -385,7 +385,7 @@ add_provider (GHashTable *h)
else
prov->func_tbl = &bad_func_tbl;
- prov->attrs = g_hash_table_new_full(g_str_hash,g_str_equal,free,free);
+ prov->attrs = g_hash_table_new_full(g_str_hash,g_str_equal,NULL,NULL);
// FIXME: can't the above fail?
GHashTableIter iter;
@@ -453,7 +453,7 @@ parse_config_inner (void)
/* Everything looks OK. */
printf("%u replication servers definedn",nservers-1);
- prov_hash = g_hash_table_new_full(g_str_hash,g_str_equal,free,free);
+ prov_hash = g_hash_table_new_full(g_str_hash,g_str_equal,NULL,NULL);
if (!prov_hash) {
error(0,0,"could not allocate provider hash");
goto err;
http://repo.or.cz/w/iwhd.git/commit/ae15a4eabca8853eb16bb4e9df6c235a1ce15b1a
commit ae15a4eabca8853eb16bb4e9df6c235a1ce15b1a
Author: Jim Meyering <meyering(a)redhat.com>
Date: Thu Dec 23 18:17:23 2010 +0100
don't use xstrndup via base_name
* rest.c (url_to_provider_name): Rewrite not to use base_name, since
that function uses xstrndup, which exits on OOM.
diff --git a/rest.c b/rest.c
index 978ef89..3585020 100644
--- a/rest.c
+++ b/rest.c
@@ -1703,12 +1703,15 @@ proxy_update_prov (void *cctx, struct MHD_Connection *conn, const char *url,
static char *
url_to_provider_name (const char *url)
{
- char *prov_name = base_name (url);
- if (prov_name)
- strip_trailing_slashes (prov_name);
+ char *p = strdup (url);
+ if (p == NULL)
+ return NULL;
+
/* Ensure we handle trailing slashes (i.e., remove them). */
- assert (prov_name == NULL
- || (*prov_name && prov_name[strlen(prov_name)-1] != '/'));
+ strip_trailing_slashes (p);
+
+ char *prov_name = strdup (last_component (p));
+ free (p);
return prov_name;
}
http://repo.or.cz/w/iwhd.git/commit/ed0b229107cca6b51adfb1ffb6079a2a23546a75
commit ed0b229107cca6b51adfb1ffb6079a2a23546a75
Author: Jim Meyering <meyering(a)redhat.com>
Date: Wed Dec 22 17:25:19 2010 +0100
use garbage collection
Add -lgc when linking.
* gc-wrap.h: New file, to map malloc, realloc, free,
etc. to GC'd equivalents.
* iwh.h: Include it.
* template.c: Include it.
* Makefile.am (iwhd_LDADD): Add -lgc and -lpthread.
* t/Makefile.am (parser_LDADD): Likewise.
* Makefile.am (iwhd_SOURCES): Add gc-wrap.h.
(TESTS): Move the simpler parser-test to precede all others.
* iwhd.spec.in (BuildRequires): Require gc-devel.
* qparser.y (free_value): Remove function.
* meta.cpp, replica.c: Remove all uses.
* query.h: Remove declaration.
* rest.c (main): Call GC_INIT.
* qparser.y (main) [PARSER_UNIT_TEST]: Likewise.
* mpipe.c: Include unistd.h here, ...
* mpipe.h: ...not here.
Don't include the following, either: fcntl.h, stdlib.h, string.h,
strings.h, sys/stat.h. They were not used, and got in the way
of gc-wrap's redefinitions.
diff --git a/Makefile.am b/Makefile.am
index 4360dd4..cbf2fc2 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -40,6 +40,7 @@ iwhd_SOURCES = auto.c backend.c backend.h + gc-wrap.h iwh.h meta.cpp meta.h @@ -94,6 +95,7 @@ rpm: dist iwhd.spec
iwhd_CPPFLAGS = $(HAIL_CFLAGS) -I$(top_srcdir)/lib
iwhd_LDADD = lib/libiwhd.a + -lgc -lpthread -lmongoclient $(BOOST_SYSTEM_LIB) $(BOOST_THREAD_LIB) diff --git a/gc-wrap.h b/gc-wrap.h
new file mode 100644
index 0000000..70c4b9d
--- /dev/null
+++ b/gc-wrap.h
@@ -0,0 +1,35 @@
+#include <string.h>
+#define GC_THREADS
+#include "gc.h"
+
+#ifndef __cplusplus
+# define malloc(n) GC_MALLOC(n)
+# define calloc(m,n) GC_MALLOC((m)*(n))
+# define free(p) GC_FREE(p)
+# define realloc(p,n) GC_REALLOC((p),(n))
+#endif
+
+static inline char *
+my_strdup (char const *s)
+{
+ size_t len = strlen (s);
+ void *t = GC_MALLOC (len + 1);
+ if (t == NULL)
+ return NULL;
+ return (char *) memcpy (t, s, len + 1);
+}
+# undef strdup
+# define strdup(s) my_strdup(s)
+
+static inline char *
+my_strndup (char const *s, size_t n)
+{
+ size_t len = strnlen (s, n);
+ char *t = (char *) GC_MALLOC (len + 1);
+ if (t == NULL)
+ return NULL;
+ t[len] = '0';
+ return (char *) memcpy (t, s, len);
+}
+# undef strndup
+# define strndup(s, n) my_strndup(s, n)
diff --git a/iwh.h b/iwh.h
index c862273..b98e6ba 100644
--- a/iwh.h
+++ b/iwh.h
@@ -69,3 +69,5 @@ GLOBAL(const char *, me, "here");
#define AUTO_MONGOD_PORT 27018
int auto_start (int dbport);
+
+#include "gc-wrap.h"
diff --git a/iwhd.spec.in b/iwhd.spec.in
index 2b28b53..eae6086 100644
--- a/iwhd.spec.in
+++ b/iwhd.spec.in
@@ -17,6 +17,7 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: boost-devel
BuildRequires: boost-filesystem
+BuildRequires: gc-devel
BuildRequires: glib2-devel
BuildRequires: hail-devel
BuildRequires: jansson-devel
diff --git a/meta.cpp b/meta.cpp
index b7ae903..59d4e53 100644
--- a/meta.cpp
+++ b/meta.cpp
@@ -440,9 +440,6 @@ RepoQuery::RepoQuery (const char *bucket, const char *key, const char *qstr,
RepoQuery::~RepoQuery ()
{
cout << "in " << __func__ << endl;
- if (expr) {
- free_value(expr);
- }
delete curs;
}
diff --git a/mpipe.c b/mpipe.c
index 46b3ad2..8272168 100644
--- a/mpipe.c
+++ b/mpipe.c
@@ -15,6 +15,7 @@
#include <config.h>
#include <assert.h>
+#include <unistd.h>
#include "iwh.h"
#include "mpipe.h"
diff --git a/mpipe.h b/mpipe.h
index 9d0f795..cf0ec72 100644
--- a/mpipe.h
+++ b/mpipe.h
@@ -16,17 +16,11 @@
#if !defined(_MPIPE_H)
#define _MPIPE_H
-#include <fcntl.h>
#include <poll.h>
#include <pthread.h>
#include <semaphore.h>
#include <stdint.h>
#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <strings.h>
-#include <unistd.h>
-#include <sys/stat.h>
/*
* This is an in-memory "pipe" construct with a twist: it lets you have
diff --git a/qparser.y b/qparser.y
index 64f025a..8ef7fe0 100644
--- a/qparser.y
+++ b/qparser.y
@@ -387,41 +387,6 @@ print_value (const value_t *v)
_print_value(v,0);
}
-void
-free_value (value_t *v)
-{
- if (v == NULL || v == &invalid) {
- return;
- }
-
- free((void *)v->resolved);
-
- switch (v->type) {
- case T_STRING:
- case T_OFIELD:
- case T_SFIELD:
- case T_ID:
- free(v->as_str);
- free(v);
- break;
- case T_LINK:
- free_value(v->as_tree.left);
- free(v->as_tree.right);
- free(v);
- break;
- case T_COMP:
- case T_AND:
- case T_OR:
- free_value(v->as_tree.right);
- /* Fall through. */
- case T_NOT:
- free_value(v->as_tree.left);
- /* Fall through. */
- default:
- free(v);
- }
-}
-
#include "qlexer.c"
value_t *
@@ -433,8 +398,6 @@ parse (const char *text)
YY_BUFFER_STATE buf = yy_scan_string (text, scanner);
value_t *result = NULL;
value_t *r = yyparse (scanner, &result) == 0 ? result : NULL;
- if (r == NULL)
- free_value (result);
yy_delete_buffer (buf, scanner);
yylex_destroy (scanner);
return r;
@@ -644,6 +607,7 @@ main (int argc, char **argv)
{
int fail = 0;
unsigned int i;
+ GC_INIT ();
for (i = 1; i < argc; ++i)
{
value_t *expr = parse (argv[i]);
@@ -651,7 +615,7 @@ main (int argc, char **argv)
{
printf ("could not parse '%s'n", argv[i]);
fail = 1;
- goto next;
+ continue;
}
print_value (expr);
@@ -660,12 +624,9 @@ main (int argc, char **argv)
if (str)
{
printf ("s= %sn", str);
- goto next;
+ continue;
}
printf ("d= %dn", eval (expr, &unit_oget, &unit_sget));
-
- next:
- free_value (expr);
}
return fail;
diff --git a/query.h b/query.h
index 523dd91..de42d80 100644
--- a/query.h
+++ b/query.h
@@ -69,9 +69,9 @@ typedef struct {
#define CALL_GETTER(g,x) g->func(g->ctx,x)
/*
- * In the normal case a caller would invoke parse once, eval multiple times,
- * and free_value once. print_value is just for debugging/testing.
- * TBD: make parse reentrant (eval already is, free_value doesn't need to be.
+ * In the normal case a caller would invoke parse once and eval multiple times.
+ * print_value is just for debugging/testing.
+ * TBD: make parse reentrant (eval already is).
* Unfortunately, a quick scan of generated code and information on the web
* seems to indicate that even a "reentrant" bison parser only encapsulates
* user state and still relies quite a bit on internal globals. That might
@@ -79,7 +79,6 @@ typedef struct {
*/
int eval (const value_t *expr,
const getter_t *oget, const getter_t *sget);
-void free_value (value_t *);
void print_value (const value_t *);
value_t *parse (const char *text);
diff --git a/replica.c b/replica.c
index 301c8d3..1910747 100644
--- a/replica.c
+++ b/replica.c
@@ -354,9 +354,6 @@ replicate (const char *url, size_t size, const char *policy, my_state *ms)
sem_post(&queue_sema);
}
- if (expr) {
- free_value(expr);
- }
free(url2);
}
diff --git a/rest.c b/rest.c
index 972c2fc..978ef89 100644
--- a/rest.c
+++ b/rest.c
@@ -2193,6 +2193,7 @@ main (int argc, char **argv)
set_program_name (argv[0]);
atexit (close_stdout);
+ GC_INIT ();
for (;;) switch (getopt_long(argc,argv,"ac:d:m:p:v",my_options,NULL)) {
case 'a':
diff --git a/t/Makefile.am b/t/Makefile.am
index 87fe3e4..0b3d100 100644
--- a/t/Makefile.am
+++ b/t/Makefile.am
@@ -15,9 +15,9 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
TESTS = + parser-test basic replication - parser-test auto
EXTRA_DIST = @@ -31,7 +31,7 @@ BUILT_SOURCES =
BUILT_SOURCES += parser.c
MAINTAINERCLEANFILES = $(BUILT_SOURCES)
parser_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/lib
-parser_LDADD = -L../lib -liwhd
+parser_LDADD = -L../lib -liwhd -lgc -lpthread
parser.c: Makefile.am
rm -f $@-t $@
diff --git a/template.c b/template.c
index 2d49e2c..1b78bf4 100644
--- a/template.c
+++ b/template.c
@@ -19,6 +19,7 @@
#include <stdlib.h>
#include <string.h>
#include "template.h"
+#include "gc-wrap.h"
static const char xml_root_header[] = " <api service="%s" version="%s">
http://repo.or.cz/w/iwhd.git/commit/2d99e43fee5f7af7f6ec6fd238ee900f9fb103aa
commit 2d99e43fee5f7af7f6ec6fd238ee900f9fb103aa
Author: Jim Meyering <meyering(a)redhat.com>
Date: Sat Dec 18 11:08:25 2010 +0100
maint: rename file-scoped global s/main_prov/g_main_prov/, and...
* setup.c (g_main_prov): Rename from main_prov, to avoid confusion
between this file-scoped global and the locals of the same name
in other compilation units.
(g_master_prov): Rename from master_prov, for consistency.
Though this one is truly global...
* setup.h (g_master_prov): Update here,...
* rest.c (g_master_prov): ...and here.
diff --git a/rest.c b/rest.c
index b58f1bc..972c2fc 100644
--- a/rest.c
+++ b/rest.c
@@ -341,7 +341,7 @@ proxy_get_data (void *cctx, struct MHD_Connection *conn, const char *url,
}
provider_t *main_prov = get_main_provider();
ms->thunk.parent = ms;
- ms->thunk.prov = ms->from_master ? master_prov : main_prov;
+ ms->thunk.prov = ms->from_master ? g_master_prov : main_prov;
pthread_create(&ms->backend_th,NULL,
ms->thunk.prov->func_tbl->get_child_func,&ms->thunk);
/* TBD: check return value */
diff --git a/setup.c b/setup.c
index 6ae5f01..d1daa19 100644
--- a/setup.c
+++ b/setup.c
@@ -69,19 +69,19 @@ extern backend_func_tbl fs_func_tbl;
static json_t *config = NULL;
static GHashTable *prov_hash = NULL;
-static provider_t *main_prov = NULL;
-provider_t *master_prov = NULL;
+static provider_t *g_main_prov = NULL;
+provider_t *g_master_prov = NULL;
provider_t *
get_main_provider (void)
{
- return main_prov;
+ return g_main_prov;
}
void
set_main_provider (provider_t *prov)
{
- main_prov = prov;
+ g_main_prov = prov;
}
int
@@ -482,7 +482,7 @@ parse_config_inner (void)
}
g_hash_table_insert(prov_hash,(char *)new_key,new_prov);
if (!i) {
- main_prov = new_prov;
+ g_main_prov = new_prov;
primary = new_prov->name;
}
new_prov->func_tbl->init_func(new_prov);
@@ -511,10 +511,10 @@ parse_config (char *cfg_file)
* TBD: initialize this in a separate module-init function, passing
* in master_host and master_port instead of using globals.
*/
- if (!master_prov) {
- master_prov = malloc(sizeof(*master_prov));
- if (master_prov) {
- master_prov->func_tbl = &curl_func_tbl;
+ if (!g_master_prov) {
+ g_master_prov = malloc(sizeof(*g_master_prov));
+ if (g_master_prov) {
+ g_master_prov->func_tbl = &curl_func_tbl;
}
}
diff --git a/setup.h b/setup.h
index 0bfbb81..54a4ca3 100644
--- a/setup.h
+++ b/setup.h
@@ -36,7 +36,7 @@ typedef struct _provider {
char *token;
} provider_t;
-provider_t *master_prov;
+provider_t *g_master_prov;
const char *parse_config (char *);
provider_t *get_provider (const char *name);
http://repo.or.cz/w/iwhd.git/commit/9bc8fc19e7d70de1fe8968bf2b844ee9c15b3574
commit 9bc8fc19e7d70de1fe8968bf2b844ee9c15b3574
Author: Jim Meyering <meyering(a)redhat.com>
Date: Sat Dec 18 10:47:58 2010 +0100
rename a URL API component: s/_set_primary/_primary/
Suggested by Jeff Darcy.
diff --git a/rest.c b/rest.c
index be4a888..b58f1bc 100644
--- a/rest.c
+++ b/rest.c
@@ -1762,7 +1762,7 @@ proxy_set_primary (void *cctx, struct MHD_Connection *conn, const char *url,
char *name = NULL;
unsigned int rc = MHD_HTTP_BAD_REQUEST;
- /* URL is guaranteed to be of the form "/_providers/NAME/_set_primary"
+ /* URL is guaranteed to be of the form "/_providers/NAME/_primary"
Extract NAME: */
bool valid = memcmp (url, "/_providers/", strlen("/_providers/")) == 0;
if (!valid) {
@@ -2055,7 +2055,7 @@ parse_url (const char *url, my_state *ms)
eindex = URL_PROVIDER;
else if (eindex == URL_ATTR
&& !strcmp (parts[URL_BUCKET], "_providers")
- && !strcmp (parts[URL_ATTR], "_set_primary"))
+ && !strcmp (parts[URL_ATTR], "_primary"))
eindex = URL_PROVIDER_SET_PRIMARY;
DPRINTF("parse_url: %d: %s %s %s", eindex, parts[URL_BUCKET],
diff --git a/t/basic b/t/basic
index 436f123..a2f91ca 100644
--- a/t/basic
+++ b/t/basic
@@ -366,7 +366,7 @@ curl http://localhost:$port/_primary > p || fail=1
grep _primary p && { warn_ add-provider/reserved-name not rejected; fail=1; }
# Move the "primary" attribute to a different provider.
-curl -X PUT $p1_url/_set_primary > p || fail=1
+curl -X PUT $p1_url/_primary > p || fail=1
test -s p && fail=1
new_primary=$(curl http://localhost:$port/_providers/_primary) || fail=1
test $new_primary = PROVIDER-1 || fail=1
@@ -375,7 +375,7 @@ test $new_primary = PROVIDER-1 || fail=1
# FIXME: if I don't restore, the following headless test makes iwhd segfault.
# Investigate that.
p1_url=http://localhost:$port/_providers/primary
-curl -X PUT $p1_url/_set_primary > p || fail=1
+curl -X PUT $p1_url/_primary > p || fail=1
http://repo.or.cz/w/iwhd.git/commit/e8699f536bb5cd49f8e20db1615221263938de07
commit e8699f536bb5cd49f8e20db1615221263938de07
Author: Jim Meyering <meyering(a)redhat.com>
Date: Fri Dec 17 17:07:47 2010 +0100
new interface: curl -X PUT http://_providers/PROVIDER/_set_primary
* rest.c: Include <errno.h>.
(proxy_set_primary): New function.
(parse_url): Handle new type: URL_PROVIDER_SET_PRIMARY.
* setup.c (set_main_provider): New function.
* setup.h (set_main_provider): Declare it.
* t/basic: Exercise the new functionality.
diff --git a/rest.c b/rest.c
index cc0a99b..be4a888 100644
--- a/rest.c
+++ b/rest.c
@@ -28,6 +28,7 @@
#include <unistd.h>
#include <sys/stat.h>
#include <assert.h>
+#include <errno.h>
#include <microhttpd.h>
#include <hstor.h> /* only for ARRAY_SIZE at this point */
@@ -58,7 +59,7 @@
typedef enum {
URL_ROOT=0, URL_BUCKET, URL_OBJECT, URL_ATTR, URL_INVAL,
- URL_QUERY, URL_PROVLIST, URL_PROVIDER
+ URL_QUERY, URL_PROVLIST, URL_PROVIDER, URL_PROVIDER_SET_PRIMARY
} url_type;
typedef struct {
@@ -1746,6 +1747,62 @@ proxy_primary_prov (void *cctx, struct MHD_Connection *conn, const char *url,
}
static int
+proxy_set_primary (void *cctx, struct MHD_Connection *conn, const char *url,
+ const char *method, const char *version, const char *data,
+ size_t *data_size, void **rctx)
+{
+ (void)cctx;
+ (void)method;
+ (void)version;
+ (void)data;
+
+ DPRINTF("PROXY SET PRIMARY PROVIDER (%s)n", url);
+
+ my_state *ms = *rctx;
+ char *name = NULL;
+ unsigned int rc = MHD_HTTP_BAD_REQUEST;
+
+ /* URL is guaranteed to be of the form "/_providers/NAME/_set_primary"
+ Extract NAME: */
+ bool valid = memcmp (url, "/_providers/", strlen("/_providers/")) == 0;
+ if (!valid) {
+ error (0, 0, "invalid request: %s", url);
+ goto bad_set;
+ }
+ const char *start = url + strlen("/_providers/");
+ const char *slash = strchr (start, '/');
+ if (slash == NULL) {
+ error (0, 0, "invalid request: %s", url);
+ goto bad_set;
+ }
+ name = strndup (start, slash - start);
+ if (name == NULL) {
+ error (0, errno, "failed to extract provider name: %s", url);
+ goto bad_set;
+ }
+
+ /* If it's not a provider name, you lose. */
+ provider_t *prov = find_provider (name);
+ if (prov) {
+ rc = MHD_HTTP_OK;
+ set_main_provider (prov);
+ }
+
+ bad_set:
+ free (name);
+
+ struct MHD_Response *resp;
+ resp = MHD_create_response_from_data(0, NULL, MHD_NO, MHD_NO);
+ if (!resp) {
+ return MHD_NO;
+ }
+ MHD_queue_response(conn,rc,resp);
+ MHD_destroy_response(resp);
+
+ return MHD_YES;
+}
+
+static int
proxy_delete_prov (void *cctx, struct MHD_Connection *conn, const char *url,
const char *method, const char *version, const char *data,
size_t *data_size, void **rctx)
@@ -1938,6 +1995,8 @@ static const rule my_rules[] = {
"POST", URL_PROVIDER, proxy_add_prov },
{ /* delete a provider */
"DELETE", URL_PROVIDER, proxy_delete_prov },
+ { /* set the primary provider */
+ "PUT", URL_PROVIDER_SET_PRIMARY, proxy_set_primary },
{ NULL, 0, NULL }
};
@@ -1994,6 +2053,10 @@ parse_url (const char *url, my_state *ms)
if (eindex == URL_OBJECT
&& !strcmp (parts[URL_BUCKET], "_providers"))
eindex = URL_PROVIDER;
+ else if (eindex == URL_ATTR
+ && !strcmp (parts[URL_BUCKET], "_providers")
+ && !strcmp (parts[URL_ATTR], "_set_primary"))
+ eindex = URL_PROVIDER_SET_PRIMARY;
DPRINTF("parse_url: %d: %s %s %s", eindex, parts[URL_BUCKET],
parts[URL_OBJECT], parts[URL_ATTR]);
diff --git a/setup.c b/setup.c
index f613f24..6ae5f01 100644
--- a/setup.c
+++ b/setup.c
@@ -78,6 +78,12 @@ get_main_provider (void)
return main_prov;
}
+void
+set_main_provider (provider_t *prov)
+{
+ main_prov = prov;
+}
+
int
validate_provider (GHashTable *h)
{
diff --git a/setup.h b/setup.h
index ecdef5f..0bfbb81 100644
--- a/setup.h
+++ b/setup.h
@@ -53,5 +53,6 @@ provider_t *find_provider (const char *name);
int add_provider (GHashTable *h);
void delete_provider (provider_t *prov);
provider_t *get_main_provider (void);
+void set_main_provider (provider_t *prov);
#endif
diff --git a/t/basic b/t/basic
index 59e2608..436f123 100644
--- a/t/basic
+++ b/t/basic
@@ -365,6 +365,18 @@ curl -dtype=http -dhost=localhost -dport=9091 $p_reserved_url || fail=1
curl http://localhost:$port/_primary > p || fail=1
grep _primary p && { warn_ add-provider/reserved-name not rejected; fail=1; }
+# Move the "primary" attribute to a different provider.
+curl -X PUT $p1_url/_set_primary > p || fail=1
+test -s p && fail=1
+new_primary=$(curl http://localhost:$port/_providers/_primary) || fail=1
+test $new_primary = PROVIDER-1 || fail=1
+
+# Restore the primary attribute to the original.
+# FIXME: if I don't restore, the following headless test makes iwhd segfault.
+# Investigate that.
+p1_url=http://localhost:$port/_providers/primary
+curl -X PUT $p1_url/_set_primary > p || fail=1
+
# Test "headless" operation (no access to metadata DB).
http://repo.or.cz/w/iwhd.git/commit/55be76211cca12e07a644809272649176f336f0e
commit 55be76211cca12e07a644809272649176f336f0e
Author: Jim Meyering <meyering(a)redhat.com>
Date: Fri Dec 17 15:37:14 2010 +0100
get primary provider name via http://host:$port/_providers/_primary
Get a URL of the form http://.../_providers/_primary
to obtain the name of the primary provider.
* rest.c (proxy_primary_prov): Implement it.
(proxy_add_prov): Prohibit addition of a provider
with the reserved name, "_primary".
* t/basic: Exercise the new functionality.
diff --git a/rest.c b/rest.c
index a56f2d3..cc0a99b 100644
--- a/rest.c
+++ b/rest.c
@@ -1712,6 +1712,40 @@ url_to_provider_name (const char *url)
}
static int
+proxy_primary_prov (void *cctx, struct MHD_Connection *conn, const char *url,
+ const char *method, const char *version, const char *data,
+ size_t *data_size, void **rctx)
+{
+ (void)cctx;
+ (void)method;
+ (void)version;
+ (void)data;
+
+ DPRINTF("PROXY GET PRIMARY PROVIDER (%s)n", url);
+
+ my_state *ms = *rctx;
+
+ // "/_providers/_primary" is the only one we accept for now.
+ bool valid = strcmp (url, "/_providers/_primary") == 0;
+ unsigned int rc = (valid ? MHD_HTTP_OK : MHD_HTTP_BAD_REQUEST);
+ if (!valid)
+ error (0, 0, "invalid request: %s", url);
+
+ const char *name = get_main_provider()->name;
+ struct MHD_Response *resp;
+ resp = MHD_create_response_from_data(valid ? strlen (name) : 0,
+ valid ? (void *) name : NULL,
+ MHD_NO, MHD_NO);
+ if (!resp) {
+ return MHD_NO;
+ }
+ MHD_queue_response(conn,rc,resp);
+ MHD_destroy_response(resp);
+
+ return MHD_YES;
+}
+
+static int
proxy_delete_prov (void *cctx, struct MHD_Connection *conn, const char *url,
const char *method, const char *version, const char *data,
size_t *data_size, void **rctx)
@@ -1798,6 +1832,16 @@ proxy_add_prov (void *cctx, struct MHD_Connection *conn, const char *url,
name);
goto add_fail;
}
+
+ // another reserved word: provider name
+ // FIXME: don't hard-code it here
+ if (strcmp (prov_name, "_primary") == 0) {
+ fprintf(stderr,
+ "add_provider: %s is a reserved namen",
+ prov_name);
+ goto add_fail;
+ }
+
// FIXME: unchecked strdup
g_hash_table_insert(ms->dict,strdup("name"),prov_name);
@@ -1888,6 +1932,8 @@ static const rule my_rules[] = {
"GET", URL_PROVLIST, proxy_list_provs },
{ /* update a provider */
"POST", URL_PROVLIST, proxy_update_prov },
+ { /* get the primary provider */
+ "GET", URL_PROVIDER, proxy_primary_prov },
{ /* create a provider */
"POST", URL_PROVIDER, proxy_add_prov },
{ /* delete a provider */
diff --git a/t/basic b/t/basic
index 19eda9b..59e2608 100644
--- a/t/basic
+++ b/t/basic
@@ -350,6 +350,22 @@ curl -f -X DELETE http://localhost:$port/_providers/no-such 2> p
test $? = 22 || fail=1
grep ' 404$' p || fail=1
+# Get the name of the current primary provider.
+curl http://localhost:$port/_providers/_primary > p || fail=1
+test "$(cat p)" = primary || fail=1
+
+# Trying to GET with anything other than "_primary" returns the empty string.
+curl http://localhost:$port/_providers/anything > p 2>/dev/null || fail=1
+test -s p && fail=1
+
+# Try to add a provider with the reserved name. It must fail.
+p_reserved_url=http://localhost:$port/_providers/_primary
+curl -dtype=http -dhost=localhost -dport=9091 $p_reserved_url || fail=1
+# Ensure it was not added.
+curl http://localhost:$port/_primary > p || fail=1
+grep _primary p && { warn_ add-provider/reserved-name not rejected; fail=1; }
+
+
# Test "headless" operation (no access to metadata DB).
kill -9 $mongo_pid
http://repo.or.cz/w/iwhd.git/commit/2143b86e49ed10a3f59b08bff562f1a804d8f4d4
commit 2143b86e49ed10a3f59b08bff562f1a804d8f4d4
Author: Jim Meyering <meyering(a)redhat.com>
Date: Thu Dec 16 18:27:10 2010 +0100
tests: clean up provider-deletion test
diff --git a/t/basic b/t/basic
index 0d394c7..19eda9b 100644
--- a/t/basic
+++ b/t/basic
@@ -345,13 +345,11 @@ curl http://localhost:$port/_providers > p || fail=1
grep PROVIDER-2 p && { warn_ $ME_: provider deletion failed; fail=1; }
# Delete a non-existent provider.
-curl -f -X DELETE http://localhost:$port/_providers/no-such
+curl -f -X DELETE http://localhost:$port/_providers/no-such 2> p
+# ensure it fails; expect exit-22 and http: 404
test $? = 22 || fail=1
-# FIXME ensure it fails
-cat p
+grep ' 404$' p || fail=1
-curl http://localhost:$port/_providers > p || fail=1
-cat p
# Test "headless" operation (no access to metadata DB).
kill -9 $mongo_pid
http://repo.or.cz/w/iwhd.git/commit/76d355f00798546cdc34079f3346547921c47185
commit 76d355f00798546cdc34079f3346547921c47185
Author: Jim Meyering <meyering(a)redhat.com>
Date: Wed Dec 15 12:45:28 2010 +0100
use new function, get_main_provider, rather than global "main_prov"
* setup.c (get_main_provider): New function.
(main_prov): Declare static.
* setup.h (main_prov): Remove global decl.
(get_main_provider): Declare.
* rest.c, replica.c: Update all uses of "main_prov".
diff --git a/replica.c b/replica.c
index f0b4b51..301c8d3 100644
--- a/replica.c
+++ b/replica.c
@@ -73,7 +73,7 @@ proxy_repl_prod (void *ctx)
void *result;
thunk.parent = item->ms;
- thunk.prov = main_prov;
+ thunk.prov = get_main_provider();
result = thunk.prov->func_tbl->get_child_func(&thunk);
return result;
diff --git a/rest.c b/rest.c
index f7ece46..a56f2d3 100644
--- a/rest.c
+++ b/rest.c
@@ -338,6 +338,7 @@ proxy_get_data (void *cctx, struct MHD_Connection *conn, const char *url,
if (!pp) {
return MHD_NO;
}
+ provider_t *main_prov = get_main_provider();
ms->thunk.parent = ms;
ms->thunk.prov = ms->from_master ? master_prov : main_prov;
pthread_create(&ms->backend_th,NULL,
@@ -468,6 +469,7 @@ proxy_put_data (void *cctx, struct MHD_Connection *conn, const char *url,
if (!pp) {
return MHD_NO;
}
+ provider_t *main_prov = get_main_provider();
pp->prov = main_prov;
ms->be_flags = BACKEND_GET_SIZE;
pthread_create(&ms->backend_th,NULL,
@@ -913,6 +915,7 @@ proxy_delete (void *cctx, struct MHD_Connection *conn, const char *url,
DPRINTF("PROXY DELETE %sn",url);
+ provider_t *main_prov = get_main_provider();
ms->thunk.parent = ms;
ms->thunk.prov = main_prov;
rc = ms->thunk.prov->func_tbl->delete_func(main_prov,
@@ -1145,6 +1148,7 @@ create_bucket (char *name, my_state *ms)
return MHD_HTTP_BAD_REQUEST;
}
+ provider_t *main_prov = get_main_provider();
rc = main_prov->func_tbl->bcreate_func(main_prov,name);
if (rc == MHD_HTTP_OK) {
if (meta_set_value(name,"_default", "_policy","0") != 0) {
@@ -1730,8 +1734,8 @@ proxy_delete_prov (void *cctx, struct MHD_Connection *conn, const char *url,
char *prov_name = url_to_provider_name (url);
provider_t *prov = find_provider (prov_name);
- // don't allow removal of current main_prov.
- if (prov == main_prov)
+ // don't allow removal of current main provider.
+ if (prov == get_main_provider())
prov = NULL;
int rc = prov ? MHD_HTTP_OK : MHD_HTTP_NOT_FOUND;
@@ -2156,6 +2160,7 @@ args_done:
sem_init(&the_sem,0,0);
if (verbose) {
+ provider_t *main_prov = get_main_provider();
printf("primary store type is %sn",main_prov->type);
if (master_host) {
printf("operating as slave to %s:%un",
diff --git a/setup.c b/setup.c
index dc494af..f613f24 100644
--- a/setup.c
+++ b/setup.c
@@ -69,9 +69,15 @@ extern backend_func_tbl fs_func_tbl;
static json_t *config = NULL;
static GHashTable *prov_hash = NULL;
-provider_t *main_prov = NULL;
+static provider_t *main_prov = NULL;
provider_t *master_prov = NULL;
+provider_t *
+get_main_provider (void)
+{
+ return main_prov;
+}
+
int
validate_provider (GHashTable *h)
{
diff --git a/setup.h b/setup.h
index dc89a74..ecdef5f 100644
--- a/setup.h
+++ b/setup.h
@@ -36,7 +36,6 @@ typedef struct _provider {
char *token;
} provider_t;
-provider_t *main_prov;
provider_t *master_prov;
const char *parse_config (char *);
@@ -53,5 +52,6 @@ int validate_provider (GHashTable *h);
provider_t *find_provider (const char *name);
int add_provider (GHashTable *h);
void delete_provider (provider_t *prov);
+provider_t *get_main_provider (void);
#endif
http://repo.or.cz/w/iwhd.git/commit/4f53c5ae1af0508fe90f2539772e247560836f73
commit 4f53c5ae1af0508fe90f2539772e247560836f73
Author: Jim Meyering <meyering(a)redhat.com>
Date: Sat Dec 11 15:58:18 2010 +0100
reject an attempt to add a provider with "name" parameter
The "name" is specified as part of the URL, not via a parameter.
* rest.c (proxy_add_prov): Handle undesired "name" parameter properly.
* t/basic: Exercise the above.
diff --git a/rest.c b/rest.c
index 4797438..f7ece46 100644
--- a/rest.c
+++ b/rest.c
@@ -1792,8 +1792,7 @@ proxy_add_prov (void *cctx, struct MHD_Connection *conn, const char *url,
fprintf(stderr,
"add_provider: do not specify name: name=%sn",
name);
- return MHD_NO;
- // FIXME: be careful that this does not leak "ms"
+ goto add_fail;
}
// FIXME: unchecked strdup
g_hash_table_insert(ms->dict,strdup("name"),prov_name);
@@ -1808,6 +1807,8 @@ proxy_add_prov (void *cctx, struct MHD_Connection *conn, const char *url,
else {
DPRINTF("invalid providern");
}
+
+ add_fail:
resp = MHD_create_response_from_data(0,NULL,MHD_NO,MHD_NO);
if (!resp) {
fprintf(stderr,"MHD_crfd failedn");
diff --git a/t/basic b/t/basic
index fc42ac4..0d394c7 100644
--- a/t/basic
+++ b/t/basic
@@ -331,6 +331,13 @@ curl -dtype=http -dhost=localhost -dport=9091 $p2_url || fail=1
curl http://localhost:$port/_providers > p || fail=1
grep PROVIDER-2 p || fail=1
+# Add provider using a "name" parameter (not permitted):
+p3_url=http://localhost:$port/_providers/PROVIDER-3
+curl -dtype=http -dname=X -dhost=localhost -dport=9091 $p3_url || fail=1
+# Ensure it was not added.
+curl http://localhost:$port/_providers > p || fail=1
+grep PROVIDER-3 p && { warn_ add-provider-w/name-param not rejected; fail=1; }
+
# Delete a provider.
curl -f -X DELETE $p2_url 2> p || fail=1
# Ensure it was deleted.
http://repo.or.cz/w/iwhd.git/commit/042463398c4b70c98a4c4890addae0a21fdc97c4
commit 042463398c4b70c98a4c4890addae0a21fdc97c4
Author: Jim Meyering <meyering(a)redhat.com>
Date: Fri Dec 10 21:11:27 2010 +0100
add provider ref-counting; FIXME: partial impl. (i.e., no incr)
delete_provider: New function.
diff --git a/rest.c b/rest.c
index f156862..4797438 100644
--- a/rest.c
+++ b/rest.c
@@ -1728,7 +1728,6 @@ proxy_delete_prov (void *cctx, struct MHD_Connection *conn, const char *url,
}
char *prov_name = url_to_provider_name (url);
- DPRINTF("PROXY DELETE PROVIDER prov=%sn", prov_name);
provider_t *prov = find_provider (prov_name);
// don't allow removal of current main_prov.
@@ -1736,10 +1735,17 @@ proxy_delete_prov (void *cctx, struct MHD_Connection *conn, const char *url,
prov = NULL;
int rc = prov ? MHD_HTTP_OK : MHD_HTTP_NOT_FOUND;
- if (prov)
- prov->deleted = 1;
- error (0, 0, "DELETE PROV: rc=%d", rc);
+ DPRINTF("PROXY DELETE PROVIDER prov=%s rc=%dn", prov_name, rc);
+
+ if (prov) {
+ /* Delete for real if no one is using it.
+ Otherwise, just mark it as deleted. */
+ if (g_atomic_int_get (&prov->refcnt) == 0)
+ delete_provider (prov);
+ else
+ prov->deleted = 1;
+ }
free (prov_name);
MHD_queue_response(conn,rc,resp);
diff --git a/setup.c b/setup.c
index 86061d1..dc494af 100644
--- a/setup.c
+++ b/setup.c
@@ -319,6 +319,7 @@ convert_provider (int i, provider_t *out)
out->token = NULL;
out->deleted = 0;
+ out->refcnt = 0;
return 1;
}
@@ -582,6 +583,19 @@ find_provider (const char *name)
return p;
}
+void
+delete_provider (provider_t *prov)
+{
+ // Remove from prov_hash, then free
+
+ g_hash_table_destroy(prov->attrs);
+ // FIXME: free other members, too?
+
+ // FIXME: unchecked strdup
+ char *name = strdup (prov->name);
+ g_hash_table_remove(prov_hash, prov->name);
+}
+
const char *
get_provider_value (const provider_t *prov, const char *fname)
{
diff --git a/setup.h b/setup.h
index 11d2207..dc89a74 100644
--- a/setup.h
+++ b/setup.h
@@ -26,7 +26,8 @@ typedef struct _provider {
const char *type;
const char *host;
int port;
- int deleted;
+ int deleted;
+ gint refcnt;
const char *username;
const char *password;
const char *path;
@@ -51,5 +52,6 @@ const char *auto_config (void);
int validate_provider (GHashTable *h);
provider_t *find_provider (const char *name);
int add_provider (GHashTable *h);
+void delete_provider (provider_t *prov);
#endif
http://repo.or.cz/w/iwhd.git/commit/e87a2a25917713f20e0543caac8ab9cef0435077
commit e87a2a25917713f20e0543caac8ab9cef0435077
Author: Jim Meyering <meyering(a)redhat.com>
Date: Mon Nov 15 17:50:53 2010 +0100
allow dynamic addition/deletion of providers
* setup.h (struct _provider) [deleted]: New member.
* setup.c (validate_provider): New function.
(json_validate_server): Renamed from validate_server.
(convert_provider): Initialize new "deleted" member.
(add_provider, find_provider): New functions.
Declare new functions.
* rest.c (prov_list_generator): Don't list a provider that
is marked as deleted.
(url_to_provider_name): New function.
(proxy_delete_prov, proxy_add_prov): New functions.
(my_rules): Add corresponding entries in this table.
* t/basic: Add minimal tests of new functionality.
diff --git a/rest.c b/rest.c
index ea8b289..f156862 100644
--- a/rest.c
+++ b/rest.c
@@ -34,6 +34,7 @@
#include <curl/curl.h>
#include <glib.h>
+#include "dirname.h"
#include "iwh.h"
#include "closeout.h"
#include "progname.h"
@@ -57,7 +58,7 @@
typedef enum {
URL_ROOT=0, URL_BUCKET, URL_OBJECT, URL_ATTR, URL_INVAL,
- URL_QUERY, URL_PROVLIST
+ URL_QUERY, URL_PROVLIST, URL_PROVIDER
} url_type;
typedef struct {
@@ -931,6 +932,7 @@ proxy_delete (void *cctx, struct MHD_Connection *conn, const char *url,
free_ms(ms);
return MHD_NO;
}
+ error (0, 0, "DELETE BUCKET: rc=%d", rc);
MHD_queue_response(conn,rc,resp);
MHD_destroy_response(resp);
@@ -1458,7 +1460,7 @@ proxy_object_post (void *cctx, struct MHD_Connection *conn, const char *url,
(void)method;
(void)version;
- DPRINTF("PROXY POST (%s, %zu)n",url,*data_size);
+ DPRINTF("PROXY POST obj (%s, %zu)n",url,*data_size);
if (ms->state == MS_NEW) {
ms->state = MS_NORMAL;
@@ -1563,6 +1565,8 @@ prov_list_generator (void *ctx, uint64_t pos, char *buf, size_t max)
}
if (g_hash_table_iter_next(&ms->prov_iter,&key,(gpointer *)&prov)) {
+ if (prov->deleted)
+ return 0;
len = tmpl_prov_entry(ms->gen_ctx,prov->name,prov->type,
prov->host, prov->port, prov->username, prov->password);
if (!len) {
@@ -1691,6 +1695,126 @@ proxy_update_prov (void *cctx, struct MHD_Connection *conn, const char *url,
return MHD_YES;
}
+static char *
+url_to_provider_name (const char *url)
+{
+ char *prov_name = base_name (url);
+ if (prov_name)
+ strip_trailing_slashes (prov_name);
+ /* Ensure we handle trailing slashes (i.e., remove them). */
+ assert (prov_name == NULL
+ || (*prov_name && prov_name[strlen(prov_name)-1] != '/'));
+ return prov_name;
+}
+
+static int
+proxy_delete_prov (void *cctx, struct MHD_Connection *conn, const char *url,
+ const char *method, const char *version, const char *data,
+ size_t *data_size, void **rctx)
+{
+ DPRINTF("PROXY DELETE PROVIDER %sn",url);
+ (void)cctx;
+ (void)method;
+ (void)version;
+ (void)data;
+ (void)data_size;
+
+ my_state *ms = *rctx;
+ struct MHD_Response *resp
+ = MHD_create_response_from_data(0,NULL,MHD_NO,MHD_NO);
+ if (!resp) {
+ free_ms(ms);
+ return MHD_NO;
+ }
+
+ char *prov_name = url_to_provider_name (url);
+ DPRINTF("PROXY DELETE PROVIDER prov=%sn", prov_name);
+ provider_t *prov = find_provider (prov_name);
+
+ // don't allow removal of current main_prov.
+ if (prov == main_prov)
+ prov = NULL;
+
+ int rc = prov ? MHD_HTTP_OK : MHD_HTTP_NOT_FOUND;
+ if (prov)
+ prov->deleted = 1;
+
+ error (0, 0, "DELETE PROV: rc=%d", rc);
+
+ free (prov_name);
+ MHD_queue_response(conn,rc,resp);
+ MHD_destroy_response(resp);
+
+ free_ms(ms);
+ return MHD_YES;
+}
+
+static int
+proxy_add_prov (void *cctx, struct MHD_Connection *conn, const char *url,
+ const char *method, const char *version, const char *data,
+ size_t *data_size, void **rctx)
+{
+ DPRINTF("PROXY ADD PROVIDER %sn",url);
+ struct MHD_Response *resp;
+ my_state *ms = *rctx;
+
+ (void)cctx;
+ (void)method;
+ (void)version;
+
+ if (ms->state == MS_NEW) {
+ ms->state = MS_NORMAL;
+ ms->url = (char *)url;
+ ms->dict = g_hash_table_new_full(
+ g_str_hash,g_str_equal,free,free);
+ ms->cleanup |= CLEANUP_DICT;
+ ms->post = MHD_create_post_processor(conn,4096,
+ prov_iterator,ms->dict);
+ ms->cleanup |= CLEANUP_POST;
+ }
+ else if (*data_size) {
+ MHD_post_process(ms->post,data,*data_size);
+ *data_size = 0;
+ }
+ else {
+ int rc = MHD_HTTP_BAD_REQUEST;
+ char *prov_name = url_to_provider_name (url);
+ /* We're about to insert "name -> $prov_name".
+ Ensure there is no "name" key already there. */
+ const char *name = g_hash_table_lookup (ms->dict, "name");
+ if (name) {
+ fprintf(stderr,
+ "add_provider: do not specify name: name=%sn",
+ name);
+ return MHD_NO;
+ // FIXME: be careful that this does not leak "ms"
+ }
+ // FIXME: unchecked strdup
+ g_hash_table_insert(ms->dict,strdup("name"),prov_name);
+
+ if (validate_provider (ms->dict)) {
+ if (!add_provider (ms->dict)) {
+ DPRINTF("add provider failedn");
+ } else {
+ rc = MHD_HTTP_OK;
+ }
+ }
+ else {
+ DPRINTF("invalid providern");
+ }
+ resp = MHD_create_response_from_data(0,NULL,MHD_NO,MHD_NO);
+ if (!resp) {
+ fprintf(stderr,"MHD_crfd failedn");
+ return MHD_NO;
+ }
+ MHD_queue_response(conn,rc,resp);
+ MHD_destroy_response(resp);
+ free_ms(ms);
+ }
+
+ return MHD_YES;
+}
+
static int
proxy_create_bucket (void *cctx, struct MHD_Connection *conn, const char *url,
const char *method, const char *version, const char *data,
@@ -1753,6 +1877,10 @@ static const rule my_rules[] = {
"GET", URL_PROVLIST, proxy_list_provs },
{ /* update a provider */
"POST", URL_PROVLIST, proxy_update_prov },
+ { /* create a provider */
+ "POST", URL_PROVIDER, proxy_add_prov },
+ { /* delete a provider */
+ "DELETE", URL_PROVIDER, proxy_delete_prov },
{ NULL, 0, NULL }
};
@@ -1806,6 +1934,12 @@ parse_url (const char *url, my_state *ms)
}
}
+ if (eindex == URL_OBJECT
+ && !strcmp (parts[URL_BUCKET], "_providers"))
+ eindex = URL_PROVIDER;
+
+ DPRINTF("parse_url: %d: %s %s %s", eindex, parts[URL_BUCKET],
+ parts[URL_OBJECT], parts[URL_ATTR]);
return eindex;
}
diff --git a/setup.c b/setup.c
index 2a03f40..86061d1 100644
--- a/setup.c
+++ b/setup.c
@@ -27,6 +27,7 @@
#include <string.h>
#include <strings.h>
#include <unistd.h>
+#include <assert.h>
#include <jansson.h>
@@ -71,8 +72,74 @@ static GHashTable *prov_hash = NULL;
provider_t *main_prov = NULL;
provider_t *master_prov = NULL;
+int
+validate_provider (GHashTable *h)
+{
+ const char *name = g_hash_table_lookup (h, "name");
+ assert (name);
+ const char *type = g_hash_table_lookup (h, "type");
+ if (type == NULL) {
+ error (0, 0, "provider %s has no type", name);
+ return 0;
+ }
+
+ unsigned int needs;
+ if (!strcasecmp(type,"s3") || !strcasecmp(type,"cf")) {
+ needs = NEED_SERVER | NEED_CREDS;
+ } else if (!strcasecmp(type,"http")) {
+ needs = NEED_SERVER;
+ } else if (!strcasecmp(type,"fs")) {
+ needs = NEED_PATH;
+ } else {
+ error (0, 0, "provider %s has invalid type: %s", name, type);
+ return 0;
+ }
+
+ int ok = 1;
+ if (needs & NEED_SERVER) {
+ const char *host = g_hash_table_lookup (h, "host");
+ if (!host) {
+ error (0, 0, "%s: %s-provider requires a host", name, type);
+ ok = 0;
+ }
+ const char *port = g_hash_table_lookup (h, "port");
+ if (!port) {
+ error (0, 0, "%s: %s-provider requires a port", name, type);
+ ok = 0;
+ }
+ // ensure port is a positive integer with 5 or fewer digits
+ if (5 < strlen (port) || strcspn (port, "0123456789")) {
+ error (0, 0, "%s: %s-provider: invalid port: %s", name, type, port);
+ ok = 0;
+ }
+ }
+
+ if (needs & NEED_CREDS) {
+ const char *key = g_hash_table_lookup (h, "key");
+ if (!key) {
+ error (0, 0, "%s: %s-provider requires a key", name, type);
+ ok = 0;
+ }
+ const char *secret = g_hash_table_lookup (h, "secret");
+ if (!secret) {
+ error (0, 0, "%s: %s-provider requires a secret", name, type);
+ ok = 0;
+ }
+ }
+
+ if (needs & NEED_PATH) {
+ const char *path = g_hash_table_lookup (h, "path");
+ if (!path) {
+ error (0, 0, "%s: %s-provider requires a path", name, type);
+ ok = 0;
+ }
+ }
+
+ return ok;
+}
+
static int
-validate_server (unsigned int i)
+json_validate_server (unsigned int i)
{
json_t *server;
json_t *elem;
@@ -209,6 +276,7 @@ convert_provider (int i, provider_t *out)
out->username = dup_json_string(server,"key");
out->password = dup_json_string(server,"secret");
out->path = dup_json_string(server,"path");
+ /* FIXME: detect failed "dup_*" calls. */
/* TBD: do this a cleaner way. */
if (!strcasecmp(out->type,"s3")) {
@@ -231,6 +299,7 @@ convert_provider (int i, provider_t *out)
iter = json_object_iter(server);
while (iter) {
key = json_object_iter_key(iter);
+ error(0,0,"convert-provider: ITER key: %s",key);
if (!is_reserved_attr(key)) {
value = json_string_value(json_object_iter_value(iter));
if (value) {
@@ -249,10 +318,100 @@ convert_provider (int i, provider_t *out)
}
out->token = NULL;
+ out->deleted = 0;
return 1;
}
+int
+add_provider (GHashTable *h)
+{
+ char *name = g_hash_table_lookup (h, "name");
+ assert (name);
+
+ provider_t *prov = calloc (1, sizeof *prov);
+ if (prov == NULL)
+ return 0;
+
+ prov->name = strdup (name);
+ if (prov->name == NULL)
+ goto fail;
+
+ prov->type = g_hash_table_lookup(h,"type");
+ if (prov->type == NULL)
+ goto fail;
+ prov->type = strdup (prov->type);
+ if (prov->type == NULL)
+ goto fail;
+
+ prov->host = g_hash_table_lookup(h,"host");
+ prov->port = atoi(g_hash_table_lookup(h,"port"));
+ /* TBD: change key/secret field names to username/password */
+ prov->username = g_hash_table_lookup(h,"key");
+ prov->password = g_hash_table_lookup(h,"secret");
+ prov->path = g_hash_table_lookup(h,"path");
+
+ if (prov->host)
+ prov->host = strdup (prov->host);
+ if (prov->username)
+ prov->username = strdup (prov->username);
+ if (prov->password)
+ prov->password = strdup (prov->password);
+ if (prov->path)
+ prov->path = strdup (prov->path);
+
+ /* TBD: do this a cleaner way. */
+ if (!strcasecmp(prov->type,"s3"))
+ prov->func_tbl = &s3_func_tbl;
+ else if (!strcasecmp(prov->type,"http"))
+ prov->func_tbl = &curl_func_tbl;
+ else if (!strcasecmp(prov->type,"cf"))
+ prov->func_tbl = &cf_func_tbl;
+ else if (!strcasecmp(prov->type,"fs"))
+ prov->func_tbl = &fs_func_tbl;
+ else
+ prov->func_tbl = &bad_func_tbl;
+
+ prov->attrs = g_hash_table_new_full(g_str_hash,g_str_equal,free,free);
+ // FIXME: can't the above fail?
+
+ GHashTableIter iter;
+ g_hash_table_iter_init (&iter, h);
+ while (1) {
+ gpointer key;
+ gpointer val;
+ if (!g_hash_table_iter_next (&iter, &key, &val))
+ break;
+
+ if (!is_reserved_attr(key)) {
+ if (val) {
+ error(0,0,"no value for %s", (char *)key);
+ continue;
+ }
+ DPRINTF("%p.%s = %sn",prov, (char *)key, (char *)val);
+ g_hash_table_insert(prov->attrs, strdup(key), strdup(val));
+ // FIXME: check strdup for failure
+ }
+ }
+
+ /* Note that we must strdup "name", since here it's a key, but above it's a
+ value. Not using // strdup here would lead to a use-after-free bug. */
+ // FIXME: check strdup for failure
+ g_hash_table_insert(prov_hash,strdup(name),prov);
+
+ return 1;
+
+ fail:
+ free ((char *) prov->name);
+ free ((char *) prov->type);
+ free ((char *) prov->host);
+ free ((char *) prov->username);
+ free ((char *) prov->password);
+ free ((char *) prov->path);
+ free (prov);
+ return 0;
+}
+
static const char *
parse_config_inner (void)
{
@@ -274,7 +433,7 @@ parse_config_inner (void)
}
for (i = 0; i < nservers; ++i) {
- if (!validate_server(i)) {
+ if (!json_validate_server(i)) {
goto err;
}
}
@@ -402,7 +561,7 @@ auto_config(void)
return primary;
}
-const provider_t *
+provider_t *
get_provider (const char *name)
{
if (!prov_hash || !name || (*name == '0')) {
@@ -411,6 +570,18 @@ get_provider (const char *name)
return g_hash_table_lookup(prov_hash,name);
}
+provider_t *
+find_provider (const char *name)
+{
+ if (!prov_hash || !name || (*name == '0')) {
+ return NULL;
+ }
+
+ provider_t *p = g_hash_table_lookup(prov_hash, name);
+
+ return p;
+}
+
const char *
get_provider_value (const provider_t *prov, const char *fname)
{
diff --git a/setup.h b/setup.h
index e70cffa..11d2207 100644
--- a/setup.h
+++ b/setup.h
@@ -26,6 +26,7 @@ typedef struct _provider {
const char *type;
const char *host;
int port;
+ int deleted;
const char *username;
const char *password;
const char *path;
@@ -38,14 +39,17 @@ provider_t *main_prov;
provider_t *master_prov;
const char *parse_config (char *);
-const provider_t *get_provider (const char *name);
-void update_provider (const char *provname,
+provider_t *get_provider (const char *name);
+void update_provider (const char *provname,
const char *username,
const char *password);
const char *get_provider_value (const provider_t *prov,
const char *fname);
void init_prov_iter (GHashTableIter *iter);
-const char *auto_config (void);
+const char *auto_config (void);
+int validate_provider (GHashTable *h);
+provider_t *find_provider (const char *name);
+int add_provider (GHashTable *h);
#endif
diff --git a/t/basic b/t/basic
index 6a30fcc..fc42ac4 100644
--- a/t/basic
+++ b/t/basic
@@ -311,14 +311,45 @@ echo bye | curl -f -T - $bucket/trunc_test || fail=1
cat FS/b1/trunc_test
test "$(cat FS/b1/trunc_test)" = bye || fail=1
+# TBD: add attribute-delete tests when that functionality is implemented
+
+# TBD: add white-box tests for attributes in mongo
+
+# Add a provider:
+p1_url=http://localhost:$port/_providers/PROVIDER-1
+curl -d type=s3 -dhost=localhost -dport=80 -dkey=u -dsecret=p + $p1_url || fail=1
+
+# Ensure it was added
+curl http://localhost:$port/_providers > p || fail=1
+grep PROVIDER-1 p || fail=1
+
+# Add another provider:
+p2_url=http://localhost:$port/_providers/PROVIDER-2
+curl -dtype=http -dhost=localhost -dport=9091 $p2_url || fail=1
+# Ensure it was added.
+curl http://localhost:$port/_providers > p || fail=1
+grep PROVIDER-2 p || fail=1
+
+# Delete a provider.
+curl -f -X DELETE $p2_url 2> p || fail=1
+# Ensure it was deleted.
+curl http://localhost:$port/_providers > p || fail=1
+grep PROVIDER-2 p && { warn_ $ME_: provider deletion failed; fail=1; }
+
+# Delete a non-existent provider.
+curl -f -X DELETE http://localhost:$port/_providers/no-such
+test $? = 22 || fail=1
+# FIXME ensure it fails
+cat p
+
+curl http://localhost:$port/_providers > p || fail=1
+cat p
+
# Test "headless" operation (no access to metadata DB).
kill -9 $mongo_pid
cleanup_() { kill $iwhd_pid; }
curl $bucket/attr_put > f3copy
test "$(cat f3copy)" = "nothing" || fail=1
-# TBD: add attribute-delete tests when that functionality is implemented
-
-# TBD: add white-box tests for attributes in mongo
-
Exit $fail
-----------------------------------------------------------------------
repo.or.cz automatic notification. Contact project admin jim(a)meyering.net
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
iwhd.git ("image warehouse daemon")
13 years, 6 months
[repo.or.cz] iwhd.git branch master updated: v0.0-274-g4d64b21
by Jim Meyering
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project iwhd.git.
The branch, master has been updated
via 4d64b213464a20f4c28921b3ed68c0240d9c99dd (commit)
via 162167233c1f92809060154dbed4be3146c5f504 (commit)
via 7ffa21ac39d711bfab5da7b847445c1b5db3e9e8 (commit)
via c4597f7fc4990f0dc4dc0ae6c5be116e9ea1dd8b (commit)
via 8dfe3f897c05855f3d39fd30e7e047ce952b5531 (commit)
via c059c0e95df17316d60bd70974f3b029602738bd (commit)
via 1fbd0757294489f70137770e44ab20fdb4f467c4 (commit)
via 371b2b03a156deb7c0190b4a463eaf164f609bbb (commit)
via 90fdaa34458e2ae186ff5f2820c6fa087fb10951 (commit)
via 83aef2f0bce333bff50105af9fd86562ef112275 (commit)
via 5876b06bee5a9412ba372f0d72b4bb629abacc6a (commit)
via b25dcd02204c034521a47bd0678a591004638868 (commit)
via 652d185244963c54f102c1b106fab3a5bb46259e (commit)
via 25a002a745a999ea9a4e58def2bf1298737d8643 (commit)
via 1c518138da2b987619c76eac0eb3020894e1becb (commit)
via 2af22e15f0a95fb1e9b32557a4097688794fc532 (commit)
via 0d9cd613e081776874dabcf298b450dde95c093e (commit)
via 75c31581176c3d405fb075e997f80a4f51f1b00a (commit)
via 8cf7615fec61f889635255bf8158c22ba64dc392 (commit)
via c615729c5fb2877fea6e0383fb2bda29db570f23 (commit)
via 693fc8a86fc54bd2f29c31ab2cefa1d86add8767 (commit)
via 839172bc2f35f8ba37ab59bdd25ea482a6e86c15 (commit)
via 72b4c4ff6037f506c78b839a48aa88a73fad5a95 (commit)
via c8d0be9f4c70775fca231996d1420e717628cc6c (commit)
via 2bbe861de39bc6e0e3220fefcbbb40dbeaa84e1d (commit)
via 88b1d8ae3d489a1df5d687a3422627d8cfc31f7b (commit)
from df00ac3954bf66d4f6026f6dc787514f6e76a96c (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
-----------------------------------------------------------------------
Summary of changes:
.gitignore | 2 +
.gitmodules | 3 +
.x-sc_trailing_blank | 1 +
GNUmakefile | 21 -
INSTALL | 365 -----------------
Makefile.am | 39 ++-
auto.c | 8 +-
autogen.sh | 3 +-
backend.c | 10 +-
bootstrap | 858 +++++++++++++++++++++++++++++++++++++++++
bootstrap.conf | 101 +++++
cfg.mk | 66 ++++
configure.ac | 109 +++++-
doc/.gitignore | 1 +
doc/warehouse_api_final.md | 8 +-
gnulib | 1 +
gnulib-tests/.gitignore | 97 +++++
gnulib-tests/Makefile.am | 3 +
iwh.h | 4 +
lib/.gitignore | 94 +++++
lib/Makefile.am | 23 ++
{ax => m4}/ax_boost_base.m4 | 10 +-
{ax => m4}/ax_boost_system.m4 | 12 +-
{ax => m4}/ax_boost_thread.m4 | 12 +-
mpipe.h | 1 -
notes.txt | 1 -
qparser.y | 38 +--
replica.c | 8 -
replica.h | 2 +
rest.c | 23 +-
setup.c | 7 +-
t/Makefile.am | 3 +-
t/replication | 18 +-
33 files changed, 1438 insertions(+), 514 deletions(-)
create mode 100644 .gitmodules
create mode 100644 .x-sc_trailing_blank
delete mode 100644 GNUmakefile
delete mode 100644 INSTALL
create mode 100755 bootstrap
create mode 100644 bootstrap.conf
create mode 100644 cfg.mk
create mode 100644 doc/.gitignore
create mode 160000 gnulib
create mode 100644 gnulib-tests/.gitignore
create mode 100644 gnulib-tests/Makefile.am
create mode 100644 lib/.gitignore
create mode 100644 lib/Makefile.am
rename {ax => m4}/ax_boost_base.m4 (97%)
rename {ax => m4}/ax_boost_system.m4 (92%)
rename {ax => m4}/ax_boost_thread.m4 (94%)
repo.or.cz automatic notification. Contact project admin jim(a)meyering.net
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
iwhd.git ("image warehouse daemon")
13 years, 6 months
[repo.or.cz] iwhd.git branch gnulib updated: v0.0-274-g4d64b21
by Jim Meyering
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project iwhd.git.
The branch, gnulib has been updated
via 4d64b213464a20f4c28921b3ed68c0240d9c99dd (commit)
from 162167233c1f92809060154dbed4be3146c5f504 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://repo.or.cz/w/iwhd.git/commit/4d64b213464a20f4c28921b3ed68c0240d9c99dd
commit 4d64b213464a20f4c28921b3ed68c0240d9c99dd
Author: Jim Meyering <meyering(a)redhat.com>
Date: Thu Dec 16 16:55:54 2010 +0100
build: make the "rpm" rule work once again
* Makefile.am (rpm): Accommodate a version number string like
"0.0.273-1621", that contains a hyphen: s/-/./
(iwhd.spec): Depend on Makefile, not Makefile.am, so that
a version number change provokes an update.
diff --git a/Makefile.am b/Makefile.am
index fa7edb8..4360dd4 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -58,18 +58,38 @@ iwhd_SOURCES =
EXTRA_iwhd_SOURCES = qlexer.l
+VERSION_no_hyphen = $$(echo $(VERSION)|tr - _)
+
MOSTLYCLEANFILES += iwhd.spec
MAINTAINERCLEANFILES += iwhd.spec
-iwhd.spec: iwhd.spec.in Makefile.am
+iwhd.spec: iwhd.spec.in Makefile
rm -f $@-t $@
- sed 's/@''VERSION@/$(VERSION)/' $< > $@-t
+ v=$$(echo $(VERSION)|tr - .); + sed 's/[@]VERSION@/'"$$v"/ $< > $@-t
chmod a=r $@-t
mv $@-t $@
+# The following rule accommodates pre-release version number strings
+# like "0.0.273-1621" that contain a "-". Repack the tarball
+# to one with "." substituted for any - in the version string.
.PHONY: rpm
rpm: dist iwhd.spec
chmod 644 $(distdir).tar.gz
- rpmbuild -ta $(distdir).tar.gz
+ case $(VERSION) in + *-*) + v=$$(echo $(VERSION)|tr - .); + base=$(PACKAGE)-$$v; + tgz=$$base.tar.gz; + tar xf $(distdir).tar.gz + && rm -rf $$base $$tgz + && mv $(distdir) $$base + && tar -czf - $$base > $$tgz + && rpmbuild -ta $$tgz; e=$$? + rm -rf $$base $$tgz; + exit $$e + ;; + *) rpmbuild -ta $(distdir).tar.gz ;; + esac
iwhd_CPPFLAGS = $(HAIL_CFLAGS) -I$(top_srcdir)/lib
iwhd_LDADD =
-----------------------------------------------------------------------
Summary of changes:
Makefile.am | 26 +++++++++++++++++++++++---
1 files changed, 23 insertions(+), 3 deletions(-)
repo.or.cz automatic notification. Contact project admin jim(a)meyering.net
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
iwhd.git ("image warehouse daemon")
13 years, 6 months
[repo.or.cz] iwhd.git branch gnulib updated: v0.0-273-g1621672
by Jim Meyering
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project iwhd.git.
The branch, gnulib has been updated
via 162167233c1f92809060154dbed4be3146c5f504 (commit)
from 7ffa21ac39d711bfab5da7b847445c1b5db3e9e8 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://repo.or.cz/w/iwhd.git/commit/162167233c1f92809060154dbed4be3146c5f504
commit 162167233c1f92809060154dbed4be3146c5f504
Author: Jim Meyering <meyering(a)redhat.com>
Date: Thu Dec 16 13:41:29 2010 +0100
maint: make autogen.sh invoke bootstrap
* autogen.sh: Invoke bootstrap.
diff --git a/autogen.sh b/autogen.sh
index 5f55a4b..56f9b9e 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -1,4 +1,3 @@
#!/bin/bash
-test -f ChangeLog || touch ChangeLog
-autoreconf -iv
+./bootstrap "$@"
-----------------------------------------------------------------------
Summary of changes:
autogen.sh | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
repo.or.cz automatic notification. Contact project admin jim(a)meyering.net
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
iwhd.git ("image warehouse daemon")
13 years, 6 months
[repo.or.cz] iwhd.git branch gnulib created: v0.0-272-g7ffa21a
by Jim Meyering
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project iwhd.git.
The branch, gnulib has been created
at 7ffa21ac39d711bfab5da7b847445c1b5db3e9e8 (commit)
- Log -----------------------------------------------------------------
http://repo.or.cz/w/iwhd.git/commit/7ffa21ac39d711bfab5da7b847445c1b5db3e9e8
commit 7ffa21ac39d711bfab5da7b847445c1b5db3e9e8
Author: Jim Meyering <meyering(a)redhat.com>
Date: Thu Dec 16 12:23:25 2010 +0100
maint: avoid const-related warnings
* auto.c: Impossible to avoid without casts. Add const attributes
and then add two casts.
* setup.c (dup_json_string): Add const attribute to each parameter.
diff --git a/auto.c b/auto.c
index b428bce..50eb1c5 100644
--- a/auto.c
+++ b/auto.c
@@ -24,7 +24,7 @@
static int auto_db_port;
static char auto_arg_port[10];
-static char *auto_arg_mongod[] = {
+static const char *const auto_arg_mongod[] = {
"mongod",
"--port", auto_arg_port,
"--dbpath", AUTO_DIR_DB,
@@ -36,7 +36,7 @@ static char *auto_arg_mongod[] = {
};
/* The --quiet option in mongod is useless, so redirect instead. */
-static char *auto_arg_mongod_quiet[] = {
+static const char *const auto_arg_mongod_quiet[] = {
"mongod",
"--port", auto_arg_port,
"--dbpath", AUTO_DIR_DB,
@@ -270,7 +270,9 @@ auto_start (int dbport)
}
DPRINTF("auto-starting mongodn");
- earg = verbose ? auto_arg_mongod : auto_arg_mongod_quiet;
+ earg = (verbose
+ ? (char **) auto_arg_mongod
+ : (char **) auto_arg_mongod_quiet);
pid = auto_spawn(AUTO_BIN_MONGOD, earg);
if (pid < 0)
return -1;
diff --git a/setup.c b/setup.c
index 9acce0a..2a03f40 100644
--- a/setup.c
+++ b/setup.c
@@ -157,7 +157,7 @@ validate_server (unsigned int i)
}
static const char *
-dup_json_string (json_t *obj, char *field)
+dup_json_string (const json_t *obj, const char *field)
{
const char *tmp;
http://repo.or.cz/w/iwhd.git/commit/c4597f7fc4990f0dc4dc0ae6c5be116e9ea1dd8b
commit c4597f7fc4990f0dc4dc0ae6c5be116e9ea1dd8b
Author: Jim Meyering <meyering(a)redhat.com>
Date: Thu Dec 16 12:20:55 2010 +0100
maint: avoid warning about "noreturn" function
* iwh.h (ATTRIBUTE_NORETURN): Define
* rest.c (usage): Use it here, to avoid a warning.
diff --git a/iwh.h b/iwh.h
index d6475de..c862273 100644
--- a/iwh.h
+++ b/iwh.h
@@ -45,6 +45,10 @@ GLOBAL(const char *, me, "here");
# define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
#endif
+#ifndef ATTRIBUTE_NORETURN
+# define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
+#endif
+
/*
* Common parts of autostart
*
diff --git a/rest.c b/rest.c
index 6f98106..ea8b289 100644
--- a/rest.c
+++ b/rest.c
@@ -1892,7 +1892,7 @@ static const struct option my_options[] = {
{ NULL, 0, NULL, '0' }
};
-static void
+static void ATTRIBUTE_NORETURN
usage (int status)
{
if (status != EXIT_SUCCESS)
http://repo.or.cz/w/iwhd.git/commit/8dfe3f897c05855f3d39fd30e7e047ce952b5531
commit 8dfe3f897c05855f3d39fd30e7e047ce952b5531
Author: Jim Meyering <meyering(a)redhat.com>
Date: Thu Dec 16 12:18:10 2010 +0100
maint: avoid theoretical risk of signed overflow
* rest.c (main): Declare "autostart" as bool and set to true or false
rather than incrementing or setting to 0.
diff --git a/rest.c b/rest.c
index 4ae4ff2..6f98106 100644
--- a/rest.c
+++ b/rest.c
@@ -1935,14 +1935,14 @@ main (int argc, char **argv)
sem_t the_sem;
char *stctx = NULL;
char *port_tmp;
- int autostart = 0;
+ bool autostart = false;
set_program_name (argv[0]);
atexit (close_stdout);
for (;;) switch (getopt_long(argc,argv,"ac:d:m:p:v",my_options,NULL)) {
case 'a':
- ++autostart;
+ autostart = true;
break;
case 'c':
cfg_file = optarg;
http://repo.or.cz/w/iwhd.git/commit/c059c0e95df17316d60bd70974f3b029602738bd
commit c059c0e95df17316d60bd70974f3b029602738bd
Author: Jim Meyering <meyering(a)redhat.com>
Date: Thu Dec 16 12:13:23 2010 +0100
maint: accommodate new, stricter warnings
* rest.c (struct): Avoid const-related warnings.
diff --git a/rest.c b/rest.c
index a5cd09b..4ae4ff2 100644
--- a/rest.c
+++ b/rest.c
@@ -61,7 +61,7 @@ typedef enum {
} url_type;
typedef struct {
- char *method;
+ const char *method;
url_type utype;
MHD_AccessHandlerCallback handler;
} rule;
@@ -940,8 +940,8 @@ proxy_delete (void *cctx, struct MHD_Connection *conn, const char *url,
/* TBD: get actual bucket list */
typedef struct {
- char *rel;
- char *link;
+ const char *rel;
+ const char *link;
} fake_bucket_t;
/* FIXME: ensure that the RHS values here stay in sync with those
http://repo.or.cz/w/iwhd.git/commit/1fbd0757294489f70137770e44ab20fdb4f467c4
commit 1fbd0757294489f70137770e44ab20fdb4f467c4
Author: Jim Meyering <meyering(a)redhat.com>
Date: Thu Dec 16 11:58:46 2010 +0100
maint: declare follow_link in replica.h
* replica.h (follow_link): Declare.
diff --git a/replica.h b/replica.h
index ceaa5ed..67fb38b 100644
--- a/replica.h
+++ b/replica.h
@@ -25,4 +25,6 @@ void replicate_delete (const char *url, my_state *ms);
void replicate_bcreate (const char *bucket, my_state *ms);
int get_rep_count (void);
+char *follow_link (char *object, const char *key);
+
#endif
http://repo.or.cz/w/iwhd.git/commit/371b2b03a156deb7c0190b4a463eaf164f609bbb
commit 371b2b03a156deb7c0190b4a463eaf164f609bbb
Author: Jim Meyering <meyering(a)redhat.com>
Date: Thu Dec 16 11:56:46 2010 +0100
maint: declare cf_put_child to be static
* backend.c (cf_put_child): Make "static" to avoid a warning.
diff --git a/backend.c b/backend.c
index b17f4ce..c18d895 100644
--- a/backend.c
+++ b/backend.c
@@ -1025,7 +1025,7 @@ cf_get_child (void * ctx)
}
/* Start a CloudFiles _consumer_. */
-void *
+static void *
cf_put_child (void * ctx)
{
pipe_private *pp = ctx;
http://repo.or.cz/w/iwhd.git/commit/90fdaa34458e2ae186ff5f2820c6fa087fb10951
commit 90fdaa34458e2ae186ff5f2820c6fa087fb10951
Author: Jim Meyering <meyering(a)redhat.com>
Date: Thu Dec 16 11:54:16 2010 +0100
maint: remove unused definitions
* replica.c (ADDR_SIZE): Remove unused definition.
(SVC_ACC_SIZE, HEADER_SIZE): Likewise.
* setup.c (NEED_NONE): Likewise.
diff --git a/replica.c b/replica.c
index 58544d4..f0b4b51 100644
--- a/replica.c
+++ b/replica.c
@@ -36,11 +36,6 @@
#include "meta.h"
#include "replica.h"
-/* Sizes for internal string buffers. */
-#define ADDR_SIZE 1024
-#define SVC_ACC_SIZE 128
-#define HEADER_SIZE 64
-
typedef enum {
REPL_PUT, /* store an object */
REPL_ODELETE, /* delete an object */
diff --git a/setup.c b/setup.c
index 42b46a5..9acce0a 100644
--- a/setup.c
+++ b/setup.c
@@ -54,7 +54,6 @@
*/
/* Bitfield for things to check in validate_server */
-#define NEED_NONE 0
#define NEED_SERVER 0x00000001
#define NEED_CREDS 0x00000002
#define NEED_PATH 0x00000004
http://repo.or.cz/w/iwhd.git/commit/83aef2f0bce333bff50105af9fd86562ef112275
commit 83aef2f0bce333bff50105af9fd86562ef112275
Author: Jim Meyering <meyering(a)redhat.com>
Date: Thu Dec 16 11:52:30 2010 +0100
do not perform arithmetic on void* pointers
* backend.c (http_put_cons, fs_put_child): Cast to (char*) first.
* rest.c (proxy_get_cons): Likewise.
diff --git a/backend.c b/backend.c
index 6e9a2cd..b17f4ce 100644
--- a/backend.c
+++ b/backend.c
@@ -195,7 +195,7 @@ http_put_cons (void *ptr, size_t size, size_t nmemb, void *stream)
if (done > total) {
done = total;
}
- memcpy(ptr,ps->data_ptr+pp->offset,done);
+ memcpy(ptr,(char *)(ps->data_ptr)+pp->offset,done);
pp->offset += done;
DPRINTF("consumer copied %zu, new offset %zun",
done, pp->offset);
@@ -1262,7 +1262,8 @@ fs_put_child (void * ctx)
while (pipe_cons_wait(pp)) {
for (offset = 0; offset < ps->data_len; offset += bytes) {
bytes = write(fd,
- ps->data_ptr+offset,ps->data_len-offset);
+ (char *)(ps->data_ptr)+offset,
+ ps->data_len-offset);
if (bytes <= 0) {
if (bytes < 0) {
error (0, errno, "%s: write failed",
diff --git a/rest.c b/rest.c
index 2ff063b..a5cd09b 100644
--- a/rest.c
+++ b/rest.c
@@ -239,7 +239,7 @@ proxy_get_cons (void *ctx, uint64_t pos, char *buf, size_t max)
if ((size_t) done > max) {
done = max;
}
- memcpy(buf,ps->data_ptr+pp->offset,done);
+ memcpy(buf,(char *)(ps->data_ptr)+pp->offset,done);
pp->offset += done;
DPRINTF("consumer copied %zu, new offset %zun",
done, pp->offset);
http://repo.or.cz/w/iwhd.git/commit/5876b06bee5a9412ba372f0d72b4bb629abacc6a
commit 5876b06bee5a9412ba372f0d72b4bb629abacc6a
Author: Jim Meyering <meyering(a)redhat.com>
Date: Thu Dec 16 11:39:41 2010 +0100
build: support configure-time --enable-gcc-warnings option
* configure.ac: Handle new --enable-gcc-warnings option.
* Makefile.am (AM_CFLAGS): Use configure-determined
$(WARN_CFLAGS) $(WERROR_CFLAGS), rather than hard-coded ones.
diff --git a/Makefile.am b/Makefile.am
index 323bcd2..fa7edb8 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -13,8 +13,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-AM_CFLAGS = -W -Wall -Wextra -Wno-unused -Wformat-security - -Wp,-D_FORTIFY_SOURCE=2 -O2 -fdiagnostics-show-option
+AM_CFLAGS = $(WARN_CFLAGS) $(WERROR_CFLAGS)
# FIXME: don't hard-code 2.0
AM_CPPFLAGS = -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include
diff --git a/configure.ac b/configure.ac
index 2e1e5a1..bfd6f5d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -79,6 +79,90 @@ AX_BOOST_BASE
AX_BOOST_SYSTEM
AX_BOOST_THREAD
+AC_ARG_ENABLE([gcc-warnings],
+ [AS_HELP_STRING([--enable-gcc-warnings],
+ [turn on lots of GCC warnings (for developers)])],
+ [case $enableval in
+ yes|no) ;;
+ *) AC_MSG_ERROR([bad value $enableval for gcc-warnings option]) ;;
+ esac
+ gl_gcc_warnings=$enableval],
+ [gl_gcc_warnings=no]
+)
+
+if test "$gl_gcc_warnings" = yes; then
+ gl_WARN_ADD([-Werror], [WERROR_CFLAGS])
+ AC_SUBST([WERROR_CFLAGS])
+
+ nw=
+ # This, $nw, is the list of warnings we disable.
+ nw="$nw -Wdeclaration-after-statement" # too useful to forbid
+ nw="$nw -Waggregate-return" # anachronistic
+ nw="$nw -Wlong-long" # C90 is anachronistic (lib/gethrxtime.h)
+ nw="$nw -Wc++-compat" # We don't care about C++ compilers
+ nw="$nw -Wundef" # Warns on '#if GNULIB_FOO' etc in gnulib
+ nw="$nw -Wtraditional" # Warns on #elif which we use often
+ nw="$nw -Wcast-qual" # Too many warnings for now
+ nw="$nw -Wconversion" # Too many warnings for now
+ nw="$nw -Wsystem-headers" # Don't let system headers trigger warnings
+ nw="$nw -Wsign-conversion" # Too many warnings for now
+ nw="$nw -Wtraditional-conversion" # Too many warnings for now
+ nw="$nw -Wunreachable-code" # Too many warnings for now
+ nw="$nw -Wunused-macros" # bison-generated
+ nw="$nw -Wpadded" # Our structs are not padded
+ nw="$nw -Wredundant-decls" # openat.h declares e.g., mkdirat
+ nw="$nw -Wlogical-op" # any use of fwrite provokes this
+ nw="$nw -Wformat-nonliteral" # who.c and pinky.c strftime uses
+ nw="$nw -Wvla" # warnings in gettext.h
+ nw="$nw -Wnested-externs" # use of XARGMATCH/verify_function__
+ nw="$nw -Wswitch-enum" # Too many warnings for now
+ nw="$nw -Wswitch-default" # Too many warnings for now
+ nw="$nw -Wstack-protector" # not worth working around
+ nw="$nw -Wstrict-overflow" # in bison-generated code
+ nw="$nw -Wunsafe-loop-optimizations" # in bison-generated code
+ nw="$nw -Wmissing-noreturn" # yy_fatal_error in flex-generated code
+
+ gl_MANYWARN_ALL_GCC([ws])
+ gl_MANYWARN_COMPLEMENT([ws], [$ws], [$nw])
+ for w in $ws; do
+ gl_WARN_ADD([$w])
+ done
+ gl_WARN_ADD([-Wno-unused])
+ gl_WARN_ADD([-Wno-missing-field-initializers]) # We need this one
+ gl_WARN_ADD([-Wno-sign-compare]) # Too many warnings for now
+ gl_WARN_ADD([-Wno-unused-parameter]) # Too many warnings for now
+
+ # In spite of excluding -Wlogical-op above, it is enabled, as of
+ # gcc 4.5.0 20090517, and it provokes warnings in cat.c, dd.c, truncate.c
+ gl_WARN_ADD([-Wno-logical-op])
+
+ gl_WARN_ADD([-fdiagnostics-show-option])
+ gl_WARN_ADD([-funit-at-a-time])
+
+ AC_SUBST([WARN_CFLAGS])
+
+ AC_DEFINE([lint], [1], [Define to 1 if the compiler is checking for lint.])
+ AC_DEFINE([_FORTIFY_SOURCE], [2],
+ [enable compile-time and run-time bounds-checking, and some warnings])
+ AC_DEFINE([GNULIB_PORTCHECK], [1], [enable some gnulib portability checks])
+
+ # We use a slightly smaller set of warning options for lib/.
+ # Remove the following and save the result in GNULIB_WARN_CFLAGS.
+ nw=
+ nw="$nw -Wuninitialized"
+ nw="$nw -Wmissing-prototypes"
+ nw="$nw -Wold-style-definition"
+ gl_MANYWARN_COMPLEMENT([GNULIB_WARN_CFLAGS], [$WARN_CFLAGS], [$nw])
+ AC_SUBST([GNULIB_WARN_CFLAGS])
+
+ # For gnulib-tests, the set is slightly smaller still.
+ nw=
+ nw="$nw -Wstrict-prototypes"
+ gl_MANYWARN_COMPLEMENT([GNULIB_TEST_WARN_CFLAGS],
+ [$GNULIB_WARN_CFLAGS], [$nw])
+ AC_SUBST([GNULIB_TEST_WARN_CFLAGS])
+fi
+
AC_CONFIG_FILES([
Makefile
gnulib-tests/Makefile
http://repo.or.cz/w/iwhd.git/commit/b25dcd02204c034521a47bd0678a591004638868
commit b25dcd02204c034521a47bd0678a591004638868
Author: Jim Meyering <meyering(a)redhat.com>
Date: Wed Dec 15 16:01:07 2010 +0100
clean-up: don't define xmalloc, xstrdup, etc. -- use gnulib's definitions
* qparser.y [PARSER_UNIT_TEST]: Include "xalloc.h".
(xalloc_die, xmalloc, xmemdup, xstrdup): Remove definitions.
* t/Makefile.am (parser_CPPFLAGS): Append for xalloc.h.
(parser_LDADD): Link with gnulib.
diff --git a/qparser.y b/qparser.y
index 8e5445e..64f025a 100644
--- a/qparser.y
+++ b/qparser.y
@@ -255,43 +255,7 @@ paren_expr:
#if defined PARSER_UNIT_TEST
-static void
-xalloc_die (void)
-{
- error (EXIT_FAILURE, 0, "%s", "memory exhausted");
-
- /* The `noreturn' cannot be given to error, since it may return if
- its first argument is 0. To help compilers understand the
- xalloc_die does not return, call abort. Also, the abort is a
- safety feature if exit_failure is 0 (which shouldn't happen). */
- abort ();
-}
-
-/* Allocate N bytes of memory dynamically, with error checking. */
-static void *
-xmalloc (size_t n)
-{
- void *p = malloc (n);
- if (!p && n != 0)
- xalloc_die ();
- return p;
-}
-
-/* Clone an object P of size S, with error checking. There's no need
- for xnmemdup (P, N, S), since xmemdup (P, N * S) works without any
- need for an arithmetic overflow check. */
-static void *
-xmemdup (void const *p, size_t s)
-{
- return memcpy (xmalloc (s), p, s);
-}
-
-/* Clone STRING. */
-static char *
-xstrdup (char const *string)
-{
- return xmemdup (string, strlen (string) + 1);
-}
+#include "xalloc.h"
static const struct { char *name; char *value; } hacked_obj_fields[] = {
/* Fake object fields for generic unit testing. */
diff --git a/t/Makefile.am b/t/Makefile.am
index c2a0af6..87fe3e4 100644
--- a/t/Makefile.am
+++ b/t/Makefile.am
@@ -30,7 +30,8 @@ check_PROGRAMS = parser
BUILT_SOURCES =
BUILT_SOURCES += parser.c
MAINTAINERCLEANFILES = $(BUILT_SOURCES)
-parser_CPPFLAGS = -I $(top_srcdir)
+parser_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/lib
+parser_LDADD = -L../lib -liwhd
parser.c: Makefile.am
rm -f $@-t $@
http://repo.or.cz/w/iwhd.git/commit/652d185244963c54f102c1b106fab3a5bb46259e
commit 652d185244963c54f102c1b106fab3a5bb46259e
Author: Jim Meyering <meyering(a)redhat.com>
Date: Wed Dec 15 08:23:52 2010 +0100
bootstrap.conf: mention bison
With this, an attempt to build from cloned-sources without "bison"
will evoke a nice error from bootstrap. Without this, you'd get
a relatively cryptic diagnostic much further down the build road.
diff --git a/bootstrap.conf b/bootstrap.conf
index 8b11421..d194728 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -83,6 +83,7 @@ buildreq=" autoconf 2.62
automake 1.11.1
autopoint -
+bison -
gettext -
git 1.4.4
gzip -
http://repo.or.cz/w/iwhd.git/commit/25a002a745a999ea9a4e58def2bf1298737d8643
commit 25a002a745a999ea9a4e58def2bf1298737d8643
Author: Jim Meyering <meyering(a)redhat.com>
Date: Mon Oct 25 16:35:03 2010 +0200
skip the malloca-tests module; too slow
diff --git a/bootstrap.conf b/bootstrap.conf
index d1fbb3a..8b11421 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -15,6 +15,10 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+# This test is fine, but inordinately slow.
+avoided_gnulib_modules='
+ --avoid=malloca-tests
+'
# gnulib modules used by this package.
gnulib_modules='
@@ -72,7 +76,7 @@ XGETTEXT_OPTIONS=$XGETTEXT_OPTIONS'\ # Automake requires that ChangeLog exist.
test -f ChangeLog || touch ChangeLog || exit 1
-gnulib_tool_option_extras="--tests-base=$bt/gnulib-tests --with-tests"
+gnulib_tool_option_extras="--tests-base=$bt/gnulib-tests --with-tests $avoided_gnulib_modules"
# Build prerequisites
buildreq="
http://repo.or.cz/w/iwhd.git/commit/1c518138da2b987619c76eac0eb3020894e1becb
commit 1c518138da2b987619c76eac0eb3020894e1becb
Author: Jim Meyering <meyering(a)redhat.com>
Date: Mon Oct 25 16:27:19 2010 +0200
avoid redundant const -- move it to the right of "*"
diff --git a/setup.c b/setup.c
index 2296b15..42b46a5 100644
--- a/setup.c
+++ b/setup.c
@@ -173,7 +173,7 @@ dup_json_string (json_t *obj, char *field)
static int
is_reserved_attr (const char *name)
{
- static const char const *rsvd[] = {
+ static char const *const rsvd[] = {
"name", "type", "host", "port", "key", "secret", "path",
NULL
};
http://repo.or.cz/w/iwhd.git/commit/2af22e15f0a95fb1e9b32557a4097688794fc532
commit 2af22e15f0a95fb1e9b32557a4097688794fc532
Author: Jim Meyering <meyering(a)redhat.com>
Date: Mon Oct 25 16:26:03 2010 +0200
disable sc_cast_of_argument_to_free check
diff --git a/cfg.mk b/cfg.mk
index 606f70e..4c493be 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -26,6 +26,7 @@ skip_low_priority = sc_prohibit_strcmp sc_unmarked_diagnostics sc_error_message_uppercase + sc_cast_of_argument_to_free sc_file_system
# Tests not to run as part of "make distcheck".
http://repo.or.cz/w/iwhd.git/commit/0d9cd613e081776874dabcf298b450dde95c093e
commit 0d9cd613e081776874dabcf298b450dde95c093e
Author: Jim Meyering <meyering(a)redhat.com>
Date: Tue Oct 5 18:21:08 2010 +0200
remove GNUmakefile -- now it is pulled from gnulib
diff --git a/GNUmakefile b/GNUmakefile
deleted file mode 100644
index 1622633..0000000
--- a/GNUmakefile
+++ /dev/null
@@ -1,21 +0,0 @@
-# This makefile is used only if you run GNU Make.
-# It is necessary if you modify files in the m4/ directory or
-# want to build targets usually of interest only to the maintainer.
-
-have-Makefile := $(shell test -f Makefile && echo yes)
-
-# If the user runs GNU make but has not yet run ./configure,
-# give them a diagnostic.
-ifeq ($(have-Makefile),yes)
-
-export VERBOSE = yes
-include Makefile
-
-else
-
-all:
- @echo There seems to be no Makefile in this directory.
- @echo "You must run ./configure before running `make'."
- @exit 1
-
-endif
http://repo.or.cz/w/iwhd.git/commit/75c31581176c3d405fb075e997f80a4f51f1b00a
commit 75c31581176c3d405fb075e997f80a4f51f1b00a
Author: Jim Meyering <meyering(a)redhat.com>
Date: Mon Oct 25 15:47:43 2010 +0200
use gnulib's closeout module
diff --git a/rest.c b/rest.c
index 73332f9..2ff063b 100644
--- a/rest.c
+++ b/rest.c
@@ -35,6 +35,7 @@
#include <glib.h>
#include "iwh.h"
+#include "closeout.h"
#include "progname.h"
#include "meta.h"
#include "backend.h"
@@ -1937,6 +1938,7 @@ main (int argc, char **argv)
int autostart = 0;
set_program_name (argv[0]);
+ atexit (close_stdout);
for (;;) switch (getopt_long(argc,argv,"ac:d:m:p:v",my_options,NULL)) {
case 'a':
http://repo.or.cz/w/iwhd.git/commit/8cf7615fec61f889635255bf8158c22ba64dc392
commit 8cf7615fec61f889635255bf8158c22ba64dc392
Author: Jim Meyering <meyering(a)redhat.com>
Date: Fri Oct 1 15:06:56 2010 +0200
use first gnulib module: progname
* cfg.mk: Enable program_name check.
* Makefile.am (iwhd_CPPFLAGS): Use -I$(top_srcdir)/lib.
(iwhd_LDADD): Link with gnulib, aka lib/libiwhd.a.
* rest.c (main): Use set_program_name.
diff --git a/Makefile.am b/Makefile.am
index 7c3d1af..323bcd2 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -16,6 +16,7 @@
AM_CFLAGS = -W -Wall -Wextra -Wno-unused -Wformat-security -Wp,-D_FORTIFY_SOURCE=2 -O2 -fdiagnostics-show-option
+# FIXME: don't hard-code 2.0
AM_CPPFLAGS = -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include
iwhd_YFLAGS = -d
@@ -71,8 +72,9 @@ rpm: dist iwhd.spec
chmod 644 $(distdir).tar.gz
rpmbuild -ta $(distdir).tar.gz
-iwhd_CPPFLAGS = $(HAIL_CFLAGS)
+iwhd_CPPFLAGS = $(HAIL_CFLAGS) -I$(top_srcdir)/lib
iwhd_LDADD = + lib/libiwhd.a -lmongoclient $(BOOST_SYSTEM_LIB) $(BOOST_THREAD_LIB) diff --git a/rest.c b/rest.c
index 68e2f2c..73332f9 100644
--- a/rest.c
+++ b/rest.c
@@ -35,6 +35,7 @@
#include <glib.h>
#include "iwh.h"
+#include "progname.h"
#include "meta.h"
#include "backend.h"
#include "setup.h"
@@ -65,7 +66,6 @@ typedef struct {
} rule;
static unsigned short my_port = MY_PORT;
-const char *program_name;
char *cfg_file = NULL;
static const char *const (reserved_name[]) = {"_default", "_new", "_policy", "_query", NULL};
@@ -1936,7 +1936,7 @@ main (int argc, char **argv)
char *port_tmp;
int autostart = 0;
- program_name = argv[0];
+ set_program_name (argv[0]);
for (;;) switch (getopt_long(argc,argv,"ac:d:m:p:v",my_options,NULL)) {
case 'a':
http://repo.or.cz/w/iwhd.git/commit/c615729c5fb2877fea6e0383fb2bda29db570f23
commit c615729c5fb2877fea6e0383fb2bda29db570f23
Author: Jim Meyering <meyering(a)redhat.com>
Date: Fri Oct 1 14:59:28 2010 +0200
enable no-blank-lines-at-EOF rule
diff --git a/cfg.mk b/cfg.mk
index 7e6d86a..606f70e 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -31,7 +31,6 @@ skip_low_priority = # Tests not to run as part of "make distcheck".
local-checks-to-skip = sc_program_name - sc_prohibit_empty_lines_at_EOF sc_space_tab sc_useless_cpp_parens $(skip_low_priority)
diff --git a/notes.txt b/notes.txt
index e449542..92e4646 100644
--- a/notes.txt
+++ b/notes.txt
@@ -190,4 +190,3 @@ To Do - priority (1 highest) work (5 largest) desc:
5 5 replicated DB
partial-object reads
partial-object writes?
-
http://repo.or.cz/w/iwhd.git/commit/693fc8a86fc54bd2f29c31ab2cefa1d86add8767
commit 693fc8a86fc54bd2f29c31ab2cefa1d86add8767
Author: Jim Meyering <meyering(a)redhat.com>
Date: Fri Oct 1 14:57:45 2010 +0200
enable "test -a/-o" prohibition
diff --git a/cfg.mk b/cfg.mk
index 0fa7fae..7e6d86a 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -32,7 +32,6 @@ skip_low_priority = local-checks-to-skip = sc_program_name sc_prohibit_empty_lines_at_EOF - sc_prohibit_test_minus_ao sc_space_tab sc_useless_cpp_parens $(skip_low_priority)
diff --git a/m4/ax_boost_base.m4 b/m4/ax_boost_base.m4
index d368238..1aa3c2f 100644
--- a/m4/ax_boost_base.m4
+++ b/m4/ax_boost_base.m4
@@ -197,7 +197,7 @@ if test "x$want_boost" = "xyes"; then
stage_version=`echo $version_dir | sed 's/boost_//' | sed 's/_/./g'`
stage_version_shorten=`expr $stage_version : '([[0-9]]*.[[0-9]]*)'`
V_CHECK=`expr $stage_version_shorten >= $_version`
- if test "$V_CHECK" = "1" -a "$ac_boost_lib_path" = "" ; then
+ if test "$V_CHECK" = "1" && test "$ac_boost_lib_path" = "" ; then
AC_MSG_NOTICE(We will use a staged boost library from $BOOST_ROOT)
BOOST_CPPFLAGS="-I$BOOST_ROOT"
BOOST_LDFLAGS="-L$BOOST_ROOT/stage/$libsubdir"
http://repo.or.cz/w/iwhd.git/commit/839172bc2f35f8ba37ab59bdd25ea482a6e86c15
commit 839172bc2f35f8ba37ab59bdd25ea482a6e86c15
Author: Jim Meyering <meyering(a)redhat.com>
Date: Fri Oct 1 14:56:30 2010 +0200
enable "echo -n/-e" prohibition
diff --git a/cfg.mk b/cfg.mk
index da52286..0fa7fae 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -31,7 +31,6 @@ skip_low_priority = # Tests not to run as part of "make distcheck".
local-checks-to-skip = sc_program_name - sc_prohibit_echo_minus_en sc_prohibit_empty_lines_at_EOF sc_prohibit_test_minus_ao sc_space_tab diff --git a/doc/warehouse_api_final.md b/doc/warehouse_api_final.md
index 0747c1b..b5d7294 100644
--- a/doc/warehouse_api_final.md
+++ b/doc/warehouse_api_final.md
@@ -167,7 +167,7 @@ single attribute:
The attribute can also be set with a PUT to the same URL.
- $ echo -n green | curl -T - http://fserver-1:9090/my_bucket/file1/color
+ $ printf green | curl -T - http://fserver-1:9090/my_bucket/file1/color
Lastly, objects and attributes can be deleted (object deletes
are propagated to secondary warehouses).
@@ -213,7 +213,7 @@ Replication Policies
Replication policies are stored as "_policy" attributes on
objects. To set a policy, use the same mechanism as for other attributes.
- $ echo -n '$color == "green"' | curl -T - http://fserver-1:9090/my_bucket/file1/_policy
+ $ printf '$color == "green"' | curl -T - http://fserver-1:9090/my_bucket/file1/_policy
This will cause the warehouse daemon to replicate to all secondary
warehouses whenever the object is changed (including attribute
@@ -235,12 +235,12 @@ what you want for two other reasons:
To specify selective replication, matching object atttributes
with secondary-warehouse attributes, you would do this instead.
- $ echo -n '$color == #color' | curl -T - http://fserver-1:9090/my_bucket/file1/_policy
+ $ printf '$color == #color' | curl -T - http://fserver-1:9090/my_bucket/file1/_policy
To set a default replication policy for all objects within a bucket,
use the "_default" pseudo-object.
- $ echo -n '$color == #color' | curl -T - http://fserver-1:9090/my_bucket/_default/_policy
+ $ printf '$color == #color' | curl -T - http://fserver-1:9090/my_bucket/_default/_policy
This will cause any modification to a green object to be replicated
to green remote warehouses any time they are changed, but will
diff --git a/t/replication b/t/replication
index 835fa68..803fe2c 100644
--- a/t/replication
+++ b/t/replication
@@ -74,7 +74,7 @@ test -f fs_upstream/rbucket/dflt_test || fail=1
test -f fs_downstream/rbucket/dflt_test && fail=1
# Set the replication policy to always replicate.
-echo -n 1 | curl -T - $bkt/_default/_policy || fail=1
+printf 1 | curl -T - $bkt/_default/_policy || fail=1
# Add a file, make sure it *is* replicated.
echo foo | curl -T - $bkt/pos_test || fail=1
@@ -83,18 +83,18 @@ test -f fs_upstream/rbucket/pos_test || fail=1
test -f fs_downstream/rbucket/pos_test || fail=1
# Make sure we can do selective replication based on object/site attributes.
-echo -n '$color==#color' | curl -T - $bkt/_default/_policy || fail=1
+printf '$color==#color' | curl -T - $bkt/_default/_policy || fail=1
# Positive test.
# NB this file is also used by the delete test below
-echo -n blue | curl -T - $bkt/sel_pos/color || fail=1
-echo -n foo | curl -T - $bkt/sel_pos || fail=1
+printf blue | curl -T - $bkt/sel_pos/color || fail=1
+printf foo | curl -T - $bkt/sel_pos || fail=1
wait_for .1 50 "wait_for_repl $api" || fail_ "replication seems stuck"
test -f fs_downstream/rbucket/sel_pos || fail=1
# Negative test.
-echo -n red | curl -T - $bkt/sel_neg/color || fail=1
-echo -n foo | curl -T - $bkt/sel_neg || fail=1
+printf red | curl -T - $bkt/sel_neg/color || fail=1
+printf foo | curl -T - $bkt/sel_neg || fail=1
wait_for .1 50 "wait_for_repl $api" || fail_ "replication seems stuck"
test -f fs_downstream/rbucket/sel_neg && fail=1
@@ -106,10 +106,10 @@ test -f fs_downstream/rbucket/sel_pos && fail=1
# Test re-replication when we change an attribute.
echo hello | curl -T - $bkt/attr_chg
-echo -n 'red' | curl -T - $bkt/attr_chg/color
-echo -n '$color=="blue"' | curl -T - $bkt/attr_chg/_policy
+printf red | curl -T - $bkt/attr_chg/color
+printf '$color=="blue"' | curl -T - $bkt/attr_chg/_policy
test -f fs_downstream/rbucket/attr_chg && fail=1
-echo -n 'blue' | curl -T - $bkt/attr_chg/color
+printf blue | curl -T - $bkt/attr_chg/color
wait_for .1 50 "wait_for_repl $api" || fail_ "replication seems stuck"
test -f fs_downstream/rbucket/attr_chg || fail=1
http://repo.or.cz/w/iwhd.git/commit/72b4c4ff6037f506c78b839a48aa88a73fad5a95
commit 72b4c4ff6037f506c78b839a48aa88a73fad5a95
Author: Jim Meyering <meyering(a)redhat.com>
Date: Fri Oct 1 14:54:56 2010 +0200
enable m4 quoting check
diff --git a/cfg.mk b/cfg.mk
index 1ac61c7..da52286 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -30,7 +30,6 @@ skip_low_priority =
# Tests not to run as part of "make distcheck".
local-checks-to-skip = - sc_m4_quote_check sc_program_name sc_prohibit_echo_minus_en sc_prohibit_empty_lines_at_EOF diff --git a/m4/ax_boost_base.m4 b/m4/ax_boost_base.m4
index 8f935f6..d368238 100644
--- a/m4/ax_boost_base.m4
+++ b/m4/ax_boost_base.m4
@@ -17,7 +17,7 @@
#
# This macro calls:
#
-# AC_SUBST(BOOST_CPPFLAGS) / AC_SUBST(BOOST_LDFLAGS)
+# AC_SUBST([BOOST_CPPFLAGS]) / AC_SUBST([BOOST_LDFLAGS])
#
# And sets:
#
@@ -238,9 +238,9 @@ if test "x$want_boost" = "xyes"; then
# execute ACTION-IF-NOT-FOUND (if present):
ifelse([$3], , :, [$3])
else
- AC_SUBST(BOOST_CPPFLAGS)
- AC_SUBST(BOOST_LDFLAGS)
- AC_DEFINE(HAVE_BOOST,,[define if the Boost library is available])
+ AC_SUBST([BOOST_CPPFLAGS])
+ AC_SUBST([BOOST_LDFLAGS])
+ AC_DEFINE([HAVE_BOOST],,[define if the Boost library is available])
# execute ACTION-IF-FOUND (if present):
ifelse([$2], , :, [$2])
fi
diff --git a/m4/ax_boost_system.m4 b/m4/ax_boost_system.m4
index e9aecb5..612d6a6 100644
--- a/m4/ax_boost_system.m4
+++ b/m4/ax_boost_system.m4
@@ -14,7 +14,7 @@
#
# This macro calls:
#
-# AC_SUBST(BOOST_SYSTEM_LIB)
+# AC_SUBST([BOOST_SYSTEM_LIB])
#
# And sets:
#
@@ -76,9 +76,9 @@ AC_DEFUN([AX_BOOST_SYSTEM],
AC_LANG_POP([C++])
])
if test "x$ax_cv_boost_system" = "xyes"; then
- AC_SUBST(BOOST_CPPFLAGS)
+ AC_SUBST([BOOST_CPPFLAGS])
- AC_DEFINE(HAVE_BOOST_SYSTEM,,[define if the Boost::System library is available])
+ AC_DEFINE([HAVE_BOOST_SYSTEM],,[define if the Boost::System library is available])
BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^/@:>@*//'`
LDFLAGS_SAVE=$LDFLAGS
@@ -86,14 +86,14 @@ AC_DEFUN([AX_BOOST_SYSTEM],
for libextension in `ls $BOOSTLIBDIR/libboost_system*.so* $BOOSTLIBDIR/libboost_system*.a* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^lib(boost_system.*).so.*$;1;' -e 's;^lib(boost_system.*).a*$;1;'` ; do
ax_lib=${libextension}
AC_CHECK_LIB($ax_lib, exit,
- [BOOST_SYSTEM_LIB="-l$ax_lib"; AC_SUBST(BOOST_SYSTEM_LIB) link_system="yes"; break],
+ [BOOST_SYSTEM_LIB="-l$ax_lib"; AC_SUBST([BOOST_SYSTEM_LIB]) link_system="yes"; break],
[link_system="no"])
done
if test "x$link_system" != "xyes"; then
for libextension in `ls $BOOSTLIBDIR/boost_system*.{dll,a}* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^(boost_system.*).dll.*$;1;' -e 's;^(boost_system.*).a*$;1;'` ; do
ax_lib=${libextension}
AC_CHECK_LIB($ax_lib, exit,
- [BOOST_SYSTEM_LIB="-l$ax_lib"; AC_SUBST(BOOST_SYSTEM_LIB) link_system="yes"; break],
+ [BOOST_SYSTEM_LIB="-l$ax_lib"; AC_SUBST([BOOST_SYSTEM_LIB]) link_system="yes"; break],
[link_system="no"])
done
fi
@@ -101,7 +101,7 @@ AC_DEFUN([AX_BOOST_SYSTEM],
else
for ax_lib in $ax_boost_user_system_lib boost_system-$ax_boost_user_system_lib; do
AC_CHECK_LIB($ax_lib, exit,
- [BOOST_SYSTEM_LIB="-l$ax_lib"; AC_SUBST(BOOST_SYSTEM_LIB) link_system="yes"; break],
+ [BOOST_SYSTEM_LIB="-l$ax_lib"; AC_SUBST([BOOST_SYSTEM_LIB]) link_system="yes"; break],
[link_system="no"])
done
diff --git a/m4/ax_boost_thread.m4 b/m4/ax_boost_thread.m4
index 1fcb867..b67b596 100644
--- a/m4/ax_boost_thread.m4
+++ b/m4/ax_boost_thread.m4
@@ -14,7 +14,7 @@
#
# This macro calls:
#
-# AC_SUBST(BOOST_THREAD_LIB)
+# AC_SUBST([BOOST_THREAD_LIB])
#
# And sets:
#
@@ -91,9 +91,9 @@ AC_DEFUN([AX_BOOST_THREAD],
BOOST_CPPFLAGS="-pthread $BOOST_CPPFLAGS"
fi
- AC_SUBST(BOOST_CPPFLAGS)
+ AC_SUBST([BOOST_CPPFLAGS])
- AC_DEFINE(HAVE_BOOST_THREAD,,[define if the Boost::Thread library is available])
+ AC_DEFINE([HAVE_BOOST_THREAD],,[define if the Boost::Thread library is available])
BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^/@:>@*//'`
LDFLAGS_SAVE=$LDFLAGS
@@ -107,14 +107,14 @@ AC_DEFUN([AX_BOOST_THREAD],
for libextension in `ls $BOOSTLIBDIR/libboost_thread*.so* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^lib(boost_thread.*).so.*$;1;'` `ls $BOOSTLIBDIR/libboost_thread*.a* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^lib(boost_thread.*).a*$;1;'`; do
ax_lib=${libextension}
AC_CHECK_LIB($ax_lib, exit,
- [BOOST_THREAD_LIB="-l$ax_lib"; AC_SUBST(BOOST_THREAD_LIB) link_thread="yes"; break],
+ [BOOST_THREAD_LIB="-l$ax_lib"; AC_SUBST([BOOST_THREAD_LIB]) link_thread="yes"; break],
[link_thread="no"])
done
if test "x$link_thread" != "xyes"; then
for libextension in `ls $BOOSTLIBDIR/boost_thread*.dll* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^(boost_thread.*).dll.*$;1;'` `ls $BOOSTLIBDIR/boost_thread*.a* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^(boost_thread.*).a*$;1;'` ; do
ax_lib=${libextension}
AC_CHECK_LIB($ax_lib, exit,
- [BOOST_THREAD_LIB="-l$ax_lib"; AC_SUBST(BOOST_THREAD_LIB) link_thread="yes"; break],
+ [BOOST_THREAD_LIB="-l$ax_lib"; AC_SUBST([BOOST_THREAD_LIB]) link_thread="yes"; break],
[link_thread="no"])
done
fi
@@ -122,7 +122,7 @@ AC_DEFUN([AX_BOOST_THREAD],
else
for ax_lib in $ax_boost_user_thread_lib boost_thread-$ax_boost_user_thread_lib; do
AC_CHECK_LIB($ax_lib, exit,
- [BOOST_THREAD_LIB="-l$ax_lib"; AC_SUBST(BOOST_THREAD_LIB) link_thread="yes"; break],
+ [BOOST_THREAD_LIB="-l$ax_lib"; AC_SUBST([BOOST_THREAD_LIB]) link_thread="yes"; break],
[link_thread="no"])
done
http://repo.or.cz/w/iwhd.git/commit/c8d0be9f4c70775fca231996d1420e717628cc6c
commit c8d0be9f4c70775fca231996d1420e717628cc6c
Author: Jim Meyering <meyering(a)redhat.com>
Date: Fri Oct 1 14:50:16 2010 +0200
maint: remove unused #include directives spotted by "make syntax-check"
diff --git a/backend.c b/backend.c
index 6f5945c..6e9a2cd 100644
--- a/backend.c
+++ b/backend.c
@@ -16,7 +16,6 @@
#include <config.h>
#include <fcntl.h>
-#include <getopt.h>
#include <poll.h>
#include <pthread.h>
#include <regex.h>
@@ -25,11 +24,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <strings.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/wait.h>
-#include <assert.h>
#include <errno.h>
#include <error.h>
diff --git a/cfg.mk b/cfg.mk
index c8d3768..1ac61c7 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -32,12 +32,9 @@ skip_low_priority = local-checks-to-skip = sc_m4_quote_check sc_program_name - sc_prohibit_assert_without_use sc_prohibit_echo_minus_en sc_prohibit_empty_lines_at_EOF - sc_prohibit_getopt_without_use sc_prohibit_test_minus_ao - sc_prohibit_strings_without_use sc_space_tab sc_useless_cpp_parens $(skip_low_priority)
diff --git a/mpipe.h b/mpipe.h
index 33ae9e5..9d0f795 100644
--- a/mpipe.h
+++ b/mpipe.h
@@ -17,7 +17,6 @@
#define _MPIPE_H
#include <fcntl.h>
-#include <getopt.h>
#include <poll.h>
#include <pthread.h>
#include <semaphore.h>
diff --git a/replica.c b/replica.c
index 9487c33..58544d4 100644
--- a/replica.c
+++ b/replica.c
@@ -18,7 +18,6 @@
#include <errno.h>
#include <error.h>
#include <fcntl.h>
-#include <getopt.h>
#include <poll.h>
#include <pthread.h>
#include <semaphore.h>
@@ -26,9 +25,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <strings.h>
#include <unistd.h>
-#include <assert.h>
#include <hstor.h>
#include <microhttpd.h> /* for HTTP status values */
diff --git a/rest.c b/rest.c
index 8c1860c..68e2f2c 100644
--- a/rest.c
+++ b/rest.c
@@ -25,7 +25,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <strings.h>
#include <unistd.h>
#include <sys/stat.h>
#include <assert.h>
diff --git a/setup.c b/setup.c
index 9ad13f1..2296b15 100644
--- a/setup.c
+++ b/setup.c
@@ -18,7 +18,6 @@
#include <errno.h>
#include <error.h>
#include <fcntl.h>
-#include <getopt.h>
#include <poll.h>
#include <pthread.h>
#include <semaphore.h>
@@ -28,7 +27,6 @@
#include <string.h>
#include <strings.h>
#include <unistd.h>
-#include <assert.h>
#include <jansson.h>
http://repo.or.cz/w/iwhd.git/commit/2bbe861de39bc6e0e3220fefcbbb40dbeaa84e1d
commit 2bbe861de39bc6e0e3220fefcbbb40dbeaa84e1d
Author: Jim Meyering <meyering(a)redhat.com>
Date: Fri Oct 1 14:41:02 2010 +0200
maint: enable no-trailing blanks prohibition
diff --git a/.x-sc_trailing_blank b/.x-sc_trailing_blank
new file mode 100644
index 0000000..9726d11
--- /dev/null
+++ b/.x-sc_trailing_blank
@@ -0,0 +1 @@
+^doc/image_repo.odt$
diff --git a/cfg.mk b/cfg.mk
index d92f4ce..c8d3768 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -39,7 +39,6 @@ local-checks-to-skip = sc_prohibit_test_minus_ao sc_prohibit_strings_without_use sc_space_tab - sc_trailing_blank sc_useless_cpp_parens $(skip_low_priority)
http://repo.or.cz/w/iwhd.git/commit/88b1d8ae3d489a1df5d687a3422627d8cfc31f7b
commit 88b1d8ae3d489a1df5d687a3422627d8cfc31f7b
Author: Jim Meyering <meyering(a)redhat.com>
Date: Thu Sep 30 16:44:11 2010 +0200
Use gnulib
Add gnulib as a submodule.
Move ax/*.m4 to m4/*.
* bootstrap: New file. Copied from gnulib.
Fill in blanks in bootstrap.conf template.
New file, cfg.mk, is very similar to what's used in other projects.
* configure.ac: use gl_INIT and gl_EARLY, per documentation.
Generate a Makefile for each of the new lib/ and gnulib-tests/
directories.
* Makefile.am (SUBDIRS): Update so we build in lib before "."
and so that "make check" runs the tests in gnulib-tests.
* rest.c: Do not hard-code 1.0 as version number.
* .gitignore: Ignore gnulib-tests.
diff --git a/.gitignore b/.gitignore
index 6fbf252..892be03 100644
--- a/.gitignore
+++ b/.gitignore
@@ -25,3 +25,5 @@ ChangeLog
Makefile
Makefile.in
#*#
+/GNUmakefile
+/gnulib-tests
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000..acb2669
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "gnulib"]
+ path = gnulib
+ url = git://git.sv.gnu.org/gnulib.git
diff --git a/INSTALL b/INSTALL
deleted file mode 100644
index 7d1c323..0000000
--- a/INSTALL
+++ /dev/null
@@ -1,365 +0,0 @@
-Installation Instructions
-*************************
-
-Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
-2006, 2007, 2008, 2009 Free Software Foundation, Inc.
-
- Copying and distribution of this file, with or without modification,
-are permitted in any medium without royalty provided the copyright
-notice and this notice are preserved. This file is offered as-is,
-without warranty of any kind.
-
-Basic Installation
-==================
-
- Briefly, the shell commands `./configure; make; make install' should
-configure, build, and install this package. The following
-more-detailed instructions are generic; see the `README' file for
-instructions specific to this package. Some packages provide this
-`INSTALL' file but do not implement all of the features documented
-below. The lack of an optional feature in a given package is not
-necessarily a bug. More recommendations for GNU packages can be found
-in *note Makefile Conventions: (standards)Makefile Conventions.
-
- The `configure' shell script attempts to guess correct values for
-various system-dependent variables used during compilation. It uses
-those values to create a `Makefile' in each directory of the package.
-It may also create one or more `.h' files containing system-dependent
-definitions. Finally, it creates a shell script `config.status' that
-you can run in the future to recreate the current configuration, and a
-file `config.log' containing compiler output (useful mainly for
-debugging `configure').
-
- It can also use an optional file (typically called `config.cache'
-and enabled with `--cache-file=config.cache' or simply `-C') that saves
-the results of its tests to speed up reconfiguring. Caching is
-disabled by default to prevent problems with accidental use of stale
-cache files.
-
- If you need to do unusual things to compile the package, please try
-to figure out how `configure' could check whether to do them, and mail
-diffs or instructions to the address given in the `README' so they can
-be considered for the next release. If you are using the cache, and at
-some point `config.cache' contains results you don't want to keep, you
-may remove or edit it.
-
- The file `configure.ac' (or `configure.in') is used to create
-`configure' by a program called `autoconf'. You need `configure.ac' if
-you want to change it or regenerate `configure' using a newer version
-of `autoconf'.
-
- The simplest way to compile this package is:
-
- 1. `cd' to the directory containing the package's source code and type
- `./configure' to configure the package for your system.
-
- Running `configure' might take a while. While running, it prints
- some messages telling which features it is checking for.
-
- 2. Type `make' to compile the package.
-
- 3. Optionally, type `make check' to run any self-tests that come with
- the package, generally using the just-built uninstalled binaries.
-
- 4. Type `make install' to install the programs and any data files and
- documentation. When installing into a prefix owned by root, it is
- recommended that the package be configured and built as a regular
- user, and only the `make install' phase executed with root
- privileges.
-
- 5. Optionally, type `make installcheck' to repeat any self-tests, but
- this time using the binaries in their final installed location.
- This target does not install anything. Running this target as a
- regular user, particularly if the prior `make install' required
- root privileges, verifies that the installation completed
- correctly.
-
- 6. You can remove the program binaries and object files from the
- source code directory by typing `make clean'. To also remove the
- files that `configure' created (so you can compile the package for
- a different kind of computer), type `make distclean'. There is
- also a `make maintainer-clean' target, but that is intended mainly
- for the package's developers. If you use it, you may have to get
- all sorts of other programs in order to regenerate files that came
- with the distribution.
-
- 7. Often, you can also type `make uninstall' to remove the installed
- files again. In practice, not all packages have tested that
- uninstallation works correctly, even though it is required by the
- GNU Coding Standards.
-
- 8. Some packages, particularly those that use Automake, provide `make
- distcheck', which can by used by developers to test that all other
- targets like `make install' and `make uninstall' work correctly.
- This target is generally not run by end users.
-
-Compilers and Options
-=====================
-
- Some systems require unusual options for compilation or linking that
-the `configure' script does not know about. Run `./configure --help'
-for details on some of the pertinent environment variables.
-
- You can give `configure' initial values for configuration parameters
-by setting variables in the command line or in the environment. Here
-is an example:
-
- ./configure CC=c99 CFLAGS=-g LIBS=-lposix
-
- *Note Defining Variables::, for more details.
-
-Compiling For Multiple Architectures
-====================================
-
- You can compile the package for more than one kind of computer at the
-same time, by placing the object files for each architecture in their
-own directory. To do this, you can use GNU `make'. `cd' to the
-directory where you want the object files and executables to go and run
-the `configure' script. `configure' automatically checks for the
-source code in the directory that `configure' is in and in `..'. This
-is known as a "VPATH" build.
-
- With a non-GNU `make', it is safer to compile the package for one
-architecture at a time in the source code directory. After you have
-installed the package for one architecture, use `make distclean' before
-reconfiguring for another architecture.
-
- On MacOS X 10.5 and later systems, you can create libraries and
-executables that work on multiple system types--known as "fat" or
-"universal" binaries--by specifying multiple `-arch' options to the
-compiler but only a single `-arch' option to the preprocessor. Like
-this:
-
- ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" - CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" - CPP="gcc -E" CXXCPP="g++ -E"
-
- This is not guaranteed to produce working output in all cases, you
-may have to build one architecture at a time and combine the results
-using the `lipo' tool if you have problems.
-
-Installation Names
-==================
-
- By default, `make install' installs the package's commands under
-`/usr/local/bin', include files under `/usr/local/include', etc. You
-can specify an installation prefix other than `/usr/local' by giving
-`configure' the option `--prefix=PREFIX', where PREFIX must be an
-absolute file name.
-
- You can specify separate installation prefixes for
-architecture-specific files and architecture-independent files. If you
-pass the option `--exec-prefix=PREFIX' to `configure', the package uses
-PREFIX as the prefix for installing programs and libraries.
-Documentation and other data files still use the regular prefix.
-
- In addition, if you use an unusual directory layout you can give
-options like `--bindir=DIR' to specify different values for particular
-kinds of files. Run `configure --help' for a list of the directories
-you can set and what kinds of files go in them. In general, the
-default for these options is expressed in terms of `${prefix}', so that
-specifying just `--prefix' will affect all of the other directory
-specifications that were not explicitly provided.
-
- The most portable way to affect installation locations is to pass the
-correct locations to `configure'; however, many packages provide one or
-both of the following shortcuts of passing variable assignments to the
-`make install' command line to change installation locations without
-having to reconfigure or recompile.
-
- The first method involves providing an override variable for each
-affected directory. For example, `make install
-prefix=/alternate/directory' will choose an alternate location for all
-directory configuration variables that were expressed in terms of
-`${prefix}'. Any directories that were specified during `configure',
-but not in terms of `${prefix}', must each be overridden at install
-time for the entire installation to be relocated. The approach of
-makefile variable overrides for each directory variable is required by
-the GNU Coding Standards, and ideally causes no recompilation.
-However, some platforms have known limitations with the semantics of
-shared libraries that end up requiring recompilation when using this
-method, particularly noticeable in packages that use GNU Libtool.
-
- The second method involves providing the `DESTDIR' variable. For
-example, `make install DESTDIR=/alternate/directory' will prepend
-`/alternate/directory' before all installation names. The approach of
-`DESTDIR' overrides is not required by the GNU Coding Standards, and
-does not work on platforms that have drive letters. On the other hand,
-it does better at avoiding recompilation issues, and works well even
-when some directory options were not specified in terms of `${prefix}'
-at `configure' time.
-
-Optional Features
-=================
-
- If the package supports it, you can cause programs to be installed
-with an extra prefix or suffix on their names by giving `configure' the
-option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
-
- Some packages pay attention to `--enable-FEATURE' options to
-`configure', where FEATURE indicates an optional part of the package.
-They may also pay attention to `--with-PACKAGE' options, where PACKAGE
-is something like `gnu-as' or `x' (for the X Window System). The
-`README' should mention any `--enable-' and `--with-' options that the
-package recognizes.
-
- For packages that use the X Window System, `configure' can usually
-find the X include and library files automatically, but if it doesn't,
-you can use the `configure' options `--x-includes=DIR' and
-`--x-libraries=DIR' to specify their locations.
-
- Some packages offer the ability to configure how verbose the
-execution of `make' will be. For these packages, running `./configure
---enable-silent-rules' sets the default to minimal output, which can be
-overridden with `make V=1'; while running `./configure
---disable-silent-rules' sets the default to verbose, which can be
-overridden with `make V=0'.
-
-Particular systems
-==================
-
- On HP-UX, the default C compiler is not ANSI C compatible. If GNU
-CC is not installed, it is recommended to use the following options in
-order to use an ANSI C compiler:
-
- ./configure CC="cc -Ae -D_XOPEN_SOURCE=500"
-
-and if that doesn't work, install pre-built binaries of GCC for HP-UX.
-
- On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot
-parse its `<wchar.h>' header file. The option `-nodtk' can be used as
-a workaround. If GNU CC is not installed, it is therefore recommended
-to try
-
- ./configure CC="cc"
-
-and if that doesn't work, try
-
- ./configure CC="cc -nodtk"
-
- On Solaris, don't put `/usr/ucb' early in your `PATH'. This
-directory contains several dysfunctional programs; working variants of
-these programs are available in `/usr/bin'. So, if you need `/usr/ucb'
-in your `PATH', put it _after_ `/usr/bin'.
-
- On Haiku, software installed for all users goes in `/boot/common',
-not `/usr/local'. It is recommended to use the following options:
-
- ./configure --prefix=/boot/common
-
-Specifying the System Type
-==========================
-
- There may be some features `configure' cannot figure out
-automatically, but needs to determine by the type of machine the package
-will run on. Usually, assuming the package is built to be run on the
-_same_ architectures, `configure' can figure that out, but if it prints
-a message saying it cannot guess the machine type, give it the
-`--build=TYPE' option. TYPE can either be a short name for the system
-type, such as `sun4', or a canonical name which has the form:
-
- CPU-COMPANY-SYSTEM
-
-where SYSTEM can have one of these forms:
-
- OS
- KERNEL-OS
-
- See the file `config.sub' for the possible values of each field. If
-`config.sub' isn't included in this package, then this package doesn't
-need to know the machine type.
-
- If you are _building_ compiler tools for cross-compiling, you should
-use the option `--target=TYPE' to select the type of system they will
-produce code for.
-
- If you want to _use_ a cross compiler, that generates code for a
-platform different from the build platform, you should specify the
-"host" platform (i.e., that on which the generated programs will
-eventually be run) with `--host=TYPE'.
-
-Sharing Defaults
-================
-
- If you want to set default values for `configure' scripts to share,
-you can create a site shell script called `config.site' that gives
-default values for variables like `CC', `cache_file', and `prefix'.
-`configure' looks for `PREFIX/share/config.site' if it exists, then
-`PREFIX/etc/config.site' if it exists. Or, you can set the
-`CONFIG_SITE' environment variable to the location of the site script.
-A warning: not all `configure' scripts look for a site script.
-
-Defining Variables
-==================
-
- Variables not defined in a site shell script can be set in the
-environment passed to `configure'. However, some packages may run
-configure again during the build, and the customized values of these
-variables may be lost. In order to avoid this problem, you should set
-them in the `configure' command line, using `VAR=value'. For example:
-
- ./configure CC=/usr/local2/bin/gcc
-
-causes the specified `gcc' to be used as the C compiler (unless it is
-overridden in the site shell script).
-
-Unfortunately, this technique does not work for `CONFIG_SHELL' due to
-an Autoconf bug. Until the bug is fixed you can use this workaround:
-
- CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash
-
-`configure' Invocation
-======================
-
- `configure' recognizes the following options to control how it
-operates.
-
-`--help'
-`-h'
- Print a summary of all of the options to `configure', and exit.
-
-`--help=short'
-`--help=recursive'
- Print a summary of the options unique to this package's
- `configure', and exit. The `short' variant lists options used
- only in the top level, while the `recursive' variant lists options
- also present in any nested packages.
-
-`--version'
-`-V'
- Print the version of Autoconf used to generate the `configure'
- script, and exit.
-
-`--cache-file=FILE'
- Enable the cache: use and save the results of the tests in FILE,
- traditionally `config.cache'. FILE defaults to `/dev/null' to
- disable caching.
-
-`--config-cache'
-`-C'
- Alias for `--cache-file=config.cache'.
-
-`--quiet'
-`--silent'
-`-q'
- Do not print messages saying which checks are being made. To
- suppress all normal output, redirect it to `/dev/null' (any error
- messages will still be shown).
-
-`--srcdir=DIR'
- Look for the package's source code in directory DIR. Usually
- `configure' can determine that directory automatically.
-
-`--prefix=DIR'
- Use DIR as the installation prefix. *note Installation Names::
- for more details, including other options available for fine-tuning
- the installation locations.
-
-`--no-create'
-`-n'
- Run the configure checks, but stop before creating any output
- files.
-
-`configure' also accepts some other, not widely useful, options. Run
-`configure --help' for more details.
-
diff --git a/Makefile.am b/Makefile.am
index 84d96ab..7c3d1af 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -20,8 +20,8 @@ AM_CPPFLAGS = -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include
iwhd_YFLAGS = -d
-SUBDIRS = . t man
-ACLOCAL_AMFLAGS = -I ax
+SUBDIRS = lib . t man gnulib-tests
+ACLOCAL_AMFLAGS = -I m4
# iwhd is short for Image WareHouse Daemon.
bin_PROGRAMS = iwhd
diff --git a/bootstrap b/bootstrap
new file mode 100755
index 0000000..5ab4cf7
--- /dev/null
+++ b/bootstrap
@@ -0,0 +1,858 @@
+#! /bin/sh
+# Print a version string.
+scriptversion=2010-07-06.10; # UTC
+
+# Bootstrap this package from checked-out sources.
+
+# Copyright (C) 2003-2010 Free Software Foundation, Inc.
+
+# This program 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.
+
+# This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Originally written by Paul Eggert. The canonical version of this
+# script is maintained as build-aux/bootstrap in gnulib, however, to
+# be useful to your project, you should place a copy of it under
+# version control in the top-level directory of your project. The
+# intent is that all customization can be done with a bootstrap.conf
+# file also maintained in your version control; gnulib comes with a
+# template build-aux/bootstrap.conf to get you started.
+
+# Please report bugs or propose patches to bug-gnulib(a)gnu.org.
+
+nl='
+'
+
+# Ensure file names are sorted consistently across platforms.
+LC_ALL=C
+export LC_ALL
+
+local_gl_dir=gl
+
+# Temporary directory names.
+bt='._bootmp'
+bt_regex=`echo "$bt"| sed 's/./[.]/g'`
+bt2=${bt}2
+
+usage() {
+ cat <<EOF
+Usage: $0 [OPTION]...
+Bootstrap this package from the checked-out sources.
+
+Options:
+ --gnulib-srcdir=DIRNAME Specify the local directory where gnulib
+ sources reside. Use this if you already
+ have gnulib sources on your machine, and
+ do not want to waste your bandwidth downloading
+ them again. Defaults to $GNULIB_SRCDIR.
+ --copy Copy files instead of creating symbolic links.
+ --force Attempt to bootstrap even if the sources seem
+ not to have been checked out.
+ --skip-po Do not download po files.
+
+If the file $0.conf exists in the same directory as this script, its
+contents are read as shell variables to configure the bootstrap.
+
+For build prerequisites, environment variables like $AUTOCONF and $AMTAR
+are honored.
+
+Running without arguments will suffice in most cases.
+EOF
+}
+
+# Configuration.
+
+# Name of the Makefile.am
+gnulib_mk=gnulib.mk
+
+# List of gnulib modules needed.
+gnulib_modules=
+
+# Any gnulib files needed that are not in modules.
+gnulib_files=
+
+# A function to be called after everything else in this script.
+# Override it via your own definition in bootstrap.conf.
+bootstrap_epilogue() { :; }
+
+# The command to download all .po files for a specified domain into
+# a specified directory. Fill in the first %s is the domain name, and
+# the second with the destination directory. Use rsync's -L and -r
+# options because the latest/%s directory and the .po files within are
+# all symlinks.
+po_download_command_format=+"rsync --delete --exclude '*.s1' -Lrtvz + 'translationproject.org::tp/latest/%s/' '%s'"
+
+extract_package_name='
+ /^AC_INIT(/{
+ /.*,.*,.*, */{
+ s///
+ s/[][]//g
+ s/)$//
+ p
+ q
+ }
+ s/AC_INIT([*//
+ s/]*,.*//
+ s/^GNU //
+ y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/
+ s/[^A-Za-z0-9_]/-/g
+ p
+ }
+'
+package=`sed -n "$extract_package_name" configure.ac` || exit
+gnulib_name=lib$package
+
+build_aux=build-aux
+source_base=lib
+m4_base=m4
+doc_base=doc
+tests_base=tests
+
+# Extra files from gnulib, which override files from other sources.
+gnulib_extra_files="
+ $build_aux/install-sh
+ $build_aux/missing
+ $build_aux/mdate-sh
+ $build_aux/texinfo.tex
+ $build_aux/depcomp
+ $build_aux/config.guess
+ $build_aux/config.sub
+ doc/INSTALL
+"
+
+# Additional gnulib-tool options to use. Use "newline" to break lines.
+gnulib_tool_option_extras=
+
+# Other locale categories that need message catalogs.
+EXTRA_LOCALE_CATEGORIES=
+
+# Additional xgettext options to use. Use "\newline" to break lines.
+XGETTEXT_OPTIONS='\+ --flag=_:1:pass-c-format\+ --flag=N_:1:pass-c-format\+ --flag=error:3:c-format --flag=error_at_line:5:c-format\+'
+
+# Package bug report address and copyright holder for gettext files
+COPYRIGHT_HOLDER='Free Software Foundation, Inc.'
+MSGID_BUGS_ADDRESS=bug-$package(a)gnu.org
+
+# Files we don't want to import.
+excluded_files=
+
+# File that should exist in the top directory of a checked out hierarchy,
+# but not in a distribution tarball.
+checkout_only_file=README-hacking
+
+# Whether to use copies instead of symlinks.
+copy=false
+
+# Set this to '.cvsignore .gitignore' in bootstrap.conf if you want
+# those files to be generated in directories like lib/, m4/, and po/.
+# Or set it to 'auto' to make this script select which to use based
+# on which version control system (if any) is used in the source directory.
+vc_ignore=auto
+
+# find_tool ENVVAR NAMES...
+# -------------------------
+# Search for a required program. Use the value of ENVVAR, if set,
+# otherwise find the first of the NAMES that can be run (i.e.,
+# supports --version). If found, set ENVVAR to the program name,
+# die otherwise.
+find_tool ()
+{
+ find_tool_envvar=$1
+ shift
+ find_tool_names=$@
+ eval "find_tool_res=$$find_tool_envvar"
+ if test x"$find_tool_res" = x; then
+ for i
+ do
+ if ($i --version </dev/null) >/dev/null 2>&1; then
+ find_tool_res=$i
+ break
+ fi
+ done
+ else
+ find_tool_error_prefix="$$find_tool_envvar: "
+ fi
+ if test x"$find_tool_res" = x; then
+ echo >&2 "$0: one of these is required: $find_tool_names"
+ exit 1
+ fi
+ ($find_tool_res --version </dev/null) >/dev/null 2>&1 || {
+ echo >&2 "$0: ${find_tool_error_prefix}cannot run $find_tool_res --version"
+ exit 1
+ }
+ eval "$find_tool_envvar=$find_tool_res"
+ eval "export $find_tool_envvar"
+}
+
+# Find sha1sum, named gsha1sum on MacPorts, and shasum on MacOS 10.6.
+find_tool SHA1SUM sha1sum gsha1sum shasum
+
+# Override the default configuration, if necessary.
+# Make sure that bootstrap.conf is sourced from the current directory
+# if we were invoked as "sh bootstrap".
+case "$0" in
+ */*) test -r "$0.conf" && . "$0.conf" ;;
+ *) test -r "$0.conf" && . ./"$0.conf" ;;
+esac
+
+
+if test "$vc_ignore" = auto; then
+ vc_ignore=
+ test -d .git && vc_ignore=.gitignore
+ test -d CVS && vc_ignore="$vc_ignore .cvsignore"
+fi
+
+# Translate configuration into internal form.
+
+# Parse options.
+
+for option
+do
+ case $option in
+ --help)
+ usage
+ exit;;
+ --gnulib-srcdir=*)
+ GNULIB_SRCDIR=`expr "X$option" : 'X--gnulib-srcdir=(.*)'`;;
+ --skip-po)
+ SKIP_PO=t;;
+ --force)
+ checkout_only_file=;;
+ --copy)
+ copy=true;;
+ *)
+ echo >&2 "$0: $option: unknown option"
+ exit 1;;
+ esac
+done
+
+if test -n "$checkout_only_file" && test ! -r "$checkout_only_file"; then
+ echo "$0: Bootstrapping from a non-checked-out distribution is risky." >&2
+ exit 1
+fi
+
+# If $STR is not already on a line by itself in $FILE, insert it,
+# sorting the new contents of the file and replacing $FILE with the result.
+insert_sorted_if_absent() {
+ file=$1
+ str=$2
+ test -f $file || touch $file
+ echo "$str" | sort -u - $file | cmp - $file > /dev/null + || echo "$str" | sort -u - $file -o $file + || exit 1
+}
+
+# Die if there is no AC_CONFIG_AUX_DIR($build_aux) line in configure.ac.
+found_aux_dir=no
+grep '^[ ]*AC_CONFIG_AUX_DIR(['"$build_aux"'])' configure.ac + >/dev/null && found_aux_dir=yes
+grep '^[ ]*AC_CONFIG_AUX_DIR('"$build_aux"')' configure.ac + >/dev/null && found_aux_dir=yes
+if test $found_aux_dir = no; then
+ echo "$0: expected line not found in configure.ac. Add the following:" >&2
+ echo " AC_CONFIG_AUX_DIR([$build_aux])" >&2
+ exit 1
+fi
+
+# If $build_aux doesn't exist, create it now, otherwise some bits
+# below will malfunction. If creating it, also mark it as ignored.
+if test ! -d $build_aux; then
+ mkdir $build_aux
+ for dot_ig in x $vc_ignore; do
+ test $dot_ig = x && continue
+ insert_sorted_if_absent $dot_ig $build_aux
+ done
+fi
+
+# Note this deviates from the version comparison in automake
+# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a
+# but this should suffice as we won't be specifying old
+# version formats or redundant trailing .0 in bootstrap.conf.
+# If we did want full compatibility then we should probably
+# use m4_version_compare from autoconf.
+sort_ver() { # sort -V is not generally available
+ ver1="$1"
+ ver2="$2"
+
+ # split on '.' and compare each component
+ i=1
+ while : ; do
+ p1=$(echo "$ver1" | cut -d. -f$i)
+ p2=$(echo "$ver2" | cut -d. -f$i)
+ if [ ! "$p1" ]; then
+ echo "$1 $2"
+ break
+ elif [ ! "$p2" ]; then
+ echo "$2 $1"
+ break
+ elif [ ! "$p1" = "$p2" ]; then
+ if [ "$p1" -gt "$p2" ] 2>/dev/null; then # numeric comparison
+ echo "$2 $1"
+ elif [ "$p2" -gt "$p1" ] 2>/dev/null; then # numeric comparison
+ echo "$1 $2"
+ else # numeric, then lexicographic comparison
+ lp=$(printf "$p1n$p2n" | LANG=C sort -n | tail -n1)
+ if [ "$lp" = "$p2" ]; then
+ echo "$1 $2"
+ else
+ echo "$2 $1"
+ fi
+ fi
+ break
+ fi
+ i=$(($i+1))
+ done
+}
+
+get_version() {
+ app=$1
+
+ $app --version >/dev/null 2>&1 || return 1
+
+ $app --version 2>&1 |
+ sed -n '# extract version within line
+ s/.*[v ]{1,}([0-9]{1,}.[.a-z0-9-]*).*/1/
+ t done
+
+ # extract version at start of line
+ s/^([0-9]{1,}.[.a-z0-9-]*).*/1/
+ t done
+
+ d
+
+ :done
+ #the following essentially does s/5.005/5.5/
+ s/.0*([1-9])/.1/g
+ p
+ q'
+}
+
+check_versions() {
+ ret=0
+
+ while read app req_ver; do
+ # Honor $APP variables ($TAR, $AUTOCONF, etc.)
+ appvar=`echo $app | tr '[a-z]' '[A-Z]'`
+ test "$appvar" = TAR && appvar=AMTAR
+ eval "app=${$appvar-$app}"
+ inst_ver=$(get_version $app)
+ if [ ! "$inst_ver" ]; then
+ echo "Error: '$app' not found" >&2
+ ret=1
+ elif [ ! "$req_ver" = "-" ]; then
+ latest_ver=$(sort_ver $req_ver $inst_ver | cut -d' ' -f2)
+ if [ ! "$latest_ver" = "$inst_ver" ]; then
+ echo "Error: '$app' version == $inst_ver is too old" >&2
+ echo " '$app' version >= $req_ver is required" >&2
+ ret=1
+ fi
+ fi
+ done
+
+ return $ret
+}
+
+print_versions() {
+ echo "Program Min_version"
+ echo "----------------------"
+ printf "$buildreq"
+ echo "----------------------"
+ # can't depend on column -t
+}
+
+if ! printf "$buildreq" | check_versions; then
+ test -f README-prereq &&
+ echo "See README-prereq for notes on obtaining these prerequisite programs:" >&2
+ echo
+ print_versions
+ exit 1
+fi
+
+echo "$0: Bootstrapping from checked-out $package sources..."
+
+# See if we can use gnulib's git-merge-changelog merge driver.
+if test -d .git && (git --version) >/dev/null 2>/dev/null ; then
+ if git config merge.merge-changelog.driver >/dev/null ; then
+ :
+ elif (git-merge-changelog --version) >/dev/null 2>/dev/null ; then
+ echo "initializing git-merge-changelog driver"
+ git config merge.merge-changelog.name 'GNU-style ChangeLog merge driver'
+ git config merge.merge-changelog.driver 'git-merge-changelog %O %A %B'
+ else
+ echo "consider installing git-merge-changelog from gnulib"
+ fi
+fi
+
+
+cleanup_gnulib() {
+ status=$?
+ rm -fr "$gnulib_path"
+ exit $status
+}
+
+git_modules_config () {
+ test -f .gitmodules && git config --file .gitmodules "$@"
+}
+
+gnulib_path=`git_modules_config submodule.gnulib.path`
+: ${gnulib_path=gnulib}
+
+# Get gnulib files.
+
+case ${GNULIB_SRCDIR--} in
+-)
+ if git_modules_config submodule.gnulib.url >/dev/null; then
+ echo "$0: getting gnulib files..."
+ git submodule init || exit $?
+ git submodule update || exit $?
+
+ elif [ ! -d "$gnulib_path" ]; then
+ echo "$0: getting gnulib files..."
+
+ trap cleanup_gnulib 1 2 13 15
+
+ shallow=
+ git clone -h 2>&1 | grep -- --depth > /dev/null && shallow='--depth 2'
+ git clone $shallow git://git.sv.gnu.org/gnulib "$gnulib_path" ||
+ cleanup_gnulib
+
+ trap - 1 2 13 15
+ fi
+ GNULIB_SRCDIR=$gnulib_path
+ ;;
+*)
+ # Use GNULIB_SRCDIR as a reference.
+ if test -d "$GNULIB_SRCDIR"/.git && + git_modules_config submodule.gnulib.url >/dev/null; then
+ echo "$0: getting gnulib files..."
+ if git submodule -h|grep -- --reference > /dev/null; then
+ # Prefer the one-liner available in git 1.6.4 or newer.
+ git submodule update --init --reference "$GNULIB_SRCDIR" + "$gnulib_path" || exit $?
+ else
+ # This fallback allows at least git 1.5.5.
+ if test -f "$gnulib_path"/gnulib-tool; then
+ # Since file already exists, assume submodule init already complete.
+ git submodule update || exit $?
+ else
+ # Older git can't clone into an empty directory.
+ rmdir "$gnulib_path" 2>/dev/null
+ git clone --reference "$GNULIB_SRCDIR" + "$(git_modules_config submodule.gnulib.url)" "$gnulib_path" + && git submodule init && git submodule update + || exit $?
+ fi
+ fi
+ GNULIB_SRCDIR=$gnulib_path
+ fi
+ ;;
+esac
+
+gnulib_tool=$GNULIB_SRCDIR/gnulib-tool
+<$gnulib_tool || exit
+
+# Get translations.
+
+download_po_files() {
+ subdir=$1
+ domain=$2
+ echo "$0: getting translations into $subdir for $domain..."
+ cmd=`printf "$po_download_command_format" "$domain" "$subdir"`
+ eval "$cmd"
+}
+
+# Mirror .po files to $po_dir/.reference and copy only the new
+# or modified ones into $po_dir. Also update $po_dir/LINGUAS.
+# Note po files that exist locally only are left in $po_dir but will
+# not be included in LINGUAS and hence will not be distributed.
+update_po_files() {
+ # Directory containing primary .po files.
+ # Overwrite them only when we're sure a .po file is new.
+ po_dir=$1
+ domain=$2
+
+ # Mirror *.po files into this dir.
+ # Usually contains *.s1 checksum files.
+ ref_po_dir="$po_dir/.reference"
+
+ test -d $ref_po_dir || mkdir $ref_po_dir || return
+ download_po_files $ref_po_dir $domain + && ls "$ref_po_dir"/*.po 2>/dev/null |
+ sed 's|.*/||; s|.po$||' > "$po_dir/LINGUAS" || return
+
+ langs=`cd $ref_po_dir && echo *.po|sed 's/.po//g'`
+ test "$langs" = '*' && langs=x
+ for po in $langs; do
+ case $po in x) continue;; esac
+ new_po="$ref_po_dir/$po.po"
+ cksum_file="$ref_po_dir/$po.s1"
+ if ! test -f "$cksum_file" ||
+ ! test -f "$po_dir/$po.po" ||
+ ! $SHA1SUM -c --status "$cksum_file" + < "$new_po" > /dev/null; then
+ echo "updated $po_dir/$po.po..."
+ cp "$new_po" "$po_dir/$po.po" + && $SHA1SUM < "$new_po" > "$cksum_file"
+ fi
+ done
+}
+
+case $SKIP_PO in
+'')
+ if test -d po; then
+ update_po_files po $package || exit
+ fi
+
+ if test -d runtime-po; then
+ update_po_files runtime-po $package-runtime || exit
+ fi;;
+esac
+
+symlink_to_dir()
+{
+ src=$1/$2
+ dst=${3-$2}
+
+ test -f "$src" && {
+
+ # If the destination directory doesn't exist, create it.
+ # This is required at least for "lib/uniwidth/cjk.h".
+ dst_dir=`dirname "$dst"`
+ if ! test -d "$dst_dir"; then
+ mkdir -p "$dst_dir"
+
+ # If we've just created a directory like lib/uniwidth,
+ # tell version control system(s) it's ignorable.
+ # FIXME: for now, this does only one level
+ parent=`dirname "$dst_dir"`
+ for dot_ig in x $vc_ignore; do
+ test $dot_ig = x && continue
+ ig=$parent/$dot_ig
+ insert_sorted_if_absent $ig `echo "$dst_dir"|sed 's,.*/,,'`
+ done
+ fi
+
+ if $copy; then
+ {
+ test ! -h "$dst" || {
+ echo "$0: rm -f $dst" &&
+ rm -f "$dst"
+ }
+ } &&
+ test -f "$dst" &&
+ cmp -s "$src" "$dst" || {
+ echo "$0: cp -fp $src $dst" &&
+ cp -fp "$src" "$dst"
+ }
+ else
+ test -h "$dst" &&
+ src_ls=`ls -diL "$src" 2>/dev/null` && set $src_ls && src_i=$1 &&
+ dst_ls=`ls -diL "$dst" 2>/dev/null` && set $dst_ls && dst_i=$1 &&
+ test "$src_i" = "$dst_i" || {
+ dot_dots=
+ case $src in
+ /*) ;;
+ *)
+ case /$dst/ in
+ *//* | */../* | */./* | /*/*/*/*/*/)
+ echo >&2 "$0: invalid symlink calculation: $src -> $dst"
+ exit 1;;
+ /*/*/*/*/) dot_dots=../../../;;
+ /*/*/*/) dot_dots=../../;;
+ /*/*/) dot_dots=../;;
+ esac;;
+ esac
+
+ echo "$0: ln -fs $dot_dots$src $dst" &&
+ ln -fs "$dot_dots$src" "$dst"
+ }
+ fi
+ }
+}
+
+cp_mark_as_generated()
+{
+ cp_src=$1
+ cp_dst=$2
+
+ if cmp -s "$cp_src" "$GNULIB_SRCDIR/$cp_dst"; then
+ symlink_to_dir "$GNULIB_SRCDIR" "$cp_dst"
+ elif cmp -s "$cp_src" "$local_gl_dir/$cp_dst"; then
+ symlink_to_dir $local_gl_dir "$cp_dst"
+ else
+ case $cp_dst in
+ *.[ch]) c1='/* '; c2=' */';;
+ *.texi) c1='@c '; c2= ;;
+ *.m4|*/Make*|Make*) c1='# ' ; c2= ;;
+ *) c1= ; c2= ;;
+ esac
+
+ # If the destination directory doesn't exist, create it.
+ # This is required at least for "lib/uniwidth/cjk.h".
+ dst_dir=`dirname "$cp_dst"`
+ test -d "$dst_dir" || mkdir -p "$dst_dir"
+
+ if test -z "$c1"; then
+ cmp -s "$cp_src" "$cp_dst" || {
+ # Copy the file first to get proper permissions if it
+ # doesn't already exist. Then overwrite the copy.
+ echo "$0: cp -f $cp_src $cp_dst" &&
+ rm -f "$cp_dst" &&
+ cp "$cp_src" "$cp_dst-t" &&
+ sed "s!$bt_regex/!!g" "$cp_src" > "$cp_dst-t" &&
+ mv -f "$cp_dst-t" "$cp_dst"
+ }
+ else
+ # Copy the file first to get proper permissions if it
+ # doesn't already exist. Then overwrite the copy.
+ cp "$cp_src" "$cp_dst-t" &&
+ (
+ echo "$c1-*- buffer-read-only: t -*- vi: set ro:$c2" &&
+ echo "${c1}DO NOT EDIT! GENERATED AUTOMATICALLY!$c2" &&
+ sed "s!$bt_regex/!!g" "$cp_src"
+ ) > $cp_dst-t &&
+ if cmp -s "$cp_dst-t" "$cp_dst"; then
+ rm -f "$cp_dst-t"
+ else
+ echo "$0: cp $cp_src $cp_dst # with edits" &&
+ mv -f "$cp_dst-t" "$cp_dst"
+ fi
+ fi
+ fi
+}
+
+version_controlled_file() {
+ dir=$1
+ file=$2
+ found=no
+ if test -d CVS; then
+ grep -F "/$file/" $dir/CVS/Entries 2>/dev/null |
+ grep '^/[^/]*/[0-9]' > /dev/null && found=yes
+ elif test -d .git; then
+ git rm -n "$dir/$file" > /dev/null 2>&1 && found=yes
+ elif test -d .svn; then
+ svn log -r HEAD "$dir/$file" > /dev/null 2>&1 && found=yes
+ else
+ echo "$0: no version control for $dir/$file?" >&2
+ fi
+ test $found = yes
+}
+
+slurp() {
+ for dir in . `(cd $1 && find * -type d -print)`; do
+ copied=
+ sep=
+ for file in `ls -a $1/$dir`; do
+ case $file in
+ .|..) continue;;
+ .*) continue;; # FIXME: should all file names starting with "." be ignored?
+ esac
+ test -d $1/$dir/$file && continue
+ for excluded_file in $excluded_files; do
+ test "$dir/$file" = "$excluded_file" && continue 2
+ done
+ if test $file = Makefile.am && test "X$gnulib_mk" != XMakefile.am; then
+ copied=$copied${sep}$gnulib_mk; sep=$nl
+ remove_intl='/^[^#].*/intl/s/^/#/;'"s!$bt_regex/!!g"
+ sed "$remove_intl" $1/$dir/$file | cmp - $dir/$gnulib_mk > /dev/null || {
+ echo "$0: Copying $1/$dir/$file to $dir/$gnulib_mk ..." &&
+ rm -f $dir/$gnulib_mk &&
+ sed "$remove_intl" $1/$dir/$file >$dir/$gnulib_mk
+ }
+ elif { test "${2+set}" = set && test -r $2/$dir/$file; } ||
+ version_controlled_file $dir $file; then
+ echo "$0: $dir/$file overrides $1/$dir/$file"
+ else
+ copied=$copied$sep$file; sep=$nl
+ if test $file = gettext.m4; then
+ echo "$0: patching m4/gettext.m4 to remove need for intl/* ..."
+ rm -f $dir/$file
+ sed '
+ /^AC_DEFUN([AM_INTL_SUBDIR],/,/^]/c+ AC_DEFUN([AM_INTL_SUBDIR], [])
+ /^AC_DEFUN([gt_INTL_SUBDIR_CORE],/,/^]/c+ AC_DEFUN([gt_INTL_SUBDIR_CORE], [])
+ $a+ AC_DEFUN([gl_LOCK_EARLY], [])
+ ' $1/$dir/$file >$dir/$file
+ else
+ cp_mark_as_generated $1/$dir/$file $dir/$file
+ fi
+ fi || exit
+ done
+
+ for dot_ig in x $vc_ignore; do
+ test $dot_ig = x && continue
+ ig=$dir/$dot_ig
+ if test -n "$copied"; then
+ insert_sorted_if_absent $ig "$copied"
+ # If an ignored file name ends with .in.h, then also add
+ # the name with just ".h". Many gnulib headers are generated,
+ # e.g., stdint.in.h -> stdint.h, dirent.in.h ->..., etc.
+ # Likewise for .gperf -> .h, .y -> .c, and .sin -> .sed
+ f=`echo "$copied"|sed 's/.in.h$/.h/;s/.sin$/.sed/;s/.y$/.c/;s/.gperf$/.h/'`
+ insert_sorted_if_absent $ig "$f"
+
+ # For files like sys_stat.in.h and sys_time.in.h, record as
+ # ignorable the directory we might eventually create: sys/.
+ f=`echo "$copied"|sed 's/sys_.*.in.h$/sys/'`
+ insert_sorted_if_absent $ig "$f"
+ fi
+ done
+ done
+}
+
+
+# Create boot temporary directories to import from gnulib and gettext.
+rm -fr $bt $bt2 &&
+mkdir $bt $bt2 || exit
+
+# Import from gnulib.
+
+gnulib_tool_options="+ --import+ --no-changelog+ --aux-dir $bt/$build_aux+ --doc-base $bt/$doc_base+ --lib $gnulib_name+ --m4-base $bt/$m4_base/+ --source-base $bt/$source_base/+ --tests-base $bt/$tests_base+ --local-dir $local_gl_dir+ $gnulib_tool_option_extras+"
+echo "$0: $gnulib_tool $gnulib_tool_options --import ..."
+$gnulib_tool $gnulib_tool_options --import $gnulib_modules &&
+slurp $bt || exit
+
+for file in $gnulib_files; do
+ symlink_to_dir "$GNULIB_SRCDIR" $file || exit
+done
+
+
+# Import from gettext.
+with_gettext=yes
+grep '^[ ]*AM_GNU_GETTEXT_VERSION(' configure.ac >/dev/null || + with_gettext=no
+
+if test $with_gettext = yes; then
+ echo "$0: (cd $bt2; ${AUTOPOINT-autopoint}) ..."
+ cp configure.ac $bt2 &&
+ (cd $bt2 && ${AUTOPOINT-autopoint} && rm configure.ac) &&
+ slurp $bt2 $bt || exit
+fi
+rm -fr $bt $bt2 || exit
+
+# Remove any dangling symlink matching "*.m4" or "*.[ch]" in some
+# gnulib-populated directories. Such .m4 files would cause aclocal to fail.
+# The following requires GNU find 4.2.3 or newer. Considering the usual
+# portability constraints of this script, that may seem a very demanding
+# requirement, but it should be ok. Ignore any failure, which is fine,
+# since this is only a convenience to help developers avoid the relatively
+# unusual case in which a symlinked-to .m4 file is git-removed from gnulib
+# between successive runs of this script.
+find "$m4_base" "$source_base" + -depth ( -name '*.m4' -o -name '*.[ch]' ) + -type l -xtype l -delete > /dev/null 2>&1
+
+# Reconfigure, getting other files.
+
+# Skip autoheader if it's not needed.
+grep -E '^[ ]*AC_CONFIG_HEADERS?>' configure.ac >/dev/null ||
+ AUTOHEADER=true
+
+for command in + libtool + "${ACLOCAL-aclocal} --force -I m4" + "${AUTOCONF-autoconf} --force" + "${AUTOHEADER-autoheader} --force" + "${AUTOMAKE-automake} --add-missing --copy --force-missing"
+do
+ if test "$command" = libtool; then
+ use_libtool=0
+ # We'd like to use grep -E, to see if any of LT_INIT,
+ # AC_PROG_LIBTOOL, AM_PROG_LIBTOOL is used in configure.ac,
+ # but that's not portable enough (e.g., for Solaris).
+ grep '^[ ]*A[CM]_PROG_LIBTOOL' configure.ac >/dev/null + && use_libtool=1
+ grep '^[ ]*LT_INIT' configure.ac >/dev/null + && use_libtool=1
+ test $use_libtool = 0 + && continue
+ command="${LIBTOOLIZE-libtoolize} -c -f"
+ fi
+ echo "$0: $command ..."
+ $command || exit
+done
+
+
+# Get some extra files from gnulib, overriding existing files.
+for file in $gnulib_extra_files; do
+ case $file in
+ */INSTALL) dst=INSTALL;;
+ build-aux/*) dst=$build_aux/`expr "$file" : 'build-aux/(.*)'`;;
+ *) dst=$file;;
+ esac
+ symlink_to_dir "$GNULIB_SRCDIR" $file $dst || exit
+done
+
+if test $with_gettext = yes; then
+ # Create gettext configuration.
+ echo "$0: Creating po/Makevars from po/Makevars.template ..."
+ rm -f po/Makevars
+ sed '
+ /^EXTRA_LOCALE_CATEGORIES *=/s/=.*/= '"$EXTRA_LOCALE_CATEGORIES"'/
+ /^COPYRIGHT_HOLDER *=/s/=.*/= '"$COPYRIGHT_HOLDER"'/
+ /^MSGID_BUGS_ADDRESS *=/s|=.*|= '"$MSGID_BUGS_ADDRESS"'|
+ /^XGETTEXT_OPTIONS *=/{
+ s/$/ \/
+ a+ '"$XGETTEXT_OPTIONS"' $${end_of_xgettext_options+}
+ }
+ ' po/Makevars.template >po/Makevars || exit 1
+
+ if test -d runtime-po; then
+ # Similarly for runtime-po/Makevars, but not quite the same.
+ rm -f runtime-po/Makevars
+ sed '
+ /^DOMAIN *=.*/s/=.*/= '"$package"'-runtime/
+ /^subdir *=.*/s/=.*/= runtime-po/
+ /^MSGID_BUGS_ADDRESS *=/s/=.*/= bug-'"$package"'@gnu.org/
+ /^XGETTEXT_OPTIONS *=/{
+ s/$/ \/
+ a+ '"$XGETTEXT_OPTIONS_RUNTIME"' $${end_of_xgettext_options+}
+ }
+ ' po/Makevars.template >runtime-po/Makevars || exit 1
+
+ # Copy identical files from po to runtime-po.
+ (cd po && cp -p Makefile.in.in *-quot *.header *.sed *.sin ../runtime-po)
+ fi
+fi
+
+bootstrap_epilogue
+
+echo "$0: done. Now you can run './configure'."
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-time-zone: "UTC"
+# time-stamp-end: "; # UTC"
+# End:
diff --git a/bootstrap.conf b/bootstrap.conf
new file mode 100644
index 0000000..d1fbb3a
--- /dev/null
+++ b/bootstrap.conf
@@ -0,0 +1,96 @@
+# Bootstrap configuration.
+
+# Copyright (C) 2006-2010 Free Software Foundation, Inc.
+
+# This program 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.
+
+# This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
+
+
+# gnulib modules used by this package.
+gnulib_modules='
+announce-gen
+c-ctype
+closeout
+dirname
+do-release-commit-and-tag
+error
+getopt-gnu
+gettext-h
+git-version-gen
+gitlog-to-changelog
+gnu-web-doc-update
+gnupload
+malloc-gnu
+maintainer-makefile
+manywarnings
+progname
+quotearg
+realloc-gnu
+ssize_t
+stddef
+stdlib
+stpcpy
+strerror
+string
+strtol
+strtoul
+strtoull
+strtoumax
+unistd
+unlocked-io
+update-copyright
+useless-if-before-free
+version-etc-fsf
+xalloc
+xstrtoumax
+'
+
+gnulib_name=libiwhd
+
+checkout_only_file=
+MSGID_BUGS_ADDRESS=iwhd-devel(a)fedorahosted.org
+
+# Additional xgettext options to use. Use "\newline" to break lines.
+XGETTEXT_OPTIONS=$XGETTEXT_OPTIONS'\+ --from-code=UTF-8\+ --flag=asprintf:2:c-format --flag=vasprintf:2:c-format\+ --flag=asnprintf:3:c-format --flag=vasnprintf:3:c-format\+ --flag=wrapf:1:c-format\+ --flag=error:3:c-format --flag=error_at_line:5:c-format\+'
+
+# Automake requires that ChangeLog exist.
+test -f ChangeLog || touch ChangeLog || exit 1
+
+gnulib_tool_option_extras="--tests-base=$bt/gnulib-tests --with-tests"
+
+# Build prerequisites
+buildreq="+autoconf 2.62
+automake 1.11.1
+autopoint -
+gettext -
+git 1.4.4
+gzip -
+makeinfo -
+rsync -
+tar -
+"
+
+bootstrap_epilogue()
+{
+ # Change paths in gnulib-tests/gnulib.mk from "../.." to "..".
+ m=gnulib-tests/gnulib.mk
+ sed 's,../..,..,g' $m > $m-t
+ mv -f $m-t $m
+}
diff --git a/cfg.mk b/cfg.mk
new file mode 100644
index 0000000..d92f4ce
--- /dev/null
+++ b/cfg.mk
@@ -0,0 +1,73 @@
+# Customize maint.mk -*- makefile -*-
+# Copyright (C) 2009-2010 Free Software Foundation, Inc.
+
+# This program 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.
+
+# This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Used in maint.mk's web-manual rule
+manual_title = GNU Grep: Print lines matching a pattern
+
+# Fixing these can wait.
+skip_low_priority = + sc_bindtextdomain + sc_texinfo_acronym + sc_prohibit_atoi_atof + sc_prohibit_tab_based_indentation + sc_prohibit_strcmp + sc_unmarked_diagnostics + sc_error_message_uppercase + sc_file_system
+
+# Tests not to run as part of "make distcheck".
+local-checks-to-skip = + sc_m4_quote_check + sc_program_name + sc_prohibit_assert_without_use + sc_prohibit_echo_minus_en + sc_prohibit_empty_lines_at_EOF + sc_prohibit_getopt_without_use + sc_prohibit_test_minus_ao + sc_prohibit_strings_without_use + sc_space_tab + sc_trailing_blank + sc_useless_cpp_parens + $(skip_low_priority)
+
+# Tools used to bootstrap this package, used for "announcement".
+bootstrap-tools = autoconf,automake,gnulib
+
+# Now that we have better tests, make this the default.
+export VERBOSE = yes
+
+old_NEWS_hash = d41d8cd98f00b204e9800998ecf8427e
+
+sc_prohibit_echo_minus_en:
+ @prohibit='<echo -[en]' + halt='do not use echo ''-e or echo ''-n; use printf instead' + $(_sc_search_regexp)
+
+# Indent only with spaces.
+sc_prohibit_tab_based_indentation:
+ @prohibit='^ * ' + halt='TAB in indentation; use only spaces' + $(_sc_search_regexp)
+
+# Don't use "indent-tabs-mode: nil" anymore. No longer needed.
+sc_prohibit_emacs__indent_tabs_mode__setting:
+ @prohibit='^( *[*#] *)?indent-tabs-mode:' + halt='use of emacs indent-tabs-mode: setting' + $(_sc_search_regexp)
+
+update-copyright-env = + UPDATE_COPYRIGHT_USE_INTERVALS=1 + UPDATE_COPYRIGHT_MAX_LINE_LENGTH=79
diff --git a/configure.ac b/configure.ac
index 83bebcf..2e1e5a1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -17,7 +17,9 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
AC_PREREQ([2.65])
-AC_INIT([iwhd], [1.0], [iwhd-devel(a)fedorahosted.org])
+AC_INIT([iwhd],
+ m4_esyscmd([build-aux/git-version-gen .tarball-version]),
+ [iwhd-devel(a)fedorahosted.org])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_HEADERS([config.h:config.hin])
@@ -28,6 +30,12 @@ AM_SILENT_RULES([yes]) # make --enable-silent-rules the default.
AC_PROG_CXX
AC_PROG_CC
AM_PROG_CC_C_O
+gl_EARLY
+AC_PROG_RANLIB
+AC_TYPE_UINT64_T
+
+gl_INIT
+
AC_PROG_YACC
AC_PROG_LEX
AM_MISSING_PROG([HELP2MAN], [help2man])
@@ -71,22 +79,11 @@ AX_BOOST_BASE
AX_BOOST_SYSTEM
AX_BOOST_THREAD
-# Checks for header files.
-AC_CHECK_HEADERS([fcntl.h stdint.h stdlib.h string.h strings.h sys/time.h unistd.h])
-
-# Checks for typedefs, structures, and compiler characteristics.
-AC_HEADER_STDBOOL
-AC_TYPE_SIZE_T
-AC_TYPE_UINT64_T
-
-# Checks for library functions.
-AC_FUNC_MALLOC
-AC_FUNC_REALLOC
-AC_CHECK_FUNCS([gettimeofday memmove memset strcasecmp strdup strndup strtoul])
-
AC_CONFIG_FILES([
Makefile
-t/Makefile
+gnulib-tests/Makefile
+lib/Makefile
man/Makefile
+t/Makefile
])
AC_OUTPUT
diff --git a/doc/.gitignore b/doc/.gitignore
new file mode 100644
index 0000000..df37308
--- /dev/null
+++ b/doc/.gitignore
@@ -0,0 +1 @@
+gendocs_template
diff --git a/gnulib b/gnulib
new file mode 160000
index 0000000..cc98e1e
--- /dev/null
+++ b/gnulib
@@ -0,0 +1 @@
+Subproject commit cc98e1ec101be0b8d260025b5e40bfec7f4b1ac5
diff --git a/gnulib-tests/.gitignore b/gnulib-tests/.gitignore
new file mode 100644
index 0000000..1c5d7c6
--- /dev/null
+++ b/gnulib-tests/.gitignore
@@ -0,0 +1,97 @@
+alloca.h
+alloca.in.h
+binary-io.h
+dup2.c
+fcntl.h
+fcntl.in.h
+getpagesize.c
+gnulib.mk
+ignore-value.h
+init.sh
+lstat.c
+macros.h
+malloca.c
+malloca.h
+malloca.valgrind
+open.c
+pathmax.h
+putenv.c
+same-inode.h
+setenv.c
+signature.h
+stat.c
+symlink.c
+sys
+sys_stat.h
+sys_stat.in.h
+test-alloca-opt.c
+test-binary-io.c
+test-binary-io.sh
+test-c-ctype.c
+test-dirname.c
+test-dup2.c
+test-environ.c
+test-errno.c
+test-fcntl-h.c
+test-fpending.c
+test-fpending.sh
+test-getopt.c
+test-getopt.h
+test-getopt_long.h
+test-inttypes.c
+test-lstat.c
+test-lstat.h
+test-malloc-gnu.c
+test-malloca.c
+test-mbrtowc.c
+test-mbrtowc1.sh
+test-mbrtowc2.sh
+test-mbrtowc3.sh
+test-mbrtowc4.sh
+test-mbsinit.c
+test-mbsinit.sh
+test-memchr.c
+test-open.c
+test-open.h
+test-quotearg-simple.c
+test-quotearg.h
+test-realloc-gnu.c
+test-setenv.c
+test-stat.c
+test-stat.h
+test-stdbool.c
+test-stddef.c
+test-stdint.c
+test-stdlib.c
+test-strerror.c
+test-string.c
+test-strnlen.c
+test-symlink.c
+test-symlink.h
+test-sys_stat.c
+test-sys_wait.c
+test-sys_wait.h
+test-time.c
+test-unistd.c
+test-unsetenv.c
+test-update-copyright.sh
+test-vc-list-files-cvs.sh
+test-vc-list-files-git.sh
+test-verify.c
+test-verify.sh
+test-version-etc.c
+test-version-etc.sh
+test-wchar.c
+test-wctype.c
+test-xalloc-die.c
+test-xalloc-die.sh
+test-xstrtol.c
+test-xstrtol.sh
+test-xstrtoul.c
+test-xstrtoumax.c
+test-xstrtoumax.sh
+time.h
+time.in.h
+unsetenv.c
+wctob.c
+zerosize-ptr.h
diff --git a/gnulib-tests/Makefile.am b/gnulib-tests/Makefile.am
new file mode 100644
index 0000000..c3a48e8
--- /dev/null
+++ b/gnulib-tests/Makefile.am
@@ -0,0 +1,3 @@
+include gnulib.mk
+
+AM_CFLAGS = $(GNULIB_WARN_CFLAGS) # $(WERROR_CFLAGS)
diff --git a/lib/.gitignore b/lib/.gitignore
new file mode 100644
index 0000000..8d76533
--- /dev/null
+++ b/lib/.gitignore
@@ -0,0 +1,94 @@
+basename-lgpl.c
+basename.c
+c-ctype.c
+c-ctype.h
+close-stream.c
+close-stream.h
+closeout.c
+closeout.h
+config.charset
+dirname-lgpl.c
+dirname.c
+dirname.h
+errno.h
+errno.in.h
+error.c
+error.h
+exitfail.c
+exitfail.h
+fpending.c
+fpending.h
+getopt.c
+getopt.h
+getopt.in.h
+getopt1.c
+getopt_int.h
+gettext.h
+gnulib.mk
+intprops.h
+inttypes.h
+inttypes.in.h
+localcharset.c
+localcharset.h
+malloc.c
+mbrtowc.c
+mbsinit.c
+memchr.c
+memchr.valgrind
+progname.c
+progname.h
+quotearg.c
+quotearg.h
+realloc.c
+ref-add.sed
+ref-add.sin
+ref-del.sed
+ref-del.sin
+stdarg.h
+stdarg.in.h
+stdbool.h
+stdbool.in.h
+stddef.h
+stddef.in.h
+stdint.h
+stdint.in.h
+stdlib.h
+stdlib.in.h
+stpcpy.c
+streq.h
+strerror.c
+string.h
+string.in.h
+stripslash.c
+strndup.c
+strnlen.c
+strtoimax.c
+strtol.c
+strtoll.c
+strtoul.c
+strtoull.c
+strtoumax.c
+sys
+sys_wait.h
+sys_wait.in.h
+unistd.h
+unistd.in.h
+unlocked-io.h
+verify.h
+version-etc-fsf.c
+version-etc.c
+version-etc.h
+wchar.h
+wchar.in.h
+wctype.h
+wctype.in.h
+xalloc-die.c
+xalloc.h
+xmalloc.c
+xstrndup.c
+xstrndup.h
+xstrtol-error.c
+xstrtol.c
+xstrtol.h
+xstrtoul.c
+xstrtoumax.c
diff --git a/lib/Makefile.am b/lib/Makefile.am
new file mode 100644
index 0000000..7871533
--- /dev/null
+++ b/lib/Makefile.am
@@ -0,0 +1,23 @@
+## Makefile for gnulib/lib -*-Makefile-*-
+
+# Copyright (C) 1995-2007, 2009-2010 Free Software Foundation, Inc.
+
+## This program 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.
+##
+## This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
+
+include gnulib.mk
+
+AM_CFLAGS += $(GNULIB_WARN_CFLAGS) $(WERROR_CFLAGS)
+
+libiwhd_a_LIBADD += $(LIBOBJS)
+libiwhd_a_DEPENDENCIES += $(LIBOBJS)
diff --git a/ax/ax_boost_base.m4 b/m4/ax_boost_base.m4
similarity index 100%
rename from ax/ax_boost_base.m4
rename to m4/ax_boost_base.m4
diff --git a/ax/ax_boost_system.m4 b/m4/ax_boost_system.m4
similarity index 100%
rename from ax/ax_boost_system.m4
rename to m4/ax_boost_system.m4
diff --git a/ax/ax_boost_thread.m4 b/m4/ax_boost_thread.m4
similarity index 100%
rename from ax/ax_boost_thread.m4
rename to m4/ax_boost_thread.m4
diff --git a/rest.c b/rest.c
index cc75f68..8c1860c 100644
--- a/rest.c
+++ b/rest.c
@@ -975,7 +975,7 @@ root_blob_generator (void *ctx, uint64_t pos, char *buf, size_t max)
}
ms->cleanup |= CLEANUP_TMPL;
ms->gen_ctx->base = host;
- len = tmpl_root_header(ms->gen_ctx,"image_warehouse","1.0");
+ len = tmpl_root_header(ms->gen_ctx,"image_warehouse",VERSION);
if (!len) {
return -1;
}
-----------------------------------------------------------------------
repo.or.cz automatic notification. Contact project admin jim(a)meyering.net
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
iwhd.git ("image warehouse daemon")
13 years, 6 months
[repo.or.cz] iwhd.git branch master updated: v0.0-248-gdf00ac3
by Jim Meyering
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project iwhd.git.
The branch, master has been updated
via df00ac3954bf66d4f6026f6dc787514f6e76a96c (commit)
from 2f9bb3adf0e201fd00c1b1abbd95dee892a67995 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://repo.or.cz/w/iwhd.git/commit/df00ac3954bf66d4f6026f6dc787514f6e76a96c
commit df00ac3954bf66d4f6026f6dc787514f6e76a96c
Author: Jim Meyering <meyering(a)redhat.com>
Date: Fri Dec 10 21:34:54 2010 +0100
tests: wait for up to 5 seconds for start-up, not just 3s
* t/replication: When running via valgrind wrappers,
3 seconds was not enough.
* t/basic: Likewise.
diff --git a/t/basic b/t/basic
index 3d610d9..6a30fcc 100644
--- a/t/basic
+++ b/t/basic
@@ -20,8 +20,8 @@ mongod --port $m_port --pidfilepath mongod/pid --dbpath mongod > mongod.log 2>&1
mongo_pid=$!
cleanup_() { kill -9 $mongo_pid; }
-# Wait for up to 3 seconds for mongod to begin listening.
-wait_for .1 30 'mongo localhost:$m_port < /dev/null' +# Wait for up to 5 seconds for mongod to begin listening.
+wait_for .1 50 'mongo localhost:$m_port < /dev/null' || framework_failure_ mongod failed to start
port=9091
@@ -137,8 +137,8 @@ iwhd -v -p $port -c iwhd.cfg -d localhost:$m_port &
iwhd_pid=$!
cleanup_() { kill -9 $mongo_pid; kill $iwhd_pid; }
-# Wait for up to 3 seconds for iwhd to begin listening on $port.
-wait_for .1 30 "curl -s http://localhost:$port" +# Wait for up to 5 seconds for iwhd to begin listening on $port.
+wait_for .1 50 "curl -s http://localhost:$port" || { echo iwhd failed to listen; Exit 1; }
# Create an empty bucket.
@@ -257,7 +257,6 @@ for i in xml json; do
done
-
# Add a single attribute to an object using the PUT method.
bucket=$bucket
printf nothing | curl -T - $bucket/attr_put || fail=1
diff --git a/t/replication b/t/replication
index 74423f2..835fa68 100644
--- a/t/replication
+++ b/t/replication
@@ -33,7 +33,7 @@ EOF
port=9092
iwhd -v -p $port -c iwhd_u.cfg -d localhost:$m_port &
iwhd_pid=$!
-wait_for .1 30 "curl http://localhost:$port" +wait_for .1 50 "curl http://localhost:$port" || framework_failure_ "iwhd upstream"
cleanup_() { kill -9 $mongo_pid; kill $iwhd_pid; }
@@ -46,7 +46,7 @@ EOF
d_port=9093
iwhd -v -p $d_port -c iwhd_d.cfg -d localhost:$m_port -m localhost:$port &
iwhd_d_pid=$!
-wait_for .1 30 "curl http://localhost:$d_port" +wait_for .1 50 "curl http://localhost:$d_port" || framework_failure_ "iwhd downstream"
cleanup_() { kill -9 $mongo_pid; kill $iwhd_pid $iwhd_d_pid; }
-----------------------------------------------------------------------
Summary of changes:
t/basic | 9 ++++-----
t/replication | 4 ++--
2 files changed, 6 insertions(+), 7 deletions(-)
repo.or.cz automatic notification. Contact project admin jim(a)meyering.net
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
iwhd.git ("image warehouse daemon")
13 years, 6 months
[repo.or.cz] iwhd.git branch master updated: v0.0-247-g2f9bb3a
by Jim Meyering
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project iwhd.git.
The branch, master has been updated
via 2f9bb3adf0e201fd00c1b1abbd95dee892a67995 (commit)
via d0ceff3457d861291f2139af3cad17fb423cddee (commit)
from 604fc112cbda1ab89d8c94554055e447ab225c6d (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://repo.or.cz/w/iwhd.git/commit/2f9bb3adf0e201fd00c1b1abbd95dee892a67995
commit 2f9bb3adf0e201fd00c1b1abbd95dee892a67995
Author: Jim Meyering <meyering(a)redhat.com>
Date: Tue Dec 14 18:09:20 2010 +0100
use strchr and strrchr, not index or rindex
* backend.c (curl_cache_child): s/index/strchr/
* rest.c (validate_url, register_image): Likewise and s/rindex/strrchr/
diff --git a/backend.c b/backend.c
index 173586d..6f5945c 100644
--- a/backend.c
+++ b/backend.c
@@ -726,7 +726,7 @@ curl_cache_child (void * ctx)
curl_easy_perform(curl);
curl_easy_cleanup(curl);
- slash = index(my_url+1,'/');
+ slash = strchr(my_url+1,'/');
if (slash) {
*slash = '0';
meta_got_copy(my_url+1,slash+1,me);
diff --git a/rest.c b/rest.c
index 4512e71..cc75f68 100644
--- a/rest.c
+++ b/rest.c
@@ -154,7 +154,7 @@ is_reserved (const char *cand, char const *const *resv_list)
static int
validate_url (const char *url)
{
- char *slash = rindex(url,'/');
+ char *slash = strrchr(url,'/');
if (!slash) {
/* There should be at least one betwixt bucket and key. */
@@ -1334,7 +1334,7 @@ register_image (my_state *ms)
return MHD_HTTP_BAD_REQUEST;
}
- next = index(site,':');
+ next = strchr(site,':');
if (next) {
*(next++) = '0';
}
http://repo.or.cz/w/iwhd.git/commit/d0ceff3457d861291f2139af3cad17fb423cddee
commit d0ceff3457d861291f2139af3cad17fb423cddee
Author: Jim Meyering <meyering(a)redhat.com>
Date: Wed Dec 15 18:47:09 2010 +0100
fix trivial comment typo
diff --git a/rest.c b/rest.c
index aa9854a..4512e71 100644
--- a/rest.c
+++ b/rest.c
@@ -478,7 +478,7 @@ proxy_put_data (void *cctx, struct MHD_Connection *conn, const char *url,
* this callback without an error response, Microhttpd posts
* the "100 Continue" header and the client starts sending
* the data. We must report errors here or forever keep
- * out peace.
+ * our peace.
*/
rc = pipe_prod_wait_init(&ms->pipe);
if (rc != 0) {
-----------------------------------------------------------------------
Summary of changes:
backend.c | 2 +-
rest.c | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
repo.or.cz automatic notification. Contact project admin jim(a)meyering.net
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
iwhd.git ("image warehouse daemon")
13 years, 6 months
[repo.or.cz] iwhd.git branch master updated: v0.0-245-g604fc11
by Jim Meyering
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project iwhd.git.
The branch, master has been updated
via 604fc112cbda1ab89d8c94554055e447ab225c6d (commit)
via ddf6a9609e1663eb5444232b77446ae2c5b1da0a (commit)
from 56bccd9c5ee7dfce955b38519f89b34b5a14e9ec (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://repo.or.cz/w/iwhd.git/commit/604fc112cbda1ab89d8c94554055e447ab225c6d
commit 604fc112cbda1ab89d8c94554055e447ab225c6d
Author: Jim Meyering <meyering(a)redhat.com>
Date: Sat Dec 11 15:41:52 2010 +0100
plug a leak
rest.c (proxy_put_data): Plug a leak exposed by reserved-object-name
testing. Without this, "make -C t check TESTS=basic" with valgrind-
wrapped iwhd would leak one "ms" object per reserved word test here:
for obj_name in _default _new _policy _query; do
echo reserved-obj-name | curl -f -T - $bucket/$obj_name 2> bad_oname.err
...
2,240 bytes in 4 blocks are definitely lost in loss record 311 of 316
at 0x4A04896: calloc (vg_replace_malloc.c:418)
by 0x42EA18: access_handler (rest.c:1967)
by 0x4E405F8: ??? (in /usr/lib64/libmicrohttpd.so.10.0.0)
by 0x4E4105F: MHD_connection_handle_idle (in /usr/lib64/libmicrohttpd.so.10.0.0)
by 0x4E43986: ??? (in /usr/lib64/libmicrohttpd.so.10.0.0)
by 0x3F49806D5A: start_thread (pthread_create.c:301)
by 0x3F48CE4AAC: clone (clone.S:115)
diff --git a/rest.c b/rest.c
index bcb32b4..aa9854a 100644
--- a/rest.c
+++ b/rest.c
@@ -452,6 +452,7 @@ proxy_put_data (void *cctx, struct MHD_Connection *conn, const char *url,
}
MHD_queue_response(conn,MHD_HTTP_FORBIDDEN,resp);
MHD_destroy_response(resp);
+ free_ms(ms);
return MHD_YES;
}
ms->state = MS_NORMAL;
http://repo.or.cz/w/iwhd.git/commit/ddf6a9609e1663eb5444232b77446ae2c5b1da0a
commit ddf6a9609e1663eb5444232b77446ae2c5b1da0a
Author: Jim Meyering <meyering(a)redhat.com>
Date: Sat Dec 11 17:43:35 2010 +0100
plug leaks-after-OOM-failure
* rest.c (proxy_object_post, proxy_update_prov): Call free_ms
before returning.
diff --git a/rest.c b/rest.c
index d07e9b5..bcb32b4 100644
--- a/rest.c
+++ b/rest.c
@@ -1511,6 +1511,7 @@ proxy_object_post (void *cctx, struct MHD_Connection *conn, const char *url,
MHD_NO,MHD_NO);
if (!resp) {
fprintf(stderr,"MHD_crfd failedn");
+ free_ms(ms);
return MHD_NO;
}
MHD_queue_response(conn,rc,resp);
@@ -1678,8 +1679,8 @@ proxy_update_prov (void *cctx, struct MHD_Connection *conn, const char *url,
resp = MHD_create_response_from_data(0,NULL,MHD_NO,MHD_NO);
if (!resp) {
fprintf(stderr,"MHD_crfd failedn");
+ free_ms(ms);
return MHD_NO;
- // FIXME: be careful that this does not leak "ms"
}
MHD_queue_response(conn,rc,resp);
MHD_destroy_response(resp);
-----------------------------------------------------------------------
Summary of changes:
rest.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
repo.or.cz automatic notification. Contact project admin jim(a)meyering.net
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
iwhd.git ("image warehouse daemon")
13 years, 6 months