Exemplo n.º 1
0
static inline void _http_response_object_declare_default_properties(TSRMLS_D)
{
	zend_class_entry *ce = http_response_object_ce;

	DCL_STATIC_PROP(PRIVATE, bool, sent, 0);
	DCL_STATIC_PROP(PRIVATE, bool, catch, 0);
	DCL_STATIC_PROP(PRIVATE, long, mode, -1);
	DCL_STATIC_PROP(PRIVATE, long, stream, 0);
	DCL_STATIC_PROP_N(PRIVATE, file);
	DCL_STATIC_PROP_N(PRIVATE, data);
	DCL_STATIC_PROP(PROTECTED, bool, cache, 0);
	DCL_STATIC_PROP(PROTECTED, bool, gzip, 0);
	DCL_STATIC_PROP_N(PROTECTED, eTag);
	DCL_STATIC_PROP(PROTECTED, long, lastModified, 0);
	DCL_STATIC_PROP_N(PROTECTED, cacheControl);
	DCL_STATIC_PROP_N(PROTECTED, contentType);
	DCL_STATIC_PROP_N(PROTECTED, contentDisposition);
	DCL_STATIC_PROP(PROTECTED, long, bufferSize, HTTP_SENDBUF_SIZE);
	DCL_STATIC_PROP(PROTECTED, double, throttleDelay, 0.0);

#ifndef WONKY
	DCL_CONST(long, "REDIRECT", HTTP_REDIRECT);
	DCL_CONST(long, "REDIRECT_PERM", HTTP_REDIRECT_PERM);
	DCL_CONST(long, "REDIRECT_POST", HTTP_REDIRECT_POST);
	DCL_CONST(long, "REDIRECT_TEMP", HTTP_REDIRECT_TEMP);
	
	DCL_CONST(long, "ETAG_MD5", HTTP_ETAG_MD5);
	DCL_CONST(long, "ETAG_SHA1", HTTP_ETAG_SHA1);
	DCL_CONST(long, "ETAG_CRC32", HTTP_ETAG_CRC32);
	
#	ifdef HTTP_HAVE_MHASH
	{
		int l, i, c = mhash_count();
		
		for (i = 0; i <= c; ++i) {
			char const_name[256] = {0};
			const char *hash_name = mhash_get_hash_name_static(i);
			
			if (hash_name) {
				l = snprintf(const_name, 255, "ETAG_MHASH_%s", hash_name);
				zend_declare_class_constant_long(ce, const_name, l, i TSRMLS_CC);
			}
		}
	}
#	endif /* HTTP_HAVE_MHASH */
#endif /* WONKY */
}
Exemplo n.º 2
0
int main(void)
{
  hashid hashid;
  const char *s;
  int ok, allok = 1;

  for(hashid = 0; hashid <= mhash_count(); hashid++)
    if ((s = mhash_get_hash_name_static(hashid)) &&
	mhash_get_hash_pblock(hashid))
    {
      printf("Checking fragmentation capabilities of %s: ", s); 
      fflush(stdout);
      printf((ok = frag_test(hashid)) ? "OK\n" : "Failed\n");
      allok &= ok;
    }
  return allok ? 0 : 1;
}
Exemplo n.º 3
0
int main(void) {

	int i, buf_len;
	MHASH td1, td2, td3;
	const unsigned char *buf = "This is a test buffer to test saving and restoring, see?";
	unsigned char *hash1, *hash2;
	hashid alg;
	char mem[1024];
	int mem_size = sizeof(mem);

	buf_len = strlen(buf);

	/* NOTE: For laziness sake, I just loop through the enum, skipping invalid integers.
	   If the enum should change, this loop will have to change! */
	for (alg = 0; alg <= mhash_count(); ++alg) {
		
		/* if algorithm does not exist */
		if (mhash_get_hash_name_static( alg)==NULL)
			continue;

		printf("Testing save/restore for algorithm %s: ", mhash_get_hash_name(alg));

		td1 = mhash_init(alg);

		if (td1 == MHASH_FAILED) {
			fprintf(stderr, "Failed to init td1.\n");
			exit(1);
		}

		for (i = 0; i < buf_len; ++i)
			mhash(td1, buf+i, 1);

		hash1 = mhash_end(td1);

/*		printf("Hash 1: ");
		for (i = 0; i < mhash_get_block_size(alg); ++i)
			printf("%.2x", hash1[i]);
		printf("\n");
*/
		td2 = mhash_init(alg);

		if (td2 == MHASH_FAILED) {
			fprintf(stderr, "Failed to init td2.\n");
			exit(1);
		}

		for (i = 0; i < buf_len/2; ++i)
			mhash(td2, buf+i, 1);

		if (mhash_save_state_mem(td2, mem, &mem_size)!=0) {
			fprintf(stderr, "Error saving state. Size: %d\n", mem_size);
			exit(1);
		}

		td3 = mhash_restore_state_mem( mem);

		if (td3 == MHASH_FAILED) {
			fprintf(stderr, "Error restoring state.\n");
			exit(1);
		}

		for (i = buf_len/2; i < buf_len; ++i)
			mhash(td3, buf+i, 1);

		hash2 = mhash_end(td3);

/*		printf("Hash 2: ");
		for (i = 0; i < mhash_get_block_size(alg); ++i)
			printf("%.2x", hash2[i]);
		printf("\n");
*/
		if (memcmp(hash1, hash2, mhash_get_block_size(alg)) == 0) {
			printf("Ok\n");
		} else {
			printf("Failed\n");
			exit(1);
		}
	}
	exit(0);
}
Exemplo n.º 4
0
int main(void)
{
	mutils_word32 i;
	mutils_word32 buf_len;
	MHASH td1, td2, td3;
	const mutils_word8 *buf = (mutils_word8 *) "This is a test buffer to test saving and restoring, see?";
	mutils_word8 *hash1;
	mutils_word8 *hash2;
	hashid alg;
	mutils_word8 mem[1024];
	mutils_word32 mem_size = sizeof(mem);

	buf_len = mutils_strlen(buf);

	/*
	 * NOTE: For laziness sake, I just loop through the enum,
	 * skipping invalid integers.
	 *
	 * If the enum should change, this loop will have to change!
	 */

	for (alg = 0; alg <= mhash_count(); ++alg)
	{
		/* if algorithm does not exist */
	  if (mhash_get_hash_name_static(alg) == (mutils_word8 *) NULL)
			continue;

		printf("Testing save/restore for algorithm %s: ", mhash_get_hash_name(alg));

		td1 = mhash_init(alg);

		if (td1 == MHASH_FAILED)
		{
			fprintf(stderr, "Failed to init td1.\n");
			exit(MUTILS_INVALID_FUNCTION);
		}

		for (i = 0; i < buf_len; ++i)
		{
			mhash(td1, buf+i, 1);
		}

		hash1 = mhash_end(td1);

		td2 = mhash_init(alg);

		if (td2 == MHASH_FAILED)
		{
			fprintf(stderr, "Failed to init td2.\n");
			exit(MUTILS_INVALID_FUNCTION);
		}

		for (i = 0; i < buf_len/2; ++i)
		{
			mhash(td2, buf+i, 1);
		}

		if (mhash_save_state_mem(td2, mem, &mem_size)!=0)
		{
			fprintf(stderr, "Error saving state. Size: %d\n", mem_size);
			exit(MUTILS_INVALID_RESULT);
		}

		td3 = mhash_restore_state_mem( mem);

		if (td3 == MHASH_FAILED)
		{
			fprintf(stderr, "Error restoring state.\n");
			exit(MUTILS_INVALID_RESULT);
		}

		for (i = buf_len/2; i < buf_len; ++i)
		{
			mhash(td3, buf+i, 1);
		}

		hash2 = mhash_end(td3);

		if (mutils_memcmp(hash1, hash2, mhash_get_block_size(alg)) == 0)
		{
			printf("Ok\n");
		}
		else
		{
			printf("Failed\n");
			exit(MUTILS_INVALID_RESULT);
		}
	}
	exit(MUTILS_OK);
}