Exemplo n.º 1
0
int main()
{
	/* Initialize the peripheria */
	avr_lcd_init();

	DDRD =  B00001111;
	PORTD = B11110000;
	
	DDRC =  B00000001;
	PORTC = B00000000;
	
	/* 
	 * Check if there was some trickery. lock_device() only locks actually
	 * if there's a number of remaining wait time seconds greater than 0.
	 */
	lock_device();
	
	/* 
	 * Accumulate the user's keystrokes in this buffer
	 */
	char keystrokes[sizeof(code)];
	
	wait_for_passcode();
	
	while (1)
	{
		uint8_t row, col;
		if (scan_kb_matrix(&row, &col))
		{
			char c = chars[row][col];
			
			if (c == 'C') /* Clear/Cancel/Correct */
			{
				wait_for_passcode();
			}
			else if (c == '#') /* Enter/OK */
			{
				/* Memcmp returns zero upon equality */
				if (memcmp(code, keystrokes, cursor) || cursor != sizeof(code))
				{
					deny_access();
				}
				else
				{
					grant_access();
				}

				wait_for_passcode();
			}
			else
			{
				keystrokes[cursor++] = c;
				avr_lcd_putc('*');
			}
		}
	}
	
	return 0;
}
Exemplo n.º 2
0
static int session_hook_func(lsi_param_t *param)
{
    int len;
    const char *qs = g_api->get_req_query_string(param->session, &len);
    if ((qs == NULL) || (len < sizeof(testuri)))
        return 0;

    int type = strtol(qs + sizeof(testuri) - 1, NULL, 10);
    return (type < 5) ? internal_redir(param) : deny_access(param);
}