src/t_enc_crc.c
static int
lt_enc_crc__Call( lua_State *L )
{
	struct t_enc_crc    *crc;
	int                  alg;

	lua_remove( L, 1 );
	crc = t_enc_crc_create_ud( L );
	alg = luaL_checkinteger( L, 1 );
	switch (alg)
	{
		case CRC_ALG_8:
			init_8( crc, POLY_8 );
			break;
		case CRC_ALG_16:
			init_16( crc, POLY_16 );
			break;
		case CRC_ALG_CCITT:
			init_ccitt( crc, POLY_CCIT );
			break;
		case CRC_ALG_CCITT_KRM:
			init_16( crc, POLY_CCITT_KRM );
			break;
		case CRC_ALG_32:
			init_32( crc, POLY_32 );
			break;
		default:
			luaL_error( L, "Unknown CRC algorithm" );
	}
	crc->bE = (lua_isboolean( L, 2 )) ? lua_toboolean( L, 2 ) : 1;

	return 1;
}
// ----------------------------- Lua CRC wrapper functions
/**--------------------------------------------------------------------------
 * Construct a CRC encoder and return it.
 * \param   L      Lua state.
 * \lparam  CLASS  table CRC
 * \lparam  key    key string (optional)
 * \lparam  kLen   length of key string (if key contains \0 bytes (optional))
 * \lreturn ud     T.Encode.Crc userdata.
 * \return  int    # of values pushed onto the stack.
 * --------------------------------------------------------------------------*/
Lua CRC wrapper functions
Construct a CRC encoder and return it.
\param   L      Lua state.
Lua CRC wrapper functions Construct a CRC encoder and return it . \ param L Lua state .
static int
lt_enc_crc__Call( lua_State *L )
{
	struct t_enc_crc    *crc;
	int                  alg;
	lua_remove( L, 1 );
	crc = t_enc_crc_create_ud( L );
	alg = luaL_checkinteger( L, 1 );
	switch (alg)
	{
		case CRC_ALG_8:
			init_8( crc, POLY_8 );
			break;
		case CRC_ALG_16:
			init_16( crc, POLY_16 );
			break;
		case CRC_ALG_CCITT:
			init_ccitt( crc, POLY_CCIT );
			break;
		case CRC_ALG_CCITT_KRM:
			init_16( crc, POLY_CCITT_KRM );
			break;
		case CRC_ALG_32:
			init_32( crc, POLY_32 );
			break;
		default:
			luaL_error( L, "Unknown CRC algorithm" );
	}
	crc->bE = (lua_isboolean( L, 2 )) ? lua_toboolean( L, 2 ) : 1;
	return 1;
}
static int lt_enc_crc__Call ( lua_State * L ) { struct t_enc_crc * crc ; int alg ; lua_remove ( L , 1 ) ; crc = t_enc_crc_create_ud ( L ) ; alg = luaL_checkinteger ( L , 1 ) ; switch ( alg ) { case CRC_ALG_8 : init_8 ( crc , POLY_8 ) ; break ; case CRC_ALG_16 : init_16 ( crc , POLY_16 ) ; break ; case CRC_ALG_CCITT : init_ccitt ( crc , POLY_CCIT ) ; break ; case CRC_ALG_CCITT_KRM : init_16 ( crc , POLY_CCITT_KRM ) ; break ; case CRC_ALG_32 : init_32 ( crc , POLY_32 ) ; break ; default : luaL_error ( L , " " ) ; } crc -> bE = ( lua_isboolean ( L , 2 ) ) ? lua_toboolean ( L , 2 ) : 1 ; return 1 ; }
Lua CRC wrapper functions
 Construct a CRC encoder and return it.
Lua CRC wrapper functions Construct a CRC encoder and return it .