示例#1
0
文件: http.c 项目: dankamongmen/snare
static int
set_default(const char *value,size_t vlen,icap_http_headers *headers,
		size_t offset,const char *description){
	char *tmp;

	if((tmp = Strndup(value,vlen)) == NULL){
		return -1;
	}
	// nag("%s <%s>\n",description,tmp);
	if(*(char **)((char *)headers + offset)){
		nag("Duplicated header: %s (%s->%s)\n",description,
			*(char **)((char *)headers + offset),tmp);
		inc_httpdupheader();
	}
	Free(*(char **)((char *)headers + offset));
	*(char **)((char *)headers + offset) = tmp;
	return 0;
}
示例#2
0
/*
 * Returns list's equivalent name. e.g for 'services_finished' it will return
 * a "FINISHED" string. We prefer capitals for debugging purposes. Caller must
 * free the string after it finishes using it.
 */
const char *ServiceGroup::
list2name(list <Service *> *list)
{
  const char *name = NULL;

  if (list == &services_active)
    name = Strndup("ACTIVE", sizeof("ACTIVE") - 1);
  else if (list == &services_wait)
    name = Strndup("WAIT", sizeof("WAIT") - 1);
  else if (list == &services_pairfini)
    name = Strndup("PAIRFINI", sizeof("PAIRFINI") - 1);
  else if (list == &services_full)
    name = Strndup("FULL", sizeof("FULL") - 1);
  else if (list == &services_finishing)
    name = Strndup("FINISHING", sizeof("FINISHING") - 1);
  else if (list == &services_finished)
    name = Strndup("FINISHED", sizeof("FINISHED") - 1);
  else
    error("%s Invalid list specified!\n", __func__);

  return name;
}