Project

General

Profile

mod_magnet.patch

crypt, 2009-12-31 15:00

View differences:

lighttpd-1.5.0_orig/src/mod_magnet.c 2008-08-04 03:33:34.000000000 +0200
200 200
	return 0;
201 201
}
202 202

  
203
static int magnet_hashme(lua_State *L) {
204
	const char *s = luaL_checkstring(L, 1);
205

  
206
	long hash = 0x1505;
207
	for( ; *s; hash = ((hash << 5) + hash) + *s++);
208
	hash&= ~(1 << 31);
209

  
210
	lua_pushinteger(L, hash);
211

  
212
	return 1;
213
}
214

  
203 215
static int magnet_stat(lua_State *L) {
204 216
	const char *s = luaL_checkstring(L, 1);
205 217
	server *srv;
......
392 404
		MAGNET_ENV_REQUEST_METHOD,
393 405
		MAGNET_ENV_REQUEST_URI,
394 406
		MAGNET_ENV_REQUEST_ORIG_URI,
395
		MAGNET_ENV_REQUEST_PROTOCOL
407
		MAGNET_ENV_REQUEST_PROTOCOL,
408

  
409
		MAGNET_ENV_REQUEST_TIME
396 410
       	} type;
397 411
} magnet_env_t;
398 412

  
......
416 430
		{ "request.orig-uri", MAGNET_ENV_REQUEST_ORIG_URI },
417 431
		{ "request.protocol", MAGNET_ENV_REQUEST_PROTOCOL },
418 432

  
433
		{ "request.time", MAGNET_ENV_REQUEST_TIME },
434

  
419 435
		{ NULL, MAGNET_ENV_UNSET }
420 436
	};
421 437

  
......
447 463
	case MAGNET_ENV_REQUEST_PROTOCOL: break;
448 464

  
449 465
	case MAGNET_ENV_UNSET: break;
466

  
467
	case MAGNET_ENV_REQUEST_TIME:
468
		buffer_copy_long(srv->tmp_buf, srv->cur_ts);
469
		dest = srv->tmp_buf;
470
		break;
450 471
	}
451 472

  
452 473
	return dest;
......
705 726
	lua_pushcfunction(L, magnet_print);                       /* (sp += 1) */
706 727
	lua_setfield(L, -2, "print"); /* -1 is the env we want to set(sp -= 1) */
707 728

  
729
	lua_pushcfunction(L, magnet_hashme);
730
	lua_setfield(L, -2, "hashme");
731

  
708 732
	/**
709 733
	 * lighty.request[] has the HTTP-request headers
710 734
	 * lighty.content[] is a table of string/file