filename
stringlengths 3
9
| code
stringlengths 4
1.87M
|
---|---|
566227.c | /**
* \file string_hash.c
* \brief Computes a hash value for a string.
* \author Copyright (c) 2012 Jason Perkins and the Premake project
*/
#include "premake.h"
#include <string.h>
int string_hash(lua_State* L)
{
const char* str = luaL_checkstring(L, 1);
lua_pushnumber(L, (lua_Number)do_hash(str, 0));
return 1;
}
unsigned long do_hash(const char* str, int seed)
{
/* DJB2 hashing; see http://www.cse.yorku.ca/~oz/hash.html */
unsigned long hash = 5381;
if (seed != 0) {
hash = hash * 33 + seed;
}
while (*str) {
hash = hash * 33 + (*str);
str++;
}
return hash;
}
|
448514.c | #include "ring.h"
/* Copyright (c) 2018 Mahmoud Fayed <[email protected]> */
#include "libpq-fe.h"
RING_FUNC(ring_get_connection_started)
{
RING_API_RETNUMBER(CONNECTION_STARTED);
}
RING_FUNC(ring_get_connection_made)
{
RING_API_RETNUMBER(CONNECTION_MADE);
}
RING_FUNC(ring_get_connection_awaiting_response)
{
RING_API_RETNUMBER(CONNECTION_AWAITING_RESPONSE);
}
RING_FUNC(ring_get_connection_auth_ok)
{
RING_API_RETNUMBER(CONNECTION_AUTH_OK);
}
RING_FUNC(ring_get_connection_ssl_startup)
{
RING_API_RETNUMBER(CONNECTION_SSL_STARTUP);
}
RING_FUNC(ring_get_connection_setenv)
{
RING_API_RETNUMBER(CONNECTION_SETENV);
}
RING_FUNC(ring_get_connection_ok)
{
RING_API_RETNUMBER(CONNECTION_OK);
}
RING_FUNC(ring_get_pqping_ok)
{
RING_API_RETNUMBER(PQPING_OK);
}
RING_FUNC(ring_get_pqping_reject)
{
RING_API_RETNUMBER(PQPING_REJECT);
}
RING_FUNC(ring_get_pqping_no_response)
{
RING_API_RETNUMBER(PQPING_NO_RESPONSE);
}
RING_FUNC(ring_get_pqping_no_attempt)
{
RING_API_RETNUMBER(PQPING_NO_ATTEMPT);
}
RING_FUNC(ring_get_pgres_empty_query)
{
RING_API_RETNUMBER(PGRES_EMPTY_QUERY);
}
RING_FUNC(ring_get_pgres_command_ok)
{
RING_API_RETNUMBER(PGRES_COMMAND_OK);
}
RING_FUNC(ring_get_pgres_tuples_ok)
{
RING_API_RETNUMBER(PGRES_TUPLES_OK);
}
RING_FUNC(ring_get_pgres_copy_out)
{
RING_API_RETNUMBER(PGRES_COPY_OUT);
}
RING_FUNC(ring_get_pgres_copy_in)
{
RING_API_RETNUMBER(PGRES_COPY_IN);
}
RING_FUNC(ring_get_pgres_bad_response)
{
RING_API_RETNUMBER(PGRES_BAD_RESPONSE);
}
RING_FUNC(ring_get_pgres_nonfatal_error)
{
RING_API_RETNUMBER(PGRES_NONFATAL_ERROR);
}
RING_FUNC(ring_get_pgres_fatal_error)
{
RING_API_RETNUMBER(PGRES_FATAL_ERROR);
}
RING_FUNC(ring_get_pgres_copy_both)
{
RING_API_RETNUMBER(PGRES_COPY_BOTH);
}
RING_FUNC(ring_get_pgres_single_tuple)
{
RING_API_RETNUMBER(PGRES_SINGLE_TUPLE);
}
RING_FUNC(ring_get_pg_diag_severity)
{
RING_API_RETNUMBER(PG_DIAG_SEVERITY);
}
RING_FUNC(ring_get_pg_diag_sqlstate)
{
RING_API_RETNUMBER(PG_DIAG_SQLSTATE);
}
RING_FUNC(ring_get_pg_diag_message_primary)
{
RING_API_RETNUMBER(PG_DIAG_MESSAGE_PRIMARY);
}
RING_FUNC(ring_get_pg_diag_message_detail)
{
RING_API_RETNUMBER(PG_DIAG_MESSAGE_DETAIL);
}
RING_FUNC(ring_get_pg_diag_message_hint)
{
RING_API_RETNUMBER(PG_DIAG_MESSAGE_HINT);
}
RING_FUNC(ring_get_pg_diag_statement_position)
{
RING_API_RETNUMBER(PG_DIAG_STATEMENT_POSITION);
}
RING_FUNC(ring_get_pg_diag_internal_position)
{
RING_API_RETNUMBER(PG_DIAG_INTERNAL_POSITION);
}
RING_FUNC(ring_get_pg_diag_internal_query)
{
RING_API_RETNUMBER(PG_DIAG_INTERNAL_QUERY);
}
RING_FUNC(ring_get_pg_diag_context)
{
RING_API_RETNUMBER(PG_DIAG_CONTEXT);
}
RING_FUNC(ring_get_pg_diag_schema_name)
{
RING_API_RETNUMBER(PG_DIAG_SCHEMA_NAME);
}
RING_FUNC(ring_get_pg_diag_table_name)
{
RING_API_RETNUMBER(PG_DIAG_TABLE_NAME);
}
RING_FUNC(ring_get_pg_diag_column_name)
{
RING_API_RETNUMBER(PG_DIAG_COLUMN_NAME);
}
RING_FUNC(ring_get_pg_diag_datatype_name)
{
RING_API_RETNUMBER(PG_DIAG_DATATYPE_NAME);
}
RING_FUNC(ring_get_pg_diag_constraint_name)
{
RING_API_RETNUMBER(PG_DIAG_CONSTRAINT_NAME);
}
RING_FUNC(ring_get_pg_diag_source_file)
{
RING_API_RETNUMBER(PG_DIAG_SOURCE_FILE);
}
RING_FUNC(ring_get_pg_diag_source_line)
{
RING_API_RETNUMBER(PG_DIAG_SOURCE_LINE);
}
RING_FUNC(ring_get_pg_diag_source_function)
{
RING_API_RETNUMBER(PG_DIAG_SOURCE_FUNCTION);
}
RING_FUNC(ring_new_pqconninfooption)
{
PQconninfoOption *pMyPointer ;
pMyPointer = (PQconninfoOption *) ring_state_malloc(((VM *) pPointer)->pRingState,sizeof(PQconninfoOption)) ;
if (pMyPointer == NULL)
{
RING_API_ERROR(RING_OOM);
return ;
}
RING_API_RETCPOINTER(pMyPointer,"PQconninfoOption");
}
RING_FUNC(ring_new_managed_pqconninfooption)
{
PQconninfoOption *pMyPointer ;
pMyPointer = (PQconninfoOption *) ring_state_malloc(((VM *) pPointer)->pRingState,sizeof(PQconninfoOption)) ;
if (pMyPointer == NULL)
{
RING_API_ERROR(RING_OOM);
return ;
}
RING_API_RETMANAGEDCPOINTER(pMyPointer,"PQconninfoOption",ring_state_free);
}
RING_FUNC(ring_destroy_pqconninfooption)
{
PQconninfoOption *pMyPointer ;
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA) ;
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
pMyPointer = RING_API_GETCPOINTER(1,"PQconninfoOption");
if (pMyPointer != NULL) {
ring_state_free(((VM *) pPointer)->pRingState,pMyPointer) ;
RING_API_SETNULLPOINTER(1);
}
}
RING_FUNC(ring_get_pqconninfooption_keyword)
{
PQconninfoOption *pMyPointer ;
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA) ;
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
pMyPointer = RING_API_GETCPOINTER(1,"PQconninfoOption");
RING_API_RETCPOINTER(pMyPointer->keyword,"char");
}
RING_FUNC(ring_set_pqconninfooption_keyword)
{
PQconninfoOption *pMyPointer ;
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA) ;
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
pMyPointer = RING_API_GETCPOINTER(1,"PQconninfoOption");
pMyPointer->keyword = (char *) RING_API_GETCPOINTER(2,"char");
}
RING_FUNC(ring_get_pqconninfooption_envvar)
{
PQconninfoOption *pMyPointer ;
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA) ;
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
pMyPointer = RING_API_GETCPOINTER(1,"PQconninfoOption");
RING_API_RETCPOINTER(pMyPointer->envvar,"char");
}
RING_FUNC(ring_set_pqconninfooption_envvar)
{
PQconninfoOption *pMyPointer ;
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA) ;
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
pMyPointer = RING_API_GETCPOINTER(1,"PQconninfoOption");
pMyPointer->envvar = (char *) RING_API_GETCPOINTER(2,"char");
}
RING_FUNC(ring_get_pqconninfooption_compiled)
{
PQconninfoOption *pMyPointer ;
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA) ;
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
pMyPointer = RING_API_GETCPOINTER(1,"PQconninfoOption");
RING_API_RETCPOINTER(pMyPointer->compiled,"char");
}
RING_FUNC(ring_set_pqconninfooption_compiled)
{
PQconninfoOption *pMyPointer ;
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA) ;
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
pMyPointer = RING_API_GETCPOINTER(1,"PQconninfoOption");
pMyPointer->compiled = (char *) RING_API_GETCPOINTER(2,"char");
}
RING_FUNC(ring_get_pqconninfooption_val)
{
PQconninfoOption *pMyPointer ;
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA) ;
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
pMyPointer = RING_API_GETCPOINTER(1,"PQconninfoOption");
RING_API_RETCPOINTER(pMyPointer->val,"char");
}
RING_FUNC(ring_set_pqconninfooption_val)
{
PQconninfoOption *pMyPointer ;
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA) ;
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
pMyPointer = RING_API_GETCPOINTER(1,"PQconninfoOption");
pMyPointer->val = (char *) RING_API_GETCPOINTER(2,"char");
}
RING_FUNC(ring_get_pqconninfooption_label)
{
PQconninfoOption *pMyPointer ;
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA) ;
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
pMyPointer = RING_API_GETCPOINTER(1,"PQconninfoOption");
RING_API_RETCPOINTER(pMyPointer->label,"char");
}
RING_FUNC(ring_set_pqconninfooption_label)
{
PQconninfoOption *pMyPointer ;
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA) ;
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
pMyPointer = RING_API_GETCPOINTER(1,"PQconninfoOption");
pMyPointer->label = (char *) RING_API_GETCPOINTER(2,"char");
}
RING_FUNC(ring_get_pqconninfooption_dispchar)
{
PQconninfoOption *pMyPointer ;
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA) ;
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
pMyPointer = RING_API_GETCPOINTER(1,"PQconninfoOption");
RING_API_RETCPOINTER(pMyPointer->dispchar,"char");
}
RING_FUNC(ring_set_pqconninfooption_dispchar)
{
PQconninfoOption *pMyPointer ;
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA) ;
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
pMyPointer = RING_API_GETCPOINTER(1,"PQconninfoOption");
pMyPointer->dispchar = (char *) RING_API_GETCPOINTER(2,"char");
}
RING_FUNC(ring_get_pqconninfooption_dispsize)
{
PQconninfoOption *pMyPointer ;
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA) ;
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
pMyPointer = RING_API_GETCPOINTER(1,"PQconninfoOption");
RING_API_RETNUMBER(pMyPointer->dispsize);
}
RING_FUNC(ring_set_pqconninfooption_dispsize)
{
PQconninfoOption *pMyPointer ;
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA) ;
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
pMyPointer = RING_API_GETCPOINTER(1,"PQconninfoOption");
pMyPointer->dispsize = RING_API_GETNUMBER(2);
}
RING_FUNC(ring_new_pqprintopt)
{
PQprintOpt *pMyPointer ;
pMyPointer = (PQprintOpt *) ring_state_malloc(((VM *) pPointer)->pRingState,sizeof(PQprintOpt)) ;
if (pMyPointer == NULL)
{
RING_API_ERROR(RING_OOM);
return ;
}
RING_API_RETCPOINTER(pMyPointer,"PQprintOpt");
}
RING_FUNC(ring_new_managed_pqprintopt)
{
PQprintOpt *pMyPointer ;
pMyPointer = (PQprintOpt *) ring_state_malloc(((VM *) pPointer)->pRingState,sizeof(PQprintOpt)) ;
if (pMyPointer == NULL)
{
RING_API_ERROR(RING_OOM);
return ;
}
RING_API_RETMANAGEDCPOINTER(pMyPointer,"PQprintOpt",ring_state_free);
}
RING_FUNC(ring_destroy_pqprintopt)
{
PQprintOpt *pMyPointer ;
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA) ;
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
pMyPointer = RING_API_GETCPOINTER(1,"PQprintOpt");
if (pMyPointer != NULL) {
ring_state_free(((VM *) pPointer)->pRingState,pMyPointer) ;
RING_API_SETNULLPOINTER(1);
}
}
RING_FUNC(ring_get_pqprintopt_header)
{
PQprintOpt *pMyPointer ;
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA) ;
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
pMyPointer = RING_API_GETCPOINTER(1,"PQprintOpt");
RING_API_RETNUMBER(pMyPointer->header);
}
RING_FUNC(ring_set_pqprintopt_header)
{
PQprintOpt *pMyPointer ;
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA) ;
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
pMyPointer = RING_API_GETCPOINTER(1,"PQprintOpt");
pMyPointer->header = RING_API_GETNUMBER(2);
}
RING_FUNC(ring_get_pqprintopt_align)
{
PQprintOpt *pMyPointer ;
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA) ;
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
pMyPointer = RING_API_GETCPOINTER(1,"PQprintOpt");
RING_API_RETNUMBER(pMyPointer->align);
}
RING_FUNC(ring_set_pqprintopt_align)
{
PQprintOpt *pMyPointer ;
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA) ;
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
pMyPointer = RING_API_GETCPOINTER(1,"PQprintOpt");
pMyPointer->align = RING_API_GETNUMBER(2);
}
RING_FUNC(ring_get_pqprintopt_standard)
{
PQprintOpt *pMyPointer ;
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA) ;
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
pMyPointer = RING_API_GETCPOINTER(1,"PQprintOpt");
RING_API_RETNUMBER(pMyPointer->standard);
}
RING_FUNC(ring_set_pqprintopt_standard)
{
PQprintOpt *pMyPointer ;
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA) ;
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
pMyPointer = RING_API_GETCPOINTER(1,"PQprintOpt");
pMyPointer->standard = RING_API_GETNUMBER(2);
}
RING_FUNC(ring_get_pqprintopt_html3)
{
PQprintOpt *pMyPointer ;
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA) ;
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
pMyPointer = RING_API_GETCPOINTER(1,"PQprintOpt");
RING_API_RETNUMBER(pMyPointer->html3);
}
RING_FUNC(ring_set_pqprintopt_html3)
{
PQprintOpt *pMyPointer ;
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA) ;
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
pMyPointer = RING_API_GETCPOINTER(1,"PQprintOpt");
pMyPointer->html3 = RING_API_GETNUMBER(2);
}
RING_FUNC(ring_get_pqprintopt_expanded)
{
PQprintOpt *pMyPointer ;
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA) ;
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
pMyPointer = RING_API_GETCPOINTER(1,"PQprintOpt");
RING_API_RETNUMBER(pMyPointer->expanded);
}
RING_FUNC(ring_set_pqprintopt_expanded)
{
PQprintOpt *pMyPointer ;
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA) ;
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
pMyPointer = RING_API_GETCPOINTER(1,"PQprintOpt");
pMyPointer->expanded = RING_API_GETNUMBER(2);
}
RING_FUNC(ring_get_pqprintopt_pager)
{
PQprintOpt *pMyPointer ;
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA) ;
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
pMyPointer = RING_API_GETCPOINTER(1,"PQprintOpt");
RING_API_RETNUMBER(pMyPointer->pager);
}
RING_FUNC(ring_set_pqprintopt_pager)
{
PQprintOpt *pMyPointer ;
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA) ;
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
pMyPointer = RING_API_GETCPOINTER(1,"PQprintOpt");
pMyPointer->pager = RING_API_GETNUMBER(2);
}
RING_FUNC(ring_get_pqprintopt_fieldSep)
{
PQprintOpt *pMyPointer ;
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA) ;
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
pMyPointer = RING_API_GETCPOINTER(1,"PQprintOpt");
RING_API_RETCPOINTER(pMyPointer->fieldSep,"char");
}
RING_FUNC(ring_set_pqprintopt_fieldSep)
{
PQprintOpt *pMyPointer ;
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA) ;
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
pMyPointer = RING_API_GETCPOINTER(1,"PQprintOpt");
pMyPointer->fieldSep = (char *) RING_API_GETCPOINTER(2,"char");
}
RING_FUNC(ring_get_pqprintopt_tableOpt)
{
PQprintOpt *pMyPointer ;
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA) ;
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
pMyPointer = RING_API_GETCPOINTER(1,"PQprintOpt");
RING_API_RETCPOINTER(pMyPointer->tableOpt,"char");
}
RING_FUNC(ring_set_pqprintopt_tableOpt)
{
PQprintOpt *pMyPointer ;
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA) ;
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
pMyPointer = RING_API_GETCPOINTER(1,"PQprintOpt");
pMyPointer->tableOpt = (char *) RING_API_GETCPOINTER(2,"char");
}
RING_FUNC(ring_get_pqprintopt_caption)
{
PQprintOpt *pMyPointer ;
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA) ;
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
pMyPointer = RING_API_GETCPOINTER(1,"PQprintOpt");
RING_API_RETCPOINTER(pMyPointer->caption,"char");
}
RING_FUNC(ring_set_pqprintopt_caption)
{
PQprintOpt *pMyPointer ;
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA) ;
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
pMyPointer = RING_API_GETCPOINTER(1,"PQprintOpt");
pMyPointer->caption = (char *) RING_API_GETCPOINTER(2,"char");
}
RING_FUNC(ring_get_pqprintopt_fieldName)
{
PQprintOpt *pMyPointer ;
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA) ;
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
pMyPointer = RING_API_GETCPOINTER(1,"PQprintOpt");
RING_API_RETCPOINTER(pMyPointer->fieldName,"char");
}
RING_FUNC(ring_set_pqprintopt_fieldName)
{
PQprintOpt *pMyPointer ;
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA) ;
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
pMyPointer = RING_API_GETCPOINTER(1,"PQprintOpt");
pMyPointer->fieldName = (char *) RING_API_GETCPOINTER(2,"char");
}
RING_FUNC(ring_new_pqargblock)
{
PQArgBlock *pMyPointer ;
pMyPointer = (PQArgBlock *) ring_state_malloc(((VM *) pPointer)->pRingState,sizeof(PQArgBlock)) ;
if (pMyPointer == NULL)
{
RING_API_ERROR(RING_OOM);
return ;
}
RING_API_RETCPOINTER(pMyPointer,"PQArgBlock");
}
RING_FUNC(ring_new_managed_pqargblock)
{
PQArgBlock *pMyPointer ;
pMyPointer = (PQArgBlock *) ring_state_malloc(((VM *) pPointer)->pRingState,sizeof(PQArgBlock)) ;
if (pMyPointer == NULL)
{
RING_API_ERROR(RING_OOM);
return ;
}
RING_API_RETMANAGEDCPOINTER(pMyPointer,"PQArgBlock",ring_state_free);
}
RING_FUNC(ring_destroy_pqargblock)
{
PQArgBlock *pMyPointer ;
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA) ;
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
pMyPointer = RING_API_GETCPOINTER(1,"PQArgBlock");
if (pMyPointer != NULL) {
ring_state_free(((VM *) pPointer)->pRingState,pMyPointer) ;
RING_API_SETNULLPOINTER(1);
}
}
RING_FUNC(ring_get_pqargblock_len)
{
PQArgBlock *pMyPointer ;
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA) ;
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
pMyPointer = RING_API_GETCPOINTER(1,"PQArgBlock");
RING_API_RETNUMBER(pMyPointer->len);
}
RING_FUNC(ring_set_pqargblock_len)
{
PQArgBlock *pMyPointer ;
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA) ;
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
pMyPointer = RING_API_GETCPOINTER(1,"PQArgBlock");
pMyPointer->len = RING_API_GETNUMBER(2);
}
RING_FUNC(ring_get_pqargblock_isint)
{
PQArgBlock *pMyPointer ;
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA) ;
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
pMyPointer = RING_API_GETCPOINTER(1,"PQArgBlock");
RING_API_RETNUMBER(pMyPointer->isint);
}
RING_FUNC(ring_set_pqargblock_isint)
{
PQArgBlock *pMyPointer ;
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA) ;
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
pMyPointer = RING_API_GETCPOINTER(1,"PQArgBlock");
pMyPointer->isint = RING_API_GETNUMBER(2);
}
RING_FUNC(ring_get_pqargblock_u_integer)
{
PQArgBlock *pMyPointer ;
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA) ;
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
pMyPointer = RING_API_GETCPOINTER(1,"PQArgBlock");
RING_API_RETNUMBER(pMyPointer->u.integer);
}
RING_FUNC(ring_set_pqargblock_u_integer)
{
PQArgBlock *pMyPointer ;
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA) ;
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
pMyPointer = RING_API_GETCPOINTER(1,"PQArgBlock");
pMyPointer->u.integer = RING_API_GETNUMBER(2);
}
RING_FUNC(ring_get_pqargblock_u_ptr)
{
PQArgBlock *pMyPointer ;
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA) ;
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
pMyPointer = RING_API_GETCPOINTER(1,"PQArgBlock");
RING_API_RETCPOINTER(pMyPointer->u.ptr,"int");
}
RING_FUNC(ring_set_pqargblock_u_ptr)
{
PQArgBlock *pMyPointer ;
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA) ;
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
pMyPointer = RING_API_GETCPOINTER(1,"PQArgBlock");
pMyPointer->u.ptr = (int *) RING_API_GETCPOINTER(2,"int");
}
RING_FUNC(ring_PQconnectdbParams)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETCPOINTER(PQconnectdbParams((char **) RING_API_GETCPOINTER2POINTER(1,"char"),(char **) RING_API_GETCPOINTER2POINTER(2,"char"), (int ) RING_API_GETNUMBER(3)),"PGconn");
}
RING_FUNC(ring_PQconnectdb)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISSTRING(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETCPOINTER(PQconnectdb(RING_API_GETSTRING(1)),"PGconn");
}
RING_FUNC(ring_PQsetdbLogin)
{
if ( RING_API_PARACOUNT != 7 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
if ( ! RING_API_ISSTRING(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISSTRING(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISSTRING(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISSTRING(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISSTRING(5) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISSTRING(6) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISSTRING(7) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETCPOINTER(PQsetdbLogin(RING_API_GETSTRING(1),RING_API_GETSTRING(2),RING_API_GETSTRING(3),RING_API_GETSTRING(4),RING_API_GETSTRING(5),RING_API_GETSTRING(6),RING_API_GETSTRING(7)),"PGconn");
}
RING_FUNC(ring_PQsetdb)
{
if ( RING_API_PARACOUNT != 5 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
if ( ! RING_API_ISSTRING(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISSTRING(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISSTRING(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISSTRING(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISSTRING(5) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETCPOINTER(PQsetdb(RING_API_GETSTRING(1),RING_API_GETSTRING(2),RING_API_GETSTRING(3),RING_API_GETSTRING(4),RING_API_GETSTRING(5)),"PGconn");
}
RING_FUNC(ring_PQconnectStartParams)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETCPOINTER(PQconnectStartParams((char **) RING_API_GETCPOINTER2POINTER(1,"char"),(char **) RING_API_GETCPOINTER2POINTER(2,"char"), (int ) RING_API_GETNUMBER(3)),"PGconn");
}
RING_FUNC(ring_PQconnectStart)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISSTRING(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETCPOINTER(PQconnectStart(RING_API_GETSTRING(1)),"PGconn");
}
RING_FUNC(ring_PQconnectPoll)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETNUMBER(PQconnectPoll((PGconn *) RING_API_GETCPOINTER(1,"PGconn")));
}
RING_FUNC(ring_PQconndefaults)
{
if ( RING_API_PARACOUNT != 0 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
RING_API_RETCPOINTER(PQconndefaults(),"PQconninfoOption");
}
RING_FUNC(ring_PQconninfo)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETCPOINTER(PQconninfo((PGconn *) RING_API_GETCPOINTER(1,"PGconn")),"PQconninfoOption");
}
RING_FUNC(ring_PQconninfoParse)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISSTRING(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETCPOINTER(PQconninfoParse(RING_API_GETSTRING(1),(char **) RING_API_GETCPOINTER2POINTER(2,"char")),"PQconninfoOption");
}
RING_FUNC(ring_PQfinish)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
PQfinish((PGconn *) RING_API_GETCPOINTER(1,"PGconn"));
}
RING_FUNC(ring_PQreset)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
PQreset((PGconn *) RING_API_GETCPOINTER(1,"PGconn"));
}
RING_FUNC(ring_PQresetStart)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETNUMBER(PQresetStart((PGconn *) RING_API_GETCPOINTER(1,"PGconn")));
}
RING_FUNC(ring_PQresetPoll)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETNUMBER(PQresetPoll((PGconn *) RING_API_GETCPOINTER(1,"PGconn")));
}
RING_FUNC(ring_PQpingParams)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
{
PGPing *pValue ;
pValue = (PGPing *) ring_state_malloc(((VM *) pPointer)->pRingState,sizeof(PGPing)) ;
*pValue = PQpingParams((char **) RING_API_GETCPOINTER2POINTER(1,"char"),(char **) RING_API_GETCPOINTER2POINTER(2,"char"), (int ) RING_API_GETNUMBER(3));
RING_API_RETMANAGEDCPOINTER(pValue,"PGPing",ring_state_free);
}
}
RING_FUNC(ring_PQping)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISSTRING(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
{
PGPing *pValue ;
pValue = (PGPing *) ring_state_malloc(((VM *) pPointer)->pRingState,sizeof(PGPing)) ;
*pValue = PQping(RING_API_GETSTRING(1));
RING_API_RETMANAGEDCPOINTER(pValue,"PGPing",ring_state_free);
}
}
RING_FUNC(ring_PQdb)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETSTRING(PQdb((PGconn *) RING_API_GETCPOINTER(1,"PGconn")));
}
RING_FUNC(ring_PQuser)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETSTRING(PQuser((PGconn *) RING_API_GETCPOINTER(1,"PGconn")));
}
RING_FUNC(ring_PQpass)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETSTRING(PQpass((PGconn *) RING_API_GETCPOINTER(1,"PGconn")));
}
RING_FUNC(ring_PQhost)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETSTRING(PQhost((PGconn *) RING_API_GETCPOINTER(1,"PGconn")));
}
RING_FUNC(ring_PQport)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETSTRING(PQport((PGconn *) RING_API_GETCPOINTER(1,"PGconn")));
}
RING_FUNC(ring_PQtty)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETSTRING(PQtty((PGconn *) RING_API_GETCPOINTER(1,"PGconn")));
}
RING_FUNC(ring_PQoptions)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETSTRING(PQoptions((PGconn *) RING_API_GETCPOINTER(1,"PGconn")));
}
RING_FUNC(ring_PQstatus)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETNUMBER(PQstatus((PGconn *) RING_API_GETCPOINTER(1,"PGconn")));
}
RING_FUNC(ring_PQtransactionStatus)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETNUMBER(PQtransactionStatus((PGconn *) RING_API_GETCPOINTER(1,"PGconn")));
}
RING_FUNC(ring_PQparameterStatus)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISSTRING(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETSTRING(PQparameterStatus((PGconn *) RING_API_GETCPOINTER(1,"PGconn"),RING_API_GETSTRING(2)));
}
RING_FUNC(ring_PQprotocolVersion)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETNUMBER(PQprotocolVersion((PGconn *) RING_API_GETCPOINTER(1,"PGconn")));
}
RING_FUNC(ring_PQserverVersion)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETNUMBER(PQserverVersion((PGconn *) RING_API_GETCPOINTER(1,"PGconn")));
}
RING_FUNC(ring_PQerrorMessage)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETSTRING(PQerrorMessage((PGconn *) RING_API_GETCPOINTER(1,"PGconn")));
}
RING_FUNC(ring_PQsocket)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETNUMBER(PQsocket((PGconn *) RING_API_GETCPOINTER(1,"PGconn")));
}
RING_FUNC(ring_PQbackendPID)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETNUMBER(PQbackendPID((PGconn *) RING_API_GETCPOINTER(1,"PGconn")));
}
RING_FUNC(ring_PQconnectionNeedsPassword)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETNUMBER(PQconnectionNeedsPassword((PGconn *) RING_API_GETCPOINTER(1,"PGconn")));
}
RING_FUNC(ring_PQconnectionUsedPassword)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETNUMBER(PQconnectionUsedPassword((PGconn *) RING_API_GETCPOINTER(1,"PGconn")));
}
RING_FUNC(ring_PQsslInUse)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETNUMBER(PQsslInUse((PGconn *) RING_API_GETCPOINTER(1,"PGconn")));
}
RING_FUNC(ring_PQsslAttribute)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISSTRING(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETSTRING(PQsslAttribute((PGconn *) RING_API_GETCPOINTER(1,"PGconn"),RING_API_GETSTRING(2)));
}
RING_FUNC(ring_PQsslAttributeNames)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETCPOINTER(PQsslAttributeNames((PGconn *) RING_API_GETCPOINTER(1,"PGconn")),"char");
}
RING_FUNC(ring_PQsslStruct)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISSTRING(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETCPOINTER(PQsslStruct((PGconn *) RING_API_GETCPOINTER(1,"PGconn"),RING_API_GETSTRING(2)),"void");
}
RING_FUNC(ring_PQgetssl)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETCPOINTER(PQgetssl((PGconn *) RING_API_GETCPOINTER(1,"PGconn")),"void");
}
RING_FUNC(ring_PQexec)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISSTRING(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETCPOINTER(PQexec((PGconn *) RING_API_GETCPOINTER(1,"PGconn"),RING_API_GETSTRING(2)),"PGresult");
}
RING_FUNC(ring_PQexecParams)
{
if ( RING_API_PARACOUNT != 8 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISSTRING(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(5) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISSTRING(6) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISSTRING(7) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(8) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETCPOINTER(PQexecParams((PGconn *) RING_API_GETCPOINTER(1,"PGconn"),RING_API_GETSTRING(2), (int ) RING_API_GETNUMBER(3),(Oid *) RING_API_GETCPOINTER(4,"Oid"),(char **) RING_API_GETCPOINTER2POINTER(5,"char"),RING_API_GETINTPOINTER(6),RING_API_GETINTPOINTER(7), (int ) RING_API_GETNUMBER(8)),"PGresult");
RING_API_ACCEPTINTVALUE(6) ;
RING_API_ACCEPTINTVALUE(7) ;
}
RING_FUNC(ring_PQprepare)
{
if ( RING_API_PARACOUNT != 5 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISSTRING(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISSTRING(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(5) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETCPOINTER(PQprepare((PGconn *) RING_API_GETCPOINTER(1,"PGconn"),RING_API_GETSTRING(2),RING_API_GETSTRING(3), (int ) RING_API_GETNUMBER(4),(Oid *) RING_API_GETCPOINTER(5,"Oid")),"PGresult");
}
RING_FUNC(ring_PQexecPrepared)
{
if ( RING_API_PARACOUNT != 7 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISSTRING(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISSTRING(5) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISSTRING(6) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(7) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETCPOINTER(PQexecPrepared((PGconn *) RING_API_GETCPOINTER(1,"PGconn"),RING_API_GETSTRING(2), (int ) RING_API_GETNUMBER(3),(char **) RING_API_GETCPOINTER2POINTER(4,"char"),RING_API_GETINTPOINTER(5),RING_API_GETINTPOINTER(6), (int ) RING_API_GETNUMBER(7)),"PGresult");
RING_API_ACCEPTINTVALUE(5) ;
RING_API_ACCEPTINTVALUE(6) ;
}
RING_FUNC(ring_PQdescribePrepared)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISSTRING(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETCPOINTER(PQdescribePrepared((PGconn *) RING_API_GETCPOINTER(1,"PGconn"),RING_API_GETSTRING(2)),"PGresult");
}
RING_FUNC(ring_PQdescribePortal)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISSTRING(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETCPOINTER(PQdescribePortal((PGconn *) RING_API_GETCPOINTER(1,"PGconn"),RING_API_GETSTRING(2)),"PGresult");
}
RING_FUNC(ring_PQresultStatus)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETNUMBER(PQresultStatus((PGresult *) RING_API_GETCPOINTER(1,"PGresult")));
}
RING_FUNC(ring_PQresStatus)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETSTRING(PQresStatus( (ExecStatusType ) (int) RING_API_GETNUMBER(1)));
}
RING_FUNC(ring_PQresultErrorMessage)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETSTRING(PQresultErrorMessage((PGresult *) RING_API_GETCPOINTER(1,"PGresult")));
}
RING_FUNC(ring_PQresultErrorField)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETSTRING(PQresultErrorField((PGresult *) RING_API_GETCPOINTER(1,"PGresult"), (int ) RING_API_GETNUMBER(2)));
}
RING_FUNC(ring_PQclear)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
PQclear((PGresult *) RING_API_GETCPOINTER(1,"PGresult"));
}
RING_FUNC(ring_PQntuples)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETNUMBER(PQntuples((PGresult *) RING_API_GETCPOINTER(1,"PGresult")));
}
RING_FUNC(ring_PQnfields)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETNUMBER(PQnfields((PGresult *) RING_API_GETCPOINTER(1,"PGresult")));
}
RING_FUNC(ring_PQfname)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETSTRING(PQfname((PGresult *) RING_API_GETCPOINTER(1,"PGresult"), (int ) RING_API_GETNUMBER(2)));
}
RING_FUNC(ring_PQfnumber)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISSTRING(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETNUMBER(PQfnumber((PGresult *) RING_API_GETCPOINTER(1,"PGresult"),RING_API_GETSTRING(2)));
}
RING_FUNC(ring_PQftable)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
{
Oid *pValue ;
pValue = (Oid *) ring_state_malloc(((VM *) pPointer)->pRingState,sizeof(Oid)) ;
*pValue = PQftable((PGresult *) RING_API_GETCPOINTER(1,"PGresult"), (int ) RING_API_GETNUMBER(2));
RING_API_RETMANAGEDCPOINTER(pValue,"Oid",ring_state_free);
}
}
RING_FUNC(ring_PQftablecol)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETNUMBER(PQftablecol((PGresult *) RING_API_GETCPOINTER(1,"PGresult"), (int ) RING_API_GETNUMBER(2)));
}
RING_FUNC(ring_PQfformat)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETNUMBER(PQfformat((PGresult *) RING_API_GETCPOINTER(1,"PGresult"), (int ) RING_API_GETNUMBER(2)));
}
RING_FUNC(ring_PQftype)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
{
Oid *pValue ;
pValue = (Oid *) ring_state_malloc(((VM *) pPointer)->pRingState,sizeof(Oid)) ;
*pValue = PQftype((PGresult *) RING_API_GETCPOINTER(1,"PGresult"), (int ) RING_API_GETNUMBER(2));
RING_API_RETMANAGEDCPOINTER(pValue,"Oid",ring_state_free);
}
}
RING_FUNC(ring_PQfmod)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETNUMBER(PQfmod((PGresult *) RING_API_GETCPOINTER(1,"PGresult"), (int ) RING_API_GETNUMBER(2)));
}
RING_FUNC(ring_PQfsize)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETNUMBER(PQfsize((PGresult *) RING_API_GETCPOINTER(1,"PGresult"), (int ) RING_API_GETNUMBER(2)));
}
RING_FUNC(ring_PQbinaryTuples)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETNUMBER(PQbinaryTuples((PGresult *) RING_API_GETCPOINTER(1,"PGresult")));
}
RING_FUNC(ring_PQgetvalue)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETSTRING(PQgetvalue((PGresult *) RING_API_GETCPOINTER(1,"PGresult"), (int ) RING_API_GETNUMBER(2), (int ) RING_API_GETNUMBER(3)));
}
RING_FUNC(ring_PQgetisnull)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETNUMBER(PQgetisnull((PGresult *) RING_API_GETCPOINTER(1,"PGresult"), (int ) RING_API_GETNUMBER(2), (int ) RING_API_GETNUMBER(3)));
}
RING_FUNC(ring_PQgetlength)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETNUMBER(PQgetlength((PGresult *) RING_API_GETCPOINTER(1,"PGresult"), (int ) RING_API_GETNUMBER(2), (int ) RING_API_GETNUMBER(3)));
}
RING_FUNC(ring_PQnparams)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETNUMBER(PQnparams((PGresult *) RING_API_GETCPOINTER(1,"PGresult")));
}
RING_FUNC(ring_PQparamtype)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
{
Oid *pValue ;
pValue = (Oid *) ring_state_malloc(((VM *) pPointer)->pRingState,sizeof(Oid)) ;
*pValue = PQparamtype((PGresult *) RING_API_GETCPOINTER(1,"PGresult"), (int ) RING_API_GETNUMBER(2));
RING_API_RETMANAGEDCPOINTER(pValue,"Oid",ring_state_free);
}
}
RING_FUNC(ring_PQprint)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
PQprint((FILE *) RING_API_GETCPOINTER(1,"FILE"),(PGresult *) RING_API_GETCPOINTER(2,"PGresult"),(PQprintOpt *) RING_API_GETCPOINTER(3,"PQprintOpt"));
}
RING_FUNC(ring_PQcmdStatus)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETSTRING(PQcmdStatus((PGresult *) RING_API_GETCPOINTER(1,"PGresult")));
}
RING_FUNC(ring_PQcmdTuples)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETSTRING(PQcmdTuples((PGresult *) RING_API_GETCPOINTER(1,"PGresult")));
}
RING_FUNC(ring_PQoidValue)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
{
Oid *pValue ;
pValue = (Oid *) ring_state_malloc(((VM *) pPointer)->pRingState,sizeof(Oid)) ;
*pValue = PQoidValue((PGresult *) RING_API_GETCPOINTER(1,"PGresult"));
RING_API_RETMANAGEDCPOINTER(pValue,"Oid",ring_state_free);
}
}
RING_FUNC(ring_PQoidStatus)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETSTRING(PQoidStatus((PGresult *) RING_API_GETCPOINTER(1,"PGresult")));
}
RING_FUNC(ring_PQescapeLiteral)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISSTRING(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETSTRING(PQescapeLiteral((PGconn *) RING_API_GETCPOINTER(1,"PGconn"),RING_API_GETSTRING(2), (size_t ) RING_API_GETNUMBER(3)));
}
RING_FUNC(ring_PQescapeIdentifier)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISSTRING(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETSTRING(PQescapeIdentifier((PGconn *) RING_API_GETCPOINTER(1,"PGconn"),RING_API_GETSTRING(2), (size_t ) RING_API_GETNUMBER(3)));
}
RING_FUNC(ring_PQescapeStringConn)
{
if ( RING_API_PARACOUNT != 5 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISSTRING(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISSTRING(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISSTRING(5) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETNUMBER(PQescapeStringConn((PGconn *) RING_API_GETCPOINTER(1,"PGconn"),RING_API_GETSTRING(2),RING_API_GETSTRING(3), (size_t ) RING_API_GETNUMBER(4),RING_API_GETINTPOINTER(5)));
RING_API_ACCEPTINTVALUE(5) ;
}
RING_FUNC(ring_PQescapeString)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISSTRING(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISSTRING(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETNUMBER(PQescapeString(RING_API_GETSTRING(1),RING_API_GETSTRING(2), (size_t ) RING_API_GETNUMBER(3)));
}
RING_FUNC(ring_PQescapeByteaConn)
{
if ( RING_API_PARACOUNT != 4 ) {
RING_API_ERROR(RING_API_MISS4PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETCPOINTER(PQescapeByteaConn((PGconn *) RING_API_GETCPOINTER(1,"PGconn"),(unsigned char *) RING_API_GETCPOINTER(2,"unsigned char"), (size_t ) RING_API_GETNUMBER(3),(size_t *) RING_API_GETCPOINTER(4,"size_t")),"unsigned char");
}
RING_FUNC(ring_PQescapeBytea)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETCPOINTER(PQescapeBytea((unsigned char *) RING_API_GETCPOINTER(1,"unsigned char"), (size_t ) RING_API_GETNUMBER(2),(size_t *) RING_API_GETCPOINTER(3,"size_t")),"unsigned char");
}
RING_FUNC(ring_PQunescapeBytea)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETCPOINTER(PQunescapeBytea((unsigned char *) RING_API_GETCPOINTER(1,"unsigned char"),(size_t *) RING_API_GETCPOINTER(2,"size_t")),"unsigned char");
}
RING_FUNC(ring_PQsendQuery)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISSTRING(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETNUMBER(PQsendQuery((PGconn *) RING_API_GETCPOINTER(1,"PGconn"),RING_API_GETSTRING(2)));
}
RING_FUNC(ring_PQsendQueryParams)
{
if ( RING_API_PARACOUNT != 8 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISSTRING(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(5) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISSTRING(6) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISSTRING(7) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(8) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETNUMBER(PQsendQueryParams((PGconn *) RING_API_GETCPOINTER(1,"PGconn"),RING_API_GETSTRING(2), (int ) RING_API_GETNUMBER(3),(Oid *) RING_API_GETCPOINTER(4,"Oid"),(char **) RING_API_GETCPOINTER2POINTER(5,"char"),RING_API_GETINTPOINTER(6),RING_API_GETINTPOINTER(7), (int ) RING_API_GETNUMBER(8)));
RING_API_ACCEPTINTVALUE(6) ;
RING_API_ACCEPTINTVALUE(7) ;
}
RING_FUNC(ring_PQsendPrepare)
{
if ( RING_API_PARACOUNT != 5 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISSTRING(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISSTRING(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(5) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETNUMBER(PQsendPrepare((PGconn *) RING_API_GETCPOINTER(1,"PGconn"),RING_API_GETSTRING(2),RING_API_GETSTRING(3), (int ) RING_API_GETNUMBER(4),(Oid *) RING_API_GETCPOINTER(5,"Oid")));
}
RING_FUNC(ring_PQsendQueryPrepared)
{
if ( RING_API_PARACOUNT != 7 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISSTRING(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISSTRING(5) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISSTRING(6) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(7) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETNUMBER(PQsendQueryPrepared((PGconn *) RING_API_GETCPOINTER(1,"PGconn"),RING_API_GETSTRING(2), (int ) RING_API_GETNUMBER(3),(char **) RING_API_GETCPOINTER2POINTER(4,"char"),RING_API_GETINTPOINTER(5),RING_API_GETINTPOINTER(6), (int ) RING_API_GETNUMBER(7)));
RING_API_ACCEPTINTVALUE(5) ;
RING_API_ACCEPTINTVALUE(6) ;
}
RING_FUNC(ring_PQsendDescribePrepared)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISSTRING(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETNUMBER(PQsendDescribePrepared((PGconn *) RING_API_GETCPOINTER(1,"PGconn"),RING_API_GETSTRING(2)));
}
RING_FUNC(ring_PQsendDescribePortal)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISSTRING(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETNUMBER(PQsendDescribePortal((PGconn *) RING_API_GETCPOINTER(1,"PGconn"),RING_API_GETSTRING(2)));
}
RING_FUNC(ring_PQgetResult)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETCPOINTER(PQgetResult((PGconn *) RING_API_GETCPOINTER(1,"PGconn")),"PGresult");
}
RING_FUNC(ring_PQconsumeInput)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETNUMBER(PQconsumeInput((PGconn *) RING_API_GETCPOINTER(1,"PGconn")));
}
RING_FUNC(ring_PQisBusy)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETNUMBER(PQisBusy((PGconn *) RING_API_GETCPOINTER(1,"PGconn")));
}
RING_FUNC(ring_PQsetnonblocking)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETNUMBER(PQsetnonblocking((PGconn *) RING_API_GETCPOINTER(1,"PGconn"), (int ) RING_API_GETNUMBER(2)));
}
RING_FUNC(ring_PQisnonblocking)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETNUMBER(PQisnonblocking((PGconn *) RING_API_GETCPOINTER(1,"PGconn")));
}
RING_FUNC(ring_PQflush)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETNUMBER(PQflush((PGconn *) RING_API_GETCPOINTER(1,"PGconn")));
}
RING_FUNC(ring_PQsetSingleRowMode)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETNUMBER(PQsetSingleRowMode((PGconn *) RING_API_GETCPOINTER(1,"PGconn")));
}
RING_FUNC(ring_PQgetCancel)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETCPOINTER(PQgetCancel((PGconn *) RING_API_GETCPOINTER(1,"PGconn")),"PGcancel");
}
RING_FUNC(ring_PQfreeCancel)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
PQfreeCancel((PGcancel *) RING_API_GETCPOINTER(1,"PGcancel"));
}
RING_FUNC(ring_PQcancel)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISSTRING(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETNUMBER(PQcancel((PGcancel *) RING_API_GETCPOINTER(1,"PGcancel"),RING_API_GETSTRING(2), (int ) RING_API_GETNUMBER(3)));
}
RING_FUNC(ring_PQrequestCancel)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETNUMBER(PQrequestCancel((PGconn *) RING_API_GETCPOINTER(1,"PGconn")));
}
RING_FUNC(ring_PQfn)
{
if ( RING_API_PARACOUNT != 7 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISSTRING(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISSTRING(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(5) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(6) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(7) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETCPOINTER(PQfn((PGconn *) RING_API_GETCPOINTER(1,"PGconn"), (int ) RING_API_GETNUMBER(2),RING_API_GETINTPOINTER(3),RING_API_GETINTPOINTER(4), (int ) RING_API_GETNUMBER(5),(PQArgBlock *) RING_API_GETCPOINTER(6,"PQArgBlock"), (int ) RING_API_GETNUMBER(7)),"PGresult");
RING_API_ACCEPTINTVALUE(3) ;
RING_API_ACCEPTINTVALUE(4) ;
}
RING_FUNC(ring_PQnotifies)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETCPOINTER(PQnotifies((PGconn *) RING_API_GETCPOINTER(1,"PGconn")),"PGnotify");
}
RING_FUNC(ring_PQputCopyData)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISSTRING(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETNUMBER(PQputCopyData((PGconn *) RING_API_GETCPOINTER(1,"PGconn"),RING_API_GETSTRING(2), (int ) RING_API_GETNUMBER(3)));
}
RING_FUNC(ring_PQputCopyEnd)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISSTRING(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETNUMBER(PQputCopyEnd((PGconn *) RING_API_GETCPOINTER(1,"PGconn"),RING_API_GETSTRING(2)));
}
RING_FUNC(ring_PQgetCopyData)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETNUMBER(PQgetCopyData((PGconn *) RING_API_GETCPOINTER(1,"PGconn"),(char **) RING_API_GETCPOINTER2POINTER(2,"char"), (int ) RING_API_GETNUMBER(3)));
}
RING_FUNC(ring_PQgetline)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISSTRING(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETNUMBER(PQgetline((PGconn *) RING_API_GETCPOINTER(1,"PGconn"),RING_API_GETSTRING(2), (int ) RING_API_GETNUMBER(3)));
}
RING_FUNC(ring_PQgetlineAsync)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISSTRING(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETNUMBER(PQgetlineAsync((PGconn *) RING_API_GETCPOINTER(1,"PGconn"),RING_API_GETSTRING(2), (int ) RING_API_GETNUMBER(3)));
}
RING_FUNC(ring_PQputline)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISSTRING(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETNUMBER(PQputline((PGconn *) RING_API_GETCPOINTER(1,"PGconn"),RING_API_GETSTRING(2)));
}
RING_FUNC(ring_PQputnbytes)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISSTRING(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETNUMBER(PQputnbytes((PGconn *) RING_API_GETCPOINTER(1,"PGconn"),RING_API_GETSTRING(2), (int ) RING_API_GETNUMBER(3)));
}
RING_FUNC(ring_PQendcopy)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETNUMBER(PQendcopy((PGconn *) RING_API_GETCPOINTER(1,"PGconn")));
}
RING_FUNC(ring_PQclientEncoding)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETNUMBER(PQclientEncoding((PGconn *) RING_API_GETCPOINTER(1,"PGconn")));
}
RING_FUNC(ring_pg_encoding_to_char)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETSTRING(pg_encoding_to_char( (int ) RING_API_GETNUMBER(1)));
}
RING_FUNC(ring_PQsetClientEncoding)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISSTRING(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETNUMBER(PQsetClientEncoding((PGconn *) RING_API_GETCPOINTER(1,"PGconn"),RING_API_GETSTRING(2)));
}
RING_FUNC(ring_PQtrace)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
PQtrace((PGconn *) RING_API_GETCPOINTER(1,"PGconn"),(FILE *) RING_API_GETCPOINTER(2,"FILE"));
}
RING_FUNC(ring_PQuntrace)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
PQuntrace((PGconn *) RING_API_GETCPOINTER(1,"PGconn"));
}
RING_FUNC(ring_PQfreemem)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
PQfreemem((void *) RING_API_GETCPOINTER(1,"void"));
}
RING_FUNC(ring_PQconninfoFree)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
PQconninfoFree((PQconninfoOption *) RING_API_GETCPOINTER(1,"PQconninfoOption"));
}
RING_FUNC(ring_PQencryptPasswordConn)
{
if ( RING_API_PARACOUNT != 4 ) {
RING_API_ERROR(RING_API_MISS4PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISSTRING(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISSTRING(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISSTRING(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETSTRING(PQencryptPasswordConn((PGconn *) RING_API_GETCPOINTER(1,"PGconn"),RING_API_GETSTRING(2),RING_API_GETSTRING(3),RING_API_GETSTRING(4)));
}
RING_FUNC(ring_PQencryptPassword)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISSTRING(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISSTRING(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETSTRING(PQencryptPassword(RING_API_GETSTRING(1),RING_API_GETSTRING(2)));
}
RING_FUNC(ring_PQmakeEmptyPGresult)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETCPOINTER(PQmakeEmptyPGresult((PGconn *) RING_API_GETCPOINTER(1,"PGconn"), (ExecStatusType ) (int) RING_API_GETNUMBER(2)),"PGresult");
}
RING_FUNC(ring_PQfireResultCreateEvents)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETNUMBER(PQfireResultCreateEvents((PGconn *) RING_API_GETCPOINTER(1,"PGconn"),(PGresult *) RING_API_GETCPOINTER(2,"PGresult")));
}
RING_FUNC(ring_PQcopyResult)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETCPOINTER(PQcopyResult((PGresult *) RING_API_GETCPOINTER(1,"PGresult"), (int ) RING_API_GETNUMBER(2)),"PGresult");
}
RING_FUNC(ring_PQsetResultAttrs)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETNUMBER(PQsetResultAttrs((PGresult *) RING_API_GETCPOINTER(1,"PGresult"), (int ) RING_API_GETNUMBER(2),(PGresAttDesc *) RING_API_GETCPOINTER(3,"PGresAttDesc")));
}
RING_FUNC(ring_PQsetvalue)
{
if ( RING_API_PARACOUNT != 5 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISSTRING(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(5) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETNUMBER(PQsetvalue((PGresult *) RING_API_GETCPOINTER(1,"PGresult"), (int ) RING_API_GETNUMBER(2), (int ) RING_API_GETNUMBER(3),RING_API_GETSTRING(4), (int ) RING_API_GETNUMBER(5)));
}
RING_FUNC(ring_PQresultAlloc)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETCPOINTER(PQresultAlloc((PGresult *) RING_API_GETCPOINTER(1,"PGresult"), (size_t ) RING_API_GETNUMBER(2)),"void");
}
RING_FUNC(ring_PQlibVersion)
{
if ( RING_API_PARACOUNT != 0 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
RING_API_RETNUMBER(PQlibVersion());
}
RING_FUNC(ring_PQsetNoticeReceiver)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
{
PQnoticeReceiver *pValue ;
pValue = (PQnoticeReceiver *) ring_state_malloc(((VM *) pPointer)->pRingState,sizeof(PQnoticeReceiver)) ;
*pValue = PQsetNoticeReceiver((PGconn *) RING_API_GETCPOINTER(1,"PGconn"),* (PQnoticeReceiver *) RING_API_GETCPOINTER(2,"PQnoticeReceiver"),(void *) RING_API_GETCPOINTER(3,"void"));
if (RING_API_ISCPOINTERNOTASSIGNED(2))
ring_state_free(((VM *) pPointer)->pRingState,RING_API_GETCPOINTER(2,"PQnoticeReceiver"));
RING_API_RETMANAGEDCPOINTER(pValue,"PQnoticeReceiver",ring_state_free);
}
}
RING_FUNC(ring_PQsetNoticeProcessor)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
{
PQnoticeProcessor *pValue ;
pValue = (PQnoticeProcessor *) ring_state_malloc(((VM *) pPointer)->pRingState,sizeof(PQnoticeProcessor)) ;
*pValue = PQsetNoticeProcessor((PGconn *) RING_API_GETCPOINTER(1,"PGconn"),* (PQnoticeProcessor *) RING_API_GETCPOINTER(2,"PQnoticeProcessor"),(void *) RING_API_GETCPOINTER(3,"void"));
if (RING_API_ISCPOINTERNOTASSIGNED(2))
ring_state_free(((VM *) pPointer)->pRingState,RING_API_GETCPOINTER(2,"PQnoticeProcessor"));
RING_API_RETMANAGEDCPOINTER(pValue,"PQnoticeProcessor",ring_state_free);
}
}
RING_FUNC(ring_PQinitOpenSSL)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
PQinitOpenSSL( (int ) RING_API_GETNUMBER(1), (int ) RING_API_GETNUMBER(2));
}
RING_FUNC(ring_PQinitSSL)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
PQinitSSL( (int ) RING_API_GETNUMBER(1));
}
RING_FUNC(ring_PQisthreadsafe)
{
if ( RING_API_PARACOUNT != 0 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
RING_API_RETNUMBER(PQisthreadsafe());
}
RING_API void ringlib_init(RingState *pRingState)
{
ring_vm_funcregister("pqconnectdbparams",ring_PQconnectdbParams);
ring_vm_funcregister("pqconnectdb",ring_PQconnectdb);
ring_vm_funcregister("pqsetdblogin",ring_PQsetdbLogin);
ring_vm_funcregister("pqsetdb",ring_PQsetdb);
ring_vm_funcregister("pqconnectstartparams",ring_PQconnectStartParams);
ring_vm_funcregister("pqconnectstart",ring_PQconnectStart);
ring_vm_funcregister("pqconnectpoll",ring_PQconnectPoll);
ring_vm_funcregister("pqconndefaults",ring_PQconndefaults);
ring_vm_funcregister("pqconninfo",ring_PQconninfo);
ring_vm_funcregister("pqconninfoparse",ring_PQconninfoParse);
ring_vm_funcregister("pqfinish",ring_PQfinish);
ring_vm_funcregister("pqreset",ring_PQreset);
ring_vm_funcregister("pqresetstart",ring_PQresetStart);
ring_vm_funcregister("pqresetpoll",ring_PQresetPoll);
ring_vm_funcregister("pqpingparams",ring_PQpingParams);
ring_vm_funcregister("pqping",ring_PQping);
ring_vm_funcregister("pqdb",ring_PQdb);
ring_vm_funcregister("pquser",ring_PQuser);
ring_vm_funcregister("pqpass",ring_PQpass);
ring_vm_funcregister("pqhost",ring_PQhost);
ring_vm_funcregister("pqport",ring_PQport);
ring_vm_funcregister("pqtty",ring_PQtty);
ring_vm_funcregister("pqoptions",ring_PQoptions);
ring_vm_funcregister("pqstatus",ring_PQstatus);
ring_vm_funcregister("pqtransactionstatus",ring_PQtransactionStatus);
ring_vm_funcregister("pqparameterstatus",ring_PQparameterStatus);
ring_vm_funcregister("pqprotocolversion",ring_PQprotocolVersion);
ring_vm_funcregister("pqserverversion",ring_PQserverVersion);
ring_vm_funcregister("pqerrormessage",ring_PQerrorMessage);
ring_vm_funcregister("pqsocket",ring_PQsocket);
ring_vm_funcregister("pqbackendpid",ring_PQbackendPID);
ring_vm_funcregister("pqconnectionneedspassword",ring_PQconnectionNeedsPassword);
ring_vm_funcregister("pqconnectionusedpassword",ring_PQconnectionUsedPassword);
ring_vm_funcregister("pqsslinuse",ring_PQsslInUse);
ring_vm_funcregister("pqsslattribute",ring_PQsslAttribute);
ring_vm_funcregister("pqsslattributenames",ring_PQsslAttributeNames);
ring_vm_funcregister("pqsslstruct",ring_PQsslStruct);
ring_vm_funcregister("pqgetssl",ring_PQgetssl);
ring_vm_funcregister("pqexec",ring_PQexec);
ring_vm_funcregister("pqexecparams",ring_PQexecParams);
ring_vm_funcregister("pqprepare",ring_PQprepare);
ring_vm_funcregister("pqexecprepared",ring_PQexecPrepared);
ring_vm_funcregister("pqdescribeprepared",ring_PQdescribePrepared);
ring_vm_funcregister("pqdescribeportal",ring_PQdescribePortal);
ring_vm_funcregister("pqresultstatus",ring_PQresultStatus);
ring_vm_funcregister("pqresstatus",ring_PQresStatus);
ring_vm_funcregister("pqresulterrormessage",ring_PQresultErrorMessage);
ring_vm_funcregister("pqresulterrorfield",ring_PQresultErrorField);
ring_vm_funcregister("pqclear",ring_PQclear);
ring_vm_funcregister("pqntuples",ring_PQntuples);
ring_vm_funcregister("pqnfields",ring_PQnfields);
ring_vm_funcregister("pqfname",ring_PQfname);
ring_vm_funcregister("pqfnumber",ring_PQfnumber);
ring_vm_funcregister("pqftable",ring_PQftable);
ring_vm_funcregister("pqftablecol",ring_PQftablecol);
ring_vm_funcregister("pqfformat",ring_PQfformat);
ring_vm_funcregister("pqftype",ring_PQftype);
ring_vm_funcregister("pqfmod",ring_PQfmod);
ring_vm_funcregister("pqfsize",ring_PQfsize);
ring_vm_funcregister("pqbinarytuples",ring_PQbinaryTuples);
ring_vm_funcregister("pqgetvalue",ring_PQgetvalue);
ring_vm_funcregister("pqgetisnull",ring_PQgetisnull);
ring_vm_funcregister("pqgetlength",ring_PQgetlength);
ring_vm_funcregister("pqnparams",ring_PQnparams);
ring_vm_funcregister("pqparamtype",ring_PQparamtype);
ring_vm_funcregister("pqprint",ring_PQprint);
ring_vm_funcregister("pqcmdstatus",ring_PQcmdStatus);
ring_vm_funcregister("pqcmdtuples",ring_PQcmdTuples);
ring_vm_funcregister("pqoidvalue",ring_PQoidValue);
ring_vm_funcregister("pqoidstatus",ring_PQoidStatus);
ring_vm_funcregister("pqescapeliteral",ring_PQescapeLiteral);
ring_vm_funcregister("pqescapeidentifier",ring_PQescapeIdentifier);
ring_vm_funcregister("pqescapestringconn",ring_PQescapeStringConn);
ring_vm_funcregister("pqescapestring",ring_PQescapeString);
ring_vm_funcregister("pqescapebyteaconn",ring_PQescapeByteaConn);
ring_vm_funcregister("pqescapebytea",ring_PQescapeBytea);
ring_vm_funcregister("pqunescapebytea",ring_PQunescapeBytea);
ring_vm_funcregister("pqsendquery",ring_PQsendQuery);
ring_vm_funcregister("pqsendqueryparams",ring_PQsendQueryParams);
ring_vm_funcregister("pqsendprepare",ring_PQsendPrepare);
ring_vm_funcregister("pqsendqueryprepared",ring_PQsendQueryPrepared);
ring_vm_funcregister("pqsenddescribeprepared",ring_PQsendDescribePrepared);
ring_vm_funcregister("pqsenddescribeportal",ring_PQsendDescribePortal);
ring_vm_funcregister("pqgetresult",ring_PQgetResult);
ring_vm_funcregister("pqconsumeinput",ring_PQconsumeInput);
ring_vm_funcregister("pqisbusy",ring_PQisBusy);
ring_vm_funcregister("pqsetnonblocking",ring_PQsetnonblocking);
ring_vm_funcregister("pqisnonblocking",ring_PQisnonblocking);
ring_vm_funcregister("pqflush",ring_PQflush);
ring_vm_funcregister("pqsetsinglerowmode",ring_PQsetSingleRowMode);
ring_vm_funcregister("pqgetcancel",ring_PQgetCancel);
ring_vm_funcregister("pqfreecancel",ring_PQfreeCancel);
ring_vm_funcregister("pqcancel",ring_PQcancel);
ring_vm_funcregister("pqrequestcancel",ring_PQrequestCancel);
ring_vm_funcregister("pqfn",ring_PQfn);
ring_vm_funcregister("pqnotifies",ring_PQnotifies);
ring_vm_funcregister("pqputcopydata",ring_PQputCopyData);
ring_vm_funcregister("pqputcopyend",ring_PQputCopyEnd);
ring_vm_funcregister("pqgetcopydata",ring_PQgetCopyData);
ring_vm_funcregister("pqgetline",ring_PQgetline);
ring_vm_funcregister("pqgetlineasync",ring_PQgetlineAsync);
ring_vm_funcregister("pqputline",ring_PQputline);
ring_vm_funcregister("pqputnbytes",ring_PQputnbytes);
ring_vm_funcregister("pqendcopy",ring_PQendcopy);
ring_vm_funcregister("pqclientencoding",ring_PQclientEncoding);
ring_vm_funcregister("pg_encoding_to_char",ring_pg_encoding_to_char);
ring_vm_funcregister("pqsetclientencoding",ring_PQsetClientEncoding);
ring_vm_funcregister("pqtrace",ring_PQtrace);
ring_vm_funcregister("pquntrace",ring_PQuntrace);
ring_vm_funcregister("pqfreemem",ring_PQfreemem);
ring_vm_funcregister("pqconninfofree",ring_PQconninfoFree);
ring_vm_funcregister("pqencryptpasswordconn",ring_PQencryptPasswordConn);
ring_vm_funcregister("pqencryptpassword",ring_PQencryptPassword);
ring_vm_funcregister("pqmakeemptypgresult",ring_PQmakeEmptyPGresult);
ring_vm_funcregister("pqfireresultcreateevents",ring_PQfireResultCreateEvents);
ring_vm_funcregister("pqcopyresult",ring_PQcopyResult);
ring_vm_funcregister("pqsetresultattrs",ring_PQsetResultAttrs);
ring_vm_funcregister("pqsetvalue",ring_PQsetvalue);
ring_vm_funcregister("pqresultalloc",ring_PQresultAlloc);
ring_vm_funcregister("pqlibversion",ring_PQlibVersion);
ring_vm_funcregister("pqsetnoticereceiver",ring_PQsetNoticeReceiver);
ring_vm_funcregister("pqsetnoticeprocessor",ring_PQsetNoticeProcessor);
ring_vm_funcregister("pqinitopenssl",ring_PQinitOpenSSL);
ring_vm_funcregister("pqinitssl",ring_PQinitSSL);
ring_vm_funcregister("pqisthreadsafe",ring_PQisthreadsafe);
ring_vm_funcregister("get_connection_started",ring_get_connection_started);
ring_vm_funcregister("get_connection_made",ring_get_connection_made);
ring_vm_funcregister("get_connection_awaiting_response",ring_get_connection_awaiting_response);
ring_vm_funcregister("get_connection_auth_ok",ring_get_connection_auth_ok);
ring_vm_funcregister("get_connection_ssl_startup",ring_get_connection_ssl_startup);
ring_vm_funcregister("get_connection_setenv",ring_get_connection_setenv);
ring_vm_funcregister("get_connection_ok",ring_get_connection_ok);
ring_vm_funcregister("get_pqping_ok",ring_get_pqping_ok);
ring_vm_funcregister("get_pqping_reject",ring_get_pqping_reject);
ring_vm_funcregister("get_pqping_no_response",ring_get_pqping_no_response);
ring_vm_funcregister("get_pqping_no_attempt",ring_get_pqping_no_attempt);
ring_vm_funcregister("get_pgres_empty_query",ring_get_pgres_empty_query);
ring_vm_funcregister("get_pgres_command_ok",ring_get_pgres_command_ok);
ring_vm_funcregister("get_pgres_tuples_ok",ring_get_pgres_tuples_ok);
ring_vm_funcregister("get_pgres_copy_out",ring_get_pgres_copy_out);
ring_vm_funcregister("get_pgres_copy_in",ring_get_pgres_copy_in);
ring_vm_funcregister("get_pgres_bad_response",ring_get_pgres_bad_response);
ring_vm_funcregister("get_pgres_nonfatal_error",ring_get_pgres_nonfatal_error);
ring_vm_funcregister("get_pgres_fatal_error",ring_get_pgres_fatal_error);
ring_vm_funcregister("get_pgres_copy_both",ring_get_pgres_copy_both);
ring_vm_funcregister("get_pgres_single_tuple",ring_get_pgres_single_tuple);
ring_vm_funcregister("get_pg_diag_severity",ring_get_pg_diag_severity);
ring_vm_funcregister("get_pg_diag_sqlstate",ring_get_pg_diag_sqlstate);
ring_vm_funcregister("get_pg_diag_message_primary",ring_get_pg_diag_message_primary);
ring_vm_funcregister("get_pg_diag_message_detail",ring_get_pg_diag_message_detail);
ring_vm_funcregister("get_pg_diag_message_hint",ring_get_pg_diag_message_hint);
ring_vm_funcregister("get_pg_diag_statement_position",ring_get_pg_diag_statement_position);
ring_vm_funcregister("get_pg_diag_internal_position",ring_get_pg_diag_internal_position);
ring_vm_funcregister("get_pg_diag_internal_query",ring_get_pg_diag_internal_query);
ring_vm_funcregister("get_pg_diag_context",ring_get_pg_diag_context);
ring_vm_funcregister("get_pg_diag_schema_name",ring_get_pg_diag_schema_name);
ring_vm_funcregister("get_pg_diag_table_name",ring_get_pg_diag_table_name);
ring_vm_funcregister("get_pg_diag_column_name",ring_get_pg_diag_column_name);
ring_vm_funcregister("get_pg_diag_datatype_name",ring_get_pg_diag_datatype_name);
ring_vm_funcregister("get_pg_diag_constraint_name",ring_get_pg_diag_constraint_name);
ring_vm_funcregister("get_pg_diag_source_file",ring_get_pg_diag_source_file);
ring_vm_funcregister("get_pg_diag_source_line",ring_get_pg_diag_source_line);
ring_vm_funcregister("get_pg_diag_source_function",ring_get_pg_diag_source_function);
ring_vm_funcregister("new_pqconninfooption",ring_new_pqconninfooption);
ring_vm_funcregister("new_managed_pqconninfooption",ring_new_managed_pqconninfooption);
ring_vm_funcregister("destroy_pqconninfooption",ring_destroy_pqconninfooption);
ring_vm_funcregister("get_pqconninfooption_keyword",ring_get_pqconninfooption_keyword);
ring_vm_funcregister("set_pqconninfooption_keyword",ring_set_pqconninfooption_keyword);
ring_vm_funcregister("get_pqconninfooption_envvar",ring_get_pqconninfooption_envvar);
ring_vm_funcregister("set_pqconninfooption_envvar",ring_set_pqconninfooption_envvar);
ring_vm_funcregister("get_pqconninfooption_compiled",ring_get_pqconninfooption_compiled);
ring_vm_funcregister("set_pqconninfooption_compiled",ring_set_pqconninfooption_compiled);
ring_vm_funcregister("get_pqconninfooption_val",ring_get_pqconninfooption_val);
ring_vm_funcregister("set_pqconninfooption_val",ring_set_pqconninfooption_val);
ring_vm_funcregister("get_pqconninfooption_label",ring_get_pqconninfooption_label);
ring_vm_funcregister("set_pqconninfooption_label",ring_set_pqconninfooption_label);
ring_vm_funcregister("get_pqconninfooption_dispchar",ring_get_pqconninfooption_dispchar);
ring_vm_funcregister("set_pqconninfooption_dispchar",ring_set_pqconninfooption_dispchar);
ring_vm_funcregister("get_pqconninfooption_dispsize",ring_get_pqconninfooption_dispsize);
ring_vm_funcregister("set_pqconninfooption_dispsize",ring_set_pqconninfooption_dispsize);
ring_vm_funcregister("new_pqprintopt",ring_new_pqprintopt);
ring_vm_funcregister("new_managed_pqprintopt",ring_new_managed_pqprintopt);
ring_vm_funcregister("destroy_pqprintopt",ring_destroy_pqprintopt);
ring_vm_funcregister("get_pqprintopt_header",ring_get_pqprintopt_header);
ring_vm_funcregister("set_pqprintopt_header",ring_set_pqprintopt_header);
ring_vm_funcregister("get_pqprintopt_align",ring_get_pqprintopt_align);
ring_vm_funcregister("set_pqprintopt_align",ring_set_pqprintopt_align);
ring_vm_funcregister("get_pqprintopt_standard",ring_get_pqprintopt_standard);
ring_vm_funcregister("set_pqprintopt_standard",ring_set_pqprintopt_standard);
ring_vm_funcregister("get_pqprintopt_html3",ring_get_pqprintopt_html3);
ring_vm_funcregister("set_pqprintopt_html3",ring_set_pqprintopt_html3);
ring_vm_funcregister("get_pqprintopt_expanded",ring_get_pqprintopt_expanded);
ring_vm_funcregister("set_pqprintopt_expanded",ring_set_pqprintopt_expanded);
ring_vm_funcregister("get_pqprintopt_pager",ring_get_pqprintopt_pager);
ring_vm_funcregister("set_pqprintopt_pager",ring_set_pqprintopt_pager);
ring_vm_funcregister("get_pqprintopt_fieldsep",ring_get_pqprintopt_fieldSep);
ring_vm_funcregister("set_pqprintopt_fieldsep",ring_set_pqprintopt_fieldSep);
ring_vm_funcregister("get_pqprintopt_tableopt",ring_get_pqprintopt_tableOpt);
ring_vm_funcregister("set_pqprintopt_tableopt",ring_set_pqprintopt_tableOpt);
ring_vm_funcregister("get_pqprintopt_caption",ring_get_pqprintopt_caption);
ring_vm_funcregister("set_pqprintopt_caption",ring_set_pqprintopt_caption);
ring_vm_funcregister("get_pqprintopt_fieldname",ring_get_pqprintopt_fieldName);
ring_vm_funcregister("set_pqprintopt_fieldname",ring_set_pqprintopt_fieldName);
ring_vm_funcregister("new_pqargblock",ring_new_pqargblock);
ring_vm_funcregister("new_managed_pqargblock",ring_new_managed_pqargblock);
ring_vm_funcregister("destroy_pqargblock",ring_destroy_pqargblock);
ring_vm_funcregister("get_pqargblock_len",ring_get_pqargblock_len);
ring_vm_funcregister("set_pqargblock_len",ring_set_pqargblock_len);
ring_vm_funcregister("get_pqargblock_isint",ring_get_pqargblock_isint);
ring_vm_funcregister("set_pqargblock_isint",ring_set_pqargblock_isint);
ring_vm_funcregister("get_pqargblock_u_integer",ring_get_pqargblock_u_integer);
ring_vm_funcregister("set_pqargblock_u_integer",ring_set_pqargblock_u_integer);
ring_vm_funcregister("get_pqargblock_u_ptr",ring_get_pqargblock_u_ptr);
ring_vm_funcregister("set_pqargblock_u_ptr",ring_set_pqargblock_u_ptr);
}
|
360559.c | /******************************************************************************
*
* Module Name: aslmapenter - Build resource descriptor/device maps
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2017, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* Code in any form, with the right to sublicense such rights; and
*
* 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
* license (with the right to sublicense), under only those claims of Intel
* patents that are infringed by the Original Intel Code, to make, use, sell,
* offer to sell, and import the Covered Code and derivative works thereof
* solely to the minimum extent necessary to exercise the above copyright
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************
*
* Alternatively, you may choose to be licensed under the terms of the
* following license:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Alternatively, you may choose to be licensed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
*****************************************************************************/
#include "acpi.h"
#include "accommon.h"
#include "acapps.h"
#include "aslcompiler.h"
/* This module used for application-level code only */
#define _COMPONENT ACPI_COMPILER
ACPI_MODULE_NAME ("aslmapenter")
/* Local prototypes */
static ACPI_GPIO_INFO *
MpCreateGpioInfo (
UINT16 PinNumber,
char *DeviceName);
static ACPI_SERIAL_INFO *
MpCreateSerialInfo (
char *DeviceName,
UINT16 Address);
/*******************************************************************************
*
* FUNCTION: MpSaveGpioInfo
*
* PARAMETERS: Resource - GPIO resource descriptor
* PinCount - From GPIO descriptor
* PinList - From GPIO descriptor
* DeviceName - The "ResourceSource" name
*
* RETURN: None
*
* DESCRIPTION: External Interface.
* Save GPIO resource descriptor information.
* Creates new GPIO info blocks, one for each pin defined by the
* GPIO descriptor.
*
******************************************************************************/
void
MpSaveGpioInfo (
ACPI_PARSE_OBJECT *Op,
AML_RESOURCE *Resource,
UINT32 PinCount,
UINT16 *PinList,
char *DeviceName)
{
ACPI_GPIO_INFO *Info;
UINT32 i;
/* Mapfile option enabled? */
if (!Gbl_MapfileFlag)
{
return;
}
/* Create an info block for each pin defined in the descriptor */
for (i = 0; i < PinCount; i++)
{
Info = MpCreateGpioInfo (PinList[i], DeviceName);
Info->Op = Op;
Info->DeviceName = DeviceName;
Info->PinCount = PinCount;
Info->PinIndex = i;
Info->PinNumber = PinList[i];
Info->Type = Resource->Gpio.ConnectionType;
Info->Direction = (UINT8) (Resource->Gpio.IntFlags & 0x0003); /* _IOR, for IO descriptor */
Info->Polarity = (UINT8) ((Resource->Gpio.IntFlags >> 1) & 0x0003); /* _POL, for INT descriptor */
}
}
/*******************************************************************************
*
* FUNCTION: MpSaveSerialInfo
*
* PARAMETERS: Resource - A Serial resource descriptor
* DeviceName - The "ResourceSource" name.
*
* RETURN: None
*
* DESCRIPTION: External Interface.
* Save serial resource descriptor information.
* Creates a new serial info block.
*
******************************************************************************/
void
MpSaveSerialInfo (
ACPI_PARSE_OBJECT *Op,
AML_RESOURCE *Resource,
char *DeviceName)
{
ACPI_SERIAL_INFO *Info;
UINT16 Address;
UINT32 Speed;
/* Mapfile option enabled? */
if (!Gbl_MapfileFlag)
{
return;
}
if (Resource->DescriptorType != ACPI_RESOURCE_NAME_SERIAL_BUS)
{
return;
}
/* Extract address and speed from the resource descriptor */
switch (Resource->CommonSerialBus.Type)
{
case AML_RESOURCE_I2C_SERIALBUSTYPE:
Address = Resource->I2cSerialBus.SlaveAddress;
Speed = Resource->I2cSerialBus.ConnectionSpeed;
break;
case AML_RESOURCE_SPI_SERIALBUSTYPE:
Address = Resource->SpiSerialBus.DeviceSelection;
Speed = Resource->SpiSerialBus.ConnectionSpeed;
break;
case AML_RESOURCE_UART_SERIALBUSTYPE:
Address = 0;
Speed = Resource->UartSerialBus.DefaultBaudRate;
break;
default: /* Invalid bus subtype */
return;
}
Info = MpCreateSerialInfo (DeviceName, Address);
Info->Op = Op;
Info->DeviceName = DeviceName;
Info->Resource = Resource;
Info->Address = Address;
Info->Speed = Speed;
}
/*******************************************************************************
*
* FUNCTION: MpCreateGpioInfo
*
* PARAMETERS: PinNumber - GPIO pin number
* DeviceName - The "ResourceSource" name
*
* RETURN: New GPIO info block.
*
* DESCRIPTION: Create a new GPIO info block and place it on the global list.
* The list is sorted by GPIO device names first, and pin numbers
* secondarily.
*
******************************************************************************/
static ACPI_GPIO_INFO *
MpCreateGpioInfo (
UINT16 PinNumber,
char *DeviceName)
{
ACPI_GPIO_INFO *Info;
ACPI_GPIO_INFO *NextGpio;
ACPI_GPIO_INFO *PrevGpio;
char *Buffer;
/*
* Allocate a new info block and insert it into the global GPIO list
* sorted by both source device name and then the pin number. There is
* one block per pin.
*/
Buffer = UtStringCacheCalloc (sizeof (ACPI_GPIO_INFO));
Info = ACPI_CAST_PTR (ACPI_GPIO_INFO, Buffer);
NextGpio = Gbl_GpioList;
PrevGpio = NULL;
if (!Gbl_GpioList)
{
Gbl_GpioList = Info;
Info->Next = NULL;
return (Info);
}
/* Sort on source DeviceName first */
while (NextGpio &&
(strcmp (DeviceName, NextGpio->DeviceName) > 0))
{
PrevGpio = NextGpio;
NextGpio = NextGpio->Next;
}
/* Now sort on the PinNumber */
while (NextGpio &&
(NextGpio->PinNumber < PinNumber) &&
!strcmp (DeviceName, NextGpio->DeviceName))
{
PrevGpio = NextGpio;
NextGpio = NextGpio->Next;
}
/* Finish the list insertion */
if (PrevGpio)
{
PrevGpio->Next = Info;
}
else
{
Gbl_GpioList = Info;
}
Info->Next = NextGpio;
return (Info);
}
/*******************************************************************************
*
* FUNCTION: MpCreateSerialInfo
*
* PARAMETERS: DeviceName - The "ResourceSource" name.
* Address - Physical address for the device
*
* RETURN: New Serial info block.
*
* DESCRIPTION: Create a new Serial info block and place it on the global list.
* The list is sorted by Serial device names first, and addresses
* secondarily.
*
******************************************************************************/
static ACPI_SERIAL_INFO *
MpCreateSerialInfo (
char *DeviceName,
UINT16 Address)
{
ACPI_SERIAL_INFO *Info;
ACPI_SERIAL_INFO *NextSerial;
ACPI_SERIAL_INFO *PrevSerial;
char *Buffer;
/*
* Allocate a new info block and insert it into the global Serial list
* sorted by both source device name and then the address.
*/
Buffer = UtStringCacheCalloc (sizeof (ACPI_SERIAL_INFO));
Info = ACPI_CAST_PTR (ACPI_SERIAL_INFO, Buffer);
NextSerial = Gbl_SerialList;
PrevSerial = NULL;
if (!Gbl_SerialList)
{
Gbl_SerialList = Info;
Info->Next = NULL;
return (Info);
}
/* Sort on source DeviceName */
while (NextSerial &&
(strcmp (DeviceName, NextSerial->DeviceName) > 0))
{
PrevSerial = NextSerial;
NextSerial = NextSerial->Next;
}
/* Now sort on the Address */
while (NextSerial &&
(NextSerial->Address < Address) &&
!strcmp (DeviceName, NextSerial->DeviceName))
{
PrevSerial = NextSerial;
NextSerial = NextSerial->Next;
}
/* Finish the list insertion */
if (PrevSerial)
{
PrevSerial->Next = Info;
}
else
{
Gbl_SerialList = Info;
}
Info->Next = NextSerial;
return (Info);
}
|
381397.c | /* -*- linux-c -*-
*
* (C) Copyright IBM Corp. 2004
* Copyright (c) 2004 by Intel Corp.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. This
* file and program are licensed under a BSD style license. See
* the Copying file included with the OpenHPI distribution for
* full licensing terms.
*
* Authors:
* Christina Hernandez<[email protected]>
*/
#include <stdio.h>
#include <stdlib.h>
#include <glib.h>
#include <string.h>
#include <SaHpi.h>
#include <oh_utils.h>
#include <el_utils.h>
#include "el_test.h"
/**
* main: EL test
*
* This test verifies failure of oh_el_prepend when res != NULL
*
* Return value: 0 on success, 1 on failure
**/
int main(int argc, char **argv)
{
oh_el *el;
SaErrorT retc;
int x;
SaHpiEventT event;
SaHpiRdrT rdr;
static char *data[10] = {
"Test data one",
"Test data two",
"Test data three",
"Test data four",
"Test data five",
"Test data six",
"Test data seven",
"Test data eight",
"Test data nine",
"Test data ten"
};
/*test oh_el_prepend with rdr != NULL */
el = oh_el_create(30);
event.Source = 1;
event.EventType = SAHPI_ET_USER;
event.Timestamp = SAHPI_TIME_UNSPECIFIED;
event.Severity = SAHPI_DEBUG;
rdr.RecordId = 1;
rdr.RdrType = SAHPI_INVENTORY_RDR;
for(x=0;x<10;x++){
strcpy((char *) &event.EventDataUnion.UserEvent.UserEventData.Data, data[x]);
retc = oh_el_prepend(el, &event, &rdr, NULL);
if (retc != SA_OK) {
CRIT("oh_el_prepend failed.");
return 1;
}
}
/* close el */
retc = oh_el_close(el);
if (retc != SA_OK) {
CRIT("oh_el_close on el failed.");
return 1;
}
return 0;
}
|
680842.c | /* TyTools - public domain
Niels Martignène <[email protected]>
https://koromix.dev/tytools
This software is in the public domain. Where that dedication is not
recognized, you are granted a perpetual, irrevocable license to copy,
distribute, and modify this file as you see fit.
See the LICENSE file for more details. */
#ifdef _WIN32
#include "common.h"
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <process.h>
#include "system.h"
#include "thread.h"
struct thread_context {
ty_thread *thread;
ty_thread_func *f;
void *udata;
HANDLE ev;
};
static unsigned int __stdcall thread_proc(void *udata)
{
struct thread_context ctx = *(struct thread_context *)udata;
union { DWORD dw; int i; } code;
SetEvent(ctx.ev);
code.i = (*ctx.f)(ctx.udata);
return code.dw;
}
int ty_thread_create(ty_thread *thread, ty_thread_func *f, void *udata)
{
struct thread_context ctx;
int r;
ctx.thread = thread;
ctx.f = f;
ctx.udata = udata;
ctx.ev = CreateEvent(NULL, TRUE, FALSE, NULL);
if (!ctx.ev) {
r = ty_error(TY_ERROR_SYSTEM, "CreateEvent() failed: %s", hs_win32_strerror(0));
goto cleanup;
}
thread->h = (HANDLE)_beginthreadex(NULL, 0, thread_proc, &ctx, 0,
(unsigned int *)&thread->thread_id);
if (!thread->h) {
r = ty_error(TY_ERROR_SYSTEM, "_beginthreadex() failed: %s", hs_win32_strerror(0));
goto cleanup;
}
WaitForSingleObject(ctx.ev, INFINITE);
r = 0;
cleanup:
if (ctx.ev)
CloseHandle(ctx.ev);
return r;
}
int ty_thread_join(ty_thread *thread)
{
assert(thread->h);
union { DWORD dw; int i; } code;
DWORD ret _HS_POSSIBLY_UNUSED;
ret = WaitForSingleObject(thread->h, INFINITE);
assert(ret == WAIT_OBJECT_0);
GetExitCodeThread(thread->h, &code.dw);
CloseHandle(thread->h);
thread->h = NULL;
return code.i;
}
void ty_thread_detach(ty_thread *thread)
{
if (!thread->h)
return;
CloseHandle(thread->h);
thread->h = NULL;
}
ty_thread_id ty_thread_get_self_id()
{
return GetCurrentThreadId();
}
int ty_mutex_init(ty_mutex *mutex)
{
InitializeCriticalSection((CRITICAL_SECTION *)&mutex->mutex);
mutex->init = true;
return 0;
}
void ty_mutex_release(ty_mutex *mutex)
{
if (!mutex->init)
return;
DeleteCriticalSection((CRITICAL_SECTION *)&mutex->mutex);
mutex->init = false;
}
void ty_mutex_lock(ty_mutex *mutex)
{
EnterCriticalSection((CRITICAL_SECTION *)&mutex->mutex);
}
void ty_mutex_unlock(ty_mutex *mutex)
{
LeaveCriticalSection((CRITICAL_SECTION *)&mutex->mutex);
}
int ty_cond_init(ty_cond *cond)
{
InitializeConditionVariable((CONDITION_VARIABLE *)&cond->cv);
cond->init = true;
return 0;
}
void ty_cond_release(ty_cond *cond)
{
// Apparently, there is no need for DeleteConditionVariable()
cond->init = false;
}
void ty_cond_signal(ty_cond *cond)
{
WakeConditionVariable((CONDITION_VARIABLE *)&cond->cv);
}
void ty_cond_broadcast(ty_cond *cond)
{
WakeAllConditionVariable((CONDITION_VARIABLE *)&cond->cv);
}
bool ty_cond_wait(ty_cond *cond, ty_mutex *mutex, int timeout)
{
return SleepConditionVariableCS((CONDITION_VARIABLE *)&cond->cv,
(CRITICAL_SECTION *)&mutex->mutex,
timeout >= 0 ? (DWORD)timeout : INFINITE);
}
#endif
|
608746.c | #include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <libgen.h>
#include "main.h"
#include "options.h"
#include "fqreader.h"
#include "linereader.h"
#include "mkdirp.h"
#include "strutils.h"
#include "tokenset.h"
#include "utils.h"
#ifdef _IS_NULL
#undef _IS_NULL
#endif
#define _IS_NULL(p) ((NULL == (p)) ? (1) : (0))
#ifdef _FREE
#undef _FREE
#endif
#define _FREE(p) ((NULL == (p)) ? (0) : (free((p)), (p) = NULL))
/*** main() ***/
int
main( int argc, char *argv[] )
{
FILE *out_a, *out_b;
char *h1, *h2, *s, *q;
char *id = NULL;
char *outname_a = NULL, *outname_b = NULL, *outdirname = NULL;
int i;
struct options *o = options_new( );
struct tokenset *t = tokenset_new( );
struct fqreader *fq = fqreader_new( NULL );
/* Get the command line options */
options_cmdline( o, argc, argv );
if ( _IS_NULL( o->outname ) || strlen( o->outname ) == 0 ) {
o->outname = realloc( o->outname, 4 * sizeof ( char ) );
strcpy( o->outname, "FQU" );
}
/* Create the output directory if necessary */
outdirname = realloc( outdirname, sizeof ( char ) * ( 2 + strlen( o->outname ) ) );
strcpy( outdirname, o->outname );
if ( strchr( outdirname, '/' ) ) { /* not the current directory */
dirname( outdirname );
mkdirp( outdirname, S_IRWXU | S_IRWXG | S_IRWXO );
}
/* Read the id files */
for ( i = o->optind; i < argc; i++ ) {
char *line;
struct linereader *z = linereader_new( );
linereader_init( z, argv[i] );
if ( _IS_NULL( z ) ) {
fprintf( stderr, "[ERROR] %s: Cannot open input file \"%s\"\n", _I_AM, argv[i] );
exit( 1 );
}
while ( ( line = ( char * ) linereader_next( z ) ) ) {
unsigned len;
stru_trim( line );
if ( line[0] == '#' || stru_is_ws( line ) )
continue;
len = strcspn( line, "\f\n\r\t\v " );
line[len] = '\0';
tokenset_add( t, line );
}
linereader_free( z );
}
outname_a = realloc( outname_a, sizeof ( char ) * ( 6 + strlen( o->outname ) ) );
strcpy( outname_a, o->outname );
strcat( outname_a, "_A.fq" );
out_a = fopen( outname_a, "wb" );
if ( _IS_NULL( out_a ) ) {
fprintf( stderr, "Could not open first output file \"%s\"\n", outname_a );
exit( 1 );
}
outname_b = realloc( outname_b, sizeof ( char ) * ( 6 + strlen( o->outname ) ) );
strcpy( outname_b, o->outname );
strcat( outname_b, "_B.fq" );
out_b = fopen( outname_b, "wb" );
if ( _IS_NULL( out_b ) ) {
fprintf( stderr, "Could not open second output file \"%s\"\n", outname_b );
exit( 1 );
}
while ( fqreader_next( fq, &h1, &h2, &s, &q ) ) {
utils_extract_id( &id, h1 ); /* get the identifier from header 1 */
if ( tokenset_exists( t, id ) )
fprintf( out_a, "@%s\n%s\n+%s\n%s\n", h1, s, h2, q );
else
fprintf( out_b, "@%s\n%s\n+%s\n%s\n", h1, s, h2, q );
}
fclose( out_a );
fclose( out_b );
_FREE( id );
_FREE( outname_a );
_FREE( outname_b );
fqreader_free( fq );
options_free( o );
tokenset_free( t );
return 0;
}
#undef _IS_NULL
#undef _FREE
|
6909.c | /*
* POK header
*
* The following file is a part of the POK project. Any modification should
* be made according to the POK licence. You CANNOT use this file or a part
* of a file for your own project.
*
* For more information on the POK licence, please see our LICENCE FILE
*
* Please follow the coding guidelines described in doc/CODING_GUIDELINES
*
* Copyright (c) 2007-2021 POK team
*/
#include <libc/stdio.h>
#include <types.h>
void user_receive(int t) { printf("I receive value %d\n", t); }
|
37699.c | static void fenz(ReturnType uint64_t out[1], const uint64_t in1[8]) {
{ const uint64_t x13 = in1[7];
{ const uint64_t x14 = in1[6];
{ const uint64_t x12 = in1[5];
{ const uint64_t x10 = in1[4];
{ const uint64_t x8 = in1[3];
{ const uint64_t x6 = in1[2];
{ const uint64_t x4 = in1[1];
{ const uint64_t x2 = in1[0];
{ uint64_t x15 = (x14 | x13);
{ uint64_t x16 = (x12 | x15);
{ uint64_t x17 = (x10 | x16);
{ uint64_t x18 = (x8 | x17);
{ uint64_t x19 = (x6 | x18);
{ uint64_t x20 = (x4 | x19);
{ uint64_t x21 = (x2 | x20);
out[0] = x21;
}}}}}}}}}}}}}}}
}
|
79815.c | /* Error handling during reading and writing of PO files.
Copyright (C) 2005-2007 Free Software Foundation, Inc.
Written by Bruno Haible <[email protected]>, 2005.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
/* Specification. */
#include "po-xerror.h"
#include <error.h>
#include <stdio.h>
#include <stdlib.h>
#include "message.h"
#include "progname.h"
#include "error-progname.h"
#include "xalloc.h"
#include "xerror.h"
#include "xvasprintf.h"
#include "po-error.h"
#include "gettext.h"
#define _(str) gettext (str)
static void
xerror (int severity, const char *prefix_tail,
const char *filename, size_t lineno, size_t column,
int multiline_p, const char *message_text)
{
if (multiline_p)
{
bool old_error_with_progname = error_with_progname;
char *prefix;
if (filename != NULL)
{
if (lineno != (size_t)(-1))
{
if (column != (size_t)(-1))
prefix =
xasprintf ("%s:%ld:%ld: %s", filename,
(long) lineno, (long) column, prefix_tail);
else
prefix =
xasprintf ("%s:%ld: %s", filename,
(long) lineno, prefix_tail);
}
else
prefix = xasprintf ("%s: %s", filename, prefix_tail);
error_with_progname = false;
}
else
prefix = xasprintf ("%s: %s", program_name, prefix_tail);
if (severity >= PO_SEVERITY_ERROR)
po_multiline_error (prefix, xstrdup (message_text));
else
po_multiline_warning (prefix, xstrdup (message_text));
error_with_progname = old_error_with_progname;
if (severity == PO_SEVERITY_FATAL_ERROR)
exit (EXIT_FAILURE);
}
else
{
int exit_status =
(severity == PO_SEVERITY_FATAL_ERROR ? EXIT_FAILURE : 0);
if (filename != NULL)
{
error_with_progname = false;
if (lineno != (size_t)(-1))
{
if (column != (size_t)(-1))
po_error (exit_status, 0, "%s:%ld:%ld: %s%s",
filename, (long) lineno, (long) column,
prefix_tail, message_text);
else
po_error_at_line (exit_status, 0, filename, lineno, "%s%s",
prefix_tail, message_text);
}
else
po_error (exit_status, 0, "%s: %s%s",
filename, prefix_tail, message_text);
error_with_progname = true;
}
else
po_error (exit_status, 0, "%s%s", prefix_tail, message_text);
if (severity < PO_SEVERITY_ERROR)
--error_message_count;
}
}
/* The default error handler is based on the lower-level error handler
in po-error.h, so that gettext-po.h can offer to override one or the
other. */
void
textmode_xerror (int severity,
const struct message_ty *message,
const char *filename, size_t lineno, size_t column,
int multiline_p, const char *message_text)
{
const char *prefix_tail =
(severity == PO_SEVERITY_WARNING ? _("warning: ") : "");
if (message != NULL && (filename == NULL || lineno == (size_t)(-1)))
{
filename = message->pos.file_name;
lineno = message->pos.line_number;
column = (size_t)(-1);
}
xerror (severity, prefix_tail, filename, lineno, column,
multiline_p, message_text);
}
void
textmode_xerror2 (int severity,
const struct message_ty *message1,
const char *filename1, size_t lineno1, size_t column1,
int multiline_p1, const char *message_text1,
const struct message_ty *message2,
const char *filename2, size_t lineno2, size_t column2,
int multiline_p2, const char *message_text2)
{
int severity1 = /* Don't exit before both texts have been output. */
(severity == PO_SEVERITY_FATAL_ERROR ? PO_SEVERITY_ERROR : severity);
const char *prefix_tail =
(severity == PO_SEVERITY_WARNING ? _("warning: ") : "");
if (message1 != NULL && (filename1 == NULL || lineno1 == (size_t)(-1)))
{
filename1 = message1->pos.file_name;
lineno1 = message1->pos.line_number;
column1 = (size_t)(-1);
}
if (message2 != NULL && (filename2 == NULL || lineno2 == (size_t)(-1)))
{
filename2 = message2->pos.file_name;
lineno2 = message2->pos.line_number;
column2 = (size_t)(-1);
}
if (multiline_p1)
xerror (severity1, prefix_tail, filename1, lineno1, column1, multiline_p1,
message_text1);
else
{
char *message_text1_extended = xasprintf ("%s...", message_text1);
xerror (severity1, prefix_tail, filename1, lineno1, column1,
multiline_p1, message_text1_extended);
free (message_text1_extended);
}
{
char *message_text2_extended = xasprintf ("...%s", message_text2);
xerror (severity, prefix_tail, filename2, lineno2, column2,
multiline_p2, message_text2_extended);
free (message_text2_extended);
}
if (severity >= PO_SEVERITY_ERROR)
/* error_message_count needs to be incremented only by 1, not by 2. */
--error_message_count;
}
void (*po_xerror) (int severity,
const struct message_ty *message,
const char *filename, size_t lineno, size_t column,
int multiline_p, const char *message_text)
= textmode_xerror;
void (*po_xerror2) (int severity,
const struct message_ty *message1,
const char *filename1, size_t lineno1, size_t column1,
int multiline_p1, const char *message_text1,
const struct message_ty *message2,
const char *filename2, size_t lineno2, size_t column2,
int multiline_p2, const char *message_text2)
= textmode_xerror2;
|
226828.c | /**********************************************************************
* Copyright (c) 2013, 2014 Pieter Wuille *
* Distributed under the MIT software license, see the accompanying *
* file COPYING or http://www.opensource.org/licenses/mit-license.php.*
**********************************************************************/
#if defined HAVE_CONFIG_H
#include "libsecp256k1-config.h"
#endif
#include <stdio.h>
#include <stdlib.h>
#include "secp256k1.c"
#include "testrand_impl.h"
#ifdef ENABLE_OPENSSL_TESTS
#include "openssl/bn.h"
#include "openssl/ec.h"
#include "openssl/ecdsa.h"
#include "openssl/obj_mac.h"
#endif
static int count = 64;
void random_field_element_test(secp256k1_fe_t *fe) {
do {
unsigned char b32[32];
secp256k1_rand256_test(b32);
if (secp256k1_fe_set_b32(fe, b32)) {
break;
}
} while(1);
}
void random_field_element_magnitude(secp256k1_fe_t *fe) {
secp256k1_fe_normalize(fe);
int n = secp256k1_rand32() % 4;
for (int i = 0; i < n; i++) {
secp256k1_fe_negate(fe, fe, 1 + 2*i);
secp256k1_fe_negate(fe, fe, 2 + 2*i);
}
}
void random_group_element_test(secp256k1_ge_t *ge) {
secp256k1_fe_t fe;
do {
random_field_element_test(&fe);
if (secp256k1_ge_set_xo(ge, &fe, secp256k1_rand32() & 1))
break;
} while(1);
}
void random_group_element_jacobian_test(secp256k1_gej_t *gej, const secp256k1_ge_t *ge) {
do {
random_field_element_test(&gej->z);
if (!secp256k1_fe_is_zero(&gej->z)) {
break;
}
} while(1);
secp256k1_fe_t z2; secp256k1_fe_sqr(&z2, &gej->z);
secp256k1_fe_t z3; secp256k1_fe_mul(&z3, &z2, &gej->z);
secp256k1_fe_mul(&gej->x, &ge->x, &z2);
secp256k1_fe_mul(&gej->y, &ge->y, &z3);
gej->infinity = ge->infinity;
}
void random_scalar_order_test(secp256k1_scalar_t *num) {
do {
unsigned char b32[32];
secp256k1_rand256_test(b32);
int overflow = 0;
secp256k1_scalar_set_b32(num, b32, &overflow);
if (overflow || secp256k1_scalar_is_zero(num))
continue;
break;
} while(1);
}
void random_scalar_order(secp256k1_scalar_t *num) {
do {
unsigned char b32[32];
secp256k1_rand256(b32);
int overflow = 0;
secp256k1_scalar_set_b32(num, b32, &overflow);
if (overflow || secp256k1_scalar_is_zero(num))
continue;
break;
} while(1);
}
/***** NUM TESTS *****/
#ifndef USE_NUM_NONE
void random_num_negate(secp256k1_num_t *num) {
if (secp256k1_rand32() & 1)
secp256k1_num_negate(num);
}
void random_num_order_test(secp256k1_num_t *num) {
secp256k1_scalar_t sc;
random_scalar_order_test(&sc);
secp256k1_scalar_get_num(num, &sc);
}
void random_num_order(secp256k1_num_t *num) {
secp256k1_scalar_t sc;
random_scalar_order(&sc);
secp256k1_scalar_get_num(num, &sc);
}
void test_num_negate(void) {
secp256k1_num_t n1;
secp256k1_num_t n2;
random_num_order_test(&n1); /* n1 = R */
random_num_negate(&n1);
secp256k1_num_copy(&n2, &n1); /* n2 = R */
secp256k1_num_sub(&n1, &n2, &n1); /* n1 = n2-n1 = 0 */
CHECK(secp256k1_num_is_zero(&n1));
secp256k1_num_copy(&n1, &n2); /* n1 = R */
secp256k1_num_negate(&n1); /* n1 = -R */
CHECK(!secp256k1_num_is_zero(&n1));
secp256k1_num_add(&n1, &n2, &n1); /* n1 = n2+n1 = 0 */
CHECK(secp256k1_num_is_zero(&n1));
secp256k1_num_copy(&n1, &n2); /* n1 = R */
secp256k1_num_negate(&n1); /* n1 = -R */
CHECK(secp256k1_num_is_neg(&n1) != secp256k1_num_is_neg(&n2));
secp256k1_num_negate(&n1); /* n1 = R */
CHECK(secp256k1_num_eq(&n1, &n2));
}
void test_num_add_sub(void) {
int r = secp256k1_rand32();
secp256k1_num_t n1;
secp256k1_num_t n2;
random_num_order_test(&n1); /* n1 = R1 */
if (r & 1) {
random_num_negate(&n1);
}
random_num_order_test(&n2); /* n2 = R2 */
if (r & 2) {
random_num_negate(&n2);
}
secp256k1_num_t n1p2, n2p1, n1m2, n2m1;
secp256k1_num_add(&n1p2, &n1, &n2); /* n1p2 = R1 + R2 */
secp256k1_num_add(&n2p1, &n2, &n1); /* n2p1 = R2 + R1 */
secp256k1_num_sub(&n1m2, &n1, &n2); /* n1m2 = R1 - R2 */
secp256k1_num_sub(&n2m1, &n2, &n1); /* n2m1 = R2 - R1 */
CHECK(secp256k1_num_eq(&n1p2, &n2p1));
CHECK(!secp256k1_num_eq(&n1p2, &n1m2));
secp256k1_num_negate(&n2m1); /* n2m1 = -R2 + R1 */
CHECK(secp256k1_num_eq(&n2m1, &n1m2));
CHECK(!secp256k1_num_eq(&n2m1, &n1));
secp256k1_num_add(&n2m1, &n2m1, &n2); /* n2m1 = -R2 + R1 + R2 = R1 */
CHECK(secp256k1_num_eq(&n2m1, &n1));
CHECK(!secp256k1_num_eq(&n2p1, &n1));
secp256k1_num_sub(&n2p1, &n2p1, &n2); /* n2p1 = R2 + R1 - R2 = R1 */
CHECK(secp256k1_num_eq(&n2p1, &n1));
}
void run_num_smalltests(void) {
for (int i=0; i<100*count; i++) {
test_num_negate();
test_num_add_sub();
}
}
#endif
/***** SCALAR TESTS *****/
void scalar_test(void) {
unsigned char c[32];
/* Set 's' to a random scalar, with value 'snum'. */
secp256k1_scalar_t s;
random_scalar_order_test(&s);
/* Set 's1' to a random scalar, with value 's1num'. */
secp256k1_scalar_t s1;
random_scalar_order_test(&s1);
/* Set 's2' to a random scalar, with value 'snum2', and byte array representation 'c'. */
secp256k1_scalar_t s2;
random_scalar_order_test(&s2);
secp256k1_scalar_get_b32(c, &s2);
#ifndef USE_NUM_NONE
secp256k1_num_t snum, s1num, s2num;
secp256k1_scalar_get_num(&snum, &s);
secp256k1_scalar_get_num(&s1num, &s1);
secp256k1_scalar_get_num(&s2num, &s2);
secp256k1_num_t order;
secp256k1_scalar_order_get_num(&order);
secp256k1_num_t half_order = order;
secp256k1_num_shift(&half_order, 1);
#endif
{
/* Test that fetching groups of 4 bits from a scalar and recursing n(i)=16*n(i-1)+p(i) reconstructs it. */
secp256k1_scalar_t n;
secp256k1_scalar_set_int(&n, 0);
for (int i = 0; i < 256; i += 4) {
secp256k1_scalar_t t;
secp256k1_scalar_set_int(&t, secp256k1_scalar_get_bits(&s, 256 - 4 - i, 4));
for (int j = 0; j < 4; j++) {
secp256k1_scalar_add(&n, &n, &n);
}
secp256k1_scalar_add(&n, &n, &t);
}
CHECK(secp256k1_scalar_eq(&n, &s));
}
{
/* Test that fetching groups of randomly-sized bits from a scalar and recursing n(i)=b*n(i-1)+p(i) reconstructs it. */
secp256k1_scalar_t n;
secp256k1_scalar_set_int(&n, 0);
int i = 0;
while (i < 256) {
int now = (secp256k1_rand32() % 15) + 1;
if (now + i > 256) {
now = 256 - i;
}
secp256k1_scalar_t t;
secp256k1_scalar_set_int(&t, secp256k1_scalar_get_bits_var(&s, 256 - now - i, now));
for (int j = 0; j < now; j++) {
secp256k1_scalar_add(&n, &n, &n);
}
secp256k1_scalar_add(&n, &n, &t);
i += now;
}
CHECK(secp256k1_scalar_eq(&n, &s));
}
#ifndef USE_NUM_NONE
{
/* Test that adding the scalars together is equal to adding their numbers together modulo the order. */
secp256k1_num_t rnum;
secp256k1_num_add(&rnum, &snum, &s2num);
secp256k1_num_mod(&rnum, &order);
secp256k1_scalar_t r;
secp256k1_scalar_add(&r, &s, &s2);
secp256k1_num_t r2num;
secp256k1_scalar_get_num(&r2num, &r);
CHECK(secp256k1_num_eq(&rnum, &r2num));
}
{
/* Test that multipying the scalars is equal to multiplying their numbers modulo the order. */
secp256k1_num_t rnum;
secp256k1_num_mul(&rnum, &snum, &s2num);
secp256k1_num_mod(&rnum, &order);
secp256k1_scalar_t r;
secp256k1_scalar_mul(&r, &s, &s2);
secp256k1_num_t r2num;
secp256k1_scalar_get_num(&r2num, &r);
CHECK(secp256k1_num_eq(&rnum, &r2num));
/* The result can only be zero if at least one of the factors was zero. */
CHECK(secp256k1_scalar_is_zero(&r) == (secp256k1_scalar_is_zero(&s) || secp256k1_scalar_is_zero(&s2)));
/* The results can only be equal to one of the factors if that factor was zero, or the other factor was one. */
CHECK(secp256k1_num_eq(&rnum, &snum) == (secp256k1_scalar_is_zero(&s) || secp256k1_scalar_is_one(&s2)));
CHECK(secp256k1_num_eq(&rnum, &s2num) == (secp256k1_scalar_is_zero(&s2) || secp256k1_scalar_is_one(&s)));
}
{
/* Check that comparison with zero matches comparison with zero on the number. */
CHECK(secp256k1_num_is_zero(&snum) == secp256k1_scalar_is_zero(&s));
/* Check that comparison with the half order is equal to testing for high scalar. */
CHECK(secp256k1_scalar_is_high(&s) == (secp256k1_num_cmp(&snum, &half_order) > 0));
secp256k1_scalar_t neg;
secp256k1_scalar_negate(&neg, &s);
secp256k1_num_t negnum;
secp256k1_num_sub(&negnum, &order, &snum);
secp256k1_num_mod(&negnum, &order);
/* Check that comparison with the half order is equal to testing for high scalar after negation. */
CHECK(secp256k1_scalar_is_high(&neg) == (secp256k1_num_cmp(&negnum, &half_order) > 0));
/* Negating should change the high property, unless the value was already zero. */
CHECK((secp256k1_scalar_is_high(&s) == secp256k1_scalar_is_high(&neg)) == secp256k1_scalar_is_zero(&s));
secp256k1_num_t negnum2;
secp256k1_scalar_get_num(&negnum2, &neg);
/* Negating a scalar should be equal to (order - n) mod order on the number. */
CHECK(secp256k1_num_eq(&negnum, &negnum2));
secp256k1_scalar_add(&neg, &neg, &s);
/* Adding a number to its negation should result in zero. */
CHECK(secp256k1_scalar_is_zero(&neg));
secp256k1_scalar_negate(&neg, &neg);
/* Negating zero should still result in zero. */
CHECK(secp256k1_scalar_is_zero(&neg));
}
{
/* Test secp256k1_scalar_mul_shift_var. */
secp256k1_scalar_t r;
unsigned int shift = 256 + (secp256k1_rand32() % 257);
secp256k1_scalar_mul_shift_var(&r, &s1, &s2, shift);
secp256k1_num_t rnum;
secp256k1_num_mul(&rnum, &s1num, &s2num);
secp256k1_num_shift(&rnum, shift - 1);
secp256k1_num_t one;
unsigned char cone[1] = {0x01};
secp256k1_num_set_bin(&one, cone, 1);
secp256k1_num_add(&rnum, &rnum, &one);
secp256k1_num_shift(&rnum, 1);
secp256k1_num_t rnum2;
secp256k1_scalar_get_num(&rnum2, &r);
CHECK(secp256k1_num_eq(&rnum, &rnum2));
}
#endif
{
/* Test that scalar inverses are equal to the inverse of their number modulo the order. */
if (!secp256k1_scalar_is_zero(&s)) {
secp256k1_scalar_t inv;
secp256k1_scalar_inverse(&inv, &s);
#ifndef USE_NUM_NONE
secp256k1_num_t invnum;
secp256k1_num_mod_inverse(&invnum, &snum, &order);
secp256k1_num_t invnum2;
secp256k1_scalar_get_num(&invnum2, &inv);
CHECK(secp256k1_num_eq(&invnum, &invnum2));
#endif
secp256k1_scalar_mul(&inv, &inv, &s);
/* Multiplying a scalar with its inverse must result in one. */
CHECK(secp256k1_scalar_is_one(&inv));
secp256k1_scalar_inverse(&inv, &inv);
/* Inverting one must result in one. */
CHECK(secp256k1_scalar_is_one(&inv));
}
}
{
/* Test commutativity of add. */
secp256k1_scalar_t r1, r2;
secp256k1_scalar_add(&r1, &s1, &s2);
secp256k1_scalar_add(&r2, &s2, &s1);
CHECK(secp256k1_scalar_eq(&r1, &r2));
}
{
/* Test add_bit. */
int bit = secp256k1_rand32() % 256;
secp256k1_scalar_t b;
secp256k1_scalar_set_int(&b, 1);
CHECK(secp256k1_scalar_is_one(&b));
for (int i = 0; i < bit; i++) {
secp256k1_scalar_add(&b, &b, &b);
}
secp256k1_scalar_t r1 = s1, r2 = s1;
if (!secp256k1_scalar_add(&r1, &r1, &b)) {
/* No overflow happened. */
secp256k1_scalar_add_bit(&r2, bit);
CHECK(secp256k1_scalar_eq(&r1, &r2));
}
}
{
/* Test commutativity of mul. */
secp256k1_scalar_t r1, r2;
secp256k1_scalar_mul(&r1, &s1, &s2);
secp256k1_scalar_mul(&r2, &s2, &s1);
CHECK(secp256k1_scalar_eq(&r1, &r2));
}
{
/* Test associativity of add. */
secp256k1_scalar_t r1, r2;
secp256k1_scalar_add(&r1, &s1, &s2);
secp256k1_scalar_add(&r1, &r1, &s);
secp256k1_scalar_add(&r2, &s2, &s);
secp256k1_scalar_add(&r2, &s1, &r2);
CHECK(secp256k1_scalar_eq(&r1, &r2));
}
{
/* Test associativity of mul. */
secp256k1_scalar_t r1, r2;
secp256k1_scalar_mul(&r1, &s1, &s2);
secp256k1_scalar_mul(&r1, &r1, &s);
secp256k1_scalar_mul(&r2, &s2, &s);
secp256k1_scalar_mul(&r2, &s1, &r2);
CHECK(secp256k1_scalar_eq(&r1, &r2));
}
{
/* Test distributitivity of mul over add. */
secp256k1_scalar_t r1, r2, t;
secp256k1_scalar_add(&r1, &s1, &s2);
secp256k1_scalar_mul(&r1, &r1, &s);
secp256k1_scalar_mul(&r2, &s1, &s);
secp256k1_scalar_mul(&t, &s2, &s);
secp256k1_scalar_add(&r2, &r2, &t);
CHECK(secp256k1_scalar_eq(&r1, &r2));
}
{
/* Test square. */
secp256k1_scalar_t r1, r2;
secp256k1_scalar_sqr(&r1, &s1);
secp256k1_scalar_mul(&r2, &s1, &s1);
CHECK(secp256k1_scalar_eq(&r1, &r2));
}
}
void run_scalar_tests(void) {
for (int i = 0; i < 128 * count; i++) {
scalar_test();
}
{
/* (-1)+1 should be zero. */
secp256k1_scalar_t s, o;
secp256k1_scalar_set_int(&s, 1);
secp256k1_scalar_negate(&o, &s);
secp256k1_scalar_add(&o, &o, &s);
CHECK(secp256k1_scalar_is_zero(&o));
}
#ifndef USE_NUM_NONE
{
/* A scalar with value of the curve order should be 0. */
secp256k1_num_t order;
secp256k1_scalar_order_get_num(&order);
unsigned char bin[32];
secp256k1_num_get_bin(bin, 32, &order);
secp256k1_scalar_t zero;
int overflow = 0;
secp256k1_scalar_set_b32(&zero, bin, &overflow);
CHECK(overflow == 1);
CHECK(secp256k1_scalar_is_zero(&zero));
}
#endif
}
/***** FIELD TESTS *****/
void random_fe(secp256k1_fe_t *x) {
unsigned char bin[32];
do {
secp256k1_rand256(bin);
if (secp256k1_fe_set_b32(x, bin)) {
return;
}
} while(1);
}
void random_fe_non_zero(secp256k1_fe_t *nz) {
int tries = 10;
while (--tries >= 0) {
random_fe(nz);
secp256k1_fe_normalize(nz);
if (!secp256k1_fe_is_zero(nz))
break;
}
/* Infinitesimal probability of spurious failure here */
CHECK(tries >= 0);
}
void random_fe_non_square(secp256k1_fe_t *ns) {
random_fe_non_zero(ns);
secp256k1_fe_t r;
if (secp256k1_fe_sqrt(&r, ns)) {
secp256k1_fe_negate(ns, ns, 1);
}
}
int check_fe_equal(const secp256k1_fe_t *a, const secp256k1_fe_t *b) {
secp256k1_fe_t an = *a; secp256k1_fe_normalize(&an);
secp256k1_fe_t bn = *b; secp256k1_fe_normalize(&bn);
return secp256k1_fe_equal(&an, &bn);
}
int check_fe_inverse(const secp256k1_fe_t *a, const secp256k1_fe_t *ai) {
secp256k1_fe_t x; secp256k1_fe_mul(&x, a, ai);
secp256k1_fe_t one; secp256k1_fe_set_int(&one, 1);
return check_fe_equal(&x, &one);
}
void run_field_inv(void) {
secp256k1_fe_t x, xi, xii;
for (int i=0; i<10*count; i++) {
random_fe_non_zero(&x);
secp256k1_fe_inv(&xi, &x);
CHECK(check_fe_inverse(&x, &xi));
secp256k1_fe_inv(&xii, &xi);
CHECK(check_fe_equal(&x, &xii));
}
}
void run_field_inv_var(void) {
secp256k1_fe_t x, xi, xii;
for (int i=0; i<10*count; i++) {
random_fe_non_zero(&x);
secp256k1_fe_inv_var(&xi, &x);
CHECK(check_fe_inverse(&x, &xi));
secp256k1_fe_inv_var(&xii, &xi);
CHECK(check_fe_equal(&x, &xii));
}
}
void run_field_inv_all(void) {
secp256k1_fe_t x[16], xi[16], xii[16];
/* Check it's safe to call for 0 elements */
secp256k1_fe_inv_all(0, xi, x);
for (int i=0; i<count; i++) {
size_t len = (secp256k1_rand32() & 15) + 1;
for (size_t j=0; j<len; j++)
random_fe_non_zero(&x[j]);
secp256k1_fe_inv_all(len, xi, x);
for (size_t j=0; j<len; j++)
CHECK(check_fe_inverse(&x[j], &xi[j]));
secp256k1_fe_inv_all(len, xii, xi);
for (size_t j=0; j<len; j++)
CHECK(check_fe_equal(&x[j], &xii[j]));
}
}
void run_field_inv_all_var(void) {
secp256k1_fe_t x[16], xi[16], xii[16];
/* Check it's safe to call for 0 elements */
secp256k1_fe_inv_all_var(0, xi, x);
for (int i=0; i<count; i++) {
size_t len = (secp256k1_rand32() & 15) + 1;
for (size_t j=0; j<len; j++)
random_fe_non_zero(&x[j]);
secp256k1_fe_inv_all_var(len, xi, x);
for (size_t j=0; j<len; j++)
CHECK(check_fe_inverse(&x[j], &xi[j]));
secp256k1_fe_inv_all_var(len, xii, xi);
for (size_t j=0; j<len; j++)
CHECK(check_fe_equal(&x[j], &xii[j]));
}
}
void run_sqr(void) {
secp256k1_fe_t x, s;
{
secp256k1_fe_set_int(&x, 1);
secp256k1_fe_negate(&x, &x, 1);
for (int i=1; i<=512; ++i) {
secp256k1_fe_mul_int(&x, 2);
secp256k1_fe_normalize(&x);
secp256k1_fe_sqr(&s, &x);
}
}
}
void test_sqrt(const secp256k1_fe_t *a, const secp256k1_fe_t *k) {
secp256k1_fe_t r1, r2;
int v = secp256k1_fe_sqrt(&r1, a);
CHECK((v == 0) == (k == NULL));
if (k != NULL) {
/* Check that the returned root is +/- the given known answer */
secp256k1_fe_negate(&r2, &r1, 1);
secp256k1_fe_add(&r1, k); secp256k1_fe_add(&r2, k);
secp256k1_fe_normalize(&r1); secp256k1_fe_normalize(&r2);
CHECK(secp256k1_fe_is_zero(&r1) || secp256k1_fe_is_zero(&r2));
}
}
void run_sqrt(void) {
secp256k1_fe_t ns, x, s, t;
/* Check sqrt(0) is 0 */
secp256k1_fe_set_int(&x, 0);
secp256k1_fe_sqr(&s, &x);
test_sqrt(&s, &x);
/* Check sqrt of small squares (and their negatives) */
for (int i=1; i<=100; i++) {
secp256k1_fe_set_int(&x, i);
secp256k1_fe_sqr(&s, &x);
test_sqrt(&s, &x);
secp256k1_fe_negate(&t, &s, 1);
test_sqrt(&t, NULL);
}
/* Consistency checks for large random values */
for (int i=0; i<10; i++) {
random_fe_non_square(&ns);
for (int j=0; j<count; j++) {
random_fe(&x);
secp256k1_fe_sqr(&s, &x);
test_sqrt(&s, &x);
secp256k1_fe_negate(&t, &s, 1);
test_sqrt(&t, NULL);
secp256k1_fe_mul(&t, &s, &ns);
test_sqrt(&t, NULL);
}
}
}
/***** GROUP TESTS *****/
int ge_equals_ge(const secp256k1_ge_t *a, const secp256k1_ge_t *b) {
if (a->infinity && b->infinity)
return 1;
return check_fe_equal(&a->x, &b->x) && check_fe_equal(&a->y, &b->y);
}
void ge_equals_gej(const secp256k1_ge_t *a, const secp256k1_gej_t *b) {
secp256k1_ge_t bb;
secp256k1_gej_t bj = *b;
secp256k1_ge_set_gej_var(&bb, &bj);
CHECK(ge_equals_ge(a, &bb));
}
void gej_equals_gej(const secp256k1_gej_t *a, const secp256k1_gej_t *b) {
secp256k1_ge_t aa, bb;
secp256k1_gej_t aj = *a, bj = *b;
secp256k1_ge_set_gej_var(&aa, &aj);
secp256k1_ge_set_gej_var(&bb, &bj);
CHECK(ge_equals_ge(&aa, &bb));
}
void test_ge(void) {
char ca[135];
char cb[68];
int rlen;
secp256k1_ge_t a, b, i, n;
random_group_element_test(&a);
random_group_element_test(&b);
rlen = sizeof(ca);
secp256k1_ge_get_hex(ca,&rlen,&a);
CHECK(rlen > 4 && rlen <= (int)sizeof(ca));
rlen = sizeof(cb);
secp256k1_ge_get_hex(cb,&rlen,&b); /* Intentionally undersized buffer. */
n = a;
secp256k1_fe_normalize(&a.y);
secp256k1_fe_negate(&n.y, &a.y, 1);
secp256k1_ge_set_infinity(&i);
random_field_element_magnitude(&a.x);
random_field_element_magnitude(&a.y);
random_field_element_magnitude(&b.x);
random_field_element_magnitude(&b.y);
random_field_element_magnitude(&n.x);
random_field_element_magnitude(&n.y);
secp256k1_gej_t aj, bj, ij, nj;
random_group_element_jacobian_test(&aj, &a);
random_group_element_jacobian_test(&bj, &b);
secp256k1_gej_set_infinity(&ij);
random_group_element_jacobian_test(&nj, &n);
random_field_element_magnitude(&aj.x);
random_field_element_magnitude(&aj.y);
random_field_element_magnitude(&aj.z);
random_field_element_magnitude(&bj.x);
random_field_element_magnitude(&bj.y);
random_field_element_magnitude(&bj.z);
random_field_element_magnitude(&nj.x);
random_field_element_magnitude(&nj.y);
random_field_element_magnitude(&nj.z);
/* gej + gej adds */
secp256k1_gej_t aaj; secp256k1_gej_add_var(&aaj, &aj, &aj);
secp256k1_gej_t abj; secp256k1_gej_add_var(&abj, &aj, &bj);
secp256k1_gej_t aij; secp256k1_gej_add_var(&aij, &aj, &ij);
secp256k1_gej_t anj; secp256k1_gej_add_var(&anj, &aj, &nj);
secp256k1_gej_t iaj; secp256k1_gej_add_var(&iaj, &ij, &aj);
secp256k1_gej_t iij; secp256k1_gej_add_var(&iij, &ij, &ij);
/* gej + ge adds */
secp256k1_gej_t aa; secp256k1_gej_add_ge_var(&aa, &aj, &a);
secp256k1_gej_t ab; secp256k1_gej_add_ge_var(&ab, &aj, &b);
secp256k1_gej_t ai; secp256k1_gej_add_ge_var(&ai, &aj, &i);
secp256k1_gej_t an; secp256k1_gej_add_ge_var(&an, &aj, &n);
secp256k1_gej_t ia; secp256k1_gej_add_ge_var(&ia, &ij, &a);
secp256k1_gej_t ii; secp256k1_gej_add_ge_var(&ii, &ij, &i);
/* const gej + ge adds */
secp256k1_gej_t aac; secp256k1_gej_add_ge(&aac, &aj, &a);
secp256k1_gej_t abc; secp256k1_gej_add_ge(&abc, &aj, &b);
secp256k1_gej_t anc; secp256k1_gej_add_ge(&anc, &aj, &n);
secp256k1_gej_t iac; secp256k1_gej_add_ge(&iac, &ij, &a);
CHECK(secp256k1_gej_is_infinity(&an));
CHECK(secp256k1_gej_is_infinity(&anj));
CHECK(secp256k1_gej_is_infinity(&anc));
gej_equals_gej(&aa, &aaj);
gej_equals_gej(&aa, &aac);
gej_equals_gej(&ab, &abj);
gej_equals_gej(&ab, &abc);
gej_equals_gej(&an, &anj);
gej_equals_gej(&an, &anc);
gej_equals_gej(&ia, &iaj);
gej_equals_gej(&ai, &aij);
gej_equals_gej(&ii, &iij);
ge_equals_gej(&a, &ai);
ge_equals_gej(&a, &ai);
ge_equals_gej(&a, &iaj);
ge_equals_gej(&a, &iaj);
ge_equals_gej(&a, &iac);
}
void run_ge(void) {
for (int i = 0; i < 2000*count; i++) {
test_ge();
}
}
/***** ECMULT TESTS *****/
void run_ecmult_chain(void) {
/* random starting point A (on the curve) */
secp256k1_fe_t ax; VERIFY_CHECK(secp256k1_fe_set_hex(&ax, "8b30bbe9ae2a990696b22f670709dff3727fd8bc04d3362c6c7bf458e2846004", 64));
secp256k1_fe_t ay; VERIFY_CHECK(secp256k1_fe_set_hex(&ay, "a357ae915c4a65281309edf20504740f0eb3343990216b4f81063cb65f2f7e0f", 64));
secp256k1_gej_t a; secp256k1_gej_set_xy(&a, &ax, &ay);
/* two random initial factors xn and gn */
static const unsigned char xni[32] = {
0x84, 0xcc, 0x54, 0x52, 0xf7, 0xfd, 0xe1, 0xed,
0xb4, 0xd3, 0x8a, 0x8c, 0xe9, 0xb1, 0xb8, 0x4c,
0xce, 0xf3, 0x1f, 0x14, 0x6e, 0x56, 0x9b, 0xe9,
0x70, 0x5d, 0x35, 0x7a, 0x42, 0x98, 0x54, 0x07
};
secp256k1_scalar_t xn;
secp256k1_scalar_set_b32(&xn, xni, NULL);
static const unsigned char gni[32] = {
0xa1, 0xe5, 0x8d, 0x22, 0x55, 0x3d, 0xcd, 0x42,
0xb2, 0x39, 0x80, 0x62, 0x5d, 0x4c, 0x57, 0xa9,
0x6e, 0x93, 0x23, 0xd4, 0x2b, 0x31, 0x52, 0xe5,
0xca, 0x2c, 0x39, 0x90, 0xed, 0xc7, 0xc9, 0xde
};
secp256k1_scalar_t gn;
secp256k1_scalar_set_b32(&gn, gni, NULL);
/* two small multipliers to be applied to xn and gn in every iteration: */
static const unsigned char xfi[32] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0x13,0x37};
secp256k1_scalar_t xf;
secp256k1_scalar_set_b32(&xf, xfi, NULL);
static const unsigned char gfi[32] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0x71,0x13};
secp256k1_scalar_t gf;
secp256k1_scalar_set_b32(&gf, gfi, NULL);
/* accumulators with the resulting coefficients to A and G */
secp256k1_scalar_t ae;
secp256k1_scalar_set_int(&ae, 1);
secp256k1_scalar_t ge;
secp256k1_scalar_set_int(&ge, 0);
/* the point being computed */
secp256k1_gej_t x = a;
for (int i=0; i<200*count; i++) {
/* in each iteration, compute X = xn*X + gn*G; */
secp256k1_ecmult(&x, &x, &xn, &gn);
/* also compute ae and ge: the actual accumulated factors for A and G */
/* if X was (ae*A+ge*G), xn*X + gn*G results in (xn*ae*A + (xn*ge+gn)*G) */
secp256k1_scalar_mul(&ae, &ae, &xn);
secp256k1_scalar_mul(&ge, &ge, &xn);
secp256k1_scalar_add(&ge, &ge, &gn);
/* modify xn and gn */
secp256k1_scalar_mul(&xn, &xn, &xf);
secp256k1_scalar_mul(&gn, &gn, &gf);
/* verify */
if (i == 60702) {
char res[132]; int resl = 132;
secp256k1_gej_get_hex(res, &resl, &x);
CHECK(strcmp(res, "(D6E96687F9B10D092A6F35439D86CEBEA4535D0D409F53586440BD74B933E830,B95CBCA2C77DA786539BE8FD53354D2D3B4F566AE658045407ED6015EE1B2A88)") == 0);
}
}
/* redo the computation, but directly with the resulting ae and ge coefficients: */
secp256k1_gej_t x2; secp256k1_ecmult(&x2, &a, &ae, &ge);
char res[132]; int resl = 132;
char res2[132]; int resl2 = 132;
secp256k1_gej_get_hex(res, &resl, &x);
secp256k1_gej_get_hex(res2, &resl2, &x2);
CHECK(strcmp(res, res2) == 0);
CHECK(strlen(res) == 131);
}
void test_point_times_order(const secp256k1_gej_t *point) {
/* X * (point + G) + (order-X) * (pointer + G) = 0 */
secp256k1_scalar_t x;
random_scalar_order_test(&x);
secp256k1_scalar_t nx;
secp256k1_scalar_negate(&nx, &x);
secp256k1_gej_t res1, res2;
secp256k1_ecmult(&res1, point, &x, &x); /* calc res1 = x * point + x * G; */
secp256k1_ecmult(&res2, point, &nx, &nx); /* calc res2 = (order - x) * point + (order - x) * G; */
secp256k1_gej_add_var(&res1, &res1, &res2);
CHECK(secp256k1_gej_is_infinity(&res1));
CHECK(secp256k1_gej_is_valid(&res1) == 0);
secp256k1_ge_t res3;
secp256k1_ge_set_gej(&res3, &res1);
CHECK(secp256k1_ge_is_infinity(&res3));
CHECK(secp256k1_ge_is_valid(&res3) == 0);
}
void run_point_times_order(void) {
secp256k1_fe_t x; VERIFY_CHECK(secp256k1_fe_set_hex(&x, "02", 2));
for (int i=0; i<500; i++) {
secp256k1_ge_t p;
if (secp256k1_ge_set_xo(&p, &x, 1)) {
CHECK(secp256k1_ge_is_valid(&p));
secp256k1_gej_t j;
secp256k1_gej_set_ge(&j, &p);
CHECK(secp256k1_gej_is_valid(&j));
test_point_times_order(&j);
}
secp256k1_fe_sqr(&x, &x);
}
char c[65]; int cl=65;
secp256k1_fe_get_hex(c, &cl, &x);
CHECK(strcmp(c, "7603CB59B0EF6C63FE6084792A0C378CDB3233A80F8A9A09A877DEAD31B38C45") == 0);
}
void test_wnaf(const secp256k1_scalar_t *number, int w) {
secp256k1_scalar_t x, two, t;
secp256k1_scalar_set_int(&x, 0);
secp256k1_scalar_set_int(&two, 2);
int wnaf[256];
int bits = secp256k1_ecmult_wnaf(wnaf, number, w);
CHECK(bits <= 256);
int zeroes = -1;
for (int i=bits-1; i>=0; i--) {
secp256k1_scalar_mul(&x, &x, &two);
int v = wnaf[i];
if (v) {
CHECK(zeroes == -1 || zeroes >= w-1); /* check that distance between non-zero elements is at least w-1 */
zeroes=0;
CHECK((v & 1) == 1); /* check non-zero elements are odd */
CHECK(v <= (1 << (w-1)) - 1); /* check range below */
CHECK(v >= -(1 << (w-1)) - 1); /* check range above */
} else {
CHECK(zeroes != -1); /* check that no unnecessary zero padding exists */
zeroes++;
}
if (v >= 0) {
secp256k1_scalar_set_int(&t, v);
} else {
secp256k1_scalar_set_int(&t, -v);
secp256k1_scalar_negate(&t, &t);
}
secp256k1_scalar_add(&x, &x, &t);
}
CHECK(secp256k1_scalar_eq(&x, number)); /* check that wnaf represents number */
}
void run_wnaf(void) {
secp256k1_scalar_t n;
for (int i=0; i<count; i++) {
random_scalar_order(&n);
if (i % 1)
secp256k1_scalar_negate(&n, &n);
test_wnaf(&n, 4+(i%10));
}
}
void random_sign(secp256k1_ecdsa_sig_t *sig, const secp256k1_scalar_t *key, const secp256k1_scalar_t *msg, int *recid) {
secp256k1_scalar_t nonce;
do {
random_scalar_order_test(&nonce);
} while(!secp256k1_ecdsa_sig_sign(sig, key, msg, &nonce, recid));
}
void test_ecdsa_sign_verify(void) {
int recid;
int getrec;
secp256k1_scalar_t msg, key;
random_scalar_order_test(&msg);
random_scalar_order_test(&key);
secp256k1_gej_t pubj; secp256k1_ecmult_gen(&pubj, &key);
secp256k1_ge_t pub; secp256k1_ge_set_gej(&pub, &pubj);
secp256k1_ecdsa_sig_t sig;
getrec = secp256k1_rand32()&1;
random_sign(&sig, &key, &msg, getrec?&recid:NULL);
if (getrec) CHECK(recid >= 0 && recid < 4);
CHECK(secp256k1_ecdsa_sig_verify(&sig, &pub, &msg));
secp256k1_scalar_t one;
secp256k1_scalar_set_int(&one, 1);
secp256k1_scalar_add(&msg, &msg, &one);
CHECK(!secp256k1_ecdsa_sig_verify(&sig, &pub, &msg));
}
void run_ecdsa_sign_verify(void) {
for (int i=0; i<10*count; i++) {
test_ecdsa_sign_verify();
}
}
void test_ecdsa_end_to_end(void) {
unsigned char privkey[32];
unsigned char message[32];
/* Generate a random key and message. */
{
secp256k1_scalar_t msg, key;
random_scalar_order_test(&msg);
random_scalar_order_test(&key);
secp256k1_scalar_get_b32(privkey, &key);
secp256k1_scalar_get_b32(message, &msg);
}
/* Construct and verify corresponding public key. */
CHECK(secp256k1_ec_seckey_verify(privkey) == 1);
unsigned char pubkey[65]; int pubkeylen = 65;
CHECK(secp256k1_ec_pubkey_create(pubkey, &pubkeylen, privkey, secp256k1_rand32() % 2) == 1);
CHECK(secp256k1_ec_pubkey_verify(pubkey, pubkeylen));
/* Verify private key import and export. */
unsigned char seckey[300]; int seckeylen = 300;
CHECK(secp256k1_ec_privkey_export(privkey, seckey, &seckeylen, secp256k1_rand32() % 2) == 1);
unsigned char privkey2[32];
CHECK(secp256k1_ec_privkey_import(privkey2, seckey, seckeylen) == 1);
CHECK(memcmp(privkey, privkey2, 32) == 0);
/* Optionally tweak the keys using addition. */
if (secp256k1_rand32() % 3 == 0) {
unsigned char rnd[32];
secp256k1_rand256_test(rnd);
int ret1 = secp256k1_ec_privkey_tweak_add(privkey, rnd);
int ret2 = secp256k1_ec_pubkey_tweak_add(pubkey, pubkeylen, rnd);
CHECK(ret1 == ret2);
if (ret1 == 0) return;
unsigned char pubkey2[65]; int pubkeylen2 = 65;
CHECK(secp256k1_ec_pubkey_create(pubkey2, &pubkeylen2, privkey, pubkeylen == 33) == 1);
CHECK(memcmp(pubkey, pubkey2, pubkeylen) == 0);
}
/* Optionally tweak the keys using multiplication. */
if (secp256k1_rand32() % 3 == 0) {
unsigned char rnd[32];
secp256k1_rand256_test(rnd);
int ret1 = secp256k1_ec_privkey_tweak_mul(privkey, rnd);
int ret2 = secp256k1_ec_pubkey_tweak_mul(pubkey, pubkeylen, rnd);
CHECK(ret1 == ret2);
if (ret1 == 0) return;
unsigned char pubkey2[65]; int pubkeylen2 = 65;
CHECK(secp256k1_ec_pubkey_create(pubkey2, &pubkeylen2, privkey, pubkeylen == 33) == 1);
CHECK(memcmp(pubkey, pubkey2, pubkeylen) == 0);
}
/* Sign. */
unsigned char signature[72]; int signaturelen = 72;
while(1) {
unsigned char rnd[32];
secp256k1_rand256_test(rnd);
if (secp256k1_ecdsa_sign(message, 32, signature, &signaturelen, privkey, rnd) == 1) {
break;
}
}
/* Verify. */
CHECK(secp256k1_ecdsa_verify(message, 32, signature, signaturelen, pubkey, pubkeylen) == 1);
/* Destroy signature and verify again. */
signature[signaturelen - 1 - secp256k1_rand32() % 20] += 1 + (secp256k1_rand32() % 255);
CHECK(secp256k1_ecdsa_verify(message, 32, signature, signaturelen, pubkey, pubkeylen) != 1);
/* Compact sign. */
unsigned char csignature[64]; int recid = 0;
while(1) {
unsigned char rnd[32];
secp256k1_rand256_test(rnd);
if (secp256k1_ecdsa_sign_compact(message, 32, csignature, privkey, rnd, &recid) == 1) {
break;
}
}
/* Recover. */
unsigned char recpubkey[65]; int recpubkeylen = 0;
CHECK(secp256k1_ecdsa_recover_compact(message, 32, csignature, recpubkey, &recpubkeylen, pubkeylen == 33, recid) == 1);
CHECK(recpubkeylen == pubkeylen);
CHECK(memcmp(pubkey, recpubkey, pubkeylen) == 0);
/* Destroy signature and verify again. */
csignature[secp256k1_rand32() % 64] += 1 + (secp256k1_rand32() % 255);
CHECK(secp256k1_ecdsa_recover_compact(message, 32, csignature, recpubkey, &recpubkeylen, pubkeylen == 33, recid) != 1 ||
memcmp(pubkey, recpubkey, pubkeylen) != 0);
CHECK(recpubkeylen == pubkeylen);
}
void run_ecdsa_end_to_end(void) {
for (int i=0; i<64*count; i++) {
test_ecdsa_end_to_end();
}
}
/* Tests several edge cases. */
void test_ecdsa_edge_cases(void) {
const unsigned char msg32[32] = {
'T', 'h', 'i', 's', ' ', 'i', 's', ' ',
'a', ' ', 'v', 'e', 'r', 'y', ' ', 's',
'e', 'c', 'r', 'e', 't', ' ', 'm', 'e',
's', 's', 'a', 'g', 'e', '.', '.', '.'
};
const unsigned char sig64[64] = {
/* Generated by signing the above message with nonce 'This is the nonce we will use...'
* and secret key 0 (which is not valid), resulting in recid 0. */
0x67, 0xCB, 0x28, 0x5F, 0x9C, 0xD1, 0x94, 0xE8,
0x40, 0xD6, 0x29, 0x39, 0x7A, 0xF5, 0x56, 0x96,
0x62, 0xFD, 0xE4, 0x46, 0x49, 0x99, 0x59, 0x63,
0x17, 0x9A, 0x7D, 0xD1, 0x7B, 0xD2, 0x35, 0x32,
0x4B, 0x1B, 0x7D, 0xF3, 0x4C, 0xE1, 0xF6, 0x8E,
0x69, 0x4F, 0xF6, 0xF1, 0x1A, 0xC7, 0x51, 0xDD,
0x7D, 0xD7, 0x3E, 0x38, 0x7E, 0xE4, 0xFC, 0x86,
0x6E, 0x1B, 0xE8, 0xEC, 0xC7, 0xDD, 0x95, 0x57
};
unsigned char pubkey[65];
int pubkeylen = 65;
CHECK(!secp256k1_ecdsa_recover_compact(msg32, 32, sig64, pubkey, &pubkeylen, 0, 0));
CHECK(secp256k1_ecdsa_recover_compact(msg32, 32, sig64, pubkey, &pubkeylen, 0, 1));
CHECK(!secp256k1_ecdsa_recover_compact(msg32, 32, sig64, pubkey, &pubkeylen, 0, 2));
CHECK(!secp256k1_ecdsa_recover_compact(msg32, 32, sig64, pubkey, &pubkeylen, 0, 3));
/* signature (r,s) = (4,4), which can be recovered with all 4 recids. */
const unsigned char sigb64[64] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04,
};
unsigned char pubkeyb[33];
int pubkeyblen = 33;
for (int recid = 0; recid < 4; recid++) {
/* (4,4) encoded in DER. */
unsigned char sigbder[8] = {0x30, 0x06, 0x02, 0x01, 0x04, 0x02, 0x01, 0x04};
/* (order + r,4) encoded in DER. */
unsigned char sigbderlong[40] = {
0x30, 0x26, 0x02, 0x21, 0x00, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xBA, 0xAE, 0xDC,
0xE6, 0xAF, 0x48, 0xA0, 0x3B, 0xBF, 0xD2, 0x5E,
0x8C, 0xD0, 0x36, 0x41, 0x45, 0x02, 0x01, 0x04
};
CHECK(secp256k1_ecdsa_recover_compact(msg32, 32, sigb64, pubkeyb, &pubkeyblen, 1, recid));
CHECK(secp256k1_ecdsa_verify(msg32, 32, sigbder, sizeof(sigbder), pubkeyb, pubkeyblen) == 1);
for (int recid2 = 0; recid2 < 4; recid2++) {
unsigned char pubkey2b[33];
int pubkey2blen = 33;
CHECK(secp256k1_ecdsa_recover_compact(msg32, 32, sigb64, pubkey2b, &pubkey2blen, 1, recid2));
/* Verifying with (order + r,4) should always fail. */
CHECK(secp256k1_ecdsa_verify(msg32, 32, sigbderlong, sizeof(sigbderlong), pubkey2b, pubkey2blen) != 1);
}
/* Damage signature. */
sigbder[7]++;
CHECK(secp256k1_ecdsa_verify(msg32, 32, sigbder, sizeof(sigbder), pubkeyb, pubkeyblen) == 0);
}
/* Test the case where ECDSA recomputes a point that is infinity. */
{
secp256k1_ecdsa_sig_t sig;
secp256k1_scalar_set_int(&sig.s, 1);
secp256k1_scalar_negate(&sig.s, &sig.s);
secp256k1_scalar_inverse(&sig.s, &sig.s);
secp256k1_scalar_set_int(&sig.r, 1);
secp256k1_gej_t keyj;
secp256k1_ecmult_gen(&keyj, &sig.r);
secp256k1_ge_t key;
secp256k1_ge_set_gej(&key, &keyj);
secp256k1_scalar_t msg = sig.s;
CHECK(secp256k1_ecdsa_sig_verify(&sig, &key, &msg) == 0);
}
/* Test r/s equal to zero */
{
/* (1,1) encoded in DER. */
unsigned char sigcder[8] = {0x30, 0x06, 0x02, 0x01, 0x01, 0x02, 0x01, 0x01};
unsigned char sigc64[64] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
};
unsigned char pubkeyc[65];
int pubkeyclen = 65;
CHECK(secp256k1_ecdsa_recover_compact(msg32, 32, sigc64, pubkeyc, &pubkeyclen, 0, 0) == 1);
CHECK(secp256k1_ecdsa_verify(msg32, 32, sigcder, sizeof(sigcder), pubkeyc, pubkeyclen) == 1);
sigcder[4] = 0;
sigc64[31] = 0;
CHECK(secp256k1_ecdsa_recover_compact(msg32, 32, sigc64, pubkeyb, &pubkeyblen, 1, 0) == 0);
CHECK(secp256k1_ecdsa_verify(msg32, 32, sigcder, sizeof(sigcder), pubkeyc, pubkeyclen) == 0);
sigcder[4] = 1;
sigcder[7] = 0;
sigc64[31] = 1;
sigc64[63] = 0;
CHECK(secp256k1_ecdsa_recover_compact(msg32, 32, sigc64, pubkeyb, &pubkeyblen, 1, 0) == 0);
CHECK(secp256k1_ecdsa_verify(msg32, 32, sigcder, sizeof(sigcder), pubkeyc, pubkeyclen) == 0);
}
}
void run_ecdsa_edge_cases(void) {
test_ecdsa_edge_cases();
}
#ifdef ENABLE_OPENSSL_TESTS
EC_KEY *get_openssl_key(const secp256k1_scalar_t *key) {
unsigned char privkey[300];
int privkeylen;
int compr = secp256k1_rand32() & 1;
const unsigned char* pbegin = privkey;
EC_KEY *ec_key = EC_KEY_new_by_curve_name(NID_secp256k1);
CHECK(secp256k1_eckey_privkey_serialize(privkey, &privkeylen, key, compr));
CHECK(d2i_ECPrivateKey(&ec_key, &pbegin, privkeylen));
CHECK(EC_KEY_check_key(ec_key));
return ec_key;
}
void test_ecdsa_openssl(void) {
secp256k1_scalar_t key, msg;
unsigned char message[32];
secp256k1_rand256_test(message);
secp256k1_scalar_set_b32(&msg, message, NULL);
random_scalar_order_test(&key);
secp256k1_gej_t qj;
secp256k1_ecmult_gen(&qj, &key);
secp256k1_ge_t q;
secp256k1_ge_set_gej(&q, &qj);
EC_KEY *ec_key = get_openssl_key(&key);
CHECK(ec_key);
unsigned char signature[80];
unsigned int sigsize = 80;
CHECK(ECDSA_sign(0, message, sizeof(message), signature, &sigsize, ec_key));
secp256k1_ecdsa_sig_t sig;
CHECK(secp256k1_ecdsa_sig_parse(&sig, signature, sigsize));
CHECK(secp256k1_ecdsa_sig_verify(&sig, &q, &msg));
secp256k1_scalar_t one;
secp256k1_scalar_set_int(&one, 1);
secp256k1_scalar_t msg2;
secp256k1_scalar_add(&msg2, &msg, &one);
CHECK(!secp256k1_ecdsa_sig_verify(&sig, &q, &msg2));
random_sign(&sig, &key, &msg, NULL);
int secp_sigsize = 80;
CHECK(secp256k1_ecdsa_sig_serialize(signature, &secp_sigsize, &sig));
CHECK(ECDSA_verify(0, message, sizeof(message), signature, secp_sigsize, ec_key) == 1);
EC_KEY_free(ec_key);
}
void run_ecdsa_openssl(void) {
for (int i=0; i<10*count; i++) {
test_ecdsa_openssl();
}
}
#endif
int main(int argc, char **argv) {
/* find iteration count */
if (argc > 1) {
count = strtol(argv[1], NULL, 0);
}
/* find random seed */
uint64_t seed;
if (argc > 2) {
seed = strtoull(argv[2], NULL, 0);
} else {
FILE *frand = fopen("/dev/urandom", "r");
if (!frand || !fread(&seed, sizeof(seed), 1, frand)) {
seed = time(NULL) * 1337;
}
fclose(frand);
}
secp256k1_rand_seed(seed);
printf("test count = %i\n", count);
printf("random seed = %llu\n", (unsigned long long)seed);
/* initialize */
secp256k1_start(SECP256K1_START_SIGN | SECP256K1_START_VERIFY);
/* initializing a second time shouldn't cause any harm or memory leaks. */
secp256k1_start(SECP256K1_START_SIGN | SECP256K1_START_VERIFY);
/* Likewise, re-running the internal init functions should be harmless. */
secp256k1_fe_start();
secp256k1_ge_start();
secp256k1_scalar_start();
secp256k1_ecdsa_start();
#ifndef USE_NUM_NONE
/* num tests */
run_num_smalltests();
#endif
/* scalar tests */
run_scalar_tests();
/* field tests */
run_field_inv();
run_field_inv_var();
run_field_inv_all();
run_field_inv_all_var();
run_sqr();
run_sqrt();
/* group tests */
run_ge();
/* ecmult tests */
run_wnaf();
run_point_times_order();
run_ecmult_chain();
/* ecdsa tests */
run_ecdsa_sign_verify();
run_ecdsa_end_to_end();
run_ecdsa_edge_cases();
#ifdef ENABLE_OPENSSL_TESTS
run_ecdsa_openssl();
#endif
printf("random run = %llu\n", (unsigned long long)secp256k1_rand32() + ((unsigned long long)secp256k1_rand32() << 32));
/* shutdown */
secp256k1_stop();
/* shutting down twice shouldn't cause any double frees. */
secp256k1_stop();
/* Same for the internal shutdown functions. */
secp256k1_fe_stop();
secp256k1_ge_stop();
secp256k1_scalar_stop();
secp256k1_ecdsa_stop();
return 0;
}
|
813319.c | /*
* Copyright (c) 2019 Centaur Analytics, Inc
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <device.h>
#include <drivers/i2c.h>
#include <drivers/sensor.h>
#include <sys/util.h>
#include <sys/byteorder.h>
#include <sys/__assert.h>
#include <logging/log.h>
#include <kernel.h>
#include "tmp116.h"
#define LOG_LEVEL CONFIG_SENSOR_LOG_LEVEL
LOG_MODULE_REGISTER(TMP116);
static int tmp116_reg_read(struct device *dev, u8_t reg, u16_t *val)
{
struct tmp116_data *drv_data = dev->driver_data;
const struct tmp116_dev_config *cfg = dev->config->config_info;
if (i2c_burst_read(drv_data->i2c, cfg->i2c_addr, reg, (u8_t *)val, 2)
< 0) {
return -EIO;
}
*val = sys_be16_to_cpu(*val);
return 0;
}
/**
* @brief Check the Device ID
*
* @param[in] dev Pointer to the device structure
*
* @retval 0 On success
* @retval -EIO Otherwise
*/
static inline int tmp116_device_id_check(struct device *dev)
{
u16_t value;
if (tmp116_reg_read(dev, TMP116_REG_DEVICE_ID, &value) != 0) {
LOG_ERR("%s: Failed to get Device ID register!",
DT_INST_0_TI_TMP116_LABEL);
return -EIO;
}
if (value != TMP116_DEVICE_ID) {
LOG_ERR("%s: Failed to match the device IDs!",
DT_INST_0_TI_TMP116_LABEL);
return -EINVAL;
}
return 0;
}
static int tmp116_sample_fetch(struct device *dev, enum sensor_channel chan)
{
struct tmp116_data *drv_data = dev->driver_data;
u16_t value;
int rc;
__ASSERT_NO_MSG(chan == SENSOR_CHAN_ALL ||
chan == SENSOR_CHAN_AMBIENT_TEMP);
/* clear sensor values */
drv_data->sample = 0U;
/* Get the most recent temperature measurement */
rc = tmp116_reg_read(dev, TMP116_REG_TEMP, &value);
if (rc < 0) {
LOG_ERR("%s: Failed to read from TEMP register!",
DT_INST_0_TI_TMP116_LABEL);
return rc;
}
/* store measurements to the driver */
drv_data->sample = (s16_t)value;
return 0;
}
static int tmp116_channel_get(struct device *dev, enum sensor_channel chan,
struct sensor_value *val)
{
struct tmp116_data *drv_data = dev->driver_data;
s32_t tmp;
if (chan != SENSOR_CHAN_AMBIENT_TEMP) {
return -ENOTSUP;
}
/*
* See datasheet "Temperature Results and Limits" section for more
* details on processing sample data.
*/
tmp = (s32_t)drv_data->sample * TMP116_RESOLUTION;
val->val1 = tmp / 10000000; /* Tens of uCelsius */
val->val2 = tmp % 10000000;
return 0;
}
static const struct sensor_driver_api tmp116_driver_api = {
.sample_fetch = tmp116_sample_fetch,
.channel_get = tmp116_channel_get
};
static int tmp116_init(struct device *dev)
{
struct tmp116_data *drv_data = dev->driver_data;
int rc;
/* Bind to the I2C bus that the sensor is connected */
drv_data->i2c = device_get_binding(DT_INST_0_TI_TMP116_BUS_NAME);
if (!drv_data->i2c) {
LOG_ERR("Cannot bind to %s device!",
DT_INST_0_TI_TMP116_BUS_NAME);
return -EINVAL;
}
/* Check the Device ID */
rc = tmp116_device_id_check(dev);
if (rc < 0) {
return rc;
}
return 0;
}
static struct tmp116_data tmp116_data;
static const struct tmp116_dev_config tmp116_config = {
.i2c_addr = DT_INST_0_TI_TMP116_BASE_ADDRESS,
};
DEVICE_AND_API_INIT(hdc1080, DT_INST_0_TI_TMP116_LABEL, tmp116_init,
&tmp116_data, &tmp116_config, POST_KERNEL,
CONFIG_SENSOR_INIT_PRIORITY, &tmp116_driver_api);
|
586761.c | /********************************************************************************************************
* uC/CPU
* CPU CONFIGURATION & PORT LAYER
*
* (c) Copyright 2004-2015; Micrium, Inc.; Weston, FL
*
* All rights reserved. Protected by international copyright laws.
*
* uC/CPU is provided in source form to registered licensees ONLY. It is
* illegal to distribute this source code to any third party unless you receive
* written permission by an authorized Micrium representative. Knowledge of
* the source code may NOT be used to develop a similar product.
*
* Please help us continue to provide the Embedded community with the finest
* software available. Your honesty is greatly appreciated.
*
* You can contact us at www.micrium.com.
*********************************************************************************************************
*/
/********************************************************************************************************
*
* CPU PORT FILE
*
* Renesas RL78 Specific code
* GNU RL78 C Compiler
*
* Filename : cpu_a.asm
* Version : V1.30.02.00
* Programmer(s) : MD
*********************************************************************************************************
*/
#include <cpu.h>
/********************************************************************************************************
* set_interrupt_state & get_interrupt_state
*
* Description: Set or retrieve interrupt priority level.
* KPIT GNU Work around for set and get interrupt states
*********************************************************************************************************
*/
void __set_interrupt_state(CPU_INT08U cpu_sr){
if (cpu_sr)
asm("EI");
else
asm("DI");
}
CPU_INT08U __get_interrupt_state(void){
CPU_INT08U cpu_sr;
asm(" MOV A, PSW"); /* Get Process Status Word Register PSW value */
asm(" SHR A, 7"); /* Save only the Interrupt Enabled (IE) Bit */
asm(" MOV %0, A" : "=r"(cpu_sr)); /* Save IE bit value into cpu_sr */ //__asm
return(cpu_sr);
}
|
407810.c | /*
* Copyright © 2006-2007 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* Authors:
* Eric Anholt <[email protected]>
*/
#include <linux/i2c.h>
#include <linux/slab.h>
#include "drmP.h"
#include "drm.h"
#include "drm_crtc.h"
#include "drm_crtc_helper.h"
#include "intel_drv.h"
#include "i915_drm.h"
#include "i915_drv.h"
static void intel_crt_dpms(struct drm_encoder *encoder, int mode)
{
struct drm_device *dev = encoder->dev;
struct drm_i915_private *dev_priv = dev->dev_private;
u32 temp, reg;
if (HAS_PCH_SPLIT(dev))
reg = PCH_ADPA;
else
reg = ADPA;
temp = I915_READ(reg);
temp &= ~(ADPA_HSYNC_CNTL_DISABLE | ADPA_VSYNC_CNTL_DISABLE);
temp &= ~ADPA_DAC_ENABLE;
switch(mode) {
case DRM_MODE_DPMS_ON:
temp |= ADPA_DAC_ENABLE;
break;
case DRM_MODE_DPMS_STANDBY:
temp |= ADPA_DAC_ENABLE | ADPA_HSYNC_CNTL_DISABLE;
break;
case DRM_MODE_DPMS_SUSPEND:
temp |= ADPA_DAC_ENABLE | ADPA_VSYNC_CNTL_DISABLE;
break;
case DRM_MODE_DPMS_OFF:
temp |= ADPA_HSYNC_CNTL_DISABLE | ADPA_VSYNC_CNTL_DISABLE;
break;
}
I915_WRITE(reg, temp);
}
static int intel_crt_mode_valid(struct drm_connector *connector,
struct drm_display_mode *mode)
{
struct drm_device *dev = connector->dev;
int max_clock = 0;
if (mode->flags & DRM_MODE_FLAG_DBLSCAN)
return MODE_NO_DBLESCAN;
if (mode->clock < 25000)
return MODE_CLOCK_LOW;
if (!IS_I9XX(dev))
max_clock = 350000;
else
max_clock = 400000;
if (mode->clock > max_clock)
return MODE_CLOCK_HIGH;
return MODE_OK;
}
static bool intel_crt_mode_fixup(struct drm_encoder *encoder,
struct drm_display_mode *mode,
struct drm_display_mode *adjusted_mode)
{
return true;
}
static void intel_crt_mode_set(struct drm_encoder *encoder,
struct drm_display_mode *mode,
struct drm_display_mode *adjusted_mode)
{
struct drm_device *dev = encoder->dev;
struct drm_crtc *crtc = encoder->crtc;
struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
struct drm_i915_private *dev_priv = dev->dev_private;
int dpll_md_reg;
u32 adpa, dpll_md;
u32 adpa_reg;
if (intel_crtc->pipe == 0)
dpll_md_reg = DPLL_A_MD;
else
dpll_md_reg = DPLL_B_MD;
if (HAS_PCH_SPLIT(dev))
adpa_reg = PCH_ADPA;
else
adpa_reg = ADPA;
if (IS_I965G(dev) && !HAS_PCH_SPLIT(dev)) {
dpll_md = I915_READ(dpll_md_reg);
I915_WRITE(dpll_md_reg,
dpll_md & ~DPLL_MD_UDI_MULTIPLIER_MASK);
}
adpa = 0;
if (adjusted_mode->flags & DRM_MODE_FLAG_PHSYNC)
adpa |= ADPA_HSYNC_ACTIVE_HIGH;
if (adjusted_mode->flags & DRM_MODE_FLAG_PVSYNC)
adpa |= ADPA_VSYNC_ACTIVE_HIGH;
if (intel_crtc->pipe == 0) {
if (HAS_PCH_CPT(dev))
adpa |= PORT_TRANS_A_SEL_CPT;
else
adpa |= ADPA_PIPE_A_SELECT;
if (!HAS_PCH_SPLIT(dev))
I915_WRITE(BCLRPAT_A, 0);
} else {
if (HAS_PCH_CPT(dev))
adpa |= PORT_TRANS_B_SEL_CPT;
else
adpa |= ADPA_PIPE_B_SELECT;
if (!HAS_PCH_SPLIT(dev))
I915_WRITE(BCLRPAT_B, 0);
}
I915_WRITE(adpa_reg, adpa);
}
static bool intel_ironlake_crt_detect_hotplug(struct drm_connector *connector)
{
struct drm_device *dev = connector->dev;
struct drm_i915_private *dev_priv = dev->dev_private;
u32 adpa, temp;
bool ret;
bool turn_off_dac = false;
temp = adpa = I915_READ(PCH_ADPA);
if (HAS_PCH_SPLIT(dev))
turn_off_dac = true;
adpa &= ~ADPA_CRT_HOTPLUG_MASK;
if (turn_off_dac)
adpa &= ~ADPA_DAC_ENABLE;
/* disable HPD first */
I915_WRITE(PCH_ADPA, adpa);
(void)I915_READ(PCH_ADPA);
adpa |= (ADPA_CRT_HOTPLUG_PERIOD_128 |
ADPA_CRT_HOTPLUG_WARMUP_10MS |
ADPA_CRT_HOTPLUG_SAMPLE_4S |
ADPA_CRT_HOTPLUG_VOLTAGE_50 | /* default */
ADPA_CRT_HOTPLUG_VOLREF_325MV |
ADPA_CRT_HOTPLUG_ENABLE |
ADPA_CRT_HOTPLUG_FORCE_TRIGGER);
DRM_DEBUG_KMS("pch crt adpa 0x%x", adpa);
I915_WRITE(PCH_ADPA, adpa);
if (wait_for((I915_READ(PCH_ADPA) & ADPA_CRT_HOTPLUG_FORCE_TRIGGER) == 0,
1000, 1))
DRM_DEBUG_KMS("timed out waiting for FORCE_TRIGGER");
if (turn_off_dac) {
/* Make sure hotplug is enabled */
I915_WRITE(PCH_ADPA, temp | ADPA_CRT_HOTPLUG_ENABLE);
(void)I915_READ(PCH_ADPA);
}
/* Check the status to see if both blue and green are on now */
adpa = I915_READ(PCH_ADPA);
adpa &= ADPA_CRT_HOTPLUG_MONITOR_MASK;
if ((adpa == ADPA_CRT_HOTPLUG_MONITOR_COLOR) ||
(adpa == ADPA_CRT_HOTPLUG_MONITOR_MONO))
ret = true;
else
ret = false;
return ret;
}
/**
* Uses CRT_HOTPLUG_EN and CRT_HOTPLUG_STAT to detect CRT presence.
*
* Not for i915G/i915GM
*
* \return true if CRT is connected.
* \return false if CRT is disconnected.
*/
static bool intel_crt_detect_hotplug(struct drm_connector *connector)
{
struct drm_device *dev = connector->dev;
struct drm_i915_private *dev_priv = dev->dev_private;
u32 hotplug_en, orig, stat;
bool ret = false;
int i, tries = 0;
if (HAS_PCH_SPLIT(dev))
return intel_ironlake_crt_detect_hotplug(connector);
/*
* On 4 series desktop, CRT detect sequence need to be done twice
* to get a reliable result.
*/
if (IS_G4X(dev) && !IS_GM45(dev))
tries = 2;
else
tries = 1;
hotplug_en = orig = I915_READ(PORT_HOTPLUG_EN);
hotplug_en |= CRT_HOTPLUG_FORCE_DETECT;
for (i = 0; i < tries ; i++) {
/* turn on the FORCE_DETECT */
I915_WRITE(PORT_HOTPLUG_EN, hotplug_en);
/* wait for FORCE_DETECT to go off */
if (wait_for((I915_READ(PORT_HOTPLUG_EN) &
CRT_HOTPLUG_FORCE_DETECT) == 0,
1000, 1))
DRM_DEBUG_KMS("timed out waiting for FORCE_DETECT to go off");
}
stat = I915_READ(PORT_HOTPLUG_STAT);
if ((stat & CRT_HOTPLUG_MONITOR_MASK) != CRT_HOTPLUG_MONITOR_NONE)
ret = true;
/* clear the interrupt we just generated, if any */
I915_WRITE(PORT_HOTPLUG_STAT, CRT_HOTPLUG_INT_STATUS);
/* and put the bits back */
I915_WRITE(PORT_HOTPLUG_EN, orig);
return ret;
}
static bool intel_crt_detect_ddc(struct drm_encoder *encoder)
{
struct intel_encoder *intel_encoder = enc_to_intel_encoder(encoder);
/* CRT should always be at 0, but check anyway */
if (intel_encoder->type != INTEL_OUTPUT_ANALOG)
return false;
return intel_ddc_probe(intel_encoder);
}
static enum drm_connector_status
intel_crt_load_detect(struct drm_crtc *crtc, struct intel_encoder *intel_encoder)
{
struct drm_encoder *encoder = &intel_encoder->enc;
struct drm_device *dev = encoder->dev;
struct drm_i915_private *dev_priv = dev->dev_private;
struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
uint32_t pipe = intel_crtc->pipe;
uint32_t save_bclrpat;
uint32_t save_vtotal;
uint32_t vtotal, vactive;
uint32_t vsample;
uint32_t vblank, vblank_start, vblank_end;
uint32_t dsl;
uint32_t bclrpat_reg;
uint32_t vtotal_reg;
uint32_t vblank_reg;
uint32_t vsync_reg;
uint32_t pipeconf_reg;
uint32_t pipe_dsl_reg;
uint8_t st00;
enum drm_connector_status status;
if (pipe == 0) {
bclrpat_reg = BCLRPAT_A;
vtotal_reg = VTOTAL_A;
vblank_reg = VBLANK_A;
vsync_reg = VSYNC_A;
pipeconf_reg = PIPEACONF;
pipe_dsl_reg = PIPEADSL;
} else {
bclrpat_reg = BCLRPAT_B;
vtotal_reg = VTOTAL_B;
vblank_reg = VBLANK_B;
vsync_reg = VSYNC_B;
pipeconf_reg = PIPEBCONF;
pipe_dsl_reg = PIPEBDSL;
}
save_bclrpat = I915_READ(bclrpat_reg);
save_vtotal = I915_READ(vtotal_reg);
vblank = I915_READ(vblank_reg);
vtotal = ((save_vtotal >> 16) & 0xfff) + 1;
vactive = (save_vtotal & 0x7ff) + 1;
vblank_start = (vblank & 0xfff) + 1;
vblank_end = ((vblank >> 16) & 0xfff) + 1;
/* Set the border color to purple. */
I915_WRITE(bclrpat_reg, 0x500050);
if (IS_I9XX(dev)) {
uint32_t pipeconf = I915_READ(pipeconf_reg);
I915_WRITE(pipeconf_reg, pipeconf | PIPECONF_FORCE_BORDER);
/* Wait for next Vblank to substitue
* border color for Color info */
intel_wait_for_vblank(dev, pipe);
st00 = I915_READ8(VGA_MSR_WRITE);
status = ((st00 & (1 << 4)) != 0) ?
connector_status_connected :
connector_status_disconnected;
I915_WRITE(pipeconf_reg, pipeconf);
} else {
bool restore_vblank = false;
int count, detect;
/*
* If there isn't any border, add some.
* Yes, this will flicker
*/
if (vblank_start <= vactive && vblank_end >= vtotal) {
uint32_t vsync = I915_READ(vsync_reg);
uint32_t vsync_start = (vsync & 0xffff) + 1;
vblank_start = vsync_start;
I915_WRITE(vblank_reg,
(vblank_start - 1) |
((vblank_end - 1) << 16));
restore_vblank = true;
}
/* sample in the vertical border, selecting the larger one */
if (vblank_start - vactive >= vtotal - vblank_end)
vsample = (vblank_start + vactive) >> 1;
else
vsample = (vtotal + vblank_end) >> 1;
/*
* Wait for the border to be displayed
*/
while (I915_READ(pipe_dsl_reg) >= vactive)
;
while ((dsl = I915_READ(pipe_dsl_reg)) <= vsample)
;
/*
* Watch ST00 for an entire scanline
*/
detect = 0;
count = 0;
do {
count++;
/* Read the ST00 VGA status register */
st00 = I915_READ8(VGA_MSR_WRITE);
if (st00 & (1 << 4))
detect++;
} while ((I915_READ(pipe_dsl_reg) == dsl));
/* restore vblank if necessary */
if (restore_vblank)
I915_WRITE(vblank_reg, vblank);
/*
* If more than 3/4 of the scanline detected a monitor,
* then it is assumed to be present. This works even on i830,
* where there isn't any way to force the border color across
* the screen
*/
status = detect * 4 > count * 3 ?
connector_status_connected :
connector_status_disconnected;
}
/* Restore previous settings */
I915_WRITE(bclrpat_reg, save_bclrpat);
return status;
}
static enum drm_connector_status
intel_crt_detect(struct drm_connector *connector, bool force)
{
struct drm_device *dev = connector->dev;
struct drm_encoder *encoder = intel_attached_encoder(connector);
struct intel_encoder *intel_encoder = enc_to_intel_encoder(encoder);
struct drm_crtc *crtc;
int dpms_mode;
enum drm_connector_status status;
if (IS_I9XX(dev) && !IS_I915G(dev) && !IS_I915GM(dev)) {
if (intel_crt_detect_hotplug(connector))
return connector_status_connected;
else
return connector_status_disconnected;
}
if (intel_crt_detect_ddc(encoder))
return connector_status_connected;
if (!force)
return connector->status;
/* for pre-945g platforms use load detect */
if (encoder->crtc && encoder->crtc->enabled) {
status = intel_crt_load_detect(encoder->crtc, intel_encoder);
} else {
crtc = intel_get_load_detect_pipe(intel_encoder, connector,
NULL, &dpms_mode);
if (crtc) {
status = intel_crt_load_detect(crtc, intel_encoder);
intel_release_load_detect_pipe(intel_encoder,
connector, dpms_mode);
} else
status = connector_status_unknown;
}
return status;
}
static void intel_crt_destroy(struct drm_connector *connector)
{
drm_sysfs_connector_remove(connector);
drm_connector_cleanup(connector);
kfree(connector);
}
static int intel_crt_get_modes(struct drm_connector *connector)
{
int ret;
struct drm_encoder *encoder = intel_attached_encoder(connector);
struct intel_encoder *intel_encoder = enc_to_intel_encoder(encoder);
struct i2c_adapter *ddc_bus;
struct drm_device *dev = connector->dev;
ret = intel_ddc_get_modes(connector, intel_encoder->ddc_bus);
if (ret || !IS_G4X(dev))
goto end;
/* Try to probe digital port for output in DVI-I -> VGA mode. */
ddc_bus = intel_i2c_create(connector->dev, GPIOD, "CRTDDC_D");
if (!ddc_bus) {
dev_printk(KERN_ERR, &connector->dev->pdev->dev,
"DDC bus registration failed for CRTDDC_D.\n");
goto end;
}
/* Try to get modes by GPIOD port */
ret = intel_ddc_get_modes(connector, ddc_bus);
intel_i2c_destroy(ddc_bus);
end:
return ret;
}
static int intel_crt_set_property(struct drm_connector *connector,
struct drm_property *property,
uint64_t value)
{
return 0;
}
/*
* Routines for controlling stuff on the analog port
*/
static const struct drm_encoder_helper_funcs intel_crt_helper_funcs = {
.dpms = intel_crt_dpms,
.mode_fixup = intel_crt_mode_fixup,
.prepare = intel_encoder_prepare,
.commit = intel_encoder_commit,
.mode_set = intel_crt_mode_set,
};
static const struct drm_connector_funcs intel_crt_connector_funcs = {
.dpms = drm_helper_connector_dpms,
.detect = intel_crt_detect,
.fill_modes = drm_helper_probe_single_connector_modes,
.destroy = intel_crt_destroy,
.set_property = intel_crt_set_property,
};
static const struct drm_connector_helper_funcs intel_crt_connector_helper_funcs = {
.mode_valid = intel_crt_mode_valid,
.get_modes = intel_crt_get_modes,
.best_encoder = intel_attached_encoder,
};
static const struct drm_encoder_funcs intel_crt_enc_funcs = {
.destroy = intel_encoder_destroy,
};
void intel_crt_init(struct drm_device *dev)
{
struct drm_connector *connector;
struct intel_encoder *intel_encoder;
struct intel_connector *intel_connector;
struct drm_i915_private *dev_priv = dev->dev_private;
u32 i2c_reg;
intel_encoder = kzalloc(sizeof(struct intel_encoder), GFP_KERNEL);
if (!intel_encoder)
return;
intel_connector = kzalloc(sizeof(struct intel_connector), GFP_KERNEL);
if (!intel_connector) {
kfree(intel_encoder);
return;
}
connector = &intel_connector->base;
drm_connector_init(dev, &intel_connector->base,
&intel_crt_connector_funcs, DRM_MODE_CONNECTOR_VGA);
drm_encoder_init(dev, &intel_encoder->enc, &intel_crt_enc_funcs,
DRM_MODE_ENCODER_DAC);
drm_mode_connector_attach_encoder(&intel_connector->base,
&intel_encoder->enc);
/* Set up the DDC bus. */
if (HAS_PCH_SPLIT(dev))
i2c_reg = PCH_GPIOA;
else {
i2c_reg = GPIOA;
/* Use VBT information for CRT DDC if available */
if (dev_priv->crt_ddc_bus != 0)
i2c_reg = dev_priv->crt_ddc_bus;
}
intel_encoder->ddc_bus = intel_i2c_create(dev, i2c_reg, "CRTDDC_A");
if (!intel_encoder->ddc_bus) {
dev_printk(KERN_ERR, &dev->pdev->dev, "DDC bus registration "
"failed.\n");
return;
}
intel_encoder->type = INTEL_OUTPUT_ANALOG;
intel_encoder->clone_mask = (1 << INTEL_SDVO_NON_TV_CLONE_BIT) |
(1 << INTEL_ANALOG_CLONE_BIT) |
(1 << INTEL_SDVO_LVDS_CLONE_BIT);
intel_encoder->crtc_mask = (1 << 0) | (1 << 1);
connector->interlace_allowed = 1;
connector->doublescan_allowed = 0;
drm_encoder_helper_add(&intel_encoder->enc, &intel_crt_helper_funcs);
drm_connector_helper_add(connector, &intel_crt_connector_helper_funcs);
drm_sysfs_connector_add(connector);
if (I915_HAS_HOTPLUG(dev))
connector->polled = DRM_CONNECTOR_POLL_HPD;
else
connector->polled = DRM_CONNECTOR_POLL_CONNECT;
dev_priv->hotplug_supported_mask |= CRT_HOTPLUG_INT_STATUS;
}
|
121483.c | /*
* dcap.c
*
* Copyright (c) 2011, DeepField Networks, Inc. <[email protected]>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of DeepField Networks, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
#include <sys/types.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <sys/stat.h>
#include <errno.h>
#include <err.h>
#include <math.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <time.h>
#include <arpa/inet.h>
#include <netinet/ip.h>
#include <netinet/ip6.h>
#include <netinet/in.h>
#include <netinet/udp.h>
#include <netinet/tcp.h>
#include <pcap/pcap.h>
#include <net/ethernet.h>
#include <event.h>
#include "dcap.h"
#ifndef ETHERTYPE_VLAN
#define ETHERTYPE_VLAN 0x8100 /* IEEE 802.1Q VLAN tagging */
#endif
#define MAXIMUM_SNAPLEN 65535
static int
datalink_offset(int i)
{
switch (i) {
case DLT_EN10MB:
i = sizeof(struct ether_header);
break;
case DLT_IEEE802:
i = 22;
break;
case DLT_FDDI:
i = 21;
break;
case DLT_LINUX_SLL:
i = 16;
break;
#ifdef DLT_LOOP
case DLT_LOOP:
#endif
case DLT_NULL:
i = 4;
break;
default:
i = -1;
break;
}
return (i);
}
static void
dcap_pcap_cb(u_char *user, const struct pcap_pkthdr *pkthdr, const u_char *pkt)
{
struct ether_header *eh;
uint16_t ether_type;
pcap_t *pcap = NULL;
struct dcap *dcap;
int length, dl, dloff;
char *p;
dcap = (struct dcap *) user;
pcap = dcap->_pcap;
if (dcap->sample_rate > 1) {
/* Seeding is left to the user. */
if (random() % dcap->sample_rate != 0) {
return;
}
}
if (pkthdr->caplen != pkthdr->len) {
warnx("Invalid caplen: %d %d\n", pkthdr->caplen, pkthdr->len);
return;
}
dl = pcap_datalink(pcap);
dloff = datalink_offset(dl);
if(dloff == -1) {
warnx("Unsupported datalink: %d\n", dl);
return;
}
if (pkthdr->len < dloff + sizeof(struct ip)) {
warnx("Invalid packet: length=%d\n", pkthdr->len);
return;
}
p = (char *)pkt;
length = pkthdr->len;
if(dl != DLT_NULL
#ifdef DLT_LOOP
&& dl != DLT_LOOP
#endif
&& dl != DLT_LINUX_SLL)
{
eh = (struct ether_header *)p;
ether_type = ntohs(eh->ether_type);
p += dloff;
length -= dloff;
/* Unencapsulate 802.1Q VLAN */
/* XXX Only supporting 1 level. Just loop for qinq? */
if (ether_type == ETHERTYPE_VLAN) {
ether_type = ntohs(*(uint16_t *)(p + 2));
p += 4;
length -= 4;
}
/* XXX Why are we only checking for IP if it's ethernet? */
if (ether_type != ETHERTYPE_IP && ether_type != ETHERTYPE_IPV6) {
warnx("Non-ip: ether_type=%d\n", ether_type);
return;
}
} else {
p += dloff;
length -= dloff;
}
dcap->pkts_captured++;
dcap->_callback((struct timeval *)&pkthdr->ts, length, p, dcap->user);
}
/* Returns fd if you want to set up libevent yourself. */
int
dcap_get_fd(struct dcap *dcap)
{
/* See man page. Apparently it's not always selectable on OS X. */
return (pcap_get_selectable_fd(dcap->_pcap));
}
static void
dcap_event_cb(int fd, short event, void *arg)
{
struct dcap *dcap = (struct dcap *)arg;
#if __APPLE__ && __MACH__
struct timeval ev_tv[1] = {{1, 0}};
#else
struct timeval *ev_tv = NULL;
#endif
/* Use pcap_dispatch with cnt of -1 so entire buffer is processed. */
pcap_dispatch(dcap->_pcap, -1,
(pcap_handler)dcap_pcap_cb, (u_char *)dcap);
event_add(dcap->_ev_pcap, ev_tv);
}
/* Use libevent to check for readiness. */
int
dcap_event_set(struct dcap *dcap)
{
#if __APPLE__ && __MACH__
/* Not totally sure what's going on, but it seems bpf won't
* consistently mark the fd as readable, possibly not until the whole
* buffer fills. So, add timeout to handle low packet rates.
* pcap_dispatch() seems to grab any waiting packets, even if the
* buffer hasn't filled. man pcap_get_selectable_fd has some notes on
* this. */
struct timeval ev_tv[1] = {{1, 0}};
#else
struct timeval *ev_tv = NULL;
#endif
event_set(dcap->_ev_pcap, dcap_get_fd(dcap), EV_READ,
dcap_event_cb, dcap);
if (event_add(dcap->_ev_pcap, ev_tv) < 0) {
warnx("event_add error");
return (-1);
}
return (0);
}
struct dcap *
dcap_init_live(char *intf_name, int promisc, char *filter,
dcap_handler callback)
{
char errbuf[PCAP_ERRBUF_SIZE];
struct bpf_program bpf_program;
bpf_u_int32 localnet, netmask;
struct dcap *dcap = NULL;
pcap_t *pcap = NULL;
int status;
/* Basically mirroring how tcpdump sets up pcap. Exceptions noted. */
if (intf_name == NULL) {
if ((intf_name = pcap_lookupdev(errbuf)) == NULL) {
warnx("%s", errbuf);
return (NULL);
}
}
if ((pcap = pcap_create(intf_name, errbuf)) == NULL) {
warnx("%s", errbuf);
return (NULL);
}
/* Try large enough to hold 1 sec of a GigE interface. */
if ((status = pcap_set_buffer_size(pcap, 1000000000 / 8)) != 0) {
warnx("%s: Can't set buffer size: %s",
intf_name, pcap_statustostr(status));
pcap_close(pcap);
return (NULL);
}
if ((status = pcap_set_snaplen(pcap, MAXIMUM_SNAPLEN)) != 0) {
warnx("%s: Can't set snapshot length: %s",
intf_name, pcap_statustostr(status));
pcap_close(pcap);
return (NULL);
}
if ((status = pcap_set_promisc(pcap, promisc)) !=0) {
warnx("%s: Can't set promiscuous mode: %s",
intf_name, pcap_statustostr(status));
pcap_close(pcap);
return (NULL);
}
/* What should timeout be? tcpdump just sets to 1000. */
if ((status = pcap_set_timeout(pcap, 1000)) != 0) {
warnx("%s: pcap_set_timeout failed: %s",
intf_name, pcap_statustostr(status));
pcap_close(pcap);
return (NULL);
}
if ((status = pcap_activate(pcap)) != 0) {
warnx("%s: %s\n(%s)", intf_name, pcap_statustostr(status),
pcap_geterr(pcap));
pcap_close(pcap);
return (NULL);
}
/* Using libevent to check for readiness, so set nonblocking. */
if ((status = pcap_setnonblock(pcap, 1, errbuf)) !=0) {
warnx("pcap_setnonblock failed: %s: %s",
pcap_statustostr(status), errbuf);
pcap_close(pcap);
return (NULL);
}
dcap = calloc(1, sizeof(struct dcap));
dcap->_pcap = pcap;
dcap->_callback = callback;
dcap->user = NULL;
/* Get the netmask. Only used for "ip broadcast" filter expression,
* so doesn't really matter. */
if (pcap_lookupnet(intf_name, &localnet, &netmask, errbuf) < 0) {
/* Not a fatal error, since we don't care. */
localnet = 0;
netmask = 0;
warnx("%s", errbuf);
}
if (pcap_compile(pcap, &bpf_program, filter, 1, netmask) < 0) {
warnx("%s", pcap_geterr(pcap));
pcap_close(pcap);
return (NULL);
}
/* XXX There's a race here. The pcap is already activated above,
* but we haven't set the filter yet. Could get some unwanted pkts. */
if (pcap_setfilter(pcap, &bpf_program) < 0) {
warnx("%s", pcap_geterr(pcap));
pcap_close(pcap);
return (NULL);
}
dcap = calloc(1, sizeof(struct dcap));
dcap->_pcap = pcap;
snprintf(dcap->intf_name, sizeof(dcap->intf_name), "%s", intf_name);
dcap->_callback = callback;
return (dcap);
}
struct dcap *
dcap_init_file(char *filename, char *filter, dcap_handler callback)
{
char pcap_errbuf[PCAP_ERRBUF_SIZE];
struct bpf_program bpf;
struct dcap *dcap = NULL;
pcap_t *pcap = NULL;
pcap = pcap_open_offline(filename, pcap_errbuf);
if (pcap == NULL) {
warnx("Could not open file %s (%s)\n", filename, pcap_errbuf);
return (NULL);
}
if (pcap_compile(pcap, &bpf, filter, 1, 0) < 0) {
warnx("filter compile failed: %s\n", pcap_geterr(pcap));
pcap_close(pcap);
return (NULL);
}
if (pcap_setfilter(pcap, &bpf) < 0) {
warnx("Pcap setfilter failed: %s\n", pcap_geterr(pcap));
pcap_close(pcap);
return (NULL);
}
dcap = calloc(1, sizeof(struct dcap));
dcap->_pcap = pcap;
dcap->_callback = callback;
dcap->user = NULL;
return (dcap);
}
void
dcap_loop_all(struct dcap *dcap)
{
pcap_loop(dcap->_pcap, -1, dcap_pcap_cb, (u_char *)dcap);
}
void
dcap_close(struct dcap *dcap)
{
pcap_close(dcap->_pcap);
free(dcap);
}
struct dcap_stat *
dcap_get_stats(struct dcap *dcap)
{
static struct dcap_stat ds;
struct pcap_stat ps;
bzero(&ds, sizeof(ds));
ds.captured = dcap->pkts_captured;
/* pcap stats not valid for file. */
if (pcap_file(dcap->_pcap) == NULL) {
bzero(&ps, sizeof(ps));
if (pcap_stats(dcap->_pcap, &ps) < 0) {
warnx("pcap_stats: %s", pcap_geterr(dcap->_pcap));
} else {
ds.ps_valid = 1;
ds.ps_recv = ps.ps_recv;
ds.ps_drop = ps.ps_drop;
ds.ps_ifdrop = ps.ps_ifdrop;
}
}
return (&ds);
}
|
346197.c | /* Search a wide string for any of a set of wide characters.
Copyright (C) 2011-2012 Free Software Foundation, Inc.
Written by Bruno Haible <[email protected]>, 2011.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <config.h>
/* Specification. */
#include <wchar.h>
#include "wcspbrk-impl.h"
|
739139.c | /*
FreeRTOS V8.0.0 - Copyright (C) 2014 Real Time Engineers Ltd.
All rights reserved
VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
***************************************************************************
* *
* FreeRTOS provides completely free yet professionally developed, *
* robust, strictly quality controlled, supported, and cross *
* platform software that has become a de facto standard. *
* *
* Help yourself get started quickly and support the FreeRTOS *
* project by purchasing a FreeRTOS tutorial book, reference *
* manual, or both from: http://www.FreeRTOS.org/Documentation *
* *
* Thank you! *
* *
***************************************************************************
This file is part of the FreeRTOS distribution.
FreeRTOS is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License (version 2) as published by the
Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.
>>! NOTE: The modification to the GPL is included to allow you to distribute
>>! a combined work that includes FreeRTOS without being obliged to provide
>>! the source code for proprietary components outside of the FreeRTOS
>>! kernel.
FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. Full license text is available from the following
link: http://www.freertos.org/a00114.html
1 tab == 4 spaces!
***************************************************************************
* *
* Having a problem? Start by reading the FAQ "My application does *
* not run, what could be wrong?" *
* *
* http://www.FreeRTOS.org/FAQHelp.html *
* *
***************************************************************************
http://www.FreeRTOS.org - Documentation, books, training, latest versions,
license and Real Time Engineers Ltd. contact details.
http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
including FreeRTOS+Trace - an indispensable productivity tool, a DOS
compatible FAT file system, and our tiny thread aware UDP/IP stack.
http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High
Integrity Systems to sell under the OpenRTOS brand. Low cost OpenRTOS
licenses offer ticketed support, indemnification and middleware.
http://www.SafeRTOS.com - High Integrity Systems also provide a safety
engineered and independently SIL3 certified version for use in safety and
mission critical applications that require provable dependability.
1 tab == 4 spaces!
*/
/*
* This file implements the same demo and test as GenQTest.c, but uses the
* light weight API in place of the fully featured API.
*
* See the comments at the top of GenQTest.c for a description.
*/
#include <stdlib.h>
/* Scheduler include files. */
#include "FreeRTOS.h"
#include "task.h"
#include "queue.h"
#include "semphr.h"
/* Demo program include files. */
#include "AltQTest.h"
#define genqQUEUE_LENGTH ( 5 )
#define genqNO_BLOCK ( 0 )
#define genqMUTEX_LOW_PRIORITY ( tskIDLE_PRIORITY )
#define genqMUTEX_TEST_PRIORITY ( tskIDLE_PRIORITY + 1 )
#define genqMUTEX_MEDIUM_PRIORITY ( tskIDLE_PRIORITY + 2 )
#define genqMUTEX_HIGH_PRIORITY ( tskIDLE_PRIORITY + 3 )
/*-----------------------------------------------------------*/
/*
* Tests the behaviour of the xQueueAltSendToFront() and xQueueAltSendToBack()
* macros by using both to fill a queue, then reading from the queue to
* check the resultant queue order is as expected. Queue data is also
* peeked.
*/
static void prvSendFrontAndBackTest( void *pvParameters );
/*
* The following three tasks are used to demonstrate the mutex behaviour.
* Each task is given a different priority to demonstrate the priority
* inheritance mechanism.
*
* The low priority task obtains a mutex. After this a high priority task
* attempts to obtain the same mutex, causing its priority to be inherited
* by the low priority task. The task with the inherited high priority then
* resumes a medium priority task to ensure it is not blocked by the medium
* priority task while it holds the inherited high priority. Once the mutex
* is returned the task with the inherited priority returns to its original
* low priority, and is therefore immediately preempted by first the high
* priority task and then the medium prioroity task before it can continue.
*/
static void prvLowPriorityMutexTask( void *pvParameters );
static void prvMediumPriorityMutexTask( void *pvParameters );
static void prvHighPriorityMutexTask( void *pvParameters );
/*-----------------------------------------------------------*/
/* Flag that will be latched to pdTRUE should any unexpected behaviour be
detected in any of the tasks. */
static portBASE_TYPE xErrorDetected = pdFALSE;
/* Counters that are incremented on each cycle of a test. This is used to
detect a stalled task - a test that is no longer running. */
static volatile unsigned long ulLoopCounter = 0;
static volatile unsigned long ulLoopCounter2 = 0;
/* The variable that is guarded by the mutex in the mutex demo tasks. */
static volatile unsigned long ulGuardedVariable = 0;
/* Handles used in the mutext test to suspend and resume the high and medium
priority mutex test tasks. */
static TaskHandle_t xHighPriorityMutexTask, xMediumPriorityMutexTask;
/*-----------------------------------------------------------*/
void vStartAltGenericQueueTasks( unsigned portBASE_TYPE uxPriority )
{
QueueHandle_t xQueue;
SemaphoreHandle_t xMutex;
/* Create the queue that we are going to use for the
prvSendFrontAndBackTest demo. */
xQueue = xQueueCreate( genqQUEUE_LENGTH, sizeof( unsigned long ) );
/* vQueueAddToRegistry() adds the queue to the queue registry, if one is
in use. The queue registry is provided as a means for kernel aware
debuggers to locate queues and has no purpose if a kernel aware debugger
is not being used. The call to vQueueAddToRegistry() will be removed
by the pre-processor if configQUEUE_REGISTRY_SIZE is not defined or is
defined to be less than 1. */
vQueueAddToRegistry( xQueue, "Alt_Gen_Test_Queue" );
/* Create the demo task and pass it the queue just created. We are
passing the queue handle by value so it does not matter that it is
declared on the stack here. */
xTaskCreate( prvSendFrontAndBackTest, "FGenQ", configMINIMAL_STACK_SIZE, ( void * ) xQueue, uxPriority, NULL );
/* Create the mutex used by the prvMutexTest task. */
xMutex = xSemaphoreCreateMutex();
/* vQueueAddToRegistry() adds the mutex to the registry, if one is
in use. The registry is provided as a means for kernel aware
debuggers to locate mutex and has no purpose if a kernel aware debugger
is not being used. The call to vQueueAddToRegistry() will be removed
by the pre-processor if configQUEUE_REGISTRY_SIZE is not defined or is
defined to be less than 1. */
vQueueAddToRegistry( ( QueueHandle_t ) xMutex, "Alt_Q_Mutex" );
/* Create the mutex demo tasks and pass it the mutex just created. We are
passing the mutex handle by value so it does not matter that it is declared
on the stack here. */
xTaskCreate( prvLowPriorityMutexTask, "FMuLow", configMINIMAL_STACK_SIZE, ( void * ) xMutex, genqMUTEX_LOW_PRIORITY, NULL );
xTaskCreate( prvMediumPriorityMutexTask, "FMuMed", configMINIMAL_STACK_SIZE, NULL, genqMUTEX_MEDIUM_PRIORITY, &xMediumPriorityMutexTask );
xTaskCreate( prvHighPriorityMutexTask, "FMuHigh", configMINIMAL_STACK_SIZE, ( void * ) xMutex, genqMUTEX_HIGH_PRIORITY, &xHighPriorityMutexTask );
}
/*-----------------------------------------------------------*/
static void prvSendFrontAndBackTest( void *pvParameters )
{
unsigned long ulData, ulData2;
QueueHandle_t xQueue;
#ifdef USE_STDIO
void vPrintDisplayMessage( const char * const * ppcMessageToSend );
const char * const pcTaskStartMsg = "Alt queue SendToFront/SendToBack/Peek test started.\r\n";
/* Queue a message for printing to say the task has started. */
vPrintDisplayMessage( &pcTaskStartMsg );
#endif
xQueue = ( QueueHandle_t ) pvParameters;
for( ;; )
{
/* The queue is empty, so sending an item to the back of the queue
should have the same efect as sending it to the front of the queue.
First send to the front and check everything is as expected. */
xQueueAltSendToFront( xQueue, ( void * ) &ulLoopCounter, genqNO_BLOCK );
if( uxQueueMessagesWaiting( xQueue ) != 1 )
{
xErrorDetected = pdTRUE;
}
if( xQueueAltReceive( xQueue, ( void * ) &ulData, genqNO_BLOCK ) != pdPASS )
{
xErrorDetected = pdTRUE;
}
/* The data we sent to the queue should equal the data we just received
from the queue. */
if( ulLoopCounter != ulData )
{
xErrorDetected = pdTRUE;
}
/* Then do the same, sending the data to the back, checking everything
is as expected. */
if( uxQueueMessagesWaiting( xQueue ) != 0 )
{
xErrorDetected = pdTRUE;
}
xQueueAltSendToBack( xQueue, ( void * ) &ulLoopCounter, genqNO_BLOCK );
if( uxQueueMessagesWaiting( xQueue ) != 1 )
{
xErrorDetected = pdTRUE;
}
if( xQueueAltReceive( xQueue, ( void * ) &ulData, genqNO_BLOCK ) != pdPASS )
{
xErrorDetected = pdTRUE;
}
if( uxQueueMessagesWaiting( xQueue ) != 0 )
{
xErrorDetected = pdTRUE;
}
/* The data we sent to the queue should equal the data we just received
from the queue. */
if( ulLoopCounter != ulData )
{
xErrorDetected = pdTRUE;
}
#if configUSE_PREEMPTION == 0
taskYIELD();
#endif
/* Place 2, 3, 4 into the queue, adding items to the back of the queue. */
for( ulData = 2; ulData < 5; ulData++ )
{
xQueueAltSendToBack( xQueue, ( void * ) &ulData, genqNO_BLOCK );
}
/* Now the order in the queue should be 2, 3, 4, with 2 being the first
thing to be read out. Now add 1 then 0 to the front of the queue. */
if( uxQueueMessagesWaiting( xQueue ) != 3 )
{
xErrorDetected = pdTRUE;
}
ulData = 1;
xQueueAltSendToFront( xQueue, ( void * ) &ulData, genqNO_BLOCK );
ulData = 0;
xQueueAltSendToFront( xQueue, ( void * ) &ulData, genqNO_BLOCK );
/* Now the queue should be full, and when we read the data out we
should receive 0, 1, 2, 3, 4. */
if( uxQueueMessagesWaiting( xQueue ) != 5 )
{
xErrorDetected = pdTRUE;
}
if( xQueueAltSendToFront( xQueue, ( void * ) &ulData, genqNO_BLOCK ) != errQUEUE_FULL )
{
xErrorDetected = pdTRUE;
}
if( xQueueAltSendToBack( xQueue, ( void * ) &ulData, genqNO_BLOCK ) != errQUEUE_FULL )
{
xErrorDetected = pdTRUE;
}
#if configUSE_PREEMPTION == 0
taskYIELD();
#endif
/* Check the data we read out is in the expected order. */
for( ulData = 0; ulData < genqQUEUE_LENGTH; ulData++ )
{
/* Try peeking the data first. */
if( xQueueAltPeek( xQueue, &ulData2, genqNO_BLOCK ) != pdPASS )
{
xErrorDetected = pdTRUE;
}
if( ulData != ulData2 )
{
xErrorDetected = pdTRUE;
}
/* Now try receiving the data for real. The value should be the
same. Clobber the value first so we know we really received it. */
ulData2 = ~ulData2;
if( xQueueAltReceive( xQueue, &ulData2, genqNO_BLOCK ) != pdPASS )
{
xErrorDetected = pdTRUE;
}
if( ulData != ulData2 )
{
xErrorDetected = pdTRUE;
}
}
/* The queue should now be empty again. */
if( uxQueueMessagesWaiting( xQueue ) != 0 )
{
xErrorDetected = pdTRUE;
}
#if configUSE_PREEMPTION == 0
taskYIELD();
#endif
/* Our queue is empty once more, add 10, 11 to the back. */
ulData = 10;
if( xQueueAltSendToBack( xQueue, &ulData, genqNO_BLOCK ) != pdPASS )
{
xErrorDetected = pdTRUE;
}
ulData = 11;
if( xQueueAltSendToBack( xQueue, &ulData, genqNO_BLOCK ) != pdPASS )
{
xErrorDetected = pdTRUE;
}
if( uxQueueMessagesWaiting( xQueue ) != 2 )
{
xErrorDetected = pdTRUE;
}
/* Now we should have 10, 11 in the queue. Add 7, 8, 9 to the
front. */
for( ulData = 9; ulData >= 7; ulData-- )
{
if( xQueueAltSendToFront( xQueue, ( void * ) &ulData, genqNO_BLOCK ) != pdPASS )
{
xErrorDetected = pdTRUE;
}
}
/* Now check that the queue is full, and that receiving data provides
the expected sequence of 7, 8, 9, 10, 11. */
if( uxQueueMessagesWaiting( xQueue ) != 5 )
{
xErrorDetected = pdTRUE;
}
if( xQueueAltSendToFront( xQueue, ( void * ) &ulData, genqNO_BLOCK ) != errQUEUE_FULL )
{
xErrorDetected = pdTRUE;
}
if( xQueueAltSendToBack( xQueue, ( void * ) &ulData, genqNO_BLOCK ) != errQUEUE_FULL )
{
xErrorDetected = pdTRUE;
}
#if configUSE_PREEMPTION == 0
taskYIELD();
#endif
/* Check the data we read out is in the expected order. */
for( ulData = 7; ulData < ( 7 + genqQUEUE_LENGTH ); ulData++ )
{
if( xQueueAltReceive( xQueue, &ulData2, genqNO_BLOCK ) != pdPASS )
{
xErrorDetected = pdTRUE;
}
if( ulData != ulData2 )
{
xErrorDetected = pdTRUE;
}
}
if( uxQueueMessagesWaiting( xQueue ) != 0 )
{
xErrorDetected = pdTRUE;
}
ulLoopCounter++;
}
}
/*-----------------------------------------------------------*/
static void prvLowPriorityMutexTask( void *pvParameters )
{
SemaphoreHandle_t xMutex = ( SemaphoreHandle_t ) pvParameters;
#ifdef USE_STDIO
void vPrintDisplayMessage( const char * const * ppcMessageToSend );
const char * const pcTaskStartMsg = "Fast mutex with priority inheritance test started.\r\n";
/* Queue a message for printing to say the task has started. */
vPrintDisplayMessage( &pcTaskStartMsg );
#endif
( void ) pvParameters;
for( ;; )
{
/* Take the mutex. It should be available now. */
if( xSemaphoreAltTake( xMutex, genqNO_BLOCK ) != pdPASS )
{
xErrorDetected = pdTRUE;
}
/* Set our guarded variable to a known start value. */
ulGuardedVariable = 0;
/* Our priority should be as per that assigned when the task was
created. */
if( uxTaskPriorityGet( NULL ) != genqMUTEX_LOW_PRIORITY )
{
xErrorDetected = pdTRUE;
}
/* Now unsuspend the high priority task. This will attempt to take the
mutex, and block when it finds it cannot obtain it. */
vTaskResume( xHighPriorityMutexTask );
/* We should now have inherited the prioritoy of the high priority task,
as by now it will have attempted to get the mutex. */
if( uxTaskPriorityGet( NULL ) != genqMUTEX_HIGH_PRIORITY )
{
xErrorDetected = pdTRUE;
}
/* We can attempt to set our priority to the test priority - between the
idle priority and the medium/high test priorities, but our actual
prioroity should remain at the high priority. */
vTaskPrioritySet( NULL, genqMUTEX_TEST_PRIORITY );
if( uxTaskPriorityGet( NULL ) != genqMUTEX_HIGH_PRIORITY )
{
xErrorDetected = pdTRUE;
}
/* Now unsuspend the medium priority task. This should not run as our
inherited priority is above that of the medium priority task. */
vTaskResume( xMediumPriorityMutexTask );
/* If the did run then it will have incremented our guarded variable. */
if( ulGuardedVariable != 0 )
{
xErrorDetected = pdTRUE;
}
/* When we give back the semaphore our priority should be disinherited
back to the priority to which we attempted to set ourselves. This means
that when the high priority task next blocks, the medium priority task
should execute and increment the guarded variable. When we next run
both the high and medium priority tasks will have been suspended again. */
if( xSemaphoreAltGive( xMutex ) != pdPASS )
{
xErrorDetected = pdTRUE;
}
/* Check that the guarded variable did indeed increment... */
if( ulGuardedVariable != 1 )
{
xErrorDetected = pdTRUE;
}
/* ... and that our priority has been disinherited to
genqMUTEX_TEST_PRIORITY. */
if( uxTaskPriorityGet( NULL ) != genqMUTEX_TEST_PRIORITY )
{
xErrorDetected = pdTRUE;
}
/* Set our priority back to our original priority ready for the next
loop around this test. */
vTaskPrioritySet( NULL, genqMUTEX_LOW_PRIORITY );
/* Just to show we are still running. */
ulLoopCounter2++;
#if configUSE_PREEMPTION == 0
taskYIELD();
#endif
}
}
/*-----------------------------------------------------------*/
static void prvMediumPriorityMutexTask( void *pvParameters )
{
( void ) pvParameters;
for( ;; )
{
/* The medium priority task starts by suspending itself. The low
priority task will unsuspend this task when required. */
vTaskSuspend( NULL );
/* When this task unsuspends all it does is increment the guarded
variable, this is so the low priority task knows that it has
executed. */
ulGuardedVariable++;
}
}
/*-----------------------------------------------------------*/
static void prvHighPriorityMutexTask( void *pvParameters )
{
SemaphoreHandle_t xMutex = ( SemaphoreHandle_t ) pvParameters;
( void ) pvParameters;
for( ;; )
{
/* The high priority task starts by suspending itself. The low
priority task will unsuspend this task when required. */
vTaskSuspend( NULL );
/* When this task unsuspends all it does is attempt to obtain
the mutex. It should find the mutex is not available so a
block time is specified. */
if( xSemaphoreAltTake( xMutex, portMAX_DELAY ) != pdPASS )
{
xErrorDetected = pdTRUE;
}
/* When we eventually obtain the mutex we just give it back then
return to suspend ready for the next test. */
if( xSemaphoreAltGive( xMutex ) != pdPASS )
{
xErrorDetected = pdTRUE;
}
}
}
/*-----------------------------------------------------------*/
/* This is called to check that all the created tasks are still running. */
portBASE_TYPE xAreAltGenericQueueTasksStillRunning( void )
{
static unsigned long ulLastLoopCounter = 0, ulLastLoopCounter2 = 0;
/* If the demo task is still running then we expect the loopcounters to
have incremented since this function was last called. */
if( ulLastLoopCounter == ulLoopCounter )
{
xErrorDetected = pdTRUE;
}
if( ulLastLoopCounter2 == ulLoopCounter2 )
{
xErrorDetected = pdTRUE;
}
ulLastLoopCounter = ulLoopCounter;
ulLastLoopCounter2 = ulLoopCounter2;
/* Errors detected in the task itself will have latched xErrorDetected
to true. */
return !xErrorDetected;
}
|
251326.c | /*
* vim:ts=4:sw=4:expandtab
*
* i3 - an improved dynamic tiling window manager
* © 2009 Michael Stapelberg and contributors (see also: LICENSE)
*
* render.c: Renders (determines position/sizes) the layout tree, updating the
* various rects. Needs to be pushed to X11 (see x.c) to be visible.
*
*/
#include "all.h"
/* Forward declarations */
static int *precalculate_sizes(Con *con, render_params *p);
static void render_root(Con *con, Con *fullscreen);
static void render_output(Con *con);
static void render_con_split(Con *con, Con *child, render_params *p, int i);
static void render_con_stacked(Con *con, Con *child, render_params *p, int i);
static void render_con_tabbed(Con *con, Con *child, render_params *p, int i);
static void render_con_dockarea(Con *con, Con *child, render_params *p);
/*
* Returns the height for the decorations
*/
int render_deco_height(void) {
int deco_height = config.font.height + 4;
if (config.font.height & 0x01)
++deco_height;
return deco_height;
}
/*
* "Renders" the given container (and its children), meaning that all rects are
* updated correctly. Note that this function does not call any xcb_*
* functions, so the changes are completely done in memory only (and
* side-effect free). As soon as you call x_push_changes(), the changes will be
* updated in X11.
*
*/
void render_con(Con *con) {
render_params params = {
.rect = con->rect,
.x = con->rect.x,
.y = con->rect.y,
.children = con_num_children(con)};
DLOG("Rendering node %p / %s / layout %d / children %d\n", con, con->name,
con->layout, params.children);
int i = 0;
con->mapped = true;
/* if this container contains a window, set the coordinates */
if (con->window) {
/* depending on the border style, the rect of the child window
* needs to be smaller */
Rect *inset = &(con->window_rect);
*inset = (Rect){0, 0, con->rect.width, con->rect.height};
if (con->fullscreen_mode == CF_NONE) {
*inset = rect_add(*inset, con_border_style_rect(con));
}
/* Obey x11 border */
inset->width -= (2 * con->border_width);
inset->height -= (2 * con->border_width);
/* NB: We used to respect resize increment size hints for tiling
* windows up until commit 0db93d9 here. However, since all terminal
* emulators cope with ignoring the size hints in a better way than we
* can (by providing their fake-transparency or background color), this
* code was removed. See also https://bugs.i3wm.org/540 */
DLOG("child will be at %dx%d with size %dx%d\n", inset->x, inset->y, inset->width, inset->height);
}
/* Check for fullscreen nodes */
Con *fullscreen = NULL;
if (con->type != CT_OUTPUT) {
fullscreen = con_get_fullscreen_con(con, (con->type == CT_ROOT ? CF_GLOBAL : CF_OUTPUT));
}
if (fullscreen) {
fullscreen->rect = params.rect;
x_raise_con(fullscreen);
render_con(fullscreen);
/* Fullscreen containers are either global (underneath the CT_ROOT
* container) or per-output (underneath the CT_CONTENT container). For
* global fullscreen containers, we cannot abort rendering here yet,
* because the floating windows (with popup_during_fullscreen smart)
* have not yet been rendered (see the CT_ROOT code path below). See
* also https://bugs.i3wm.org/1393 */
if (con->type != CT_ROOT) {
return;
}
}
/* find the height for the decorations */
params.deco_height = render_deco_height();
/* precalculate the sizes to be able to correct rounding errors */
params.sizes = precalculate_sizes(con, ¶ms);
if (con->layout == L_OUTPUT) {
/* Skip i3-internal outputs */
if (con_is_internal(con))
goto free_params;
render_output(con);
} else if (con->type == CT_ROOT) {
render_root(con, fullscreen);
} else {
Con *child;
TAILQ_FOREACH(child, &(con->nodes_head), nodes) {
assert(params.children > 0);
if (con->layout == L_SPLITH || con->layout == L_SPLITV) {
render_con_split(con, child, ¶ms, i);
} else if (con->layout == L_STACKED) {
render_con_stacked(con, child, ¶ms, i);
} else if (con->layout == L_TABBED) {
render_con_tabbed(con, child, ¶ms, i);
} else if (con->layout == L_DOCKAREA) {
render_con_dockarea(con, child, ¶ms);
}
DLOG("child at (%d, %d) with (%d x %d)\n",
child->rect.x, child->rect.y, child->rect.width, child->rect.height);
x_raise_con(child);
render_con(child);
i++;
}
/* in a stacking or tabbed container, we ensure the focused client is raised */
if (con->layout == L_STACKED || con->layout == L_TABBED) {
TAILQ_FOREACH_REVERSE(child, &(con->focus_head), focus_head, focused)
x_raise_con(child);
if ((child = TAILQ_FIRST(&(con->focus_head)))) {
/* By rendering the stacked container again, we handle the case
* that we have a non-leaf-container inside the stack. In that
* case, the children of the non-leaf-container need to be
* raised as well. */
render_con(child);
}
if (params.children != 1)
/* Raise the stack con itself. This will put the stack
* decoration on top of every stack window. That way, when a
* new window is opened in the stack, the old window will not
* obscure part of the decoration (it’s unmapped afterwards). */
x_raise_con(con);
}
}
free_params:
FREE(params.sizes);
}
static int *precalculate_sizes(Con *con, render_params *p) {
if ((con->layout != L_SPLITH && con->layout != L_SPLITV) || p->children <= 0) {
return NULL;
}
int *sizes = smalloc(p->children * sizeof(int));
assert(!TAILQ_EMPTY(&con->nodes_head));
Con *child;
int i = 0, assigned = 0;
int total = con_rect_size_in_orientation(con);
TAILQ_FOREACH(child, &(con->nodes_head), nodes) {
double percentage = child->percent > 0.0 ? child->percent : 1.0 / p->children;
assigned += sizes[i++] = lround(percentage * total);
}
assert(assigned == total ||
(assigned > total && assigned - total <= p->children * 2) ||
(assigned < total && total - assigned <= p->children * 2));
int signal = assigned < total ? 1 : -1;
while (assigned != total) {
for (i = 0; i < p->children && assigned != total; ++i) {
sizes[i] += signal;
assigned += signal;
}
}
return sizes;
}
static void render_root(Con *con, Con *fullscreen) {
Con *output;
if (!fullscreen) {
TAILQ_FOREACH(output, &(con->nodes_head), nodes) {
render_con(output);
}
}
/* We need to render floating windows after rendering all outputs’
* tiling windows because they need to be on top of *every* output at
* all times. This is important when the user places floating
* windows/containers so that they overlap on another output. */
DLOG("Rendering floating windows:\n");
TAILQ_FOREACH(output, &(con->nodes_head), nodes) {
if (con_is_internal(output))
continue;
/* Get the active workspace of that output */
Con *content = output_get_content(output);
if (!content || TAILQ_EMPTY(&(content->focus_head))) {
DLOG("Skipping this output because it is currently being destroyed.\n");
continue;
}
Con *workspace = TAILQ_FIRST(&(content->focus_head));
Con *fullscreen = con_get_fullscreen_covering_ws(workspace);
Con *child;
TAILQ_FOREACH(child, &(workspace->floating_head), floating_windows) {
if (fullscreen != NULL) {
/* Don’t render floating windows when there is a fullscreen
* window on that workspace. Necessary to make floating
* fullscreen work correctly (ticket #564). Exception to the
* above rule: smart popup_during_fullscreen handling (popups
* belonging to the fullscreen app will be rendered). */
if (config.popup_during_fullscreen != PDF_SMART || fullscreen->window == NULL) {
continue;
}
Con *floating_child = con_descend_focused(child);
Con *transient_con = floating_child;
bool is_transient_for = false;
while (transient_con != NULL &&
transient_con->window != NULL &&
transient_con->window->transient_for != XCB_NONE) {
DLOG("transient_con = 0x%08x, transient_con->window->transient_for = 0x%08x, fullscreen_id = 0x%08x\n",
transient_con->window->id, transient_con->window->transient_for, fullscreen->window->id);
if (transient_con->window->transient_for == fullscreen->window->id) {
is_transient_for = true;
break;
}
Con *next_transient = con_by_window_id(transient_con->window->transient_for);
if (next_transient == NULL)
break;
/* Some clients (e.g. x11-ssh-askpass) actually set
* WM_TRANSIENT_FOR to their own window id, so break instead of
* looping endlessly. */
if (transient_con == next_transient)
break;
transient_con = next_transient;
}
if (!is_transient_for)
continue;
else {
DLOG("Rendering floating child even though in fullscreen mode: "
"floating->transient_for (0x%08x) --> fullscreen->id (0x%08x)\n",
floating_child->window->transient_for, fullscreen->window->id);
}
}
DLOG("floating child at (%d,%d) with %d x %d\n",
child->rect.x, child->rect.y, child->rect.width, child->rect.height);
x_raise_con(child);
render_con(child);
}
}
}
/*
* Renders a container with layout L_OUTPUT. In this layout, all CT_DOCKAREAs
* get the height of their content and the remaining CT_CON gets the rest.
*
*/
static void render_output(Con *con) {
Con *child, *dockchild;
int x = con->rect.x;
int y = con->rect.y;
int height = con->rect.height;
/* Find the content container and ensure that there is exactly one. Also
* check for any non-CT_DOCKAREA clients. */
Con *content = NULL;
TAILQ_FOREACH(child, &(con->nodes_head), nodes) {
if (child->type == CT_CON) {
if (content != NULL) {
DLOG("More than one CT_CON on output container\n");
assert(false);
}
content = child;
} else if (child->type != CT_DOCKAREA) {
DLOG("Child %p of type %d is inside the OUTPUT con\n", child, child->type);
assert(false);
}
}
if (content == NULL) {
DLOG("Skipping this output because it is currently being destroyed.\n");
return;
}
/* We need to find out if there is a fullscreen con on the current workspace
* and take the short-cut to render it directly (the user does not want to
* see the dockareas in that case) */
Con *ws = con_get_fullscreen_con(content, CF_OUTPUT);
if (!ws) {
DLOG("Skipping this output because it is currently being destroyed.\n");
return;
}
Con *fullscreen = con_get_fullscreen_con(ws, CF_OUTPUT);
if (fullscreen) {
fullscreen->rect = con->rect;
x_raise_con(fullscreen);
render_con(fullscreen);
return;
}
/* First pass: determine the height of all CT_DOCKAREAs (the sum of their
* children) and figure out how many pixels we have left for the rest */
TAILQ_FOREACH(child, &(con->nodes_head), nodes) {
if (child->type != CT_DOCKAREA)
continue;
child->rect.height = 0;
TAILQ_FOREACH(dockchild, &(child->nodes_head), nodes)
child->rect.height += dockchild->geometry.height;
height -= child->rect.height;
}
/* Second pass: Set the widths/heights */
TAILQ_FOREACH(child, &(con->nodes_head), nodes) {
if (child->type == CT_CON) {
child->rect.x = x;
child->rect.y = y;
child->rect.width = con->rect.width;
child->rect.height = height;
}
child->rect.x = x;
child->rect.y = y;
child->rect.width = con->rect.width;
child->deco_rect.x = 0;
child->deco_rect.y = 0;
child->deco_rect.width = 0;
child->deco_rect.height = 0;
y += child->rect.height;
DLOG("child at (%d, %d) with (%d x %d)\n",
child->rect.x, child->rect.y, child->rect.width, child->rect.height);
x_raise_con(child);
render_con(child);
}
}
static void render_con_split(Con *con, Con *child, render_params *p, int i) {
assert(con->layout == L_SPLITH || con->layout == L_SPLITV);
if (con->layout == L_SPLITH) {
child->rect.x = p->x;
child->rect.y = p->y;
child->rect.width = p->sizes[i];
child->rect.height = p->rect.height;
p->x += child->rect.width;
} else {
child->rect.x = p->x;
child->rect.y = p->y;
child->rect.width = p->rect.width;
child->rect.height = p->sizes[i];
p->y += child->rect.height;
}
/* first we have the decoration, if this is a leaf node */
if (con_is_leaf(child)) {
if (child->border_style == BS_NORMAL) {
/* TODO: make a function for relative coords? */
child->deco_rect.x = child->rect.x - con->rect.x;
child->deco_rect.y = child->rect.y - con->rect.y;
child->rect.y += p->deco_height;
child->rect.height -= p->deco_height;
child->deco_rect.width = child->rect.width;
child->deco_rect.height = p->deco_height;
} else {
child->deco_rect.x = 0;
child->deco_rect.y = 0;
child->deco_rect.width = 0;
child->deco_rect.height = 0;
}
}
}
static void render_con_stacked(Con *con, Con *child, render_params *p, int i) {
assert(con->layout == L_STACKED);
child->rect.x = p->x;
child->rect.y = p->y;
child->rect.width = p->rect.width;
child->rect.height = p->rect.height;
child->deco_rect.x = p->x - con->rect.x;
child->deco_rect.y = p->y - con->rect.y + (i * p->deco_height);
child->deco_rect.width = child->rect.width;
child->deco_rect.height = p->deco_height;
if (p->children > 1 || (child->border_style != BS_PIXEL && child->border_style != BS_NONE)) {
child->rect.y += (p->deco_height * p->children);
child->rect.height -= (p->deco_height * p->children);
}
}
static void render_con_tabbed(Con *con, Con *child, render_params *p, int i) {
assert(con->layout == L_TABBED);
child->rect.x = p->x;
child->rect.y = p->y;
child->rect.width = p->rect.width;
child->rect.height = p->rect.height;
child->deco_rect.width = floor((float)child->rect.width / p->children);
child->deco_rect.x = p->x - con->rect.x + i * child->deco_rect.width;
child->deco_rect.y = p->y - con->rect.y;
/* Since the tab width may be something like 31,6 px per tab, we
* let the last tab have all the extra space (0,6 * children). */
if (i == (p->children - 1)) {
child->deco_rect.width += (child->rect.width - (child->deco_rect.x + child->deco_rect.width));
}
if (p->children > 1 || (child->border_style != BS_PIXEL && child->border_style != BS_NONE)) {
child->rect.y += p->deco_height;
child->rect.height -= p->deco_height;
child->deco_rect.height = p->deco_height;
} else {
child->deco_rect.height = (child->border_style == BS_PIXEL ? 1 : 0);
}
}
static void render_con_dockarea(Con *con, Con *child, render_params *p) {
assert(con->layout == L_DOCKAREA);
child->rect.x = p->x;
child->rect.y = p->y;
child->rect.width = p->rect.width;
child->rect.height = child->geometry.height;
child->deco_rect.x = 0;
child->deco_rect.y = 0;
child->deco_rect.width = 0;
child->deco_rect.height = 0;
p->y += child->rect.height;
}
|
864817.c | /* A Bison parser, made by GNU Bison 3.5.1. */
/* Bison implementation for Yacc-like parsers in C
Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2020 Free Software Foundation,
Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
under terms of your choice, so long as that work isn't itself a
parser generator using the skeleton or a modified version thereof
as a parser skeleton. Alternatively, if you modify or redistribute
the parser skeleton itself, you may (at your option) remove this
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
/* C LALR(1) parser skeleton written by Richard Stallman, by
simplifying the original so-called "semantic" parser. */
/* All symbols defined below should begin with yy or YY, to avoid
infringing on user name space. This should be done even for local
variables, as they might otherwise be expanded by user macros.
There are some unavoidable exceptions within include files to
define necessary library symbols; they are noted "INFRINGES ON
USER NAME SPACE" below. */
/* Undocumented macros, especially those whose name start with YY_,
are private implementation details. Do not rely on them. */
/* Identify Bison output. */
#define YYBISON 1
/* Bison version. */
#define YYBISON_VERSION "3.5.1"
/* Skeleton name. */
#define YYSKELETON_NAME "yacc.c"
/* Pure parsers. */
#define YYPURE 1
/* Push parsers. */
#define YYPUSH 0
/* Pull parsers. */
#define YYPULL 1
/* Substitute the variable and function names. */
#define yyparse pj_wkt1_parse
#define yylex pj_wkt1_lex
#define yyerror pj_wkt1_error
#define yydebug pj_wkt1_debug
#define yynerrs pj_wkt1_nerrs
/* First part of user prologue. */
/******************************************************************************
* Project: PROJ
* Purpose: WKT1 parser grammar
* Author: Even Rouault, <even.rouault at spatialys.com>
*
******************************************************************************
* Copyright (c) 2013-2018 Even Rouault, <even.rouault at spatialys.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
****************************************************************************/
#include "wkt1_parser.h"
# ifndef YY_CAST
# ifdef __cplusplus
# define YY_CAST(Type, Val) static_cast<Type> (Val)
# define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast<Type> (Val)
# else
# define YY_CAST(Type, Val) ((Type) (Val))
# define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val))
# endif
# endif
# ifndef YY_NULLPTR
# if defined __cplusplus
# if 201103L <= __cplusplus
# define YY_NULLPTR nullptr
# else
# define YY_NULLPTR 0
# endif
# else
# define YY_NULLPTR ((void*)0)
# endif
# endif
/* Enabling verbose error messages. */
#ifdef YYERROR_VERBOSE
# undef YYERROR_VERBOSE
# define YYERROR_VERBOSE 1
#else
# define YYERROR_VERBOSE 1
#endif
/* Use api.header.include to #include this header
instead of duplicating it here. */
#ifndef YY_PJ_WKT1_SRC_WKT1_GENERATED_PARSER_H_INCLUDED
# define YY_PJ_WKT1_SRC_WKT1_GENERATED_PARSER_H_INCLUDED
/* Debug traces. */
#ifndef YYDEBUG
# define YYDEBUG 0
#endif
#if YYDEBUG
extern int pj_wkt1_debug;
#endif
/* Token type. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
enum yytokentype
{
END = 0,
T_PARAM_MT = 258,
T_CONCAT_MT = 259,
T_INVERSE_MT = 260,
T_PASSTHROUGH_MT = 261,
T_PROJCS = 262,
T_PROJECTION = 263,
T_GEOGCS = 264,
T_DATUM = 265,
T_SPHEROID = 266,
T_PRIMEM = 267,
T_UNIT = 268,
T_GEOCCS = 269,
T_AUTHORITY = 270,
T_VERT_CS = 271,
T_VERTCS = 272,
T_VERT_DATUM = 273,
T_VDATUM = 274,
T_COMPD_CS = 275,
T_AXIS = 276,
T_TOWGS84 = 277,
T_FITTED_CS = 278,
T_LOCAL_CS = 279,
T_LOCAL_DATUM = 280,
T_PARAMETER = 281,
T_EXTENSION = 282,
T_STRING = 283,
T_NUMBER = 284,
T_IDENTIFIER = 285
};
#endif
/* Value type. */
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef int YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
# define YYSTYPE_IS_DECLARED 1
#endif
int pj_wkt1_parse (pj_wkt1_parse_context *context);
#endif /* !YY_PJ_WKT1_SRC_WKT1_GENERATED_PARSER_H_INCLUDED */
#ifdef short
# undef short
#endif
/* On compilers that do not define __PTRDIFF_MAX__ etc., make sure
<limits.h> and (if available) <stdint.h> are included
so that the code can choose integer types of a good width. */
#ifndef __PTRDIFF_MAX__
# include <limits.h> /* INFRINGES ON USER NAME SPACE */
# if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
# include <stdint.h> /* INFRINGES ON USER NAME SPACE */
# define YY_STDINT_H
# endif
#endif
/* Narrow types that promote to a signed type and that can represent a
signed or unsigned integer of at least N bits. In tables they can
save space and decrease cache pressure. Promoting to a signed type
helps avoid bugs in integer arithmetic. */
#ifdef __INT_LEAST8_MAX__
typedef __INT_LEAST8_TYPE__ yytype_int8;
#elif defined YY_STDINT_H
typedef int_least8_t yytype_int8;
#else
typedef signed char yytype_int8;
#endif
#ifdef __INT_LEAST16_MAX__
typedef __INT_LEAST16_TYPE__ yytype_int16;
#elif defined YY_STDINT_H
typedef int_least16_t yytype_int16;
#else
typedef short yytype_int16;
#endif
#if defined __UINT_LEAST8_MAX__ && __UINT_LEAST8_MAX__ <= __INT_MAX__
typedef __UINT_LEAST8_TYPE__ yytype_uint8;
#elif (!defined __UINT_LEAST8_MAX__ && defined YY_STDINT_H \
&& UINT_LEAST8_MAX <= INT_MAX)
typedef uint_least8_t yytype_uint8;
#elif !defined __UINT_LEAST8_MAX__ && UCHAR_MAX <= INT_MAX
typedef unsigned char yytype_uint8;
#else
typedef short yytype_uint8;
#endif
#if defined __UINT_LEAST16_MAX__ && __UINT_LEAST16_MAX__ <= __INT_MAX__
typedef __UINT_LEAST16_TYPE__ yytype_uint16;
#elif (!defined __UINT_LEAST16_MAX__ && defined YY_STDINT_H \
&& UINT_LEAST16_MAX <= INT_MAX)
typedef uint_least16_t yytype_uint16;
#elif !defined __UINT_LEAST16_MAX__ && USHRT_MAX <= INT_MAX
typedef unsigned short yytype_uint16;
#else
typedef int yytype_uint16;
#endif
#ifndef YYPTRDIFF_T
# if defined __PTRDIFF_TYPE__ && defined __PTRDIFF_MAX__
# define YYPTRDIFF_T __PTRDIFF_TYPE__
# define YYPTRDIFF_MAXIMUM __PTRDIFF_MAX__
# elif defined PTRDIFF_MAX
# ifndef ptrdiff_t
# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
# endif
# define YYPTRDIFF_T ptrdiff_t
# define YYPTRDIFF_MAXIMUM PTRDIFF_MAX
# else
# define YYPTRDIFF_T long
# define YYPTRDIFF_MAXIMUM LONG_MAX
# endif
#endif
#ifndef YYSIZE_T
# ifdef __SIZE_TYPE__
# define YYSIZE_T __SIZE_TYPE__
# elif defined size_t
# define YYSIZE_T size_t
# elif defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
# define YYSIZE_T size_t
# else
# define YYSIZE_T unsigned
# endif
#endif
#define YYSIZE_MAXIMUM \
YY_CAST (YYPTRDIFF_T, \
(YYPTRDIFF_MAXIMUM < YY_CAST (YYSIZE_T, -1) \
? YYPTRDIFF_MAXIMUM \
: YY_CAST (YYSIZE_T, -1)))
#define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X))
/* Stored state numbers (used for stacks). */
typedef yytype_int16 yy_state_t;
/* State numbers in computations. */
typedef int yy_state_fast_t;
#ifndef YY_
# if defined YYENABLE_NLS && YYENABLE_NLS
# if ENABLE_NLS
# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
# define YY_(Msgid) dgettext ("bison-runtime", Msgid)
# endif
# endif
# ifndef YY_
# define YY_(Msgid) Msgid
# endif
#endif
#ifndef YY_ATTRIBUTE_PURE
# if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__)
# define YY_ATTRIBUTE_PURE __attribute__ ((__pure__))
# else
# define YY_ATTRIBUTE_PURE
# endif
#endif
#ifndef YY_ATTRIBUTE_UNUSED
# if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__)
# define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__))
# else
# define YY_ATTRIBUTE_UNUSED
# endif
#endif
/* Suppress unused-variable warnings by "using" E. */
#if ! defined lint || defined __GNUC__
# define YYUSE(E) ((void) (E))
#else
# define YYUSE(E) /* empty */
#endif
#if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
/* Suppress an incorrect diagnostic about yylval being uninitialized. */
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
_Pragma ("GCC diagnostic push") \
_Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \
_Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
# define YY_IGNORE_MAYBE_UNINITIALIZED_END \
_Pragma ("GCC diagnostic pop")
#else
# define YY_INITIAL_VALUE(Value) Value
#endif
#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
# define YY_IGNORE_MAYBE_UNINITIALIZED_END
#endif
#ifndef YY_INITIAL_VALUE
# define YY_INITIAL_VALUE(Value) /* Nothing. */
#endif
#if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__
# define YY_IGNORE_USELESS_CAST_BEGIN \
_Pragma ("GCC diagnostic push") \
_Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"")
# define YY_IGNORE_USELESS_CAST_END \
_Pragma ("GCC diagnostic pop")
#endif
#ifndef YY_IGNORE_USELESS_CAST_BEGIN
# define YY_IGNORE_USELESS_CAST_BEGIN
# define YY_IGNORE_USELESS_CAST_END
#endif
#define YY_ASSERT(E) ((void) (0 && (E)))
#if ! defined yyoverflow || YYERROR_VERBOSE
/* The parser invokes alloca or malloc; define the necessary symbols. */
# ifdef YYSTACK_USE_ALLOCA
# if YYSTACK_USE_ALLOCA
# ifdef __GNUC__
# define YYSTACK_ALLOC __builtin_alloca
# elif defined __BUILTIN_VA_ARG_INCR
# include <alloca.h> /* INFRINGES ON USER NAME SPACE */
# elif defined _AIX
# define YYSTACK_ALLOC __alloca
# elif defined _MSC_VER
# include <malloc.h> /* INFRINGES ON USER NAME SPACE */
# define alloca _alloca
# else
# define YYSTACK_ALLOC alloca
# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
/* Use EXIT_SUCCESS as a witness for stdlib.h. */
# ifndef EXIT_SUCCESS
# define EXIT_SUCCESS 0
# endif
# endif
# endif
# endif
# endif
# ifdef YYSTACK_ALLOC
/* Pacify GCC's 'empty if-body' warning. */
# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
# ifndef YYSTACK_ALLOC_MAXIMUM
/* The OS might guarantee only one guard page at the bottom of the stack,
and a page size can be as small as 4096 bytes. So we cannot safely
invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
to allow for a few compiler-allocated temporary stack slots. */
# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
# endif
# else
# define YYSTACK_ALLOC YYMALLOC
# define YYSTACK_FREE YYFREE
# ifndef YYSTACK_ALLOC_MAXIMUM
# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
# endif
# if (defined __cplusplus && ! defined EXIT_SUCCESS \
&& ! ((defined YYMALLOC || defined malloc) \
&& (defined YYFREE || defined free)))
# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
# ifndef EXIT_SUCCESS
# define EXIT_SUCCESS 0
# endif
# endif
# ifndef YYMALLOC
# define YYMALLOC malloc
# if ! defined malloc && ! defined EXIT_SUCCESS
void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
# endif
# endif
# ifndef YYFREE
# define YYFREE free
# if ! defined free && ! defined EXIT_SUCCESS
void free (void *); /* INFRINGES ON USER NAME SPACE */
# endif
# endif
# endif
#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
#if (! defined yyoverflow \
&& (! defined __cplusplus \
|| (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
/* A type that is properly aligned for any stack member. */
union yyalloc
{
yy_state_t yyss_alloc;
YYSTYPE yyvs_alloc;
};
/* The size of the maximum gap between one aligned stack and the next. */
# define YYSTACK_GAP_MAXIMUM (YYSIZEOF (union yyalloc) - 1)
/* The size of an array large to enough to hold all stacks, each with
N elements. */
# define YYSTACK_BYTES(N) \
((N) * (YYSIZEOF (yy_state_t) + YYSIZEOF (YYSTYPE)) \
+ YYSTACK_GAP_MAXIMUM)
# define YYCOPY_NEEDED 1
/* Relocate STACK from its old location to the new one. The
local variables YYSIZE and YYSTACKSIZE give the old and new number of
elements in the stack, and YYPTR gives the new location of the
stack. Advance YYPTR to a properly aligned location for the next
stack. */
# define YYSTACK_RELOCATE(Stack_alloc, Stack) \
do \
{ \
YYPTRDIFF_T yynewbytes; \
YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
Stack = &yyptr->Stack_alloc; \
yynewbytes = yystacksize * YYSIZEOF (*Stack) + YYSTACK_GAP_MAXIMUM; \
yyptr += yynewbytes / YYSIZEOF (*yyptr); \
} \
while (0)
#endif
#if defined YYCOPY_NEEDED && YYCOPY_NEEDED
/* Copy COUNT objects from SRC to DST. The source and destination do
not overlap. */
# ifndef YYCOPY
# if defined __GNUC__ && 1 < __GNUC__
# define YYCOPY(Dst, Src, Count) \
__builtin_memcpy (Dst, Src, YY_CAST (YYSIZE_T, (Count)) * sizeof (*(Src)))
# else
# define YYCOPY(Dst, Src, Count) \
do \
{ \
YYPTRDIFF_T yyi; \
for (yyi = 0; yyi < (Count); yyi++) \
(Dst)[yyi] = (Src)[yyi]; \
} \
while (0)
# endif
# endif
#endif /* !YYCOPY_NEEDED */
/* YYFINAL -- State number of the termination state. */
#define YYFINAL 32
/* YYLAST -- Last index in YYTABLE. */
#define YYLAST 230
/* YYNTOKENS -- Number of terminals. */
#define YYNTOKENS 36
/* YYNNTS -- Number of nonterminals. */
#define YYNNTS 70
/* YYNRULES -- Number of rules. */
#define YYNRULES 107
/* YYNSTATES -- Number of states. */
#define YYNSTATES 274
#define YYUNDEFTOK 2
#define YYMAXUTOK 285
/* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
as returned by yylex, with out-of-bounds checking. */
#define YYTRANSLATE(YYX) \
(0 <= (YYX) && (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
as returned by yylex. */
static const yytype_int8 yytranslate[] =
{
0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
32, 34, 2, 2, 35, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 31, 2, 33, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
25, 26, 27, 28, 29, 30
};
#if YYDEBUG
/* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
static const yytype_int16 yyrline[] =
{
0, 80, 80, 92, 92, 95, 98, 98, 101, 101,
101, 101, 104, 107, 109, 110, 113, 115, 116, 119,
122, 126, 131, 131, 131, 131, 131, 131, 134, 135,
138, 138, 142, 146, 147, 150, 151, 153, 154, 155,
156, 158, 159, 162, 165, 168, 172, 174, 175, 176,
177, 180, 184, 187, 190, 193, 196, 199, 202, 205,
208, 211, 212, 213, 214, 217, 220, 223, 224, 227,
229, 230, 231, 234, 236, 236, 239, 241, 242, 243,
246, 249, 252, 257, 257, 259, 262, 267, 270, 272,
275, 278, 281, 284, 287, 290, 293, 296, 299, 302,
305, 308, 311, 313, 315, 316, 317, 320
};
#endif
#if YYDEBUG || YYERROR_VERBOSE || 1
/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
First, the terminals, then, starting at YYNTOKENS, nonterminals. */
static const char *const yytname[] =
{
"\"end of string\"", "error", "$undefined", "\"PARAM_MT\"",
"\"CONCAT_MT\"", "\"INVERSE_MT\"", "\"PASSTHROUGH_MT\"", "\"PROJCS\"",
"\"PROJECTION\"", "\"GEOGCS\"", "\"DATUM\"", "\"SPHEROID\"",
"\"PRIMEM\"", "\"UNIT\"", "\"GEOCCS\"", "\"AUTHORITY\"", "\"VERT_CS\"",
"\"VERTCS\"", "\"VERT_DATUM\"", "\"VDATUM\"", "\"COMPD_CS\"", "\"AXIS\"",
"\"TOWGS84\"", "\"FITTED_CS\"", "\"LOCAL_CS\"", "\"LOCAL_DATUM\"",
"\"PARAMETER\"", "\"EXTENSION\"", "\"string\"", "\"number\"",
"\"identifier\"", "'['", "'('", "']'", "')'", "','", "$accept", "input",
"begin_node", "begin_node_name", "end_node", "math_transform",
"param_mt", "parameter", "opt_parameter_list", "concat_mt",
"opt_math_transform_list", "inv_mt", "passthrough_mt", "integer",
"coordinate_system", "horz_cs_with_opt_esri_vertcs", "horz_cs",
"projected_cs", "opt_parameter_list_linear_unit",
"parameter_list_linear_unit", "opt_twin_axis_extension_authority",
"opt_authority", "extension", "projection", "geographic_cs", "datum",
"opt_towgs84_authority_extension", "spheroid", "semi_major_axis",
"inverse_flattening", "prime_meridian", "longitude", "angular_unit",
"linear_unit", "unit", "conversion_factor", "geocentric_cs",
"opt_three_axis_extension_authority", "three_axis", "authority",
"vert_cs", "esri_vert_cs", "opt_axis_authority", "vert_datum",
"vdatum_or_datum", "vdatum", "opt_extension_authority", "datum_type",
"compd_cs", "head_cs", "tail_cs", "twin_axis", "axis", "towgs84",
"towgs84_parameters", "three_parameters", "seven_parameters", "dx", "dy",
"dz", "ex", "ey", "ez", "ppm", "fitted_cs", "to_base", "base_cs",
"local_cs", "opt_axis_list_authority", "local_datum", YY_NULLPTR
};
#endif
# ifdef YYPRINT
/* YYTOKNUM[NUM] -- (External) token number corresponding to the
(internal) symbol number NUM (which must be that of a token). */
static const yytype_int16 yytoknum[] =
{
0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
285, 91, 40, 93, 41, 44
};
# endif
#define YYPACT_NINF (-141)
#define yypact_value_is_default(Yyn) \
((Yyn) == YYPACT_NINF)
#define YYTABLE_NINF (-1)
#define yytable_value_is_error(Yyn) \
0
/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
STATE-NUM. */
static const yytype_int16 yypact[] =
{
119, 41, 41, 41, 41, 41, 41, 41, 41, 31,
-141, -141, 6, -141, -141, -141, -141, -141, -141, -141,
-141, -141, -141, 16, 32, 34, 42, 55, 68, 69,
70, 23, -141, 37, -141, 99, 101, 101, 95, 19,
4, 141, -141, -141, 89, -141, -141, 80, 41, 82,
85, 41, 86, 41, -141, 87, -141, -141, 90, 41,
41, 41, 41, -141, -141, -141, -141, -141, 92, 41,
94, 123, 97, 125, 125, 103, 127, 63, -4, 30,
113, 141, 141, 120, 119, 115, 127, 41, 116, 142,
41, 117, 121, 126, 41, 124, -141, -141, 41, 133,
63, -141, -141, -141, -141, 134, 132, 63, 135, 63,
-141, 136, -141, 63, 126, 137, 138, -4, 41, 140,
143, 127, 127, -141, 134, 144, 28, 63, 145, -4,
-141, -3, 63, 113, -141, 141, 63, -141, 141, -141,
138, 139, 146, 63, 147, 148, 13, 63, 152, 147,
-141, 149, 63, 156, 41, 41, -141, 138, -141, 157,
-141, -141, 41, 138, -141, -141, -141, 135, -141, 63,
63, 153, -141, -141, 61, 63, 158, 41, 138, -141,
134, -141, -141, 138, 63, 61, 63, -141, -141, 138,
154, 155, -141, 63, 159, -141, -141, -141, -141, 28,
63, 138, -141, 134, 160, -141, -141, 161, 162, -141,
-141, 63, -141, 138, 134, -141, 163, -141, 63, 164,
167, -141, 165, -141, 153, -141, -141, -141, 139, 170,
-141, 63, -141, -141, 166, -141, -141, -141, 139, -141,
63, 63, 63, -141, -141, -141, 138, -141, 171, 168,
-141, -141, -141, 63, -141, 169, 139, -141, 173, -141,
-141, 172, 176, -141, 174, 177, -141, 175, 179, -141,
178, 182, -141, -141
};
/* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
Performed when YYTABLE does not specify something else to do. Zero
means the default is an error. */
static const yytype_int8 yydefact[] =
{
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2, 22, 28, 31, 30, 23, 24, 68, 25, 26,
27, 3, 4, 0, 0, 0, 0, 0, 0, 0,
0, 0, 1, 0, 5, 0, 0, 0, 0, 0,
0, 0, 6, 7, 0, 103, 29, 0, 0, 0,
0, 0, 0, 0, 75, 0, 74, 82, 0, 0,
0, 0, 0, 100, 8, 9, 10, 11, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
14, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 70, 57, 76, 0, 0,
0, 34, 33, 83, 84, 77, 0, 0, 17, 0,
21, 0, 101, 0, 0, 0, 41, 0, 0, 47,
0, 0, 0, 80, 77, 0, 0, 0, 0, 0,
69, 0, 0, 14, 12, 0, 0, 19, 0, 99,
41, 0, 0, 0, 37, 0, 0, 0, 0, 37,
56, 61, 0, 0, 0, 0, 72, 41, 67, 0,
35, 36, 0, 41, 79, 81, 15, 17, 16, 0,
0, 104, 42, 44, 0, 0, 0, 0, 41, 50,
77, 46, 55, 41, 0, 0, 0, 73, 59, 41,
0, 0, 71, 0, 0, 78, 18, 20, 107, 0,
0, 41, 40, 77, 0, 32, 52, 0, 0, 49,
48, 0, 45, 41, 77, 64, 0, 60, 0, 0,
0, 13, 0, 105, 104, 102, 39, 38, 0, 0,
92, 0, 89, 88, 0, 54, 63, 62, 0, 58,
0, 0, 0, 106, 85, 53, 41, 87, 0, 0,
66, 86, 43, 0, 93, 0, 0, 51, 0, 65,
94, 90, 0, 95, 0, 0, 96, 0, 0, 97,
0, 0, 98, 91
};
/* YYPGOTO[NTERM-NUM]. */
static const yytype_int16 yypgoto[] =
{
-141, -141, -59, 12, -77, -55, -141, 56, 44, -141,
45, -141, -141, -141, 130, -141, 180, -141, 98, 88,
67, -89, -140, -141, -27, 48, -141, -141, -141, -141,
150, -141, -141, -43, -79, -141, -141, -141, -141, -121,
151, 185, -141, -141, -141, -141, -119, 105, -141, -141,
-141, -141, -137, -141, -141, -141, -141, -141, -141, -141,
-141, -141, -141, -141, -141, -141, -141, -141, -2, -141
};
/* YYDEFGOTO[NTERM-NUM]. */
static const yytype_int16 yydefgoto[] =
{
-1, 9, 23, 24, 45, 63, 64, 99, 107, 65,
136, 66, 67, 111, 10, 11, 12, 13, 100, 101,
175, 143, 163, 88, 14, 49, 147, 119, 207, 246,
91, 183, 149, 102, 96, 189, 15, 186, 214, 156,
16, 17, 127, 52, 55, 56, 132, 124, 18, 58,
105, 203, 157, 180, 231, 232, 233, 234, 255, 261,
264, 267, 270, 273, 19, 68, 113, 20, 200, 70
};
/* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
positive, shift that token. If negative, reduce the rule whose
number is the opposite. If YYTABLE_NINF, syntax error. */
static const yytype_int16 yytable[] =
{
97, 81, 82, 83, 171, 152, 178, 115, 47, 94,
164, 1, 154, 2, 25, 26, 27, 28, 29, 30,
31, 172, 98, 130, 162, 179, 108, 109, 154, 48,
134, 32, 137, 95, 201, 177, 139, 204, 53, 2,
162, 33, 150, 154, 34, 213, 4, 5, 216, 155,
158, 170, 103, 202, 5, 165, 42, 43, 44, 168,
72, 210, 224, 75, 215, 77, 173, 35, 192, 36,
181, 80, 21, 22, 195, 187, 154, 37, 223, 151,
167, 85, 155, 169, 227, 50, 161, 54, 162, 209,
38, 244, 197, 198, 211, 237, 42, 43, 205, 116,
218, 249, 120, 39, 40, 41, 125, 212, 2, 217,
128, 48, 226, 51, 69, 71, 221, 73, 208, 259,
74, 76, 78, 225, 236, 79, 1, 84, 2, 86,
145, 87, 89, 3, 235, 4, 5, 90, 93, 6,
94, 239, 7, 8, 59, 60, 61, 62, 106, 110,
114, 117, 121, 118, 247, 123, 122, 253, 98, 126,
155, 154, 133, 250, 251, 252, 190, 191, 129, 131,
135, 138, 141, 142, 194, 146, 257, 166, 148, 153,
159, 182, 174, 176, 185, 188, 193, 206, 199, 219,
220, 230, 240, 242, 222, 228, 229, 241, 238, 245,
254, 248, 260, 256, 258, 263, 266, 262, 269, 265,
268, 272, 196, 271, 112, 144, 184, 160, 46, 140,
57, 0, 243, 0, 92, 0, 0, 0, 0, 0,
104
};
static const yytype_int16 yycheck[] =
{
77, 60, 61, 62, 141, 124, 146, 86, 35, 13,
131, 7, 15, 9, 2, 3, 4, 5, 6, 7,
8, 142, 26, 100, 27, 146, 81, 82, 15, 10,
107, 0, 109, 76, 174, 22, 113, 174, 19, 9,
27, 35, 121, 15, 28, 185, 16, 17, 185, 21,
127, 140, 79, 174, 17, 132, 33, 34, 35, 136,
48, 180, 199, 51, 185, 53, 143, 35, 157, 35,
147, 59, 31, 32, 163, 152, 15, 35, 199, 122,
135, 69, 21, 138, 203, 37, 129, 39, 27, 178,
35, 228, 169, 170, 183, 214, 33, 34, 175, 87,
189, 238, 90, 35, 35, 35, 94, 184, 9, 186,
98, 10, 201, 18, 25, 35, 193, 35, 177, 256,
35, 35, 35, 200, 213, 35, 7, 35, 9, 35,
118, 8, 35, 14, 211, 16, 17, 12, 35, 20,
13, 218, 23, 24, 3, 4, 5, 6, 35, 29,
35, 35, 35, 11, 231, 29, 35, 246, 26, 35,
21, 15, 106, 240, 241, 242, 154, 155, 35, 35,
35, 35, 35, 35, 162, 35, 253, 133, 35, 35,
35, 29, 35, 35, 35, 29, 29, 29, 35, 35,
35, 29, 28, 28, 35, 35, 35, 30, 35, 29,
29, 35, 29, 35, 35, 29, 29, 35, 29, 35,
35, 29, 167, 35, 84, 117, 149, 129, 33, 114,
40, -1, 224, -1, 74, -1, -1, -1, -1, -1,
79
};
/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
symbol of state STATE-NUM. */
static const yytype_int8 yystos[] =
{
0, 7, 9, 14, 16, 17, 20, 23, 24, 37,
50, 51, 52, 53, 60, 72, 76, 77, 84, 100,
103, 31, 32, 38, 39, 39, 39, 39, 39, 39,
39, 39, 0, 35, 28, 35, 35, 35, 35, 35,
35, 35, 33, 34, 35, 40, 77, 60, 10, 61,
61, 18, 79, 19, 61, 80, 81, 52, 85, 3,
4, 5, 6, 41, 42, 45, 47, 48, 101, 25,
105, 35, 39, 35, 35, 39, 35, 39, 35, 35,
39, 38, 38, 38, 35, 39, 35, 8, 59, 35,
12, 66, 66, 35, 13, 69, 70, 40, 26, 43,
54, 55, 69, 60, 76, 86, 35, 44, 41, 41,
29, 49, 50, 102, 35, 70, 39, 35, 11, 63,
39, 35, 35, 29, 83, 39, 35, 78, 39, 35,
40, 35, 82, 43, 40, 35, 46, 40, 35, 40,
83, 35, 35, 57, 54, 39, 35, 62, 35, 68,
70, 69, 82, 35, 15, 21, 75, 88, 40, 35,
55, 69, 27, 58, 75, 40, 44, 41, 40, 41,
57, 88, 75, 40, 35, 56, 35, 22, 58, 75,
89, 40, 29, 67, 56, 35, 73, 40, 29, 71,
39, 39, 57, 29, 39, 57, 46, 40, 40, 35,
104, 58, 75, 87, 88, 40, 29, 64, 38, 57,
82, 57, 40, 58, 74, 75, 88, 40, 57, 35,
35, 40, 35, 75, 88, 40, 57, 82, 35, 35,
29, 90, 91, 92, 93, 40, 57, 82, 35, 40,
28, 30, 28, 104, 88, 29, 65, 40, 35, 88,
40, 40, 40, 57, 29, 94, 35, 40, 35, 88,
29, 95, 35, 29, 96, 35, 29, 97, 35, 29,
98, 35, 29, 99
};
/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
static const yytype_int8 yyr1[] =
{
0, 36, 37, 38, 38, 39, 40, 40, 41, 41,
41, 41, 42, 43, 44, 44, 45, 46, 46, 47,
48, 49, 50, 50, 50, 50, 50, 50, 51, 51,
52, 52, 53, 54, 54, 55, 55, 56, 56, 56,
56, 57, 57, 58, 59, 60, 61, 62, 62, 62,
62, 63, 64, 65, 66, 67, 68, 69, 70, 71,
72, 73, 73, 73, 73, 74, 75, 76, 76, 77,
78, 78, 78, 79, 80, 80, 81, 82, 82, 82,
83, 84, 85, 86, 86, 87, 88, 89, 90, 90,
91, 92, 93, 94, 95, 96, 97, 98, 99, 100,
101, 102, 103, 103, 104, 104, 104, 105
};
/* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */
static const yytype_int8 yyr2[] =
{
0, 2, 1, 1, 1, 2, 1, 1, 1, 1,
1, 1, 4, 5, 0, 3, 5, 0, 3, 4,
6, 1, 1, 1, 1, 1, 1, 1, 1, 3,
1, 1, 10, 1, 1, 3, 3, 0, 3, 3,
2, 0, 2, 5, 4, 10, 6, 0, 3, 3,
2, 8, 1, 1, 6, 1, 1, 1, 6, 1,
10, 0, 3, 3, 2, 5, 5, 8, 1, 7,
0, 3, 2, 6, 1, 1, 3, 0, 3, 2,
1, 8, 1, 1, 1, 3, 5, 4, 1, 1,
5, 13, 1, 1, 1, 1, 1, 1, 1, 7,
1, 1, 10, 3, 0, 2, 3, 6
};
#define yyerrok (yyerrstatus = 0)
#define yyclearin (yychar = YYEMPTY)
#define YYEMPTY (-2)
#define YYEOF 0
#define YYACCEPT goto yyacceptlab
#define YYABORT goto yyabortlab
#define YYERROR goto yyerrorlab
#define YYRECOVERING() (!!yyerrstatus)
#define YYBACKUP(Token, Value) \
do \
if (yychar == YYEMPTY) \
{ \
yychar = (Token); \
yylval = (Value); \
YYPOPSTACK (yylen); \
yystate = *yyssp; \
goto yybackup; \
} \
else \
{ \
yyerror (context, YY_("syntax error: cannot back up")); \
YYERROR; \
} \
while (0)
/* Error token number */
#define YYTERROR 1
#define YYERRCODE 256
/* Enable debugging if requested. */
#if YYDEBUG
# ifndef YYFPRINTF
# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
# define YYFPRINTF fprintf
# endif
# define YYDPRINTF(Args) \
do { \
if (yydebug) \
YYFPRINTF Args; \
} while (0)
/* This macro is provided for backward compatibility. */
#ifndef YY_LOCATION_PRINT
# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
#endif
# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
do { \
if (yydebug) \
{ \
YYFPRINTF (stderr, "%s ", Title); \
yy_symbol_print (stderr, \
Type, Value, context); \
YYFPRINTF (stderr, "\n"); \
} \
} while (0)
/*-----------------------------------.
| Print this symbol's value on YYO. |
`-----------------------------------*/
static void
yy_symbol_value_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep, pj_wkt1_parse_context *context)
{
FILE *yyoutput = yyo;
YYUSE (yyoutput);
YYUSE (context);
if (!yyvaluep)
return;
# ifdef YYPRINT
if (yytype < YYNTOKENS)
YYPRINT (yyo, yytoknum[yytype], *yyvaluep);
# endif
YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
YYUSE (yytype);
YY_IGNORE_MAYBE_UNINITIALIZED_END
}
/*---------------------------.
| Print this symbol on YYO. |
`---------------------------*/
static void
yy_symbol_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep, pj_wkt1_parse_context *context)
{
YYFPRINTF (yyo, "%s %s (",
yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);
yy_symbol_value_print (yyo, yytype, yyvaluep, context);
YYFPRINTF (yyo, ")");
}
/*------------------------------------------------------------------.
| yy_stack_print -- Print the state stack from its BOTTOM up to its |
| TOP (included). |
`------------------------------------------------------------------*/
static void
yy_stack_print (yy_state_t *yybottom, yy_state_t *yytop)
{
YYFPRINTF (stderr, "Stack now");
for (; yybottom <= yytop; yybottom++)
{
int yybot = *yybottom;
YYFPRINTF (stderr, " %d", yybot);
}
YYFPRINTF (stderr, "\n");
}
# define YY_STACK_PRINT(Bottom, Top) \
do { \
if (yydebug) \
yy_stack_print ((Bottom), (Top)); \
} while (0)
/*------------------------------------------------.
| Report that the YYRULE is going to be reduced. |
`------------------------------------------------*/
static void
yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp, int yyrule, pj_wkt1_parse_context *context)
{
int yylno = yyrline[yyrule];
int yynrhs = yyr2[yyrule];
int yyi;
YYFPRINTF (stderr, "Reducing stack by rule %d (line %d):\n",
yyrule - 1, yylno);
/* The symbols being reduced. */
for (yyi = 0; yyi < yynrhs; yyi++)
{
YYFPRINTF (stderr, " $%d = ", yyi + 1);
yy_symbol_print (stderr,
yystos[+yyssp[yyi + 1 - yynrhs]],
&yyvsp[(yyi + 1) - (yynrhs)]
, context);
YYFPRINTF (stderr, "\n");
}
}
# define YY_REDUCE_PRINT(Rule) \
do { \
if (yydebug) \
yy_reduce_print (yyssp, yyvsp, Rule, context); \
} while (0)
/* Nonzero means print parse trace. It is left uninitialized so that
multiple parsers can coexist. */
int yydebug;
#else /* !YYDEBUG */
# define YYDPRINTF(Args)
# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
# define YY_STACK_PRINT(Bottom, Top)
# define YY_REDUCE_PRINT(Rule)
#endif /* !YYDEBUG */
/* YYINITDEPTH -- initial size of the parser's stacks. */
#ifndef YYINITDEPTH
# define YYINITDEPTH 200
#endif
/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
if the built-in stack extension method is used).
Do not make this value too large; the results are undefined if
YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
evaluated with infinite-precision integer arithmetic. */
#ifndef YYMAXDEPTH
# define YYMAXDEPTH 10000
#endif
#if YYERROR_VERBOSE
# ifndef yystrlen
# if defined __GLIBC__ && defined _STRING_H
# define yystrlen(S) (YY_CAST (YYPTRDIFF_T, strlen (S)))
# else
/* Return the length of YYSTR. */
static YYPTRDIFF_T
yystrlen (const char *yystr)
{
YYPTRDIFF_T yylen;
for (yylen = 0; yystr && yystr[yylen]; yylen++)
continue;
return yylen;
}
# endif
# endif
# ifndef yystpcpy
# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
# define yystpcpy stpcpy
# else
/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
YYDEST. */
static char *
yystpcpy (char *yydest, const char *yysrc)
{
char *yyd = yydest;
const char *yys = yysrc;
while ((*yyd++ = *yys++) != '\0')
continue;
return yyd - 1;
}
# endif
# endif
# ifndef yytnamerr
/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
quotes and backslashes, so that it's suitable for yyerror. The
heuristic is that double-quoting is unnecessary unless the string
contains an apostrophe, a comma, or backslash (other than
backslash-backslash). YYSTR is taken from yytname. If YYRES is
null, do not copy; instead, return the length of what the result
would have been. */
static YYPTRDIFF_T
yytnamerr (char *yyres, const char *yystr)
{
if (*yystr == '"')
{
YYPTRDIFF_T yyn = 0;
char const *yyp = yystr;
for (;;)
switch (*++yyp)
{
case '\'':
case ',':
goto do_not_strip_quotes;
case '\\':
if (*++yyp != '\\')
goto do_not_strip_quotes;
else
goto append;
append:
default:
if (yyres)
yyres[yyn] = *yyp;
yyn++;
break;
case '"':
if (yyres)
yyres[yyn] = '\0';
return yyn;
}
do_not_strip_quotes: ;
}
if (yyres)
return (YYPTRDIFF_T)(yystpcpy (yyres, yystr) - yyres);
else
return yystrlen (yystr);
}
# endif
/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
about the unexpected token YYTOKEN for the state stack whose top is
YYSSP.
Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
not large enough to hold the message. In that case, also set
*YYMSG_ALLOC to the required number of bytes. Return 2 if the
required number of bytes is too large to store. */
static int
yysyntax_error (YYPTRDIFF_T *yymsg_alloc, char **yymsg,
yy_state_t *yyssp, int yytoken)
{
enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
/* Internationalized format string. */
const char *yyformat = YY_NULLPTR;
/* Arguments of yyformat: reported tokens (one for the "unexpected",
one per "expected"). */
char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
/* Actual size of YYARG. */
int yycount = 0;
/* Cumulated lengths of YYARG. */
YYPTRDIFF_T yysize = 0;
/* There are many possibilities here to consider:
- If this state is a consistent state with a default action, then
the only way this function was invoked is if the default action
is an error action. In that case, don't check for expected
tokens because there are none.
- The only way there can be no lookahead present (in yychar) is if
this state is a consistent state with a default action. Thus,
detecting the absence of a lookahead is sufficient to determine
that there is no unexpected or expected token to report. In that
case, just report a simple "syntax error".
- Don't assume there isn't a lookahead just because this state is a
consistent state with a default action. There might have been a
previous inconsistent state, consistent state with a non-default
action, or user semantic action that manipulated yychar.
- Of course, the expected token list depends on states to have
correct lookahead information, and it depends on the parser not
to perform extra reductions after fetching a lookahead from the
scanner and before detecting a syntax error. Thus, state merging
(from LALR or IELR) and default reductions corrupt the expected
token list. However, the list is correct for canonical LR with
one exception: it will still contain any token that will not be
accepted due to an error action in a later state.
*/
if (yytoken != YYEMPTY)
{
int yyn = yypact[+*yyssp];
YYPTRDIFF_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]);
yysize = yysize0;
yyarg[yycount++] = yytname[yytoken];
if (!yypact_value_is_default (yyn))
{
/* Start YYX at -YYN if negative to avoid negative indexes in
YYCHECK. In other words, skip the first -YYN actions for
this state because they are default actions. */
int yyxbegin = yyn < 0 ? -yyn : 0;
/* Stay within bounds of both yycheck and yytname. */
int yychecklim = YYLAST - yyn + 1;
int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
int yyx;
for (yyx = yyxbegin; yyx < yyxend; ++yyx)
if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
&& !yytable_value_is_error (yytable[yyx + yyn]))
{
if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
{
yycount = 1;
yysize = yysize0;
break;
}
yyarg[yycount++] = yytname[yyx];
{
YYPTRDIFF_T yysize1
= yysize + yytnamerr (YY_NULLPTR, yytname[yyx]);
if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)
yysize = yysize1;
else
return 2;
}
}
}
}
switch (yycount)
{
# define YYCASE_(N, S) \
case N: \
yyformat = S; \
break
default: /* Avoid compiler warnings. */
YYCASE_(0, YY_("syntax error"));
YYCASE_(1, YY_("syntax error, unexpected %s"));
YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
# undef YYCASE_
}
{
/* Don't count the "%s"s in the final size, but reserve room for
the terminator. */
YYPTRDIFF_T yysize1 = yysize + (yystrlen (yyformat) - 2 * yycount) + 1;
if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)
yysize = yysize1;
else
return 2;
}
if (*yymsg_alloc < yysize)
{
*yymsg_alloc = 2 * yysize;
if (! (yysize <= *yymsg_alloc
&& *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
*yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
return 1;
}
/* Avoid sprintf, as that infringes on the user's name space.
Don't have undefined behavior even if the translation
produced a string with the wrong number of "%s"s. */
{
char *yyp = *yymsg;
int yyi = 0;
while ((*yyp = *yyformat) != '\0')
if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
{
yyp += yytnamerr (yyp, yyarg[yyi++]);
yyformat += 2;
}
else
{
++yyp;
++yyformat;
}
}
return 0;
}
#endif /* YYERROR_VERBOSE */
/*-----------------------------------------------.
| Release the memory associated to this symbol. |
`-----------------------------------------------*/
static void
yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, pj_wkt1_parse_context *context)
{
YYUSE (yyvaluep);
YYUSE (context);
if (!yymsg)
yymsg = "Deleting";
YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
YYUSE (yytype);
YY_IGNORE_MAYBE_UNINITIALIZED_END
}
/*----------.
| yyparse. |
`----------*/
int
yyparse (pj_wkt1_parse_context *context)
{
/* The lookahead symbol. */
int yychar;
/* The semantic value of the lookahead symbol. */
/* Default value used for initialization, for pacifying older GCCs
or non-GCC compilers. */
YY_INITIAL_VALUE (static YYSTYPE yyval_default;)
YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
/* Number of syntax errors so far. */
int yynerrs;
yy_state_fast_t yystate;
/* Number of tokens to shift before error messages enabled. */
int yyerrstatus;
/* The stacks and their tools:
'yyss': related to states.
'yyvs': related to semantic values.
Refer to the stacks through separate pointers, to allow yyoverflow
to reallocate them elsewhere. */
/* The state stack. */
yy_state_t yyssa[YYINITDEPTH];
yy_state_t *yyss;
yy_state_t *yyssp;
/* The semantic value stack. */
YYSTYPE yyvsa[YYINITDEPTH];
YYSTYPE *yyvs;
YYSTYPE *yyvsp;
YYPTRDIFF_T yystacksize;
int yyn;
int yyresult;
/* Lookahead token as an internal (translated) token number. */
int yytoken = 0;
/* The variables used to return semantic value and location from the
action routines. */
YYSTYPE yyval;
#if YYERROR_VERBOSE
/* Buffer for error messages, and its allocated size. */
char yymsgbuf[128];
char *yymsg = yymsgbuf;
YYPTRDIFF_T yymsg_alloc = sizeof yymsgbuf;
#endif
#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
/* The number of symbols on the RHS of the reduced rule.
Keep to zero when no symbol should be popped. */
int yylen = 0;
yyssp = yyss = yyssa;
yyvsp = yyvs = yyvsa;
yystacksize = YYINITDEPTH;
YYDPRINTF ((stderr, "Starting parse\n"));
yystate = 0;
yyerrstatus = 0;
yynerrs = 0;
yychar = YYEMPTY; /* Cause a token to be read. */
goto yysetstate;
/*------------------------------------------------------------.
| yynewstate -- push a new state, which is found in yystate. |
`------------------------------------------------------------*/
yynewstate:
/* In all cases, when you get here, the value and location stacks
have just been pushed. So pushing a state here evens the stacks. */
yyssp++;
/*--------------------------------------------------------------------.
| yysetstate -- set current state (the top of the stack) to yystate. |
`--------------------------------------------------------------------*/
yysetstate:
YYDPRINTF ((stderr, "Entering state %d\n", yystate));
YY_ASSERT (0 <= yystate && yystate < YYNSTATES);
YY_IGNORE_USELESS_CAST_BEGIN
*yyssp = YY_CAST (yy_state_t, yystate);
YY_IGNORE_USELESS_CAST_END
if (yyss + yystacksize - 1 <= yyssp)
#if !defined yyoverflow && !defined YYSTACK_RELOCATE
goto yyexhaustedlab;
#else
{
/* Get the current used size of the three stacks, in elements. */
YYPTRDIFF_T yysize = (YYPTRDIFF_T)(yyssp - yyss + 1);
# if defined yyoverflow
{
/* Give user a chance to reallocate the stack. Use copies of
these so that the &'s don't force the real ones into
memory. */
yy_state_t *yyss1 = yyss;
YYSTYPE *yyvs1 = yyvs;
/* Each stack pointer address is followed by the size of the
data in use in that stack, in bytes. This used to be a
conditional around just the two extra args, but that might
be undefined if yyoverflow is a macro. */
yyoverflow (YY_("memory exhausted"),
&yyss1, yysize * YYSIZEOF (*yyssp),
&yyvs1, yysize * YYSIZEOF (*yyvsp),
&yystacksize);
yyss = yyss1;
yyvs = yyvs1;
}
# else /* defined YYSTACK_RELOCATE */
/* Extend the stack our own way. */
if (YYMAXDEPTH <= yystacksize)
goto yyexhaustedlab;
yystacksize *= 2;
if (YYMAXDEPTH < yystacksize)
yystacksize = YYMAXDEPTH;
{
yy_state_t *yyss1 = yyss;
union yyalloc *yyptr =
YY_CAST (union yyalloc *,
YYSTACK_ALLOC (YY_CAST (YYSIZE_T, YYSTACK_BYTES (yystacksize))));
if (! yyptr)
goto yyexhaustedlab;
YYSTACK_RELOCATE (yyss_alloc, yyss);
YYSTACK_RELOCATE (yyvs_alloc, yyvs);
# undef YYSTACK_RELOCATE
if (yyss1 != yyssa)
YYSTACK_FREE (yyss1);
}
# endif
yyssp = yyss + yysize - 1;
yyvsp = yyvs + yysize - 1;
YY_IGNORE_USELESS_CAST_BEGIN
YYDPRINTF ((stderr, "Stack size increased to %ld\n",
YY_CAST (long, yystacksize)));
YY_IGNORE_USELESS_CAST_END
if (yyss + yystacksize - 1 <= yyssp)
YYABORT;
}
#endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */
if (yystate == YYFINAL)
YYACCEPT;
goto yybackup;
/*-----------.
| yybackup. |
`-----------*/
yybackup:
/* Do appropriate processing given the current state. Read a
lookahead token if we need one and don't already have one. */
/* First try to decide what to do without reference to lookahead token. */
yyn = yypact[yystate];
if (yypact_value_is_default (yyn))
goto yydefault;
/* Not known => get a lookahead token if don't already have one. */
/* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
if (yychar == YYEMPTY)
{
YYDPRINTF ((stderr, "Reading a token: "));
yychar = yylex (&yylval, context);
}
if (yychar <= YYEOF)
{
yychar = yytoken = YYEOF;
YYDPRINTF ((stderr, "Now at end of input.\n"));
}
else
{
yytoken = YYTRANSLATE (yychar);
YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
}
/* If the proper action on seeing token YYTOKEN is to reduce or to
detect an error, take that action. */
yyn += yytoken;
if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
goto yydefault;
yyn = yytable[yyn];
if (yyn <= 0)
{
if (yytable_value_is_error (yyn))
goto yyerrlab;
yyn = -yyn;
goto yyreduce;
}
/* Count tokens shifted since error; after three, turn off error
status. */
if (yyerrstatus)
yyerrstatus--;
/* Shift the lookahead token. */
YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
yystate = yyn;
YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
*++yyvsp = yylval;
YY_IGNORE_MAYBE_UNINITIALIZED_END
/* Discard the shifted token. */
yychar = YYEMPTY;
goto yynewstate;
/*-----------------------------------------------------------.
| yydefault -- do the default action for the current state. |
`-----------------------------------------------------------*/
yydefault:
yyn = yydefact[yystate];
if (yyn == 0)
goto yyerrlab;
goto yyreduce;
/*-----------------------------.
| yyreduce -- do a reduction. |
`-----------------------------*/
yyreduce:
/* yyn is the number of a rule to reduce with. */
yylen = yyr2[yyn];
/* If YYLEN is nonzero, implement the default value of the action:
'$$ = $1'.
Otherwise, the following line sets YYVAL to garbage.
This behavior is undocumented and Bison
users should not rely upon it. Assigning to YYVAL
unconditionally makes the parser a bit smaller, and it avoids a
GCC warning that YYVAL may be used uninitialized. */
yyval = yyvsp[1-yylen];
YY_REDUCE_PRINT (yyn);
switch (yyn)
{
default: break;
}
/* User semantic actions sometimes alter yychar, and that requires
that yytoken be updated with the new translation. We take the
approach of translating immediately before every use of yytoken.
One alternative is translating here after every semantic action,
but that translation would be missed if the semantic action invokes
YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
incorrect destructor might then be invoked immediately. In the
case of YYERROR or YYBACKUP, subsequent parser actions might lead
to an incorrect destructor call or verbose syntax error message
before the lookahead is translated. */
YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
YYPOPSTACK (yylen);
yylen = 0;
YY_STACK_PRINT (yyss, yyssp);
*++yyvsp = yyval;
/* Now 'shift' the result of the reduction. Determine what state
that goes to, based on the state we popped back to and the rule
number reduced by. */
{
const int yylhs = yyr1[yyn] - YYNTOKENS;
const int yyi = yypgoto[yylhs] + *yyssp;
yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp
? yytable[yyi]
: yydefgoto[yylhs]);
}
goto yynewstate;
/*--------------------------------------.
| yyerrlab -- here on detecting error. |
`--------------------------------------*/
yyerrlab:
/* Make sure we have latest lookahead translation. See comments at
user semantic actions for why this is necessary. */
yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
/* If not already recovering from an error, report this error. */
if (!yyerrstatus)
{
++yynerrs;
#if ! YYERROR_VERBOSE
yyerror (context, YY_("syntax error"));
#else
# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
yyssp, yytoken)
{
char const *yymsgp = YY_("syntax error");
int yysyntax_error_status;
yysyntax_error_status = YYSYNTAX_ERROR;
if (yysyntax_error_status == 0)
yymsgp = yymsg;
else if (yysyntax_error_status == 1)
{
if (yymsg != yymsgbuf)
YYSTACK_FREE (yymsg);
yymsg = YY_CAST (char *, YYSTACK_ALLOC (YY_CAST (YYSIZE_T, yymsg_alloc)));
if (!yymsg)
{
yymsg = yymsgbuf;
yymsg_alloc = sizeof yymsgbuf;
yysyntax_error_status = 2;
}
else
{
yysyntax_error_status = YYSYNTAX_ERROR;
yymsgp = yymsg;
}
}
yyerror (context, yymsgp);
if (yysyntax_error_status == 2)
goto yyexhaustedlab;
}
# undef YYSYNTAX_ERROR
#endif
}
if (yyerrstatus == 3)
{
/* If just tried and failed to reuse lookahead token after an
error, discard it. */
if (yychar <= YYEOF)
{
/* Return failure if at end of input. */
if (yychar == YYEOF)
YYABORT;
}
else
{
yydestruct ("Error: discarding",
yytoken, &yylval, context);
yychar = YYEMPTY;
}
}
/* Else will try to reuse lookahead token after shifting the error
token. */
goto yyerrlab1;
/*---------------------------------------------------.
| yyerrorlab -- error raised explicitly by YYERROR. |
`---------------------------------------------------*/
#if 0
yyerrorlab:
/* Pacify compilers when the user code never invokes YYERROR and the
label yyerrorlab therefore never appears in user code. */
if (0)
YYERROR;
/* Do not reclaim the symbols of the rule whose action triggered
this YYERROR. */
YYPOPSTACK (yylen);
yylen = 0;
YY_STACK_PRINT (yyss, yyssp);
yystate = *yyssp;
goto yyerrlab1;
/*-------------------------------------------------------------.
| yyerrlab1 -- common code for both syntax error and YYERROR. |
`-------------------------------------------------------------*/
#endif
yyerrlab1:
yyerrstatus = 3; /* Each real token shifted decrements this. */
for (;;)
{
yyn = yypact[yystate];
if (!yypact_value_is_default (yyn))
{
yyn += YYTERROR;
if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
{
yyn = yytable[yyn];
if (0 < yyn)
break;
}
}
/* Pop the current state because it cannot handle the error token. */
if (yyssp == yyss)
YYABORT;
yydestruct ("Error: popping",
yystos[yystate], yyvsp, context);
YYPOPSTACK (1);
yystate = *yyssp;
YY_STACK_PRINT (yyss, yyssp);
}
YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
*++yyvsp = yylval;
YY_IGNORE_MAYBE_UNINITIALIZED_END
/* Shift the error token. */
YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
yystate = yyn;
goto yynewstate;
/*-------------------------------------.
| yyacceptlab -- YYACCEPT comes here. |
`-------------------------------------*/
yyacceptlab:
yyresult = 0;
goto yyreturn;
/*-----------------------------------.
| yyabortlab -- YYABORT comes here. |
`-----------------------------------*/
yyabortlab:
yyresult = 1;
goto yyreturn;
#if !defined yyoverflow || YYERROR_VERBOSE
/*-------------------------------------------------.
| yyexhaustedlab -- memory exhaustion comes here. |
`-------------------------------------------------*/
yyexhaustedlab:
yyerror (context, YY_("memory exhausted"));
yyresult = 2;
/* Fall through. */
#endif
/*-----------------------------------------------------.
| yyreturn -- parsing is finished, return the result. |
`-----------------------------------------------------*/
yyreturn:
if (yychar != YYEMPTY)
{
/* Make sure we have latest lookahead translation. See comments at
user semantic actions for why this is necessary. */
yytoken = YYTRANSLATE (yychar);
yydestruct ("Cleanup: discarding lookahead",
yytoken, &yylval, context);
}
/* Do not reclaim the symbols of the rule whose action triggered
this YYABORT or YYACCEPT. */
YYPOPSTACK (yylen);
YY_STACK_PRINT (yyss, yyssp);
while (yyssp != yyss)
{
yydestruct ("Cleanup: popping",
yystos[+*yyssp], yyvsp, context);
YYPOPSTACK (1);
}
#ifndef yyoverflow
if (yyss != yyssa)
YYSTACK_FREE (yyss);
#endif
#if YYERROR_VERBOSE
if (yymsg != yymsgbuf)
YYSTACK_FREE (yymsg);
#endif
return yyresult;
}
|
1003092.c | /// MentOS, The Mentoring Operating system project
/// @file math.c
/// @brief
/// @copyright (c) 2014-2021 This file is distributed under the MIT License.
/// See LICENSE.md for details.
#include "math.h"
#include "stdint.h"
double round(double x)
{
double out;
__asm__ __volatile__("fldln2; fldl %1; frndint"
: "=t"(out)
: "m"(x));
return out;
}
double floor(double x)
{
if (x > -1.0 && x < 1.0) {
if (x >= 0)
return 0.0;
return -1.0;
}
int i = (int)x;
if (x < 0)
return (double)(i - 1);
return (double)i;
}
double ceil(double x)
{
if (x > -1.0 && x < 1.0) {
if (x <= 0)
return 0.0;
return 1.0;
}
int i = (int)x;
if (x > 0)
return (double)(i + 1);
return (double)i;
}
double pow(double base, double exponent)
{
double out;
__asm__ __volatile__("fyl2x;"
"fld %%st;"
"frndint;"
"fsub %%st,%%st(1);"
"fxch;"
"fchs;"
"f2xm1;"
"fld1;"
"faddp;"
"fxch;"
"fld1;"
"fscale;"
"fstp %%st(1);"
"fmulp;"
: "=t"(out)
: "0"(base), "u"(exponent)
: "st(1)");
return out;
}
double exp(double x)
{
return pow(M_E, x);
}
double fabs(double x)
{
double out;
__asm__ __volatile__("fldln2; fldl %1; fabs"
: "=t"(out)
: "m"(x));
return out;
}
float fabsf(float x)
{
float out;
__asm__ __volatile__("fldln2; fldl %1; fabs"
: "=t"(out)
: "m"(x));
return out;
}
double sqrt(double x)
{
double out;
__asm__ __volatile__("fldln2; fldl %1; fsqrt"
: "=t"(out)
: "m"(x));
return out;
}
float sqrtf(float x)
{
float out;
__asm__ __volatile__("fldln2; fldl %1; fsqrt"
: "=t"(out)
: "m"(x));
return out;
}
int isinf(double x)
{
union {
unsigned long long u;
double f;
} ieee754;
ieee754.f = x;
return ((unsigned)(ieee754.u >> 32U) & 0x7fffffffU) == 0x7ff00000U &&
((unsigned)ieee754.u == 0);
}
int isnan(double x)
{
union {
unsigned long long u;
double f;
} ieee754;
ieee754.f = x;
return ((unsigned)(ieee754.u >> 32) & 0x7fffffff) +
((unsigned)ieee754.u != 0) >
0x7ff00000;
}
double log10(double x)
{
return ln(x) / ln(10);
}
double ln(double x)
{
double out;
__asm__ __volatile__("fldln2; fldl %1; fyl2x"
: "=t"(out)
: "m"(x));
return out;
}
double logx(double x, double y)
{
// Base may not equal 1 or be negative.
if (y == 1.f || y < 0.f || ln(y) == 0.f)
return 0.f;
return ln(x) / ln(y);
}
/// Max power for forward and reverse projections.
#define MAXPOWTWO 4.503599627370496000E+15
double modf(double x, double *intpart)
{
register double absvalue;
if ((absvalue = (x >= 0.0) ? x : -x) >= MAXPOWTWO) {
// It must be an integer.
(*intpart) = x;
} else {
// Shift fraction off right.
(*intpart) = absvalue + MAXPOWTWO;
// Shift back without fraction.
(*intpart) -= MAXPOWTWO;
// Above arithmetic might round.
while ((*intpart) > absvalue) {
// Test again just to be sure.
(*intpart) -= 1.0;
}
if (x < 0.0) {
(*intpart) = -(*intpart);
}
}
// Signed fractional part.
return (x - (*intpart));
}
|
276460.c | /*
* WPA Supplicant - privilege separated driver interface
* Copyright (c) 2007-2009, Jouni Malinen <[email protected]>
*
* This software may be distributed under the terms of the BSD license.
* See README for more details.
*/
#include "includes.h"
#include <sys/un.h>
#include "common.h"
#include "driver.h"
#include "eloop.h"
#include "common/privsep_commands.h"
struct wpa_driver_privsep_data {
void *ctx;
u8 own_addr[ETH_ALEN];
int priv_socket;
char *own_socket_path;
int cmd_socket;
char *own_cmd_path;
struct sockaddr_un priv_addr;
char ifname[16];
};
static int wpa_priv_reg_cmd(struct wpa_driver_privsep_data *drv, int cmd)
{
int res;
res = sendto(drv->priv_socket, &cmd, sizeof(cmd), 0,
(struct sockaddr *) &drv->priv_addr,
sizeof(drv->priv_addr));
if (res < 0)
wpa_printf(MSG_ERROR, "sendto: %s", strerror(errno));
return res < 0 ? -1 : 0;
}
static int wpa_priv_cmd(struct wpa_driver_privsep_data *drv, int cmd,
const void *data, size_t data_len,
void *reply, size_t *reply_len)
{
struct msghdr msg;
struct iovec io[2];
io[0].iov_base = &cmd;
io[0].iov_len = sizeof(cmd);
io[1].iov_base = (u8 *) data;
io[1].iov_len = data_len;
os_memset(&msg, 0, sizeof(msg));
msg.msg_iov = io;
msg.msg_iovlen = data ? 2 : 1;
msg.msg_name = &drv->priv_addr;
msg.msg_namelen = sizeof(drv->priv_addr);
if (sendmsg(drv->cmd_socket, &msg, 0) < 0) {
wpa_printf(MSG_ERROR, "sendmsg(cmd_socket): %s",
strerror(errno));
return -1;
}
if (reply) {
fd_set rfds;
struct timeval tv;
int res;
FD_ZERO(&rfds);
FD_SET(drv->cmd_socket, &rfds);
tv.tv_sec = 5;
tv.tv_usec = 0;
res = select(drv->cmd_socket + 1, &rfds, NULL, NULL, &tv);
if (res < 0 && errno != EINTR) {
wpa_printf(MSG_ERROR, "select: %s", strerror(errno));
return -1;
}
if (FD_ISSET(drv->cmd_socket, &rfds)) {
res = recv(drv->cmd_socket, reply, *reply_len, 0);
if (res < 0) {
wpa_printf(MSG_ERROR, "recv: %s",
strerror(errno));
return -1;
}
*reply_len = res;
} else {
wpa_printf(MSG_DEBUG, "PRIVSEP: Timeout while waiting "
"for reply (cmd=%d)", cmd);
return -1;
}
}
return 0;
}
static int wpa_driver_privsep_scan(void *priv,
struct wpa_driver_scan_params *params)
{
struct wpa_driver_privsep_data *drv = priv;
const u8 *ssid = params->ssids[0].ssid;
size_t ssid_len = params->ssids[0].ssid_len;
wpa_printf(MSG_DEBUG, "%s: priv=%p", __func__, priv);
return wpa_priv_cmd(drv, PRIVSEP_CMD_SCAN, ssid, ssid_len,
NULL, NULL);
}
static struct wpa_scan_results *
wpa_driver_privsep_get_scan_results2(void *priv)
{
struct wpa_driver_privsep_data *drv = priv;
int res, num;
u8 *buf, *pos, *end;
size_t reply_len = 60000;
struct wpa_scan_results *results;
struct wpa_scan_res *r;
buf = os_malloc(reply_len);
if (buf == NULL)
return NULL;
res = wpa_priv_cmd(drv, PRIVSEP_CMD_GET_SCAN_RESULTS,
NULL, 0, buf, &reply_len);
if (res < 0) {
os_free(buf);
return NULL;
}
wpa_printf(MSG_DEBUG, "privsep: Received %lu bytes of scan results",
(unsigned long) reply_len);
if (reply_len < sizeof(int)) {
wpa_printf(MSG_DEBUG, "privsep: Invalid scan result len %lu",
(unsigned long) reply_len);
os_free(buf);
return NULL;
}
pos = buf;
end = buf + reply_len;
os_memcpy(&num, pos, sizeof(int));
if (num < 0 || num > 1000) {
os_free(buf);
return NULL;
}
pos += sizeof(int);
results = os_zalloc(sizeof(*results));
if (results == NULL) {
os_free(buf);
return NULL;
}
results->res = os_calloc(num, sizeof(struct wpa_scan_res *));
if (results->res == NULL) {
os_free(results);
os_free(buf);
return NULL;
}
while (results->num < (size_t) num && pos + sizeof(int) < end) {
int len;
os_memcpy(&len, pos, sizeof(int));
pos += sizeof(int);
if (len < 0 || len > 10000 || pos + len > end)
break;
r = os_malloc(len);
if (r == NULL)
break;
os_memcpy(r, pos, len);
pos += len;
if (sizeof(*r) + r->ie_len > (size_t) len) {
os_free(r);
break;
}
results->res[results->num++] = r;
}
os_free(buf);
return results;
}
static int wpa_driver_privsep_set_key(const char *ifname, void *priv,
enum wpa_alg alg, const u8 *addr,
int key_idx, int set_tx,
const u8 *seq, size_t seq_len,
const u8 *key, size_t key_len)
{
struct wpa_driver_privsep_data *drv = priv;
struct privsep_cmd_set_key cmd;
wpa_printf(MSG_DEBUG, "%s: priv=%p alg=%d key_idx=%d set_tx=%d",
__func__, priv, alg, key_idx, set_tx);
os_memset(&cmd, 0, sizeof(cmd));
cmd.alg = alg;
if (addr)
os_memcpy(cmd.addr, addr, ETH_ALEN);
else
os_memset(cmd.addr, 0xff, ETH_ALEN);
cmd.key_idx = key_idx;
cmd.set_tx = set_tx;
if (seq && seq_len > 0 && seq_len < sizeof(cmd.seq)) {
os_memcpy(cmd.seq, seq, seq_len);
cmd.seq_len = seq_len;
}
if (key && key_len > 0 && key_len < sizeof(cmd.key)) {
os_memcpy(cmd.key, key, key_len);
cmd.key_len = key_len;
}
return wpa_priv_cmd(drv, PRIVSEP_CMD_SET_KEY, &cmd, sizeof(cmd),
NULL, NULL);
}
static int wpa_driver_privsep_authenticate(
void *priv, struct wpa_driver_auth_params *params)
{
struct wpa_driver_privsep_data *drv = priv;
struct privsep_cmd_authenticate *data;
int i, res;
size_t buflen;
u8 *pos;
wpa_printf(MSG_DEBUG, "%s: priv=%p freq=%d bssid=" MACSTR
" auth_alg=%d local_state_change=%d p2p=%d",
__func__, priv, params->freq, MAC2STR(params->bssid),
params->auth_alg, params->local_state_change, params->p2p);
buflen = sizeof(*data) + params->ie_len + params->sae_data_len;
data = os_zalloc(buflen);
if (data == NULL)
return -1;
data->freq = params->freq;
os_memcpy(data->bssid, params->bssid, ETH_ALEN);
os_memcpy(data->ssid, params->ssid, params->ssid_len);
data->ssid_len = params->ssid_len;
data->auth_alg = params->auth_alg;
data->ie_len = params->ie_len;
for (i = 0; i < 4; i++) {
if (params->wep_key[i])
os_memcpy(data->wep_key[i], params->wep_key[i],
params->wep_key_len[i]);
data->wep_key_len[i] = params->wep_key_len[i];
}
data->wep_tx_keyidx = params->wep_tx_keyidx;
data->local_state_change = params->local_state_change;
data->p2p = params->p2p;
pos = (u8 *) (data + 1);
if (params->ie_len) {
os_memcpy(pos, params->ie, params->ie_len);
pos += params->ie_len;
}
if (params->sae_data_len)
os_memcpy(pos, params->sae_data, params->sae_data_len);
res = wpa_priv_cmd(drv, PRIVSEP_CMD_AUTHENTICATE, data, buflen,
NULL, NULL);
os_free(data);
return res;
}
static int wpa_driver_privsep_associate(
void *priv, struct wpa_driver_associate_params *params)
{
struct wpa_driver_privsep_data *drv = priv;
struct privsep_cmd_associate *data;
int res;
size_t buflen;
wpa_printf(MSG_DEBUG, "%s: priv=%p freq=%d pairwise_suite=%d "
"group_suite=%d key_mgmt_suite=%d auth_alg=%d mode=%d",
__func__, priv, params->freq.freq, params->pairwise_suite,
params->group_suite, params->key_mgmt_suite,
params->auth_alg, params->mode);
buflen = sizeof(*data) + params->wpa_ie_len;
data = os_zalloc(buflen);
if (data == NULL)
return -1;
if (params->bssid)
os_memcpy(data->bssid, params->bssid, ETH_ALEN);
os_memcpy(data->ssid, params->ssid, params->ssid_len);
data->ssid_len = params->ssid_len;
data->hwmode = params->freq.mode;
data->freq = params->freq.freq;
data->channel = params->freq.channel;
data->pairwise_suite = params->pairwise_suite;
data->group_suite = params->group_suite;
data->key_mgmt_suite = params->key_mgmt_suite;
data->auth_alg = params->auth_alg;
data->mode = params->mode;
data->wpa_ie_len = params->wpa_ie_len;
if (params->wpa_ie)
os_memcpy(data + 1, params->wpa_ie, params->wpa_ie_len);
/* TODO: add support for other assoc parameters */
res = wpa_priv_cmd(drv, PRIVSEP_CMD_ASSOCIATE, data, buflen,
NULL, NULL);
os_free(data);
return res;
}
static int wpa_driver_privsep_get_bssid(void *priv, u8 *bssid)
{
struct wpa_driver_privsep_data *drv = priv;
int res;
size_t len = ETH_ALEN;
res = wpa_priv_cmd(drv, PRIVSEP_CMD_GET_BSSID, NULL, 0, bssid, &len);
if (res < 0 || len != ETH_ALEN)
return -1;
return 0;
}
static int wpa_driver_privsep_get_ssid(void *priv, u8 *ssid)
{
struct wpa_driver_privsep_data *drv = priv;
int res, ssid_len;
u8 reply[sizeof(int) + SSID_MAX_LEN];
size_t len = sizeof(reply);
res = wpa_priv_cmd(drv, PRIVSEP_CMD_GET_SSID, NULL, 0, reply, &len);
if (res < 0 || len < sizeof(int))
return -1;
os_memcpy(&ssid_len, reply, sizeof(int));
if (ssid_len < 0 || ssid_len > SSID_MAX_LEN ||
sizeof(int) + ssid_len > len) {
wpa_printf(MSG_DEBUG, "privsep: Invalid get SSID reply");
return -1;
}
os_memcpy(ssid, &reply[sizeof(int)], ssid_len);
return ssid_len;
}
static int wpa_driver_privsep_deauthenticate(void *priv, const u8 *addr,
int reason_code)
{
//struct wpa_driver_privsep_data *drv = priv;
wpa_printf(MSG_DEBUG, "%s addr=" MACSTR " reason_code=%d",
__func__, MAC2STR(addr), reason_code);
wpa_printf(MSG_DEBUG, "%s - TODO", __func__);
return 0;
}
static void wpa_driver_privsep_event_auth(void *ctx, u8 *buf, size_t len)
{
union wpa_event_data data;
struct privsep_event_auth *auth;
os_memset(&data, 0, sizeof(data));
if (len < sizeof(*auth))
return;
auth = (struct privsep_event_auth *) buf;
if (len < sizeof(*auth) + auth->ies_len)
return;
os_memcpy(data.auth.peer, auth->peer, ETH_ALEN);
os_memcpy(data.auth.bssid, auth->bssid, ETH_ALEN);
data.auth.auth_type = auth->auth_type;
data.auth.auth_transaction = auth->auth_transaction;
data.auth.status_code = auth->status_code;
if (auth->ies_len) {
data.auth.ies = (u8 *) (auth + 1);
data.auth.ies_len = auth->ies_len;
}
wpa_supplicant_event(ctx, EVENT_AUTH, &data);
}
static void wpa_driver_privsep_event_assoc(void *ctx,
enum wpa_event_type event,
u8 *buf, size_t len)
{
union wpa_event_data data;
int inc_data = 0;
u8 *pos, *end;
int ie_len;
os_memset(&data, 0, sizeof(data));
pos = buf;
end = buf + len;
if (end - pos < (int) sizeof(int))
return;
os_memcpy(&ie_len, pos, sizeof(int));
pos += sizeof(int);
if (ie_len < 0 || ie_len > end - pos)
return;
if (ie_len) {
data.assoc_info.req_ies = pos;
data.assoc_info.req_ies_len = ie_len;
pos += ie_len;
inc_data = 1;
}
wpa_supplicant_event(ctx, event, inc_data ? &data : NULL);
}
static void wpa_driver_privsep_event_interface_status(void *ctx, u8 *buf,
size_t len)
{
union wpa_event_data data;
int ievent;
if (len < sizeof(int) ||
len - sizeof(int) > sizeof(data.interface_status.ifname))
return;
os_memcpy(&ievent, buf, sizeof(int));
os_memset(&data, 0, sizeof(data));
data.interface_status.ievent = ievent;
os_memcpy(data.interface_status.ifname, buf + sizeof(int),
len - sizeof(int));
wpa_supplicant_event(ctx, EVENT_INTERFACE_STATUS, &data);
}
static void wpa_driver_privsep_event_michael_mic_failure(
void *ctx, u8 *buf, size_t len)
{
union wpa_event_data data;
if (len != sizeof(int))
return;
os_memset(&data, 0, sizeof(data));
os_memcpy(&data.michael_mic_failure.unicast, buf, sizeof(int));
wpa_supplicant_event(ctx, EVENT_MICHAEL_MIC_FAILURE, &data);
}
static void wpa_driver_privsep_event_pmkid_candidate(void *ctx, u8 *buf,
size_t len)
{
union wpa_event_data data;
if (len != sizeof(struct pmkid_candidate))
return;
os_memset(&data, 0, sizeof(data));
os_memcpy(&data.pmkid_candidate, buf, len);
wpa_supplicant_event(ctx, EVENT_PMKID_CANDIDATE, &data);
}
static void wpa_driver_privsep_event_stkstart(void *ctx, u8 *buf, size_t len)
{
union wpa_event_data data;
if (len != ETH_ALEN)
return;
os_memset(&data, 0, sizeof(data));
os_memcpy(data.stkstart.peer, buf, ETH_ALEN);
wpa_supplicant_event(ctx, EVENT_STKSTART, &data);
}
static void wpa_driver_privsep_event_ft_response(void *ctx, u8 *buf,
size_t len)
{
union wpa_event_data data;
if (len < sizeof(int) + ETH_ALEN)
return;
os_memset(&data, 0, sizeof(data));
os_memcpy(&data.ft_ies.ft_action, buf, sizeof(int));
os_memcpy(data.ft_ies.target_ap, buf + sizeof(int), ETH_ALEN);
data.ft_ies.ies = buf + sizeof(int) + ETH_ALEN;
data.ft_ies.ies_len = len - sizeof(int) - ETH_ALEN;
wpa_supplicant_event(ctx, EVENT_FT_RESPONSE, &data);
}
static void wpa_driver_privsep_event_rx_eapol(void *ctx, u8 *buf, size_t len)
{
if (len < ETH_ALEN)
return;
drv_event_eapol_rx(ctx, buf, buf + ETH_ALEN, len - ETH_ALEN);
}
static void wpa_driver_privsep_receive(int sock, void *eloop_ctx,
void *sock_ctx)
{
struct wpa_driver_privsep_data *drv = eloop_ctx;
u8 *buf, *event_buf;
size_t event_len;
int res, event;
enum privsep_event e;
struct sockaddr_un from;
socklen_t fromlen = sizeof(from);
const size_t buflen = 2000;
buf = os_malloc(buflen);
if (buf == NULL)
return;
res = recvfrom(sock, buf, buflen, 0,
(struct sockaddr *) &from, &fromlen);
if (res < 0) {
wpa_printf(MSG_ERROR, "recvfrom(priv_socket): %s",
strerror(errno));
os_free(buf);
return;
}
wpa_printf(MSG_DEBUG, "privsep_driver: received %u bytes", res);
if (res < (int) sizeof(int)) {
wpa_printf(MSG_DEBUG, "Too short event message (len=%d)", res);
return;
}
os_memcpy(&event, buf, sizeof(int));
event_buf = &buf[sizeof(int)];
event_len = res - sizeof(int);
wpa_printf(MSG_DEBUG, "privsep: Event %d received (len=%lu)",
event, (unsigned long) event_len);
e = event;
switch (e) {
case PRIVSEP_EVENT_SCAN_RESULTS:
wpa_supplicant_event(drv->ctx, EVENT_SCAN_RESULTS, NULL);
break;
case PRIVSEP_EVENT_SCAN_STARTED:
wpa_supplicant_event(drv->ctx, EVENT_SCAN_STARTED, NULL);
break;
case PRIVSEP_EVENT_ASSOC:
wpa_driver_privsep_event_assoc(drv->ctx, EVENT_ASSOC,
event_buf, event_len);
break;
case PRIVSEP_EVENT_DISASSOC:
wpa_supplicant_event(drv->ctx, EVENT_DISASSOC, NULL);
break;
case PRIVSEP_EVENT_ASSOCINFO:
wpa_driver_privsep_event_assoc(drv->ctx, EVENT_ASSOCINFO,
event_buf, event_len);
break;
case PRIVSEP_EVENT_MICHAEL_MIC_FAILURE:
wpa_driver_privsep_event_michael_mic_failure(
drv->ctx, event_buf, event_len);
break;
case PRIVSEP_EVENT_INTERFACE_STATUS:
wpa_driver_privsep_event_interface_status(drv->ctx, event_buf,
event_len);
break;
case PRIVSEP_EVENT_PMKID_CANDIDATE:
wpa_driver_privsep_event_pmkid_candidate(drv->ctx, event_buf,
event_len);
break;
case PRIVSEP_EVENT_STKSTART:
wpa_driver_privsep_event_stkstart(drv->ctx, event_buf,
event_len);
break;
case PRIVSEP_EVENT_FT_RESPONSE:
wpa_driver_privsep_event_ft_response(drv->ctx, event_buf,
event_len);
break;
case PRIVSEP_EVENT_RX_EAPOL:
wpa_driver_privsep_event_rx_eapol(drv->ctx, event_buf,
event_len);
break;
case PRIVSEP_EVENT_AUTH:
wpa_driver_privsep_event_auth(drv->ctx, event_buf, event_len);
break;
}
os_free(buf);
}
static void * wpa_driver_privsep_init(void *ctx, const char *ifname)
{
struct wpa_driver_privsep_data *drv;
drv = os_zalloc(sizeof(*drv));
if (drv == NULL)
return NULL;
drv->ctx = ctx;
drv->priv_socket = -1;
drv->cmd_socket = -1;
os_strlcpy(drv->ifname, ifname, sizeof(drv->ifname));
return drv;
}
static void wpa_driver_privsep_deinit(void *priv)
{
struct wpa_driver_privsep_data *drv = priv;
if (drv->priv_socket >= 0) {
wpa_priv_reg_cmd(drv, PRIVSEP_CMD_UNREGISTER);
eloop_unregister_read_sock(drv->priv_socket);
close(drv->priv_socket);
}
if (drv->own_socket_path) {
unlink(drv->own_socket_path);
os_free(drv->own_socket_path);
}
if (drv->cmd_socket >= 0) {
eloop_unregister_read_sock(drv->cmd_socket);
close(drv->cmd_socket);
}
if (drv->own_cmd_path) {
unlink(drv->own_cmd_path);
os_free(drv->own_cmd_path);
}
os_free(drv);
}
static int wpa_driver_privsep_set_param(void *priv, const char *param)
{
struct wpa_driver_privsep_data *drv = priv;
const char *pos;
char *own_dir, *priv_dir;
static unsigned int counter = 0;
size_t len;
struct sockaddr_un addr;
wpa_printf(MSG_DEBUG, "%s: param='%s'", __func__, param);
if (param == NULL)
pos = NULL;
else
pos = os_strstr(param, "own_dir=");
if (pos) {
char *end;
own_dir = os_strdup(pos + 8);
if (own_dir == NULL)
return -1;
end = os_strchr(own_dir, ' ');
if (end)
*end = '\0';
} else {
own_dir = os_strdup("/tmp");
if (own_dir == NULL)
return -1;
}
if (param == NULL)
pos = NULL;
else
pos = os_strstr(param, "priv_dir=");
if (pos) {
char *end;
priv_dir = os_strdup(pos + 9);
if (priv_dir == NULL) {
os_free(own_dir);
return -1;
}
end = os_strchr(priv_dir, ' ');
if (end)
*end = '\0';
} else {
priv_dir = os_strdup("/var/run/wpa_priv");
if (priv_dir == NULL) {
os_free(own_dir);
return -1;
}
}
len = os_strlen(own_dir) + 50;
drv->own_socket_path = os_malloc(len);
if (drv->own_socket_path == NULL) {
os_free(priv_dir);
os_free(own_dir);
return -1;
}
os_snprintf(drv->own_socket_path, len, "%s/wpa_privsep-%d-%d",
own_dir, getpid(), counter++);
len = os_strlen(own_dir) + 50;
drv->own_cmd_path = os_malloc(len);
if (drv->own_cmd_path == NULL) {
os_free(drv->own_socket_path);
drv->own_socket_path = NULL;
os_free(priv_dir);
os_free(own_dir);
return -1;
}
os_snprintf(drv->own_cmd_path, len, "%s/wpa_privsep-%d-%d",
own_dir, getpid(), counter++);
os_free(own_dir);
drv->priv_addr.sun_family = AF_UNIX;
os_snprintf(drv->priv_addr.sun_path, sizeof(drv->priv_addr.sun_path),
"%s/%s", priv_dir, drv->ifname);
os_free(priv_dir);
drv->priv_socket = socket(PF_UNIX, SOCK_DGRAM, 0);
if (drv->priv_socket < 0) {
wpa_printf(MSG_ERROR, "socket(PF_UNIX): %s", strerror(errno));
os_free(drv->own_socket_path);
drv->own_socket_path = NULL;
return -1;
}
os_memset(&addr, 0, sizeof(addr));
addr.sun_family = AF_UNIX;
os_strlcpy(addr.sun_path, drv->own_socket_path, sizeof(addr.sun_path));
if (bind(drv->priv_socket, (struct sockaddr *) &addr, sizeof(addr)) <
0) {
wpa_printf(MSG_ERROR,
"privsep-set-params priv-sock: bind(PF_UNIX): %s",
strerror(errno));
close(drv->priv_socket);
drv->priv_socket = -1;
unlink(drv->own_socket_path);
os_free(drv->own_socket_path);
drv->own_socket_path = NULL;
return -1;
}
eloop_register_read_sock(drv->priv_socket, wpa_driver_privsep_receive,
drv, NULL);
drv->cmd_socket = socket(PF_UNIX, SOCK_DGRAM, 0);
if (drv->cmd_socket < 0) {
wpa_printf(MSG_ERROR, "socket(PF_UNIX): %s", strerror(errno));
os_free(drv->own_cmd_path);
drv->own_cmd_path = NULL;
return -1;
}
os_memset(&addr, 0, sizeof(addr));
addr.sun_family = AF_UNIX;
os_strlcpy(addr.sun_path, drv->own_cmd_path, sizeof(addr.sun_path));
if (bind(drv->cmd_socket, (struct sockaddr *) &addr, sizeof(addr)) < 0)
{
wpa_printf(MSG_ERROR,
"privsep-set-params cmd-sock: bind(PF_UNIX): %s",
strerror(errno));
close(drv->cmd_socket);
drv->cmd_socket = -1;
unlink(drv->own_cmd_path);
os_free(drv->own_cmd_path);
drv->own_cmd_path = NULL;
return -1;
}
if (wpa_priv_reg_cmd(drv, PRIVSEP_CMD_REGISTER) < 0) {
wpa_printf(MSG_ERROR, "Failed to register with wpa_priv");
return -1;
}
return 0;
}
static int wpa_driver_privsep_get_capa(void *priv,
struct wpa_driver_capa *capa)
{
struct wpa_driver_privsep_data *drv = priv;
int res;
size_t len = sizeof(*capa);
res = wpa_priv_cmd(drv, PRIVSEP_CMD_GET_CAPA, NULL, 0, capa, &len);
if (res < 0 || len != sizeof(*capa))
return -1;
/* For now, no support for passing extended_capa pointers */
capa->extended_capa = NULL;
capa->extended_capa_mask = NULL;
capa->extended_capa_len = 0;
return 0;
}
static const u8 * wpa_driver_privsep_get_mac_addr(void *priv)
{
struct wpa_driver_privsep_data *drv = priv;
wpa_printf(MSG_DEBUG, "%s", __func__);
return drv->own_addr;
}
static int wpa_driver_privsep_set_country(void *priv, const char *alpha2)
{
struct wpa_driver_privsep_data *drv = priv;
wpa_printf(MSG_DEBUG, "%s country='%s'", __func__, alpha2);
return wpa_priv_cmd(drv, PRIVSEP_CMD_SET_COUNTRY, alpha2,
os_strlen(alpha2), NULL, NULL);
}
struct wpa_driver_ops wpa_driver_privsep_ops = {
"privsep",
"wpa_supplicant privilege separated driver",
.get_bssid = wpa_driver_privsep_get_bssid,
.get_ssid = wpa_driver_privsep_get_ssid,
.set_key = wpa_driver_privsep_set_key,
.init = wpa_driver_privsep_init,
.deinit = wpa_driver_privsep_deinit,
.set_param = wpa_driver_privsep_set_param,
.scan2 = wpa_driver_privsep_scan,
.deauthenticate = wpa_driver_privsep_deauthenticate,
.authenticate = wpa_driver_privsep_authenticate,
.associate = wpa_driver_privsep_associate,
.get_capa = wpa_driver_privsep_get_capa,
.get_mac_addr = wpa_driver_privsep_get_mac_addr,
.get_scan_results2 = wpa_driver_privsep_get_scan_results2,
.set_country = wpa_driver_privsep_set_country,
};
const struct wpa_driver_ops *const wpa_drivers[] =
{
&wpa_driver_privsep_ops,
NULL
};
|
457458.c | /* $Id$ */
/*
* %ISC_START_LICENSE%
* ---------------------------------------------------------------------
* Copyright 2016, Google, Inc.
* Copyright 2013, Pittsburgh Supercomputing Center
* All rights reserved.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the
* above copyright notice and this permission notice appear in all
* copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
* WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
* AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
* --------------------------------------------------------------------
* %END_LICENSE%
*/
#include <sys/param.h>
#include <stdio.h>
#include <string.h>
#include "pfl/str.h"
char *
pfl_getprocenv(int pid, const char *key)
{
char fn[PATH_MAX], buf[BUFSIZ], *t, *p;
FILE *fp;
int c;
if (snprintf(fn, sizeof(fn), "/proc/%d/environ", pid) == -1)
return (NULL);
fp = fopen(fn, "r");
if (fp == NULL)
return (NULL);
t = buf;
p = NULL;
while ((c = fgetc(fp)) != EOF) {
if (t < buf + sizeof(buf)) {
*t++ = c;
if (c == '\0' && t > buf + 1) {
if ((p = strchr(buf, '=')) != NULL) {
*p++ = '\0';
if (strcmp(buf, key) == 0)
break;
p = NULL;
}
}
}
if (c == '\0')
t = buf;
}
fclose(fp);
return (p ? pfl_strdup(p) : NULL);
}
|
358353.c | #include<stdio.h>
void print_array(int n, int *a){
for(int i=0; i<n; i++)
printf("%d ",*(a+i));
}
void section_sort(int *a,int n)
{
for(int i=0;i<n;i++)
{
int min_index=i;
for(int j=i+1;j<n;j++)
if(*(a+j)<*(a+min_index))
min_index=j;
int temp=*(a+i);
*(a+i)=*(a+min_index);
*(a+min_index)=temp;
}
}
int main()
{
printf("Enter the number of elements you wants : ");
int n;
scanf("%d",&n);
int a[n];
printf("Eenter elements : ");
for(int i=0;i<n;i++)
scanf("%d",&a[i]);
printf("-------------------------------\n");
printf("Array :\n");
for(int i=0;i<n;i++)
printf("%d ",a[i]);
section_sort(a,n);
printf("\n-------------------------------");
printf("\nSorted Array :\n");
print_array(n, a);
printf("\n-------------------------------\n");
return 0;
}
|
659886.c | /* ------------------------------------------
* Copyright (c) 2016, Synopsys, Inc. All rights reserved.
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
* 1) Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2) Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
* 3) Neither the name of the Synopsys, Inc., nor the names of its contributors may
* be used to endorse or promote products derived from this software without
* specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* \version 2016.05
* \date 2014-07-31
* \author Wayne Ren([email protected])
--------------------------------------------- */
/**
* \defgroup BOARD_EMSK_COMMON_INIT EMSK Common Init Module
* \ingroup BOARD_EMSK_COMMON
* \brief EMSK Board Common Init Module
* \details
* EMSK timer/gpio/interrupt init process. Device-driver installation is done while
* getting the device object for the first time.
*/
/**
* \file
* \ingroup BOARD_EMSK_COMMON_INIT
* \brief common emsk init module
*/
/**
* \addtogroup BOARD_EMSK_COMMON_INIT
* @{
*/
#include "inc/arc/arc_builtin.h"
#include "inc/arc/arc.h"
#include "inc/arc/arc_timer.h"
#include "board/emsk/emsk.h"
#include "board/emsk/common/emsk_timer.h"
#include "board/emsk/common/mux.h"
#ifdef ARC_FEATURE_DMP_PERIPHERAL
#define PERIPHERAL_BASE ARC_FEATURE_DMP_PERIPHERAL
#else
#define PERIPHERAL_BASE _arc_aux_read(AUX_DMP_PERIPHERAL)
#endif
/**
* \brief emsk-related mux io init
*/
static void emsk_mux_init(void)
{
MUX_REG *mux_regs;
mux_regs = (MUX_REG *)(PERIPHERAL_BASE | REL_REGBASE_PINMUX);
mux_init(mux_regs);
/**
* + Please refer to corresponding EMSK User Guide for detailed information
* -> Appendix: A Hardware Functional Description
* -> Pmods Configuration summary
* + Set up pin-multiplexer of all PMOD connections
* - PM1 J1: Upper row as UART 0, lower row as SPI Slave
* - PM2 J2: IIC 0 and run/halt signals
* - PM3 J3: GPIO Port A and Port C
* - PM4 J4: IIC 1 and Port D
* - PM5 J5: Upper row as SPI Master, lower row as Port A
* - PM6 J6: Upper row as SPI Master, lower row as Port A
*/
set_pmod_mux(mux_regs, PM1_UR_UART_0 | PM1_LR_SPI_S \
| PM2_I2C_HRI \
| PM3_GPIO_AC \
| PM4_I2C_GPIO_D \
| PM5_UR_SPI_M1 | PM5_LR_GPIO_A \
| PM6_UR_SPI_M0 | PM6_LR_GPIO_A);
/**
* PM1 upper row as UART
* UM4:RXD, UM3:TXD
* UM2:RTS_N, UM1:CTS_N
*/
set_uart_map(mux_regs, 0x9c);
}
/**
* \brief Board init routine MUST be called in each application
* \note It is better to disable interrupts when calling this function
* remember to enable interrupt when you want to use them
*/
void board_init(void)
{
timer_init();
emsk_mux_init();
emsk_gpio_init();
emsk_timer_init();
}
/** @} end of group BOARD_EMSK_COMMON_INIT */
|
118101.c | /******************************************************************************
*
* Module Name: evgpeutil - GPE utilities
*
*****************************************************************************/
/*
* Copyright (C) 2000 - 2017, Intel Corp.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* Alternatively, this software may be distributed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
* NO WARRANTY
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGES.
*/
#include "acpi.h"
#include "accommon.h"
#include "acevents.h"
#define _COMPONENT ACPI_EVENTS
ACPI_MODULE_NAME ("evgpeutil")
#if (!ACPI_REDUCED_HARDWARE) /* Entire module */
/*******************************************************************************
*
* FUNCTION: AcpiEvWalkGpeList
*
* PARAMETERS: GpeWalkCallback - Routine called for each GPE block
* Context - Value passed to callback
*
* RETURN: Status
*
* DESCRIPTION: Walk the GPE lists.
*
******************************************************************************/
ACPI_STATUS
AcpiEvWalkGpeList (
ACPI_GPE_CALLBACK GpeWalkCallback,
void *Context)
{
ACPI_GPE_BLOCK_INFO *GpeBlock;
ACPI_GPE_XRUPT_INFO *GpeXruptInfo;
ACPI_STATUS Status = AE_OK;
ACPI_CPU_FLAGS Flags;
ACPI_FUNCTION_TRACE (EvWalkGpeList);
Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
/* Walk the interrupt level descriptor list */
GpeXruptInfo = AcpiGbl_GpeXruptListHead;
while (GpeXruptInfo)
{
/* Walk all Gpe Blocks attached to this interrupt level */
GpeBlock = GpeXruptInfo->GpeBlockListHead;
while (GpeBlock)
{
/* One callback per GPE block */
Status = GpeWalkCallback (GpeXruptInfo, GpeBlock, Context);
if (ACPI_FAILURE (Status))
{
if (Status == AE_CTRL_END) /* Callback abort */
{
Status = AE_OK;
}
goto UnlockAndExit;
}
GpeBlock = GpeBlock->Next;
}
GpeXruptInfo = GpeXruptInfo->Next;
}
UnlockAndExit:
AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
return_ACPI_STATUS (Status);
}
/*******************************************************************************
*
* FUNCTION: AcpiEvGetGpeDevice
*
* PARAMETERS: GPE_WALK_CALLBACK
*
* RETURN: Status
*
* DESCRIPTION: Matches the input GPE index (0-CurrentGpeCount) with a GPE
* block device. NULL if the GPE is one of the FADT-defined GPEs.
*
******************************************************************************/
ACPI_STATUS
AcpiEvGetGpeDevice (
ACPI_GPE_XRUPT_INFO *GpeXruptInfo,
ACPI_GPE_BLOCK_INFO *GpeBlock,
void *Context)
{
ACPI_GPE_DEVICE_INFO *Info = Context;
/* Increment Index by the number of GPEs in this block */
Info->NextBlockBaseIndex += GpeBlock->GpeCount;
if (Info->Index < Info->NextBlockBaseIndex)
{
/*
* The GPE index is within this block, get the node. Leave the node
* NULL for the FADT-defined GPEs
*/
if ((GpeBlock->Node)->Type == ACPI_TYPE_DEVICE)
{
Info->GpeDevice = GpeBlock->Node;
}
Info->Status = AE_OK;
return (AE_CTRL_END);
}
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: AcpiEvGetGpeXruptBlock
*
* PARAMETERS: InterruptNumber - Interrupt for a GPE block
* GpeXruptBlock - Where the block is returned
*
* RETURN: Status
*
* DESCRIPTION: Get or Create a GPE interrupt block. There is one interrupt
* block per unique interrupt level used for GPEs. Should be
* called only when the GPE lists are semaphore locked and not
* subject to change.
*
******************************************************************************/
ACPI_STATUS
AcpiEvGetGpeXruptBlock (
UINT32 InterruptNumber,
ACPI_GPE_XRUPT_INFO **GpeXruptBlock)
{
ACPI_GPE_XRUPT_INFO *NextGpeXrupt;
ACPI_GPE_XRUPT_INFO *GpeXrupt;
ACPI_STATUS Status;
ACPI_CPU_FLAGS Flags;
ACPI_FUNCTION_TRACE (EvGetGpeXruptBlock);
/* No need for lock since we are not changing any list elements here */
NextGpeXrupt = AcpiGbl_GpeXruptListHead;
while (NextGpeXrupt)
{
if (NextGpeXrupt->InterruptNumber == InterruptNumber)
{
*GpeXruptBlock = NextGpeXrupt;
return_ACPI_STATUS (AE_OK);
}
NextGpeXrupt = NextGpeXrupt->Next;
}
/* Not found, must allocate a new xrupt descriptor */
GpeXrupt = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_GPE_XRUPT_INFO));
if (!GpeXrupt)
{
return_ACPI_STATUS (AE_NO_MEMORY);
}
GpeXrupt->InterruptNumber = InterruptNumber;
/* Install new interrupt descriptor with spin lock */
Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
if (AcpiGbl_GpeXruptListHead)
{
NextGpeXrupt = AcpiGbl_GpeXruptListHead;
while (NextGpeXrupt->Next)
{
NextGpeXrupt = NextGpeXrupt->Next;
}
NextGpeXrupt->Next = GpeXrupt;
GpeXrupt->Previous = NextGpeXrupt;
}
else
{
AcpiGbl_GpeXruptListHead = GpeXrupt;
}
AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
/* Install new interrupt handler if not SCI_INT */
if (InterruptNumber != AcpiGbl_FADT.SciInterrupt)
{
Status = AcpiOsInstallInterruptHandler (InterruptNumber,
AcpiEvGpeXruptHandler, GpeXrupt);
if (ACPI_FAILURE (Status))
{
ACPI_EXCEPTION ((AE_INFO, Status,
"Could not install GPE interrupt handler at level 0x%X",
InterruptNumber));
return_ACPI_STATUS (Status);
}
}
*GpeXruptBlock = GpeXrupt;
return_ACPI_STATUS (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: AcpiEvDeleteGpeXrupt
*
* PARAMETERS: GpeXrupt - A GPE interrupt info block
*
* RETURN: Status
*
* DESCRIPTION: Remove and free a GpeXrupt block. Remove an associated
* interrupt handler if not the SCI interrupt.
*
******************************************************************************/
ACPI_STATUS
AcpiEvDeleteGpeXrupt (
ACPI_GPE_XRUPT_INFO *GpeXrupt)
{
ACPI_STATUS Status;
ACPI_CPU_FLAGS Flags;
ACPI_FUNCTION_TRACE (EvDeleteGpeXrupt);
/* We never want to remove the SCI interrupt handler */
if (GpeXrupt->InterruptNumber == AcpiGbl_FADT.SciInterrupt)
{
GpeXrupt->GpeBlockListHead = NULL;
return_ACPI_STATUS (AE_OK);
}
/* Disable this interrupt */
Status = AcpiOsRemoveInterruptHandler (
GpeXrupt->InterruptNumber, AcpiEvGpeXruptHandler);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
/* Unlink the interrupt block with lock */
Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
if (GpeXrupt->Previous)
{
GpeXrupt->Previous->Next = GpeXrupt->Next;
}
else
{
/* No previous, update list head */
AcpiGbl_GpeXruptListHead = GpeXrupt->Next;
}
if (GpeXrupt->Next)
{
GpeXrupt->Next->Previous = GpeXrupt->Previous;
}
AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
/* Free the block */
ACPI_FREE (GpeXrupt);
return_ACPI_STATUS (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: AcpiEvDeleteGpeHandlers
*
* PARAMETERS: GpeXruptInfo - GPE Interrupt info
* GpeBlock - Gpe Block info
*
* RETURN: Status
*
* DESCRIPTION: Delete all Handler objects found in the GPE data structs.
* Used only prior to termination.
*
******************************************************************************/
ACPI_STATUS
AcpiEvDeleteGpeHandlers (
ACPI_GPE_XRUPT_INFO *GpeXruptInfo,
ACPI_GPE_BLOCK_INFO *GpeBlock,
void *Context)
{
ACPI_GPE_EVENT_INFO *GpeEventInfo;
ACPI_GPE_NOTIFY_INFO *Notify;
ACPI_GPE_NOTIFY_INFO *Next;
UINT32 i;
UINT32 j;
ACPI_FUNCTION_TRACE (EvDeleteGpeHandlers);
/* Examine each GPE Register within the block */
for (i = 0; i < GpeBlock->RegisterCount; i++)
{
/* Now look at the individual GPEs in this byte register */
for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++)
{
GpeEventInfo = &GpeBlock->EventInfo[((ACPI_SIZE) i *
ACPI_GPE_REGISTER_WIDTH) + j];
if ((ACPI_GPE_DISPATCH_TYPE (GpeEventInfo->Flags) ==
ACPI_GPE_DISPATCH_HANDLER) ||
(ACPI_GPE_DISPATCH_TYPE (GpeEventInfo->Flags) ==
ACPI_GPE_DISPATCH_RAW_HANDLER))
{
/* Delete an installed handler block */
ACPI_FREE (GpeEventInfo->Dispatch.Handler);
GpeEventInfo->Dispatch.Handler = NULL;
GpeEventInfo->Flags &= ~ACPI_GPE_DISPATCH_MASK;
}
else if (ACPI_GPE_DISPATCH_TYPE (GpeEventInfo->Flags) ==
ACPI_GPE_DISPATCH_NOTIFY)
{
/* Delete the implicit notification device list */
Notify = GpeEventInfo->Dispatch.NotifyList;
while (Notify)
{
Next = Notify->Next;
ACPI_FREE (Notify);
Notify = Next;
}
GpeEventInfo->Dispatch.NotifyList = NULL;
GpeEventInfo->Flags &= ~ACPI_GPE_DISPATCH_MASK;
}
}
}
return_ACPI_STATUS (AE_OK);
}
#endif /* !ACPI_REDUCED_HARDWARE */
|
66959.c | /* Copyright 2018 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <stdio.h>
#include <string.h>
#include <inttypes.h>
#include <assert.h>
#include <libpdbg.h>
static int count_target(struct pdbg_target *parent, const char *classname)
{
struct pdbg_target *target;
int n = 0;
pdbg_for_each_target(classname, parent, target) {
n++;
}
return n;
}
static int count_class_target(const char *classname)
{
struct pdbg_target *target;
int n = 0;
pdbg_for_each_class_target(classname, target) {
n++;
}
return n;
}
static int count_child_target(struct pdbg_target *parent)
{
struct pdbg_target *child;
int n = 0;
pdbg_for_each_child_target(parent, child) {
n++;
}
return n;
}
int main(void)
{
struct pdbg_target *root, *target, *parent, *parent2;
const char *name;
int count;
assert(pdbg_set_backend(PDBG_BACKEND_FAKE, NULL));
assert(pdbg_targets_init(NULL));
root = pdbg_target_root();
assert(root);
count = count_class_target("fsi");
assert(count == 8);
count = count_class_target("pib");
assert(count == 8);
count = count_class_target("core");
assert(count == 32);
count = count_class_target("thread");
assert(count == 64);
pdbg_for_each_child_target(root, parent) {
name = pdbg_target_dn_name(parent);
assert(strncmp(name, "proc", 4) == 0);
pdbg_for_each_target("pib", parent, target) {
name = pdbg_target_class_name(target);
assert(!strcmp(name, "pib"));
}
pdbg_for_each_target("fsi", parent, target) {
name = pdbg_target_class_name(target);
assert(!strcmp(name, "fsi"));
}
};
pdbg_for_each_class_target("fsi", target) {
parent = pdbg_target_parent(NULL, target);
assert(parent);
name = pdbg_target_dn_name(parent);
assert(strncmp(name, "proc", 4) == 0);
parent = pdbg_target_parent("fsi", target);
assert(parent == NULL);
parent = pdbg_target_parent("pib", target);
assert(parent == NULL);
parent = pdbg_target_parent("core", target);
assert(parent == NULL);
parent = pdbg_target_parent("thread", target);
assert(parent == NULL);
count = count_child_target(target);
assert(count == 0);
count = count_target(target, "fsi");
assert(count == 1);
count = count_target(target, "pib");
assert(count == 0);
count = count_target(target, "core");
assert(count == 0);
count = count_target(target, "thread");
assert(count == 0);
name = pdbg_target_name(target);
assert(!strcmp(name, "Fake FSI"));
name = pdbg_target_class_name(target);
assert(!strcmp(name, "fsi"));
name = pdbg_target_dn_name(target);
assert(!strncmp(name, "fsi", 3));
}
pdbg_for_each_class_target("pib", target) {
parent = pdbg_target_parent(NULL, target);
assert(parent);
name = pdbg_target_dn_name(parent);
assert(strncmp(name, "proc", 4) == 0);
parent = pdbg_target_parent("fsi", target);
assert(parent == NULL);
parent = pdbg_target_parent("pib", target);
assert(parent == NULL);
parent = pdbg_target_parent("core", target);
assert(parent == NULL);
parent = pdbg_target_parent("thread", target);
assert(parent == NULL);
count = count_child_target(target);
assert(count == 4);
count = count_target(target, "fsi");
assert(count == 0);
count = count_target(target, "pib");
assert(count == 1);
count = count_target(target, "core");
assert(count == 4);
count = count_target(target, "thread");
assert(count == 8);
name = pdbg_target_name(target);
assert(!strcmp(name, "Fake PIB"));
name = pdbg_target_class_name(target);
assert(!strcmp(name, "pib"));
name = pdbg_target_dn_name(target);
assert(!strncmp(name, "pib", 3));
}
pdbg_for_each_class_target("core", target) {
uint64_t addr, size;
uint32_t index;
parent = pdbg_target_parent("fsi", target);
assert(parent == NULL);
parent = pdbg_target_parent("pib", target);
assert(parent);
parent2 = pdbg_target_require_parent("pib", target);
assert(parent == parent2);
parent = pdbg_target_parent("core", target);
assert(parent == NULL);
parent = pdbg_target_parent("thread", target);
assert(parent == NULL);
count = count_child_target(target);
assert(count == 2);
count = count_target(target, "fsi");
assert(count == 0);
count = count_target(target, "pib");
assert(count == 0);
count = count_target(target, "core");
assert(count == 1);
count = count_target(target, "thread");
assert(count == 2);
name = pdbg_target_name(target);
assert(!strcmp(name, "Fake Core"));
name = pdbg_target_class_name(target);
assert(!strcmp(name, "core"));
name = pdbg_target_dn_name(target);
assert(!strncmp(name, "core", 4));
index = pdbg_target_index(target);
addr = pdbg_target_address(target, &size);
assert(size == 0);
assert(addr == 0x10000 + (index + 1)*0x10);
}
pdbg_for_each_class_target("thread", target) {
parent = pdbg_target_parent("fsi", target);
assert(parent == NULL);
parent = pdbg_target_parent("pib", target);
assert(parent);
parent2 = pdbg_target_require_parent("pib", target);
assert(parent == parent2);
parent = pdbg_target_parent("core", target);
assert(parent);
parent2 = pdbg_target_require_parent("core", target);
assert(parent == parent2);
parent = pdbg_target_parent("thread", target);
assert(parent == NULL);
count = count_child_target(target);
assert(count == 0);
count = count_target(target, "fsi");
assert(count == 0);
count = count_target(target, "pib");
assert(count == 0);
count = count_target(target, "core");
assert(count == 0);
count = count_target(target, "thread");
assert(count == 1);
name = pdbg_target_name(target);
assert(!strcmp(name, "Fake Thread"));
name = pdbg_target_class_name(target);
assert(!strcmp(name, "thread"));
name = pdbg_target_dn_name(target);
assert(!strncmp(name, "thread", 6));
}
return 0;
}
|
511929.c | #include<stdio.h>
void merge(int arr[], int l, int m, int r)
{
int i, j, k;
int n1 = m - l + 1;
int n2 = r - m;
/* create temp arrays */
int L[n1], R[n2];
/* Copy data to temp arrays L[] and R[] */
for (i = 0; i < n1; i++)
L[i] = arr[l + i];
for (j = 0; j < n2; j++)
R[j] = arr[m + 1+ j];
/* Merge the temp arrays back into arr[l..r]*/
i = 0; // Initial index of first subarray
j = 0; // Initial index of second subarray
k = l; // Initial index of merged subarray
while (i < n1 && j < n2)
{
if (L[i] <= R[j])
{
arr[k] = L[i];
i++;
}
else
{
arr[k] = R[j];
j++;
}
k++;
}
/* Copy the remaining elements of L[], if there
are any */
while (i < n1)
{
arr[k] = L[i];
i++;
k++;
}
/* Copy the remaining elements of R[], if there
are any */
while (j < n2)
{
arr[k] = R[j];
j++;
k++;
}
}
/* l is for left index and r is right index of the
sub-array of arr to be sorted */
void mergeSort(int arr[], int l, int r)
{
if (l < r)
{
// Same as (l+r)/2, but avoids overflow for
// large l and h
int m = l+(r-l)/2;
// Sort first and second halves
mergeSort(arr, l, m);
mergeSort(arr, m+1, r);
merge(arr, l, m, r);
}
}
int main()
{
int n,num[1000000];
scanf("%d",&n);
int i;
for(i=0;i<n;i++)
scanf("%d",&num[i]);
int j,l;
mergeSort(num,0,n-1);
int q;
scanf("%d",&q);
int quer;
for(i=0;i<q;i++)
{
int low=0;
int high=n;
int mid=(high+low)/2;
scanf("%d",&quer);
while(low<=high)
{
if(quer<num[0])
{
printf("%d\n",num[0]);
break;
}
else if(quer>num[n-1])
{
printf("0\n");
break;
}
else if(quer==num[mid])
{
printf("%d\n",num[mid]);
break;
}
else if(quer>num[mid])
{
low=mid+1;
if(quer<num[mid+1] && quer>num[mid])
{
printf("%d\n",num[mid+1]);
break;
}
}
else if(quer<num[mid])
{
high=mid-1;
if(quer>num[mid-1]&& quer<num[mid])
{
printf("%d\n",num[mid]);
break;
}
}
mid=(high+low)/2;
}
}
return 0;
}
|
239964.c | /* Copyright (c) 2010-2013, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include <hdmi.h>
#include <msm_panel.h>
#include <platform/timer.h>
#include <platform/clock.h>
#include <platform/iomap.h>
#define MDP4_OVERLAYPROC1_BASE 0x18000
#define MDP4_RGB_BASE 0x40000
#define MDP4_RGB_OFF 0x10000
struct hdmi_disp_mode_timing_type hdmi_timing_default = {
.height = 1080,
.hsync_porch_fp = 88,
.hsync_width = 44,
.hsync_porch_bp = 148,
.width = 1920,
.vsync_porch_fp = 4,
.vsync_width = 5,
.vsync_porch_bp = 36,
.bpp = 24,
};
static uint8_t hdmi_msm_avi_iframe_lut[][16] = {
/* 480p60 480i60 576p50 576i50 720p60 720p50 1080p60 1080i60 1080p50
1080i50 1080p24 1080p30 1080p25 640x480p 480p60_16_9 576p50_4_3 */
{0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10}, /*00*/
{0x18, 0x18, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28,
0x28, 0x28, 0x28, 0x28, 0x18, 0x28, 0x18}, /*01*/
{0x00, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
0x04, 0x04, 0x04, 0x04, 0x88, 0x00, 0x04}, /*02*/
{0x02, 0x06, 0x11, 0x15, 0x04, 0x13, 0x10, 0x05, 0x1F,
0x14, 0x20, 0x22, 0x21, 0x01, 0x03, 0x11}, /*03*/
{0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*04*/
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*05*/
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*06*/
{0xE1, 0xE1, 0x41, 0x41, 0xD1, 0xd1, 0x39, 0x39, 0x39,
0x39, 0x39, 0x39, 0x39, 0xe1, 0xE1, 0x41}, /*07*/
{0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x04, 0x04, 0x04,
0x04, 0x04, 0x04, 0x04, 0x01, 0x01, 0x02}, /*08*/
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*09*/
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*10*/
{0xD1, 0xD1, 0xD1, 0xD1, 0x01, 0x01, 0x81, 0x81, 0x81,
0x81, 0x81, 0x81, 0x81, 0x81, 0xD1, 0xD1}, /*11*/
{0x02, 0x02, 0x02, 0x02, 0x05, 0x05, 0x07, 0x07, 0x07,
0x07, 0x07, 0x07, 0x07, 0x02, 0x02, 0x02} /*12*/
};
void hdmi_msm_set_mode(int on)
{
uint32_t val = 0;
if (on) {
val |= 0x00000003;
writel(val, HDMI_CTRL);
} else {
val &= ~0x00000002;
writel(val, HDMI_CTRL);
}
}
struct hdmi_disp_mode_timing_type *hdmi_common_init_panel_info()
{
return &hdmi_timing_default;
}
void hdmi_set_fb_addr(void *addr)
{
hdmi_timing_default.base = addr;
}
void hdmi_msm_panel_init(struct msm_panel_info *pinfo)
{
if (!pinfo)
return;
pinfo->xres = hdmi_timing_default.width;
pinfo->yres = hdmi_timing_default.height;
pinfo->bpp = hdmi_timing_default.bpp;
pinfo->type = HDMI_PANEL;
pinfo->hdmi.h_back_porch = hdmi_timing_default.hsync_porch_bp;
pinfo->hdmi.h_front_porch = hdmi_timing_default.hsync_porch_fp;
pinfo->hdmi.h_pulse_width = hdmi_timing_default.hsync_width;
pinfo->hdmi.v_back_porch = hdmi_timing_default.vsync_porch_bp;
pinfo->hdmi.v_front_porch = hdmi_timing_default.vsync_porch_fp;
pinfo->hdmi.v_pulse_width = hdmi_timing_default.vsync_width;
}
void hdmi_frame_ctrl_reg()
{
uint32_t hdmi_frame_ctrl;
hdmi_frame_ctrl = ((0 << 31) & 0x80000000);
hdmi_frame_ctrl |= ((0 << 29) & 0x20000000);
hdmi_frame_ctrl |= ((0 << 28) & 0x10000000);
writel(hdmi_frame_ctrl, HDMI_FRAME_CTRL);
}
void hdmi_video_setup()
{
uint32_t hsync_total = 0;
uint32_t vsync_total = 0;
uint32_t hsync_start = 0;
uint32_t hsync_end = 0;
uint32_t vsync_start = 0;
uint32_t vsync_end = 0;
uint32_t hvsync_total = 0;
uint32_t hsync_active = 0;
uint32_t vsync_active = 0;
uint32_t hdmi_frame_ctrl = 0;
uint32_t val;
struct hdmi_disp_mode_timing_type *hdmi_timing =
hdmi_common_init_panel_info();
hsync_total = hdmi_timing->width + hdmi_timing->hsync_porch_fp
+ hdmi_timing->hsync_porch_bp + hdmi_timing->hsync_width - 1;
vsync_total = hdmi_timing->height + hdmi_timing->vsync_porch_fp
+ hdmi_timing->vsync_porch_bp + hdmi_timing->vsync_width - 1;
hvsync_total = (vsync_total << 16) & 0x0FFF0000;
hvsync_total |= (hsync_total << 0) & 0x00000FFF;
writel(hvsync_total, HDMI_TOTAL);
hsync_start = hdmi_timing->hsync_porch_bp + hdmi_timing->hsync_width;
hsync_end = (hsync_total + 1) - hdmi_timing->hsync_porch_fp;
hsync_active = (hsync_end << 16) & 0x0FFF0000;
hsync_active |= (hsync_start << 0) & 0x00000FFF;
writel(hsync_active, HDMI_ACTIVE_HSYNC);
vsync_start =
hdmi_timing->vsync_porch_bp + hdmi_timing->vsync_width - 1;
vsync_end = vsync_total - hdmi_timing->vsync_porch_fp;
vsync_active = (vsync_end << 16) & 0x0FFF0000;
vsync_active |= (vsync_start << 0) & 0x00000FFF;
writel(vsync_active, HDMI_ACTIVE_VSYNC);
writel(0, HDMI_VSYNC_TOTAL_F2);
writel(0, HDMI_VSYNC_ACTIVE_F2);
hdmi_frame_ctrl_reg();
}
void hdmi_msm_avi_info_frame(void)
{
/* two header + length + 13 data */
uint8_t aviInfoFrame[16];
uint8_t checksum;
uint32_t sum;
uint32_t regVal;
uint8_t i;
uint8_t mode = 6; //HDMI_VFRMT_1920x1080p60_16_9
/* InfoFrame Type = 82 */
aviInfoFrame[0] = 0x82;
/* Version = 2 */
aviInfoFrame[1] = 2;
/* Length of AVI InfoFrame = 13 */
aviInfoFrame[2] = 13;
/* Data Byte 01: 0 Y1 Y0 A0 B1 B0 S1 S0 */
aviInfoFrame[3] = hdmi_msm_avi_iframe_lut[0][mode];
/* Setting underscan bit */
aviInfoFrame[3] |= 0x02;
/* Data Byte 02: C1 C0 M1 M0 R3 R2 R1 R0 */
aviInfoFrame[4] = hdmi_msm_avi_iframe_lut[1][mode];
/* Data Byte 03: ITC EC2 EC1 EC0 Q1 Q0 SC1 SC0 */
aviInfoFrame[5] = hdmi_msm_avi_iframe_lut[2][mode];
/* Data Byte 04: 0 VIC6 VIC5 VIC4 VIC3 VIC2 VIC1 VIC0 */
aviInfoFrame[6] = hdmi_msm_avi_iframe_lut[3][mode];
/* Data Byte 05: 0 0 0 0 PR3 PR2 PR1 PR0 */
aviInfoFrame[7] = hdmi_msm_avi_iframe_lut[4][mode];
/* Data Byte 06: LSB Line No of End of Top Bar */
aviInfoFrame[8] = hdmi_msm_avi_iframe_lut[5][mode];
/* Data Byte 07: MSB Line No of End of Top Bar */
aviInfoFrame[9] = hdmi_msm_avi_iframe_lut[6][mode];
/* Data Byte 08: LSB Line No of Start of Bottom Bar */
aviInfoFrame[10] = hdmi_msm_avi_iframe_lut[7][mode];
/* Data Byte 09: MSB Line No of Start of Bottom Bar */
aviInfoFrame[11] = hdmi_msm_avi_iframe_lut[8][mode];
/* Data Byte 10: LSB Pixel Number of End of Left Bar */
aviInfoFrame[12] = hdmi_msm_avi_iframe_lut[9][mode];
/* Data Byte 11: MSB Pixel Number of End of Left Bar */
aviInfoFrame[13] = hdmi_msm_avi_iframe_lut[10][mode];
/* Data Byte 12: LSB Pixel Number of Start of Right Bar */
aviInfoFrame[14] = hdmi_msm_avi_iframe_lut[11][mode];
/* Data Byte 13: MSB Pixel Number of Start of Right Bar */
aviInfoFrame[15] = hdmi_msm_avi_iframe_lut[12][mode];
sum = 0;
for (i = 0; i < 16; i++)
sum += aviInfoFrame[i];
sum &= 0xFF;
sum = 256 - sum;
checksum = (uint8_t) sum;
regVal = aviInfoFrame[5];
regVal = regVal << 8 | aviInfoFrame[4];
regVal = regVal << 8 | aviInfoFrame[3];
regVal = regVal << 8 | checksum;
writel(regVal, MSM_HDMI_BASE + 0x006C);
regVal = aviInfoFrame[9];
regVal = regVal << 8 | aviInfoFrame[8];
regVal = regVal << 8 | aviInfoFrame[7];
regVal = regVal << 8 | aviInfoFrame[6];
writel(regVal, MSM_HDMI_BASE + 0x0070);
regVal = aviInfoFrame[13];
regVal = regVal << 8 | aviInfoFrame[12];
regVal = regVal << 8 | aviInfoFrame[11];
regVal = regVal << 8 | aviInfoFrame[10];
writel(regVal, MSM_HDMI_BASE + 0x0074);
regVal = aviInfoFrame[1];
regVal = regVal << 16 | aviInfoFrame[15];
regVal = regVal << 8 | aviInfoFrame[14];
writel(regVal, MSM_HDMI_BASE + 0x0078);
/* INFOFRAME_CTRL0[0x002C] */
/* 0x3 for AVI InfFrame enable (every frame) */
writel(readl(0x002C) | 0x00000003L, MSM_HDMI_BASE + 0x002C);
}
void hdmi_app_clk_init(int on)
{
uint32_t val = 0;
if (on) {
/* Enable hdmi apps clock */
val = readl(MISC_CC2_REG);
val = BIT(11);
writel(val, MISC_CC2_REG);
udelay(10);
/* Enable hdmi master clock */
val = readl(MMSS_AHB_EN_REG);
val |= BIT(14);
writel(val, MMSS_AHB_EN_REG);
udelay(10);
/* Enable hdmi slave clock */
val = readl(MMSS_AHB_EN_REG);
val |= BIT(4);
writel(val, MMSS_AHB_EN_REG);
udelay(10);
} else {
// Disable clocks
val = readl(MISC_CC2_REG);
val &= ~(BIT(11));
writel(val, MISC_CC2_REG);
udelay(10);
val = readl(MMSS_AHB_EN_REG);
val &= ~(BIT(14));
writel(val, MMSS_AHB_EN_REG);
udelay(10);
val = readl(MMSS_AHB_EN_REG);
val &= ~(BIT(4));
writel(val, MMSS_AHB_EN_REG);
udelay(10);
}
}
int hdmi_msm_turn_on(void)
{
uint32_t hotplug_control;
hdmi_msm_set_mode(0);
hdmi_msm_reset_core(); // Reset the core
hdmi_msm_init_phy();
// Enable USEC REF timer
writel(0x0001001B, HDMI_USEC_REFTIMER);
// Write 1 to HDMI_CTRL to enable HDMI
hdmi_msm_set_mode(1);
// Video setup for HDMI
hdmi_video_setup();
// AVI info setup
hdmi_msm_avi_info_frame();
return 0;
}
int hdmi_dtv_init()
{
uint32_t hsync_period;
uint32_t hsync_ctrl;
uint32_t hsync_start_x;
uint32_t hsync_end_x;
uint32_t display_hctl;
uint32_t vsync_period;
uint32_t display_v_start;
uint32_t display_v_end;
uint32_t hsync_polarity;
uint32_t vsync_polarity;
uint32_t data_en_polarity;
uint32_t ctrl_polarity;
uint32_t dtv_border_clr = 0;
uint32_t dtv_underflow_clr = 0;
uint32_t active_v_start = 0;
uint32_t active_v_end = 0;
uint32_t dtv_hsync_skew = 0;
uint32_t intf, stage, snum, mask, data;
unsigned char *rgb_base;
unsigned char *overlay_base;
uint32_t val;
struct hdmi_disp_mode_timing_type *timing =
hdmi_common_init_panel_info();
// MDP E config
writel((unsigned)timing->base, MDP_BASE + 0xb0008); //FB Address
writel(((timing->height << 16) | timing->width), MDP_BASE + 0xb0004);
writel((timing->width * timing->bpp / 8), MDP_BASE + 0xb000c);
writel(0, MDP_BASE + 0xb0010);
writel(DMA_PACK_PATTERN_RGB | DMA_DSTC0G_8BITS | DMA_DSTC1B_8BITS |
DMA_DSTC2R_8BITS, MDP_BASE + 0xb0000);
writel(0xff0000, MDP_BASE + 0xb0070);
writel(0xff0000, MDP_BASE + 0xb0074);
writel(0xff0000, MDP_BASE + 0xb0078);
// overlay rgb setup RGB2
rgb_base = MDP_BASE + MDP4_RGB_BASE;
rgb_base += (MDP4_RGB_OFF * 1);
writel(((timing->height << 16) | timing->width), rgb_base + 0x0000);
writel(0x0, rgb_base + 0x0004);
writel(((timing->height << 16) | timing->width), rgb_base + 0x0008);
writel(0x0, rgb_base + 0x000c);
writel(timing->base, rgb_base + 0x0010); //FB address
writel((timing->width * timing->bpp / 8), rgb_base + 0x0040);
writel(0x2443F, rgb_base + 0x0050); //format
writel(0x20001, rgb_base + 0x0054); //pattern
writel(0x0, rgb_base + 0x0058);
writel(0x20000000, rgb_base + 0x005c); //phaseX
writel(0x20000000, rgb_base + 0x0060); // phaseY
// mdp4 mixer setup MDP4_MIXER1
data = readl(MDP_BASE + 0x10100);
stage = 9;
snum = 12;
mask = 0x0f;
mask <<= snum;
stage <<= snum;
data &= ~mask;
data |= stage;
writel(data, MDP_BASE + 0x10100); // Overlay CFG conf
data = readl(MDP_BASE + 0x10100);
// Overlay cfg
overlay_base = MDP_BASE + MDP4_OVERLAYPROC1_BASE;
writel(0x0, MDP_BASE + 0x0038); //EXternal interface select
data = ((timing->height << 16) | timing->width);
writel(data, overlay_base + 0x0008);
writel(timing->base, overlay_base + 0x000c);
writel((timing->width * timing->bpp / 8), overlay_base + 0x0010);
writel(0x10, overlay_base + 0x104);
writel(0x10, overlay_base + 0x124);
writel(0x10, overlay_base + 0x144);
writel(0x01, overlay_base + 0x0004); /* directout */
hsync_period =
timing->hsync_width + timing->hsync_porch_bp + timing->width +
timing->hsync_porch_fp;
hsync_ctrl = (hsync_period << 16) | timing->hsync_width;
hsync_start_x = timing->hsync_width + timing->hsync_porch_bp;
hsync_end_x = hsync_period - timing->hsync_porch_fp - 1;
display_hctl = (hsync_end_x << 16) | hsync_start_x;
vsync_period =
(timing->vsync_width + timing->vsync_porch_bp + timing->height +
timing->vsync_porch_fp) * hsync_period;
display_v_start =
(timing->vsync_width + timing->vsync_porch_bp) * hsync_period;
display_v_end =
vsync_period - (timing->vsync_porch_bp * hsync_period) - 1;
dtv_underflow_clr |= 0x80000000;
hsync_polarity = 0;
vsync_polarity = 0;
data_en_polarity = 0;
ctrl_polarity =
(data_en_polarity << 2) | (vsync_polarity << 1) | (hsync_polarity);
writel(hsync_ctrl, MDP_BASE + DTV_BASE + 0x4);
writel(vsync_period, MDP_BASE + DTV_BASE + 0x8);
writel(timing->vsync_width * hsync_period,
MDP_BASE + DTV_BASE + 0xc);
writel(display_hctl, MDP_BASE + DTV_BASE + 0x18);
writel(display_v_start, MDP_BASE + DTV_BASE + 0x1c);
writel(0x25a197, MDP_BASE + DTV_BASE + 0x20);
writel(dtv_border_clr, MDP_BASE + DTV_BASE + 0x40);
writel(0x8fffffff, MDP_BASE + DTV_BASE + 0x44);
writel(dtv_hsync_skew, MDP_BASE + DTV_BASE + 0x48);
writel(ctrl_polarity, MDP_BASE + DTV_BASE + 0x50);
writel(0x0, MDP_BASE + DTV_BASE + 0x2c);
writel(active_v_start, MDP_BASE + DTV_BASE + 0x30);
writel(active_v_end, MDP_BASE + DTV_BASE + 0x38);
/* Enable DTV block */
writel(0x01, MDP_BASE + DTV_BASE);
/* Flush mixer/pipes configurations */
val = BIT(1);
val |= BIT(5);
writel(val, MDP_BASE + 0x18000);
return 0;
}
void hdmi_display_shutdown()
{
writel(0x0, MDP_BASE + DTV_BASE);
writel(0x8, MDP_BASE + 0x0038);
writel(0x0, MDP_BASE + 0x10100);
}
|
296126.c | #include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv) {
if (argc != 4) {
fprintf(stderr, "wrong number of arguments\n");
exit(1);
}
FILE *in, *out;
in = fopen(argv[1], "r");
if (in == NULL) {
printf("open error : %s\n", argv[1]);
exit(1);
}
out = fopen(argv[2], "w");
if (out == NULL) {
printf("open error : %s\n", argv[2]);
exit(1);
}
double d;
int nbCol = atoi(argv[3]);
for (int j = 0; j < nbCol; j++) {
int rt;
rt = fread(&d, sizeof(double), 1, in);
if (rt > 0) {
fprintf(out, "%d %lf\n", j, d);
// fprintf (stdout, "%d %d %lf\n", i, j ,d);
} else {
exit(0);
}
}
}
|
119289.c | /* Copyright (c) 2007-2017 Dovecot authors, see the included COPYING file */
#include "test-lib.h"
#include "str.h"
#include "str-sanitize.h"
struct str_sanitize_test {
const char *str;
unsigned int max_len;
const char *sanitized; /* NULL for no change */
};
void test_str_sanitize(void)
{
static struct str_sanitize_test tests[] = {
{ NULL, 2, NULL },
{ "", 2, NULL },
{ "a", 2, NULL },
{ "ab", 2, NULL },
{ "abc", 2, "..." },
{ "abcd", 3, "..." },
{ "abcde", 4, "a..." },
{ "\xD1\x81", 1, "..." },
{ "\xD1\x81", 2, "\xD1\x81" },
{ "\xD1\x81", 3, NULL },
{ "\xC3\xA4\xC3\xA4zyxa", 1, "..." },
{ "\xC3\xA4\xC3\xA4zyxa", 2, "..." },
{ "\xC3\xA4\xC3\xA4zyxa", 3, "..." },
{ "\xC3\xA4\xC3\xA4zyxa", 4, "..." },
{ "\xC3\xA4\xC3\xA4zyxa", 5, "\xC3\xA4..." },
{ "\xC3\xA4\xC3\xA4zyxa", 6, "\xC3\xA4..." },
{ "\xC3\xA4\xC3\xA4zyxa", 7, "\xC3\xA4\xC3\xA4..." },
{ "\xC3\xA4\xC3\xA4zyxa", 8, "\xC3\xA4\xC3\xA4zyxa" },
{ "\001x\x1fy\x81", 10, "?x?y?" }
};
const char *str;
string_t *str2;
unsigned int i;
test_begin("str_sanitize");
for (i = 0; i < N_ELEMENTS(tests); i++) {
str = str_sanitize(tests[i].str, tests[i].max_len);
if (tests[i].sanitized != NULL)
test_assert_idx(null_strcmp(str, tests[i].sanitized) == 0, i);
else
test_assert_idx(str == tests[i].str, i);
}
test_end();
test_begin("str_sanitize_append");
str2 = t_str_new(128);
for (i = 0; i < N_ELEMENTS(tests); i++) {
if (tests[i].str == NULL)
continue;
str_truncate(str2, 0);
str_append(str2, "1234567890");
str_sanitize_append(str2, tests[i].str, tests[i].max_len);
test_assert_idx(strncmp(str_c(str2), "1234567890", 10) == 0, i);
if (tests[i].sanitized != NULL)
test_assert_idx(strcmp(str_c(str2)+10, tests[i].sanitized) == 0, i);
else
test_assert_idx(strcmp(str_c(str2)+10, tests[i].str) == 0, i);
}
test_end();
}
|
616582.c | /*******************************************************************************
ENC28J60 Check TX Status State Machine
Company:
Microchip Technology Inc.
File Name:
drv_enc28j60_check_tx_status_state.c
Summary:
Description:
*******************************************************************************/
// DOM-IGNORE-BEGIN
/*****************************************************************************
Copyright (C) 2014-2018 Microchip Technology Inc. and its subsidiaries.
Microchip Technology Inc. and its subsidiaries.
Subject to your compliance with these terms, you may use Microchip software
and any derivatives exclusively with Microchip products. It is your
responsibility to comply with third party license terms applicable to your
use of third party software (including open source software) that may
accompany Microchip software.
THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED
WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A PARTICULAR
PURPOSE.
IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS
BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE
FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN
ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
*****************************************************************************/
// DOM-IGNORE-END
#include "drv_enc28j60_check_tx_status_state.h"
#include "..//drv_enc28j60_local.h"
#include "../drv_enc28j60_utils.h"
#include "drv_enc28j60_running_state.h"
int32_t DRV_ENC28J60_ChkTxStatusStateTask(struct _DRV_ENC28J60_DriverInfo * pDrvInst)
{
int choice;
int count;
DRV_ENC28J60_PHY_RES phyRes;
uint16_t phyRegValue;
DRV_ENC28J60_RegUnion reg;
uintptr_t ret;
DRV_ENC28J60_BUS_RESULT res;
DRV_ENC28J60_TX_PACKET_INFO* pTxLock;
DRV_ENC28J60_CHECK_TX_STATUS_INFO * curSt = &(pDrvInst->mainStateInfo.runningInfo.chkTxStaInfo);
switch(curSt->state)
{
case DRV_ENC28J60_CTS_WAIT:
if (curSt->txUpdateNeeded)
{
for (choice = 0; choice < MAX_TX_DESCRIPTORS; choice ++)
{
for (count = 0; count < MAX_TX_DESCRIPTORS; count++)
{
if (pDrvInst->txDescriptors[count].state == DRV_ENC28J60_TP_WAIT_FOR_COMPLETE)
{
pDrvInst->txDescriptors[count].state = DRV_ENC28J60_TP_RST_EIR;
break;
}
}
}
curSt->txUpdateNeeded = false;
break;
}
// no txUpdateNeeded detected
// try to avoid a TX lock; check if any lock in the DRV_ENC28J60_TP_WAIT_FOR_COMPLETE status
pTxLock = 0;
for (count = 0; count < MAX_TX_DESCRIPTORS; count++)
{
if (pDrvInst->txDescriptors[count].state == DRV_ENC28J60_TP_WAIT_FOR_COMPLETE)
{
pTxLock = pDrvInst->txDescriptors + count;
break;
}
}
if(pTxLock)
{
curSt->pTxLock = pTxLock;
curSt->state = DRV_ENC28J60_CTS_READ_PHSTAT2;
}
break;
case DRV_ENC28J60_CTS_READ_PHSTAT2:
phyRes = (*pDrvInst->busVTable->fpPhyRdStart)(pDrvInst, DRV_ENC28J60_PHY_SFR_PHSTAT2);
if(phyRes >= 0)
{ // success
curSt->state = DRV_ENC28J60_CTS_WAIT_PHSTAT2;
}
// else error; retry
break;
case DRV_ENC28J60_CTS_WAIT_PHSTAT2:
phyRes = (*pDrvInst->busVTable->fpPhyRd)(pDrvInst, DRV_ENC28J60_PHY_SFR_PHSTAT2, &phyRegValue);
if(phyRes < 0)
{ // error; retry
curSt->state = DRV_ENC28J60_CTS_READ_PHSTAT2;
break;
}
else if (phyRes == DRV_ENC28J60_PHY_RES_PENDING)
{ // wait some more
break;
}
// got the PHY value
reg.value = phyRegValue;
if(reg.phstat2.TXSTAT != 0)
{ // PHY is busy, ok, no problem
curSt->state = DRV_ENC28J60_CTS_DONE;
break;
}
curSt->state = DRV_ENC28J60_CTS_READ_ECON1;
// no break
case DRV_ENC28J60_CTS_READ_ECON1:
ret = (*pDrvInst->busVTable->fpSfrRdStart)(pDrvInst, DRV_ENC28J60_SFR_ECON1, false);
if(ret != 0)
{ // success
curSt->op = ret;
curSt->state = DRV_ENC28J60_CTS_WAIT_ECON1;
}
// else retry
break;
case DRV_ENC28J60_CTS_WAIT_ECON1:
res = (*pDrvInst->busVTable->fpSfrRdResult)(pDrvInst, curSt->op, ®, true);
if(res < 0)
{ // some error; retry
curSt->state = DRV_ENC28J60_CTS_READ_ECON1;
break;
}
else if(res == DRV_ENC28J60_BR_PENDING)
{ // wait some more
break;
}
// have ECON1
if(reg.econ1.TXRTS == 0)
{ // all fine, done
curSt->state = DRV_ENC28J60_CTS_DONE;
break;
}
// TX logic may be locked!
((DRV_ENC28J60_TX_PACKET_INFO*)curSt->pTxLock)->state = DRV_ENC28J60_TP_RESET_TX;
curSt->txUpdateNeeded = true;
curSt->state = DRV_ENC28J60_CTS_DONE;
// no break
case DRV_ENC28J60_CTS_DONE:
curSt->state = DRV_ENC28J60_CTS_WAIT;
break;
}
return 0;
}
int32_t DRV_ENC28J60_ChkTxStatusStateEnter(struct _DRV_ENC28J60_DriverInfo * pDrvInst)
{
DRV_ENC28J60_CHECK_TX_STATUS_INFO * curSt = &(pDrvInst->mainStateInfo.runningInfo.chkTxStaInfo);
curSt->state = DRV_ENC28J60_CTS_WAIT;
curSt->txUpdateNeeded = false;
return 0;
}
int32_t DRV_ENC28J60_ChkTxStatusStateExit(struct _DRV_ENC28J60_DriverInfo * pDrvInst)
{
return 0;
}
|
922566.c | #ifndef lint
static const char RCSid[] = "$Id: pmutil.c,v 2.5 2020/04/08 15:14:21 rschregle Exp $";
#endif
/*
======================================================================
Photon map utilities
Roland Schregle (roland.schregle@{hslu.ch, gmail.com})
(c) Fraunhofer Institute for Solar Energy Systems,
(c) Lucerne University of Applied Sciences and Arts,
supported by the Swiss National Science Foundation (SNSF, #147053)
======================================================================
$Id: pmutil.c,v 2.5 2020/04/08 15:14:21 rschregle Exp $
*/
#include "pmap.h"
#include "pmapio.h"
#include "pmapbias.h"
#include "otypes.h"
#include <sys/stat.h>
extern char *octname;
/* Photon map lookup functions per type */
void (*pmapLookup [NUM_PMAP_TYPES])(PhotonMap*, RAY*, COLOR) = {
photonDensity, photonPreCompDensity, photonDensity, volumePhotonDensity,
photonDensity, photonDensity
};
void colorNorm (COLOR c)
/* Normalise colour channels to average of 1 */
{
const float avg = colorAvg(c);
if (!avg)
return;
c [0] /= avg;
c [1] /= avg;
c [2] /= avg;
}
void loadPmaps (PhotonMap **pmaps, const PhotonMapParams *parm)
{
unsigned t;
struct stat octstat, pmstat;
PhotonMap *pm;
PhotonMapType type;
for (t = 0; t < NUM_PMAP_TYPES; t++)
if (setPmapParam(&pm, parm + t)) {
/* Check if photon map newer than octree */
if (pm -> fileName && octname &&
!stat(pm -> fileName, &pmstat) && !stat(octname, &octstat) &&
octstat.st_mtime > pmstat.st_mtime) {
sprintf(errmsg, "photon map in file %s may be stale",
pm -> fileName);
error(USER, errmsg);
}
/* Load photon map from file and get its type */
if ((type = loadPhotonMap(pm, pm -> fileName)) == PMAP_TYPE_NONE)
error(USER, "failed loading photon map");
/* Assign to appropriate photon map type (deleting previously
* loaded photon map of same type if necessary) */
if (pmaps [type]) {
sprintf(errmsg, "multiple %s photon maps, dropping previous",
pmapName [type]);
error(WARNING, errmsg);
deletePhotons(pmaps [type]);
free(pmaps [type]);
}
pmaps [type] = pm;
/* Check for valid density estimate bandwidths */
if ((pm -> minGather > 1 || pm -> maxGather > 1) &&
(type == PMAP_TYPE_PRECOMP)) {
/* Force bwidth to 1 for precomputed pmap */
error(WARNING, "ignoring bandwidth for precomp photon map");
pm -> minGather = pm -> maxGather = 1;
}
if ((pm -> maxGather > pm -> minGather) &&
(type == PMAP_TYPE_VOLUME)) {
/* Biascomp for volume pmaps (see volumePhotonDensity() below)
is considered redundant, and there's probably no point in
recovering by using the lower bandwidth, since it's probably
not what the user wants, so bail out. */
sprintf(errmsg,
"bias compensation is not available with %s photon maps",
pmapName [type]);
error(USER, errmsg);
}
if (pm -> maxGather > pm -> numPhotons) {
error(WARNING, "adjusting density estimate bandwidth");
pm -> minGather = pm -> maxGather = pm -> numPhotons;
}
}
}
void cleanUpPmaps (PhotonMap **pmaps)
{
unsigned t;
for (t = 0; t < NUM_PMAP_TYPES; t++) {
if (pmaps [t]) {
deletePhotons(pmaps [t]);
free(pmaps [t]);
}
}
}
void photonDensity (PhotonMap *pmap, RAY *ray, COLOR irrad)
/* Photon density estimate. Returns irradiance at ray -> rop. */
{
unsigned i;
float r2;
COLOR flux;
Photon *photon;
const PhotonSearchQueueNode *sqn;
setcolor(irrad, 0, 0, 0);
if (!pmap -> maxGather)
return;
/* Ignore sources */
if (ray -> ro && islight(objptr(ray -> ro -> omod) -> otype))
return;
findPhotons(pmap, ray);
/* Need at least 2 photons */
if (pmap -> squeue.tail < 2) {
#ifdef PMAP_NONEFOUND
sprintf(errmsg, "no photons found on %s at (%.3f, %.3f, %.3f)",
ray -> ro ? ray -> ro -> oname : "<null>",
ray -> rop [0], ray -> rop [1], ray -> rop [2]);
error(WARNING, errmsg);
#endif
return;
}
if (pmap -> minGather == pmap -> maxGather) {
/* No bias compensation. Just do a plain vanilla estimate */
sqn = pmap -> squeue.node + 1;
/* Average radius^2 between furthest two photons to improve accuracy */
r2 = max(sqn -> dist2, (sqn + 1) -> dist2);
r2 = 0.25 * (pmap -> maxDist2 + r2 + 2 * sqrt(pmap -> maxDist2 * r2));
/* Skip the extra photon */
for (i = 1 ; i < pmap -> squeue.tail; i++, sqn++) {
photon = getNearestPhoton(&pmap -> squeue, sqn -> idx);
getPhotonFlux(photon, flux);
#ifdef PMAP_EPANECHNIKOV
/* Apply Epanechnikov kernel to photon flux based on photon dist */
scalecolor(flux, 2 * (1 - sqn -> dist2 / r2));
#endif
addcolor(irrad, flux);
}
/* Divide by search area PI * r^2, 1 / PI required as ambient
normalisation factor */
scalecolor(irrad, 1 / (PI * PI * r2));
return;
}
else
/* Apply bias compensation to density estimate */
biasComp(pmap, irrad);
}
void photonPreCompDensity (PhotonMap *pmap, RAY *r, COLOR irrad)
/* Returns precomputed photon density estimate at ray -> rop. */
{
Photon p;
setcolor(irrad, 0, 0, 0);
/* Ignore sources */
if (r -> ro && islight(objptr(r -> ro -> omod) -> otype))
return;
if (find1Photon(preCompPmap, r, &p))
/* p contains a found photon, so get its irradiance, otherwise it
* remains zero under the assumption all photons are too distant
* to contribute significantly */
getPhotonFlux(&p, irrad);
}
void volumePhotonDensity (PhotonMap *pmap, RAY *ray, COLOR irrad)
/* Photon volume density estimate. Returns irradiance at ray -> rop. */
{
unsigned i;
float r2, gecc2, ph;
COLOR flux;
Photon *photon;
const PhotonSearchQueueNode *sqn;
setcolor(irrad, 0, 0, 0);
if (!pmap -> maxGather)
return;
findPhotons(pmap, ray);
/* Need at least 2 photons */
if (pmap -> squeue.tail < 2)
return;
#if 0
/* Volume biascomp disabled (probably redundant) */
if (pmap -> minGather == pmap -> maxGather)
#endif
{
/* No bias compensation. Just do a plain vanilla estimate */
gecc2 = ray -> gecc * ray -> gecc;
sqn = pmap -> squeue.node + 1;
/* Average radius^2 between furthest two photons to improve accuracy */
r2 = max(sqn -> dist2, (sqn + 1) -> dist2);
r2 = 0.25 * (pmap -> maxDist2 + r2 + 2 * sqrt(pmap -> maxDist2 * r2));
/* Skip the extra photon */
for (i = 1; i < pmap -> squeue.tail; i++, sqn++) {
photon = getNearestPhoton(&pmap -> squeue, sqn -> idx);
/* Compute phase function for inscattering from photon */
if (gecc2 <= FTINY)
ph = 1;
else {
ph = DOT(ray -> rdir, photon -> norm) / 127;
ph = 1 + gecc2 - 2 * ray -> gecc * ph;
ph = (1 - gecc2) / (ph * sqrt(ph));
}
getPhotonFlux(photon, flux);
scalecolor(flux, ph);
addcolor(irrad, flux);
}
/* Divide by search volume 4 / 3 * PI * r^3 and phase function
normalization factor 1 / (4 * PI) */
scalecolor(irrad, 3 / (16 * PI * PI * r2 * sqrt(r2)));
return;
}
#if 0
else
/* Apply bias compensation to density estimate */
volumeBiasComp(pmap, ray, irrad);
#endif
}
|
905220.c | /* Test for warnings for missing format attributes. Don't warn if no
relevant parameters for a format attribute; see c/1017. */
/* Origin: Joseph Myers <[email protected]> */
/* { dg-do compile { target { *-*-mingw* } } } */
/* { dg-options "-std=gnu99 -Wmissing-format-attribute" } */
#define USE_SYSTEM_FORMATS
#include "format.h"
void
foo (int i, ...)
{
va_list ap;
va_start (ap, i);
vprintf ("Foo %s bar %s", ap); /* { dg-bogus "candidate" "bogus printf attribute warning" } */
va_end (ap);
}
|
330911.c | /*
* Copyright (C) 2017 Red Hat, Inc.
*
* Author: Nikos Mavrogiannopoulos
*
* This file is part of GnuTLS.
*
* The GnuTLS is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>
*
*/
#include "gnutls_int.h"
#include "errors.h"
#include "hello_ext.h"
#include "handshake.h"
#include "tls13/hello_retry.h"
#include "auth/cert.h"
#include "mbuffers.h"
#include "state.h"
int _gnutls13_send_hello_retry_request(gnutls_session_t session, unsigned again)
{
int ret;
mbuffer_st *bufel = NULL;
gnutls_buffer_st buf;
const version_entry_st *ver;
const uint8_t vbuf[2] = {0x03, 0x03};
if (again == 0) {
ver = get_version(session);
if (unlikely(ver == NULL || session->security_parameters.cs == NULL))
return gnutls_assert_val(GNUTLS_E_INTERNAL_ERROR);
ret = _gnutls_buffer_init_handshake_mbuffer(&buf);
if (ret < 0)
return gnutls_assert_val(ret);
ret = _gnutls_buffer_append_data(&buf, vbuf, 2);
if (ret < 0)
return gnutls_assert_val(ret);
ret = _gnutls_buffer_append_data(&buf,
HRR_RANDOM,
GNUTLS_RANDOM_SIZE);
if (ret < 0) {
gnutls_assert();
goto cleanup;
}
ret = _gnutls_buffer_append_data_prefix(&buf, 8,
session->security_parameters.session_id,
session->security_parameters.session_id_size);
if (ret < 0) {
gnutls_assert();
goto cleanup;
}
ret = _gnutls_buffer_append_data(&buf, session->security_parameters.cs->id, 2);
if (ret < 0) {
gnutls_assert();
goto cleanup;
}
/* compression */
ret = _gnutls_buffer_append_prefix(&buf, 8, 0);
if (ret < 0) {
gnutls_assert();
goto cleanup;
}
ret = _gnutls_gen_hello_extensions(session, &buf,
GNUTLS_EXT_FLAG_HRR,
GNUTLS_EXT_ANY);
if (ret < 0) {
gnutls_assert();
goto cleanup;
}
/* reset extensions sent by this session to allow re-sending them */
session->internals.used_exts = 0;
reset_binders(session);
bufel = _gnutls_buffer_to_mbuffer(&buf);
}
return _gnutls_send_handshake(session, bufel, GNUTLS_HANDSHAKE_HELLO_RETRY_REQUEST);
cleanup:
_gnutls_buffer_clear(&buf);
return ret;
}
int
_gnutls13_recv_hello_retry_request(gnutls_session_t session,
gnutls_buffer_st *buf)
{
int ret;
uint8_t tmp[2];
const gnutls_cipher_suite_entry_st *cs;
const mac_entry_st *prf;
gnutls_datum_t session_id;
uint8_t random[GNUTLS_RANDOM_SIZE];
/* only under TLS 1.3 */
if (IS_DTLS(session))
return gnutls_assert_val(GNUTLS_E_UNEXPECTED_PACKET);
if (session->internals.hsk_flags & HSK_HRR_RECEIVED)
return gnutls_assert_val(GNUTLS_E_UNEXPECTED_PACKET);
session->internals.hsk_flags |= HSK_HRR_RECEIVED;
/* version */
ret = _gnutls_buffer_pop_data(buf, tmp, 2);
if (ret < 0)
return gnutls_assert_val(GNUTLS_E_UNEXPECTED_PACKET_LENGTH);
if (unlikely(tmp[0] != 0x03 || tmp[1] != 0x03))
return gnutls_assert_val(GNUTLS_E_UNSUPPORTED_VERSION_PACKET);
ret = _gnutls_buffer_pop_data(buf, random, GNUTLS_RANDOM_SIZE);
if (ret < 0)
return gnutls_assert_val(GNUTLS_E_UNEXPECTED_PACKET_LENGTH);
if (memcmp(random, HRR_RANDOM, GNUTLS_RANDOM_SIZE) != 0) {
return gnutls_assert_val(GNUTLS_E_RECEIVED_ILLEGAL_PARAMETER);
}
ret = _gnutls_buffer_pop_datum_prefix8(buf, &session_id);
if (ret < 0)
return gnutls_assert_val(GNUTLS_E_UNEXPECTED_PACKET_LENGTH);
/* read ciphersuites */
ret = _gnutls_buffer_pop_data(buf, tmp, 2);
if (ret < 0)
return gnutls_assert_val(GNUTLS_E_UNEXPECTED_PACKET_LENGTH);
cs = ciphersuite_to_entry(tmp);
if (unlikely(cs == NULL))
return gnutls_assert_val(GNUTLS_E_UNKNOWN_CIPHER_SUITE);
_gnutls_handshake_log("EXT[%p]: Hello Retry Request with %s\n", session, cs->name);
memcpy(session->internals.hrr_cs, cs->id, 2);
prf = mac_to_entry(cs->prf);
if (unlikely(prf == NULL))
return gnutls_assert_val(GNUTLS_E_UNKNOWN_CIPHER_SUITE);
/* compression */
ret = _gnutls_buffer_pop_data(buf, tmp, 1);
if (ret < 0)
return gnutls_assert_val(GNUTLS_E_UNEXPECTED_PACKET_LENGTH);
if (unlikely(tmp[0] != 0))
return gnutls_assert_val(GNUTLS_E_RECEIVED_ILLEGAL_PARAMETER);
ret = _gnutls13_handshake_hash_buffers_synth(session, prf, 1);
if (ret < 0)
return gnutls_assert_val(ret);
if (buf->length <= 2) {
/* no extensions present */
return gnutls_assert_val(GNUTLS_E_UNEXPECTED_EXTENSIONS_LENGTH);
}
/* figure version first */
ret =
_gnutls_parse_hello_extensions(session, GNUTLS_EXT_FLAG_HRR,
GNUTLS_EXT_VERSION_NEG,
buf->data, buf->length);
if (ret < 0)
return gnutls_assert_val(ret);
/* parse the rest of extensions */
ret = _gnutls_parse_hello_extensions(session, GNUTLS_EXT_FLAG_HRR, GNUTLS_EXT_ANY,
buf->data, buf->length);
if (ret < 0)
return gnutls_assert_val(ret);
session->internals.used_exts = 0;
return 0;
}
|
490658.c | [22:56, 01/12/2019] vitor(C): void listar_todosemprestimos(struct Emprestimo *vetor2,int tam)
{
FILE *arq;
arq = fopen("Emprestimos.dat","rb");
if(arq==NULL){
printf("\n Problema ao abrir o arquivo");
exit(0);
}
else{
struct Emprestimo x[tam];
fread(&x,sizeof(struct Emprestimo),tam,arq);
int i;
//Contador do numero de usuarios
int cont=0;
for(i=0;i<tam;i++)
{
//incrementa contador, ele recebe 1 no comeco
cont++;
printf("\nO EMPRESTIMO %d ",cont);
printf("\n");
printf("\nISBN:%d",x[i].isbn);
printf("\nCPF:%d",x[i].cpf);
printf("\nData de retirada:%s",x[i].dataRetirada);
printf("\nData de retirada:%s",x[i].dataDevolucao);
printf("\nValor da multa: %f",x[i].valorMulta);
printf("\n");
}
fclose(arq);
}};
int cadastrar_emprestimo(struct Emprestimo *vetor2)
{
int i,contE=0;
char op[]="sim";
char op_aut[10];//op_tel
int cont_aut=0;//cont dos autores
while(strcmp(op,"sim")==0)
{
vetor2 = (struct Emprestimo *) realloc(vetor2,(contE+1)*sizeof(struct Emprestimo));
printf("\nDigite o isbn do livro:");
scanf("%d",&vetor2[contE].isbn);
fflush(stdin);
printf("\nDigite o cpf do usuario:");
scanf("%d",&vetor2[contE].cpf);
fflush(stdin);
printf("\nDigite a data de retirada:");
scanf("%s",vetor2[contE].dataRetirada);
fflush(stdin);
printf("\nDigite a data de devolucao:");
scanf("%s",vetor2[contE].dataDevolucao);
fflush(stdin);
printf("\nDigite o valor da multa:");
scanf("%f",&vetor2[contE].valorMulta);
fflush(stdin);
contE++;
printf("\nDeseja adicionar outro emprestimo? [sim/nao]:");
gets(op);
fflush(stdin);
//Arquivo
FILE *arq;
arq = fopen("Emprestimos.dat","ab+");
fwrite(&vetor2[contE],sizeof(struct Emprestimo),1,arq);
fclose(arq);
//if de finalizacao
if(strcmp(op,"nao")==0)
{
printf("\nProcesso total finalizado\n");
break;
}
}
return contE;
}
|
471096.c |
#include "uart.h"
void UART_Init(UART_REGS_Type *uart){
return;
}
void UART_SetBaud(UART_REGS_Type *uart, uint32_t baud_rate){
return;
}
void UART_TransmitByte(UART_REGS_Type * uart, uint8_t byte){
return;
}
uint8_t UART_ReceiveByte(UART_REGS_Type * uart){
return 0;
}
|
299130.c | #include "il2cpp-config.h"
#ifndef _MSC_VER
# include <alloca.h>
#else
# include <malloc.h>
#endif
#include "codegen/il2cpp-codegen-metadata.h"
IL2CPP_EXTERN_C_BEGIN
IL2CPP_EXTERN_C_END
// 0x00000001 UnityEngine.XR.Management.XRManagerSettings UnityEngine.XR.Management.XRGeneralSettings::get_Manager()
extern void XRGeneralSettings_get_Manager_mBD0D772CE77641DA8B7226D1A9CD3F8E699F7779 ();
// 0x00000002 System.Void UnityEngine.XR.Management.XRGeneralSettings::set_Manager(UnityEngine.XR.Management.XRManagerSettings)
extern void XRGeneralSettings_set_Manager_mA00141C36332EE942A8FB3000E021F10B9751DBB ();
// 0x00000003 UnityEngine.XR.Management.XRGeneralSettings UnityEngine.XR.Management.XRGeneralSettings::get_Instance()
extern void XRGeneralSettings_get_Instance_m0D915EB6CD760E30475C5F67090DD8442196FE47 ();
// 0x00000004 UnityEngine.XR.Management.XRManagerSettings UnityEngine.XR.Management.XRGeneralSettings::get_AssignedSettings()
extern void XRGeneralSettings_get_AssignedSettings_m78AFF6E40149AE2FE4F89E55D1FABCFF3A768AF6 ();
// 0x00000005 System.Boolean UnityEngine.XR.Management.XRGeneralSettings::get_InitManagerOnStart()
extern void XRGeneralSettings_get_InitManagerOnStart_m0CA51D67FC8AB767C45954CF09E4E152E32BB92F ();
// 0x00000006 System.Void UnityEngine.XR.Management.XRGeneralSettings::Awake()
extern void XRGeneralSettings_Awake_m70E1426BA7E91710C8A7B82824E4377E47EF9C41 ();
// 0x00000007 System.Void UnityEngine.XR.Management.XRGeneralSettings::Quit()
extern void XRGeneralSettings_Quit_mD6E708EB9FA9A52EDAF992CD04089A5E23522C60 ();
// 0x00000008 System.Void UnityEngine.XR.Management.XRGeneralSettings::Start()
extern void XRGeneralSettings_Start_m3236D327A4A3E66527CEBDA2F5BDD07D01B71EA5 ();
// 0x00000009 System.Void UnityEngine.XR.Management.XRGeneralSettings::OnDestroy()
extern void XRGeneralSettings_OnDestroy_mF1FAFD114FDDAF476767A2EDA9171942E4DCF17E ();
// 0x0000000A System.Void UnityEngine.XR.Management.XRGeneralSettings::AttemptInitializeXRSDKOnLoad()
extern void XRGeneralSettings_AttemptInitializeXRSDKOnLoad_mC7F0EFAC852684103350BC26B573F1E085707EAD ();
// 0x0000000B System.Void UnityEngine.XR.Management.XRGeneralSettings::AttemptStartXRSDKOnBeforeSplashScreen()
extern void XRGeneralSettings_AttemptStartXRSDKOnBeforeSplashScreen_m4D982B772260F4FFB51456402EA7DD993181FBCD ();
// 0x0000000C System.Void UnityEngine.XR.Management.XRGeneralSettings::InitXRSDK()
extern void XRGeneralSettings_InitXRSDK_m7E948591C80EC7A2A97417A959BEA5DF4BACB58D ();
// 0x0000000D System.Void UnityEngine.XR.Management.XRGeneralSettings::StartXRSDK()
extern void XRGeneralSettings_StartXRSDK_mE58ED248C7E672773A4D9FF8BBECEC0DBE2D0059 ();
// 0x0000000E System.Void UnityEngine.XR.Management.XRGeneralSettings::StopXRSDK()
extern void XRGeneralSettings_StopXRSDK_m0307D54FDB9513DD49B5523D7FEC72513DE7E47F ();
// 0x0000000F System.Void UnityEngine.XR.Management.XRGeneralSettings::DeInitXRSDK()
extern void XRGeneralSettings_DeInitXRSDK_m736781E104A1DBBFFE393393B0ADFBCB9F164EED ();
// 0x00000010 System.Void UnityEngine.XR.Management.XRGeneralSettings::.ctor()
extern void XRGeneralSettings__ctor_mF398EFC4AD993C540516487FC50F83C2468DFB3A ();
// 0x00000011 System.Void UnityEngine.XR.Management.XRGeneralSettings::.cctor()
extern void XRGeneralSettings__cctor_m3894F3807749E1AA75D5D4995DD41CB3DCE5C44D ();
// 0x00000012 System.Boolean UnityEngine.XR.Management.XRLoader::Initialize()
extern void XRLoader_Initialize_m5E528D0A51C1AD2732689F548B99E1A88470BD02 ();
// 0x00000013 System.Boolean UnityEngine.XR.Management.XRLoader::Start()
extern void XRLoader_Start_mBA33843711A6DFB08AC623A2F2892FD71CB1DDE7 ();
// 0x00000014 System.Boolean UnityEngine.XR.Management.XRLoader::Stop()
extern void XRLoader_Stop_m2E7F152C1FAF60294D7A95E077719AF493869894 ();
// 0x00000015 System.Boolean UnityEngine.XR.Management.XRLoader::Deinitialize()
extern void XRLoader_Deinitialize_m863CE4A82FE431245E25BA85C04DC3F0E8E88CDA ();
// 0x00000016 T UnityEngine.XR.Management.XRLoader::GetLoadedSubsystem()
// 0x00000017 System.Collections.Generic.List`1<UnityEngine.Rendering.GraphicsDeviceType> UnityEngine.XR.Management.XRLoader::GetSupportedGraphicsDeviceTypes(System.Boolean)
extern void XRLoader_GetSupportedGraphicsDeviceTypes_m322533865DF60C4FD1F029988C4C4AEF1925FD5E ();
// 0x00000018 System.Void UnityEngine.XR.Management.XRLoader::.ctor()
extern void XRLoader__ctor_m9F3AB0D960DC1395FBBF3D0D65EB27E70662B4B8 ();
// 0x00000019 System.Boolean UnityEngine.XR.Management.XRManagerSettings::get_automaticLoading()
extern void XRManagerSettings_get_automaticLoading_mDCB2A7289C4FE8BD7FBA7CA207CE4EEE14C19CA9 ();
// 0x0000001A System.Void UnityEngine.XR.Management.XRManagerSettings::set_automaticLoading(System.Boolean)
extern void XRManagerSettings_set_automaticLoading_mF7787829863EF4D75DC56716E9283C9D456030DD ();
// 0x0000001B System.Boolean UnityEngine.XR.Management.XRManagerSettings::get_automaticRunning()
extern void XRManagerSettings_get_automaticRunning_mDC0FE3222A77630AB1D51AA0811CCA3132024C59 ();
// 0x0000001C System.Void UnityEngine.XR.Management.XRManagerSettings::set_automaticRunning(System.Boolean)
extern void XRManagerSettings_set_automaticRunning_m0B46221356F33FFE168DACAA8812E938036FD439 ();
// 0x0000001D System.Collections.Generic.List`1<UnityEngine.XR.Management.XRLoader> UnityEngine.XR.Management.XRManagerSettings::get_loaders()
extern void XRManagerSettings_get_loaders_mBD4F29A6F89D5D620634FC1853A88257FA58AE36 ();
// 0x0000001E System.Boolean UnityEngine.XR.Management.XRManagerSettings::get_isInitializationComplete()
extern void XRManagerSettings_get_isInitializationComplete_m878C7DDB712D4F99160B2F7C71CBFC201F5AB63F ();
// 0x0000001F UnityEngine.XR.Management.XRLoader UnityEngine.XR.Management.XRManagerSettings::get_activeLoader()
extern void XRManagerSettings_get_activeLoader_m9371C31D367F55202EE948306D0C61A9D8725B67 ();
// 0x00000020 System.Void UnityEngine.XR.Management.XRManagerSettings::set_activeLoader(UnityEngine.XR.Management.XRLoader)
extern void XRManagerSettings_set_activeLoader_m4961B290666B1461944FD0487DECB699A903D8D3 ();
// 0x00000021 T UnityEngine.XR.Management.XRManagerSettings::ActiveLoaderAs()
// 0x00000022 System.Void UnityEngine.XR.Management.XRManagerSettings::InitializeLoaderSync()
extern void XRManagerSettings_InitializeLoaderSync_mC8931AA78045796B6C9CFCF8CAF6FB0B54C40025 ();
// 0x00000023 System.Collections.IEnumerator UnityEngine.XR.Management.XRManagerSettings::InitializeLoader()
extern void XRManagerSettings_InitializeLoader_m6AE56C59F2EDD415911272B417E0085F6009667F ();
// 0x00000024 System.Boolean UnityEngine.XR.Management.XRManagerSettings::CheckGraphicsAPICompatibility(UnityEngine.XR.Management.XRLoader)
extern void XRManagerSettings_CheckGraphicsAPICompatibility_m17471A8679FF7F6CD90FFB12D036A5075DF3F8C1 ();
// 0x00000025 System.Void UnityEngine.XR.Management.XRManagerSettings::StartSubsystems()
extern void XRManagerSettings_StartSubsystems_m3A10751468041448DBCB179136F3313FEA29537F ();
// 0x00000026 System.Void UnityEngine.XR.Management.XRManagerSettings::StopSubsystems()
extern void XRManagerSettings_StopSubsystems_m1B4A77F81B323A476A1446FF1AD1B3F2482FB7A9 ();
// 0x00000027 System.Void UnityEngine.XR.Management.XRManagerSettings::DeinitializeLoader()
extern void XRManagerSettings_DeinitializeLoader_mAEB6EFBBDB20076FC3B7DB17D7B2FAA34E2C5E2C ();
// 0x00000028 System.Void UnityEngine.XR.Management.XRManagerSettings::Start()
extern void XRManagerSettings_Start_m318DCEC189E13498E539AD0FD1411F006ADFC987 ();
// 0x00000029 System.Void UnityEngine.XR.Management.XRManagerSettings::OnDisable()
extern void XRManagerSettings_OnDisable_mBF327F3EF9A66EE05ABFFF207440B683CBC9A25E ();
// 0x0000002A System.Void UnityEngine.XR.Management.XRManagerSettings::OnDestroy()
extern void XRManagerSettings_OnDestroy_m0D6707A5F61284A0BB3808ABBEB8EEA82C92452A ();
// 0x0000002B System.Void UnityEngine.XR.Management.XRManagerSettings::.ctor()
extern void XRManagerSettings__ctor_mC1B877CD102E57833EE8D4811A9424598F34078B ();
// 0x0000002C System.Void UnityEngine.XR.Management.XRManagerSettings::.cctor()
extern void XRManagerSettings__cctor_m6AEE40CBB054335113BCA1BE4C4DAA4DFCD4BF99 ();
// 0x0000002D System.Void UnityEngine.XR.Management.XRManagerSettings_<InitializeLoader>d__21::.ctor(System.Int32)
extern void U3CInitializeLoaderU3Ed__21__ctor_mE1EFD8B0AE006E71FC3596E10AB1BFAC6B7570E1 ();
// 0x0000002E System.Void UnityEngine.XR.Management.XRManagerSettings_<InitializeLoader>d__21::System.IDisposable.Dispose()
extern void U3CInitializeLoaderU3Ed__21_System_IDisposable_Dispose_m3D0F83E1A23AF0F08427EF6C1FC7FBB8BCA5FE4D ();
// 0x0000002F System.Boolean UnityEngine.XR.Management.XRManagerSettings_<InitializeLoader>d__21::MoveNext()
extern void U3CInitializeLoaderU3Ed__21_MoveNext_mC17EDB30580E987D970F6F6AB785210EF7FE5AA2 ();
// 0x00000030 System.Void UnityEngine.XR.Management.XRManagerSettings_<InitializeLoader>d__21::<>m__Finally1()
extern void U3CInitializeLoaderU3Ed__21_U3CU3Em__Finally1_m8B409C7A2D9E4222422F06BFEC8DF4D3F1187747 ();
// 0x00000031 System.Object UnityEngine.XR.Management.XRManagerSettings_<InitializeLoader>d__21::System.Collections.Generic.IEnumerator<System.Object>.get_Current()
extern void U3CInitializeLoaderU3Ed__21_System_Collections_Generic_IEnumeratorU3CSystem_ObjectU3E_get_Current_mBC84CBAC26C6E31E3B7368934B5DE21A94FE484B ();
// 0x00000032 System.Void UnityEngine.XR.Management.XRManagerSettings_<InitializeLoader>d__21::System.Collections.IEnumerator.Reset()
extern void U3CInitializeLoaderU3Ed__21_System_Collections_IEnumerator_Reset_mA8F74EB916C42DF0855C5110619D38843142C4E4 ();
// 0x00000033 System.Object UnityEngine.XR.Management.XRManagerSettings_<InitializeLoader>d__21::System.Collections.IEnumerator.get_Current()
extern void U3CInitializeLoaderU3Ed__21_System_Collections_IEnumerator_get_Current_m6332A8667B15EA740D7E8F292B2F324594C31F60 ();
static Il2CppMethodPointer s_methodPointers[51] =
{
XRGeneralSettings_get_Manager_mBD0D772CE77641DA8B7226D1A9CD3F8E699F7779,
XRGeneralSettings_set_Manager_mA00141C36332EE942A8FB3000E021F10B9751DBB,
XRGeneralSettings_get_Instance_m0D915EB6CD760E30475C5F67090DD8442196FE47,
XRGeneralSettings_get_AssignedSettings_m78AFF6E40149AE2FE4F89E55D1FABCFF3A768AF6,
XRGeneralSettings_get_InitManagerOnStart_m0CA51D67FC8AB767C45954CF09E4E152E32BB92F,
XRGeneralSettings_Awake_m70E1426BA7E91710C8A7B82824E4377E47EF9C41,
XRGeneralSettings_Quit_mD6E708EB9FA9A52EDAF992CD04089A5E23522C60,
XRGeneralSettings_Start_m3236D327A4A3E66527CEBDA2F5BDD07D01B71EA5,
XRGeneralSettings_OnDestroy_mF1FAFD114FDDAF476767A2EDA9171942E4DCF17E,
XRGeneralSettings_AttemptInitializeXRSDKOnLoad_mC7F0EFAC852684103350BC26B573F1E085707EAD,
XRGeneralSettings_AttemptStartXRSDKOnBeforeSplashScreen_m4D982B772260F4FFB51456402EA7DD993181FBCD,
XRGeneralSettings_InitXRSDK_m7E948591C80EC7A2A97417A959BEA5DF4BACB58D,
XRGeneralSettings_StartXRSDK_mE58ED248C7E672773A4D9FF8BBECEC0DBE2D0059,
XRGeneralSettings_StopXRSDK_m0307D54FDB9513DD49B5523D7FEC72513DE7E47F,
XRGeneralSettings_DeInitXRSDK_m736781E104A1DBBFFE393393B0ADFBCB9F164EED,
XRGeneralSettings__ctor_mF398EFC4AD993C540516487FC50F83C2468DFB3A,
XRGeneralSettings__cctor_m3894F3807749E1AA75D5D4995DD41CB3DCE5C44D,
XRLoader_Initialize_m5E528D0A51C1AD2732689F548B99E1A88470BD02,
XRLoader_Start_mBA33843711A6DFB08AC623A2F2892FD71CB1DDE7,
XRLoader_Stop_m2E7F152C1FAF60294D7A95E077719AF493869894,
XRLoader_Deinitialize_m863CE4A82FE431245E25BA85C04DC3F0E8E88CDA,
NULL,
XRLoader_GetSupportedGraphicsDeviceTypes_m322533865DF60C4FD1F029988C4C4AEF1925FD5E,
XRLoader__ctor_m9F3AB0D960DC1395FBBF3D0D65EB27E70662B4B8,
XRManagerSettings_get_automaticLoading_mDCB2A7289C4FE8BD7FBA7CA207CE4EEE14C19CA9,
XRManagerSettings_set_automaticLoading_mF7787829863EF4D75DC56716E9283C9D456030DD,
XRManagerSettings_get_automaticRunning_mDC0FE3222A77630AB1D51AA0811CCA3132024C59,
XRManagerSettings_set_automaticRunning_m0B46221356F33FFE168DACAA8812E938036FD439,
XRManagerSettings_get_loaders_mBD4F29A6F89D5D620634FC1853A88257FA58AE36,
XRManagerSettings_get_isInitializationComplete_m878C7DDB712D4F99160B2F7C71CBFC201F5AB63F,
XRManagerSettings_get_activeLoader_m9371C31D367F55202EE948306D0C61A9D8725B67,
XRManagerSettings_set_activeLoader_m4961B290666B1461944FD0487DECB699A903D8D3,
NULL,
XRManagerSettings_InitializeLoaderSync_mC8931AA78045796B6C9CFCF8CAF6FB0B54C40025,
XRManagerSettings_InitializeLoader_m6AE56C59F2EDD415911272B417E0085F6009667F,
XRManagerSettings_CheckGraphicsAPICompatibility_m17471A8679FF7F6CD90FFB12D036A5075DF3F8C1,
XRManagerSettings_StartSubsystems_m3A10751468041448DBCB179136F3313FEA29537F,
XRManagerSettings_StopSubsystems_m1B4A77F81B323A476A1446FF1AD1B3F2482FB7A9,
XRManagerSettings_DeinitializeLoader_mAEB6EFBBDB20076FC3B7DB17D7B2FAA34E2C5E2C,
XRManagerSettings_Start_m318DCEC189E13498E539AD0FD1411F006ADFC987,
XRManagerSettings_OnDisable_mBF327F3EF9A66EE05ABFFF207440B683CBC9A25E,
XRManagerSettings_OnDestroy_m0D6707A5F61284A0BB3808ABBEB8EEA82C92452A,
XRManagerSettings__ctor_mC1B877CD102E57833EE8D4811A9424598F34078B,
XRManagerSettings__cctor_m6AEE40CBB054335113BCA1BE4C4DAA4DFCD4BF99,
U3CInitializeLoaderU3Ed__21__ctor_mE1EFD8B0AE006E71FC3596E10AB1BFAC6B7570E1,
U3CInitializeLoaderU3Ed__21_System_IDisposable_Dispose_m3D0F83E1A23AF0F08427EF6C1FC7FBB8BCA5FE4D,
U3CInitializeLoaderU3Ed__21_MoveNext_mC17EDB30580E987D970F6F6AB785210EF7FE5AA2,
U3CInitializeLoaderU3Ed__21_U3CU3Em__Finally1_m8B409C7A2D9E4222422F06BFEC8DF4D3F1187747,
U3CInitializeLoaderU3Ed__21_System_Collections_Generic_IEnumeratorU3CSystem_ObjectU3E_get_Current_mBC84CBAC26C6E31E3B7368934B5DE21A94FE484B,
U3CInitializeLoaderU3Ed__21_System_Collections_IEnumerator_Reset_mA8F74EB916C42DF0855C5110619D38843142C4E4,
U3CInitializeLoaderU3Ed__21_System_Collections_IEnumerator_get_Current_m6332A8667B15EA740D7E8F292B2F324594C31F60,
};
static const int32_t s_InvokerIndices[51] =
{
14,
26,
4,
14,
114,
23,
3,
23,
23,
3,
3,
23,
23,
23,
23,
23,
3,
114,
114,
114,
114,
-1,
323,
23,
114,
31,
114,
31,
14,
114,
14,
26,
-1,
23,
14,
9,
23,
23,
23,
23,
23,
23,
23,
3,
32,
23,
114,
23,
14,
23,
14,
};
static const Il2CppTokenRangePair s_rgctxIndices[1] =
{
{ 0x06000021, { 0, 1 } },
};
static const Il2CppRGCTXDefinition s_rgctxValues[1] =
{
{ (Il2CppRGCTXDataType)2, 14731 },
};
extern const Il2CppCodeGenModule g_Unity_XR_ManagementCodeGenModule;
const Il2CppCodeGenModule g_Unity_XR_ManagementCodeGenModule =
{
"Unity.XR.Management.dll",
51,
s_methodPointers,
s_InvokerIndices,
0,
NULL,
1,
s_rgctxIndices,
1,
s_rgctxValues,
NULL,
};
|
236972.c | /*
* Copyright (c) 2017, Alliance for Open Media. All rights reserved
*
* This source code is subject to the terms of the BSD 2 Clause License and
* the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
* was not distributed with this source code in the LICENSE file, you can
* obtain it at www.aomedia.org/license/software. If the Alliance for Open
* Media Patent License 1.0 was not distributed with this source code in the
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
*/
#include "aom_dsp/bitwriter.h"
#include "av1/common/common.h"
// Recenters a non-negative literal v around a reference r
static uint16_t recenter_nonneg(uint16_t r, uint16_t v) {
if (v > (r << 1))
return v;
else if (v >= r)
return ((v - r) << 1);
else
return ((r - v) << 1) - 1;
}
// Recenters a non-negative literal v in [0, n-1] around a
// reference r also in [0, n-1]
static uint16_t recenter_finite_nonneg(uint16_t n, uint16_t r, uint16_t v) {
if ((r << 1) <= n) {
return recenter_nonneg(r, v);
} else {
return recenter_nonneg(n - 1 - r, n - 1 - v);
}
}
// Codes a symbol v in [-2^mag_bits, 2^mag_bits].
// mag_bits is number of bits for magnitude. The alphabet is of size
// 2 * 2^mag_bits + 1, symmetric around 0, where one bit is used to
// indicate 0 or non-zero, mag_bits bits are used to indicate magnitide
// and 1 more bit for the sign if non-zero.
void aom_write_primitive_symmetric(aom_writer *w, int16_t v,
unsigned int abs_bits) {
if (v == 0) {
aom_write_bit(w, 0);
} else {
const int x = abs(v);
const int s = v < 0;
aom_write_bit(w, 1);
aom_write_bit(w, s);
aom_write_literal(w, x - 1, abs_bits);
}
}
int aom_count_primitive_symmetric(int16_t v, unsigned int abs_bits) {
return (v == 0 ? 1 : abs_bits + 2);
}
// Encodes a value v in [0, n-1] quasi-uniformly
void aom_write_primitive_quniform(aom_writer *w, uint16_t n, uint16_t v) {
if (n <= 1) return;
const int l = get_msb(n - 1) + 1;
const int m = (1 << l) - n;
if (v < m) {
aom_write_literal(w, v, l - 1);
} else {
aom_write_literal(w, m + ((v - m) >> 1), l - 1);
aom_write_bit(w, (v - m) & 1);
}
}
int aom_count_primitive_quniform(uint16_t n, uint16_t v) {
if (n <= 1) return 0;
const int l = get_msb(n - 1) + 1;
const int m = (1 << l) - n;
return v < m ? l - 1 : l;
}
// Encodes a value v in [0, n-1] based on a reference ref also in [0, n-1]
// The closest p values of v from ref are coded using a p-ary quasi-unoform
// short code while the remaining n-p values are coded with a longer code.
void aom_write_primitive_refbilevel(aom_writer *w, uint16_t n, uint16_t p,
uint16_t ref, uint16_t v) {
if (n <= 1) return;
assert(p > 0 && p <= n);
assert(ref < n);
int lolimit = ref - p / 2;
int hilimit = lolimit + p - 1;
if (lolimit < 0) {
lolimit = 0;
hilimit = p - 1;
} else if (hilimit >= n) {
hilimit = n - 1;
lolimit = n - p;
}
if (v >= lolimit && v <= hilimit) {
aom_write_bit(w, 1);
v = v - lolimit;
aom_write_primitive_quniform(w, p, v);
} else {
aom_write_bit(w, 0);
if (v > hilimit) v -= p;
aom_write_primitive_quniform(w, n - p, v);
}
}
int aom_count_primitive_refbilevel(uint16_t n, uint16_t p, uint16_t ref,
uint16_t v) {
if (n <= 1) return 0;
assert(p > 0 && p <= n);
assert(ref < n);
int lolimit = ref - p / 2;
int hilimit = lolimit + p - 1;
if (lolimit < 0) {
lolimit = 0;
hilimit = p - 1;
} else if (hilimit >= n) {
hilimit = n - 1;
lolimit = n - p;
}
int count = 0;
if (v >= lolimit && v <= hilimit) {
count++;
v = v - lolimit;
count += aom_count_primitive_quniform(p, v);
} else {
count++;
if (v > hilimit) v -= p;
count += aom_count_primitive_quniform(n - p, v);
}
return count;
}
// Finite subexponential code that codes a symbol v in [0, n-1] with parameter k
void aom_write_primitive_subexpfin(aom_writer *w, uint16_t n, uint16_t k,
uint16_t v) {
int i = 0;
int mk = 0;
while (1) {
int b = (i ? k + i - 1 : k);
int a = (1 << b);
if (n <= mk + 3 * a) {
aom_write_primitive_quniform(w, n - mk, v - mk);
break;
} else {
int t = (v >= mk + a);
aom_write_bit(w, t);
if (t) {
i = i + 1;
mk += a;
} else {
aom_write_literal(w, v - mk, b);
break;
}
}
}
}
int aom_count_primitive_subexpfin(uint16_t n, uint16_t k, uint16_t v) {
int count = 0;
int i = 0;
int mk = 0;
while (1) {
int b = (i ? k + i - 1 : k);
int a = (1 << b);
if (n <= mk + 3 * a) {
count += aom_count_primitive_quniform(n - mk, v - mk);
break;
} else {
int t = (v >= mk + a);
count++;
if (t) {
i = i + 1;
mk += a;
} else {
count += b;
break;
}
}
}
return count;
}
// Finite subexponential code that codes a symbol v in [0, n-1] with parameter k
// based on a reference ref also in [0, n-1].
// Recenters symbol around r first and then uses a finite subexponential code.
void aom_write_primitive_refsubexpfin(aom_writer *w, uint16_t n, uint16_t k,
int16_t ref, int16_t v) {
aom_write_primitive_subexpfin(w, n, k, recenter_finite_nonneg(n, ref, v));
}
void aom_write_signed_primitive_refsubexpfin(aom_writer *w, uint16_t n,
uint16_t k, uint16_t ref,
uint16_t v) {
ref += n - 1;
v += n - 1;
const uint16_t scaled_n = (n << 1) - 1;
aom_write_primitive_refsubexpfin(w, scaled_n, k, ref, v);
}
int aom_count_primitive_refsubexpfin(uint16_t n, uint16_t k, uint16_t ref,
uint16_t v) {
return aom_count_primitive_subexpfin(n, k, recenter_finite_nonneg(n, ref, v));
}
int aom_count_signed_primitive_refsubexpfin(uint16_t n, uint16_t k, int16_t ref,
int16_t v) {
ref += n - 1;
v += n - 1;
const uint16_t scaled_n = (n << 1) - 1;
return aom_count_primitive_refsubexpfin(scaled_n, k, ref, v);
}
|
803243.c | /*-
* BSD LICENSE
*
* Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Intel Corporation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <stdarg.h>
#include <errno.h>
#include <stdlib.h>
#include <sys/queue.h>
#include <rte_common.h>
#include <rte_memory.h>
#include <rte_memzone.h>
#include <rte_per_lcore.h>
#include <rte_launch.h>
#include <rte_eal.h>
#include <rte_lcore.h>
#include <rte_malloc.h>
#include <rte_cycles.h>
#include <rte_random.h>
#include <rte_string_fns.h>
#include "test.h"
#define N 10000
/*
* Malloc
* ======
*
* Allocate some dynamic memory from heap (3 areas). Check that areas
* don't overlap and that alignment constraints match. This test is
* done many times on different lcores simultaneously.
*/
/* Test if memory overlaps: return 1 if true, or 0 if false. */
static int
is_memory_overlap(void *p1, size_t len1, void *p2, size_t len2)
{
unsigned long ptr1 = (unsigned long)p1;
unsigned long ptr2 = (unsigned long)p2;
if (ptr2 >= ptr1 && (ptr2 - ptr1) < len1)
return 1;
else if (ptr2 < ptr1 && (ptr1 - ptr2) < len2)
return 1;
return 0;
}
static int
is_aligned(void *p, int align)
{
unsigned long addr = (unsigned long)p;
unsigned mask = align - 1;
if (addr & mask)
return 0;
return 1;
}
static int
test_align_overlap_per_lcore(__attribute__((unused)) void *arg)
{
const unsigned align1 = 8,
align2 = 64,
align3 = 2048;
unsigned i,j;
void *p1 = NULL, *p2 = NULL, *p3 = NULL;
int ret = 0;
for (i = 0; i < N; i++) {
p1 = rte_zmalloc("dummy", 1000, align1);
if (!p1){
printf("rte_zmalloc returned NULL (i=%u)\n", i);
ret = -1;
break;
}
for(j = 0; j < 1000 ; j++) {
if( *(char *)p1 != 0) {
printf("rte_zmalloc didn't zero"
"the allocated memory\n");
ret = -1;
}
}
p2 = rte_malloc("dummy", 1000, align2);
if (!p2){
printf("rte_malloc returned NULL (i=%u)\n", i);
ret = -1;
rte_free(p1);
break;
}
p3 = rte_malloc("dummy", 1000, align3);
if (!p3){
printf("rte_malloc returned NULL (i=%u)\n", i);
ret = -1;
rte_free(p1);
rte_free(p2);
break;
}
if (is_memory_overlap(p1, 1000, p2, 1000)) {
printf("p1 and p2 overlaps\n");
ret = -1;
}
if (is_memory_overlap(p2, 1000, p3, 1000)) {
printf("p2 and p3 overlaps\n");
ret = -1;
}
if (is_memory_overlap(p1, 1000, p3, 1000)) {
printf("p1 and p3 overlaps\n");
ret = -1;
}
if (!is_aligned(p1, align1)) {
printf("p1 is not aligned\n");
ret = -1;
}
if (!is_aligned(p2, align2)) {
printf("p2 is not aligned\n");
ret = -1;
}
if (!is_aligned(p3, align3)) {
printf("p3 is not aligned\n");
ret = -1;
}
rte_free(p1);
rte_free(p2);
rte_free(p3);
}
rte_malloc_dump_stats(stdout, "dummy");
return ret;
}
static int
test_reordered_free_per_lcore(__attribute__((unused)) void *arg)
{
const unsigned align1 = 8,
align2 = 64,
align3 = 2048;
unsigned i,j;
void *p1, *p2, *p3;
int ret = 0;
for (i = 0; i < 30; i++) {
p1 = rte_zmalloc("dummy", 1000, align1);
if (!p1){
printf("rte_zmalloc returned NULL (i=%u)\n", i);
ret = -1;
break;
}
for(j = 0; j < 1000 ; j++) {
if( *(char *)p1 != 0) {
printf("rte_zmalloc didn't zero"
"the allocated memory\n");
ret = -1;
}
}
/* use calloc to allocate 1000 16-byte items this time */
p2 = rte_calloc("dummy", 1000, 16, align2);
/* for third request use regular malloc again */
p3 = rte_malloc("dummy", 1000, align3);
if (!p2 || !p3){
printf("rte_malloc returned NULL (i=%u)\n", i);
ret = -1;
break;
}
if (is_memory_overlap(p1, 1000, p2, 1000)) {
printf("p1 and p2 overlaps\n");
ret = -1;
}
if (is_memory_overlap(p2, 1000, p3, 1000)) {
printf("p2 and p3 overlaps\n");
ret = -1;
}
if (is_memory_overlap(p1, 1000, p3, 1000)) {
printf("p1 and p3 overlaps\n");
ret = -1;
}
if (!is_aligned(p1, align1)) {
printf("p1 is not aligned\n");
ret = -1;
}
if (!is_aligned(p2, align2)) {
printf("p2 is not aligned\n");
ret = -1;
}
if (!is_aligned(p3, align3)) {
printf("p3 is not aligned\n");
ret = -1;
}
/* try freeing in every possible order */
switch (i%6){
case 0:
rte_free(p1);
rte_free(p2);
rte_free(p3);
break;
case 1:
rte_free(p1);
rte_free(p3);
rte_free(p2);
break;
case 2:
rte_free(p2);
rte_free(p1);
rte_free(p3);
break;
case 3:
rte_free(p2);
rte_free(p3);
rte_free(p1);
break;
case 4:
rte_free(p3);
rte_free(p1);
rte_free(p2);
break;
case 5:
rte_free(p3);
rte_free(p2);
rte_free(p1);
break;
}
}
rte_malloc_dump_stats(stdout, "dummy");
return ret;
}
/* test function inside the malloc lib*/
static int
test_str_to_size(void)
{
struct {
const char *str;
uint64_t value;
} test_values[] =
{{ "5G", (uint64_t)5 * 1024 * 1024 *1024 },
{"0x20g", (uint64_t)0x20 * 1024 * 1024 *1024},
{"10M", 10 * 1024 * 1024},
{"050m", 050 * 1024 * 1024},
{"8K", 8 * 1024},
{"15k", 15 * 1024},
{"0200", 0200},
{"0x103", 0x103},
{"432", 432},
{"-1", 0}, /* negative values return 0 */
{" -2", 0},
{" -3MB", 0},
{"18446744073709551616", 0} /* ULLONG_MAX + 1 == out of range*/
};
unsigned i;
for (i = 0; i < sizeof(test_values)/sizeof(test_values[0]); i++)
if (rte_str_to_size(test_values[i].str) != test_values[i].value)
return -1;
return 0;
}
static int
test_multi_alloc_statistics(void)
{
int socket = 0;
struct rte_malloc_socket_stats pre_stats, post_stats ,first_stats, second_stats;
size_t size = 2048;
int align = 1024;
#ifndef RTE_LIBRTE_MALLOC_DEBUG
int trailer_size = 0;
#else
int trailer_size = RTE_CACHE_LINE_SIZE;
#endif
int overhead = RTE_CACHE_LINE_SIZE + trailer_size;
rte_malloc_get_socket_stats(socket, &pre_stats);
void *p1 = rte_malloc_socket("stats", size , align, socket);
if (!p1)
return -1;
rte_free(p1);
rte_malloc_dump_stats(stdout, "stats");
rte_malloc_get_socket_stats(socket,&post_stats);
/* Check statistics reported are correct */
/* All post stats should be equal to pre stats after alloc freed */
if ((post_stats.heap_totalsz_bytes != pre_stats.heap_totalsz_bytes) &&
(post_stats.heap_freesz_bytes!=pre_stats.heap_freesz_bytes) &&
(post_stats.heap_allocsz_bytes!=pre_stats.heap_allocsz_bytes)&&
(post_stats.alloc_count!=pre_stats.alloc_count)&&
(post_stats.free_count!=pre_stats.free_count)) {
printf("Malloc statistics are incorrect - freed alloc\n");
return -1;
}
/* Check two consecutive allocations */
size = 1024;
align = 0;
rte_malloc_get_socket_stats(socket,&pre_stats);
void *p2 = rte_malloc_socket("add", size ,align, socket);
if (!p2)
return -1;
rte_malloc_get_socket_stats(socket,&first_stats);
void *p3 = rte_malloc_socket("add2", size,align, socket);
if (!p3)
return -1;
rte_malloc_get_socket_stats(socket,&second_stats);
rte_free(p2);
rte_free(p3);
/* After freeing both allocations check stats return to original */
rte_malloc_get_socket_stats(socket, &post_stats);
if(second_stats.heap_totalsz_bytes != first_stats.heap_totalsz_bytes) {
printf("Incorrect heap statistics: Total size \n");
return -1;
}
/* Check allocated size is equal to two additions plus overhead */
if(second_stats.heap_allocsz_bytes !=
size + overhead + first_stats.heap_allocsz_bytes) {
printf("Incorrect heap statistics: Allocated size \n");
return -1;
}
/* Check that allocation count increments correctly i.e. +1 */
if (second_stats.alloc_count != first_stats.alloc_count + 1) {
printf("Incorrect heap statistics: Allocated count \n");
return -1;
}
if (second_stats.free_count != first_stats.free_count){
printf("Incorrect heap statistics: Free count \n");
return -1;
}
/* Make sure that we didn't touch our greatest chunk: 2 * 11M) */
if (post_stats.greatest_free_size != pre_stats.greatest_free_size) {
printf("Incorrect heap statistics: Greatest free size \n");
return -1;
}
/* Free size must equal the original free size minus the new allocation*/
if (first_stats.heap_freesz_bytes <= second_stats.heap_freesz_bytes) {
printf("Incorrect heap statistics: Free size \n");
return -1;
}
if ((post_stats.heap_totalsz_bytes != pre_stats.heap_totalsz_bytes) &&
(post_stats.heap_freesz_bytes!=pre_stats.heap_freesz_bytes) &&
(post_stats.heap_allocsz_bytes!=pre_stats.heap_allocsz_bytes)&&
(post_stats.alloc_count!=pre_stats.alloc_count)&&
(post_stats.free_count!=pre_stats.free_count)) {
printf("Malloc statistics are incorrect - freed alloc\n");
return -1;
}
return 0;
}
static int
test_rte_malloc_type_limits(void)
{
/* The type-limits functionality is not yet implemented,
* so always return 0 no matter what the retval.
*/
const char *typename = "limit_test";
rte_malloc_set_limit(typename, 64 * 1024);
rte_malloc_dump_stats(stdout, typename);
return 0;
}
static int
test_realloc(void)
{
const char hello_str[] = "Hello, world!";
const unsigned size1 = 1024;
const unsigned size2 = size1 + 1024;
const unsigned size3 = size2;
const unsigned size4 = size3 + 1024;
/* test data is the same even if element is moved*/
char *ptr1 = rte_zmalloc(NULL, size1, RTE_CACHE_LINE_SIZE);
if (!ptr1){
printf("NULL pointer returned from rte_zmalloc\n");
return -1;
}
snprintf(ptr1, size1, "%s" ,hello_str);
char *ptr2 = rte_realloc(ptr1, size2, RTE_CACHE_LINE_SIZE);
if (!ptr2){
rte_free(ptr1);
printf("NULL pointer returned from rte_realloc\n");
return -1;
}
if (ptr1 == ptr2){
printf("unexpected - ptr1 == ptr2\n");
}
if (strcmp(ptr2, hello_str) != 0){
printf("Error - lost data from pointed area\n");
rte_free(ptr2);
return -1;
}
unsigned i;
for (i = strnlen(hello_str, sizeof(hello_str)); i < size1; i++)
if (ptr2[i] != 0){
printf("Bad data in realloc\n");
rte_free(ptr2);
return -1;
}
/* now allocate third element, free the second
* and resize third. It should not move. (ptr1 is now invalid)
*/
char *ptr3 = rte_zmalloc(NULL, size3, RTE_CACHE_LINE_SIZE);
if (!ptr3){
printf("NULL pointer returned from rte_zmalloc\n");
rte_free(ptr2);
return -1;
}
for (i = 0; i < size3; i++)
if (ptr3[i] != 0){
printf("Bad data in zmalloc\n");
rte_free(ptr3);
rte_free(ptr2);
return -1;
}
rte_free(ptr2);
/* first resize to half the size of the freed block */
char *ptr4 = rte_realloc(ptr3, size4, RTE_CACHE_LINE_SIZE);
if (!ptr4){
printf("NULL pointer returned from rte_realloc\n");
rte_free(ptr3);
return -1;
}
if (ptr3 != ptr4){
printf("Unexpected - ptr4 != ptr3\n");
rte_free(ptr4);
return -1;
}
/* now resize again to the full size of the freed block */
ptr4 = rte_realloc(ptr3, size3 + size2 + size1, RTE_CACHE_LINE_SIZE);
if (ptr3 != ptr4){
printf("Unexpected - ptr4 != ptr3 on second resize\n");
rte_free(ptr4);
return -1;
}
rte_free(ptr4);
/* now try a resize to a smaller size, see if it works */
const unsigned size5 = 1024;
const unsigned size6 = size5 / 2;
char *ptr5 = rte_malloc(NULL, size5, RTE_CACHE_LINE_SIZE);
if (!ptr5){
printf("NULL pointer returned from rte_malloc\n");
return -1;
}
char *ptr6 = rte_realloc(ptr5, size6, RTE_CACHE_LINE_SIZE);
if (!ptr6){
printf("NULL pointer returned from rte_realloc\n");
rte_free(ptr5);
return -1;
}
if (ptr5 != ptr6){
printf("Error, resizing to a smaller size moved data\n");
rte_free(ptr6);
return -1;
}
rte_free(ptr6);
/* check for behaviour changing alignment */
const unsigned size7 = 1024;
const unsigned orig_align = RTE_CACHE_LINE_SIZE;
unsigned new_align = RTE_CACHE_LINE_SIZE * 2;
char *ptr7 = rte_malloc(NULL, size7, orig_align);
if (!ptr7){
printf("NULL pointer returned from rte_malloc\n");
return -1;
}
/* calc an alignment we don't already have */
while(RTE_PTR_ALIGN(ptr7, new_align) == ptr7)
new_align *= 2;
char *ptr8 = rte_realloc(ptr7, size7, new_align);
if (!ptr8){
printf("NULL pointer returned from rte_realloc\n");
rte_free(ptr7);
return -1;
}
if (RTE_PTR_ALIGN(ptr8, new_align) != ptr8){
printf("Failure to re-align data\n");
rte_free(ptr8);
return -1;
}
rte_free(ptr8);
/* test behaviour when there is a free block after current one,
* but its not big enough
*/
unsigned size9 = 1024, size10 = 1024;
unsigned size11 = size9 + size10 + 256;
char *ptr9 = rte_malloc(NULL, size9, RTE_CACHE_LINE_SIZE);
if (!ptr9){
printf("NULL pointer returned from rte_malloc\n");
return -1;
}
char *ptr10 = rte_malloc(NULL, size10, RTE_CACHE_LINE_SIZE);
if (!ptr10){
printf("NULL pointer returned from rte_malloc\n");
return -1;
}
rte_free(ptr9);
char *ptr11 = rte_realloc(ptr10, size11, RTE_CACHE_LINE_SIZE);
if (!ptr11){
printf("NULL pointer returned from rte_realloc\n");
rte_free(ptr10);
return -1;
}
if (ptr11 == ptr10){
printf("Error, unexpected that realloc has not created new buffer\n");
rte_free(ptr11);
return -1;
}
rte_free(ptr11);
/* check we don't crash if we pass null to realloc
* We should get a malloc of the size requested*/
const size_t size12 = 1024;
size_t size12_check;
char *ptr12 = rte_realloc(NULL, size12, RTE_CACHE_LINE_SIZE);
if (!ptr12){
printf("NULL pointer returned from rte_realloc\n");
return -1;
}
if (rte_malloc_validate(ptr12, &size12_check) < 0 ||
size12_check != size12){
rte_free(ptr12);
return -1;
}
rte_free(ptr12);
return 0;
}
static int
test_random_alloc_free(void *_ __attribute__((unused)))
{
struct mem_list {
struct mem_list *next;
char data[0];
} *list_head = NULL;
unsigned i;
unsigned count = 0;
rte_srand((unsigned)rte_rdtsc());
for (i = 0; i < N; i++){
unsigned free_mem = 0;
size_t allocated_size;
while (!free_mem){
const unsigned mem_size = sizeof(struct mem_list) + \
rte_rand() % (64 * 1024);
const unsigned align = 1 << (rte_rand() % 12); /* up to 4k alignment */
struct mem_list *entry = rte_malloc(NULL,
mem_size, align);
if (entry == NULL)
return -1;
if (RTE_PTR_ALIGN(entry, align)!= entry)
return -1;
if (rte_malloc_validate(entry, &allocated_size) == -1
|| allocated_size < mem_size)
return -1;
memset(entry->data, rte_lcore_id(),
mem_size - sizeof(*entry));
entry->next = list_head;
if (rte_malloc_validate(entry, NULL) == -1)
return -1;
list_head = entry;
count++;
/* switch to freeing the memory with a 20% probability */
free_mem = ((rte_rand() % 10) >= 8);
}
while (list_head){
struct mem_list *entry = list_head;
list_head = list_head->next;
rte_free(entry);
}
}
printf("Lcore %u allocated/freed %u blocks\n", rte_lcore_id(), count);
return 0;
}
#define err_return() do { \
printf("%s: %d - Error\n", __func__, __LINE__); \
goto err_return; \
} while (0)
static int
test_rte_malloc_validate(void)
{
const size_t request_size = 1024;
size_t allocated_size;
char *data_ptr = rte_malloc(NULL, request_size, RTE_CACHE_LINE_SIZE);
#ifdef RTE_LIBRTE_MALLOC_DEBUG
int retval;
char *over_write_vals = NULL;
#endif
if (data_ptr == NULL) {
printf("%s: %d - Allocation error\n", __func__, __LINE__);
return -1;
}
/* check that a null input returns -1 */
if (rte_malloc_validate(NULL, NULL) != -1)
err_return();
/* check that we get ok on a valid pointer */
if (rte_malloc_validate(data_ptr, &allocated_size) < 0)
err_return();
/* check that the returned size is ok */
if (allocated_size < request_size)
err_return();
#ifdef RTE_LIBRTE_MALLOC_DEBUG
/****** change the header to be bad */
char save_buf[64];
over_write_vals = (char *)((uintptr_t)data_ptr - sizeof(save_buf));
/* first save the data as a backup before overwriting it */
memcpy(save_buf, over_write_vals, sizeof(save_buf));
memset(over_write_vals, 1, sizeof(save_buf));
/* then run validate */
retval = rte_malloc_validate(data_ptr, NULL);
/* finally restore the data again */
memcpy(over_write_vals, save_buf, sizeof(save_buf));
/* check we previously had an error */
if (retval != -1)
err_return();
/* check all ok again */
if (rte_malloc_validate(data_ptr, &allocated_size) < 0)
err_return();
/**** change the trailer to be bad */
over_write_vals = (char *)((uintptr_t)data_ptr + allocated_size);
/* first save the data as a backup before overwriting it */
memcpy(save_buf, over_write_vals, sizeof(save_buf));
memset(over_write_vals, 1, sizeof(save_buf));
/* then run validate */
retval = rte_malloc_validate(data_ptr, NULL);
/* finally restore the data again */
memcpy(over_write_vals, save_buf, sizeof(save_buf));
if (retval != -1)
err_return();
/* check all ok again */
if (rte_malloc_validate(data_ptr, &allocated_size) < 0)
err_return();
#endif
rte_free(data_ptr);
return 0;
err_return:
/*clean up */
rte_free(data_ptr);
return -1;
}
static int
test_zero_aligned_alloc(void)
{
char *p1 = rte_malloc(NULL,1024, 0);
if (!p1)
goto err_return;
if (!rte_is_aligned(p1, RTE_CACHE_LINE_SIZE))
goto err_return;
rte_free(p1);
return 0;
err_return:
/*clean up */
if (p1) rte_free(p1);
return -1;
}
static int
test_malloc_bad_params(void)
{
const char *type = NULL;
size_t size = 0;
unsigned align = RTE_CACHE_LINE_SIZE;
/* rte_malloc expected to return null with inappropriate size */
char *bad_ptr = rte_malloc(type, size, align);
if (bad_ptr != NULL)
goto err_return;
/* rte_malloc expected to return null with inappropriate alignment */
align = 17;
size = 1024;
bad_ptr = rte_malloc(type, size, align);
if (bad_ptr != NULL)
goto err_return;
return 0;
err_return:
/* clean up pointer */
if (bad_ptr)
rte_free(bad_ptr);
return -1;
}
/* Check if memory is available on a specific socket */
static int
is_mem_on_socket(int32_t socket)
{
const struct rte_memseg *ms = rte_eal_get_physmem_layout();
unsigned i;
for (i = 0; i < RTE_MAX_MEMSEG; i++) {
if (socket == ms[i].socket_id)
return 1;
}
return 0;
}
/*
* Find what socket a memory address is on. Only works for addresses within
* memsegs, not heap or stack...
*/
static int32_t
addr_to_socket(void * addr)
{
const struct rte_memseg *ms = rte_eal_get_physmem_layout();
unsigned i;
for (i = 0; i < RTE_MAX_MEMSEG; i++) {
if ((ms[i].addr <= addr) &&
((uintptr_t)addr <
((uintptr_t)ms[i].addr + (uintptr_t)ms[i].len)))
return ms[i].socket_id;
}
return -1;
}
/* Test using rte_[c|m|zm]alloc_socket() on a specific socket */
static int
test_alloc_single_socket(int32_t socket)
{
const char *type = NULL;
const size_t size = 10;
const unsigned align = 0;
char *mem = NULL;
int32_t desired_socket = (socket == SOCKET_ID_ANY) ?
(int32_t)rte_socket_id() : socket;
/* Test rte_calloc_socket() */
mem = rte_calloc_socket(type, size, sizeof(char), align, socket);
if (mem == NULL)
return -1;
if (addr_to_socket(mem) != desired_socket) {
rte_free(mem);
return -1;
}
rte_free(mem);
/* Test rte_malloc_socket() */
mem = rte_malloc_socket(type, size, align, socket);
if (mem == NULL)
return -1;
if (addr_to_socket(mem) != desired_socket) {
return -1;
}
rte_free(mem);
/* Test rte_zmalloc_socket() */
mem = rte_zmalloc_socket(type, size, align, socket);
if (mem == NULL)
return -1;
if (addr_to_socket(mem) != desired_socket) {
rte_free(mem);
return -1;
}
rte_free(mem);
return 0;
}
static int
test_alloc_socket(void)
{
unsigned socket_count = 0;
unsigned i;
if (test_alloc_single_socket(SOCKET_ID_ANY) < 0)
return -1;
for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
if (is_mem_on_socket(i)) {
socket_count++;
if (test_alloc_single_socket(i) < 0) {
printf("Fail: rte_malloc_socket(..., %u) did not succeed\n",
i);
return -1;
}
}
else {
if (test_alloc_single_socket(i) == 0) {
printf("Fail: rte_malloc_socket(..., %u) succeeded\n",
i);
return -1;
}
}
}
/* Print warnign if only a single socket, but don't fail the test */
if (socket_count < 2) {
printf("WARNING: alloc_socket test needs memory on multiple sockets!\n");
}
return 0;
}
static int
test_malloc(void)
{
unsigned lcore_id;
int ret = 0;
if (test_str_to_size() < 0){
printf("test_str_to_size() failed\n");
return -1;
}
else printf("test_str_to_size() passed\n");
if (test_zero_aligned_alloc() < 0){
printf("test_zero_aligned_alloc() failed\n");
return -1;
}
else printf("test_zero_aligned_alloc() passed\n");
if (test_malloc_bad_params() < 0){
printf("test_malloc_bad_params() failed\n");
return -1;
}
else printf("test_malloc_bad_params() passed\n");
if (test_realloc() < 0){
printf("test_realloc() failed\n");
return -1;
}
else printf("test_realloc() passed\n");
/*----------------------------*/
RTE_LCORE_FOREACH_SLAVE(lcore_id) {
rte_eal_remote_launch(test_align_overlap_per_lcore, NULL, lcore_id);
}
RTE_LCORE_FOREACH_SLAVE(lcore_id) {
if (rte_eal_wait_lcore(lcore_id) < 0)
ret = -1;
}
if (ret < 0){
printf("test_align_overlap_per_lcore() failed\n");
return ret;
}
else printf("test_align_overlap_per_lcore() passed\n");
/*----------------------------*/
RTE_LCORE_FOREACH_SLAVE(lcore_id) {
rte_eal_remote_launch(test_reordered_free_per_lcore, NULL, lcore_id);
}
RTE_LCORE_FOREACH_SLAVE(lcore_id) {
if (rte_eal_wait_lcore(lcore_id) < 0)
ret = -1;
}
if (ret < 0){
printf("test_reordered_free_per_lcore() failed\n");
return ret;
}
else printf("test_reordered_free_per_lcore() passed\n");
/*----------------------------*/
RTE_LCORE_FOREACH_SLAVE(lcore_id) {
rte_eal_remote_launch(test_random_alloc_free, NULL, lcore_id);
}
RTE_LCORE_FOREACH_SLAVE(lcore_id) {
if (rte_eal_wait_lcore(lcore_id) < 0)
ret = -1;
}
if (ret < 0){
printf("test_random_alloc_free() failed\n");
return ret;
}
else printf("test_random_alloc_free() passed\n");
/*----------------------------*/
ret = test_rte_malloc_type_limits();
if (ret < 0){
printf("test_rte_malloc_type_limits() failed\n");
return ret;
}
/* TODO: uncomment following line once type limits are valid */
/*else printf("test_rte_malloc_type_limits() passed\n");*/
/*----------------------------*/
ret = test_rte_malloc_validate();
if (ret < 0){
printf("test_rte_malloc_validate() failed\n");
return ret;
}
else printf("test_rte_malloc_validate() passed\n");
ret = test_alloc_socket();
if (ret < 0){
printf("test_alloc_socket() failed\n");
return ret;
}
else printf("test_alloc_socket() passed\n");
ret = test_multi_alloc_statistics();
if (ret < 0) {
printf("test_multi_alloc_statistics() failed\n");
return ret;
}
else
printf("test_multi_alloc_statistics() passed\n");
return 0;
}
REGISTER_TEST_COMMAND(malloc_autotest, test_malloc);
|
824505.c | /* Jyothiraditya Nellakra's Solutions to Project Euler Questions */
#include <inttypes.h>
#include <stdio.h>
int main() {
int64_t choices[21][21];
for(int64_t i = 20; i > -1; i--) {
choices[i][20] = 0;
choices[20][i] = 0;
}
for(int64_t i = 19; i > -1; i--) {
for(int64_t j = i; j > -1; j--) {
choices[i][j] = choices[i + 1][j] + choices[i][j + 1] + 1;
choices[j][i] = choices[j + 1][i] + choices[j][i + 1] + 1;
}
}
printf("%" PRId64 "\n", choices[0][0] + 1);
return 0;
}
|
390145.c | /* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
/*
* Copyright (c) 2006,2007,2010,2011 Red Hat, Inc.
* All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
*
* * Neither the name of Red Hat, Inc., nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
#include <errno.h>
#include "k5-platform.h"
#include "k5-buf.h"
#include "k5-utf8.h"
#include "krb5.h"
#include <prerror.h>
#include <prmem.h>
#include <prprf.h>
#include <nss.h>
#include <cert.h>
#include <certdb.h>
#include <ciferfam.h>
#include <cms.h>
#include <keyhi.h>
#include <nssb64.h>
#include <ocsp.h>
#include <p12plcy.h>
#include <p12.h>
#include <pk11pub.h>
#include <pkcs12.h>
#include <secerr.h>
#include <secmodt.h>
#include <secmod.h>
#include <secoidt.h>
#include <secoid.h>
/* Avoid including our local copy of "pkcs11.h" from one of the local headers,
* since the definitions we want to use are going to be the ones that NSS
* provides. */
#define PKCS11_H
#include "pkinit.h"
#include "pkinit_crypto.h"
/* We should probably avoid using the default location for certificate trusts,
* unless we can be sure that the list of trusted roots isn't being shared
* with general-purpose SSL/TLS configuration, even though we're leaning on
* SSL/TLS trust settings. */
#define DEFAULT_CONFIGDIR "/etc/pki/nssdb"
/* #define DEBUG_DER "/usr/lib64/nss/unsupported-tools/derdump" */
/* #define DEBUG_SENSITIVE */
/* Define to create a temporary on-disk database when we need to import PKCS12
* identities. */
#define PKCS12_HACK
/* Prefix to mark the nicknames we make up for pkcs12 bundles that don't
* include a friendly name. */
#define PKCS12_PREFIX "pkinit-pkcs12"
/* The library name of the NSSPEM module. */
#define PEM_MODULE "nsspem"
/* Forward declaration. */
static krb5_error_code cert_retrieve_cert_sans(krb5_context context,
CERTCertificate *cert,
krb5_principal **pkinit_sans,
krb5_principal **upn_sans,
unsigned char ***kdc_hostname);
static void crypto_update_signer_identity(krb5_context,
pkinit_identity_crypto_context);
/* DomainParameters: RFC 2459, 7.3.2. */
struct domain_parameters {
SECItem p, g, q, j;
struct validation_parms *validation_parms;
};
/* Plugin and request state. */
struct _pkinit_plg_crypto_context {
PLArenaPool *pool;
NSSInitContext *ncontext;
};
struct _pkinit_req_crypto_context {
PLArenaPool *pool;
SECKEYPrivateKey *client_dh_privkey; /* used by clients */
SECKEYPublicKey *client_dh_pubkey; /* used by clients */
struct domain_parameters client_dh_params; /* used by KDCs */
CERTCertificate *peer_cert; /* the other party */
};
struct _pkinit_identity_crypto_context {
PLArenaPool *pool;
const char *identity;
SECMODModule *pem_module; /* used for FILE: and DIR: */
struct _pkinit_identity_crypto_module {
char *name;
char *spec;
SECMODModule *module;
} **id_modules; /* used for PKCS11: */
struct _pkinit_identity_crypto_userdb {
char *name;
PK11SlotInfo *userdb;
} **id_userdbs; /* used for NSS: */
struct _pkinit_identity_crypto_p12slot {
char *p12name;
PK11SlotInfo *slot;
} id_p12_slot; /* used for PKCS12: */
struct _pkinit_identity_crypto_file {
char *name;
PK11GenericObject *obj;
CERTCertificate *cert;
} **id_objects; /* used with FILE: and DIR: */
SECItem **id_crls;
CERTCertList *id_certs, *ca_certs;
CERTCertificate *id_cert;
struct {
krb5_context context;
krb5_prompter_fct prompter;
void *prompter_data;
const char *identity;
} pwcb_args;
krb5_boolean defer_id_prompt;
pkinit_deferred_id *deferred_ids;
krb5_boolean defer_with_dummy_password;
};
struct _pkinit_cert_info { /* aka _pkinit_cert_handle */
PLArenaPool *pool;
struct _pkinit_identity_crypto_context *id_cryptoctx;
CERTCertificate *cert;
};
struct _pkinit_cert_iter_info { /* aka _pkinit_cert_iter_handle */
PLArenaPool *pool;
struct _pkinit_identity_crypto_context *id_cryptoctx;
CERTCertListNode *node;
};
/* Protocol elements that we need to encode or decode. */
/* DH parameters: draft-ietf-cat-kerberos-pk-init-08.txt, 3.1.2.2. */
struct dh_parameters {
SECItem p, g, private_value_length;
};
static const SEC_ASN1Template dh_parameters_template[] = {
{
SEC_ASN1_SEQUENCE,
0,
NULL,
sizeof(struct dh_parameters),
},
{
SEC_ASN1_INTEGER,
offsetof(struct dh_parameters, p),
&SEC_IntegerTemplate,
sizeof(SECItem),
},
{
SEC_ASN1_INTEGER,
offsetof(struct dh_parameters, g),
&SEC_IntegerTemplate,
sizeof(SECItem),
},
{
SEC_ASN1_INTEGER | SEC_ASN1_OPTIONAL,
offsetof(struct dh_parameters, private_value_length),
&SEC_IntegerTemplate,
sizeof(SECItem),
},
{0, 0, NULL, 0}
};
/* ValidationParms: RFC 2459, 7.3.2. */
struct validation_parms {
SECItem seed, pgen_counter;
};
static const SEC_ASN1Template validation_parms_template[] = {
{
SEC_ASN1_SEQUENCE,
0,
NULL,
sizeof(struct validation_parms),
},
{
SEC_ASN1_BIT_STRING,
offsetof(struct validation_parms, seed),
&SEC_BitStringTemplate,
sizeof(SECItem),
},
{
SEC_ASN1_INTEGER,
offsetof(struct validation_parms, pgen_counter),
&SEC_IntegerTemplate,
sizeof(SECItem),
},
{0, 0, NULL, 0}
};
/* DomainParameters: RFC 2459, 7.3.2. */
struct domain_parameters;
static const SEC_ASN1Template domain_parameters_template[] = {
{
SEC_ASN1_SEQUENCE,
0,
NULL,
sizeof(struct domain_parameters),
},
{
SEC_ASN1_INTEGER,
offsetof(struct domain_parameters, p),
&SEC_IntegerTemplate,
sizeof(SECItem),
},
{
SEC_ASN1_INTEGER,
offsetof(struct domain_parameters, g),
&SEC_IntegerTemplate,
sizeof(SECItem),
},
{
SEC_ASN1_INTEGER,
offsetof(struct domain_parameters, q),
&SEC_IntegerTemplate,
sizeof(SECItem),
},
{
SEC_ASN1_INTEGER | SEC_ASN1_OPTIONAL,
offsetof(struct domain_parameters, j),
&SEC_IntegerTemplate,
sizeof(SECItem),
},
{
SEC_ASN1_INLINE | SEC_ASN1_POINTER | SEC_ASN1_OPTIONAL,
offsetof(struct domain_parameters, validation_parms),
&validation_parms_template,
sizeof(struct validation_parms *),
},
{0, 0, NULL, 0}
};
/* IssuerAndSerialNumber: RFC 3852, 10.2.4. */
struct issuer_and_serial_number {
SECItem issuer;
SECItem serial;
};
static const SEC_ASN1Template issuer_and_serial_number_template[] = {
{
SEC_ASN1_SEQUENCE,
0,
NULL,
sizeof(struct issuer_and_serial_number),
},
{
SEC_ASN1_ANY,
offsetof(struct issuer_and_serial_number, issuer),
&SEC_AnyTemplate,
sizeof(SECItem),
},
{
SEC_ASN1_INTEGER,
offsetof(struct issuer_and_serial_number, serial),
&SEC_IntegerTemplate,
sizeof(SECItem),
},
{0, 0, NULL, 0}
};
/* KerberosString: RFC 4120, 5.2.1. */
static const SEC_ASN1Template kerberos_string_template[] = {
{
SEC_ASN1_GENERAL_STRING,
0,
NULL,
sizeof(SECItem),
}
};
/* Realm: RFC 4120, 5.2.2. */
struct realm {
SECItem name;
};
static const SEC_ASN1Template realm_template[] = {
{
SEC_ASN1_GENERAL_STRING,
0,
NULL,
sizeof(SECItem),
}
};
/* PrincipalName: RFC 4120, 5.2.2. */
static const SEC_ASN1Template sequence_of_kerberos_string_template[] = {
{
SEC_ASN1_SEQUENCE_OF,
0,
&kerberos_string_template,
0,
}
};
struct principal_name {
SECItem name_type;
SECItem **name_string;
};
static const SEC_ASN1Template principal_name_template[] = {
{
SEC_ASN1_SEQUENCE,
0,
NULL,
sizeof(struct principal_name),
},
{
SEC_ASN1_CONTEXT_SPECIFIC | 0 | SEC_ASN1_CONSTRUCTED | SEC_ASN1_EXPLICIT,
offsetof(struct principal_name, name_type),
&SEC_IntegerTemplate,
sizeof(SECItem),
},
{
SEC_ASN1_CONTEXT_SPECIFIC | 1 | SEC_ASN1_CONSTRUCTED | SEC_ASN1_EXPLICIT,
offsetof(struct principal_name, name_string),
sequence_of_kerberos_string_template,
sizeof(struct SECItem **),
},
{0, 0, NULL, 0},
};
/* KRB5PrincipalName: RFC 4556, 3.2.2. */
struct kerberos_principal_name {
SECItem realm;
struct principal_name principal_name;
};
static const SEC_ASN1Template kerberos_principal_name_template[] = {
{
SEC_ASN1_SEQUENCE,
0,
NULL,
sizeof(struct kerberos_principal_name),
},
{
SEC_ASN1_CONTEXT_SPECIFIC | 0 | SEC_ASN1_CONSTRUCTED | SEC_ASN1_EXPLICIT,
offsetof(struct kerberos_principal_name, realm),
&realm_template,
sizeof(struct realm),
},
{
SEC_ASN1_CONTEXT_SPECIFIC | 1 | SEC_ASN1_CONSTRUCTED | SEC_ASN1_EXPLICIT,
offsetof(struct kerberos_principal_name, principal_name),
&principal_name_template,
sizeof(struct principal_name),
},
{0, 0, NULL, 0}
};
/* ContentInfo: RFC 3852, 3. */
struct content_info {
SECItem content_type, content;
};
static const SEC_ASN1Template content_info_template[] = {
{
SEC_ASN1_SEQUENCE,
0,
NULL,
sizeof(struct content_info),
},
{
SEC_ASN1_OBJECT_ID,
offsetof(struct content_info, content_type),
&SEC_ObjectIDTemplate,
sizeof(SECItem),
},
{
SEC_ASN1_CONTEXT_SPECIFIC | 0 | SEC_ASN1_CONSTRUCTED | SEC_ASN1_EXPLICIT,
offsetof(struct content_info, content),
&SEC_OctetStringTemplate,
sizeof(SECItem),
},
{0, 0, NULL, 0}
};
/* OIDs. */
static unsigned char oid_pkinit_key_purpose_client_bytes[] = {
0x2b, 0x06, 0x01, 0x05, 0x02, 0x03, 0x04
};
static SECItem pkinit_kp_client = {
siDEROID,
oid_pkinit_key_purpose_client_bytes,
7,
};
static unsigned char oid_pkinit_key_purpose_kdc_bytes[] = {
0x2b, 0x06, 0x01, 0x05, 0x02, 0x03, 0x05
};
static SECItem pkinit_kp_kdc = {
siDEROID,
oid_pkinit_key_purpose_kdc_bytes,
7,
};
static unsigned char oid_ms_sc_login_key_purpose_bytes[] = {
0x2b, 0x06, 0x01, 0x04, 0x01, 0x82, 0x37, 0x14, 0x02, 0x02
};
static SECItem pkinit_kp_mssclogin = {
siDEROID,
oid_ms_sc_login_key_purpose_bytes,
10,
};
static unsigned char oid_pkinit_name_type_principal_bytes[] = {
0x2b, 0x06, 0x01, 0x05, 0x02, 0x02
};
static SECItem pkinit_nt_principal = {
siDEROID,
oid_pkinit_name_type_principal_bytes,
6,
};
static unsigned char oid_pkinit_name_type_upn_bytes[] = {
0x2b, 0x06, 0x01, 0x04, 0x01, 0x82, 0x37, 0x14, 0x02, 0x03
};
static SECItem pkinit_nt_upn = {
siDEROID,
oid_pkinit_name_type_upn_bytes,
10,
};
static SECOidTag
get_pkinit_data_auth_data_tag(void)
{
static unsigned char oid_pkinit_auth_data_bytes[] = {
0x2b, 0x06, 0x01, 0x05, 0x02, 0x03, 0x01
};
static SECOidData oid_pkinit_auth_data = {
{
siDEROID,
oid_pkinit_auth_data_bytes,
7,
},
SEC_OID_UNKNOWN,
"PKINIT Client Authentication Data",
CKM_INVALID_MECHANISM,
UNSUPPORTED_CERT_EXTENSION,
};
if (oid_pkinit_auth_data.offset == SEC_OID_UNKNOWN)
oid_pkinit_auth_data.offset = SECOID_AddEntry(&oid_pkinit_auth_data);
return oid_pkinit_auth_data.offset;
}
static SECOidTag
get_pkinit_data_auth_data9_tag(void)
{
static unsigned char oid_pkinit_auth_data9_bytes[] =
{ 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x07, 0x01 };
static SECOidData oid_pkinit_auth_data9 = {
{
siDEROID,
oid_pkinit_auth_data9_bytes,
9,
},
SEC_OID_UNKNOWN,
"PKINIT Client Authentication Data (Draft 9)",
CKM_INVALID_MECHANISM,
UNSUPPORTED_CERT_EXTENSION,
};
if (oid_pkinit_auth_data9.offset == SEC_OID_UNKNOWN)
oid_pkinit_auth_data9.offset = SECOID_AddEntry(&oid_pkinit_auth_data9);
return oid_pkinit_auth_data9.offset;
}
static SECOidTag
get_pkinit_data_rkey_data_tag(void)
{
static unsigned char oid_pkinit_rkey_data_bytes[] = {
0x2b, 0x06, 0x01, 0x05, 0x02, 0x03, 0x03
};
static SECOidData oid_pkinit_rkey_data = {
{
siDEROID,
oid_pkinit_rkey_data_bytes,
7,
},
SEC_OID_UNKNOWN,
"PKINIT Reply Key Data",
CKM_INVALID_MECHANISM,
UNSUPPORTED_CERT_EXTENSION,
};
if (oid_pkinit_rkey_data.offset == SEC_OID_UNKNOWN)
oid_pkinit_rkey_data.offset = SECOID_AddEntry(&oid_pkinit_rkey_data);
return oid_pkinit_rkey_data.offset;
}
static SECOidTag
get_pkinit_data_dhkey_data_tag(void)
{
static unsigned char oid_pkinit_dhkey_data_bytes[] = {
0x2b, 0x06, 0x01, 0x05, 0x02, 0x03, 0x02
};
static SECOidData oid_pkinit_dhkey_data = {
{
siDEROID,
oid_pkinit_dhkey_data_bytes,
7,
},
SEC_OID_UNKNOWN,
"PKINIT DH Reply Key Data",
CKM_INVALID_MECHANISM,
UNSUPPORTED_CERT_EXTENSION,
};
if (oid_pkinit_dhkey_data.offset == SEC_OID_UNKNOWN)
oid_pkinit_dhkey_data.offset = SECOID_AddEntry(&oid_pkinit_dhkey_data);
return oid_pkinit_dhkey_data.offset;
}
static SECItem *
get_oid_from_tag(SECOidTag tag)
{
SECOidData *data;
data = SECOID_FindOIDByTag(tag);
if (data != NULL)
return &data->oid;
else
return NULL;
}
#ifdef DEBUG_DER
static void
derdump(unsigned char *data, unsigned int length)
{
FILE *p;
p = popen(DEBUG_DER, "w");
if (p != NULL) {
fwrite(data, 1, length, p);
pclose(p);
}
}
#endif
#ifdef DEBUG_CMS
static void
cmsdump(unsigned char *data, unsigned int length)
{
FILE *p;
p = popen(DEBUG_CMS, "w");
if (p != NULL) {
fwrite(data, 1, length, p);
pclose(p);
}
}
#endif
/* A password-prompt callback for NSS that calls the libkrb5 callback. */
static char *
crypto_pwfn(const char *what, PRBool is_hardware, CK_FLAGS token_flags,
PRBool retry, void *arg)
{
int ret;
pkinit_identity_crypto_context id;
krb5_prompt prompt;
krb5_prompt_type prompt_types[2];
krb5_data reply;
char *text, *answer;
const char *warning, *password;
size_t text_size;
void *data;
/* We only want to be called once. */
if (retry)
return NULL;
/* We need our callback arguments. */
if (arg == NULL)
return NULL;
id = arg;
/* If we need to warn about the PIN, figure out the text. */
if (token_flags & CKF_USER_PIN_LOCKED)
warning = "PIN locked";
else if (token_flags & CKF_USER_PIN_FINAL_TRY)
warning = "PIN final try";
else if (token_flags & CKF_USER_PIN_COUNT_LOW)
warning = "PIN count low";
else
warning = NULL;
/*
* If we have the name of an identity here, then we're either supposed to
* save its name, or attempt to use a password, if one was supplied.
*/
if (id->pwcb_args.identity != NULL) {
if (id->defer_id_prompt) {
/* If we're in the defer-prompts step, just save the identity name
* and "fail". */
if (!is_hardware)
token_flags = 0;
pkinit_set_deferred_id(&id->deferred_ids, id->pwcb_args.identity,
token_flags, NULL);
if (id->defer_with_dummy_password) {
/* Return a useless result. */
answer = PR_Malloc(1);
if (answer != NULL) {
*answer = '\0';
return answer;
}
}
} else {
/* Check if we already have a password for this identity. If so,
* just return a copy of it. */
password = pkinit_find_deferred_id(id->deferred_ids,
id->pwcb_args.identity);
if (password != NULL) {
/* The result will be freed with PR_Free, so return a copy. */
text_size = strlen(password) + 1;
answer = PR_Malloc(text_size);
if (answer != NULL) {
memcpy(answer, password, text_size);
pkiDebug("%s: returning %ld-char answer\n", __FUNCTION__,
(long)strlen(answer));
return answer;
}
}
}
}
if (id->pwcb_args.prompter == NULL)
return NULL;
/* Set up the prompt. */
text_size = strlen(what) + 100;
text = PORT_ArenaZAlloc(id->pool, text_size);
if (text == NULL) {
pkiDebug("out of memory");
return NULL;
}
if (is_hardware) {
if (warning != NULL)
snprintf(text, text_size, "%s PIN (%s)", what, warning);
else
snprintf(text, text_size, "%s PIN", what);
} else {
snprintf(text, text_size, "%s %s", _("Pass phrase for"), what);
}
memset(&prompt, 0, sizeof(prompt));
prompt.prompt = text;
prompt.hidden = 1;
prompt.reply = &reply;
reply.length = 256;
data = malloc(reply.length);
reply.data = data;
what = NULL;
answer = NULL;
/* Call the prompter callback. */
prompt_types[0] = KRB5_PROMPT_TYPE_PREAUTH;
prompt_types[1] = 0;
(*k5int_set_prompt_types)(id->pwcb_args.context, prompt_types);
fflush(NULL);
ret = (*id->pwcb_args.prompter)(id->pwcb_args.context,
id->pwcb_args.prompter_data,
what, answer, 1, &prompt);
(*k5int_set_prompt_types)(id->pwcb_args.context, NULL);
answer = NULL;
if ((ret == 0) && (reply.data != NULL)) {
/* The result will be freed with PR_Free, so return a copy. */
answer = PR_Malloc(reply.length + 1);
memcpy(answer, reply.data, reply.length);
answer[reply.length] = '\0';
answer[strcspn(answer, "\r\n")] = '\0';
#ifdef DEBUG_SENSITIVE
pkiDebug("%s: returning \"%s\"\n", __FUNCTION__, answer);
#else
pkiDebug("%s: returning %ld-char answer\n", __FUNCTION__,
(long) strlen(answer));
#endif
}
if (reply.data == data)
free(reply.data);
return answer;
}
/* A password-prompt callback for NSS that calls the libkrb5 callback. */
static char *
crypto_pwcb(PK11SlotInfo *slot, PRBool retry, void *arg)
{
pkinit_identity_crypto_context id;
const char *what = NULL;
CK_TOKEN_INFO tinfo;
CK_FLAGS tflags;
if (PK11_GetTokenInfo(slot, &tinfo) == SECSuccess)
tflags = tinfo.flags;
else
tflags = 0;
if (arg != NULL) {
id = arg;
what = id->pwcb_args.identity;
}
return crypto_pwfn((what != NULL) ? what : PK11_GetTokenName(slot),
PK11_IsHW(slot), tflags, retry, arg);
}
/*
* Make sure we're using our callback, and set up the callback data.
*/
static void *
crypto_pwcb_prep(pkinit_identity_crypto_context id_cryptoctx,
const char *identity, krb5_context context)
{
PK11_SetPasswordFunc(crypto_pwcb);
id_cryptoctx->pwcb_args.context = context;
id_cryptoctx->pwcb_args.identity = identity;
return id_cryptoctx;
}
krb5_error_code
pkinit_init_identity_crypto(pkinit_identity_crypto_context *id_cryptoctx)
{
PLArenaPool *pool;
pkinit_identity_crypto_context id;
pkiDebug("%s\n", __FUNCTION__);
pool = PORT_NewArena(sizeof(double));
if (pool == NULL)
return ENOMEM;
id = PORT_ArenaZAlloc(pool, sizeof(*id));
if (id == NULL) {
PORT_FreeArena(pool, PR_TRUE);
return ENOMEM;
}
id->pool = pool;
id->id_certs = CERT_NewCertList();
id->ca_certs = CERT_NewCertList();
if ((id->id_certs != NULL) && (id->ca_certs != NULL)) {
*id_cryptoctx = id;
return 0;
}
if (id->ca_certs != NULL)
CERT_DestroyCertList(id->ca_certs);
if (id->id_certs != NULL)
CERT_DestroyCertList(id->id_certs);
PORT_FreeArena(pool, PR_TRUE);
return ENOMEM;
}
/* Return the slot which we'll use for holding imported PKCS12 certificates
* and keys. Open the module if we need to, first. */
static PK11SlotInfo *
crypto_get_p12_slot(struct _pkinit_identity_crypto_context *id)
{
char *configdir, *spec;
size_t spec_size;
int attempts;
if (id->id_p12_slot.slot == NULL) {
configdir = DEFAULT_CONFIGDIR;
#ifdef PKCS12_HACK
/* Figure out where to put the temporary userdb. */
attempts = 0;
while ((attempts < TMP_MAX) &&
(spec = tempnam(NULL, "pk12-")) != NULL) {
if (spec != NULL) {
if (mkdir(spec, S_IRWXU) == 0) {
configdir = spec;
break;
} else {
free(spec);
if (errno != EEXIST)
break;
}
attempts++;
}
}
#endif
spec_size = strlen("configDir='' flags=readOnly") +
strlen(configdir) + 1;
spec = PORT_ArenaZAlloc(id->pool, spec_size);
if (spec != NULL) {
if (strcmp(configdir, DEFAULT_CONFIGDIR) != 0)
snprintf(spec, spec_size, "configDir='%s'", configdir);
else
snprintf(spec, spec_size, "configDir='%s' flags=readOnly",
configdir);
id->id_p12_slot.slot = SECMOD_OpenUserDB(spec);
}
#ifdef PKCS12_HACK
if (strcmp(configdir, DEFAULT_CONFIGDIR) != 0) {
DIR *dir;
struct dirent *ent;
char *path;
/* First, initialize the slot. */
if (id->id_p12_slot.slot != NULL)
if (PK11_NeedUserInit(id->id_p12_slot.slot))
PK11_InitPin(id->id_p12_slot.slot, "", "");
/* Scan the directory, deleting all of the contents. */
dir = opendir(configdir);
if (dir == NULL)
pkiDebug("%s: error removing directory \"%s\": %s\n",
__FUNCTION__, configdir, strerror(errno));
else {
while ((ent = readdir(dir)) != NULL) {
if ((strcmp(ent->d_name, ".") == 0) ||
(strcmp(ent->d_name, "..") == 0)) {
continue;
}
if (k5_path_join(configdir, ent->d_name, &path) == 0) {
remove(path);
free(path);
}
}
closedir(dir);
}
/* Remove the directory itself. */
rmdir(configdir);
free(configdir);
}
}
#endif
return id->id_p12_slot.slot;
}
/* Close the slot which we've been using for holding imported PKCS12
* certificates and keys. */
static void
crypto_close_p12_slot(struct _pkinit_identity_crypto_context *id)
{
PK11_FreeSlot(id->id_p12_slot.slot);
id->id_p12_slot.slot = NULL;
}
void
pkinit_fini_identity_crypto(pkinit_identity_crypto_context id_cryptoctx)
{
int i;
pkiDebug("%s\n", __FUNCTION__);
/* The order of cleanup here is intended to ensure that nothing gets
* freed before anything that might have a reference to it. */
if (id_cryptoctx->deferred_ids != NULL)
pkinit_free_deferred_ids(id_cryptoctx->deferred_ids);
if (id_cryptoctx->id_cert != NULL)
CERT_DestroyCertificate(id_cryptoctx->id_cert);
CERT_DestroyCertList(id_cryptoctx->ca_certs);
CERT_DestroyCertList(id_cryptoctx->id_certs);
if (id_cryptoctx->id_objects != NULL)
for (i = 0; id_cryptoctx->id_objects[i] != NULL; i++) {
if (id_cryptoctx->id_objects[i]->cert != NULL)
CERT_DestroyCertificate(id_cryptoctx->id_objects[i]->cert);
PK11_DestroyGenericObject(id_cryptoctx->id_objects[i]->obj);
}
if (id_cryptoctx->id_p12_slot.slot != NULL)
crypto_close_p12_slot(id_cryptoctx);
if (id_cryptoctx->id_userdbs != NULL)
for (i = 0; id_cryptoctx->id_userdbs[i] != NULL; i++)
PK11_FreeSlot(id_cryptoctx->id_userdbs[i]->userdb);
if (id_cryptoctx->id_modules != NULL) {
for (i = 0; id_cryptoctx->id_modules[i] != NULL; i++) {
if (id_cryptoctx->id_modules[i]->module != NULL)
SECMOD_DestroyModule(id_cryptoctx->id_modules[i]->module);
}
}
if (id_cryptoctx->id_crls != NULL)
for (i = 0; id_cryptoctx->id_crls[i] != NULL; i++)
CERT_UncacheCRL(CERT_GetDefaultCertDB(), id_cryptoctx->id_crls[i]);
if (id_cryptoctx->pem_module != NULL)
SECMOD_DestroyModule(id_cryptoctx->pem_module);
PORT_FreeArena(id_cryptoctx->pool, PR_TRUE);
}
static SECStatus
crypto_register_any(SECOidTag tag)
{
if (NSS_CMSType_RegisterContentType(tag,
NULL,
0,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL, NULL, PR_TRUE) != SECSuccess)
return ENOMEM;
return 0;
}
krb5_error_code
pkinit_init_plg_crypto(pkinit_plg_crypto_context *plg_cryptoctx)
{
PLArenaPool *pool;
SECOidTag tag;
pkiDebug("%s\n", __FUNCTION__);
pool = PORT_NewArena(sizeof(double));
if (pool != NULL) {
*plg_cryptoctx = PORT_ArenaZAlloc(pool, sizeof(**plg_cryptoctx));
if (*plg_cryptoctx != NULL) {
(*plg_cryptoctx)->pool = pool;
(*plg_cryptoctx)->ncontext = NSS_InitContext(DEFAULT_CONFIGDIR,
NULL,
NULL,
NULL,
NULL,
NSS_INIT_READONLY |
NSS_INIT_NOCERTDB |
NSS_INIT_NOMODDB |
NSS_INIT_FORCEOPEN |
NSS_INIT_NOROOTINIT |
NSS_INIT_PK11RELOAD);
if ((*plg_cryptoctx)->ncontext != NULL) {
tag = get_pkinit_data_auth_data9_tag();
if (crypto_register_any(tag) != SECSuccess) {
PORT_FreeArena(pool, PR_TRUE);
return ENOMEM;
}
tag = get_pkinit_data_auth_data_tag();
if (crypto_register_any(tag) != SECSuccess) {
PORT_FreeArena(pool, PR_TRUE);
return ENOMEM;
}
tag = get_pkinit_data_rkey_data_tag();
if (crypto_register_any(tag) != SECSuccess) {
PORT_FreeArena(pool, PR_TRUE);
return ENOMEM;
}
tag = get_pkinit_data_dhkey_data_tag();
if (crypto_register_any(tag) != SECSuccess) {
PORT_FreeArena(pool, PR_TRUE);
return ENOMEM;
}
return 0;
}
}
PORT_FreeArena(pool, PR_TRUE);
}
return ENOMEM;
}
void
pkinit_fini_plg_crypto(pkinit_plg_crypto_context plg_cryptoctx)
{
pkiDebug("%s\n", __FUNCTION__);
if (plg_cryptoctx == NULL)
return;
if (NSS_ShutdownContext(plg_cryptoctx->ncontext) != SECSuccess)
pkiDebug("%s: error shutting down context\n", __FUNCTION__);
PORT_FreeArena(plg_cryptoctx->pool, PR_TRUE);
}
krb5_error_code
pkinit_init_req_crypto(pkinit_req_crypto_context *req_cryptoctx)
{
PLArenaPool *pool;
pkiDebug("%s\n", __FUNCTION__);
pool = PORT_NewArena(sizeof(double));
if (pool != NULL) {
*req_cryptoctx = PORT_ArenaZAlloc(pool, sizeof(**req_cryptoctx));
if (*req_cryptoctx != NULL) {
(*req_cryptoctx)->pool = pool;
return 0;
}
PORT_FreeArena(pool, PR_TRUE);
}
return ENOMEM;
}
void
pkinit_fini_req_crypto(pkinit_req_crypto_context req_cryptoctx)
{
pkiDebug("%s\n", __FUNCTION__);
if (req_cryptoctx->client_dh_privkey != NULL)
SECKEY_DestroyPrivateKey(req_cryptoctx->client_dh_privkey);
if (req_cryptoctx->client_dh_pubkey != NULL)
SECKEY_DestroyPublicKey(req_cryptoctx->client_dh_pubkey);
if (req_cryptoctx->peer_cert != NULL)
CERT_DestroyCertificate(req_cryptoctx->peer_cert);
PORT_FreeArena(req_cryptoctx->pool, PR_TRUE);
}
/* Duplicate the memory from the SECItem into a malloc()d buffer. */
static int
secitem_to_buf_len(SECItem *item, unsigned char **out, unsigned int *len)
{
*out = malloc(item->len);
if (*out == NULL)
return ENOMEM;
memcpy(*out, item->data, item->len);
*len = item->len;
return 0;
}
/* Encode the raw buffer as an unsigned integer. If the first byte in the
* buffer has its high bit set, we need to prepend a zero byte to make sure it
* isn't treated as a negative value. */
static int
secitem_to_dh_pubval(SECItem *item, unsigned char **out, unsigned int *len)
{
PLArenaPool *pool;
SECItem *uval, uinteger;
int i;
pool = PORT_NewArena(sizeof(double));
if (pool == NULL)
return ENOMEM;
if (item->data[0] & 0x80) {
uval = SECITEM_AllocItem(pool, NULL, item->len + 1);
if (uval == NULL) {
PORT_FreeArena(pool, PR_TRUE);
return ENOMEM;
}
uval->data[0] = '\0';
memcpy(uval->data + 1, item->data, item->len);
} else {
uval = item;
}
memset(&uinteger, 0, sizeof(uinteger));
if (SEC_ASN1EncodeItem(pool, &uinteger, uval,
SEC_ASN1_GET(SEC_IntegerTemplate)) != &uinteger) {
PORT_FreeArena(pool, PR_TRUE);
return ENOMEM;
}
i = secitem_to_buf_len(&uinteger, out, len);
PORT_FreeArena(pool, PR_TRUE);
return i;
}
/* Decode a DER unsigned integer, and return just the bits that make up that
* integer. */
static int
secitem_from_dh_pubval(PLArenaPool *pool,
unsigned char *dh_pubkey, unsigned int dh_pubkey_len,
SECItem *bits_out)
{
SECItem tmp;
tmp.data = dh_pubkey;
tmp.len = dh_pubkey_len;
memset(bits_out, 0, sizeof(*bits_out));
if (SEC_ASN1DecodeItem(pool, bits_out,
SEC_ASN1_GET(SEC_IntegerTemplate),
&tmp) != SECSuccess)
return ENOMEM;
return 0;
}
/* Load the contents of a file into a SECitem. If it looks like a PEM-wrapped
* item, maybe try to undo the base64 encoding. */
enum secitem_from_file_type {
secitem_from_file_plain,
secitem_from_file_decode
};
static int
secitem_from_file(PLArenaPool *pool, const char *filename,
enum secitem_from_file_type secitem_from_file_type,
SECItem *item_out)
{
SECItem tmp, *decoded;
struct stat st;
int fd, i, n;
const char *encoded, *p;
char *what, *q;
memset(item_out, 0, sizeof(*item_out));
fd = open(filename, O_RDONLY);
if (fd == -1)
return errno;
if (fstat(fd, &st) == -1) {
i = errno;
close(fd);
return i;
}
memset(&tmp, 0, sizeof(tmp));
tmp.data = PORT_ArenaZAlloc(pool, st.st_size + 1);
if (tmp.data == NULL) {
close(fd);
return ENOMEM;
}
n = 0;
while (n < st.st_size) {
i = read(fd, tmp.data + n, st.st_size - n);
if (i <= 0)
break;
n += i;
}
close(fd);
if (n < st.st_size)
return ENOMEM;
tmp.data[n] = '\0';
tmp.len = n;
encoded = (const char *) tmp.data;
if ((secitem_from_file_type == secitem_from_file_decode) &&
(tmp.len > 11) &&
((strncmp(encoded, "-----BEGIN ", 11) == 0) ||
((encoded = strstr((char *)tmp.data, "\n-----BEGIN")) != NULL))) {
if (encoded[0] == '\n')
encoded++;
/* find the beginning of the next line */
p = encoded;
p += strcspn(p, "\r\n");
p += strspn(p, "\r\n");
q = NULL;
what = PORT_ArenaZAlloc(pool, p - (encoded + 2) + 1);
if (what != NULL) {
/* construct the matching end-of-item and look for it */
memcpy(what, "-----END ", 9);
memcpy(what + 9, encoded + 11, p - (encoded + 11));
what[p - (encoded + 2)] = '\0';
q = strstr(p, what);
}
if (q != NULL) {
*q = '\0';
decoded = NSSBase64_DecodeBuffer(pool, NULL, p, q - p);
if (decoded != NULL)
tmp = *decoded;
}
}
*item_out = tmp;
return 0;
}
static struct oakley_group
{
int identifier;
int bits; /* shortest prime first, so that a
* sequential search for a set with a
* length that exceeds the minimum will
* find the entry with the shortest
* suitable prime */
char name[32];
char prime[4096]; /* large enough to hold that prime */
long generator; /* note: oakley_parse_group() assumes that this
* number fits into a long */
char subprime[4096]; /* large enough to hold its subprime
* ((p-1)/2) */
} oakley_groups[] = {
{
1, 768,
"Oakley MODP Group 1",
"FFFFFFFF FFFFFFFF C90FDAA2 2168C234 C4C6628B 80DC1CD1"
"29024E08 8A67CC74 020BBEA6 3B139B22 514A0879 8E3404DD"
"EF9519B3 CD3A431B 302B0A6D F25F1437 4FE1356D 6D51C245"
"E485B576 625E7EC6 F44C42E9 A63A3620 FFFFFFFF FFFFFFFF",
2,
"7FFFFFFF FFFFFFFF E487ED51 10B4611A 62633145 C06E0E68"
"94812704 4533E63A 0105DF53 1D89CD91 28A5043C C71A026E"
"F7CA8CD9 E69D218D 98158536 F92F8A1B A7F09AB6 B6A8E122"
"F242DABB 312F3F63 7A262174 D31D1B10 7FFFFFFF FFFFFFFF",
},
{
2, 1024,
"Oakley MODP Group 2",
"FFFFFFFF FFFFFFFF C90FDAA2 2168C234 C4C6628B 80DC1CD1"
"29024E08 8A67CC74 020BBEA6 3B139B22 514A0879 8E3404DD"
"EF9519B3 CD3A431B 302B0A6D F25F1437 4FE1356D 6D51C245"
"E485B576 625E7EC6 F44C42E9 A637ED6B 0BFF5CB6 F406B7ED"
"EE386BFB 5A899FA5 AE9F2411 7C4B1FE6 49286651 ECE65381"
"FFFFFFFF FFFFFFFF",
2,
"7FFFFFFF FFFFFFFF E487ED51 10B4611A 62633145 C06E0E68"
"94812704 4533E63A 0105DF53 1D89CD91 28A5043C C71A026E"
"F7CA8CD9 E69D218D 98158536 F92F8A1B A7F09AB6 B6A8E122"
"F242DABB 312F3F63 7A262174 D31BF6B5 85FFAE5B 7A035BF6"
"F71C35FD AD44CFD2 D74F9208 BE258FF3 24943328 F67329C0"
"FFFFFFFF FFFFFFFF",
},
{
5, 1536,
"Oakley MODP Group 5",
"FFFFFFFF FFFFFFFF C90FDAA2 2168C234 C4C6628B 80DC1CD1"
"29024E08 8A67CC74 020BBEA6 3B139B22 514A0879 8E3404DD"
"EF9519B3 CD3A431B 302B0A6D F25F1437 4FE1356D 6D51C245"
"E485B576 625E7EC6 F44C42E9 A637ED6B 0BFF5CB6 F406B7ED"
"EE386BFB 5A899FA5 AE9F2411 7C4B1FE6 49286651 ECE45B3D"
"C2007CB8 A163BF05 98DA4836 1C55D39A 69163FA8 FD24CF5F"
"83655D23 DCA3AD96 1C62F356 208552BB 9ED52907 7096966D"
"670C354E 4ABC9804 F1746C08 CA237327 FFFFFFFF FFFFFFFF",
2,
"7FFFFFFF FFFFFFFF E487ED51 10B4611A 62633145 C06E0E68"
"94812704 4533E63A 0105DF53 1D89CD91 28A5043C C71A026E"
"F7CA8CD9 E69D218D 98158536 F92F8A1B A7F09AB6 B6A8E122"
"F242DABB 312F3F63 7A262174 D31BF6B5 85FFAE5B 7A035BF6"
"F71C35FD AD44CFD2 D74F9208 BE258FF3 24943328 F6722D9E"
"E1003E5C 50B1DF82 CC6D241B 0E2AE9CD 348B1FD4 7E9267AF"
"C1B2AE91 EE51D6CB 0E3179AB 1042A95D CF6A9483 B84B4B36"
"B3861AA7 255E4C02 78BA3604 6511B993 FFFFFFFF FFFFFFFF",
},
{
14, 2048,
"Oakley MODP Group 14",
"FFFFFFFF FFFFFFFF C90FDAA2 2168C234 C4C6628B 80DC1CD1"
"29024E08 8A67CC74 020BBEA6 3B139B22 514A0879 8E3404DD"
"EF9519B3 CD3A431B 302B0A6D F25F1437 4FE1356D 6D51C245"
"E485B576 625E7EC6 F44C42E9 A637ED6B 0BFF5CB6 F406B7ED"
"EE386BFB 5A899FA5 AE9F2411 7C4B1FE6 49286651 ECE45B3D"
"C2007CB8 A163BF05 98DA4836 1C55D39A 69163FA8 FD24CF5F"
"83655D23 DCA3AD96 1C62F356 208552BB 9ED52907 7096966D"
"670C354E 4ABC9804 F1746C08 CA18217C 32905E46 2E36CE3B"
"E39E772C 180E8603 9B2783A2 EC07A28F B5C55DF0 6F4C52C9"
"DE2BCBF6 95581718 3995497C EA956AE5 15D22618 98FA0510"
"15728E5A 8AACAA68 FFFFFFFF FFFFFFFF",
2,
"7FFFFFFF FFFFFFFF E487ED51 10B4611A 62633145 C06E0E68"
"94812704 4533E63A 0105DF53 1D89CD91 28A5043C C71A026E"
"F7CA8CD9 E69D218D 98158536 F92F8A1B A7F09AB6 B6A8E122"
"F242DABB 312F3F63 7A262174 D31BF6B5 85FFAE5B 7A035BF6"
"F71C35FD AD44CFD2 D74F9208 BE258FF3 24943328 F6722D9E"
"E1003E5C 50B1DF82 CC6D241B 0E2AE9CD 348B1FD4 7E9267AF"
"C1B2AE91 EE51D6CB 0E3179AB 1042A95D CF6A9483 B84B4B36"
"B3861AA7 255E4C02 78BA3604 650C10BE 19482F23 171B671D"
"F1CF3B96 0C074301 CD93C1D1 7603D147 DAE2AEF8 37A62964"
"EF15E5FB 4AAC0B8C 1CCAA4BE 754AB572 8AE9130C 4C7D0288"
"0AB9472D 45565534 7FFFFFFF FFFFFFFF",
},
{
15, 3072,
"Oakley MODP Group 15",
"FFFFFFFF FFFFFFFF C90FDAA2 2168C234 C4C6628B 80DC1CD1"
"29024E08 8A67CC74 020BBEA6 3B139B22 514A0879 8E3404DD"
"EF9519B3 CD3A431B 302B0A6D F25F1437 4FE1356D 6D51C245"
"E485B576 625E7EC6 F44C42E9 A637ED6B 0BFF5CB6 F406B7ED"
"EE386BFB 5A899FA5 AE9F2411 7C4B1FE6 49286651 ECE45B3D"
"C2007CB8 A163BF05 98DA4836 1C55D39A 69163FA8 FD24CF5F"
"83655D23 DCA3AD96 1C62F356 208552BB 9ED52907 7096966D"
"670C354E 4ABC9804 F1746C08 CA18217C 32905E46 2E36CE3B"
"E39E772C 180E8603 9B2783A2 EC07A28F B5C55DF0 6F4C52C9"
"DE2BCBF6 95581718 3995497C EA956AE5 15D22618 98FA0510"
"15728E5A 8AAAC42D AD33170D 04507A33 A85521AB DF1CBA64"
"ECFB8504 58DBEF0A 8AEA7157 5D060C7D B3970F85 A6E1E4C7"
"ABF5AE8C DB0933D7 1E8C94E0 4A25619D CEE3D226 1AD2EE6B"
"F12FFA06 D98A0864 D8760273 3EC86A64 521F2B18 177B200C"
"BBE11757 7A615D6C 770988C0 BAD946E2 08E24FA0 74E5AB31"
"43DB5BFC E0FD108E 4B82D120 A93AD2CA FFFFFFFF FFFFFFFF",
2,
"7FFFFFFF FFFFFFFF E487ED51 10B4611A 62633145 C06E0E68"
"94812704 4533E63A 0105DF53 1D89CD91 28A5043C C71A026E"
"F7CA8CD9 E69D218D 98158536 F92F8A1B A7F09AB6 B6A8E122"
"F242DABB 312F3F63 7A262174 D31BF6B5 85FFAE5B 7A035BF6"
"F71C35FD AD44CFD2 D74F9208 BE258FF3 24943328 F6722D9E"
"E1003E5C 50B1DF82 CC6D241B 0E2AE9CD 348B1FD4 7E9267AF"
"C1B2AE91 EE51D6CB 0E3179AB 1042A95D CF6A9483 B84B4B36"
"B3861AA7 255E4C02 78BA3604 650C10BE 19482F23 171B671D"
"F1CF3B96 0C074301 CD93C1D1 7603D147 DAE2AEF8 37A62964"
"EF15E5FB 4AAC0B8C 1CCAA4BE 754AB572 8AE9130C 4C7D0288"
"0AB9472D 45556216 D6998B86 82283D19 D42A90D5 EF8E5D32"
"767DC282 2C6DF785 457538AB AE83063E D9CB87C2 D370F263"
"D5FAD746 6D8499EB 8F464A70 2512B0CE E771E913 0D697735"
"F897FD03 6CC50432 6C3B0139 9F643532 290F958C 0BBD9006"
"5DF08BAB BD30AEB6 3B84C460 5D6CA371 047127D0 3A72D598"
"A1EDADFE 707E8847 25C16890 549D6965 7FFFFFFF FFFFFFFF",
},
{
16, 4096,
"Oakley MODP Group 16",
"FFFFFFFF FFFFFFFF C90FDAA2 2168C234 C4C6628B 80DC1CD1"
"29024E08 8A67CC74 020BBEA6 3B139B22 514A0879 8E3404DD"
"EF9519B3 CD3A431B 302B0A6D F25F1437 4FE1356D 6D51C245"
"E485B576 625E7EC6 F44C42E9 A637ED6B 0BFF5CB6 F406B7ED"
"EE386BFB 5A899FA5 AE9F2411 7C4B1FE6 49286651 ECE45B3D"
"C2007CB8 A163BF05 98DA4836 1C55D39A 69163FA8 FD24CF5F"
"83655D23 DCA3AD96 1C62F356 208552BB 9ED52907 7096966D"
"670C354E 4ABC9804 F1746C08 CA18217C 32905E46 2E36CE3B"
"E39E772C 180E8603 9B2783A2 EC07A28F B5C55DF0 6F4C52C9"
"DE2BCBF6 95581718 3995497C EA956AE5 15D22618 98FA0510"
"15728E5A 8AAAC42D AD33170D 04507A33 A85521AB DF1CBA64"
"ECFB8504 58DBEF0A 8AEA7157 5D060C7D B3970F85 A6E1E4C7"
"ABF5AE8C DB0933D7 1E8C94E0 4A25619D CEE3D226 1AD2EE6B"
"F12FFA06 D98A0864 D8760273 3EC86A64 521F2B18 177B200C"
"BBE11757 7A615D6C 770988C0 BAD946E2 08E24FA0 74E5AB31"
"43DB5BFC E0FD108E 4B82D120 A9210801 1A723C12 A787E6D7"
"88719A10 BDBA5B26 99C32718 6AF4E23C 1A946834 B6150BDA"
"2583E9CA 2AD44CE8 DBBBC2DB 04DE8EF9 2E8EFC14 1FBECAA6"
"287C5947 4E6BC05D 99B2964F A090C3A2 233BA186 515BE7ED"
"1F612970 CEE2D7AF B81BDD76 2170481C D0069127 D5B05AA9"
"93B4EA98 8D8FDDC1 86FFB7DC 90A6C08F 4DF435C9 34063199"
"FFFFFFFF FFFFFFFF",
2,
"7FFFFFFF FFFFFFFF E487ED51 10B4611A 62633145 C06E0E68"
"94812704 4533E63A 0105DF53 1D89CD91 28A5043C C71A026E"
"F7CA8CD9 E69D218D 98158536 F92F8A1B A7F09AB6 B6A8E122"
"F242DABB 312F3F63 7A262174 D31BF6B5 85FFAE5B 7A035BF6"
"F71C35FD AD44CFD2 D74F9208 BE258FF3 24943328 F6722D9E"
"E1003E5C 50B1DF82 CC6D241B 0E2AE9CD 348B1FD4 7E9267AF"
"C1B2AE91 EE51D6CB 0E3179AB 1042A95D CF6A9483 B84B4B36"
"B3861AA7 255E4C02 78BA3604 650C10BE 19482F23 171B671D"
"F1CF3B96 0C074301 CD93C1D1 7603D147 DAE2AEF8 37A62964"
"EF15E5FB 4AAC0B8C 1CCAA4BE 754AB572 8AE9130C 4C7D0288"
"0AB9472D 45556216 D6998B86 82283D19 D42A90D5 EF8E5D32"
"767DC282 2C6DF785 457538AB AE83063E D9CB87C2 D370F263"
"D5FAD746 6D8499EB 8F464A70 2512B0CE E771E913 0D697735"
"F897FD03 6CC50432 6C3B0139 9F643532 290F958C 0BBD9006"
"5DF08BAB BD30AEB6 3B84C460 5D6CA371 047127D0 3A72D598"
"A1EDADFE 707E8847 25C16890 54908400 8D391E09 53C3F36B"
"C438CD08 5EDD2D93 4CE1938C 357A711E 0D4A341A 5B0A85ED"
"12C1F4E5 156A2674 6DDDE16D 826F477C 97477E0A 0FDF6553"
"143E2CA3 A735E02E CCD94B27 D04861D1 119DD0C3 28ADF3F6"
"8FB094B8 67716BD7 DC0DEEBB 10B8240E 68034893 EAD82D54"
"C9DA754C 46C7EEE0 C37FDBEE 48536047 A6FA1AE4 9A0318CC"
"FFFFFFFF FFFFFFFF",
}
};
/* Convert a string of hexadecimal characters to a binary integer. */
static SECItem *
hex_to_secitem(const char *hex, SECItem *item)
{
int count, i;
unsigned int j;
unsigned char c, acc;
j = 0;
c = hex[0];
/* If the high bit would be set, prepend a zero byte to keep the result
* from being negative. */
if ((c == '8') ||
(c == '9') ||
((c >= 'a') && (c <= 'f')) || ((c >= 'A') && (c <= 'F'))) {
item->data[j] = 0;
j++;
}
count = 0;
acc = 0;
for (i = 0; hex[i] != '\0'; i++) {
if ((count % 2) == 0)
acc = 0;
c = hex[i];
if ((c >= '0') && (c <= '9'))
acc = (acc << 4) | (c - '0');
else if ((c >= 'a') && (c <= 'f'))
acc = (acc << 4) | (c - 'a' + 10);
else if ((c >= 'A') && (c <= 'F'))
acc = (acc << 4) | (c - 'A' + 10);
else
continue;
count++;
if ((count % 2) == 0) {
item->data[j] = acc & 0xff;
acc = 0;
j++;
}
if (j >= item->len) {
/* overrun */
return NULL;
break;
}
}
if (hex[i] != '\0') /* unused bytes? */
return NULL;
item->len = j;
return item;
}
static int
oakley_parse_group(PLArenaPool *pool, struct oakley_group *group,
struct domain_parameters **domain_params_out)
{
unsigned int bytes;
struct domain_parameters *params;
SECItem *t;
params = PORT_ArenaZAlloc(pool, sizeof(*params));
if (params == NULL)
return ENOMEM;
/* Allocate more memory than we'll probably need. */
bytes = group->bits;
/* Encode the prime (p). */
t = SECITEM_AllocItem(pool, NULL, bytes);
if (t == NULL)
return ENOMEM;
if (hex_to_secitem(group->prime, t) != t)
return ENOMEM;
params->p = *t;
/* Encode the generator. */
if (SEC_ASN1EncodeInteger(pool, ¶ms->g,
group->generator) != ¶ms->g)
return ENOMEM;
/* Encode the subprime. */
t = SECITEM_AllocItem(pool, NULL, bytes);
if (t == NULL)
return ENOMEM;
if (hex_to_secitem(group->subprime, t) != t)
return ENOMEM;
params->q = *t;
*domain_params_out = params;
return 0;
}
static struct domain_parameters *
oakley_get_group(PLArenaPool *pool, int minimum_prime_size)
{
unsigned int i;
struct domain_parameters *params;
params = PORT_ArenaZAlloc(pool, sizeof(*params));
if (params == NULL)
return NULL;
for (i = 0; i < sizeof(oakley_groups) / sizeof(oakley_groups[0]); i++)
if (oakley_groups[i].bits >= minimum_prime_size)
if (oakley_parse_group(pool, &oakley_groups[i], ¶ms) == 0)
return params;
return NULL;
}
/* Create DH parameters to be sent to the KDC. On success, dh_params should
* contain an encoded DomainParameters structure (per RFC3280, the "parameters"
* in an AlgorithmIdentifier), and dh_pubkey should contain the public value
* we're prepared to send to the KDC, encoded as an integer (per RFC3280, the
* "subjectPublicKey" field of a SubjectPublicKeyInfo -- the integer is wrapped
* up into a bitstring elsewhere). */
krb5_error_code
client_create_dh(krb5_context context,
pkinit_plg_crypto_context plg_cryptoctx,
pkinit_req_crypto_context req_cryptoctx,
pkinit_identity_crypto_context id_cryptoctx,
int dh_size_bits,
unsigned char **dh_params,
unsigned int *dh_params_len,
unsigned char **dh_pubkey, unsigned int *dh_pubkey_len)
{
PLArenaPool *pool;
PK11SlotInfo *slot;
SECKEYPrivateKey *priv;
SECKEYPublicKey *pub;
SECKEYDHParams dh_param;
struct domain_parameters *params;
SECItem encoded;
pool = PORT_NewArena(sizeof(double));
if (pool == NULL)
return ENOMEM;
memset(¶ms, 0, sizeof(params));
/* Find suitable domain parameters. */
params = oakley_get_group(pool, dh_size_bits);
if (params == NULL) {
pkiDebug("%s: error finding suitable parameters\n", __FUNCTION__);
return ENOENT;
}
/* Set up to generate the public key. */
memset(&dh_param, 0, sizeof(dh_param));
dh_param.arena = pool;
dh_param.prime = params->p;
dh_param.base = params->g;
/* Generate a public value and a private key. */
slot = PK11_GetBestSlot(CKM_DH_PKCS_KEY_PAIR_GEN,
crypto_pwcb_prep(id_cryptoctx, NULL, context));
if (slot == NULL) {
PORT_FreeArena(pool, PR_TRUE);
pkiDebug("%s: error selecting slot\n", __FUNCTION__);
return ENOMEM;
}
pub = NULL;
priv = PK11_GenerateKeyPair(slot, CKM_DH_PKCS_KEY_PAIR_GEN,
&dh_param, &pub, PR_FALSE, PR_FALSE,
crypto_pwcb_prep(id_cryptoctx, NULL, context));
/* Finish building the return values. */
memset(&encoded, 0, sizeof(encoded));
if (SEC_ASN1EncodeItem(pool, &encoded, params,
domain_parameters_template) != &encoded) {
PK11_FreeSlot(slot);
PORT_FreeArena(pool, PR_TRUE);
pkiDebug("%s: error encoding parameters\n", __FUNCTION__);
return ENOMEM;
}
/* Export the return values. */
if (secitem_to_buf_len(&encoded, dh_params, dh_params_len) != 0) {
PK11_FreeSlot(slot);
PORT_FreeArena(pool, PR_TRUE);
return ENOMEM;
}
if (secitem_to_dh_pubval(&pub->u.dh.publicValue, dh_pubkey,
dh_pubkey_len) != 0) {
free(*dh_params);
*dh_params = NULL;
PK11_FreeSlot(slot);
PORT_FreeArena(pool, PR_TRUE);
return ENOMEM;
}
/* Save our private and public keys for reuse later. */
if (req_cryptoctx->client_dh_privkey != NULL)
SECKEY_DestroyPrivateKey(req_cryptoctx->client_dh_privkey);
req_cryptoctx->client_dh_privkey = priv;
if (req_cryptoctx->client_dh_pubkey != NULL)
SECKEY_DestroyPublicKey(req_cryptoctx->client_dh_pubkey);
req_cryptoctx->client_dh_pubkey = pub;
PK11_FreeSlot(slot);
PORT_FreeArena(pool, PR_TRUE);
return 0;
}
/* Combine the KDC's public key value with our copy of the parameters and our
* secret key to generate the session key. */
krb5_error_code
client_process_dh(krb5_context context,
pkinit_plg_crypto_context plg_cryptoctx,
pkinit_req_crypto_context req_cryptoctx,
pkinit_identity_crypto_context id_cryptoctx,
unsigned char *dh_pubkey,
unsigned int dh_pubkey_len,
unsigned char **dh_session_key,
unsigned int *dh_session_key_len)
{
PLArenaPool *pool;
PK11SlotInfo *slot;
SECKEYPublicKey *pub, pub2;
PK11SymKey *sym;
SECItem *bits;
pool = PORT_NewArena(sizeof(double));
if (pool == NULL)
return ENOMEM;
/* Rebuild the KDC's public key using our parameters and the supplied
* public value (subjectPublicKey). */
pub = SECKEY_CopyPublicKey(req_cryptoctx->client_dh_pubkey);
if (pub == NULL) {
PORT_FreeArena(pool, PR_TRUE);
return ENOMEM;
}
pub2 = *pub;
if (secitem_from_dh_pubval(pool, dh_pubkey, dh_pubkey_len,
&pub2.u.dh.publicValue) != 0) {
SECKEY_DestroyPublicKey(pub);
PORT_FreeArena(pool, PR_TRUE);
return ENOMEM;
}
/* Generate the shared value using our private key and the KDC's
* public key. */
slot = PK11_GetBestSlot(CKM_DH_PKCS_KEY_PAIR_GEN,
crypto_pwcb_prep(id_cryptoctx, NULL, context));
if (slot == NULL) {
SECKEY_DestroyPublicKey(pub);
PORT_FreeArena(pool, PR_TRUE);
return ENOMEM;
}
sym = PK11_PubDerive(req_cryptoctx->client_dh_privkey, &pub2, PR_FALSE,
NULL, NULL,
CKM_DH_PKCS_DERIVE,
CKM_TLS_MASTER_KEY_DERIVE_DH,
CKA_DERIVE,
0, crypto_pwcb_prep(id_cryptoctx, NULL, context));
if (sym == NULL) {
PK11_FreeSlot(slot);
SECKEY_DestroyPublicKey(pub);
PORT_FreeArena(pool, PR_TRUE);
return ENOMEM;
}
/* Export the shared value. */
if ((PK11_ExtractKeyValue(sym) != SECSuccess) ||
((bits = PK11_GetKeyData(sym)) == NULL) ||
(secitem_to_buf_len(bits, dh_session_key, dh_session_key_len) != 0)) {
PK11_FreeSymKey(sym);
PK11_FreeSlot(slot);
SECKEY_DestroyPublicKey(pub);
PORT_FreeArena(pool, PR_TRUE);
return ENOMEM;
}
PK11_FreeSymKey(sym);
PK11_FreeSlot(slot);
SECKEY_DestroyPublicKey(pub);
PORT_FreeArena(pool, PR_TRUE);
return 0;
}
/* Given a binary-encoded integer, count the number of bits. */
static int
get_integer_bits(SECItem *integer)
{
unsigned int i;
unsigned char c;
int size = 0;
for (i = 0; i < integer->len; i++) {
c = integer->data[i];
if (c != 0) {
size = (integer->len - i - 1) * 8;
while (c != 0) {
c >>= 1;
size++;
}
break;
}
}
return size;
}
/* Verify that the client-supplied parameters include a prime of sufficient
* size. */
krb5_error_code
server_check_dh(krb5_context context,
pkinit_plg_crypto_context plg_cryptoctx,
pkinit_req_crypto_context req_cryptoctx,
pkinit_identity_crypto_context id_cryptoctx,
krb5_data *dh_params, int minbits)
{
PLArenaPool *pool;
SECItem item;
pool = PORT_NewArena(sizeof(double));
if (pool == NULL)
return ENOMEM;
item.data = (unsigned char *)dh_params->data;
item.len = dh_params->length;
memset(&req_cryptoctx->client_dh_params, 0,
sizeof(req_cryptoctx->client_dh_params));
if (SEC_ASN1DecodeItem(req_cryptoctx->pool,
&req_cryptoctx->client_dh_params,
domain_parameters_template, &item) != SECSuccess) {
PORT_FreeArena(pool, PR_TRUE);
return ENOMEM;
}
if (get_integer_bits(&req_cryptoctx->client_dh_params.p) < minbits) {
PORT_FreeArena(pool, PR_TRUE);
return KRB5KDC_ERR_DH_KEY_PARAMETERS_NOT_ACCEPTED;
}
PORT_FreeArena(pool, PR_TRUE);
return 0;
}
/* Take apart the client-supplied SubjectPublicKeyInfo, which contains both an
* encoded DomainParameters structure (per RFC3279), and a public value, and
* generate our own private key and public value using the supplied parameters.
* Use our private key and the client's public value to derive the session key,
* and hand our public value and the session key back to our caller. */
krb5_error_code
server_process_dh(krb5_context context,
pkinit_plg_crypto_context plg_cryptoctx,
pkinit_req_crypto_context req_cryptoctx,
pkinit_identity_crypto_context id_cryptoctx,
unsigned char *received_pubkey,
unsigned int received_pub_len,
unsigned char **dh_pubkey,
unsigned int *dh_pubkey_len,
unsigned char **server_key,
unsigned int *server_key_len)
{
PLArenaPool *pool;
SECKEYPrivateKey *priv;
SECKEYPublicKey *pub, pub2;
SECKEYDHParams dh_params;
PK11SymKey *sym;
SECItem pubval, *bits;
PK11SlotInfo *slot;
pool = PORT_NewArena(sizeof(double));
if (pool == NULL)
return ENOMEM;
/* Store the client's public value. */
pubval.data = received_pubkey;
pubval.len = received_pub_len;
/* Set up DH parameters the using client's domain parameters. */
memset(&dh_params, 0, sizeof(dh_params));
dh_params.arena = pool;
dh_params.prime = req_cryptoctx->client_dh_params.p;
dh_params.base = req_cryptoctx->client_dh_params.g;
/* Generate a public value and a private key using the parameters. */
slot = PK11_GetBestSlot(CKM_DH_PKCS_KEY_PAIR_GEN,
crypto_pwcb_prep(id_cryptoctx, NULL, context));
if (slot == NULL) {
PORT_FreeArena(pool, PR_TRUE);
return ENOMEM;
}
pub = NULL;
priv = PK11_GenerateKeyPair(slot, CKM_DH_PKCS_KEY_PAIR_GEN,
&dh_params, &pub, PR_FALSE, PR_FALSE,
crypto_pwcb_prep(id_cryptoctx, NULL, context));
if (priv == NULL) {
PK11_FreeSlot(slot);
PORT_FreeArena(pool, PR_TRUE);
return ENOMEM;
}
/* Build the client's public key using the client's parameters and
* public value. */
pub2 = *pub;
if (SEC_ASN1DecodeItem(pool, &pub2.u.dh.publicValue,
SEC_ASN1_GET(SEC_IntegerTemplate),
&pubval) != SECSuccess) {
SECKEY_DestroyPrivateKey(priv);
SECKEY_DestroyPublicKey(pub);
PK11_FreeSlot(slot);
PORT_FreeArena(pool, PR_TRUE);
return ENOMEM;
}
/* Generate the shared value using our private key and the client's
* public key. */
sym = PK11_PubDerive(priv, &pub2, PR_FALSE,
NULL, NULL,
CKM_DH_PKCS_DERIVE,
CKM_TLS_MASTER_KEY_DERIVE_DH,
CKA_DERIVE,
0, crypto_pwcb_prep(id_cryptoctx, NULL, context));
if (sym == NULL) {
SECKEY_DestroyPrivateKey(priv);
SECKEY_DestroyPublicKey(pub);
PK11_FreeSlot(slot);
PORT_FreeArena(pool, PR_TRUE);
return ENOMEM;
}
/* Export the shared value for our use and our public value for
* transmission back to the client. */
*server_key = NULL;
*dh_pubkey = NULL;
if ((PK11_ExtractKeyValue(sym) != SECSuccess) ||
((bits = PK11_GetKeyData(sym)) == NULL) ||
(secitem_to_buf_len(bits, server_key, server_key_len) != 0) ||
(secitem_to_dh_pubval(&pub->u.dh.publicValue,
dh_pubkey, dh_pubkey_len) != 0)) {
free(*server_key);
free(*dh_pubkey);
PK11_FreeSymKey(sym);
SECKEY_DestroyPrivateKey(priv);
SECKEY_DestroyPublicKey(pub);
PK11_FreeSlot(slot);
PORT_FreeArena(pool, PR_TRUE);
return ENOMEM;
}
PK11_FreeSymKey(sym);
SECKEY_DestroyPrivateKey(priv);
SECKEY_DestroyPublicKey(pub);
PK11_FreeSlot(slot);
PORT_FreeArena(pool, PR_TRUE);
return 0;
}
/* Create the issuer-and-serial portion of an external principal identifier for
* a KDC's cert that we already have. */
krb5_error_code
create_issuerAndSerial(krb5_context context,
pkinit_plg_crypto_context plg_cryptoctx,
pkinit_req_crypto_context req_cryptoctx,
pkinit_identity_crypto_context id_cryptoctx,
unsigned char **kdcId_buf, unsigned int *kdcId_len)
{
PLArenaPool *pool;
struct issuer_and_serial_number isn;
SECItem item;
/* Check if we have a peer cert. If we don't have one, that's okay. */
if (req_cryptoctx->peer_cert == NULL)
return 0;
/* Scratch arena. */
pool = PORT_NewArena(sizeof(double));
if (pool == NULL)
return ENOMEM;
/* Encode the peer's issuer/serial. */
isn.issuer = req_cryptoctx->peer_cert->derIssuer;
isn.serial = req_cryptoctx->peer_cert->serialNumber;
memset(&item, 0, sizeof(item));
if (SEC_ASN1EncodeItem(id_cryptoctx->id_cert->arena, &item, &isn,
issuer_and_serial_number_template) != &item) {
PORT_FreeArena(pool, PR_TRUE);
return ENOMEM;
}
/* Export the value. */
if (secitem_to_buf_len(&item, kdcId_buf, kdcId_len) != 0) {
PORT_FreeArena(pool, PR_TRUE);
return ENOMEM;
}
PORT_FreeArena(pool, PR_TRUE);
return 0;
}
/* Populate a list of AlgorithmIdentifier structures with the OIDs of the key
* wrap algorithms that we support. */
static void
free_n_algorithm_identifiers(krb5_algorithm_identifier **ids, int i)
{
while (i >= 0) {
free(ids[i]->algorithm.data);
free(ids[i]);
i--;
}
free(ids);
}
krb5_error_code
create_krb5_supportedCMSTypes(krb5_context context,
pkinit_plg_crypto_context plg_cryptoctx,
pkinit_req_crypto_context req_cryptoctx,
pkinit_identity_crypto_context id_cryptoctx,
krb5_algorithm_identifier ***supportedCMSTypes)
{
SECOidData *oid;
SECOidTag oids[] = {
SEC_OID_CMS_3DES_KEY_WRAP, /* no parameters */
SEC_OID_AES_128_KEY_WRAP, /* no parameters */
SEC_OID_AES_192_KEY_WRAP, /* no parameters */
SEC_OID_AES_256_KEY_WRAP, /* no parameters */
/* RC2 key wrap requires parameters, so skip it */
};
krb5_algorithm_identifier **ids, *id;
unsigned int i;
ids = malloc(sizeof(id) * ((sizeof(oids) / sizeof(oids[0])) + 1));
if (ids == NULL)
return ENOMEM;
for (i = 0; i < (sizeof(oids) / sizeof(oids[0])); i++) {
id = malloc(sizeof(*id));
if (id == NULL) {
free_n_algorithm_identifiers(ids, i - 1);
return ENOMEM;
}
memset(id, 0, sizeof(*id));
ids[i] = id;
oid = SECOID_FindOIDByTag(oids[i]);
if (secitem_to_buf_len(&oid->oid,
(unsigned char **)&id->algorithm.data,
&id->algorithm.length) != 0) {
free(ids[i]);
free_n_algorithm_identifiers(ids, i - 1);
return ENOMEM;
}
}
ids[i] = NULL;
*supportedCMSTypes = ids;
return 0;
}
/* Populate a list of trusted certifiers with the list of the root certificates
* that we trust. */
static void
free_n_principal_identifiers(krb5_external_principal_identifier **ids, int i)
{
while (i >= 0) {
free(ids[i]->subjectKeyIdentifier.data);
free(ids[i]->issuerAndSerialNumber.data);
free(ids[i]->subjectName.data);
free(ids[i]);
i--;
}
free(ids);
}
krb5_error_code
create_krb5_trustedCertifiers(krb5_context context,
pkinit_plg_crypto_context plg_cryptoctx,
pkinit_req_crypto_context req_cryptoctx,
pkinit_identity_crypto_context id_cryptoctx,
krb5_external_principal_identifier ***
trustedCertifiers)
{
CERTCertListNode *node;
krb5_external_principal_identifier **ids, *id;
unsigned int i, n;
*trustedCertifiers = NULL;
/* Count the root certs. */
n = 0;
if (!CERT_LIST_EMPTY(id_cryptoctx->ca_certs)) {
for (n = 0, node = CERT_LIST_HEAD(id_cryptoctx->ca_certs);
(node != NULL) &&
(node->cert != NULL) &&
!CERT_LIST_END(node, id_cryptoctx->ca_certs);
node = CERT_LIST_NEXT(node)) {
n++;
}
}
/* Build the result list. */
if (n > 0) {
ids = malloc((n + 1) * sizeof(id));
if (ids == NULL)
return ENOMEM;
node = CERT_LIST_HEAD(id_cryptoctx->ca_certs);
for (i = 0; i < n; i++) {
id = malloc(sizeof(*id));
if (id == NULL) {
free_n_principal_identifiers(ids, i - 1);
return ENOMEM;
}
memset(id, 0, sizeof(*id));
/* Use the certificate's subject key ID iff it's
* actually in the certificate. Allocate the memory
* from the heap because it'll be freed by other parts
* of the pkinit module. */
if ((node->cert->keyIDGenerated ?
secitem_to_buf_len(&node->cert->derSubject,
(unsigned char **)
&id->subjectName.data,
&id->subjectName.length) :
secitem_to_buf_len(&node->cert->subjectKeyID,
(unsigned char **)
&id->subjectKeyIdentifier.data,
&id->subjectKeyIdentifier.length)) != 0) {
/* Free the earlier items. */
free(ids[i]);
free_n_principal_identifiers(ids, i - 1);
return ENOMEM;
}
ids[i] = id;
node = CERT_LIST_NEXT(node);
}
ids[i] = NULL;
*trustedCertifiers = ids;
}
return 0;
}
/* Add a certificate to a list if it isn't already in the list. Since the list
* would take ownership of the cert if we added it to the list, if it's already
* in the list, delete this reference to it. */
static SECStatus
cert_maybe_add_to_list(CERTCertList *list, CERTCertificate *cert)
{
CERTCertListNode *node;
for (node = CERT_LIST_HEAD(list);
(node != NULL) &&
(node->cert != NULL) &&
!CERT_LIST_END(node, list);
node = CERT_LIST_NEXT(node)) {
if (SECITEM_ItemsAreEqual(&node->cert->derCert, &cert->derCert)) {
/* Don't add the duplicate. */
CERT_DestroyCertificate(cert);
return SECSuccess;
}
}
return CERT_AddCertToListTail(list, cert);
}
/* Load CA certificates from the slot. */
static SECStatus
cert_load_ca_certs_from_slot(krb5_context context,
pkinit_identity_crypto_context id,
PK11SlotInfo *slot,
const char *identity)
{
CERTCertificate *cert;
CERTCertList *list;
CERTCertListNode *node;
CERTCertTrust trust;
SECStatus status;
/* Log in if the slot requires it. */
PK11_TokenRefresh(slot);
if (!PK11_IsLoggedIn(slot, crypto_pwcb_prep(id, identity, context)) &&
PK11_NeedLogin(slot)) {
pkiDebug("%s: logging in to token \"%s\"\n",
__FUNCTION__, PK11_GetTokenName(slot));
if (PK11_Authenticate(slot, PR_TRUE,
crypto_pwcb_prep(id, identity,
context)) != SECSuccess) {
pkiDebug("%s: error logging into \"%s\": %s, skipping\n",
__FUNCTION__, PK11_GetTokenName(slot),
PORT_ErrorToName(PORT_GetError()));
return SECFailure;
}
}
/* Get the list of certs from the slot. */
list = PK11_ListCertsInSlot(slot);
if (list == NULL) {
pkiDebug("%s: nothing found in token \"%s\"\n",
__FUNCTION__, PK11_GetTokenName(slot));
return SECSuccess;
}
if (CERT_LIST_EMPTY(list)) {
CERT_DestroyCertList(list);
pkiDebug("%s: nothing found in token \"%s\"\n",
__FUNCTION__, PK11_GetTokenName(slot));
return SECSuccess;
}
/* Walk the list of certs, and for each one that's a CA, add
* it to our CA cert list. */
status = SECSuccess;
for (node = CERT_LIST_HEAD(list);
(node != NULL) &&
(node->cert != NULL) &&
!CERT_LIST_END(node, list);
node = CERT_LIST_NEXT(node)) {
#if 0
/* Skip it if it's not a root. */
if (!node->cert->isRoot) {
continue;
}
#endif
/* Skip it if we don't trust it to issue certificates. */
if (CERT_GetCertTrust(node->cert, &trust) != SECSuccess)
continue;
if ((SEC_GET_TRUST_FLAGS(&trust, trustSSL) &
(CERTDB_TRUSTED_CA |
CERTDB_TRUSTED_CLIENT_CA | CERTDB_NS_TRUSTED_CA)) == 0)
continue;
/* DestroyCertList frees all of the certs in the list,
* so we need to create a copy that we can own. */
cert = CERT_DupCertificate(node->cert);
/* Add it to the list. */
if (cert_maybe_add_to_list(id->ca_certs, cert) != SECSuccess)
status = SECFailure;
}
CERT_DestroyCertList(list);
return status;
}
/* Load certificates for which we have private keys from the slot. */
static int
cert_load_certs_with_keys_from_slot(krb5_context context,
pkinit_identity_crypto_context
id_cryptoctx,
PK11SlotInfo *slot,
const char *cert_label,
const char *cert_id,
const char *identity)
{
CERTCertificate *cert;
CERTCertList *clist;
CERTCertListNode *cnode;
SECKEYPrivateKey *key;
int status;
/* Log in if the slot requires it. */
PK11_TokenRefresh(slot);
if (!PK11_IsLoggedIn(slot, crypto_pwcb_prep(id_cryptoctx, identity,
context)) &&
PK11_NeedLogin(slot)) {
pkiDebug("%s: logging in to token \"%s\"\n",
__FUNCTION__, PK11_GetTokenName(slot));
if (PK11_Authenticate(slot, PR_TRUE,
crypto_pwcb_prep(id_cryptoctx, identity,
context)) != SECSuccess) {
pkiDebug("%s: error logging into \"%s\": %s, skipping\n",
__FUNCTION__, PK11_GetTokenName(slot),
PORT_ErrorToName(PORT_GetError()));
return id_cryptoctx->defer_id_prompt ? 0 : ENOMEM;
}
}
/* Get the list of certs from the slot. */
clist = PK11_ListCertsInSlot(slot);
if (clist == NULL) {
pkiDebug("%s: nothing found in token \"%s\"\n",
__FUNCTION__, PK11_GetTokenName(slot));
return 0;
}
if (CERT_LIST_EMPTY(clist)) {
CERT_DestroyCertList(clist);
pkiDebug("%s: nothing found in token \"%s\"\n",
__FUNCTION__, PK11_GetTokenName(slot));
return 0;
}
/* Walk the list of certs, and for each one for which we can
* find the matching private key, add it and the keys to the
* lists. */
status = 0;
for (cnode = CERT_LIST_HEAD(clist);
(cnode != NULL) &&
(cnode->cert != NULL) &&
!CERT_LIST_END(cnode, clist);
cnode = CERT_LIST_NEXT(cnode)) {
if (cnode->cert->nickname != NULL) {
if ((cert_label != NULL) && (cert_id != NULL)) {
if ((strcmp(cert_id, cnode->cert->nickname) != 0) &&
(strcmp(cert_label, cnode->cert->nickname) != 0))
continue;
} else if (cert_label != NULL) {
if (strcmp(cert_label, cnode->cert->nickname) != 0)
continue;
} else if (cert_id != NULL) {
if (strcmp(cert_id, cnode->cert->nickname) != 0)
continue;
}
}
key = PK11_FindPrivateKeyFromCert(slot, cnode->cert,
crypto_pwcb_prep(id_cryptoctx,
identity, context));
if (key == NULL) {
pkiDebug("%s: no key for \"%s\", skipping it\n",
__FUNCTION__,
cnode->cert->nickname ?
cnode->cert->nickname : "(no name)");
continue;
}
pkiDebug("%s: found \"%s\" and its matching key\n",
__FUNCTION__,
cnode->cert->nickname ? cnode->cert->nickname : "(no name)");
/* DestroyCertList frees all of the certs in the list,
* so we need to create a copy that it can own. */
cert = CERT_DupCertificate(cnode->cert);
if (cert_maybe_add_to_list(id_cryptoctx->id_certs,
cert) != SECSuccess)
status = ENOMEM;
/* We don't need this reference to the key. */
SECKEY_DestroyPrivateKey(key);
}
CERT_DestroyCertList(clist);
return status;
}
/*
* Reassemble the identity as it was supplied by the user or the library
* configuration.
*/
static char *
reassemble_pkcs11_name(PLArenaPool *pool, pkinit_identity_opts *idopts)
{
struct k5buf buf;
int n = 0;
char *ret;
k5_buf_init_dynamic(&buf);
k5_buf_add(&buf, "PKCS11:");
n = 0;
if (idopts->p11_module_name != NULL) {
k5_buf_add_fmt(&buf, "%smodule_name=%s", n++ ? ":" : "",
idopts->p11_module_name);
}
if (idopts->token_label != NULL) {
k5_buf_add_fmt(&buf, "%stoken=%s", n++ ? ":" : "",
idopts->token_label);
}
if (idopts->cert_label != NULL) {
k5_buf_add_fmt(&buf, "%scertlabel=%s", n++ ? ":" : "",
idopts->cert_label);
}
if (idopts->cert_id_string != NULL) {
k5_buf_add_fmt(&buf, "%scertid=%s", n++ ? ":" : "",
idopts->cert_id_string);
}
if (idopts->slotid != PK_NOSLOT) {
k5_buf_add_fmt(&buf, "%sslotid=%ld", n++ ? ":" : "",
(long)idopts->slotid);
}
if (k5_buf_len(&buf) >= 0)
ret = PORT_ArenaStrdup(pool, k5_buf_data(&buf));
else
ret = NULL;
k5_free_buf(&buf);
return ret;
}
/*
* Assemble an identity string that will distinguish this token from any other
* that is accessible through the same module, even if the user didn't specify
* a token name.
*/
static char *
reassemble_pkcs11_identity(PLArenaPool *pool, pkinit_identity_opts *idopts,
long slotid, const char *tokenname)
{
struct k5buf buf;
int n = 0;
char *ret;
k5_buf_init_dynamic(&buf);
k5_buf_add(&buf, "PKCS11:");
n = 0;
if (idopts->p11_module_name != NULL) {
k5_buf_add_fmt(&buf, "%smodule_name=%s",
n++ ? ":" : "",
idopts->p11_module_name);
}
if (slotid != PK_NOSLOT)
k5_buf_add_fmt(&buf, "%sslotid=%ld", n++ ? ":" : "", slotid);
if (tokenname != NULL)
k5_buf_add_fmt(&buf, "%stoken=%s", n++ ? ":" : "", tokenname);
if (k5_buf_len(&buf) >= 0)
ret = PORT_ArenaStrdup(pool, k5_buf_data(&buf));
else
ret = NULL;
k5_free_buf(&buf);
return ret;
}
static SECStatus
crypto_load_pkcs11(krb5_context context,
pkinit_plg_crypto_context plg_cryptoctx,
pkinit_req_crypto_context req_cryptoctx,
pkinit_identity_opts *idopts,
pkinit_identity_crypto_context id_cryptoctx)
{
struct _pkinit_identity_crypto_module **id_modules, *module;
PK11SlotInfo *slot;
CK_TOKEN_INFO tinfo;
char *spec, *identity;
size_t spec_size;
const char *tokenname;
SECStatus status;
int i, j;
if (idopts == NULL)
return SECFailure;
/* If no module is specified, use the default module from pkinit.h. */
if (idopts->p11_module_name == NULL) {
idopts->p11_module_name = strdup(PKCS11_MODNAME);
if (idopts->p11_module_name == NULL)
return SECFailure;
}
/* Build the module spec. */
spec_size = strlen("library=''") + strlen(idopts->p11_module_name) * 2 + 1;
spec = PORT_ArenaZAlloc(id_cryptoctx->pool, spec_size);
if (spec == NULL)
return SECFailure;
strlcpy(spec, "library=\"", spec_size);
j = strlen(spec);
for (i = 0; idopts->p11_module_name[i] != '\0'; i++) {
if (strchr("\"", idopts->p11_module_name[i]) != NULL)
spec[j++] = '\\';
spec[j++] = idopts->p11_module_name[i];
}
spec[j++] = '\0';
strlcat(spec, "\"", spec_size);
/* Count the number of modules we've already loaded. */
if (id_cryptoctx->id_modules != NULL) {
for (i = 0; id_cryptoctx->id_modules[i] != NULL; i++)
continue;
} else {
i = 0;
}
/* Allocate a bigger list. */
id_modules = PORT_ArenaZAlloc(id_cryptoctx->pool,
sizeof(id_modules[0]) * (i + 2));
if (id_modules == NULL)
return SECFailure;
for (j = 0; j < i; j++)
id_modules[j] = id_cryptoctx->id_modules[j];
/* Actually load the module, or just ref an already-loaded copy. */
module = PORT_ArenaZAlloc(id_cryptoctx->pool, sizeof(*module));
if (module == NULL)
return SECFailure;
module->name = reassemble_pkcs11_name(id_cryptoctx->pool, idopts);
if (module->name == NULL)
return SECFailure;
module->spec = spec;
for (j = 0; j < i; j++) {
if (strcmp(module->spec, id_modules[j]->spec) == 0)
break;
}
if (j < i)
module->module = SECMOD_ReferenceModule(id_modules[j]->module);
else
module->module = SECMOD_LoadUserModule(spec, NULL, PR_FALSE);
if (module->module == NULL) {
pkiDebug("%s: error loading PKCS11 module \"%s\"",
__FUNCTION__, idopts->p11_module_name);
return SECFailure;
}
if (!module->module->loaded) {
pkiDebug("%s: error really loading PKCS11 module \"%s\"",
__FUNCTION__, idopts->p11_module_name);
SECMOD_DestroyModule(module->module);
module->module = NULL;
return SECFailure;
}
SECMOD_UpdateSlotList(module->module);
pkiDebug("%s: loaded PKCS11 module \"%s\"\n", __FUNCTION__,
idopts->p11_module_name);
/* Add us to the list and set the new list. */
id_modules[j++] = module;
id_modules[j] = NULL;
id_cryptoctx->id_modules = id_modules;
/* Walk the list of slots in the module. */
status = SECFailure;
for (i = 0;
(i < module->module->slotCount) &&
((slot = module->module->slots[i]) != NULL);
i++) {
PK11_TokenRefresh(slot);
if (idopts->slotid != PK_NOSLOT) {
if (idopts->slotid != PK11_GetSlotID(slot))
continue;
}
tokenname = PK11_GetTokenName(slot);
if (tokenname == NULL || strlen(tokenname) == 0)
continue;
/* If we're looking for a specific token, and this isn't it, go on. */
if (idopts->token_label != NULL) {
if (strcmp(idopts->cert_label, tokenname) != 0)
continue;
}
/* Assemble a useful identity string, in case of an incomplete one. */
identity = reassemble_pkcs11_identity(id_cryptoctx->pool, idopts,
(long)PK11_GetSlotID(slot),
tokenname);
/*
* Skip past all of the loading-certificates-and-keys logic, pick up
* the token flags, and call it done for now.
*/
if (id_cryptoctx->defer_id_prompt) {
if (!PK11_IsLoggedIn(slot, crypto_pwcb_prep(id_cryptoctx, identity,
context)) &&
PK11_NeedLogin(slot)) {
pkiDebug("%s: reading flags for token \"%s\"\n",
__FUNCTION__, PK11_GetTokenName(slot));
if (PK11_GetTokenInfo(slot, &tinfo) == SECSuccess) {
pkinit_set_deferred_id(&id_cryptoctx->deferred_ids,
identity, tinfo.flags, NULL);
}
}
return SECSuccess;
}
if (!PK11_IsPresent(slot))
continue;
/* Load private keys and their certs from this token. */
if (cert_load_certs_with_keys_from_slot(context, id_cryptoctx,
slot, idopts->cert_label,
idopts->cert_id_string,
identity) == 0)
status = SECSuccess;
/* If no label was specified, then we've looked at a token, so we're
* done. */
if (idopts->token_label == NULL)
break;
}
return status;
}
/* Return the slot which we'll use for holding PEM items. Open the module if
* we need to, first. */
static PK11SlotInfo *
crypto_get_pem_slot(struct _pkinit_identity_crypto_context *id)
{
PK11SlotInfo *slot;
char *pem_module_name, *spec;
size_t spec_size;
if (id->pem_module == NULL) {
pem_module_name = PR_GetLibraryName(NULL, PEM_MODULE);
if (pem_module_name == NULL) {
pkiDebug("%s: error determining library name for %s\n",
__FUNCTION__, PEM_MODULE);
return NULL;
}
spec_size = strlen("library=") + strlen(pem_module_name) + 1;
spec = malloc(spec_size);
if (spec == NULL) {
pkiDebug("%s: out of memory building spec for %s\n",
__FUNCTION__, pem_module_name);
PR_FreeLibraryName(pem_module_name);
return NULL;
}
snprintf(spec, spec_size, "library=%s", pem_module_name);
id->pem_module = SECMOD_LoadUserModule(spec, NULL, PR_FALSE);
if (id->pem_module == NULL)
pkiDebug("%s: error loading %s\n", __FUNCTION__, pem_module_name);
else if (!id->pem_module->loaded)
pkiDebug("%s: error really loading %s\n", __FUNCTION__,
pem_module_name);
else
SECMOD_UpdateSlotList(id->pem_module);
free(spec);
PR_FreeLibraryName(pem_module_name);
}
if ((id->pem_module != NULL) && id->pem_module->loaded) {
if (id->pem_module->slotCount != 0)
slot = id->pem_module->slots[0];
else
slot = NULL;
if (slot == NULL)
pkiDebug("%s: no slots in %s?\n", __FUNCTION__, PEM_MODULE);
} else {
slot = NULL;
}
return slot;
}
/* Resolve any ambiguities from having a duplicate nickname in the PKCS12
* bundle and in the database, or the bag not providing a nickname. Note: you
* might expect "arg" to be a wincx, but it's actually a certificate! (Mozilla
* bug #321584, fixed in 3.12, documented by #586163, in 3.13.) */
static SECItem *
crypto_nickname_c_cb(SECItem *old_nickname, PRBool *cancel, void *arg)
{
CERTCertificate *leaf;
char *old_name, *new_name, *p;
SECItem *new_nickname, tmp;
size_t new_name_size;
int i;
leaf = arg;
if (old_nickname != NULL)
pkiDebug("%s: warning: nickname collision on \"%.*s\", "
"generating a new nickname\n", __FUNCTION__,
old_nickname->len, old_nickname->data);
else
pkiDebug("%s: warning: nickname collision, generating a new "
"nickname\n", __FUNCTION__);
new_nickname = NULL;
if (old_nickname == NULL) {
old_name = leaf->subjectName;
new_name_size = strlen(PKCS12_PREFIX ": #1") + strlen(old_name) + 1;
new_name = PR_Malloc(new_name_size);
if (new_name != NULL) {
snprintf(new_name, new_name_size, PKCS12_PREFIX ": %s #1",
old_name);
tmp.data = (unsigned char *) new_name;
tmp.len = strlen(new_name) + 1;
new_nickname = SECITEM_DupItem(&tmp);
PR_Free(new_name);
}
} else {
old_name = (char *) old_nickname->data;
if (strncmp(old_name, PKCS12_PREFIX ": ",
strlen(PKCS12_PREFIX) + 2) == 0) {
p = strrchr(old_name, '#');
i = (p ? atoi(p + 1) : 0) + 1;
old_name = leaf->subjectName;
new_name_size = strlen(PKCS12_PREFIX ": #") +
strlen(old_name) + 3 * sizeof(i) + 1;
new_name = PR_Malloc(new_name_size);
} else {
old_name = leaf->subjectName;
new_name_size = strlen(PKCS12_PREFIX ": #1") +
strlen(old_name) + 1;
new_name = PR_Malloc(new_name_size);
i = 1;
}
if (new_name != NULL) {
snprintf(new_name, new_name_size, PKCS12_PREFIX ": %s #%d",
old_name, i);
tmp.data = (unsigned char *) new_name;
tmp.len = strlen(new_name) + 1;
new_nickname = SECITEM_DupItem(&tmp);
PR_Free(new_name);
}
}
if (new_nickname == NULL) {
pkiDebug("%s: warning: unable to generate a new nickname\n",
__FUNCTION__);
*cancel = PR_TRUE;
} else {
pkiDebug("%s: generated new nickname \"%.*s\"\n",
__FUNCTION__, new_nickname->len, new_nickname->data);
*cancel = PR_FALSE;
}
return new_nickname;
}
static char *
reassemble_pkcs12_name(PLArenaPool *pool, const char *filename)
{
char *tmp, *ret;
if (asprintf(&tmp, "PKCS12:%s", filename) < 0)
return NULL;
ret = PORT_ArenaStrdup(pool, tmp);
free(tmp);
return ret;
}
static SECStatus
crypto_load_pkcs12(krb5_context context,
pkinit_plg_crypto_context plg_cryptoctx,
pkinit_req_crypto_context req_cryptoctx,
const char *name,
pkinit_identity_crypto_context id_cryptoctx)
{
PK11SlotInfo *slot;
SEC_PKCS12DecoderContext *ctx;
unsigned char emptypwd[] = { '\0', '\0' };
SECItem tmp, password;
PRBool retry;
int attempt;
char *identity;
if ((slot = crypto_get_p12_slot(id_cryptoctx)) == NULL) {
pkiDebug("%s: skipping identity PKCS12 bundle \"%s\": "
"no slot found\n", __FUNCTION__, name);
return SECFailure;
}
if (secitem_from_file(id_cryptoctx->pool, name,
secitem_from_file_decode, &tmp) != 0) {
pkiDebug("%s: skipping identity PKCS12 bundle \"%s\": "
"error reading from file\n", __FUNCTION__, name);
return SECFailure;
}
/* There's a chance we'll need these. */
SEC_PKCS12EnableCipher(PKCS12_RC2_CBC_40, PR_TRUE);
SEC_PKCS12EnableCipher(PKCS12_RC2_CBC_128, PR_TRUE);
SEC_PKCS12EnableCipher(PKCS12_RC4_40, PR_TRUE);
SEC_PKCS12EnableCipher(PKCS12_RC4_128, PR_TRUE);
SEC_PKCS12EnableCipher(PKCS12_DES_56, PR_TRUE);
SEC_PKCS12EnableCipher(PKCS12_DES_EDE3_168, PR_TRUE);
/* Pass in the password. */
memset(&password, 0, sizeof(password));
password.data = emptypwd;
password.len = 2;
attempt = 0;
ctx = NULL;
identity = reassemble_pkcs12_name(id_cryptoctx->pool, name);
if (identity == NULL)
return SECFailure;
id_cryptoctx->id_p12_slot.p12name = identity;
do {
retry = PR_FALSE;
ctx = SEC_PKCS12DecoderStart(&password,
slot,
crypto_pwcb_prep(id_cryptoctx, identity,
context),
NULL, NULL, NULL, NULL, NULL);
if (ctx == NULL) {
pkiDebug("%s: skipping identity PKCS12 bundle \"%s\": "
"error setting up decoder\n", __FUNCTION__, name);
return SECFailure;
}
if (SEC_PKCS12DecoderUpdate(ctx, tmp.data, tmp.len) != SECSuccess) {
pkiDebug("%s: skipping identity PKCS12 bundle \"%s\": "
"error passing data to decoder\n", __FUNCTION__, name);
SEC_PKCS12DecoderFinish(ctx);
return SECFailure;
}
if (SEC_PKCS12DecoderVerify(ctx) != SECSuccess) {
char *newpass;
krb5_ucs2 *ucs2;
unsigned char *ucs2s;
size_t i, n_ucs2s;
SECErrorCodes err;
err = PORT_GetError();
SEC_PKCS12DecoderFinish(ctx);
switch (err) {
case SEC_ERROR_BAD_PASSWORD:
if (id_cryptoctx->defer_id_prompt) {
pkinit_set_deferred_id(&id_cryptoctx->deferred_ids,
identity, 0, NULL);
return SECSuccess;
}
pkiDebug("%s: prompting for password for %s\n",
__FUNCTION__, name);
newpass = crypto_pwfn(name, PR_FALSE, 0, (attempt > 0),
id_cryptoctx);
attempt++;
if (newpass != NULL) {
/* convert to 16-bit big-endian */
if (krb5int_utf8s_to_ucs2les(newpass,
&ucs2s, &n_ucs2s) == 0) {
PR_Free(newpass);
ucs2 = (krb5_ucs2 *) ucs2s;
for (i = 0; i < n_ucs2s / 2; i++)
ucs2[i] = SWAP16(ucs2[i]);
password.data = (void *) ucs2s;
password.len = n_ucs2s + 2;
PORT_SetError(0);
retry = PR_TRUE;
continue;
}
PR_Free(newpass);
}
break;
default:
break;
}
pkiDebug("%s: skipping identity PKCS12 bundle \"%s\": "
"error verifying data: %d\n", __FUNCTION__,
name, PORT_GetError());
return SECFailure;
}
} while (retry);
if (SEC_PKCS12DecoderValidateBags(ctx,
crypto_nickname_c_cb) != SECSuccess) {
pkiDebug("%s: skipping identity PKCS12 bundle \"%s\": "
"error validating bags: %d\n", __FUNCTION__, name,
PORT_GetError());
SEC_PKCS12DecoderFinish(ctx);
if (password.data != emptypwd)
free(password.data);
return SECFailure;
}
if (SEC_PKCS12DecoderImportBags(ctx) != SECSuccess) {
pkiDebug("%s: skipping identity PKCS12 bundle \"%s\": "
"error importing data: %d\n", __FUNCTION__, name,
PORT_GetError());
SEC_PKCS12DecoderFinish(ctx);
if (password.data != emptypwd)
free(password.data);
return SECFailure;
}
pkiDebug("%s: imported PKCS12 bundle \"%s\"\n", __FUNCTION__, name);
SEC_PKCS12DecoderFinish(ctx);
if (password.data != emptypwd)
free(password.data);
if (cert_load_certs_with_keys_from_slot(context, id_cryptoctx, slot,
NULL, NULL, identity) == 0)
return SECSuccess;
else
return SECFailure;
}
/* Helper to fill out a CK_ATTRIBUTE. */
static void
crypto_set_attributes(CK_ATTRIBUTE *attr,
CK_ATTRIBUTE_TYPE type,
void *pValue, CK_ULONG ulValueLen)
{
memset(attr, 0, sizeof(*attr));
attr->type = type;
attr->pValue = pValue;
attr->ulValueLen = ulValueLen;
}
static char *
reassemble_files_name(PLArenaPool *pool, const char *certfile,
const char *keyfile)
{
char *tmp, *ret;
if (keyfile != NULL) {
if (asprintf(&tmp, "FILE:%s,%s", certfile, keyfile) < 0)
return NULL;
} else {
if (asprintf(&tmp, "FILE:%s", certfile) < 0)
return NULL;
}
ret = PORT_ArenaStrdup(pool, tmp);
free(tmp);
return ret;
}
/* Load keys, certs, and/or CRLs from files. */
static SECStatus
crypto_load_files(krb5_context context,
pkinit_plg_crypto_context plg_cryptoctx,
pkinit_req_crypto_context req_cryptoctx,
const char *certfile,
const char *keyfile,
const char *crlfile,
PRBool cert_self, PRBool cert_mark_trusted,
pkinit_identity_crypto_context id_cryptoctx)
{
PK11SlotInfo *slot;
struct _pkinit_identity_crypto_file *cobj, *kobj, **id_objects;
PRBool permanent;
SECKEYPrivateKey *key;
CK_ATTRIBUTE attrs[4];
CK_BBOOL cktrue = CK_TRUE, cktrust;
CK_OBJECT_CLASS keyclass = CKO_PRIVATE_KEY, certclass = CKO_CERTIFICATE;
CERTCertificate *cert;
SECItem tmp, *crl, **crls;
SECStatus status;
int i, j, n_attrs, n_objs, n_crls;
if ((slot = crypto_get_pem_slot(id_cryptoctx)) == NULL) {
if (certfile != NULL)
pkiDebug("%s: nsspem module not loaded, not loading file \"%s\"\n",
__FUNCTION__, certfile);
if (keyfile != NULL)
pkiDebug("%s: nsspem module not loaded, not loading file \"%s\"\n",
__FUNCTION__, keyfile);
if (crlfile != NULL)
pkiDebug("%s: nsspem module not loaded, not loading file \"%s\"\n",
__FUNCTION__, crlfile);
return SECFailure;
}
if ((certfile == NULL) && (crlfile == NULL))
return SECFailure;
/* Load the certificate first to work around RHBZ#859535. */
cobj = NULL;
if (certfile != NULL) {
n_attrs = 0;
crypto_set_attributes(&attrs[n_attrs++], CKA_CLASS,
&certclass, sizeof(certclass));
crypto_set_attributes(&attrs[n_attrs++], CKA_TOKEN,
&cktrue, sizeof(cktrue));
crypto_set_attributes(&attrs[n_attrs++], CKA_LABEL,
(char *) certfile, strlen(certfile) + 1);
cktrust = cert_mark_trusted ? CK_TRUE : CK_FALSE;
crypto_set_attributes(&attrs[n_attrs++], CKA_TRUST,
&cktrust, sizeof(cktrust));
permanent = PR_FALSE; /* set lifetime to "session" */
cobj = PORT_ArenaZAlloc(id_cryptoctx->pool, sizeof(*cobj));
if (cobj == NULL)
return SECFailure;
cobj->name = reassemble_files_name(id_cryptoctx->pool,
certfile, keyfile);
if (cobj->name == NULL)
return SECFailure;
cobj->obj = PK11_CreateGenericObject(slot, attrs, n_attrs, permanent);
if (cobj->obj == NULL) {
pkiDebug("%s: error loading %scertificate \"%s\": %s\n",
__FUNCTION__, cert_mark_trusted ? "CA " : "", certfile,
PORT_ErrorToName(PORT_GetError()));
status = SECFailure;
} else {
pkiDebug("%s: loaded %scertificate \"%s\"\n",
__FUNCTION__, cert_mark_trusted ? "CA " : "", certfile);
status = SECSuccess;
/* Add it to the list of objects that we're keeping. */
if (id_cryptoctx->id_objects != NULL)
for (i = 0; id_cryptoctx->id_objects[i] != NULL; i++)
continue;
else
i = 0;
id_objects = PORT_ArenaZAlloc(id_cryptoctx->pool,
sizeof(id_objects[0]) * (i + 2));
if (id_objects != NULL) {
n_objs = i;
for (i = 0; i < n_objs; i++)
id_objects[i] = id_cryptoctx->id_objects[i];
id_objects[i++] = cobj;
id_objects[i++] = NULL;
id_cryptoctx->id_objects = id_objects;
}
/* Find the certificate that goes with this generic object. */
memset(&tmp, 0, sizeof(tmp));
status = PK11_ReadRawAttribute(PK11_TypeGeneric, cobj->obj,
CKA_VALUE, &tmp);
if (status == SECSuccess) {
cobj->cert = CERT_FindCertByDERCert(CERT_GetDefaultCertDB(),
&tmp);
SECITEM_FreeItem(&tmp, PR_FALSE);
} else {
pkiDebug("%s: error locating certificate \"%s\"\n",
__FUNCTION__, certfile);
}
/* Save a reference to the right list. */
if (cobj->cert != NULL) {
cert = CERT_DupCertificate(cobj->cert);
if (cert == NULL)
return SECFailure;
if (cert_self) {
/* Add to the identity list. */
if (cert_maybe_add_to_list(id_cryptoctx->id_certs,
cert) != SECSuccess)
status = SECFailure;
} else if (cert_mark_trusted) {
/* Add to the CA list. */
if (cert_maybe_add_to_list(id_cryptoctx->ca_certs,
cert) != SECSuccess)
status = SECFailure;
} else {
/* Don't just lose the reference. */
CERT_DestroyCertificate(cert);
}
}
}
}
/* Now load what should be the corresponding private key. */
kobj = NULL;
if (status == SECSuccess && keyfile != NULL) {
n_attrs = 0;
crypto_set_attributes(&attrs[n_attrs++], CKA_CLASS,
&keyclass, sizeof(keyclass));
crypto_set_attributes(&attrs[n_attrs++], CKA_TOKEN,
&cktrue, sizeof(cktrue));
crypto_set_attributes(&attrs[n_attrs++], CKA_LABEL,
(char *)keyfile, strlen(keyfile) + 1);
permanent = PR_FALSE; /* set lifetime to "session" */
kobj = PORT_ArenaZAlloc(id_cryptoctx->pool, sizeof(*kobj));
if (kobj == NULL)
return SECFailure;
kobj->obj = PK11_CreateGenericObject(slot, attrs, n_attrs, permanent);
if (kobj->obj == NULL) {
pkiDebug("%s: error loading key \"%s\": %s\n", __FUNCTION__,
keyfile, PORT_ErrorToName(PORT_GetError()));
status = SECFailure;
} else {
pkiDebug("%s: loaded key \"%s\"\n", __FUNCTION__, keyfile);
status = SECSuccess;
/* Add it to the list of objects that we're keeping. */
if (id_cryptoctx->id_objects != NULL) {
for (i = 0; id_cryptoctx->id_objects[i] != NULL; i++)
continue;
} else {
i = 0;
}
id_objects = PORT_ArenaZAlloc(id_cryptoctx->pool,
sizeof(id_objects[0]) * (i + 2));
if (id_objects != NULL) {
n_objs = i;
for (i = 0; i < n_objs; i++)
id_objects[i] = id_cryptoctx->id_objects[i];
id_objects[i++] = kobj;
id_objects[i++] = NULL;
id_cryptoctx->id_objects = id_objects;
}
}
/* "Log in" (provide an encryption password) if the PEM slot now
* requires it. */
PK11_TokenRefresh(slot);
/*
* Unlike most tokens, this one won't self-destruct if we throw wrong
* passwords at it, but it will cause the module to clear the
* needs-login flag so that we can continue importing PEM items.
*/
if (!PK11_IsLoggedIn(slot, crypto_pwcb_prep(id_cryptoctx, cobj->name,
context)) &&
PK11_NeedLogin(slot)) {
pkiDebug("%s: logging in to token \"%s\"\n",
__FUNCTION__, PK11_GetTokenName(slot));
if (PK11_Authenticate(slot, PR_TRUE,
crypto_pwcb_prep(id_cryptoctx, cobj->name,
context)) != SECSuccess) {
pkiDebug("%s: error logging into \"%s\": %s, skipping\n",
__FUNCTION__, PK11_GetTokenName(slot),
PORT_ErrorToName(PORT_GetError()));
status = SECFailure;
PK11_DestroyGenericObject(kobj->obj);
kobj->obj = NULL;
}
}
/* If we loaded a key and a certificate, see if they match. */
if (cobj != NULL && cobj->cert != NULL && kobj->obj != NULL) {
key = PK11_FindPrivateKeyFromCert(slot, cobj->cert,
crypto_pwcb_prep(id_cryptoctx,
cobj->name,
context));
if (key == NULL) {
pkiDebug("%s: no private key found for \"%s\"(%s), "
"even though we just loaded that key?\n",
__FUNCTION__,
cobj->cert->nickname ?
cobj->cert->nickname : "(no name)",
certfile);
status = SECFailure;
} else {
/* We don't need this reference to the key. */
SECKEY_DestroyPrivateKey(key);
}
}
}
/* If we succeeded to this point, or more likely didn't do anything
* yet, cache a CRL. */
if ((status == SECSuccess) && (crlfile != NULL)) {
memset(&tmp, 0, sizeof(tmp));
if (secitem_from_file(id_cryptoctx->pool, crlfile,
secitem_from_file_decode, &tmp) == 0) {
crl = SECITEM_ArenaDupItem(id_cryptoctx->pool, &tmp);
/* Count the CRLs. */
if (id_cryptoctx->id_crls != NULL) {
for (i = 0; id_cryptoctx->id_crls[i] != NULL; i++)
continue;
} else {
i = 0;
}
n_crls = i;
/* Allocate a bigger list. */
crls = PORT_ArenaZAlloc(id_cryptoctx->pool,
sizeof(crls[0]) * (n_crls + 2));
for (j = 0; j < n_crls; j++)
crls[j] = id_cryptoctx->id_crls[j];
if (crl != NULL) {
status = CERT_CacheCRL(CERT_GetDefaultCertDB(), crl);
if (status == SECSuccess) {
crls[j++] = crl;
pkiDebug("%s: cached CRL from \"%s\"\n",
__FUNCTION__, crlfile);
} else
pkiDebug("%s: error loading CRL from \"%s\": %d\n",
__FUNCTION__, crlfile, PORT_GetError());
}
crls[j++] = NULL;
id_cryptoctx->id_crls = crls;
} else
status = SECFailure;
}
return status;
}
static SECStatus
crypto_load_dir(krb5_context context,
pkinit_plg_crypto_context plg_cryptoctx,
pkinit_req_crypto_context req_cryptoctx,
const char *dirname,
PRBool cert_self, PRBool cert_mark_trusted, PRBool load_crl,
pkinit_identity_crypto_context id_cryptoctx)
{
SECStatus status;
DIR *dir;
struct dirent *ent;
char *key, *certcrl;
const char *suffix = load_crl ? ".crl" : ".crt";
int i;
if (crypto_get_pem_slot(id_cryptoctx) == NULL) {
pkiDebug("%s: nsspem module not loaded, "
"not loading directory \"%s\"\n", __FUNCTION__, dirname);
return SECFailure;
}
if (dirname == NULL)
return SECFailure;
dir = opendir(dirname);
if (dir == NULL) {
pkiDebug("%s: error loading directory \"%s\": %s\n",
__FUNCTION__, dirname, strerror(errno));
return SECFailure;
}
status = SECFailure;
pkiDebug("%s: scanning directory \"%s\"\n", __FUNCTION__, dirname);
while ((ent = readdir(dir)) != NULL) {
i = strlen(ent->d_name);
/* Skip over anything that isn't named "<something>.crt" or
* "<something>.crl", whichever we want at the moment. */
if ((i < 5) || (strcmp(ent->d_name + i - 4, suffix) != 0)) {
pkiDebug("%s: skipping candidate \"%s/%s\"\n",
__FUNCTION__, dirname, ent->d_name);
continue;
}
/* Construct a path to the file. */
certcrl = NULL;
if (k5_path_join(dirname, ent->d_name, &certcrl) != 0) {
pkiDebug("%s: error building pathname \"%s %s\"\n",
__FUNCTION__, dirname, ent->d_name);
continue;
}
key = NULL;
if (!load_crl && cert_self) { /* No key. */
/* Construct the matching key name. */
if (k5_path_join(dirname, ent->d_name, &key) != 0) {
pkiDebug("%s: error building pathname \"%s %s\"\n",
__FUNCTION__, dirname, ent->d_name);
free(certcrl);
continue;
}
i = strlen(key);
memcpy(key + i - 4, ".key", 5);
}
/* Try loading the key and file as a pair. */
if (crypto_load_files(context,
plg_cryptoctx,
req_cryptoctx,
load_crl ? NULL : certcrl,
key,
load_crl ? certcrl : NULL,
cert_self, cert_mark_trusted,
id_cryptoctx) == SECSuccess)
status = SECSuccess;
free(certcrl);
free(key);
}
closedir(dir);
return status;
}
static char *
reassemble_nssdb_name(PLArenaPool *pool, const char *dbdir)
{
char *tmp, *ret;
if (asprintf(&tmp, "NSS:%s", dbdir) < 0)
return NULL;
ret = PORT_ArenaStrdup(pool, tmp);
free(tmp);
return ret;
}
/* Load up a certificate database. */
static krb5_error_code
crypto_load_nssdb(krb5_context context,
pkinit_plg_crypto_context plg_cryptoctx,
pkinit_req_crypto_context req_cryptoctx,
const char *configdir,
pkinit_identity_crypto_context id_cryptoctx)
{
struct _pkinit_identity_crypto_userdb *userdb, **id_userdbs;
char *p;
size_t spec_size;
int i, j;
if (configdir == NULL)
return ENOENT;
/* Build the spec. */
spec_size = strlen("configDir='' flags=readOnly") +
strlen(configdir) * 2 + 1;
p = PORT_ArenaZAlloc(id_cryptoctx->pool, spec_size);
if (p == NULL)
return ENOMEM;
strlcpy(p, "configDir='", spec_size);
j = strlen(p);
for (i = 0; configdir[i] != '\0'; i++) {
if (configdir[i] == '\'')
p[j++] = '\\'; /* Is this the right way to do
* escaping? */
p[j++] = configdir[i];
}
p[j++] = '\0';
strlcat(p, "' flags=readOnly", spec_size);
/* Count the number of modules we've already loaded. */
if (id_cryptoctx->id_userdbs != NULL) {
for (i = 0; id_cryptoctx->id_userdbs[i] != NULL; i++)
continue;
} else
i = 0;
/* Allocate a bigger list. */
id_userdbs = PORT_ArenaZAlloc(id_cryptoctx->pool,
sizeof(id_userdbs[0]) * (i + 2));
for (j = 0; j < i; j++)
id_userdbs[j] = id_cryptoctx->id_userdbs[j];
/* Actually load the module. */
userdb = PORT_ArenaZAlloc(id_cryptoctx->pool, sizeof(*userdb));
if (userdb == NULL)
return SECFailure;
userdb->name = reassemble_nssdb_name(id_cryptoctx->pool, configdir);
if (userdb->name == NULL)
return SECFailure;
userdb->userdb = SECMOD_OpenUserDB(p);
if (userdb->userdb == NULL) {
pkiDebug("%s: error loading NSS cert database \"%s\"\n",
__FUNCTION__, configdir);
return ENOENT;
}
pkiDebug("%s: opened NSS database \"%s\"\n", __FUNCTION__, configdir);
/* Add us to the list and set the new list. */
id_userdbs[i++] = userdb;
id_userdbs[i++] = NULL;
id_cryptoctx->id_userdbs = id_userdbs;
/* Load the CAs from the database. */
cert_load_ca_certs_from_slot(context, id_cryptoctx, userdb->userdb,
userdb->name);
/* Load the keys from the database. */
return cert_load_certs_with_keys_from_slot(context, id_cryptoctx,
userdb->userdb, NULL, NULL,
userdb->name);
}
/* Load up a certificate and associated key. */
krb5_error_code
crypto_load_certs(krb5_context context,
pkinit_plg_crypto_context plg_cryptoctx,
pkinit_req_crypto_context req_cryptoctx,
pkinit_identity_opts *idopts,
pkinit_identity_crypto_context id_cryptoctx,
krb5_principal princ,
krb5_boolean defer_id_prompts)
{
SECStatus status;
id_cryptoctx->defer_id_prompt = defer_id_prompts;
switch (idopts->idtype) {
case IDTYPE_FILE:
id_cryptoctx->defer_with_dummy_password = TRUE;
status = crypto_load_files(context,
plg_cryptoctx,
req_cryptoctx,
idopts->cert_filename,
idopts->key_filename,
NULL, PR_TRUE, PR_FALSE, id_cryptoctx);
if (status != SECSuccess) {
pkiDebug("%s: error loading files \"%s\" and \"%s\": %s\n",
__FUNCTION__, idopts->cert_filename,
idopts->key_filename, PORT_ErrorToName(PORT_GetError()));
return defer_id_prompts ? 0 : ENOMEM;
}
return 0;
break;
case IDTYPE_NSS:
id_cryptoctx->defer_with_dummy_password = FALSE;
status = crypto_load_nssdb(context,
plg_cryptoctx,
req_cryptoctx,
idopts->cert_filename, id_cryptoctx);
if (status != SECSuccess) {
pkiDebug("%s: error loading NSS certdb \"%s\": %s\n",
__FUNCTION__, idopts->cert_filename,
PORT_ErrorToName(PORT_GetError()));
return ENOMEM;
}
return 0;
break;
case IDTYPE_DIR:
id_cryptoctx->defer_with_dummy_password = TRUE;
status = crypto_load_dir(context,
plg_cryptoctx,
req_cryptoctx,
idopts->cert_filename,
PR_TRUE, PR_FALSE, PR_FALSE, id_cryptoctx);
if (status != SECSuccess) {
pkiDebug("%s: error loading directory \"%s\": %s\n",
__FUNCTION__, idopts->cert_filename,
PORT_ErrorToName(PORT_GetError()));
return defer_id_prompts ? 0 : ENOMEM;
}
return 0;
break;
case IDTYPE_PKCS11:
id_cryptoctx->defer_with_dummy_password = FALSE;
status = crypto_load_pkcs11(context,
plg_cryptoctx,
req_cryptoctx, idopts, id_cryptoctx);
if (status != SECSuccess) {
pkiDebug("%s: error loading module \"%s\": %s\n",
__FUNCTION__, idopts->p11_module_name,
PORT_ErrorToName(PORT_GetError()));
return ENOMEM;
}
return 0;
break;
case IDTYPE_PKCS12:
id_cryptoctx->defer_with_dummy_password = FALSE;
status = crypto_load_pkcs12(context,
plg_cryptoctx,
req_cryptoctx,
idopts->cert_filename, id_cryptoctx);
if (status != SECSuccess) {
pkiDebug("%s: error loading PKCS12 bundle \"%s\"\n",
__FUNCTION__, idopts->cert_filename);
return ENOMEM;
}
return 0;
break;
default:
return EINVAL;
break;
}
}
/* Drop "self" certificate and keys that we didn't select. */
krb5_error_code
crypto_free_cert_info(krb5_context context,
pkinit_plg_crypto_context plg_cryptoctx,
pkinit_req_crypto_context req_cryptoctx,
pkinit_identity_crypto_context id_cryptoctx)
{
/* Mimic the OpenSSL-based implementation's check first. */
if (id_cryptoctx == NULL)
return EINVAL;
/* Maybe should we nuke the id_certs list here? */
return 0;
}
/* Count how many candidate "self" certificates and keys we have. We could as
* easily count the keys. */
krb5_error_code
crypto_cert_get_count(krb5_context context,
pkinit_plg_crypto_context plg_cryptoctx,
pkinit_req_crypto_context req_cryptoctx,
pkinit_identity_crypto_context id_cryptoctx,
int *cert_count)
{
CERTCertListNode *node;
*cert_count = 0;
if (!CERT_LIST_EMPTY(id_cryptoctx->id_certs))
for (node = CERT_LIST_HEAD(id_cryptoctx->id_certs);
(node != NULL) &&
(node->cert != NULL) &&
!CERT_LIST_END(node, id_cryptoctx->id_certs);
node = CERT_LIST_NEXT(node))
(*cert_count)++;
pkiDebug("%s: %d candidate key/certificate pairs found\n",
__FUNCTION__, *cert_count);
return 0;
}
/* Start walking the list of "self" certificates and keys. */
krb5_error_code
crypto_cert_iteration_begin(krb5_context context,
pkinit_plg_crypto_context plg_cryptoctx,
pkinit_req_crypto_context req_cryptoctx,
pkinit_identity_crypto_context id_cryptoctx,
pkinit_cert_iter_handle *iter_handle)
{
PLArenaPool *pool;
struct _pkinit_cert_iter_info *handle;
if (CERT_LIST_EMPTY(id_cryptoctx->id_certs))
return ENOENT;
pool = PORT_NewArena(sizeof(double));
if (pool == NULL)
return ENOMEM;
handle = PORT_ArenaZAlloc(pool, sizeof(*handle));
if (handle == NULL) {
PORT_FreeArena(pool, PR_TRUE);
return ENOMEM;
}
handle->pool = pool;
handle->id_cryptoctx = id_cryptoctx;
handle->node = CERT_LIST_HEAD(handle->id_cryptoctx->id_certs);
*iter_handle = handle;
return 0;
}
/* Stop walking the list of "self" certificates and keys. */
krb5_error_code
crypto_cert_iteration_end(krb5_context context,
pkinit_cert_iter_handle iter_handle)
{
PORT_FreeArena(iter_handle->pool, PR_TRUE);
return 0;
}
/* Walk to the first/next "self" certificate and key. The cert_handle we
* produce here has to be useful beyond the life of the iteration handle, so it
* can't be allocated from the iteration handle's memory pool. */
krb5_error_code
crypto_cert_iteration_next(krb5_context context,
pkinit_cert_iter_handle iter_handle,
pkinit_cert_handle *cert_handle)
{
PLArenaPool *pool;
/* Check if we're at the last node. */
if (CERT_LIST_END(iter_handle->node,
iter_handle->id_cryptoctx->id_certs)) {
/* No more entries. */
*cert_handle = NULL;
return PKINIT_ITER_NO_MORE;
}
/* Create a pool to hold info about this certificate. */
pool = PORT_NewArena(sizeof(double));
if (pool == NULL)
return ENOMEM;
*cert_handle = PORT_ArenaZAlloc(pool, sizeof(**cert_handle));
if (*cert_handle == NULL) {
PORT_FreeArena(pool, PR_TRUE);
return ENOMEM;
}
(*cert_handle)->pool = pool;
/* Return a copy of the certificate in this node, and then move on to
* the next one. */
(*cert_handle)->id_cryptoctx = iter_handle->id_cryptoctx;
(*cert_handle)->cert = CERT_DupCertificate(iter_handle->node->cert);
iter_handle->node = CERT_LIST_NEXT(iter_handle->node);
return 0;
}
/* Read names, key usage, and extended key usage from the cert. */
static SECItem *
cert_get_ext_by_tag(CERTCertificate *cert, SECOidTag tag)
{
SECOidData *oid;
int i;
oid = SECOID_FindOIDByTag(tag);
for (i = 0;
(cert->extensions != NULL) && (cert->extensions[i] != NULL);
i++)
if (SECITEM_ItemsAreEqual(&cert->extensions[i]->id, &oid->oid))
return &cert->extensions[i]->value;
return NULL;
}
/* Check for the presence of a particular key usage in the cert's keyUsage
* extension field. If it's not there, NSS just sets all of the bits, which is
* consistent with what the OpenSSL version of this does. */
static unsigned int
cert_get_ku_bits(krb5_context context, CERTCertificate *cert)
{
unsigned int ku = 0;
if (cert->keyUsage & KU_DIGITAL_SIGNATURE)
ku |= PKINIT_KU_DIGITALSIGNATURE;
if (cert->keyUsage & KU_KEY_ENCIPHERMENT)
ku |= PKINIT_KU_KEYENCIPHERMENT;
return ku;
}
static unsigned int
cert_get_eku_bits(krb5_context context, CERTCertificate *cert, PRBool kdc)
{
PLArenaPool *pool;
SECItem *ext, **oids;
SECOidData *clientauth, *serverauth, *email;
int i;
unsigned int eku;
/* Pull out the extension. */
ext = cert_get_ext_by_tag(cert, SEC_OID_X509_EXT_KEY_USAGE);
if (ext == NULL)
return 0;
/* Look up the well-known OIDs. */
clientauth = SECOID_FindOIDByTag(SEC_OID_EXT_KEY_USAGE_CLIENT_AUTH);
serverauth = SECOID_FindOIDByTag(SEC_OID_EXT_KEY_USAGE_SERVER_AUTH);
email = SECOID_FindOIDByTag(SEC_OID_EXT_KEY_USAGE_EMAIL_PROTECT);
/* Decode the list of OIDs. */
pool = PORT_NewArena(sizeof(double));
oids = NULL;
if (SEC_ASN1DecodeItem(pool, &oids,
SEC_ASN1_GET(SEC_SequenceOfObjectIDTemplate),
ext) != SECSuccess) {
PORT_FreeArena(pool, PR_TRUE);
return 0;
}
eku = 0;
for (i = 0; (oids != NULL) && (oids[i] != NULL); i++) {
if (SECITEM_ItemsAreEqual(oids[i], &email->oid))
eku |= PKINIT_EKU_EMAILPROTECTION;
if (kdc) {
if (SECITEM_ItemsAreEqual(oids[i], &pkinit_kp_kdc))
eku |= PKINIT_EKU_PKINIT;
if (SECITEM_ItemsAreEqual(oids[i], &serverauth->oid))
eku |= PKINIT_EKU_CLIENTAUTH;
} else {
if (SECITEM_ItemsAreEqual(oids[i], &pkinit_kp_client))
eku |= PKINIT_EKU_PKINIT;
if (SECITEM_ItemsAreEqual(oids[i], &clientauth->oid))
eku |= PKINIT_EKU_CLIENTAUTH;
}
if (SECITEM_ItemsAreEqual(oids[i], &pkinit_kp_mssclogin))
eku |= PKINIT_EKU_MSSCLOGIN;
}
PORT_FreeArena(pool, PR_TRUE);
return eku;
}
krb5_error_code
crypto_cert_get_matching_data(krb5_context context,
pkinit_cert_handle cert_handle,
pkinit_cert_matching_data **ret_data)
{
pkinit_cert_matching_data *md;
md = malloc(sizeof(*md));
if (md == NULL) {
return ENOMEM;
}
md->ch = cert_handle;
md->subject_dn = strdup(cert_handle->cert->subjectName);
/* FIXME: string representation varies from OpenSSL's */
md->issuer_dn = strdup(cert_handle->cert->issuerName);
/* FIXME: string representation varies from OpenSSL's */
md->ku_bits = cert_get_ku_bits(context, cert_handle->cert);
md->eku_bits = cert_get_eku_bits(context, cert_handle->cert, PR_FALSE);
if (cert_retrieve_cert_sans(context, cert_handle->cert,
&md->sans, &md->sans, NULL) != 0)
md->sans = NULL;
*ret_data = md;
return 0;
}
/* Free up the data for this certificate. */
krb5_error_code
crypto_cert_release(krb5_context context, pkinit_cert_handle cert_handle)
{
CERT_DestroyCertificate(cert_handle->cert);
PORT_FreeArena(cert_handle->pool, PR_TRUE);
return 0;
}
/* Free names, key usage, and extended key usage from the cert matching data
* structure -- everything except the cert_handle it contains, anyway. */
krb5_error_code
crypto_cert_free_matching_data(krb5_context context,
pkinit_cert_matching_data *data)
{
free(data->subject_dn);
free(data->issuer_dn);
free(data);
return 0;
}
/* Mark the cert tracked in the matching data structure as the one we're going
* to use. */
krb5_error_code
crypto_cert_select(krb5_context context, pkinit_cert_matching_data *data)
{
CERTCertificate *cert;
cert = CERT_DupCertificate(data->ch->cert);
if (data->ch->id_cryptoctx->id_cert != NULL)
CERT_DestroyCertificate(data->ch->id_cryptoctx->id_cert);
data->ch->id_cryptoctx->id_cert = cert;
crypto_update_signer_identity(context, data->ch->id_cryptoctx);
return 0;
}
/* Try to select the "default" cert, which for now is the only cert, if we only
* have one. */
krb5_error_code
crypto_cert_select_default(krb5_context context,
pkinit_plg_crypto_context plg_cryptoctx,
pkinit_req_crypto_context req_cryptoctx,
pkinit_identity_crypto_context id_cryptoctx)
{
CERTCertListNode *node;
CERTCertificate *cert;
krb5_principal *sans;
krb5_data *c;
krb5_error_code code;
int result, count, i;
result = crypto_cert_get_count(context,
plg_cryptoctx,
req_cryptoctx, id_cryptoctx, &count);
if (result != 0)
return result;
if (count == 1)
/* use the only cert */
cert = (CERT_LIST_HEAD(id_cryptoctx->id_certs))->cert;
else {
pkiDebug("%s: searching for a KDC certificate\n", __FUNCTION__);
/* look for a cert that includes a TGS principal name */
cert = NULL;
for (node = CERT_LIST_HEAD(id_cryptoctx->id_certs);
(node != NULL) &&
(node->cert != NULL) &&
!CERT_LIST_END(node, id_cryptoctx->id_certs);
node = CERT_LIST_NEXT(node)) {
sans = NULL;
pkiDebug("%s: checking candidate certificate \"%s\"\n",
__FUNCTION__, node->cert->subjectName);
code = cert_retrieve_cert_sans(context, node->cert,
&sans, NULL, NULL);
if ((code == 0) && (sans != NULL)) {
for (i = 0; sans[i] != NULL; i++) {
c = krb5_princ_component(context, sans[i], 0);
if ((c->length == KRB5_TGS_NAME_SIZE) &&
(memcmp(c->data, KRB5_TGS_NAME,
KRB5_TGS_NAME_SIZE) == 0)) {
cert = node->cert;
pkiDebug("%s: selecting %s "
"certificate \"%s\"\n",
__FUNCTION__,
KRB5_TGS_NAME, cert->subjectName);
}
krb5_free_principal(context, sans[i]);
}
free(sans);
sans = NULL;
}
if (cert != NULL)
break;
}
if (cert == NULL)
return ENOENT;
}
if (id_cryptoctx->id_cert != NULL)
CERT_DestroyCertificate(id_cryptoctx->id_cert);
id_cryptoctx->id_cert = CERT_DupCertificate(cert);
crypto_update_signer_identity(context, id_cryptoctx);
return 0;
}
krb5_error_code
crypto_load_cas_and_crls(krb5_context context,
pkinit_plg_crypto_context plg_cryptoctx,
pkinit_req_crypto_context req_cryptoctx,
pkinit_identity_opts * idopts,
pkinit_identity_crypto_context id_cryptoctx,
int idtype, int catype, char *id)
{
SECStatus status;
PRBool cert_self, cert_mark_trusted, load_crl;
/* Figure out what we're doing here. */
switch (catype) {
case CATYPE_ANCHORS:
/* Screen out source types we can't use. */
switch (idtype) {
case IDTYPE_FILE:
case IDTYPE_DIR:
case IDTYPE_NSS:
/* We only support these sources. */
break;
default:
return EINVAL;
break;
}
/* Mark certs we load as trusted roots. */
cert_self = PR_FALSE;
cert_mark_trusted = PR_TRUE;
load_crl = PR_FALSE;
break;
case CATYPE_INTERMEDIATES:
/* Screen out source types we can't use. */
switch (idtype) {
case IDTYPE_FILE:
case IDTYPE_DIR:
case IDTYPE_NSS:
/* We only support these sources. */
break;
default:
return EINVAL;
break;
}
/* Hang on to certs as reference material. */
cert_self = PR_FALSE;
cert_mark_trusted = PR_FALSE;
load_crl = PR_FALSE;
break;
case CATYPE_CRLS:
/* Screen out source types we can't use. */
switch (idtype) {
case IDTYPE_FILE:
case IDTYPE_DIR:
/* We only support these sources. */
break;
default:
return EINVAL;
break;
}
/* No certs, just CRLs. */
cert_self = PR_FALSE;
cert_mark_trusted = PR_FALSE;
load_crl = PR_TRUE;
break;
default:
return ENOSYS;
break;
}
switch (idtype) {
case IDTYPE_FILE:
status = crypto_load_files(context,
plg_cryptoctx,
req_cryptoctx,
load_crl ? NULL : id,
NULL,
load_crl ? id : NULL,
cert_self, cert_mark_trusted, id_cryptoctx);
if (status != SECSuccess) {
pkiDebug("%s: error loading file \"%s\"\n", __FUNCTION__, id);
return ENOMEM;
}
return 0;
break;
case IDTYPE_NSS:
status = crypto_load_nssdb(context,
plg_cryptoctx,
req_cryptoctx, id, id_cryptoctx);
if (status != SECSuccess) {
pkiDebug("%s: error loading NSS certdb \"%s\"\n",
__FUNCTION__, idopts->cert_filename);
return ENOMEM;
}
return 0;
break;
case IDTYPE_DIR:
status = crypto_load_dir(context,
plg_cryptoctx,
req_cryptoctx,
id,
cert_self, cert_mark_trusted, load_crl,
id_cryptoctx);
if (status != SECSuccess) {
pkiDebug("%s: error loading directory \"%s\"\n", __FUNCTION__, id);
return ENOMEM;
}
return 0;
break;
default:
return EINVAL;
break;
}
}
/* Retrieve the client's copy of the KDC's certificate. */
krb5_error_code
pkinit_get_kdc_cert(krb5_context context,
pkinit_plg_crypto_context plg_cryptoctx,
pkinit_req_crypto_context req_cryptoctx,
pkinit_identity_crypto_context id_cryptoctx,
krb5_principal princ)
{
/* Nothing to do. */
return 0;
}
/* Create typed-data with sets of acceptable DH parameters. */
krb5_error_code
pkinit_create_td_dh_parameters(krb5_context context,
pkinit_plg_crypto_context plg_cryptoctx,
pkinit_req_crypto_context req_cryptoctx,
pkinit_identity_crypto_context id_cryptoctx,
pkinit_plg_opts *opts, krb5_pa_data ***pa_data)
{
struct domain_parameters *params;
SECItem tmp, *oid;
krb5_algorithm_identifier id[sizeof(oakley_groups) /
sizeof(oakley_groups[0])];
krb5_algorithm_identifier *ids[(sizeof(id) / sizeof(id[0])) + 1];
unsigned int i, j;
krb5_data *data;
krb5_pa_data **typed_data;
krb5_error_code code;
*pa_data = NULL;
/* Fetch the algorithm OID. */
oid = get_oid_from_tag(SEC_OID_X942_DIFFIE_HELMAN_KEY);
if (oid == NULL)
return ENOMEM;
/* Walk the lists of parameters that we know. */
for (i = 0, j = 0; i < sizeof(id) / sizeof(id[0]); i++) {
if (oakley_groups[i].bits < opts->dh_min_bits)
continue;
/* Encode these parameters for use as algorithm parameters. */
if (oakley_parse_group(req_cryptoctx->pool, &oakley_groups[i],
¶ms) != 0)
continue;
memset(¶ms, 0, sizeof(params));
if (SEC_ASN1EncodeItem(req_cryptoctx->pool, &tmp,
params,
domain_parameters_template) != SECSuccess)
continue;
/* Add it to the list. */
memset(&id[j], 0, sizeof(id[j]));
id[j].algorithm.data = (char *)oid->data;
id[j].algorithm.length = oid->len;
id[j].parameters.data = (char *)tmp.data;
id[j].parameters.length = tmp.len;
ids[j] = &id[j];
j++;
}
if (j == 0)
return ENOENT;
ids[j] = NULL;
/* Pass it back up. */
data = NULL;
code = (*k5int_encode_krb5_td_dh_parameters)(ids, &data);
if (code != 0)
return code;
typed_data = malloc(sizeof(*typed_data) * 2);
if (typed_data == NULL) {
krb5_free_data(context, data);
return ENOMEM;
}
typed_data[0] = malloc(sizeof(**typed_data));
if (typed_data[0] == NULL) {
free(typed_data);
krb5_free_data(context, data);
return ENOMEM;
}
typed_data[0]->pa_type = TD_DH_PARAMETERS;
typed_data[0]->length = data->length;
typed_data[0]->contents = (unsigned char *) data->data;
typed_data[1] = NULL;
*pa_data = typed_data;
free(data);
return code;
}
/* Parse typed-data with sets of acceptable DH parameters and return the
* minimum prime size that the KDC will accept. */
krb5_error_code
pkinit_process_td_dh_params(krb5_context context,
pkinit_plg_crypto_context plg_cryptoctx,
pkinit_req_crypto_context req_cryptoctx,
pkinit_identity_crypto_context id_cryptoctx,
krb5_algorithm_identifier **algId,
int *new_dh_size)
{
struct domain_parameters params;
SECItem item;
int i, size;
/* Set an initial reasonable guess if we got no hints that we could
* parse. */
*new_dh_size = 2048;
for (i = 0; (algId != NULL) && (algId[i] != NULL); i++) {
/* Decode the domain parameters. */
item.len = algId[i]->parameters.length;
item.data = (unsigned char *)algId[i]->parameters.data;
memset(¶ms, 0, sizeof(params));
if (SEC_ASN1DecodeItem(req_cryptoctx->pool, ¶ms,
domain_parameters_template,
&item) != SECSuccess)
continue;
/* Count the size of the prime by finding the first non-zero
* byte and working out the size of the integer. */
size = get_integer_bits(¶ms.p);
/* If this is the first parameter set, or the current parameter
* size is lower than our previous guess, use it. */
if ((i == 0) || (size < *new_dh_size))
*new_dh_size = size;
}
return 0;
}
/* Create typed-data with the client cert that we didn't like. */
krb5_error_code
pkinit_create_td_invalid_certificate(krb5_context context,
pkinit_plg_crypto_context plg_cryptoctx,
pkinit_req_crypto_context req_cryptoctx,
pkinit_identity_crypto_context
id_cryptoctx, krb5_pa_data ***pa_data)
{
CERTCertificate *invalid;
krb5_external_principal_identifier id;
krb5_external_principal_identifier *ids[2];
struct issuer_and_serial_number isn;
krb5_data *data;
SECItem item;
krb5_pa_data **typed_data;
krb5_error_code code;
*pa_data = NULL;
/* We didn't trust the peer's certificate. FIXME: or was it a
* certificate that was somewhere in its certifying chain? */
if (req_cryptoctx->peer_cert == NULL)
return ENOENT;
invalid = req_cryptoctx->peer_cert;
/* Fill in the identifier. */
memset(&id, 0, sizeof(id));
if (req_cryptoctx->peer_cert->keyIDGenerated) {
isn.issuer = invalid->derIssuer;
isn.serial = invalid->serialNumber;
if (SEC_ASN1EncodeItem(req_cryptoctx->pool, &item, &isn,
issuer_and_serial_number_template) != &item)
return ENOMEM;
id.issuerAndSerialNumber.data = (char *)item.data;
id.issuerAndSerialNumber.length = item.len;
} else {
item = invalid->subjectKeyID;
id.subjectKeyIdentifier.data = (char *)item.data;
id.subjectKeyIdentifier.length = item.len;
}
ids[0] = &id;
ids[1] = NULL;
/* Pass it back up. */
data = NULL;
code = (*k5int_encode_krb5_td_trusted_certifiers)(ids, &data);
if (code != 0)
return code;
typed_data = malloc(sizeof(*typed_data) * 2);
if (typed_data == NULL) {
krb5_free_data(context, data);
return ENOMEM;
}
typed_data[0] = malloc(sizeof(**typed_data));
if (typed_data[0] == NULL) {
free(typed_data);
krb5_free_data(context, data);
return ENOMEM;
}
typed_data[0]->pa_type = TD_INVALID_CERTIFICATES;
typed_data[0]->length = data->length;
typed_data[0]->contents = (unsigned char *) data->data;
typed_data[1] = NULL;
*pa_data = typed_data;
free(data);
return code;
}
/* Create typed-data with a list of certifiers that we would accept. */
krb5_error_code
pkinit_create_td_trusted_certifiers(krb5_context context,
pkinit_plg_crypto_context plg_cryptoctx,
pkinit_req_crypto_context req_cryptoctx,
pkinit_identity_crypto_context
id_cryptoctx, krb5_pa_data ***pa_data)
{
krb5_external_principal_identifier **ids;
krb5_external_principal_identifier *id;
struct issuer_and_serial_number isn;
krb5_data *data;
SECItem item;
krb5_pa_data **typed_data;
krb5_error_code code;
int i;
unsigned int trustf;
SECStatus status;
PK11SlotList *slist;
PK11SlotListElement *sle;
CERTCertificate *cert;
CERTCertList *sclist, *clist;
CERTCertListNode *node;
*pa_data = NULL;
/* Build the list of trusted roots. */
clist = CERT_NewCertList();
if (clist == NULL)
return ENOMEM;
/* Get the list of tokens. All of them. */
slist = PK11_GetAllTokens(CKM_INVALID_MECHANISM, PR_FALSE,
PR_FALSE,
crypto_pwcb_prep(id_cryptoctx, NULL, context));
if (slist == NULL) {
CERT_DestroyCertList(clist);
return ENOENT;
}
/* Walk the list of tokens. */
i = 0;
status = SECSuccess;
for (sle = slist->head; sle != NULL; sle = sle->next) {
/* Skip over slots we would still need to log in to before using. */
if (!PK11_IsLoggedIn(sle->slot,
crypto_pwcb_prep(id_cryptoctx, NULL, context)) &&
PK11_NeedLogin(sle->slot)) {
pkiDebug("%s: skipping token \"%s\"\n",
__FUNCTION__, PK11_GetTokenName(sle->slot));
continue;
}
/* Get the list of certs, and skip the slot if it doesn't have
* any. */
sclist = PK11_ListCertsInSlot(sle->slot);
if (sclist == NULL) {
pkiDebug("%s: nothing found in token \"%s\"\n",
__FUNCTION__, PK11_GetTokenName(sle->slot));
continue;
}
if (CERT_LIST_EMPTY(sclist)) {
CERT_DestroyCertList(sclist);
pkiDebug("%s: nothing found in token \"%s\"\n",
__FUNCTION__, PK11_GetTokenName(sle->slot));
continue;
}
/* Walk the list of certs, and for each one that's a trusted
* root, add it to the list. */
for (node = CERT_LIST_HEAD(sclist);
(node != NULL) &&
(node->cert != NULL) &&
!CERT_LIST_END(node, sclist);
node = CERT_LIST_NEXT(node)) {
/* If we have no trust for it, we can't trust it. */
if (node->cert->trust == NULL)
continue;
/* We need to trust it to issue client certs. */
trustf = SEC_GET_TRUST_FLAGS(node->cert->trust, trustSSL);
if (!(trustf & CERTDB_TRUSTED_CLIENT_CA))
continue;
/* DestroyCertList frees all of the certs in the list,
* so we need to create a copy that it can own. */
cert = CERT_DupCertificate(node->cert);
if (cert_maybe_add_to_list(clist, cert) != SECSuccess)
status = ENOMEM;
else
i++;
}
CERT_DestroyCertList(sclist);
}
PK11_FreeSlotList(slist);
if (status != SECSuccess) {
CERT_DestroyCertList(clist);
return ENOMEM;
}
/* Allocate some temporary storage. */
id = PORT_ArenaZAlloc(req_cryptoctx->pool, sizeof(**ids) * i);
ids = PORT_ArenaZAlloc(req_cryptoctx->pool, sizeof(*ids) * (i + 1));
if ((id == NULL) || (ids == NULL)) {
CERT_DestroyCertList(clist);
return ENOMEM;
}
/* Fill in the identifiers. */
i = 0;
for (node = CERT_LIST_HEAD(clist);
(node != NULL) &&
(node->cert != NULL) &&
!CERT_LIST_END(node, clist);
node = CERT_LIST_NEXT(node)) {
if (node->cert->keyIDGenerated) {
isn.issuer = node->cert->derIssuer;
isn.serial = node->cert->serialNumber;
if (SEC_ASN1EncodeItem(req_cryptoctx->pool, &item, &isn,
issuer_and_serial_number_template) !=
&item) {
CERT_DestroyCertList(clist);
return ENOMEM;
}
id[i].issuerAndSerialNumber.data = (char *)item.data;
id[i].issuerAndSerialNumber.length = item.len;
} else {
item = node->cert->subjectKeyID;
id[i].subjectKeyIdentifier.data = (char *)item.data;
id[i].subjectKeyIdentifier.length = item.len;
}
ids[i] = &id[i];
i++;
}
ids[i] = NULL;
/* Pass the list back up. */
data = NULL;
code = (*k5int_encode_krb5_td_trusted_certifiers)(ids, &data);
CERT_DestroyCertList(clist);
if (code != 0)
return code;
typed_data = malloc(sizeof(*typed_data) * 2);
if (typed_data == NULL) {
krb5_free_data(context, data);
return ENOMEM;
}
typed_data[0] = malloc(sizeof(**typed_data));
if (typed_data[0] == NULL) {
free(typed_data);
krb5_free_data(context, data);
return ENOMEM;
}
typed_data[0]->pa_type = TD_TRUSTED_CERTIFIERS;
typed_data[0]->length = data->length;
typed_data[0]->contents = (unsigned char *) data->data;
typed_data[1] = NULL;
*pa_data = typed_data;
free(data);
return code;
}
krb5_error_code
pkinit_process_td_trusted_certifiers(krb5_context context,
pkinit_plg_crypto_context plg_cryptoctx,
pkinit_req_crypto_context req_cryptoctx,
pkinit_identity_crypto_context
id_cryptoctx,
krb5_external_principal_identifier **
trustedCertifiers,
int td_type)
{
/* We should select a different client certificate based on the list of
* trusted certifiers, but for now we'll just chicken out. */
return KRB5KDC_ERR_PREAUTH_FAILED;
}
/* Check if the encoded issuer/serial matches our (the KDC's) certificate. */
krb5_error_code
pkinit_check_kdc_pkid(krb5_context context,
pkinit_plg_crypto_context plg_cryptoctx,
pkinit_req_crypto_context req_cryptoctx,
pkinit_identity_crypto_context id_cryptoctx,
unsigned char *pkid_buf,
unsigned int pkid_len, int *valid_kdcPkId)
{
PLArenaPool *pool;
CERTCertificate *cert;
SECItem pkid;
struct issuer_and_serial_number isn;
pool = PORT_NewArena(sizeof(double));
if (pool == NULL)
return ENOMEM;
/* Verify that we have selected a certificate for our (the KDC's) own
* use. */
if (id_cryptoctx->id_cert == NULL)
return ENOENT;
cert = id_cryptoctx->id_cert;
/* Decode the pair. */
pkid.data = pkid_buf;
pkid.len = pkid_len;
memset(&isn, 0, sizeof(isn));
if (SEC_ASN1DecodeItem(pool, &isn, issuer_and_serial_number_template,
&pkid) != SECSuccess) {
PORT_FreeArena(pool, PR_TRUE);
return ENOMEM;
}
/* Compare the issuer and serial number. */
*valid_kdcPkId = SECITEM_ItemsAreEqual(&isn.issuer,
&cert->derIssuer) &&
SECITEM_ItemsAreEqual(&isn.serial, &cert->serialNumber);
/* Clean up. */
PORT_FreeArena(pool, PR_TRUE);
return 0;
}
krb5_error_code
pkinit_identity_set_prompter(pkinit_identity_crypto_context id_cryptoctx,
krb5_prompter_fct prompter, void *prompter_data)
{
id_cryptoctx->pwcb_args.prompter = prompter;
id_cryptoctx->pwcb_args.prompter_data = prompter_data;
return 0;
}
/* Convert a DH secret and optional data to a keyblock using the specified
* digest and a big-endian counter of the specified length that starts at the
* specified value. */
static krb5_error_code
pkinit_octetstring_hkdf(krb5_context context,
SECOidTag hash_alg,
int counter_start, size_t counter_length,
krb5_enctype etype,
unsigned char *dh_key, unsigned int dh_key_len,
char *other_data, unsigned int other_data_len,
krb5_keyblock *krb5key)
{
PK11Context *ctx;
unsigned int left, length, rnd_len;
unsigned char counter[8], buf[512]; /* the longest digest we support */
int i;
char *rnd_buf;
size_t kbyte, klength;
krb5_data rnd_data;
krb5_error_code result;
NSSInitContext *ncontext;
if (counter_length > sizeof(counter))
return EINVAL;
result = krb5_c_keylengths(context, etype, &kbyte, &klength);
if (result != 0)
return result;
rnd_buf = malloc(dh_key_len);
if (rnd_buf == NULL)
return ENOMEM;
memset(counter, 0, sizeof(counter));
for (i = sizeof(counter) - 1; i >= 0; i--)
counter[i] = (counter_start >> (8 * (counter_length - 1 - i))) & 0xff;
rnd_len = kbyte;
left = rnd_len;
ncontext = NSS_InitContext(DEFAULT_CONFIGDIR,
NULL,
NULL,
NULL,
NULL,
NSS_INIT_READONLY |
NSS_INIT_NOCERTDB |
NSS_INIT_NOMODDB |
NSS_INIT_FORCEOPEN |
NSS_INIT_NOROOTINIT |
NSS_INIT_PK11RELOAD);
while (left > 0) {
ctx = PK11_CreateDigestContext(hash_alg);
if (ctx == NULL) {
krb5int_zap(buf, sizeof(buf));
krb5int_zap(rnd_buf, dh_key_len);
free(rnd_buf);
return ENOMEM;
}
if (PK11_DigestBegin(ctx) != SECSuccess) {
PK11_DestroyContext(ctx, PR_TRUE);
krb5int_zap(buf, sizeof(buf));
krb5int_zap(rnd_buf, dh_key_len);
free(rnd_buf);
return ENOMEM;
}
if (PK11_DigestOp(ctx, counter, counter_length) != SECSuccess) {
PK11_DestroyContext(ctx, PR_TRUE);
krb5int_zap(buf, sizeof(buf));
krb5int_zap(rnd_buf, dh_key_len);
free(rnd_buf);
return ENOMEM;
}
if (PK11_DigestOp(ctx, dh_key, dh_key_len) != SECSuccess) {
PK11_DestroyContext(ctx, PR_TRUE);
krb5int_zap(buf, sizeof(buf));
krb5int_zap(rnd_buf, dh_key_len);
free(rnd_buf);
return ENOMEM;
}
if ((other_data_len > 0) &&
(PK11_DigestOp(ctx, (const unsigned char *) other_data,
other_data_len) != SECSuccess)) {
PK11_DestroyContext(ctx, PR_TRUE);
krb5int_zap(buf, sizeof(buf));
krb5int_zap(rnd_buf, dh_key_len);
free(rnd_buf);
return ENOMEM;
}
if (PK11_DigestFinal(ctx, buf, &length, sizeof(buf)) != SECSuccess) {
PK11_DestroyContext(ctx, PR_TRUE);
krb5int_zap(buf, sizeof(buf));
krb5int_zap(rnd_buf, dh_key_len);
free(rnd_buf);
return ENOMEM;
}
PK11_DestroyContext(ctx, PR_TRUE);
if (left < length) {
length = left;
}
memcpy(rnd_buf + rnd_len - left, buf, length);
left -= length;
for (i = counter_length - 1; i >= 0; i--) {
counter[i] = ((counter[i] + 1) & 0xff);
if (counter[i] != 0)
break;
}
}
if (NSS_ShutdownContext(ncontext) != SECSuccess)
pkiDebug("%s: error shutting down context\n", __FUNCTION__);
krb5key->contents = malloc(klength);
if (krb5key->contents == NULL) {
krb5key->length = 0;
return ENOMEM;
}
krb5key->length = klength;
krb5key->enctype = etype;
rnd_data.data = rnd_buf;
rnd_data.length = rnd_len;
result = krb5_c_random_to_key(context, etype, &rnd_data, krb5key);
krb5int_zap(buf, sizeof(buf));
krb5int_zap(rnd_buf, dh_key_len);
free(rnd_buf);
return result;
}
/* Convert a DH secret to a keyblock, RFC4556-style. */
krb5_error_code
pkinit_octetstring2key(krb5_context context,
krb5_enctype etype,
unsigned char *dh_key,
unsigned int dh_key_len, krb5_keyblock *krb5key)
{
return pkinit_octetstring_hkdf(context,
SEC_OID_SHA1, 0, 1, etype,
dh_key, dh_key_len, NULL, 0,
krb5key);
}
/* Return TRUE if the item and the "algorithm" part of the algorithm identifier
* are the same. */
static PRBool
data_and_ptr_and_length_equal(const krb5_data *data,
const void *ptr, size_t len)
{
return (data->length == len) && (memcmp(data->data, ptr, len) == 0);
}
/* Encode the other info used by the agility KDF. Taken almost verbatim from
* parts of the agility KDF in pkinit_crypto_openssl.c */
static krb5_error_code
encode_agility_kdf_other_info(krb5_context context,
krb5_data *alg_oid,
krb5_const_principal party_u_info,
krb5_const_principal party_v_info,
krb5_enctype enctype,
krb5_data *as_req,
krb5_data *pk_as_rep,
krb5_data **other_info)
{
krb5_error_code retval = 0;
krb5_sp80056a_other_info other_info_fields;
krb5_pkinit_supp_pub_info supp_pub_info_fields;
krb5_data *supp_pub_info = NULL;
krb5_algorithm_identifier alg_id;
/* If this is anonymous pkinit, we need to use the anonymous principal for
* party_u_info */
if (party_u_info &&
krb5_principal_compare_any_realm(context, party_u_info,
krb5_anonymous_principal()))
party_u_info = krb5_anonymous_principal();
/* Encode the ASN.1 octet string for "SuppPubInfo" */
supp_pub_info_fields.enctype = enctype;
supp_pub_info_fields.as_req = *as_req;
supp_pub_info_fields.pk_as_rep = *pk_as_rep;
retval = encode_krb5_pkinit_supp_pub_info(&supp_pub_info_fields,
&supp_pub_info);
if (retval != 0)
goto cleanup;
/* Now encode the ASN.1 octet string for "OtherInfo" */
memset(&alg_id, 0, sizeof alg_id);
alg_id.algorithm = *alg_oid; /*alias, don't have to free it*/
other_info_fields.algorithm_identifier = alg_id;
other_info_fields.party_u_info = (krb5_principal) party_u_info;
other_info_fields.party_v_info = (krb5_principal) party_v_info;
other_info_fields.supp_pub_info = *supp_pub_info;
retval = encode_krb5_sp80056a_other_info(&other_info_fields, other_info);
if (retval != 0)
goto cleanup;
cleanup:
krb5_free_data(context, supp_pub_info);
return retval;
}
/* Convert a DH secret to a keyblock using the key derivation function
* identified by the passed-in algorithm identifier. Return ENOSYS if it's not
* one that we support. */
krb5_error_code
pkinit_alg_agility_kdf(krb5_context context,
krb5_data *secret,
krb5_data *alg_oid,
krb5_const_principal party_u_info,
krb5_const_principal party_v_info,
krb5_enctype enctype,
krb5_data *as_req,
krb5_data *pk_as_rep,
krb5_keyblock *key_block)
{
krb5_data *other_info = NULL;
krb5_error_code retval = ENOSYS;
retval = encode_agility_kdf_other_info(context,
alg_oid,
party_u_info,
party_v_info,
enctype, as_req, pk_as_rep,
&other_info);
if (retval != 0)
return retval;
if (data_and_ptr_and_length_equal(alg_oid, krb5_pkinit_sha512_oid,
krb5_pkinit_sha512_oid_len))
retval = pkinit_octetstring_hkdf(context,
SEC_OID_SHA512, 1, 4, enctype,
(unsigned char *)secret->data,
secret->length, other_info->data,
other_info->length, key_block);
else if (data_and_ptr_and_length_equal(alg_oid, krb5_pkinit_sha256_oid,
krb5_pkinit_sha256_oid_len))
retval = pkinit_octetstring_hkdf(context,
SEC_OID_SHA256, 1, 4, enctype,
(unsigned char *)secret->data,
secret->length, other_info->data,
other_info->length, key_block);
else if (data_and_ptr_and_length_equal(alg_oid, krb5_pkinit_sha1_oid,
krb5_pkinit_sha1_oid_len))
retval = pkinit_octetstring_hkdf(context,
SEC_OID_SHA1, 1, 4, enctype,
(unsigned char *)secret->data,
secret->length, other_info->data,
other_info->length, key_block);
else
retval = KRB5KDC_ERR_NO_ACCEPTABLE_KDF;
krb5_free_data(context, other_info);
return retval;
}
static int
cert_add_string(unsigned char ***list, int *count,
int len, const unsigned char *value)
{
unsigned char **tmp;
tmp = malloc(sizeof(tmp[0]) * (*count + 2));
if (tmp == NULL) {
return ENOMEM;
}
memcpy(tmp, *list, *count * sizeof(tmp[0]));
tmp[*count] = malloc(len + 1);
if (tmp[*count] == NULL) {
free(tmp);
return ENOMEM;
}
memcpy(tmp[*count], value, len);
tmp[*count][len] = '\0';
tmp[*count + 1] = NULL;
if (*count != 0) {
free(*list);
}
*list = tmp;
(*count)++;
return 0;
}
static int
cert_add_princ(krb5_context context, krb5_principal princ,
krb5_principal **sans_inout, int *n_sans_inout)
{
krb5_principal *tmp;
tmp = malloc(sizeof(krb5_principal *) * (*n_sans_inout + 2));
if (tmp == NULL) {
return ENOMEM;
}
memcpy(tmp, *sans_inout, sizeof(tmp[0]) * *n_sans_inout);
if (krb5_copy_principal(context, princ, &tmp[*n_sans_inout]) != 0) {
free(tmp);
return ENOMEM;
}
tmp[*n_sans_inout + 1] = NULL;
if (*n_sans_inout > 0) {
free(*sans_inout);
}
*sans_inout = tmp;
(*n_sans_inout)++;
return 0;
}
static int
cert_add_upn(PLArenaPool * pool, krb5_context context, SECItem *name,
krb5_principal **sans_inout, int *n_sans_inout)
{
SECItem decoded;
char *unparsed;
krb5_principal tmp;
int i;
/* Decode the string. */
memset(&decoded, 0, sizeof(decoded));
if (SEC_ASN1DecodeItem(pool, &decoded,
SEC_ASN1_GET(SEC_UTF8StringTemplate),
name) != SECSuccess) {
return ENOMEM;
}
unparsed = malloc(decoded.len + 1);
if (unparsed == NULL) {
return ENOMEM;
}
memcpy(unparsed, decoded.data, decoded.len);
unparsed[decoded.len] = '\0';
/* Parse the string into a principal name. */
if (krb5_parse_name(context, unparsed, &tmp) != 0) {
free(unparsed);
return ENOMEM;
}
free(unparsed);
/* Unparse the name back into a string and make sure it matches what
* was in the certificate. */
if (krb5_unparse_name(context, tmp, &unparsed) != 0) {
krb5_free_principal(context, tmp);
return ENOMEM;
}
if ((strlen(unparsed) != decoded.len) ||
(memcmp(unparsed, decoded.data, decoded.len) != 0)) {
krb5_free_unparsed_name(context, unparsed);
krb5_free_principal(context, tmp);
return ENOMEM;
}
/* Add the principal name to the list. */
i = cert_add_princ(context, tmp, sans_inout, n_sans_inout);
krb5_free_unparsed_name(context, unparsed);
krb5_free_principal(context, tmp);
return i;
}
static int
cert_add_kpn(PLArenaPool * pool, krb5_context context, SECItem *name,
krb5_principal** sans_inout, int *n_sans_inout)
{
struct kerberos_principal_name kname;
SECItem **names;
krb5_data *comps;
krb5_principal_data tmp;
unsigned long name_type;
int i, j;
/* Decode the structure. */
memset(&kname, 0, sizeof(kname));
if (SEC_ASN1DecodeItem(pool, &kname,
kerberos_principal_name_template,
name) != SECSuccess)
return ENOMEM;
/* Recover the name type and count the components. */
if (SEC_ASN1DecodeInteger(&kname.principal_name.name_type,
&name_type) != SECSuccess)
return ENOMEM;
names = kname.principal_name.name_string;
for (i = 0; (names != NULL) && (names[i] != NULL); i++)
continue;
comps = malloc(sizeof(comps[0]) * i);
/* Fake up a principal structure. */
for (j = 0; j < i; j++) {
comps[j].length = names[j]->len;
comps[j].data = (char *) names[j]->data;
}
memset(&tmp, 0, sizeof(tmp));
tmp.type = name_type;
tmp.realm.length = kname.realm.len;
tmp.realm.data = (char *) kname.realm.data;
tmp.length = i;
tmp.data = comps;
/* Add the principal name to the list. */
i = cert_add_princ(context, &tmp, sans_inout, n_sans_inout);
free(comps);
return i;
}
static const char *
crypto_get_identity_by_slot(krb5_context context,
pkinit_identity_crypto_context id_cryptoctx,
PK11SlotInfo *slot)
{
PK11SlotInfo *mslot;
struct _pkinit_identity_crypto_userdb *userdb;
struct _pkinit_identity_crypto_module *module;
int i, j;
mslot = id_cryptoctx->id_p12_slot.slot;
if ((mslot != NULL) && (PK11_GetSlotID(mslot) == PK11_GetSlotID(slot)))
return id_cryptoctx->id_p12_slot.p12name;
for (i = 0;
(id_cryptoctx->id_userdbs != NULL) &&
(id_cryptoctx->id_userdbs[i] != NULL);
i++) {
userdb = id_cryptoctx->id_userdbs[i];
if (PK11_GetSlotID(userdb->userdb) == PK11_GetSlotID(slot))
return userdb->name;
}
for (i = 0;
(id_cryptoctx->id_modules != NULL) &&
(id_cryptoctx->id_modules[i] != NULL);
i++) {
module = id_cryptoctx->id_modules[i];
for (j = 0; j < module->module->slotCount; j++) {
mslot = module->module->slots[j];
if (PK11_GetSlotID(mslot) == PK11_GetSlotID(slot))
return module->name;
}
}
return NULL;
}
static void
crypto_update_signer_identity(krb5_context context,
pkinit_identity_crypto_context id_cryptoctx)
{
PK11SlotList *slist;
PK11SlotListElement *sle;
CERTCertificate *cert;
struct _pkinit_identity_crypto_file *obj;
int i;
id_cryptoctx->identity = NULL;
if (id_cryptoctx->id_cert == NULL)
return;
cert = id_cryptoctx->id_cert;
for (i = 0;
(id_cryptoctx->id_objects != NULL) &&
(id_cryptoctx->id_objects[i] != NULL);
i++) {
obj = id_cryptoctx->id_objects[i];
if ((obj->cert != NULL) && CERT_CompareCerts(obj->cert, cert)) {
id_cryptoctx->identity = obj->name;
return;
}
}
if (cert->slot != NULL) {
id_cryptoctx->identity = crypto_get_identity_by_slot(context,
id_cryptoctx,
cert->slot);
if (id_cryptoctx->identity != NULL)
return;
}
slist = PK11_GetAllSlotsForCert(cert, NULL);
if (slist != NULL) {
for (sle = PK11_GetFirstSafe(slist);
sle != NULL;
sle = PK11_GetNextSafe(slist, sle, PR_FALSE)) {
id_cryptoctx->identity = crypto_get_identity_by_slot(context,
id_cryptoctx,
sle->slot);
if (id_cryptoctx->identity != NULL) {
PK11_FreeSlotList(slist);
return;
}
}
PK11_FreeSlotList(slist);
}
}
krb5_error_code
crypto_retrieve_signer_identity(krb5_context context,
pkinit_identity_crypto_context id_cryptoctx,
const char **identity)
{
*identity = id_cryptoctx->identity;
if (*identity == NULL)
return ENOENT;
return 0;
}
static krb5_error_code
cert_retrieve_cert_sans(krb5_context context,
CERTCertificate *cert,
krb5_principal **pkinit_sans_out,
krb5_principal **upn_sans_out,
unsigned char ***kdc_hostname_out)
{
PLArenaPool *pool;
CERTGeneralName name;
SECItem *ext, **encoded_names;
int i, n_pkinit_sans, n_upn_sans, n_hostnames;
/* Pull out the extension. */
ext = cert_get_ext_by_tag(cert, SEC_OID_X509_SUBJECT_ALT_NAME);
if (ext == NULL)
return ENOENT;
/* Split up the list of names. */
pool = PORT_NewArena(sizeof(double));
if (pool == NULL)
return ENOMEM;
encoded_names = NULL;
if (SEC_ASN1DecodeItem(pool, &encoded_names,
SEC_ASN1_GET(SEC_SequenceOfAnyTemplate),
ext) != SECSuccess) {
pkiDebug("%s: error decoding subjectAltName extension\n",
__FUNCTION__);
PORT_FreeArena(pool, PR_TRUE);
return ENOMEM;
}
/* Check each name in turn. */
for (i = 0, n_pkinit_sans = 0, n_upn_sans = 0, n_hostnames = 0;
(encoded_names != NULL) && (encoded_names[i] != NULL);
i++) {
memset(&name, 0, sizeof(name));
if (CERT_DecodeGeneralName(pool, encoded_names[i], &name) != &name) {
pkiDebug("%s: error decoding GeneralName value, skipping\n",
__FUNCTION__);
continue;
}
switch (name.type) {
case certDNSName:
/* hostname, easy */
if ((kdc_hostname_out != NULL) &&
(cert_add_string(kdc_hostname_out, &n_hostnames,
name.name.other.len,
name.name.other.data) != 0)) {
PORT_FreeArena(pool, PR_TRUE);
return ENOMEM;
}
break;
case certOtherName:
/* possibly a kerberos principal name */
if (SECITEM_ItemsAreEqual(&name.name.OthName.oid,
&pkinit_nt_principal)) {
/* Add it to the list. */
if ((pkinit_sans_out != NULL) &&
(cert_add_kpn(pool, context, &name.name.OthName.name,
pkinit_sans_out, &n_pkinit_sans) != 0)) {
PORT_FreeArena(pool, PR_TRUE);
return ENOMEM;
}
/* If both lists are the same, fix the count. */
if (pkinit_sans_out == upn_sans_out)
n_upn_sans = n_pkinit_sans;
} else
/* possibly a user principal name */
if (SECITEM_ItemsAreEqual(&name.name.OthName.oid,
&pkinit_nt_upn)) {
/* Add it to the list. */
if ((upn_sans_out != NULL) &&
(cert_add_upn(pool, context, &name.name.OthName.name,
upn_sans_out, &n_upn_sans) != 0)) {
PORT_FreeArena(pool, PR_TRUE);
return ENOMEM;
}
/* If both lists are the same, fix the count. */
if (upn_sans_out == pkinit_sans_out)
n_pkinit_sans = n_upn_sans;
}
break;
default:
break;
}
}
PORT_FreeArena(pool, PR_TRUE);
return 0;
}
krb5_error_code
crypto_retrieve_cert_sans(krb5_context context,
pkinit_plg_crypto_context plg_cryptoctx,
pkinit_req_crypto_context req_cryptoctx,
pkinit_identity_crypto_context id_cryptoctx,
krb5_principal **pkinit_sans,
krb5_principal **upn_sans,
unsigned char ***kdc_hostname)
{
return cert_retrieve_cert_sans(context,
req_cryptoctx->peer_cert,
pkinit_sans, upn_sans, kdc_hostname);
}
krb5_error_code
crypto_check_cert_eku(krb5_context context,
pkinit_plg_crypto_context plg_cryptoctx,
pkinit_req_crypto_context req_cryptoctx,
pkinit_identity_crypto_context id_cryptoctx,
int checking_kdc_cert,
int allow_secondary_usage, int *eku_valid)
{
int ku, eku;
*eku_valid = 0;
ku = cert_get_ku_bits(context, req_cryptoctx->peer_cert);
if (!(ku & PKINIT_KU_DIGITALSIGNATURE)) {
return 0;
}
eku = cert_get_eku_bits(context, req_cryptoctx->peer_cert,
checking_kdc_cert ? PR_TRUE : PR_FALSE);
if (checking_kdc_cert) {
if (eku & PKINIT_EKU_PKINIT) {
*eku_valid = 1;
} else if (allow_secondary_usage && (eku & PKINIT_EKU_CLIENTAUTH)) {
*eku_valid = 1;
}
} else {
if (eku & PKINIT_EKU_PKINIT) {
*eku_valid = 1;
} else if (allow_secondary_usage && (eku & PKINIT_EKU_MSSCLOGIN)) {
*eku_valid = 1;
}
}
return 0;
}
krb5_error_code
cms_contentinfo_create(krb5_context context,
pkinit_plg_crypto_context plg_cryptoctx,
pkinit_req_crypto_context req_cryptoctx,
pkinit_identity_crypto_context id_cryptoctx,
int cms_msg_type,
unsigned char *in_data, unsigned int in_length,
unsigned char **out_data, unsigned int *out_data_len)
{
PLArenaPool *pool;
SECItem *oid, encoded;
SECOidTag encapsulated_tag;
struct content_info cinfo;
switch (cms_msg_type) {
case CMS_SIGN_DRAFT9:
encapsulated_tag = get_pkinit_data_auth_data9_tag();
break;
case CMS_SIGN_CLIENT:
encapsulated_tag = get_pkinit_data_auth_data_tag();
break;
case CMS_SIGN_SERVER:
encapsulated_tag = get_pkinit_data_dhkey_data_tag();
break;
case CMS_ENVEL_SERVER:
encapsulated_tag = get_pkinit_data_rkey_data_tag();
break;
default:
return ENOSYS;
break;
}
oid = get_oid_from_tag(encapsulated_tag);
if (oid == NULL) {
return ENOMEM;
}
pool = PORT_NewArena(sizeof(double));
if (pool == NULL) {
return ENOMEM;
}
memset(&cinfo, 0, sizeof(cinfo));
cinfo.content_type = *oid;
cinfo.content.data = in_data;
cinfo.content.len = in_length;
memset(&encoded, 0, sizeof(encoded));
if (SEC_ASN1EncodeItem(pool, &encoded, &cinfo,
content_info_template) != &encoded) {
PORT_FreeArena(pool, PR_TRUE);
pkiDebug("%s: error encoding data\n", __FUNCTION__);
return ENOMEM;
}
if (secitem_to_buf_len(&encoded, out_data, out_data_len) != 0) {
PORT_FreeArena(pool, PR_TRUE);
return ENOMEM;
}
#ifdef DEBUG_DER
derdump(*out_data, *out_data_len);
#endif
#ifdef DEBUG_CMS
cmsdump(*out_data, *out_data_len);
#endif
PORT_FreeArena(pool, PR_TRUE);
return 0;
}
/* Create a signed-data content info, add a signature to it, and return it. */
enum sdcc_include_certchain {
signeddata_common_create_omit_chain,
signeddata_common_create_with_chain
};
enum sdcc_include_signed_attrs {
signeddata_common_create_omit_signed_attrs,
signeddata_common_create_with_signed_attrs
};
static krb5_error_code
crypto_signeddata_common_create(krb5_context context,
pkinit_plg_crypto_context plg_cryptoctx,
pkinit_req_crypto_context req_cryptoctx,
pkinit_identity_crypto_context id_cryptoctx,
NSSCMSMessage *msg,
SECOidTag digest,
enum sdcc_include_certchain certchain_mode,
enum sdcc_include_signed_attrs add_signedattrs,
NSSCMSSignedData **signed_data_out)
{
NSSCMSSignedData *sdata;
NSSCMSSignerInfo *signer;
NSSCMSCertChainMode chainmode;
/* Create a signed-data object. */
sdata = NSS_CMSSignedData_Create(msg);
if (sdata == NULL)
return ENOMEM;
if (id_cryptoctx->id_cert != NULL) {
/* Create a signer and add it to the signed-data pointer. */
signer = NSS_CMSSignerInfo_Create(msg, id_cryptoctx->id_cert, digest);
if (signer == NULL)
return ENOMEM;
chainmode = (certchain_mode == signeddata_common_create_with_chain) ?
NSSCMSCM_CertChain :
NSSCMSCM_CertOnly;
if (NSS_CMSSignerInfo_IncludeCerts(signer,
chainmode,
certUsageAnyCA) != SECSuccess) {
pkiDebug("%s: error setting IncludeCerts\n", __FUNCTION__);
return ENOMEM;
}
if (NSS_CMSSignedData_AddSignerInfo(sdata, signer) != SECSuccess)
return ENOMEM;
if (add_signedattrs == signeddata_common_create_with_signed_attrs) {
/* The presence of any signed attribute means the digest
* becomes a signed attribute, too. */
if (NSS_CMSSignerInfo_AddSigningTime(signer,
PR_Now()) != SECSuccess) {
pkiDebug("%s: error adding signing time\n", __FUNCTION__);
return ENOMEM;
}
}
}
*signed_data_out = sdata;
return 0;
}
/* Create signed-then-enveloped data. */
krb5_error_code
cms_envelopeddata_create(krb5_context context,
pkinit_plg_crypto_context plg_cryptoctx,
pkinit_req_crypto_context req_cryptoctx,
pkinit_identity_crypto_context id_cryptoctx,
krb5_preauthtype pa_type,
int include_certchain,
unsigned char *key_pack,
unsigned int key_pack_len,
unsigned char **envel_data,
unsigned int *envel_data_len)
{
NSSCMSMessage *msg;
NSSCMSContentInfo *info;
NSSCMSEnvelopedData *env;
NSSCMSRecipientInfo *recipient;
NSSCMSSignedData *sdata;
PLArenaPool *pool;
SECOidTag encapsulated_tag, digest;
SECItem plain, encoded;
enum sdcc_include_signed_attrs add_signed_attrs;
switch (pa_type) {
case KRB5_PADATA_PK_AS_REQ_OLD:
case KRB5_PADATA_PK_AS_REP_OLD:
digest = SEC_OID_MD5;
add_signed_attrs = signeddata_common_create_omit_signed_attrs;
encapsulated_tag = get_pkinit_data_rkey_data_tag();
break;
case KRB5_PADATA_PK_AS_REQ:
case KRB5_PADATA_PK_AS_REP:
digest = SEC_OID_SHA1;
add_signed_attrs = signeddata_common_create_with_signed_attrs;
encapsulated_tag = get_pkinit_data_rkey_data_tag();
break;
default:
return ENOSYS;
break;
}
if (id_cryptoctx->id_cert == NULL) {
pkiDebug("%s: no signer identity\n", __FUNCTION__);
return ENOENT;
}
if (req_cryptoctx->peer_cert == NULL) {
pkiDebug("%s: no recipient identity\n", __FUNCTION__);
return ENOENT;
}
pool = PORT_NewArena(sizeof(double));
if (pool == NULL) {
return ENOMEM;
}
/* Create the containing message. */
msg = NSS_CMSMessage_Create(pool);
if (msg == NULL) {
PORT_FreeArena(pool, PR_TRUE);
return ENOMEM;
}
/* Create an enveloped-data pointer and set it as the message's
* contents. */
env = NSS_CMSEnvelopedData_Create(msg, SEC_OID_DES_EDE3_CBC, 0);
if (env == NULL) {
pkiDebug("%s: error creating enveloped-data\n", __FUNCTION__);
NSS_CMSMessage_Destroy(msg);
PORT_FreeArena(pool, PR_TRUE);
return ENOMEM;
}
info = NSS_CMSMessage_GetContentInfo(msg);
if (info == NULL) {
NSS_CMSMessage_Destroy(msg);
PORT_FreeArena(pool, PR_TRUE);
return ENOMEM;
}
if (NSS_CMSContentInfo_SetContent_EnvelopedData(msg, info,
env) != SECSuccess) {
pkiDebug("%s: error setting enveloped-data content\n", __FUNCTION__);
NSS_CMSMessage_Destroy(msg);
PORT_FreeArena(pool, PR_TRUE);
return ENOMEM;
}
/* Create a recipient and add it to the enveloped-data pointer. */
recipient = NSS_CMSRecipientInfo_Create(msg, req_cryptoctx->peer_cert);
if (recipient == NULL) {
pkiDebug("%s: error creating recipient-info\n", __FUNCTION__);
NSS_CMSMessage_Destroy(msg);
PORT_FreeArena(pool, PR_TRUE);
return ENOMEM;
}
if (NSS_CMSEnvelopedData_AddRecipient(env, recipient) != SECSuccess) {
pkiDebug("%s: error adding recipient\n", __FUNCTION__);
NSS_CMSMessage_Destroy(msg);
PORT_FreeArena(pool, PR_TRUE);
return ENOMEM;
}
/* Create a signed-data pointer and set it as the enveloped-data's
* contents. */
info = NSS_CMSEnvelopedData_GetContentInfo(env);
if (info == NULL) {
NSS_CMSMessage_Destroy(msg);
PORT_FreeArena(pool, PR_TRUE);
return ENOMEM;
}
sdata = NULL;
if ((crypto_signeddata_common_create(context,
plg_cryptoctx,
req_cryptoctx,
id_cryptoctx,
msg,
digest,
include_certchain ?
signeddata_common_create_with_chain :
signeddata_common_create_omit_chain,
add_signed_attrs,
&sdata) != 0) || (sdata == NULL)) {
NSS_CMSMessage_Destroy(msg);
PORT_FreeArena(pool, PR_TRUE);
return ENOMEM;
}
if (NSS_CMSContentInfo_SetContent_SignedData(msg, info,
sdata) != SECSuccess) {
pkiDebug("%s: error setting signed-data content\n", __FUNCTION__);
NSS_CMSMessage_Destroy(msg);
PORT_FreeArena(pool, PR_TRUE);
return ENOMEM;
}
/* Set the raw data as the contents for the signed-data. */
info = NSS_CMSSignedData_GetContentInfo(sdata);
if (info == NULL) {
NSS_CMSMessage_Destroy(msg);
PORT_FreeArena(pool, PR_TRUE);
return ENOMEM;
}
if (NSS_CMSContentInfo_SetContent(msg, info, encapsulated_tag,
NULL) != SECSuccess) {
pkiDebug("%s: error setting encapsulated content\n", __FUNCTION__);
NSS_CMSMessage_Destroy(msg);
PORT_FreeArena(pool, PR_TRUE);
return ENOMEM;
}
/* Encode and export. */
memset(&plain, 0, sizeof(plain));
plain.data = key_pack;
plain.len = key_pack_len;
memset(&encoded, 0, sizeof(encoded));
if (NSS_CMSDEREncode(msg, &plain, &encoded, pool) != SECSuccess) {
pkiDebug("%s: error encoding enveloped-data\n", __FUNCTION__);
NSS_CMSMessage_Destroy(msg);
PORT_FreeArena(pool, PR_TRUE);
return ENOMEM;
}
if (secitem_to_buf_len(&encoded, envel_data, envel_data_len) != 0) {
NSS_CMSMessage_Destroy(msg);
PORT_FreeArena(pool, PR_TRUE);
return ENOMEM;
}
#ifdef DEBUG_DER
derdump(*envel_data, *envel_data_len);
#endif
#ifdef DEBUG_CMS
cmsdump(*envel_data, *envel_data_len);
#endif
NSS_CMSMessage_Destroy(msg);
PORT_FreeArena(pool, PR_TRUE);
return 0;
}
/* Check if this cert is marked as a CA which is trusted to issue certs for
* the indicated usage. Return PR_TRUE if it is. */
static PRBool
crypto_is_cert_trusted(CERTCertificate *cert, SECCertUsage usage)
{
CERTCertTrust trust;
unsigned int ca_trust;
if (usage == certUsageSSLClient)
ca_trust = CERTDB_TRUSTED_CLIENT_CA;
else if (usage == certUsageSSLServer)
ca_trust = CERTDB_TRUSTED_CA;
else {
pkiDebug("%s: internal error: needed CA trust unknown\n", __FUNCTION__);
return PR_FALSE;
}
memset(&trust, 0, sizeof(trust));
if (CERT_GetCertTrust(cert, &trust) != SECSuccess) {
pkiDebug("%s: unable to find trust for \"%s\"\n", __FUNCTION__,
cert->subjectName);
return PR_FALSE;
}
if ((SEC_GET_TRUST_FLAGS(&trust, trustSSL) & ca_trust) != ca_trust) {
pkiDebug("%s: \"%s\" is not a trusted CA\n", __FUNCTION__,
cert->subjectName);
return PR_FALSE;
}
return PR_TRUE;
}
/* Check if this cert includes an AuthorityInfoAccess extension which points
* to an OCSP responder. Return PR_TRUE if it does. */
static PRBool
crypto_cert_has_ocsp_responder(CERTCertificate *cert)
{
CERTAuthInfoAccess **aia;
SECOidData *ocsp;
SECItem encoded_aia;
int i;
/* Look up the OID for "use an OCSP responder". */
ocsp = SECOID_FindOIDByTag(SEC_OID_PKIX_OCSP);
if (ocsp == NULL) {
pkiDebug("%s: internal error: OCSP not known\n", __FUNCTION__);
return PR_FALSE;
}
/* Find the AIA extension. */
memset(&encoded_aia, 0, sizeof(encoded_aia));
if (CERT_FindCertExtension(cert, SEC_OID_X509_AUTH_INFO_ACCESS,
&encoded_aia) != SECSuccess) {
pkiDebug("%s: no AuthorityInfoAccess extension for \"%s\"\n",
__FUNCTION__, cert->subjectName);
return PR_FALSE;
}
/* Decode the AIA extension. */
aia = CERT_DecodeAuthInfoAccessExtension(cert->arena, &encoded_aia);
if (aia == NULL) {
pkiDebug("%s: error parsing AuthorityInfoAccess for \"%s\"\n",
__FUNCTION__, cert->subjectName);
return PR_FALSE;
}
/* We're looking for at least one OCSP responder. */
for (i = 0; (aia[i] != NULL); i++)
if (SECITEM_ItemsAreEqual(&(aia[i]->method), &(ocsp->oid))) {
pkiDebug("%s: found OCSP responder for \"%s\"\n",
__FUNCTION__, cert->subjectName);
return PR_TRUE;
}
return PR_FALSE;
}
/* In the original implementation, the assumption has been that we'd use any
* CRLs, and if we were missing a CRL for the certificate or any point in its
* issuing chain, we'd raise a failure iff the require_crl_checking flag was
* set.
*
* This is not exactly how NSS does things. When checking the revocation
* status of a particular certificate, NSS will consult a cached copy of a CRL
* issued by the certificate's issuer if one's available. If the CRL shows
* that the certificate is revoked, it returns an error. If it succeeds,
* however, processing continues, and if the certificate contains an AIA
* extension which lists an OCSP responder, the library attempts to contact the
* responder to also give it a chance to tell us that the certificate has been
* revoked. We can control what happens if this connection attempt fails by
* calling CERT_SetOCSPFailureMode().
*
* We attempt to compensate for this difference in behavior by walking the
* issuing chain ourselves, ensuring that for the certificate and all of its
* issuers, that either we have a CRL on-hand for its issuer, or if OCSP
* checking is allowed, that the certificate contains the location of an OCSP
* responder. We stop only when we reach a trusted CA certificate, as NSS
* does. */
static int
crypto_check_for_revocation_information(CERTCertificate *cert,
CERTCertDBHandle *certdb,
PRBool allow_ocsp_checking,
SECCertUsage usage)
{
CERTCertificate *issuer;
CERTSignedCrl *crl;
issuer = CERT_FindCertIssuer(cert, PR_Now(), usage);
while (issuer != NULL) {
/* Do we have a CRL for this cert's issuer? */
crl = SEC_FindCrlByName(certdb, &cert->derIssuer, SEC_CRL_TYPE);
if (crl != NULL) {
pkiDebug("%s: have CRL for \"%s\"\n", __FUNCTION__,
cert->issuerName);
} else {
SEC_DestroyCrl(crl);
if (allow_ocsp_checking) {
/* Check if the cert points to an OCSP responder. */
if (!crypto_cert_has_ocsp_responder(cert)) {
/* No CRL, no OCSP responder. */
pkiDebug("%s: no OCSP responder for \"%s\"\n", __FUNCTION__,
cert->subjectName);
return -1;
}
} else {
/* No CRL, and OCSP not allowed. */
pkiDebug("%s: no CRL for issuer \"%s\"\n", __FUNCTION__,
cert->issuerName);
return -1;
}
}
/* Check if this issuer is a trusted CA. If it is, we're done. */
if (crypto_is_cert_trusted(issuer, usage)) {
pkiDebug("%s: \"%s\" is a trusted CA\n", __FUNCTION__,
issuer->subjectName);
CERT_DestroyCertificate(issuer);
return 0;
}
/* Move on to the next link in the chain. */
cert = issuer;
issuer = CERT_FindCertIssuer(cert, PR_Now(), usage);
if (issuer == NULL) {
pkiDebug("%s: unable to find issuer for \"%s\"\n", __FUNCTION__,
cert->subjectName);
/* Don't leak the reference to the last intermediate. */
CERT_DestroyCertificate(cert);
return -1;
}
if (SECITEM_ItemsAreEqual(&cert->derCert, &issuer->derCert)) {
pkiDebug("%s: \"%s\" is self-signed, but not trusted\n",
__FUNCTION__, cert->subjectName);
/* Don't leak the references to the self-signed cert. */
CERT_DestroyCertificate(issuer);
CERT_DestroyCertificate(cert);
return -1;
}
/* Don't leak the reference to the just-traversed intermediate. */
CERT_DestroyCertificate(cert);
cert = NULL;
}
return -1;
}
/* Verify that we have a signed-data content info, that it has one signer, that
* the signer can be trusted, and then check the type of the encapsulated
* content and return that content. */
static krb5_error_code
crypto_signeddata_common_verify(krb5_context context,
pkinit_plg_crypto_context plg_cryptoctx,
pkinit_req_crypto_context req_cryptoctx,
pkinit_identity_crypto_context id_cryptoctx,
int require_crl_checking,
NSSCMSContentInfo *cinfo,
CERTCertDBHandle *certdb,
SECCertUsage usage,
SECOidTag expected_type,
SECOidTag expected_type2,
PLArenaPool *pool,
int cms_msg_type,
SECItem **plain_out,
int *is_signed_out)
{
NSSCMSSignedData *sdata;
NSSCMSSignerInfo *signer;
NSSCMSMessage *ecmsg;
NSSCMSContentInfo *ecinfo;
CERTCertificate *cert;
SECOidTag encapsulated_tag;
SEC_OcspFailureMode ocsp_failure_mode;
SECOidData *expected, *received;
SECStatus status;
SECItem *edata;
int n_signers;
PRBool allow_ocsp_checking = PR_TRUE;
*is_signed_out = 0;
/* Handle cases where we're passed data containing signed-data. */
if (NSS_CMSContentInfo_GetContentTypeTag(cinfo) == SEC_OID_PKCS7_DATA) {
/* Look at the payload data. */
edata = NSS_CMSContentInfo_GetContent(cinfo);
if (edata == NULL) {
pkiDebug("%s: no plain-data content\n", __FUNCTION__);
return ENOMEM;
}
/* See if it's content-info. */
ecmsg = NSS_CMSMessage_CreateFromDER(edata,
NULL, NULL,
crypto_pwcb,
crypto_pwcb_prep(id_cryptoctx,
NULL, context),
NULL, NULL);
if (ecmsg == NULL) {
pkiDebug("%s: plain-data not parsable\n", __FUNCTION__);
return ENOMEM;
}
/* Check if it actually contains signed-data. */
ecinfo = NSS_CMSMessage_GetContentInfo(ecmsg);
if (ecinfo == NULL) {
pkiDebug("%s: plain-data has no cinfo\n", __FUNCTION__);
NSS_CMSMessage_Destroy(ecmsg);
return ENOMEM;
}
if (NSS_CMSContentInfo_GetContentTypeTag(ecinfo) !=
SEC_OID_PKCS7_SIGNED_DATA) {
pkiDebug("%s: plain-data is not sdata\n", __FUNCTION__);
NSS_CMSMessage_Destroy(ecmsg);
return EINVAL;
}
pkiDebug("%s: parsed plain-data (length=%ld) as signed-data\n",
__FUNCTION__, (long) edata->len);
cinfo = ecinfo;
} else
/* Okay, it's a normal signed-data blob. */
ecmsg = NULL;
/* Check that we have signed data, that it has exactly one signature,
* and fish out the signer information. */
if (NSS_CMSContentInfo_GetContentTypeTag(cinfo) !=
SEC_OID_PKCS7_SIGNED_DATA) {
pkiDebug("%s: content type mismatch\n", __FUNCTION__);
if (ecmsg != NULL)
NSS_CMSMessage_Destroy(ecmsg);
return EINVAL;
}
sdata = NSS_CMSContentInfo_GetContent(cinfo);
if (sdata == NULL) {
pkiDebug("%s: decoding error? content-info was NULL\n", __FUNCTION__);
if (ecmsg != NULL)
NSS_CMSMessage_Destroy(ecmsg);
return ENOENT;
}
n_signers = NSS_CMSSignedData_SignerInfoCount(sdata);
if (n_signers > 1) {
pkiDebug("%s: wrong number of signers (%d, not 0 or 1)\n",
__FUNCTION__, n_signers);
if (ecmsg != NULL)
NSS_CMSMessage_Destroy(ecmsg);
return ENOENT;
}
if (n_signers < 1)
signer = NULL;
else {
/* Import the bundle's certs and locate the signerInfo. */
if (NSS_CMSSignedData_ImportCerts(sdata, certdb, usage,
PR_FALSE) != SECSuccess) {
pkiDebug("%s: error importing signer certs\n", __FUNCTION__);
if (ecmsg != NULL)
NSS_CMSMessage_Destroy(ecmsg);
return ENOENT;
}
signer = NSS_CMSSignedData_GetSignerInfo(sdata, 0);
if (signer == NULL) {
pkiDebug("%s: no signers?\n", __FUNCTION__);
if (ecmsg != NULL)
NSS_CMSMessage_Destroy(ecmsg);
return ENOENT;
}
if (!NSS_CMSSignedData_HasDigests(sdata)) {
pkiDebug("%s: no digests?\n", __FUNCTION__);
if (ecmsg != NULL)
NSS_CMSMessage_Destroy(ecmsg);
return ENOENT;
}
if (require_crl_checking && (signer->cert != NULL))
if (crypto_check_for_revocation_information(signer->cert, certdb,
allow_ocsp_checking,
usage) != 0) {
if (ecmsg != NULL)
NSS_CMSMessage_Destroy(ecmsg);
return KRB5KDC_ERR_REVOCATION_STATUS_UNAVAILABLE;
}
if (allow_ocsp_checking) {
status = CERT_EnableOCSPChecking(certdb);
if (status != SECSuccess) {
pkiDebug("%s: error enabling OCSP: %s\n", __FUNCTION__,
PR_ErrorToString(status == SECFailure ?
PORT_GetError() : status,
PR_LANGUAGE_I_DEFAULT));
if (ecmsg != NULL)
NSS_CMSMessage_Destroy(ecmsg);
return ENOMEM;
}
ocsp_failure_mode = require_crl_checking ?
ocspMode_FailureIsVerificationFailure :
ocspMode_FailureIsNotAVerificationFailure;
status = CERT_SetOCSPFailureMode(ocsp_failure_mode);
if (status != SECSuccess) {
pkiDebug("%s: error setting OCSP failure mode: %s\n",
__FUNCTION__,
PR_ErrorToString(status == SECFailure ?
PORT_GetError() : status,
PR_LANGUAGE_I_DEFAULT));
if (ecmsg != NULL)
NSS_CMSMessage_Destroy(ecmsg);
return ENOMEM;
}
} else {
status = CERT_DisableOCSPChecking(certdb);
if ((status != SECSuccess) &&
(PORT_GetError() != SEC_ERROR_OCSP_NOT_ENABLED)) {
pkiDebug("%s: error disabling OCSP: %s\n", __FUNCTION__,
PR_ErrorToString(status == SECFailure ?
PORT_GetError() : status,
PR_LANGUAGE_I_DEFAULT));
if (ecmsg != NULL)
NSS_CMSMessage_Destroy(ecmsg);
return ENOMEM;
}
}
status = NSS_CMSSignedData_VerifySignerInfo(sdata, 0, certdb, usage);
if (status != SECSuccess) {
pkiDebug("%s: signer verify failed: %s\n", __FUNCTION__,
PR_ErrorToString(status == SECFailure ?
PORT_GetError() : status,
PR_LANGUAGE_I_DEFAULT));
if (ecmsg != NULL)
NSS_CMSMessage_Destroy(ecmsg);
switch (cms_msg_type) {
case CMS_SIGN_DRAFT9:
case CMS_SIGN_CLIENT:
switch (PORT_GetError()) {
case SEC_ERROR_REVOKED_CERTIFICATE:
return KRB5KDC_ERR_REVOKED_CERTIFICATE;
case SEC_ERROR_UNKNOWN_ISSUER:
return KRB5KDC_ERR_CANT_VERIFY_CERTIFICATE;
default:
return KRB5KDC_ERR_CLIENT_NOT_TRUSTED;
}
break;
case CMS_SIGN_SERVER:
case CMS_ENVEL_SERVER:
switch (PORT_GetError()) {
case SEC_ERROR_REVOKED_CERTIFICATE:
return KRB5KDC_ERR_REVOKED_CERTIFICATE;
case SEC_ERROR_UNKNOWN_ISSUER:
return KRB5KDC_ERR_CANT_VERIFY_CERTIFICATE;
default:
return KRB5KDC_ERR_KDC_NOT_TRUSTED;
}
break;
default:
return ENOMEM;
}
}
pkiDebug("%s: signer verify passed\n", __FUNCTION__);
*is_signed_out = 1;
}
/* Pull out the payload. */
ecinfo = NSS_CMSSignedData_GetContentInfo(sdata);
if (ecinfo == NULL) {
pkiDebug("%s: error getting encapsulated content\n", __FUNCTION__);
if (ecmsg != NULL)
NSS_CMSMessage_Destroy(ecmsg);
return ENOMEM;
}
encapsulated_tag = NSS_CMSContentInfo_GetContentTypeTag(ecinfo);
if ((encapsulated_tag != expected_type) &&
((expected_type2 == SEC_OID_UNKNOWN) ||
(encapsulated_tag != expected_type2))) {
pkiDebug("%s: wrong encapsulated content type\n", __FUNCTION__);
expected = SECOID_FindOIDByTag(expected_type);
if (encapsulated_tag != SEC_OID_UNKNOWN)
received = SECOID_FindOIDByTag(encapsulated_tag);
else
received = NULL;
if (expected != NULL) {
if (received != NULL) {
pkiDebug("%s: was expecting \"%s\"(%d), but got \"%s\"(%d)\n",
__FUNCTION__,
expected->desc, expected->offset,
received->desc, received->offset);
} else {
pkiDebug("%s: was expecting \"%s\"(%d), "
"but got unrecognized type (%d)\n",
__FUNCTION__,
expected->desc, expected->offset, encapsulated_tag);
}
}
if (ecmsg != NULL)
NSS_CMSMessage_Destroy(ecmsg);
return EINVAL;
}
*plain_out = NSS_CMSContentInfo_GetContent(ecinfo);
if ((*plain_out != NULL) && ((*plain_out)->len == 0))
pkiDebug("%s: warning: encapsulated content appears empty\n",
__FUNCTION__);
if (signer != NULL) {
/* Save the peer cert -- we'll need it later. */
pkiDebug("%s: saving peer certificate\n", __FUNCTION__);
if (req_cryptoctx->peer_cert != NULL)
CERT_DestroyCertificate(req_cryptoctx->peer_cert);
cert = NSS_CMSSignerInfo_GetSigningCertificate(signer, certdb);
req_cryptoctx->peer_cert = CERT_DupCertificate(cert);
}
if (ecmsg != NULL) {
*plain_out = SECITEM_ArenaDupItem(pool, *plain_out);
NSS_CMSMessage_Destroy(ecmsg);
}
return 0;
}
/* Verify signed-then-enveloped data, and return the data that was signed. */
krb5_error_code
cms_envelopeddata_verify(krb5_context context,
pkinit_plg_crypto_context plg_cryptoctx,
pkinit_req_crypto_context req_cryptoctx,
pkinit_identity_crypto_context id_cryptoctx,
krb5_preauthtype pa_type,
int require_crl_checking,
unsigned char *envel_data,
unsigned int envel_data_len,
unsigned char **signed_data,
unsigned int *signed_data_len)
{
NSSCMSMessage *msg;
NSSCMSContentInfo *info;
NSSCMSEnvelopedData *env;
CERTCertDBHandle *certdb;
PLArenaPool *pool;
SECItem *plain, encoded;
SECCertUsage usage;
SECOidTag expected_tag, expected_tag2;
int is_signed, ret;
pool = PORT_NewArena(sizeof(double));
if (pool == NULL)
return ENOMEM;
certdb = CERT_GetDefaultCertDB();
/* Decode the message. */
#ifdef DEBUG_DER
derdump(envel_data, envel_data_len);
#endif
encoded.data = envel_data;
encoded.len = envel_data_len;
msg = NSS_CMSMessage_CreateFromDER(&encoded,
NULL, NULL,
crypto_pwcb,
crypto_pwcb_prep(id_cryptoctx,
NULL, context),
NULL, NULL);
if (msg == NULL)
return ENOMEM;
/* Make sure it's enveloped-data. */
info = NSS_CMSMessage_GetContentInfo(msg);
if (info == NULL) {
NSS_CMSMessage_Destroy(msg);
PORT_FreeArena(pool, PR_TRUE);
return ENOMEM;
}
if (NSS_CMSContentInfo_GetContentTypeTag(info) !=
SEC_OID_PKCS7_ENVELOPED_DATA) {
NSS_CMSMessage_Destroy(msg);
PORT_FreeArena(pool, PR_TRUE);
return EINVAL;
}
/* Okay, it's enveloped-data. */
env = NSS_CMSContentInfo_GetContent(info);
/* Pull out the encapsulated content. It should be signed-data. */
info = NSS_CMSEnvelopedData_GetContentInfo(env);
if (info == NULL) {
NSS_CMSMessage_Destroy(msg);
PORT_FreeArena(pool, PR_TRUE);
return ENOMEM;
}
/* Pull out the signed data and verify it. */
expected_tag = get_pkinit_data_rkey_data_tag();
expected_tag2 = SEC_OID_PKCS7_DATA;
usage = certUsageSSLServer;
plain = NULL;
is_signed = 0;
ret = crypto_signeddata_common_verify(context,
plg_cryptoctx,
req_cryptoctx,
id_cryptoctx,
require_crl_checking,
info,
certdb,
usage,
expected_tag,
expected_tag2,
pool,
CMS_ENVEL_SERVER,
&plain,
&is_signed);
if ((ret != 0) || (plain == NULL) || !is_signed) {
NSS_CMSMessage_Destroy(msg);
PORT_FreeArena(pool, PR_TRUE);
return ret ? ret : ENOMEM;
}
/* Export the payload. */
if (secitem_to_buf_len(plain, signed_data, signed_data_len) != 0) {
NSS_CMSMessage_Destroy(msg);
PORT_FreeArena(pool, PR_TRUE);
return ENOMEM;
}
NSS_CMSMessage_Destroy(msg);
PORT_FreeArena(pool, PR_TRUE);
return 0;
}
krb5_error_code
cms_signeddata_create(krb5_context context,
pkinit_plg_crypto_context plg_cryptoctx,
pkinit_req_crypto_context req_cryptoctx,
pkinit_identity_crypto_context id_cryptoctx,
int cms_msg_type,
int include_certchain,
unsigned char *payload,
unsigned int payload_len,
unsigned char **signed_data,
unsigned int *signed_data_len)
{
NSSCMSMessage *msg;
NSSCMSContentInfo *info;
NSSCMSSignedData *sdata;
PLArenaPool *pool;
SECItem plain, encoded;
SECOidTag digest, encapsulated_tag;
enum sdcc_include_signed_attrs add_signed_attrs;
switch (cms_msg_type) {
case CMS_SIGN_DRAFT9:
digest = SEC_OID_MD5;
add_signed_attrs = signeddata_common_create_omit_signed_attrs;
encapsulated_tag = get_pkinit_data_auth_data9_tag();
break;
case CMS_SIGN_CLIENT:
digest = SEC_OID_SHA1;
add_signed_attrs = signeddata_common_create_with_signed_attrs;
encapsulated_tag = get_pkinit_data_auth_data_tag();
break;
case CMS_SIGN_SERVER:
digest = SEC_OID_SHA1;
add_signed_attrs = signeddata_common_create_with_signed_attrs;
encapsulated_tag = get_pkinit_data_dhkey_data_tag();
break;
case CMS_ENVEL_SERVER:
default:
return ENOSYS;
break;
}
pool = PORT_NewArena(sizeof(double));
if (pool == NULL)
return ENOMEM;
/* Create the containing message. */
msg = NSS_CMSMessage_Create(pool);
if (msg == NULL) {
PORT_FreeArena(pool, PR_TRUE);
return ENOMEM;
}
/* Create a signed-data pointer and set it as the message's
* contents. */
info = NSS_CMSMessage_GetContentInfo(msg);
if (info == NULL) {
NSS_CMSMessage_Destroy(msg);
PORT_FreeArena(pool, PR_TRUE);
return ENOMEM;
}
sdata = NULL;
if ((crypto_signeddata_common_create(context,
plg_cryptoctx,
req_cryptoctx,
id_cryptoctx,
msg,
digest,
include_certchain ?
signeddata_common_create_with_chain :
signeddata_common_create_omit_chain,
add_signed_attrs,
&sdata) != 0) || (sdata == NULL)) {
NSS_CMSMessage_Destroy(msg);
PORT_FreeArena(pool, PR_TRUE);
return ENOMEM;
}
if (NSS_CMSContentInfo_SetContent_SignedData(msg, info,
sdata) != SECSuccess) {
pkiDebug("%s: error setting signed-data content\n", __FUNCTION__);
NSS_CMSMessage_Destroy(msg);
PORT_FreeArena(pool, PR_TRUE);
return ENOMEM;
}
/* Set the data as the contents of the signed-data. */
info = NSS_CMSSignedData_GetContentInfo(sdata);
if (info == NULL) {
NSS_CMSMessage_Destroy(msg);
PORT_FreeArena(pool, PR_TRUE);
return ENOMEM;
}
if (NSS_CMSContentInfo_SetContent(msg, info, encapsulated_tag,
NULL) != SECSuccess) {
pkiDebug("%s: error setting encapsulated content type\n",
__FUNCTION__);
NSS_CMSMessage_Destroy(msg);
PORT_FreeArena(pool, PR_TRUE);
return ENOMEM;
}
/* Encode and export. */
memset(&plain, 0, sizeof(plain));
plain.data = payload;
plain.len = payload_len;
memset(&encoded, 0, sizeof(encoded));
if (NSS_CMSDEREncode(msg, &plain, &encoded, pool) != SECSuccess) {
NSS_CMSMessage_Destroy(msg);
PORT_FreeArena(pool, PR_TRUE);
pkiDebug("%s: error encoding signed-data: %s\n", __FUNCTION__,
PORT_ErrorToName(PORT_GetError()));
return ENOMEM;
}
if (secitem_to_buf_len(&encoded, signed_data, signed_data_len) != 0) {
NSS_CMSMessage_Destroy(msg);
PORT_FreeArena(pool, PR_TRUE);
return ENOMEM;
}
#ifdef DEBUG_DER
derdump(*signed_data, *signed_data_len);
#endif
#ifdef DEBUG_CMS
cmsdump(*signed_data, *signed_data_len);
#endif
NSS_CMSMessage_Destroy(msg);
PORT_FreeArena(pool, PR_TRUE);
return 0;
}
krb5_error_code
cms_signeddata_verify(krb5_context context,
pkinit_plg_crypto_context plg_cryptoctx,
pkinit_req_crypto_context req_cryptoctx,
pkinit_identity_crypto_context id_cryptoctx,
int cms_msg_type,
int require_crl_checking,
unsigned char *signed_data,
unsigned int signed_data_len,
unsigned char **payload,
unsigned int *payload_len,
unsigned char **authz_data,
unsigned int *authz_data_len,
int *is_signed)
{
NSSCMSMessage *msg;
NSSCMSContentInfo *info;
CERTCertDBHandle *certdb;
SECCertUsage usage;
SECOidTag expected_tag, expected_tag2;
PLArenaPool *pool;
SECItem *plain, encoded;
struct content_info simple_content_info;
int was_signed, ret;
switch (cms_msg_type) {
case CMS_SIGN_DRAFT9:
usage = certUsageSSLClient;
expected_tag = get_pkinit_data_auth_data9_tag();
break;
case CMS_SIGN_CLIENT:
usage = certUsageSSLClient;
expected_tag = get_pkinit_data_auth_data_tag();
break;
case CMS_SIGN_SERVER:
usage = certUsageSSLServer;
expected_tag = get_pkinit_data_dhkey_data_tag();
break;
case CMS_ENVEL_SERVER:
default:
return ENOSYS;
break;
}
expected_tag2 = SEC_OID_UNKNOWN;
pool = PORT_NewArena(sizeof(double));
if (pool == NULL)
return ENOMEM;
certdb = CERT_GetDefaultCertDB();
#ifdef DEBUG_DER
derdump(signed_data, signed_data_len);
#endif
memset(&encoded, 0, sizeof(encoded));
encoded.data = signed_data;
encoded.len = signed_data_len;
/* Take a quick look at what it claims to be. */
memset(&simple_content_info, 0, sizeof(simple_content_info));
if (SEC_ASN1DecodeItem(pool, &simple_content_info,
content_info_template, &encoded) == SECSuccess)
/* If it's unsigned data of the right type... */
if (SECOID_FindOIDTag(&simple_content_info.content_type) ==
expected_tag) {
/* Pull out the payload -- it's not wrapped in a
* SignedData. */
pkiDebug("%s: data is not signed\n", __FUNCTION__);
if (is_signed != NULL)
*is_signed = 0;
if (secitem_to_buf_len(&simple_content_info.content,
payload, payload_len) != 0) {
PORT_FreeArena(pool, PR_TRUE);
return ENOMEM;
}
return 0;
}
/* Decode the message. */
msg = NSS_CMSMessage_CreateFromDER(&encoded,
NULL, NULL,
crypto_pwcb,
crypto_pwcb_prep(id_cryptoctx,
NULL, context),
NULL, NULL);
if (msg == NULL)
return ENOMEM;
/* Double-check that it's signed. */
info = NSS_CMSMessage_GetContentInfo(msg);
if (info == NULL) {
NSS_CMSMessage_Destroy(msg);
PORT_FreeArena(pool, PR_TRUE);
return ENOMEM;
}
switch (NSS_CMSContentInfo_GetContentTypeTag(info)) {
case SEC_OID_PKCS7_SIGNED_DATA:
/* It's signed: try to verify the signature. */
pkiDebug("%s: data is probably signed, checking\n", __FUNCTION__);
plain = NULL;
was_signed = 0;
ret = crypto_signeddata_common_verify(context,
plg_cryptoctx,
req_cryptoctx,
id_cryptoctx,
require_crl_checking,
info,
certdb,
usage,
expected_tag,
expected_tag2,
pool,
cms_msg_type,
&plain,
&was_signed);
if ((ret != 0) || (plain == NULL)) {
NSS_CMSMessage_Destroy(msg);
PORT_FreeArena(pool, PR_TRUE);
return ret ? ret : ENOMEM;
}
if (is_signed != NULL)
*is_signed = was_signed;
break;
case SEC_OID_PKCS7_DATA:
/* It's not signed: try to pull out the payload. */
pkiDebug("%s: data is not signed\n", __FUNCTION__);
if (is_signed != NULL)
*is_signed = 0;
plain = NSS_CMSContentInfo_GetContent(info);
break;
default:
NSS_CMSMessage_Destroy(msg);
PORT_FreeArena(pool, PR_TRUE);
return ENOMEM;
}
/* Export the payload. */
if ((plain == NULL) ||
(secitem_to_buf_len(plain, payload, payload_len) != 0)) {
NSS_CMSMessage_Destroy(msg);
PORT_FreeArena(pool, PR_TRUE);
return ENOMEM;
}
NSS_CMSMessage_Destroy(msg);
PORT_FreeArena(pool, PR_TRUE);
return 0;
}
/*
* Add an item to the pkinit_identity_crypto_context's list of deferred
* identities.
*/
krb5_error_code
crypto_set_deferred_id(krb5_context context,
pkinit_identity_crypto_context id_cryptoctx,
const char *identity, const char *password)
{
unsigned long ck_flags;
ck_flags = pkinit_get_deferred_id_flags(id_cryptoctx->deferred_ids,
identity);
return pkinit_set_deferred_id(&id_cryptoctx->deferred_ids,
identity, ck_flags, password);
}
/*
* Retrieve a read-only copy of the pkinit_identity_crypto_context's list of
* deferred identities, sure to be valid only until the next time someone calls
* either pkinit_set_deferred_id() or crypto_set_deferred_id().
*/
const pkinit_deferred_id *
crypto_get_deferred_ids(krb5_context context,
pkinit_identity_crypto_context id_cryptoctx)
{
pkinit_deferred_id *deferred;
const pkinit_deferred_id *ret;
deferred = id_cryptoctx->deferred_ids;
ret = (const pkinit_deferred_id *)deferred;
return ret;
}
|
619594.c | /*
* routines to convert an array into its MTF position values
*
*/
#include <stdlib.h>
#include <crblib/inc.h>
#include <crblib/memutil.h>
//protos:
struct MTFInfo * MTF_Init(long NumSymbols);
void MTF_CleanUp(struct MTFInfo * MTFI);
int MTF_Translate(struct MTFInfo * MTFI,int val); /* -1 error */
int MTF_Untranslate(struct MTFInfo * MTFI,int pos); /* -1 error */
bool MTF_TransformArray(struct MTFInfo * MTFI,ubyte * Array,long ArrayLen);
bool MTF_UntransformArray(struct MTFInfo * MTFI,ubyte * Array,long ArrayLen);
//structs:
struct MTFNode
{
struct MTFNode * Next;
struct MTFNode * Prev;
long Char;
};
struct MTFInfo
{
struct MTFNode * Head;
struct MTFNode * NodeBlock;
long NumSymbols;
};
/*
* MTF Transform stuff
*
*/
struct MTFInfo * MTF_Init(long NumSymbols)
{
struct MTFInfo * MTFI;
struct MTFNode *CurNode;
long i;
if ( (MTFI = AllocMem(sizeof(struct MTFInfo),MEMF_ANY|MEMF_CLEAR)) == NULL )
return(NULL);
if ( (MTFI->NodeBlock = AllocMem(sizeof(struct MTFNode)*NumSymbols,MEMF_ANY)) == NULL )
{
FreeMem(MTFI,sizeof(struct MTFInfo));
return(NULL);
}
MTFI->NumSymbols = NumSymbols;
CurNode = MTFI->Head = MTFI->NodeBlock;
CurNode->Prev = NULL;
for(i=0;i<(NumSymbols-1);i++)
{
CurNode->Next = MTFI->NodeBlock + i + 1;
CurNode->Next->Prev = CurNode;
CurNode->Char = i;
CurNode = CurNode->Next;
}
CurNode->Next = NULL;
CurNode->Char = NumSymbols - 1;
return(MTFI);
}
void MTF_CleanUp(struct MTFInfo * MTFI)
{
if ( MTFI )
{
SmartFree(MTFI->NodeBlock,sizeof(struct MTFNode)*(MTFI->NumSymbols));
FreeMem(MTFI,sizeof(struct MTFInfo));
}
}
int MTF_Translate(struct MTFInfo * MTFI,int val) /* -1 error */
{
int pos;
struct MTFNode * N;
pos = 0;
N = MTFI->Head;
for(;;)
{
if ( N->Char == val )
break;
pos++;
N = N->Next;
if ( N == NULL )
return(-1);
}
if ( N->Prev )
{
N->Prev->Next = N->Next;
if ( N->Next ) N->Next->Prev = N->Prev;
N->Next = MTFI->Head;
MTFI->Head = N;
N->Next->Prev = N;
N->Prev = NULL;
}
return(pos);
}
int MTF_Untranslate(struct MTFInfo * MTFI,int pos)
{
int val;
struct MTFNode * N;
N = MTFI->Head;
while(pos>0)
{
pos--;
N = N->Next;
if ( N == NULL )
return(-1);
}
val = N->Char;
if ( N->Prev )
{
N->Prev->Next = N->Next;
if ( N->Next ) N->Next->Prev = N->Prev;
N->Next = MTFI->Head;
MTFI->Head = N;
N->Next->Prev = N;
N->Prev = NULL;
}
return(val);
}
bool MTF_TransformArray(struct MTFInfo * MTFI,ubyte * Array,long ArrayLen)
{
int val;
while(ArrayLen--)
{
val = MTF_Translate(MTFI,*Array);
if ( val == -1 ) return(0);
*Array++ = val;
}
return(1);
}
bool MTF_UntransformArray(struct MTFInfo * MTFI,ubyte * Array,long ArrayLen)
{
int val;
while(ArrayLen--)
{
val = MTF_Untranslate(MTFI,*Array);
if ( val == -1 ) return(0);
*Array++ = val;
}
return(1);
}
|
279476.c | #include <assert.h>
#include <ccan/str/hex/hex.h>
#include <ccan/tal/str/str.h>
#include <common/dev_disconnect.h>
#include <common/status.h>
#include <stdio.h>
#include <wire/peer_wire.h>
#include <wire/wire_io.h>
/* AUTOGENERATED MOCKS START */
/* Generated stub for amount_asset_extract_value */
u8 *amount_asset_extract_value(const tal_t *ctx UNNEEDED, struct amount_asset *asset UNNEEDED)
{ fprintf(stderr, "amount_asset_extract_value called!\n"); abort(); }
/* Generated stub for amount_asset_is_main */
bool amount_asset_is_main(struct amount_asset *asset UNNEEDED)
{ fprintf(stderr, "amount_asset_is_main called!\n"); abort(); }
/* Generated stub for amount_asset_to_sat */
struct amount_sat amount_asset_to_sat(struct amount_asset *asset UNNEEDED)
{ fprintf(stderr, "amount_asset_to_sat called!\n"); abort(); }
/* Generated stub for amount_sat */
struct amount_sat amount_sat(u64 satoshis UNNEEDED)
{ fprintf(stderr, "amount_sat called!\n"); abort(); }
/* Generated stub for amount_sat_add */
bool amount_sat_add(struct amount_sat *val UNNEEDED,
struct amount_sat a UNNEEDED,
struct amount_sat b UNNEEDED)
{ fprintf(stderr, "amount_sat_add called!\n"); abort(); }
/* Generated stub for amount_sat_eq */
bool amount_sat_eq(struct amount_sat a UNNEEDED, struct amount_sat b UNNEEDED)
{ fprintf(stderr, "amount_sat_eq called!\n"); abort(); }
/* Generated stub for amount_sat_greater_eq */
bool amount_sat_greater_eq(struct amount_sat a UNNEEDED, struct amount_sat b UNNEEDED)
{ fprintf(stderr, "amount_sat_greater_eq called!\n"); abort(); }
/* Generated stub for amount_sat_sub */
bool amount_sat_sub(struct amount_sat *val UNNEEDED,
struct amount_sat a UNNEEDED,
struct amount_sat b UNNEEDED)
{ fprintf(stderr, "amount_sat_sub called!\n"); abort(); }
/* Generated stub for amount_sat_to_asset */
struct amount_asset amount_sat_to_asset(struct amount_sat *sat UNNEEDED, const u8 *asset UNNEEDED)
{ fprintf(stderr, "amount_sat_to_asset called!\n"); abort(); }
/* Generated stub for amount_tx_fee */
struct amount_sat amount_tx_fee(u32 fee_per_kw UNNEEDED, size_t weight UNNEEDED)
{ fprintf(stderr, "amount_tx_fee called!\n"); abort(); }
/* Generated stub for fromwire */
const u8 *fromwire(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, void *copy UNNEEDED, size_t n UNNEEDED)
{ fprintf(stderr, "fromwire called!\n"); abort(); }
/* Generated stub for fromwire_amount_sat */
struct amount_sat fromwire_amount_sat(const u8 **cursor UNNEEDED, size_t *max UNNEEDED)
{ fprintf(stderr, "fromwire_amount_sat called!\n"); abort(); }
/* Generated stub for fromwire_bool */
bool fromwire_bool(const u8 **cursor UNNEEDED, size_t *max UNNEEDED)
{ fprintf(stderr, "fromwire_bool called!\n"); abort(); }
/* Generated stub for fromwire_fail */
void *fromwire_fail(const u8 **cursor UNNEEDED, size_t *max UNNEEDED)
{ fprintf(stderr, "fromwire_fail called!\n"); abort(); }
/* Generated stub for fromwire_secp256k1_ecdsa_signature */
void fromwire_secp256k1_ecdsa_signature(const u8 **cursor UNNEEDED, size_t *max UNNEEDED,
secp256k1_ecdsa_signature *signature UNNEEDED)
{ fprintf(stderr, "fromwire_secp256k1_ecdsa_signature called!\n"); abort(); }
/* Generated stub for fromwire_sha256 */
void fromwire_sha256(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, struct sha256 *sha256 UNNEEDED)
{ fprintf(stderr, "fromwire_sha256 called!\n"); abort(); }
/* Generated stub for fromwire_tal_arrn */
u8 *fromwire_tal_arrn(const tal_t *ctx UNNEEDED,
const u8 **cursor UNNEEDED, size_t *max UNNEEDED, size_t num UNNEEDED)
{ fprintf(stderr, "fromwire_tal_arrn called!\n"); abort(); }
/* Generated stub for fromwire_u16 */
u16 fromwire_u16(const u8 **cursor UNNEEDED, size_t *max UNNEEDED)
{ fprintf(stderr, "fromwire_u16 called!\n"); abort(); }
/* Generated stub for fromwire_u32 */
u32 fromwire_u32(const u8 **cursor UNNEEDED, size_t *max UNNEEDED)
{ fprintf(stderr, "fromwire_u32 called!\n"); abort(); }
/* Generated stub for fromwire_u64 */
u64 fromwire_u64(const u8 **cursor UNNEEDED, size_t *max UNNEEDED)
{ fprintf(stderr, "fromwire_u64 called!\n"); abort(); }
/* Generated stub for fromwire_u8 */
u8 fromwire_u8(const u8 **cursor UNNEEDED, size_t *max UNNEEDED)
{ fprintf(stderr, "fromwire_u8 called!\n"); abort(); }
/* Generated stub for towire */
void towire(u8 **pptr UNNEEDED, const void *data UNNEEDED, size_t len UNNEEDED)
{ fprintf(stderr, "towire called!\n"); abort(); }
/* Generated stub for towire_amount_sat */
void towire_amount_sat(u8 **pptr UNNEEDED, const struct amount_sat sat UNNEEDED)
{ fprintf(stderr, "towire_amount_sat called!\n"); abort(); }
/* Generated stub for towire_bool */
void towire_bool(u8 **pptr UNNEEDED, bool v UNNEEDED)
{ fprintf(stderr, "towire_bool called!\n"); abort(); }
/* Generated stub for towire_secp256k1_ecdsa_signature */
void towire_secp256k1_ecdsa_signature(u8 **pptr UNNEEDED,
const secp256k1_ecdsa_signature *signature UNNEEDED)
{ fprintf(stderr, "towire_secp256k1_ecdsa_signature called!\n"); abort(); }
/* Generated stub for towire_sha256 */
void towire_sha256(u8 **pptr UNNEEDED, const struct sha256 *sha256 UNNEEDED)
{ fprintf(stderr, "towire_sha256 called!\n"); abort(); }
/* Generated stub for towire_u16 */
void towire_u16(u8 **pptr UNNEEDED, u16 v UNNEEDED)
{ fprintf(stderr, "towire_u16 called!\n"); abort(); }
/* Generated stub for towire_u32 */
void towire_u32(u8 **pptr UNNEEDED, u32 v UNNEEDED)
{ fprintf(stderr, "towire_u32 called!\n"); abort(); }
/* Generated stub for towire_u64 */
void towire_u64(u8 **pptr UNNEEDED, u64 v UNNEEDED)
{ fprintf(stderr, "towire_u64 called!\n"); abort(); }
/* Generated stub for towire_u8 */
void towire_u8(u8 **pptr UNNEEDED, u8 v UNNEEDED)
{ fprintf(stderr, "towire_u8 called!\n"); abort(); }
/* Generated stub for towire_u8_array */
void towire_u8_array(u8 **pptr UNNEEDED, const u8 *arr UNNEEDED, size_t num UNNEEDED)
{ fprintf(stderr, "towire_u8_array called!\n"); abort(); }
/* AUTOGENERATED MOCKS END */
void status_fmt(enum log_level level UNUSED,
const struct node_id *node_id UNUSED,
const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
vprintf(fmt, ap);
printf("\n");
va_end(ap);
}
#include "../cryptomsg.c"
static struct secret secret_from_hex(const char *hex)
{
struct secret secret;
hex += 2;
if (!hex_decode(hex, strlen(hex), &secret, sizeof(secret)))
abort();
return secret;
}
static void check_result(const u8 *msg, const char *hex)
{
assert(streq(hex, tal_hex(tmpctx, msg)));
}
int main(void)
{
setup_locale();
struct crypto_state cs_out, cs_in;
struct secret sk, rk, ck;
const void *msg;
size_t i;
setup_tmpctx();
msg = tal_dup_arr(tmpctx, char, "hello", 5, 0);
/* BOLT #8:
*
* name: transport-initiator successful handshake
*...
* # ck,temp_k3=0x919219dbb2920afa8db80f9a51787a840bcf111ed8d588caf9ab4be716e42b01,0x981a46c820fb7a241bc8184ba4bb1f01bcdfafb00dde80098cb8c38db9141520
* # encryptWithAD(0x981a46c820fb7a241bc8184ba4bb1f01bcdfafb00dde80098cb8c38db9141520, 0x000000000000000000000000, 0x5dcb5ea9b4ccc755e0e3456af3990641276e1d5dc9afd82f974d90a47c918660, <empty>)
* # t=0x8dc68b1c466263b47fdf31e560e139ba
* output: 0x00b9e3a702e93e3a9948c2ed6e5fd7590a6e1c3a0344cfc9d5b57357049aa22355361aa02e55a8fc28fef5bd6d71ad0c38228dc68b1c466263b47fdf31e560e139ba
* # HKDF(0x919219dbb2920afa8db80f9a51787a840bcf111ed8d588caf9ab4be716e42b01,zero)
* output: sk,rk=0x969ab31b4d288cedf6218839b27a3e2140827047f2c0f01bf5c04435d43511a9,0xbb9020b8965f4df047e07f955f3c4b88418984aadc5cdb35096b9ea8fa5c3442
*/
ck = secret_from_hex("0x919219dbb2920afa8db80f9a51787a840bcf111ed8d588caf9ab4be716e42b01");
sk = secret_from_hex("0x969ab31b4d288cedf6218839b27a3e2140827047f2c0f01bf5c04435d43511a9");
rk = secret_from_hex("0xbb9020b8965f4df047e07f955f3c4b88418984aadc5cdb35096b9ea8fa5c3442");
cs_out.sn = cs_out.rn = cs_in.sn = cs_in.rn = 0;
cs_out.sk = cs_in.rk = sk;
cs_out.rk = cs_in.sk = rk;
cs_out.s_ck = cs_out.r_ck = cs_in.s_ck = cs_in.r_ck = ck;
for (i = 0; i < 1002; i++) {
u8 *dec, *enc;
u16 len;
enc = cryptomsg_encrypt_msg(tmpctx, &cs_out, msg);
/* BOLT #8:
*
* output 0: 0xcf2b30ddf0cf3f80e7c35a6e6730b59fe802473180f396d88a8fb0db8cbcf25d2f214cf9ea1d95
*/
if (i == 0)
check_result(enc, "cf2b30ddf0cf3f80e7c35a6e6730b59fe802473180f396d88a8fb0db8cbcf25d2f214cf9ea1d95");
/* BOLT #8:
*
* output 1: 0x72887022101f0b6753e0c7de21657d35a4cb2a1f5cde2650528bbc8f837d0f0d7ad833b1a256a1
*/
if (i == 1)
check_result(enc, "72887022101f0b6753e0c7de21657d35a4cb2a1f5cde2650528bbc8f837d0f0d7ad833b1a256a1");
/* BOLT #8:
*
* output 500: 0x178cb9d7387190fa34db9c2d50027d21793c9bc2d40b1e14dcf30ebeeeb220f48364f7a4c68bf8
* output 501: 0x1b186c57d44eb6de4c057c49940d79bb838a145cb528d6e8fd26dbe50a60ca2c104b56b60e45bd
*/
if (i == 500)
check_result(enc, "178cb9d7387190fa34db9c2d50027d21793c9bc2d40b1e14dcf30ebeeeb220f48364f7a4c68bf8");
if (i == 501)
check_result(enc, "1b186c57d44eb6de4c057c49940d79bb838a145cb528d6e8fd26dbe50a60ca2c104b56b60e45bd");
/* BOLT #8:
*
* output 1000: 0x4a2f3cc3b5e78ddb83dcb426d9863d9d9a723b0337c89dd0b005d89f8d3c05c52b76b29b740f09
* output 1001: 0x2ecd8c8a5629d0d02ab457a0fdd0f7b90a192cd46be5ecb6ca570bfc5e268338b1a16cf4ef2d36
*/
if (i == 1000)
check_result(enc, "4a2f3cc3b5e78ddb83dcb426d9863d9d9a723b0337c89dd0b005d89f8d3c05c52b76b29b740f09");
if (i == 1001)
check_result(enc, "2ecd8c8a5629d0d02ab457a0fdd0f7b90a192cd46be5ecb6ca570bfc5e268338b1a16cf4ef2d36");
if (!cryptomsg_decrypt_header(&cs_in, enc, &len))
abort();
/* Trim header */
memmove(enc, enc + CRYPTOMSG_HDR_SIZE,
tal_bytelen(enc) - CRYPTOMSG_HDR_SIZE);
tal_resize(&enc, tal_bytelen(enc) - CRYPTOMSG_HDR_SIZE);
dec = cryptomsg_decrypt_body(enc, &cs_in, enc);
assert(memeq(dec, tal_bytelen(dec), msg, tal_bytelen(msg)));
}
tal_free(tmpctx);
return 0;
}
|
711669.c | /* LibTomCrypt, modular cryptographic library -- Tom St Denis
*
* LibTomCrypt is a library that provides various cryptographic
* algorithms in a highly modular and flexible manner.
*
* The library is free for all purposes without any express
* guarantee it works.
*
* Tom St Denis, [email protected], http://libtomcrypt.com
*/
#include "tomcrypt.h"
/**
@file omac_memory.c
OMAC1 support, process a block of memory, Tom St Denis
*/
#ifdef LTC_OMAC
/**
OMAC a block of memory
@param cipher The index of the desired cipher
@param key The secret key
@param keylen The length of the secret key (octets)
@param in The data to send through OMAC
@param inlen The length of the data to send through OMAC (octets)
@param out [out] The destination of the authentication tag
@param outlen [in/out] The max size and resulting size of the authentication tag (octets)
@return CRYPT_OK if successful
*/
int omac_memory(int cipher,
const unsigned char *key, unsigned long keylen,
const unsigned char *in, unsigned long inlen,
unsigned char *out, unsigned long *outlen)
{
int err;
omac_state *omac;
LTC_ARGCHK(key != NULL);
LTC_ARGCHK(in != NULL);
LTC_ARGCHK(out != NULL);
LTC_ARGCHK(outlen != NULL);
/* is the cipher valid? */
if ((err = cipher_is_valid(cipher)) != CRYPT_OK) {
return err;
}
/* Use accelerator if found */
if (cipher_descriptor[cipher].omac_memory != NULL) {
return cipher_descriptor[cipher].omac_memory(key, keylen, in, inlen, out, outlen);
}
/* allocate ram for omac state */
omac = XMALLOC(sizeof(omac_state));
if (omac == NULL) {
return CRYPT_MEM;
}
/* omac process the message */
if ((err = omac_init(omac, cipher, key, keylen)) != CRYPT_OK) {
goto LBL_ERR;
}
if ((err = omac_process(omac, in, inlen)) != CRYPT_OK) {
goto LBL_ERR;
}
if ((err = omac_done(omac, out, outlen)) != CRYPT_OK) {
goto LBL_ERR;
}
err = CRYPT_OK;
LBL_ERR:
#ifdef LTC_CLEAN_STACK
zeromem(omac, sizeof(omac_state));
#endif
XFREE(omac);
return err;
}
#endif
/* $Source: /cvs/libtom/libtomcrypt/src/mac/omac/omac_memory.c,v $ */
/* $Revision: 1.6 $ */
/* $Date: 2006/11/08 23:01:06 $ */
|
117117.c | #include<stdio.h>
int min(int a[], int n);
int max(int a[], int n);
void f(int *m, int *n);
int main()
{
int a[100];
int i, n,mi,ma;
scanf("%d", &n);
for (i = 0; i < n; i++)
{
scanf("%d", &a[i]);
}
for (i = 0; i < n; i++)
{
if(a[i]==max(a,n))
ma=i;
if (a[i] == min(a, n))
mi = i;
}
f(&a[0],& a[mi]);
f(&a[n-1], &a[ma]);
for (i = 0; i < n; i++)
{
if(i==n-1)
printf("%d", a[i]);
else
printf("%d ", a[i]);
}
}
int min(int a[], int n)
{
int i, min = 10000;
for (i = 0; i < n; i++)
{
min = min < a[i] ? min : a[i];
}
return min;
}
int max(int a[], int n)
{
int i, max = -32767;
for (i = 0; i < n; i++)
{
max = max > a[i] ? max : a[i];
}
return max;
}
void f(int *m, int *n)
{
int t;
t = *m;
*m = *n;
*n = t;
}
|
690918.c | // SPDX-License-Identifier: X11
// 2020-08-31
// Coprime (500pt)
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#define MAX 1000005
bool *erato(uint_least32_t bound);
int main() {
uint_least32_t N;
scanf("%u\n", &N);
bool *P = erato(MAX);
uint_least32_t *Ap = calloc(MAX, sizeof(uint_least32_t));
bool set = true;
bool pair = true;
uint_least8_t s;
uint_least32_t A, i, j;
for (i = 0; i < N; i++) {
scanf("%u", &A);
if (A == 1) {
continue;
}
if (P[A]) {
if (Ap[A])
pair = false;
Ap[A]++;
if (Ap[A] == N)
set = false;
continue;
}
if (!(A & 1)) {
if (Ap[2])
pair = false;
Ap[2]++;
if (Ap[2] == N)
set = false;
while (!(A & 1))
A >>= 1;
if (A == 1) {
continue;
}
if (P[A]) {
if (Ap[A])
pair = false;
Ap[A]++;
if (Ap[A] == N)
set = false;
continue;
}
}
if (!(A % 3)) {
if (Ap[3])
pair = false;
Ap[3]++;
if (Ap[3] == N)
set = false;
while (!(A % 3))
A /= 3;
if (A == 1) {
continue;
}
if (P[A]) {
if (Ap[A])
pair = false;
Ap[A]++;
if (Ap[A] == N)
set = false;
continue;
}
}
for (j = 5, s = 2; j * j <= A; j += s, s = 6 - s)
if (!(A % j)) {
if (Ap[j])
pair = false;
Ap[j]++;
if (Ap[j] == N)
set = false;
while (!(A % j))
A /= j;
if (A == 1) {
break;
}
if (P[A]) {
if (Ap[A])
pair = false;
Ap[A]++;
if (Ap[A] == N)
set = false;
break;
}
}
}
if (pair)
printf("pairwise coprime\n");
else if (set)
printf("setwise coprime\n");
else
printf("not coprime\n");
free(P);
free(Ap);
}
bool *erato(uint_least32_t bound) {
if (!bound)
return NULL;
bool *array = calloc(bound, sizeof(bool));
uint_least32_t i,j;
uint_least8_t s,ss;
if (bound < 3)
return array;
array[2] = true;
if (bound < 4)
return array;
array[3] = true;
if (bound < 5)
return array;
for (i = 5, s = 2; i < bound; i += s, s = 6 - s)
array[i] = true;
for (i = 5, s = 2; i < bound; i += s, s = 6 - s)
if (array[i])
for (j = i, ss = s; i * j < bound; j += ss, ss = 6 - ss)
array[i * j] = false;
return array;
}
|
130651.c | before sort: -2 0 -2 5 5 3 -1 -3 5 5 0 2 -4 4 2
after sort: -4 -3 -2 -2 -1 0 0 2 2 3 4 5 5 5 5
|
370403.c | /* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE134_Uncontrolled_Format_String__char_listen_socket_snprintf_61b.c
Label Definition File: CWE134_Uncontrolled_Format_String.label.xml
Template File: sources-sinks-61b.tmpl.c
*/
/*
* @description
* CWE: 134 Uncontrolled Format String
* BadSource: listen_socket Read data using a listen socket (server side)
* GoodSource: Copy a fixed string into data
* Sinks: snprintf
* GoodSink: snprintf with "%s" as the third argument and data as the fourth
* BadSink : snprintf with data as the third argument
* Flow Variant: 61 Data flow: data returned from one function to another in different source files
*
* */
#include "std_testcase.h"
#ifdef _WIN32
# include <winsock2.h>
# include <windows.h>
# include <direct.h>
# define PATH_SZ 100
# pragma comment(lib, "ws2_32") /* include ws2_32.lib when linking */
# define CLOSE_SOCKET closesocket
#else
# define PATH_SZ PATH_MAX
# define INVALID_SOCKET -1
# define SOCKET_ERROR -1
# define CLOSE_SOCKET close
# define SOCKET int
#endif
#define TCP_PORT 27015
#define LISTEN_BACKLOG 5
#ifdef _WIN32
# define SNPRINTF _snprintf
#else /* NOT _WIN32 */
# define SNPRINTF snprintf
#endif
#ifndef OMITBAD
char * CWE134_Uncontrolled_Format_String__char_listen_socket_snprintf_61b_bad_source(char * data)
{
{
#ifdef _WIN32
WSADATA wsa_data;
int wsa_data_init = 0;
#endif
int recv_rv;
struct sockaddr_in s_in;
char *replace;
SOCKET listen_socket = INVALID_SOCKET;
SOCKET accept_socket = INVALID_SOCKET;
size_t data_len = strlen(data);
do
{
#ifdef _WIN32
if (WSAStartup(MAKEWORD(2,2), &wsa_data) != NO_ERROR) break;
wsa_data_init = 1;
#endif
listen_socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (listen_socket == INVALID_SOCKET) break;
memset(&s_in, 0, sizeof(s_in));
s_in.sin_family = AF_INET;
s_in.sin_addr.s_addr = INADDR_ANY;
s_in.sin_port = htons(TCP_PORT);
if (bind(listen_socket, (struct sockaddr*)&s_in, sizeof(s_in)) == SOCKET_ERROR) break;
if (listen(listen_socket, LISTEN_BACKLOG) == SOCKET_ERROR) break;
accept_socket = accept(listen_socket, NULL, NULL);
if (accept_socket == SOCKET_ERROR) break;
/* Abort on error or the connection was closed */
recv_rv = recv(accept_socket, (char *)data+data_len, (int)(100-data_len-1), 0);
if (recv_rv == SOCKET_ERROR || recv_rv == 0) break;
/* Append null terminator */
data[recv_rv] = '\0';
/* Eliminate CRLF */
replace = strchr(data, '\r');
if (replace) *replace = '\0';
replace = strchr(data, '\n');
if (replace) *replace = '\0';
}
while (0);
if (listen_socket != INVALID_SOCKET) CLOSE_SOCKET(listen_socket);
if (accept_socket != INVALID_SOCKET) CLOSE_SOCKET(accept_socket);
#ifdef _WIN32
if (wsa_data_init) WSACleanup();
#endif
}
return data;
}
#endif /* OMITBAD */
#ifndef OMITGOOD
/* goodG2B() uses the GoodSource with the BadSink */
char * CWE134_Uncontrolled_Format_String__char_listen_socket_snprintf_61b_goodG2B_source(char * data)
{
/* FIX: Use a fixed string that does not contain a format specifier */
strcpy(data, "fixedstringtest");
return data;
}
/* goodB2G() uses the BadSource with the GoodSink */
char * CWE134_Uncontrolled_Format_String__char_listen_socket_snprintf_61b_goodB2G_source(char * data)
{
{
#ifdef _WIN32
WSADATA wsa_data;
int wsa_data_init = 0;
#endif
int recv_rv;
struct sockaddr_in s_in;
char *replace;
SOCKET listen_socket = INVALID_SOCKET;
SOCKET accept_socket = INVALID_SOCKET;
size_t data_len = strlen(data);
do
{
#ifdef _WIN32
if (WSAStartup(MAKEWORD(2,2), &wsa_data) != NO_ERROR) break;
wsa_data_init = 1;
#endif
listen_socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (listen_socket == INVALID_SOCKET) break;
memset(&s_in, 0, sizeof(s_in));
s_in.sin_family = AF_INET;
s_in.sin_addr.s_addr = INADDR_ANY;
s_in.sin_port = htons(TCP_PORT);
if (bind(listen_socket, (struct sockaddr*)&s_in, sizeof(s_in)) == SOCKET_ERROR) break;
if (listen(listen_socket, LISTEN_BACKLOG) == SOCKET_ERROR) break;
accept_socket = accept(listen_socket, NULL, NULL);
if (accept_socket == SOCKET_ERROR) break;
/* Abort on error or the connection was closed */
recv_rv = recv(accept_socket, (char *)data+data_len, (int)(100-data_len-1), 0);
if (recv_rv == SOCKET_ERROR || recv_rv == 0) break;
/* Append null terminator */
data[recv_rv] = '\0';
/* Eliminate CRLF */
replace = strchr(data, '\r');
if (replace) *replace = '\0';
replace = strchr(data, '\n');
if (replace) *replace = '\0';
}
while (0);
if (listen_socket != INVALID_SOCKET) CLOSE_SOCKET(listen_socket);
if (accept_socket != INVALID_SOCKET) CLOSE_SOCKET(accept_socket);
#ifdef _WIN32
if (wsa_data_init) WSACleanup();
#endif
}
return data;
}
#endif /* OMITGOOD */
|
656890.c | /*
* AC-3 encoder options
* Copyright (c) 2011 Justin Ruggles <[email protected]>
*
* This file is part of Libav.
*
* Libav is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* Libav is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with Libav; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "libavutil/opt.h"
#include "ac3.h"
#if AC3ENC_TYPE == AC3ENC_TYPE_AC3_FIXED
static const AVOption ac3fixed_options[] = {
#elif AC3ENC_TYPE == AC3ENC_TYPE_AC3
static const AVOption ac3_options[] = {
#else /* AC3ENC_TYPE_EAC3 */
static const AVOption eac3_options[] = {
#endif
/* Metadata Options */
{"per_frame_metadata", "Allow Changing Metadata Per-Frame", OFFSET(allow_per_frame_metadata), AV_OPT_TYPE_INT, {.dbl = 0 }, 0, 1, AC3ENC_PARAM},
#if AC3ENC_TYPE != AC3ENC_TYPE_EAC3
/* AC-3 downmix levels */
{"center_mixlev", "Center Mix Level", OFFSET(center_mix_level), AV_OPT_TYPE_FLOAT, {.dbl = LEVEL_MINUS_4POINT5DB }, 0.0, 1.0, AC3ENC_PARAM},
{"surround_mixlev", "Surround Mix Level", OFFSET(surround_mix_level), AV_OPT_TYPE_FLOAT, {.dbl = LEVEL_MINUS_6DB }, 0.0, 1.0, AC3ENC_PARAM},
#endif
/* audio production information */
{"mixing_level", "Mixing Level", OFFSET(mixing_level), AV_OPT_TYPE_INT, {.dbl = AC3ENC_OPT_NONE }, AC3ENC_OPT_NONE, 111, AC3ENC_PARAM},
{"room_type", "Room Type", OFFSET(room_type), AV_OPT_TYPE_INT, {.dbl = AC3ENC_OPT_NONE }, AC3ENC_OPT_NONE, AC3ENC_OPT_SMALL_ROOM, AC3ENC_PARAM, "room_type"},
{"notindicated", "Not Indicated (default)", 0, AV_OPT_TYPE_CONST, {.dbl = AC3ENC_OPT_NOT_INDICATED }, INT_MIN, INT_MAX, AC3ENC_PARAM, "room_type"},
{"large", "Large Room", 0, AV_OPT_TYPE_CONST, {.dbl = AC3ENC_OPT_LARGE_ROOM }, INT_MIN, INT_MAX, AC3ENC_PARAM, "room_type"},
{"small", "Small Room", 0, AV_OPT_TYPE_CONST, {.dbl = AC3ENC_OPT_SMALL_ROOM }, INT_MIN, INT_MAX, AC3ENC_PARAM, "room_type"},
/* other metadata options */
{"copyright", "Copyright Bit", OFFSET(copyright), AV_OPT_TYPE_INT, {.dbl = AC3ENC_OPT_NONE }, AC3ENC_OPT_NONE, 1, AC3ENC_PARAM},
{"dialnorm", "Dialogue Level (dB)", OFFSET(dialogue_level), AV_OPT_TYPE_INT, {.dbl = -31 }, -31, -1, AC3ENC_PARAM},
{"dsur_mode", "Dolby Surround Mode", OFFSET(dolby_surround_mode), AV_OPT_TYPE_INT, {.dbl = AC3ENC_OPT_NONE }, AC3ENC_OPT_NONE, AC3ENC_OPT_MODE_ON, AC3ENC_PARAM, "dsur_mode"},
{"notindicated", "Not Indicated (default)", 0, AV_OPT_TYPE_CONST, {.dbl = AC3ENC_OPT_NOT_INDICATED }, INT_MIN, INT_MAX, AC3ENC_PARAM, "dsur_mode"},
{"on", "Dolby Surround Encoded", 0, AV_OPT_TYPE_CONST, {.dbl = AC3ENC_OPT_MODE_ON }, INT_MIN, INT_MAX, AC3ENC_PARAM, "dsur_mode"},
{"off", "Not Dolby Surround Encoded", 0, AV_OPT_TYPE_CONST, {.dbl = AC3ENC_OPT_MODE_OFF }, INT_MIN, INT_MAX, AC3ENC_PARAM, "dsur_mode"},
{"original", "Original Bit Stream", OFFSET(original), AV_OPT_TYPE_INT, {.dbl = AC3ENC_OPT_NONE }, AC3ENC_OPT_NONE, 1, AC3ENC_PARAM},
/* extended bitstream information */
{"dmix_mode", "Preferred Stereo Downmix Mode", OFFSET(preferred_stereo_downmix), AV_OPT_TYPE_INT, {.dbl = AC3ENC_OPT_NONE }, AC3ENC_OPT_NONE, AC3ENC_OPT_DOWNMIX_LORO, AC3ENC_PARAM, "dmix_mode"},
{"notindicated", "Not Indicated (default)", 0, AV_OPT_TYPE_CONST, {.dbl = AC3ENC_OPT_NOT_INDICATED }, INT_MIN, INT_MAX, AC3ENC_PARAM, "dmix_mode"},
{"ltrt", "Lt/Rt Downmix Preferred", 0, AV_OPT_TYPE_CONST, {.dbl = AC3ENC_OPT_DOWNMIX_LTRT }, INT_MIN, INT_MAX, AC3ENC_PARAM, "dmix_mode"},
{"loro", "Lo/Ro Downmix Preferred", 0, AV_OPT_TYPE_CONST, {.dbl = AC3ENC_OPT_DOWNMIX_LORO }, INT_MIN, INT_MAX, AC3ENC_PARAM, "dmix_mode"},
{"ltrt_cmixlev", "Lt/Rt Center Mix Level", OFFSET(ltrt_center_mix_level), AV_OPT_TYPE_FLOAT, {.dbl = -1.0 }, -1.0, 2.0, AC3ENC_PARAM},
{"ltrt_surmixlev", "Lt/Rt Surround Mix Level", OFFSET(ltrt_surround_mix_level), AV_OPT_TYPE_FLOAT, {.dbl = -1.0 }, -1.0, 2.0, AC3ENC_PARAM},
{"loro_cmixlev", "Lo/Ro Center Mix Level", OFFSET(loro_center_mix_level), AV_OPT_TYPE_FLOAT, {.dbl = -1.0 }, -1.0, 2.0, AC3ENC_PARAM},
{"loro_surmixlev", "Lo/Ro Surround Mix Level", OFFSET(loro_surround_mix_level), AV_OPT_TYPE_FLOAT, {.dbl = -1.0 }, -1.0, 2.0, AC3ENC_PARAM},
{"dsurex_mode", "Dolby Surround EX Mode", OFFSET(dolby_surround_ex_mode), AV_OPT_TYPE_INT, {.dbl = AC3ENC_OPT_NONE }, AC3ENC_OPT_NONE, AC3ENC_OPT_MODE_ON, AC3ENC_PARAM, "dsurex_mode"},
{"notindicated", "Not Indicated (default)", 0, AV_OPT_TYPE_CONST, {.dbl = AC3ENC_OPT_NOT_INDICATED }, INT_MIN, INT_MAX, AC3ENC_PARAM, "dsurex_mode"},
{"on", "Dolby Surround EX Encoded", 0, AV_OPT_TYPE_CONST, {.dbl = AC3ENC_OPT_MODE_ON }, INT_MIN, INT_MAX, AC3ENC_PARAM, "dsurex_mode"},
{"off", "Not Dolby Surround EX Encoded", 0, AV_OPT_TYPE_CONST, {.dbl = AC3ENC_OPT_MODE_OFF }, INT_MIN, INT_MAX, AC3ENC_PARAM, "dsurex_mode"},
{"dheadphone_mode", "Dolby Headphone Mode", OFFSET(dolby_headphone_mode), AV_OPT_TYPE_INT, {.dbl = AC3ENC_OPT_NONE }, AC3ENC_OPT_NONE, AC3ENC_OPT_MODE_ON, AC3ENC_PARAM, "dheadphone_mode"},
{"notindicated", "Not Indicated (default)", 0, AV_OPT_TYPE_CONST, {.dbl = AC3ENC_OPT_NOT_INDICATED }, INT_MIN, INT_MAX, AC3ENC_PARAM, "dheadphone_mode"},
{"on", "Dolby Headphone Encoded", 0, AV_OPT_TYPE_CONST, {.dbl = AC3ENC_OPT_MODE_ON }, INT_MIN, INT_MAX, AC3ENC_PARAM, "dheadphone_mode"},
{"off", "Not Dolby Headphone Encoded", 0, AV_OPT_TYPE_CONST, {.dbl = AC3ENC_OPT_MODE_OFF }, INT_MIN, INT_MAX, AC3ENC_PARAM, "dheadphone_mode"},
{"ad_conv_type", "A/D Converter Type", OFFSET(ad_converter_type), AV_OPT_TYPE_INT, {.dbl = AC3ENC_OPT_NONE }, AC3ENC_OPT_NONE, AC3ENC_OPT_ADCONV_HDCD, AC3ENC_PARAM, "ad_conv_type"},
{"standard", "Standard (default)", 0, AV_OPT_TYPE_CONST, {.dbl = AC3ENC_OPT_ADCONV_STANDARD }, INT_MIN, INT_MAX, AC3ENC_PARAM, "ad_conv_type"},
{"hdcd", "HDCD", 0, AV_OPT_TYPE_CONST, {.dbl = AC3ENC_OPT_ADCONV_HDCD }, INT_MIN, INT_MAX, AC3ENC_PARAM, "ad_conv_type"},
/* Other Encoding Options */
{"stereo_rematrixing", "Stereo Rematrixing", OFFSET(stereo_rematrixing), AV_OPT_TYPE_INT, {.dbl = AC3ENC_OPT_ON }, AC3ENC_OPT_OFF, AC3ENC_OPT_ON, AC3ENC_PARAM},
{"channel_coupling", "Channel Coupling", OFFSET(channel_coupling), AV_OPT_TYPE_INT, {.dbl = AC3ENC_OPT_AUTO }, AC3ENC_OPT_AUTO, AC3ENC_OPT_ON, AC3ENC_PARAM, "channel_coupling"},
{"auto", "Selected by the Encoder", 0, AV_OPT_TYPE_CONST, {.dbl = AC3ENC_OPT_AUTO }, INT_MIN, INT_MAX, AC3ENC_PARAM, "channel_coupling"},
{"cpl_start_band", "Coupling Start Band", OFFSET(cpl_start), AV_OPT_TYPE_INT, {.dbl = AC3ENC_OPT_AUTO }, AC3ENC_OPT_AUTO, 15, AC3ENC_PARAM, "cpl_start_band"},
{"auto", "Selected by the Encoder", 0, AV_OPT_TYPE_CONST, {.dbl = AC3ENC_OPT_AUTO }, INT_MIN, INT_MAX, AC3ENC_PARAM, "cpl_start_band"},
{NULL}
};
|
962874.c | #include <osal.h>
#include <httpd.h>
#include <stdlib.h>
#include <stdbool.h>
int pre_start_mem, post_stop_mem, post_stop_min_mem;
bool basic_sanity = true;
/********************* Basic Handlers Start *******************/
int hello_get_handler(httpd_req_t *req)
{
#define STR "Hello World!"
httpd_resp_send(req, STR, strlen(STR));
return OS_SUCCESS;
#undef STR
}
int hello_type_get_handler(httpd_req_t *req)
{
#define STR "Hello World!"
httpd_resp_set_type(req, HTTPD_TYPE_TEXT);
httpd_resp_send(req, STR, strlen(STR));
return OS_SUCCESS;
#undef STR
}
int hello_status_get_handler(httpd_req_t *req)
{
#define STR "Hello World!"
httpd_resp_set_status(req, HTTPD_500);
httpd_resp_send(req, STR, strlen(STR));
return OS_SUCCESS;
#undef STR
}
int echo_post_handler(httpd_req_t *req)
{
char buf[100];
int ret;
ret = httpd_req_recv(req, buf, sizeof(buf));
if (ret < 0)
return -OS_FAIL;
buf[ret] = '\0';
httpd_resp_send(req, buf, strlen(buf));
return OS_SUCCESS;
}
void adder_free_func(void *ctx)
{
printf("Custom Free Context function called\n");
free(ctx);
}
/* Create a context, keep incrementing value in the context, by whatever was
* received. Return the result
*/
int adder_post_handler(httpd_req_t *req)
{
char buf[10];
char outbuf[50];
int ret;
ret = httpd_req_recv(req, buf, sizeof(buf));
if (ret < 0)
return -OS_FAIL;
buf[ret] = '\0';
int val = atoi(buf);
printf("/adder handler read %d\n", val);
if (! req->sess_ctx) {
printf("/adder allocating new session\n");
req->sess_ctx = malloc(sizeof(int));
req->free_ctx = adder_free_func;
*(int *)req->sess_ctx = 0;
}
int *adder = (int *)req->sess_ctx;
*adder += val;
snprintf(outbuf, sizeof(outbuf),"%d", *adder);
httpd_resp_send(req, outbuf, strlen(outbuf));
return OS_SUCCESS;
}
int leftover_data_post_handler(httpd_req_t *req)
{
/* Only echo the first 10 bytes of the request, leaving the rest of the
* request data as is.
*/
char buf[11];
int ret;
ret = httpd_req_recv(req, buf, sizeof(buf) - 1);
if (ret < 0)
return -OS_FAIL;
buf[ret] = '\0';
httpd_resp_send(req, buf, strlen(buf));
return OS_SUCCESS;
}
int __httpd_send(int sockfd, const char *buf, unsigned buf_len, int flags);
void generate_async_resp(void *arg)
{
char buf[250];
int fd = (int )arg;
#define HTTPD_HDR_STR "HTTP/1.1 200 OK\r\n" \
"Content-Type: text/html\r\n" \
"Content-Length: %d\r\n"
#define STR "Hello Double World!"
snprintf(buf, sizeof(buf), HTTPD_HDR_STR,
strlen(STR));
__httpd_send(fd, buf, strlen(buf), 0);
/* Space for sending additional headers based on set_header */
__httpd_send(fd, "\r\n", strlen("\r\n"), 0);
__httpd_send(fd, STR, strlen(STR), 0);
}
int async_get_handler(httpd_req_t *req)
{
#define STR "Hello World!"
httpd_resp_send(req, STR, strlen(STR));
/* Also register a HTTPD Work which sends the same data on the same
* socket again
*/
httpd_queue_work(generate_async_resp, (void *)httpd_req_to_sockfd(req));
return OS_SUCCESS;
#undef STR
}
struct httpd_uri basic_handlers[] = {
{ .uri = "/hello/type_html",
.get = hello_type_get_handler,
},
{ .uri = "/hello",
.get = hello_get_handler,
},
{ .uri = "/hello/status_500",
.get = hello_status_get_handler,
},
{ .uri = "/echo",
.post = echo_post_handler,
.put = echo_post_handler,
},
{ .uri = "/leftover_data",
.post = leftover_data_post_handler,
},
{ .uri = "/adder",
.post = adder_post_handler,
},
{ .uri = "/async_data",
.get = async_get_handler,
},
};
int basic_handlers_no = sizeof(basic_handlers)/sizeof(struct httpd_uri);
void register_basic_handlers(void)
{
int i, ret;
printf("No of handlers = %d\n", basic_handlers_no);
for (i = 0; i < basic_handlers_no; i++) {
ret = httpd_register_uri_handler(&basic_handlers[i]);
printf("register uri returned %d\n", ret);
}
}
/********************* Basic Handlers End *******************/
int my_hello_post_handler(httpd_req_t *req)
{
char buf[10];
char outbuf[50];
int ret;
ret = httpd_req_recv(req, buf, sizeof(buf));
if (ret < 0)
return -OS_FAIL;
httpd_resp_set_status(req, HTTPD_404);
httpd_resp_set_type(req, HTTPD_TYPE_TEXT);
printf("Read %d bytes as:%s:\n", ret, buf);
buf[ret] = '\0';
#define STR "my_hello_handler"
snprintf(outbuf, sizeof(outbuf), STR" %s", buf);
httpd_resp_send(req, outbuf, strlen(outbuf));
return OS_SUCCESS;
#undef STR
}
/********************* Test Handler Limit Start *******************/
int null_func(httpd_req_t *req)
{
return OS_SUCCESS;
}
struct httpd_uri handler_limit_uri = {
.uri = "/limit",
.get = null_func,
.post = null_func
};
void test_handler_limit(void)
{
int i, ret;
/* Register the same handler for MAX URI Handlers */
printf("Test: Register Max URI handlers: %d...", HTTPD_MAX_URI_HANDLERS);
for (i = 0; i < HTTPD_MAX_URI_HANDLERS; i++) {
ret = httpd_register_uri_handler(&handler_limit_uri);
if (ret != OS_SUCCESS) {
printf("Fail\n");
goto error_ret;
}
}
printf("Success\n");
/* Register the MAX URI + 1 Handlers should fail */
printf("Test: Register Max URI + 1 handlers: %d th...", HTTPD_MAX_URI_HANDLERS +1 );
ret = httpd_register_uri_handler(&handler_limit_uri);
if (ret == OS_SUCCESS) {
printf("Fail\n");
goto error_ret;
}
printf("Success\n");
/* Register the MAX URI + 1 Handlers should fail */
printf("Test: Unregister 1 handlers...");
ret = httpd_unregister_uri_handler(&handler_limit_uri);
if (ret != OS_SUCCESS) {
printf("Fail\n");
goto error_ret;
}
printf("Success\n");
/* Register the MAX URI + 1 Handlers should fail */
printf("Test: Register 1 more handler");
ret = httpd_register_uri_handler(&handler_limit_uri);
if (ret != OS_SUCCESS) {
printf("Fail\n");
goto error_ret;
}
printf("Success\n");
/* Unregister the same handler for MAX URI Handlers */
printf("Test: Unregister all handlers:");
for (i = 0; i < HTTPD_MAX_URI_HANDLERS; i++) {
ret = httpd_unregister_uri_handler(&handler_limit_uri);
if (ret != OS_SUCCESS) {
printf("Fail\n");
goto error_ret;
}
}
printf("Success\n");
error_ret:
basic_sanity = false;
}
/********************* Test Handler Limit End *******************/
int test_httpd_start()
{
pre_start_mem = os_get_current_free_mem();
printf("HTTPD Start: Current free memory: %d\n", pre_start_mem);
return httpd_start();
}
void test_httpd_stop()
{
httpd_stop();
post_stop_mem = os_get_current_free_mem();
post_stop_min_mem = os_get_minimum_free_mem();
httpd_d("HTTPD Stop: Current free memory: %d\n", post_stop_mem);
httpd_d("HTTPD Stop: Minimum free memory: %d\n", post_stop_min_mem);
}
void start_tests(void)
{
test_handler_limit();
printf("Starting httpd\n");
test_httpd_start();
register_basic_handlers();
}
|
357345.c |
#include "includes.h"
static
LWMsgStatus
LwTaskDaemonIpcSetLogInfo(
LWMsgCall* pCall, /* IN */
const LWMsgParams* pIn, /* IN */
LWMsgParams* pOut, /* OUT */
void* pData /* IN */
);
static
LWMsgStatus
LwTaskDaemonIpcGetLogInfo(
LWMsgCall* pCall, /* IN */
const LWMsgParams* pIn, /* IN */
LWMsgParams* pOut, /* OUT */
void* pData /* IN */
);
static
LWMsgStatus
LwTaskDaemonIpcGetPid(
LWMsgCall* pCall, /* IN */
const LWMsgParams* pIn, /* IN */
LWMsgParams* pOut, /* OUT */
void* pData /* IN */
);
static
LWMsgStatus
LwTaskDaemonIpcTaskStart(
LWMsgCall* pCall, /* IN */
const LWMsgParams* pIn, /* IN */
LWMsgParams* pOut, /* OUT */
void* pData /* IN */
);
static
LWMsgStatus
LwTaskDaemonIpcTaskStop(
LWMsgCall* pCall, /* IN */
const LWMsgParams* pIn, /* IN */
LWMsgParams* pOut, /* OUT */
void* pData /* IN */
);
static
LWMsgStatus
LwTaskDaemonIpcTaskDelete(
LWMsgCall* pCall, /* IN */
const LWMsgParams* pIn, /* IN */
LWMsgParams* pOut, /* OUT */
void* pData /* IN */
);
static
LWMsgStatus
LwTaskDaemonIpcGetTypes(
LWMsgCall* pCall, /* IN */
const LWMsgParams* pIn, /* IN */
LWMsgParams* pOut, /* OUT */
void* pData /* IN */
);
static
LWMsgStatus
LwTaskDaemonIpcGetStatus(
LWMsgCall* pCall, /* IN */
const LWMsgParams* pIn, /* IN */
LWMsgParams* pOut, /* OUT */
void* pData /* IN */
);
static
LWMsgStatus
LwTaskDaemonIpcCreate(
LWMsgCall* pCall, /* IN */
const LWMsgParams* pIn, /* IN */
LWMsgParams* pOut, /* OUT */
void* pData /* IN */
);
static
LWMsgStatus
LwTaskDaemonIpcGetSchema(
LWMsgCall* pCall, /* IN */
const LWMsgParams* pIn, /* IN */
LWMsgParams* pOut, /* OUT */
void* pData /* IN */
);
static
LWMsgStatus
LwTaskDaemonIpcEnum(
LWMsgCall* pCall, /* IN */
const LWMsgParams* pIn, /* IN */
LWMsgParams* pOut, /* OUT */
void* pData /* IN */
);
static
LWMsgDispatchSpec
gLwTaskDaemonIpcDispatchSpec[] =
{
LWMSG_DISPATCH_BLOCK(LW_TASK_SET_LOG_INFO, LwTaskDaemonIpcSetLogInfo),
LWMSG_DISPATCH_BLOCK(LW_TASK_GET_LOG_INFO, LwTaskDaemonIpcGetLogInfo),
LWMSG_DISPATCH_BLOCK(LW_TASK_GET_PID, LwTaskDaemonIpcGetPid),
LWMSG_DISPATCH_BLOCK(LW_TASK_START, LwTaskDaemonIpcTaskStart),
LWMSG_DISPATCH_BLOCK(LW_TASK_STOP, LwTaskDaemonIpcTaskStop),
LWMSG_DISPATCH_BLOCK(LW_TASK_DELETE, LwTaskDaemonIpcTaskDelete),
LWMSG_DISPATCH_BLOCK(LW_TASK_GET_TYPES, LwTaskDaemonIpcGetTypes),
LWMSG_DISPATCH_BLOCK(LW_TASK_GET_STATUS, LwTaskDaemonIpcGetStatus),
LWMSG_DISPATCH_BLOCK(LW_TASK_CREATE, LwTaskDaemonIpcCreate),
LWMSG_DISPATCH_BLOCK(LW_TASK_GET_SCHEMA, LwTaskDaemonIpcGetSchema),
LWMSG_DISPATCH_BLOCK(LW_TASK_ENUM, LwTaskDaemonIpcEnum),
LWMSG_DISPATCH_END
};
static
LWMsgStatus
LwTaskDaemonIpcGetPid(
LWMsgCall* pCall, /* IN */
const LWMsgParams* pIn, /* IN */
LWMsgParams* pOut, /* OUT */
void* pData /* IN */
);
DWORD
LwTaskDaemonIpcAddDispatch(
LWMsgServer* pServer /* IN OUT */
)
{
return MAP_LWMSG_ERROR(lwmsg_server_add_dispatch_spec(
pServer,
gLwTaskDaemonIpcDispatchSpec));
}
static
LWMsgStatus
LwTaskDaemonIpcSetLogInfo(
LWMsgCall* pCall, /* IN */
const LWMsgParams* pIn, /* IN */
LWMsgParams* pOut, /* OUT */
void* pData /* IN */
)
{
DWORD dwError = 0;
LWMsgStatus status = LWMSG_STATUS_SUCCESS;
PLW_TASK_STATUS_REPLY pStatusResponse = NULL;
BAIL_ON_INVALID_POINTER(pIn->data);
dwError = LwAllocateMemory(
sizeof(LW_TASK_STATUS_REPLY),
(PVOID*)&pStatusResponse);
BAIL_ON_LW_TASK_ERROR(dwError);
dwError = LwTaskLogSetInfo_r((PLW_TASK_LOG_INFO)pIn->data);
/* Transmit failure to client but do not bail out of dispatch loop */
if (dwError)
{
pStatusResponse->dwError = dwError;
pOut->tag = LW_TASK_SET_LOG_INFO_FAILED;
pOut->data = pStatusResponse;
dwError = 0;
goto cleanup;
}
pOut->tag = LW_TASK_SET_LOG_INFO_SUCCESS;
pOut->data = pStatusResponse;
cleanup:
return status;
error:
goto cleanup;
}
static
LWMsgStatus
LwTaskDaemonIpcGetLogInfo(
LWMsgCall* pCall, /* IN */
const LWMsgParams* pIn, /* IN */
LWMsgParams* pOut, /* OUT */
void* pData /* IN */
)
{
DWORD dwError = 0;
LWMsgStatus status = LWMSG_STATUS_SUCCESS;
PLW_TASK_STATUS_REPLY pStatusResponse = NULL;
PLW_TASK_LOG_INFO pLogInfo = NULL;
dwError = LwAllocateMemory(
sizeof(LW_TASK_STATUS_REPLY),
(PVOID*)&pStatusResponse);
BAIL_ON_LW_TASK_ERROR(dwError);
dwError = LwTaskLogGetInfo_r(&pLogInfo);
if (dwError)
{
pStatusResponse->dwError = dwError;
pOut->tag = LW_TASK_GET_LOG_INFO_FAILED;
pOut->data = pStatusResponse;
pStatusResponse = NULL;
dwError = 0;
goto cleanup;
}
pOut->tag = LW_TASK_GET_LOG_INFO_SUCCESS;
pOut->data = pLogInfo;
cleanup:
LW_SAFE_FREE_MEMORY(pStatusResponse);
return status;
error:
goto cleanup;
}
static
LWMsgStatus
LwTaskDaemonIpcGetPid(
LWMsgCall* pCall, /* IN */
const LWMsgParams* pIn, /* IN */
LWMsgParams* pOut, /* OUT */
void* pData /* IN */
)
{
DWORD dwError = 0;
LWMsgStatus status = LWMSG_STATUS_SUCCESS;
pid_t* pPid = NULL;
dwError = LwAllocateMemory(sizeof(*pPid), OUT_PPVOID(&pPid));
BAIL_ON_LW_TASK_ERROR(dwError);
*pPid = getpid();
pOut->tag = LW_TASK_GET_PID_SUCCESS;
pOut->data = pPid;
pPid = NULL;
cleanup:
LW_SAFE_FREE_MEMORY(pPid);
return status;
error:
goto cleanup;
}
static
LWMsgStatus
LwTaskDaemonIpcTaskStart(
LWMsgCall* pCall, /* IN */
const LWMsgParams* pIn, /* IN */
LWMsgParams* pOut, /* OUT */
void* pData /* IN */
)
{
DWORD dwError = 0;
LWMsgStatus status = LWMSG_STATUS_SUCCESS;
PLW_TASK_IPC_START_ARGS pRequest = NULL;
PLW_TASK_STATUS_REPLY pStatusResponse = NULL;
BAIL_ON_INVALID_POINTER(pIn->data);
dwError = LwAllocateMemory(
sizeof(LW_TASK_STATUS_REPLY),
(PVOID*)&pStatusResponse);
BAIL_ON_LW_TASK_ERROR(dwError);
pRequest = (PLW_TASK_IPC_START_ARGS)pIn->data;
dwError = LwTaskSrvStart(
pRequest->pszTaskId,
pRequest->pArgArray,
pRequest->dwNumArgs);
/* Transmit failure to client but do not bail out of dispatch loop */
if (dwError)
{
pStatusResponse->dwError = dwError;
pOut->tag = LW_TASK_START_FAILED;
pOut->data = pStatusResponse;
dwError = 0;
goto cleanup;
}
pOut->tag = LW_TASK_START_SUCCESS;
pOut->data = pStatusResponse;
cleanup:
return status;
error:
goto cleanup;
}
static
LWMsgStatus
LwTaskDaemonIpcTaskStop(
LWMsgCall* pCall, /* IN */
const LWMsgParams* pIn, /* IN */
LWMsgParams* pOut, /* OUT */
void* pData /* IN */
)
{
DWORD dwError = 0;
LWMsgStatus status = LWMSG_STATUS_SUCCESS;
PLW_TASK_STATUS_REPLY pStatusResponse = NULL;
BAIL_ON_INVALID_POINTER(pIn->data);
dwError = LwAllocateMemory(
sizeof(LW_TASK_STATUS_REPLY),
(PVOID*)&pStatusResponse);
BAIL_ON_LW_TASK_ERROR(dwError);
dwError = LwTaskSrvStop((PCSTR)pIn->data);
/* Transmit failure to client but do not bail out of dispatch loop */
if (dwError)
{
pStatusResponse->dwError = dwError;
pOut->tag = LW_TASK_STOP_FAILED;
pOut->data = pStatusResponse;
dwError = 0;
goto cleanup;
}
pOut->tag = LW_TASK_STOP_SUCCESS;
pOut->data = pStatusResponse;
cleanup:
return status;
error:
goto cleanup;
}
static
LWMsgStatus
LwTaskDaemonIpcTaskDelete(
LWMsgCall* pCall, /* IN */
const LWMsgParams* pIn, /* IN */
LWMsgParams* pOut, /* OUT */
void* pData /* IN */
)
{
DWORD dwError = 0;
LWMsgStatus status = LWMSG_STATUS_SUCCESS;
PLW_TASK_STATUS_REPLY pStatusResponse = NULL;
BAIL_ON_INVALID_POINTER(pIn->data);
dwError = LwAllocateMemory(
sizeof(LW_TASK_STATUS_REPLY),
(PVOID*)&pStatusResponse);
BAIL_ON_LW_TASK_ERROR(dwError);
dwError = LwTaskSrvDelete((PCSTR)pIn->data);
/* Transmit failure to client but do not bail out of dispatch loop */
if (dwError)
{
pStatusResponse->dwError = dwError;
pOut->tag = LW_TASK_DELETE_FAILED;
pOut->data = pStatusResponse;
dwError = 0;
goto cleanup;
}
pOut->tag = LW_TASK_DELETE_SUCCESS;
pOut->data = pStatusResponse;
cleanup:
return status;
error:
goto cleanup;
}
static
LWMsgStatus
LwTaskDaemonIpcGetTypes(
LWMsgCall* pCall, /* IN */
const LWMsgParams* pIn, /* IN */
LWMsgParams* pOut, /* OUT */
void* pData /* IN */
)
{
DWORD dwError = 0;
LWMsgStatus status = LWMSG_STATUS_SUCCESS;
PLW_TASK_STATUS_REPLY pStatusResponse = NULL;
PLW_TASK_IPC_GET_TYPES pResult = NULL;
dwError = LwAllocateMemory(
sizeof(LW_TASK_STATUS_REPLY),
(PVOID*)&pStatusResponse);
BAIL_ON_LW_TASK_ERROR(dwError);
dwError = LwAllocateMemory(
sizeof(LW_TASK_IPC_GET_TYPES),
(PVOID*)&pResult);
BAIL_ON_LW_TASK_ERROR(dwError);
dwError = LwTaskSrvGetTypes(
&pResult->pdwTaskTypeArray,
&pResult->dwNumTaskTypes);
if (dwError)
{
pStatusResponse->dwError = dwError;
pOut->tag = LW_TASK_GET_TYPES_FAILED;
pOut->data = pStatusResponse;
pStatusResponse = NULL;
dwError = 0;
goto cleanup;
}
pOut->tag = LW_TASK_GET_TYPES_SUCCESS;
pOut->data = pResult;
pResult = NULL;
cleanup:
LW_SAFE_FREE_MEMORY(pStatusResponse);
if (pResult)
{
LwFreeMemory(pResult);
}
return status;
error:
goto cleanup;
}
static
LWMsgStatus
LwTaskDaemonIpcGetStatus(
LWMsgCall* pCall, /* IN */
const LWMsgParams* pIn, /* IN */
LWMsgParams* pOut, /* OUT */
void* pData /* IN */
)
{
DWORD dwError = 0;
LWMsgStatus status = LWMSG_STATUS_SUCCESS;
PLW_TASK_STATUS_REPLY pStatusResponse = NULL;
PLW_TASK_STATUS pResult = NULL;
BAIL_ON_INVALID_POINTER(pIn->data);
dwError = LwAllocateMemory(
sizeof(LW_TASK_STATUS_REPLY),
(PVOID*)&pStatusResponse);
BAIL_ON_LW_TASK_ERROR(dwError);
dwError = LwAllocateMemory(sizeof(LW_TASK_STATUS), (PVOID*)&pResult);
BAIL_ON_LW_TASK_ERROR(dwError);
dwError = LwTaskSrvGetStatus((PCSTR)pIn->data, pResult);
if (dwError)
{
pStatusResponse->dwError = dwError;
pOut->tag = LW_TASK_GET_STATUS_FAILED;
pOut->data = pStatusResponse;
pStatusResponse = NULL;
dwError = 0;
goto cleanup;
}
pOut->tag = LW_TASK_GET_STATUS_SUCCESS;
pOut->data = pResult;
pResult = NULL;
cleanup:
LW_SAFE_FREE_MEMORY(pStatusResponse);
if (pResult)
{
LwFreeMemory(pResult);
}
return status;
error:
goto cleanup;
}
static
LWMsgStatus
LwTaskDaemonIpcCreate(
LWMsgCall* pCall, /* IN */
const LWMsgParams* pIn, /* IN */
LWMsgParams* pOut, /* OUT */
void* pData /* IN */
)
{
DWORD dwError = 0;
LWMsgStatus status = LWMSG_STATUS_SUCCESS;
PLW_TASK_STATUS_REPLY pStatusResponse = NULL;
PLW_TASK_IPC_CREATE_ARGS pCreateArgs = NULL;
PSTR pszTaskId = NULL;
BAIL_ON_INVALID_POINTER(pIn->data);
dwError = LwAllocateMemory(
sizeof(LW_TASK_STATUS_REPLY),
(PVOID*)&pStatusResponse);
BAIL_ON_LW_TASK_ERROR(dwError);
pCreateArgs = (PLW_TASK_IPC_CREATE_ARGS)pIn->data;
dwError = LwTaskSrvCreate(
pCreateArgs->taskType,
pCreateArgs->pArgArray,
pCreateArgs->dwNumArgs,
&pszTaskId);
/* Transmit failure to client but do not bail out of dispatch loop */
if (dwError)
{
pStatusResponse->dwError = dwError;
pOut->tag = LW_TASK_CREATE_FAILED;
pOut->data = pStatusResponse;
dwError = 0;
goto cleanup;
}
pOut->tag = LW_TASK_CREATE_SUCCESS;
pOut->data = pszTaskId;
pszTaskId = NULL;
cleanup:
LW_SAFE_FREE_MEMORY(pStatusResponse);
LW_SAFE_FREE_MEMORY(pszTaskId);
return status;
error:
goto cleanup;
}
static
LWMsgStatus
LwTaskDaemonIpcGetSchema(
LWMsgCall* pCall, /* IN */
const LWMsgParams* pIn, /* IN */
LWMsgParams* pOut, /* OUT */
void* pData /* IN */
)
{
DWORD dwError = 0;
LWMsgStatus status = LWMSG_STATUS_SUCCESS;
PLW_TASK_STATUS_REPLY pStatusResponse = NULL;
PLW_TASK_IPC_SCHEMA pResult = NULL;
BAIL_ON_INVALID_POINTER(pIn->data);
dwError = LwAllocateMemory(
sizeof(LW_TASK_STATUS_REPLY),
(PVOID*)&pStatusResponse);
BAIL_ON_LW_TASK_ERROR(dwError);
dwError = LwAllocateMemory(sizeof(LW_TASK_IPC_SCHEMA), (PVOID*)&pResult);
BAIL_ON_LW_TASK_ERROR(dwError);
dwError = LwTaskSrvGetSchema(
((PLW_TASK_IPC_GET_SCHEMA)pIn->data)->taskType,
&pResult->pArgInfoArray,
&pResult->dwNumArgInfos);
if (dwError)
{
pStatusResponse->dwError = dwError;
pOut->tag = LW_TASK_GET_SCHEMA_FAILED;
pOut->data = pStatusResponse;
pStatusResponse = NULL;
dwError = 0;
goto cleanup;
}
pOut->tag = LW_TASK_GET_SCHEMA_SUCCESS;
pOut->data = pResult;
pResult = NULL;
cleanup:
LW_SAFE_FREE_MEMORY(pStatusResponse);
if (pResult)
{
LwFreeMemory(pResult);
}
return status;
error:
goto cleanup;
}
static
LWMsgStatus
LwTaskDaemonIpcEnum(
LWMsgCall* pCall, /* IN */
const LWMsgParams* pIn, /* IN */
LWMsgParams* pOut, /* OUT */
void* pData /* IN */
)
{
DWORD dwError = 0;
LWMsgStatus status = LWMSG_STATUS_SUCCESS;
PLW_TASK_STATUS_REPLY pStatusResponse = NULL;
PLW_TASK_IPC_ENUM_REQUEST pRequest = NULL;
PLW_TASK_IPC_ENUM_RESPONSE pResult = NULL;
BAIL_ON_INVALID_POINTER(pIn->data);
dwError = LwAllocateMemory(
sizeof(LW_TASK_STATUS_REPLY),
(PVOID*)&pStatusResponse);
BAIL_ON_LW_TASK_ERROR(dwError);
dwError = LwAllocateMemory(
sizeof(LW_TASK_IPC_ENUM_RESPONSE),
(PVOID*)&pResult);
BAIL_ON_LW_TASK_ERROR(dwError);
pRequest = (PLW_TASK_IPC_ENUM_REQUEST)pIn->data;
pResult->dwResume = pRequest->dwResume;
dwError = LwTaskSrvEnum(
pRequest->taskType,
&pResult->dwTotalTaskInfos,
&pResult->dwNumTaskInfos,
&pResult->pTaskInfoArray,
&pResult->dwResume);
if (dwError)
{
pStatusResponse->dwError = dwError;
pOut->tag = LW_TASK_ENUM_FAILED;
pOut->data = pStatusResponse;
pStatusResponse = NULL;
dwError = 0;
goto cleanup;
}
pOut->tag = LW_TASK_ENUM_SUCCESS;
pOut->data = pResult;
pResult = NULL;
cleanup:
LW_SAFE_FREE_MEMORY(pStatusResponse);
if (pResult)
{
LwFreeMemory(pResult);
}
return status;
error:
goto cleanup;
}
|
589777.c | /* $NetBSD: main.c,v 1.4 1997/10/10 13:36:04 lukem Exp $ */
/*
* Copyright (c) 1994
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Ralph Campbell.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#ifndef lint
__COPYRIGHT("@(#) Copyright (c) 1994\n\
The Regents of the University of California. All rights reserved.\n");
#endif /* not lint */
#ifndef lint
#if 0
static char sccsid[] = "@(#)main.c 8.4 (Berkeley) 5/4/95";
#else
__RCSID("$NetBSD: main.c,v 1.4 1997/10/10 13:36:04 lukem Exp $");
#endif
#endif /* not lint */
#include <curses.h>
#include <err.h>
#include <signal.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "gomoku.h"
#define USER 0 /* get input from standard input */
#define PROGRAM 1 /* get input from program */
#define INPUTF 2 /* get input from a file */
int interactive = 1; /* true if interactive */
int debug; /* true if debugging */
int test; /* both moves come from 1: input, 2: computer */
char *prog; /* name of program */
FILE *debugfp; /* file for debug output */
FILE *inputfp; /* file for debug input */
char pdir[4] = "-\\|/";
char fmtbuf[128];
struct spotstr board[BAREA]; /* info for board */
struct combostr frames[FAREA]; /* storage for all frames */
struct combostr *sortframes[2]; /* sorted list of non-empty frames */
u_char overlap[FAREA * FAREA]; /* true if frame [a][b] overlap */
short intersect[FAREA * FAREA]; /* frame [a][b] intersection */
int movelog[BSZ * BSZ]; /* log of all the moves */
int movenum; /* current move number */
char *plyr[2]; /* who's who */
int main __P((int, char *[]));
int
main(argc, argv)
int argc;
char **argv;
{
char buf[128];
int color, curmove, i, ch;
int input[2];
static char *fmt[2] = {
"%3d %-6s",
"%3d %-6s"
};
color = curmove = 0;
prog = strrchr(argv[0], '/');
if (prog)
prog++;
else
prog = argv[0];
while ((ch = getopt(argc, argv, "bcdD:u")) != -1) {
switch (ch) {
case 'b': /* background */
interactive = 0;
break;
case 'd': /* debugging */
debug++;
break;
case 'D': /* log debug output to file */
if ((debugfp = fopen(optarg, "w")) == NULL)
err(1, "%s", optarg);
break;
case 'u': /* testing: user verses user */
test = 1;
break;
case 'c': /* testing: computer verses computer */
test = 2;
break;
}
}
argc -= optind;
argv += optind;
if (argc) {
if ((inputfp = fopen(*argv, "r")) == NULL)
err(1, "%s", *argv);
}
if (!debug)
#ifdef SVR4
srand(time(0));
#else
srandom(time(0));
#endif
if (interactive)
cursinit(); /* initialize curses */
again:
bdinit(board); /* initialize board contents */
if (interactive) {
plyr[BLACK] = plyr[WHITE] = "???";
bdisp_init(); /* initialize display of board */
#ifdef DEBUG
signal(SIGINT, whatsup);
#else
signal(SIGINT, quitsig);
#endif
if (inputfp == NULL && test == 0) {
for (;;) {
ask("black or white? ");
getline(buf, sizeof(buf));
if (buf[0] == 'b' || buf[0] == 'B') {
color = BLACK;
break;
}
if (buf[0] == 'w' || buf[0] == 'W') {
color = WHITE;
break;
}
move(22, 0);
printw("Black moves first. Please enter `black' or `white'\n");
}
move(22, 0);
clrtoeol();
}
} else {
setbuf(stdout, 0);
getline(buf, sizeof(buf));
if (strcmp(buf, "black") == 0)
color = BLACK;
else if (strcmp(buf, "white") == 0)
color = WHITE;
else {
sprintf(fmtbuf,
"Huh? Expected `black' or `white', got `%s'\n",
buf);
panic(fmtbuf);
}
}
if (inputfp) {
input[BLACK] = INPUTF;
input[WHITE] = INPUTF;
} else {
switch (test) {
case 0: /* user verses program */
input[color] = USER;
input[!color] = PROGRAM;
break;
case 1: /* user verses user */
input[BLACK] = USER;
input[WHITE] = USER;
break;
case 2: /* program verses program */
input[BLACK] = PROGRAM;
input[WHITE] = PROGRAM;
break;
}
}
if (interactive) {
plyr[BLACK] = input[BLACK] == USER ? "you" : prog;
plyr[WHITE] = input[WHITE] == USER ? "you" : prog;
bdwho(1);
}
for (color = BLACK; ; color = !color) {
top:
switch (input[color]) {
case INPUTF: /* input comes from a file */
curmove = readinput(inputfp);
if (curmove != ILLEGAL)
break;
switch (test) {
case 0: /* user verses program */
input[color] = USER;
input[!color] = PROGRAM;
break;
case 1: /* user verses user */
input[BLACK] = USER;
input[WHITE] = USER;
break;
case 2: /* program verses program */
input[BLACK] = PROGRAM;
input[WHITE] = PROGRAM;
break;
}
plyr[BLACK] = input[BLACK] == USER ? "you" : prog;
plyr[WHITE] = input[WHITE] == USER ? "you" : prog;
bdwho(1);
goto top;
case USER: /* input comes from standard input */
getinput:
if (interactive)
ask("move? ");
if (!getline(buf, sizeof(buf))) {
curmove = RESIGN;
break;
}
if (buf[0] == '\0')
goto getinput;
curmove = ctos(buf);
if (interactive) {
if (curmove == SAVE) {
FILE *fp;
ask("save file name? ");
(void)getline(buf, sizeof(buf));
if ((fp = fopen(buf, "w")) == NULL) {
log("cannot create save file");
goto getinput;
}
for (i = 0; i < movenum - 1; i++)
fprintf(fp, "%s\n",
stoc(movelog[i]));
fclose(fp);
goto getinput;
}
if (curmove != RESIGN &&
board[curmove].s_occ != EMPTY) {
log("Illegal move");
goto getinput;
}
}
break;
case PROGRAM: /* input comes from the program */
curmove = pickmove(color);
break;
}
if (interactive) {
sprintf(fmtbuf, fmt[color], movenum, stoc(curmove));
log(fmtbuf);
}
if ((i = makemove(color, curmove)) != MOVEOK)
break;
if (interactive)
bdisp();
}
if (interactive) {
move(22, 0);
switch (i) {
case WIN:
if (input[color] == PROGRAM)
addstr("Ha ha, I won");
else
addstr("Rats! you won");
break;
case TIE:
addstr("Wow! its a tie");
break;
case ILLEGAL:
addstr("Illegal move");
break;
}
clrtoeol();
bdisp();
if (i != RESIGN) {
replay:
ask("replay? ");
if (getline(buf, sizeof(buf)) &&
(buf[0] == 'y' || buf[0] == 'Y'))
goto again;
if (strcmp(buf, "save") == 0) {
FILE *fp;
ask("save file name? ");
(void)getline(buf, sizeof(buf));
if ((fp = fopen(buf, "w")) == NULL) {
log("cannot create save file");
goto replay;
}
for (i = 0; i < movenum - 1; i++)
fprintf(fp, "%s\n",
stoc(movelog[i]));
fclose(fp);
goto replay;
}
}
}
quit();
/* NOTREACHED */
return(0);
}
int
readinput(fp)
FILE *fp;
{
char *cp;
int c;
cp = fmtbuf;
while ((c = getc(fp)) != EOF && c != '\n')
*cp++ = c;
*cp = '\0';
return (ctos(fmtbuf));
}
#ifdef DEBUG
/*
* Handle strange situations.
*/
void
whatsup(signum)
int signum;
{
int i, pnum, n, s1, s2, d1, d2;
struct spotstr *sp;
FILE *fp;
char *str;
struct elist *ep;
struct combostr *cbp;
if (!interactive)
quit();
top:
ask("cmd? ");
if (!getline(fmtbuf, sizeof(fmtbuf)))
quit();
switch (*fmtbuf) {
case '\0':
goto top;
case 'q': /* conservative quit */
quit();
case 'd': /* set debug level */
debug = fmtbuf[1] - '0';
sprintf(fmtbuf, "Debug set to %d", debug);
dlog(fmtbuf);
sleep(1);
case 'c':
break;
case 'b': /* back up a move */
if (movenum > 1) {
movenum--;
board[movelog[movenum - 1]].s_occ = EMPTY;
bdisp();
}
goto top;
case 's': /* suggest a move */
i = fmtbuf[1] == 'b' ? BLACK : WHITE;
sprintf(fmtbuf, "suggest %c %s", i == BLACK ? 'B' : 'W',
stoc(pickmove(i)));
dlog(fmtbuf);
goto top;
case 'f': /* go forward a move */
board[movelog[movenum - 1]].s_occ = movenum & 1 ? BLACK : WHITE;
movenum++;
bdisp();
goto top;
case 'l': /* print move history */
if (fmtbuf[1] == '\0') {
for (i = 0; i < movenum - 1; i++)
dlog(stoc(movelog[i]));
goto top;
}
if ((fp = fopen(fmtbuf + 1, "w")) == NULL)
goto top;
for (i = 0; i < movenum - 1; i++) {
fprintf(fp, "%s", stoc(movelog[i]));
if (++i < movenum - 1)
fprintf(fp, " %s\n", stoc(movelog[i]));
else
fputc('\n', fp);
}
bdump(fp);
fclose(fp);
goto top;
case 'o':
n = 0;
for (str = fmtbuf + 1; *str; str++)
if (*str == ',') {
for (d1 = 0; d1 < 4; d1++)
if (str[-1] == pdir[d1])
break;
str[-1] = '\0';
sp = &board[s1 = ctos(fmtbuf + 1)];
n = (sp->s_frame[d1] - frames) * FAREA;
*str++ = '\0';
break;
}
sp = &board[s2 = ctos(str)];
while (*str)
str++;
for (d2 = 0; d2 < 4; d2++)
if (str[-1] == pdir[d2])
break;
n += sp->s_frame[d2] - frames;
str = fmtbuf;
sprintf(str, "overlap %s%c,", stoc(s1), pdir[d1]);
str += strlen(str);
sprintf(str, "%s%c = %x", stoc(s2), pdir[d2], overlap[n]);
dlog(fmtbuf);
goto top;
case 'p':
sp = &board[i = ctos(fmtbuf + 1)];
sprintf(fmtbuf, "V %s %x/%d %d %x/%d %d %d %x", stoc(i),
sp->s_combo[BLACK].s, sp->s_level[BLACK],
sp->s_nforce[BLACK],
sp->s_combo[WHITE].s, sp->s_level[WHITE],
sp->s_nforce[WHITE], sp->s_wval, sp->s_flg);
dlog(fmtbuf);
sprintf(fmtbuf, "FB %s %x %x %x %x", stoc(i),
sp->s_fval[BLACK][0].s, sp->s_fval[BLACK][1].s,
sp->s_fval[BLACK][2].s, sp->s_fval[BLACK][3].s);
dlog(fmtbuf);
sprintf(fmtbuf, "FW %s %x %x %x %x", stoc(i),
sp->s_fval[WHITE][0].s, sp->s_fval[WHITE][1].s,
sp->s_fval[WHITE][2].s, sp->s_fval[WHITE][3].s);
dlog(fmtbuf);
goto top;
case 'e': /* e {b|w} [0-9] spot */
str = fmtbuf + 1;
if (*str >= '0' && *str <= '9')
n = *str++ - '0';
else
n = 0;
sp = &board[i = ctos(str)];
for (ep = sp->s_empty; ep; ep = ep->e_next) {
cbp = ep->e_combo;
if (n) {
if (cbp->c_nframes > n)
continue;
if (cbp->c_nframes != n)
break;
}
printcombo(cbp, fmtbuf);
dlog(fmtbuf);
}
goto top;
default:
syntax:
dlog("Options are:");
dlog("q - quit");
dlog("c - continue");
dlog("d# - set debug level to #");
dlog("p# - print values at #");
goto top;
}
}
#endif /* DEBUG */
/*
* Display debug info.
*/
void
dlog(str)
char *str;
{
if (debugfp)
fprintf(debugfp, "%s\n", str);
if (interactive)
dislog(str);
else
fprintf(stderr, "%s\n", str);
}
void
log(str)
char *str;
{
if (debugfp)
fprintf(debugfp, "%s\n", str);
if (interactive)
dislog(str);
else
printf("%s\n", str);
}
void
quit()
{
if (interactive) {
bdisp(); /* show final board */
cursfini();
}
exit(0);
}
void
quitsig(dummy)
int dummy;
{
quit();
}
/*
* Die gracefully.
*/
void
panic(str)
char *str;
{
fprintf(stderr, "%s: %s\n", prog, str);
fputs("resign\n", stdout);
quit();
}
|
501873.c | #include <stdio.h>
#include <A2C.h>
#include "utility.h"
#define BUFFER_LENGTH 2048
int MemoryCheck()
{
#ifdef _MSC_VER
_CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
_CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
if (_CrtDumpMemoryLeaks()) {
return 1;
}
#endif // _MSC_VER
return 0;
}
A2C_ERROR DecodeFromFile(PVOID * ppv, PC_A2C_DESCRIPTOR pdesc, int flags, char const * szFileName, int fDER)
{
unsigned char buffer[BUFFER_LENGTH];
int cb = 0;
A2C_CONTEXT* pcxt = NULL;
A2C_ERROR err = A2C_ERROR_Success;
FILE * fp;
fp = fopen(szFileName, "rb");
if (fp == NULL) return A2C_ERROR_ICE;
while (1) {
cb = fread(buffer, 1, sizeof(buffer), fp);
if (cb < 0) {
err = A2C_ERROR_malformedEncoding;
break;
}
if (cb == 0) {
break;
}
if (fDER) {
err = A2C_DecodeDer( ppv, pdesc, flags, &pcxt, buffer, cb );
}
else {
err = A2C_DecodeBer( ppv, pdesc, flags, &pcxt, buffer, cb );
}
if ((err != A2C_ERROR_Success) && (err != A2C_ERROR_needMoreData)) {
break;
}
flags |= A2C_FLAGS_MORE_DATA;
}
if (pcxt != NULL) A2C_FreeContext(pcxt);
fclose(fp);
return err;
}
A2C_ERROR DecodeFromFileBy1(PVOID * ppv, PC_A2C_DESCRIPTOR pdesc, int flags, char const * szFileName)
{
unsigned char buffer[1];
int cb = 0;
A2C_CONTEXT* pcxt = NULL;
A2C_ERROR err = A2C_ERROR_Success;
FILE * fp;
fp = fopen(szFileName, "rb");
if (fp == NULL) return A2C_ERROR_ICE;
while (1) {
cb = fread(buffer, 1, sizeof(buffer), fp);
if (cb < 0) {
err = A2C_ERROR_malformedEncoding;
break;
}
if (cb == 0) {
break;
}
err = A2C_DecodeBer( ppv, pdesc, flags, &pcxt, buffer, cb );
if ((err != A2C_ERROR_Success) && (err != A2C_ERROR_needMoreData)) {
break;
}
flags |= A2C_FLAGS_MORE_DATA;
}
if (pcxt != NULL) A2C_FreeContext(pcxt);
fclose(fp);
return err;
}
A2C_ERROR EncodeToFile(PCVOID pv, PC_A2C_DESCRIPTOR pdesc, int flags, int fDER, char const * szFileName)
{
int cb;
A2C_ERROR err;
FILE * fp = NULL;
PBYTE pb = NULL;
A2C_STREAM * pstm = NULL;
/*
* Create output buffer
*/
err = A2C_CreateMemoryStream(&pstm);
if (err != A2C_ERROR_Success) return err;
/*
* Try and encode the object
*/
if (fDER) {
err = A2C_EncodeDer(pv, pdesc, flags, NULL, pstm);
}
else {
err = A2C_EncodeBer(pv, pdesc, flags, NULL, pstm);
}
if (err != A2C_ERROR_Success) {
goto ErrorExit;
}
/*
* Open the file
*/
fp = fopen(szFileName, "wb");
if (fp == NULL) {
err = A2C_ERROR_ICE;
goto ErrorExit;
}
/*
* Get the buffer and write to file
*/
err = A2C_GetDataFromStream(pstm, &pb, &cb);
if (err != A2C_ERROR_Success) {
goto ErrorExit;
}
if (fwrite(pb, cb, 1, fp) != cb) {
err = A2C_ERROR_ICE;
}
/*
* Cleanup and go home
*/
ErrorExit:
if (pstm != NULL) pstm->pfnFree(pstm);
if (pb != NULL) free(pb);
if (fp != NULL) fclose(fp);
return err;
}
A2C_ERROR EncodeCompareToFile(PCVOID pv, PC_A2C_DESCRIPTOR pdesc, int flags, int fDER, char const * szFileName)
{
BYTE buffer[BUFFER_LENGTH];
int cb;
int cbStm;
A2C_ERROR err = A2C_ERROR_Success;
FILE * fp = NULL;
A2C_STREAM * pstm = NULL;
PBYTE pbStm = NULL;
PBYTE pbStmRoot = NULL;
/*
* Create output buffer
*/
err = A2C_CreateMemoryStream(&pstm);
if (err != A2C_ERROR_Success) return err;
/*
* Try and encode the object
*/
if (fDER) {
err = A2C_EncodeDer(pv, pdesc, flags, NULL, pstm);
}
else {
err = A2C_EncodeBer(pv, pdesc, flags, NULL, pstm);
}
if (err != A2C_ERROR_Success) goto ErrorExit;
/*
* Grab the buffer from the stream
*/
err = A2C_GetDataFromStream(pstm, &pbStmRoot, &cbStm);
if (err != A2C_ERROR_Success) goto ErrorExit;
pbStm = pbStmRoot;
/*
* Open the file
*/
fp = fopen(szFileName, "rb");
if (fp == NULL) {
err = A2C_ERROR_ICE;
goto ErrorExit;
}
/*
* Now start comparing the file
*/
while (1) {
cb = fread(buffer, 1, sizeof(buffer), fp);
if (cb < 0) {
err = A2C_ERROR_malformedEncoding;
goto ErrorExit;
}
if (cb == 0) {
if (cbStm != 0) {
err = A2C_ERROR_malformedEncoding;
goto ErrorExit;
}
err = A2C_ERROR_Success;
goto ErrorExit;
}
if (cb > cbStm) {
err = A2C_ERROR_malformedEncoding;
goto ErrorExit;
}
if (memcmp(buffer, pbStm, cb) != 0) {
err = A2C_ERROR_malformedEncoding;
goto ErrorExit;
}
pbStm += cb;
cbStm -= cb;
}
ErrorExit:
if (fp != NULL) fclose(fp);
if (pbStmRoot != NULL) free(pbStmRoot);
if (pstm != NULL) pstm->pfnFree(pstm);
return err;
}
A2C_ERROR ValidateCompareToFile(PCVOID pv, PC_A2C_DESCRIPTOR pdesc, char const * szFileName)
{
unsigned char buffer[BUFFER_LENGTH];
int cb;
int cbStm;
A2C_ERROR err;
int f = FALSE;
FILE * fp = NULL;
PBYTE pbStm = NULL;
PBYTE pbStmRoot = NULL;
A2C_STREAM * pstm = NULL;
A2C_CONTEXT * pcxt = NULL;
/*
* Create the output buffer
*/
err = A2C_CreateMemoryStream(&pstm);
if (err != A2C_ERROR_Success) return err;
/*
* Loop until we are finished doing the validate
*/
do {
err = A2C_Validate2(pv, pdesc, &pcxt, &f, pstm);
if (err != A2C_ERROR_Success) goto ErrorExit;
} while (!f);
/*
* Grab the buffer from the stream
*/
err = A2C_GetDataFromStream(pstm, &pbStmRoot, &cbStm);
if (err != A2C_ERROR_Success) goto ErrorExit;
pbStm = pbStmRoot;
/*
* Open the file
*/
fp = fopen(szFileName, "rb");
if (fp == NULL) {
err = A2C_ERROR_ICE;
goto ErrorExit;
}
/*
* Now start comparing the file
*/
while (1) {
cb = fread(buffer, 1, sizeof(buffer), fp);
if (cb < 0) {
err = A2C_ERROR_malformedEncoding;
goto ErrorExit;
}
if (cb == 0) {
if (cbStm != 0) {
err = A2C_ERROR_malformedEncoding;
goto ErrorExit;
}
err = A2C_ERROR_Success;
goto ErrorExit;
}
if (cb > cbStm) {
err = A2C_ERROR_malformedEncoding;
goto ErrorExit;
}
if (memcmp(buffer, pbStm, cb) != 0) {
err = A2C_ERROR_malformedEncoding;
goto ErrorExit;
}
pbStm += cb;
cbStm -= cb;
}
ErrorExit:
if (fp != NULL) fclose(fp);
if (pbStmRoot != NULL) free(pbStmRoot);
if (pstm != NULL) pstm->pfnFree(pstm);
return err;
}
|
76803.c | /*
** EPITECH PROJECT, 2017
** my_printf
** File description:
** my_printf
*/
#include "my.h"
void init_tab_fonct(int (**tab_fonct)())
{
tab_fonct[0] = my_putstr;
tab_fonct[1] = my_put_nbr;
tab_fonct[2] = my_put_nbr;
tab_fonct[3] = my_put_nbr_octal;
tab_fonct[4] = my_put_nbr_hexa;
tab_fonct[5] = my_put_nbr_hexa_cap;
tab_fonct[6] = my_put_nbr_unsigned;
tab_fonct[7] = my_printable;
tab_fonct[8] = my_print_pointer;
tab_fonct[9] = my_put_nbr_binary;
tab_fonct[10] = my_putchar;
tab_fonct[11] = my_put_nbr_long;
}
int parse_format(t_flags *f)
{
for (int a = 0; f->format[a] != '\0'; a++) {
f->nb_space = 0;
f->nb_format = -1;
if (f->format[a] == '%' && f->format[a + 1] == '\0')
return (0);
if (f->format[a] == '%' && if_flag(f->format[a + 1])) {
f->nb_format = check_format(f->format[a + 1]);
a++;
}
if (f->nb_format != - 1 && f->nb_format != 12)
f->nb_letter += (*f->tab_fonct[f->nb_format]) \
(va_arg(f->arg, void *));
else
f->nb_letter += my_putchar(f->format[a]);
}
return (f->nb_letter);
}
int my_printf(const char *format, ...)
{
t_flags *f;
f = malloc(sizeof(*f));
f->format = malloc(sizeof(char) * my_strlen(format) + 1);
f->format = format;
f->nb_space = 0;
f->s_nb_letter = 0;
f->nb_format = 0;
va_start(f->arg, format);
init_tab_fonct(f->tab_fonct);
f->nb_letter = parse_format(f);
va_end(f->arg);
return (f->nb_letter);
}
|
349181.c | #include "ring.h"
/*
OpenGL 2.1 Extension
Copyright (c) 2017 Mahmoud Fayed <[email protected]>
*/
#include <GL/glew.h>
#include <GL/glut.h>
RING_FUNC(ring_get_gl_zero)
{
RING_API_RETNUMBER(GL_ZERO);
}
RING_FUNC(ring_get_gl_false)
{
RING_API_RETNUMBER(GL_FALSE);
}
RING_FUNC(ring_get_gl_logic_op)
{
RING_API_RETNUMBER(GL_LOGIC_OP);
}
RING_FUNC(ring_get_gl_none)
{
RING_API_RETNUMBER(GL_NONE);
}
RING_FUNC(ring_get_gl_texture_components)
{
RING_API_RETNUMBER(GL_TEXTURE_COMPONENTS);
}
RING_FUNC(ring_get_gl_no_error)
{
RING_API_RETNUMBER(GL_NO_ERROR);
}
RING_FUNC(ring_get_gl_points)
{
RING_API_RETNUMBER(GL_POINTS);
}
RING_FUNC(ring_get_gl_current_bit)
{
RING_API_RETNUMBER(GL_CURRENT_BIT);
}
RING_FUNC(ring_get_gl_true)
{
RING_API_RETNUMBER(GL_TRUE);
}
RING_FUNC(ring_get_gl_one)
{
RING_API_RETNUMBER(GL_ONE);
}
RING_FUNC(ring_get_gl_client_pixel_store_bit)
{
RING_API_RETNUMBER(GL_CLIENT_PIXEL_STORE_BIT);
}
RING_FUNC(ring_get_gl_lines)
{
RING_API_RETNUMBER(GL_LINES);
}
RING_FUNC(ring_get_gl_line_loop)
{
RING_API_RETNUMBER(GL_LINE_LOOP);
}
RING_FUNC(ring_get_gl_point_bit)
{
RING_API_RETNUMBER(GL_POINT_BIT);
}
RING_FUNC(ring_get_gl_client_vertex_array_bit)
{
RING_API_RETNUMBER(GL_CLIENT_VERTEX_ARRAY_BIT);
}
RING_FUNC(ring_get_gl_line_strip)
{
RING_API_RETNUMBER(GL_LINE_STRIP);
}
RING_FUNC(ring_get_gl_line_bit)
{
RING_API_RETNUMBER(GL_LINE_BIT);
}
RING_FUNC(ring_get_gl_triangles)
{
RING_API_RETNUMBER(GL_TRIANGLES);
}
RING_FUNC(ring_get_gl_triangle_strip)
{
RING_API_RETNUMBER(GL_TRIANGLE_STRIP);
}
RING_FUNC(ring_get_gl_triangle_fan)
{
RING_API_RETNUMBER(GL_TRIANGLE_FAN);
}
RING_FUNC(ring_get_gl_quads)
{
RING_API_RETNUMBER(GL_QUADS);
}
RING_FUNC(ring_get_gl_quad_strip)
{
RING_API_RETNUMBER(GL_QUAD_STRIP);
}
RING_FUNC(ring_get_gl_polygon_bit)
{
RING_API_RETNUMBER(GL_POLYGON_BIT);
}
RING_FUNC(ring_get_gl_polygon)
{
RING_API_RETNUMBER(GL_POLYGON);
}
RING_FUNC(ring_get_gl_polygon_stipple_bit)
{
RING_API_RETNUMBER(GL_POLYGON_STIPPLE_BIT);
}
RING_FUNC(ring_get_gl_pixel_mode_bit)
{
RING_API_RETNUMBER(GL_PIXEL_MODE_BIT);
}
RING_FUNC(ring_get_gl_lighting_bit)
{
RING_API_RETNUMBER(GL_LIGHTING_BIT);
}
RING_FUNC(ring_get_gl_fog_bit)
{
RING_API_RETNUMBER(GL_FOG_BIT);
}
RING_FUNC(ring_get_gl_depth_buffer_bit)
{
RING_API_RETNUMBER(GL_DEPTH_BUFFER_BIT);
}
RING_FUNC(ring_get_gl_accum)
{
RING_API_RETNUMBER(GL_ACCUM);
}
RING_FUNC(ring_get_gl_load)
{
RING_API_RETNUMBER(GL_LOAD);
}
RING_FUNC(ring_get_gl_return)
{
RING_API_RETNUMBER(GL_RETURN);
}
RING_FUNC(ring_get_gl_mult)
{
RING_API_RETNUMBER(GL_MULT);
}
RING_FUNC(ring_get_gl_add)
{
RING_API_RETNUMBER(GL_ADD);
}
RING_FUNC(ring_get_gl_never)
{
RING_API_RETNUMBER(GL_NEVER);
}
RING_FUNC(ring_get_gl_accum_buffer_bit)
{
RING_API_RETNUMBER(GL_ACCUM_BUFFER_BIT);
}
RING_FUNC(ring_get_gl_less)
{
RING_API_RETNUMBER(GL_LESS);
}
RING_FUNC(ring_get_gl_equal)
{
RING_API_RETNUMBER(GL_EQUAL);
}
RING_FUNC(ring_get_gl_lequal)
{
RING_API_RETNUMBER(GL_LEQUAL);
}
RING_FUNC(ring_get_gl_greater)
{
RING_API_RETNUMBER(GL_GREATER);
}
RING_FUNC(ring_get_gl_notequal)
{
RING_API_RETNUMBER(GL_NOTEQUAL);
}
RING_FUNC(ring_get_gl_gequal)
{
RING_API_RETNUMBER(GL_GEQUAL);
}
RING_FUNC(ring_get_gl_always)
{
RING_API_RETNUMBER(GL_ALWAYS);
}
RING_FUNC(ring_get_gl_src_color)
{
RING_API_RETNUMBER(GL_SRC_COLOR);
}
RING_FUNC(ring_get_gl_one_minus_src_color)
{
RING_API_RETNUMBER(GL_ONE_MINUS_SRC_COLOR);
}
RING_FUNC(ring_get_gl_src_alpha)
{
RING_API_RETNUMBER(GL_SRC_ALPHA);
}
RING_FUNC(ring_get_gl_one_minus_src_alpha)
{
RING_API_RETNUMBER(GL_ONE_MINUS_SRC_ALPHA);
}
RING_FUNC(ring_get_gl_dst_alpha)
{
RING_API_RETNUMBER(GL_DST_ALPHA);
}
RING_FUNC(ring_get_gl_one_minus_dst_alpha)
{
RING_API_RETNUMBER(GL_ONE_MINUS_DST_ALPHA);
}
RING_FUNC(ring_get_gl_dst_color)
{
RING_API_RETNUMBER(GL_DST_COLOR);
}
RING_FUNC(ring_get_gl_one_minus_dst_color)
{
RING_API_RETNUMBER(GL_ONE_MINUS_DST_COLOR);
}
RING_FUNC(ring_get_gl_src_alpha_saturate)
{
RING_API_RETNUMBER(GL_SRC_ALPHA_SATURATE);
}
RING_FUNC(ring_get_gl_stencil_buffer_bit)
{
RING_API_RETNUMBER(GL_STENCIL_BUFFER_BIT);
}
RING_FUNC(ring_get_gl_front_left)
{
RING_API_RETNUMBER(GL_FRONT_LEFT);
}
RING_FUNC(ring_get_gl_front_right)
{
RING_API_RETNUMBER(GL_FRONT_RIGHT);
}
RING_FUNC(ring_get_gl_back_left)
{
RING_API_RETNUMBER(GL_BACK_LEFT);
}
RING_FUNC(ring_get_gl_back_right)
{
RING_API_RETNUMBER(GL_BACK_RIGHT);
}
RING_FUNC(ring_get_gl_front)
{
RING_API_RETNUMBER(GL_FRONT);
}
RING_FUNC(ring_get_gl_back)
{
RING_API_RETNUMBER(GL_BACK);
}
RING_FUNC(ring_get_gl_left)
{
RING_API_RETNUMBER(GL_LEFT);
}
RING_FUNC(ring_get_gl_right)
{
RING_API_RETNUMBER(GL_RIGHT);
}
RING_FUNC(ring_get_gl_front_and_back)
{
RING_API_RETNUMBER(GL_FRONT_AND_BACK);
}
RING_FUNC(ring_get_gl_aux0)
{
RING_API_RETNUMBER(GL_AUX0);
}
RING_FUNC(ring_get_gl_aux1)
{
RING_API_RETNUMBER(GL_AUX1);
}
RING_FUNC(ring_get_gl_aux2)
{
RING_API_RETNUMBER(GL_AUX2);
}
RING_FUNC(ring_get_gl_aux3)
{
RING_API_RETNUMBER(GL_AUX3);
}
RING_FUNC(ring_get_gl_invalid_enum)
{
RING_API_RETNUMBER(GL_INVALID_ENUM);
}
RING_FUNC(ring_get_gl_invalid_value)
{
RING_API_RETNUMBER(GL_INVALID_VALUE);
}
RING_FUNC(ring_get_gl_invalid_operation)
{
RING_API_RETNUMBER(GL_INVALID_OPERATION);
}
RING_FUNC(ring_get_gl_stack_overflow)
{
RING_API_RETNUMBER(GL_STACK_OVERFLOW);
}
RING_FUNC(ring_get_gl_stack_underflow)
{
RING_API_RETNUMBER(GL_STACK_UNDERFLOW);
}
RING_FUNC(ring_get_gl_out_of_memory)
{
RING_API_RETNUMBER(GL_OUT_OF_MEMORY);
}
RING_FUNC(ring_get_gl_2d)
{
RING_API_RETNUMBER(GL_2D);
}
RING_FUNC(ring_get_gl_3d)
{
RING_API_RETNUMBER(GL_3D);
}
RING_FUNC(ring_get_gl_3d_color)
{
RING_API_RETNUMBER(GL_3D_COLOR);
}
RING_FUNC(ring_get_gl_3d_color_texture)
{
RING_API_RETNUMBER(GL_3D_COLOR_TEXTURE);
}
RING_FUNC(ring_get_gl_4d_color_texture)
{
RING_API_RETNUMBER(GL_4D_COLOR_TEXTURE);
}
RING_FUNC(ring_get_gl_pass_through_token)
{
RING_API_RETNUMBER(GL_PASS_THROUGH_TOKEN);
}
RING_FUNC(ring_get_gl_point_token)
{
RING_API_RETNUMBER(GL_POINT_TOKEN);
}
RING_FUNC(ring_get_gl_line_token)
{
RING_API_RETNUMBER(GL_LINE_TOKEN);
}
RING_FUNC(ring_get_gl_polygon_token)
{
RING_API_RETNUMBER(GL_POLYGON_TOKEN);
}
RING_FUNC(ring_get_gl_bitmap_token)
{
RING_API_RETNUMBER(GL_BITMAP_TOKEN);
}
RING_FUNC(ring_get_gl_draw_pixel_token)
{
RING_API_RETNUMBER(GL_DRAW_PIXEL_TOKEN);
}
RING_FUNC(ring_get_gl_copy_pixel_token)
{
RING_API_RETNUMBER(GL_COPY_PIXEL_TOKEN);
}
RING_FUNC(ring_get_gl_line_reset_token)
{
RING_API_RETNUMBER(GL_LINE_RESET_TOKEN);
}
RING_FUNC(ring_get_gl_exp)
{
RING_API_RETNUMBER(GL_EXP);
}
RING_FUNC(ring_get_gl_viewport_bit)
{
RING_API_RETNUMBER(GL_VIEWPORT_BIT);
}
RING_FUNC(ring_get_gl_exp2)
{
RING_API_RETNUMBER(GL_EXP2);
}
RING_FUNC(ring_get_gl_cw)
{
RING_API_RETNUMBER(GL_CW);
}
RING_FUNC(ring_get_gl_ccw)
{
RING_API_RETNUMBER(GL_CCW);
}
RING_FUNC(ring_get_gl_coeff)
{
RING_API_RETNUMBER(GL_COEFF);
}
RING_FUNC(ring_get_gl_order)
{
RING_API_RETNUMBER(GL_ORDER);
}
RING_FUNC(ring_get_gl_domain)
{
RING_API_RETNUMBER(GL_DOMAIN);
}
RING_FUNC(ring_get_gl_current_color)
{
RING_API_RETNUMBER(GL_CURRENT_COLOR);
}
RING_FUNC(ring_get_gl_current_index)
{
RING_API_RETNUMBER(GL_CURRENT_INDEX);
}
RING_FUNC(ring_get_gl_current_normal)
{
RING_API_RETNUMBER(GL_CURRENT_NORMAL);
}
RING_FUNC(ring_get_gl_current_texture_coords)
{
RING_API_RETNUMBER(GL_CURRENT_TEXTURE_COORDS);
}
RING_FUNC(ring_get_gl_current_raster_color)
{
RING_API_RETNUMBER(GL_CURRENT_RASTER_COLOR);
}
RING_FUNC(ring_get_gl_current_raster_index)
{
RING_API_RETNUMBER(GL_CURRENT_RASTER_INDEX);
}
RING_FUNC(ring_get_gl_current_raster_texture_coords)
{
RING_API_RETNUMBER(GL_CURRENT_RASTER_TEXTURE_COORDS);
}
RING_FUNC(ring_get_gl_current_raster_position)
{
RING_API_RETNUMBER(GL_CURRENT_RASTER_POSITION);
}
RING_FUNC(ring_get_gl_current_raster_position_valid)
{
RING_API_RETNUMBER(GL_CURRENT_RASTER_POSITION_VALID);
}
RING_FUNC(ring_get_gl_current_raster_distance)
{
RING_API_RETNUMBER(GL_CURRENT_RASTER_DISTANCE);
}
RING_FUNC(ring_get_gl_point_smooth)
{
RING_API_RETNUMBER(GL_POINT_SMOOTH);
}
RING_FUNC(ring_get_gl_point_size)
{
RING_API_RETNUMBER(GL_POINT_SIZE);
}
RING_FUNC(ring_get_gl_point_size_range)
{
RING_API_RETNUMBER(GL_POINT_SIZE_RANGE);
}
RING_FUNC(ring_get_gl_point_size_granularity)
{
RING_API_RETNUMBER(GL_POINT_SIZE_GRANULARITY);
}
RING_FUNC(ring_get_gl_line_smooth)
{
RING_API_RETNUMBER(GL_LINE_SMOOTH);
}
RING_FUNC(ring_get_gl_line_width)
{
RING_API_RETNUMBER(GL_LINE_WIDTH);
}
RING_FUNC(ring_get_gl_line_width_range)
{
RING_API_RETNUMBER(GL_LINE_WIDTH_RANGE);
}
RING_FUNC(ring_get_gl_line_width_granularity)
{
RING_API_RETNUMBER(GL_LINE_WIDTH_GRANULARITY);
}
RING_FUNC(ring_get_gl_line_stipple)
{
RING_API_RETNUMBER(GL_LINE_STIPPLE);
}
RING_FUNC(ring_get_gl_line_stipple_pattern)
{
RING_API_RETNUMBER(GL_LINE_STIPPLE_PATTERN);
}
RING_FUNC(ring_get_gl_line_stipple_repeat)
{
RING_API_RETNUMBER(GL_LINE_STIPPLE_REPEAT);
}
RING_FUNC(ring_get_gl_list_mode)
{
RING_API_RETNUMBER(GL_LIST_MODE);
}
RING_FUNC(ring_get_gl_max_list_nesting)
{
RING_API_RETNUMBER(GL_MAX_LIST_NESTING);
}
RING_FUNC(ring_get_gl_list_base)
{
RING_API_RETNUMBER(GL_LIST_BASE);
}
RING_FUNC(ring_get_gl_list_index)
{
RING_API_RETNUMBER(GL_LIST_INDEX);
}
RING_FUNC(ring_get_gl_polygon_mode)
{
RING_API_RETNUMBER(GL_POLYGON_MODE);
}
RING_FUNC(ring_get_gl_polygon_smooth)
{
RING_API_RETNUMBER(GL_POLYGON_SMOOTH);
}
RING_FUNC(ring_get_gl_polygon_stipple)
{
RING_API_RETNUMBER(GL_POLYGON_STIPPLE);
}
RING_FUNC(ring_get_gl_edge_flag)
{
RING_API_RETNUMBER(GL_EDGE_FLAG);
}
RING_FUNC(ring_get_gl_cull_face)
{
RING_API_RETNUMBER(GL_CULL_FACE);
}
RING_FUNC(ring_get_gl_cull_face_mode)
{
RING_API_RETNUMBER(GL_CULL_FACE_MODE);
}
RING_FUNC(ring_get_gl_front_face)
{
RING_API_RETNUMBER(GL_FRONT_FACE);
}
RING_FUNC(ring_get_gl_lighting)
{
RING_API_RETNUMBER(GL_LIGHTING);
}
RING_FUNC(ring_get_gl_light_model_local_viewer)
{
RING_API_RETNUMBER(GL_LIGHT_MODEL_LOCAL_VIEWER);
}
RING_FUNC(ring_get_gl_light_model_two_side)
{
RING_API_RETNUMBER(GL_LIGHT_MODEL_TWO_SIDE);
}
RING_FUNC(ring_get_gl_light_model_ambient)
{
RING_API_RETNUMBER(GL_LIGHT_MODEL_AMBIENT);
}
RING_FUNC(ring_get_gl_shade_model)
{
RING_API_RETNUMBER(GL_SHADE_MODEL);
}
RING_FUNC(ring_get_gl_color_material_face)
{
RING_API_RETNUMBER(GL_COLOR_MATERIAL_FACE);
}
RING_FUNC(ring_get_gl_color_material_parameter)
{
RING_API_RETNUMBER(GL_COLOR_MATERIAL_PARAMETER);
}
RING_FUNC(ring_get_gl_color_material)
{
RING_API_RETNUMBER(GL_COLOR_MATERIAL);
}
RING_FUNC(ring_get_gl_fog)
{
RING_API_RETNUMBER(GL_FOG);
}
RING_FUNC(ring_get_gl_fog_index)
{
RING_API_RETNUMBER(GL_FOG_INDEX);
}
RING_FUNC(ring_get_gl_fog_density)
{
RING_API_RETNUMBER(GL_FOG_DENSITY);
}
RING_FUNC(ring_get_gl_fog_start)
{
RING_API_RETNUMBER(GL_FOG_START);
}
RING_FUNC(ring_get_gl_fog_end)
{
RING_API_RETNUMBER(GL_FOG_END);
}
RING_FUNC(ring_get_gl_fog_mode)
{
RING_API_RETNUMBER(GL_FOG_MODE);
}
RING_FUNC(ring_get_gl_fog_color)
{
RING_API_RETNUMBER(GL_FOG_COLOR);
}
RING_FUNC(ring_get_gl_depth_range)
{
RING_API_RETNUMBER(GL_DEPTH_RANGE);
}
RING_FUNC(ring_get_gl_depth_test)
{
RING_API_RETNUMBER(GL_DEPTH_TEST);
}
RING_FUNC(ring_get_gl_depth_writemask)
{
RING_API_RETNUMBER(GL_DEPTH_WRITEMASK);
}
RING_FUNC(ring_get_gl_depth_clear_value)
{
RING_API_RETNUMBER(GL_DEPTH_CLEAR_VALUE);
}
RING_FUNC(ring_get_gl_depth_func)
{
RING_API_RETNUMBER(GL_DEPTH_FUNC);
}
RING_FUNC(ring_get_gl_accum_clear_value)
{
RING_API_RETNUMBER(GL_ACCUM_CLEAR_VALUE);
}
RING_FUNC(ring_get_gl_stencil_test)
{
RING_API_RETNUMBER(GL_STENCIL_TEST);
}
RING_FUNC(ring_get_gl_stencil_clear_value)
{
RING_API_RETNUMBER(GL_STENCIL_CLEAR_VALUE);
}
RING_FUNC(ring_get_gl_stencil_func)
{
RING_API_RETNUMBER(GL_STENCIL_FUNC);
}
RING_FUNC(ring_get_gl_stencil_value_mask)
{
RING_API_RETNUMBER(GL_STENCIL_VALUE_MASK);
}
RING_FUNC(ring_get_gl_stencil_fail)
{
RING_API_RETNUMBER(GL_STENCIL_FAIL);
}
RING_FUNC(ring_get_gl_stencil_pass_depth_fail)
{
RING_API_RETNUMBER(GL_STENCIL_PASS_DEPTH_FAIL);
}
RING_FUNC(ring_get_gl_stencil_pass_depth_pass)
{
RING_API_RETNUMBER(GL_STENCIL_PASS_DEPTH_PASS);
}
RING_FUNC(ring_get_gl_stencil_ref)
{
RING_API_RETNUMBER(GL_STENCIL_REF);
}
RING_FUNC(ring_get_gl_stencil_writemask)
{
RING_API_RETNUMBER(GL_STENCIL_WRITEMASK);
}
RING_FUNC(ring_get_gl_matrix_mode)
{
RING_API_RETNUMBER(GL_MATRIX_MODE);
}
RING_FUNC(ring_get_gl_normalize)
{
RING_API_RETNUMBER(GL_NORMALIZE);
}
RING_FUNC(ring_get_gl_viewport)
{
RING_API_RETNUMBER(GL_VIEWPORT);
}
RING_FUNC(ring_get_gl_modelview_stack_depth)
{
RING_API_RETNUMBER(GL_MODELVIEW_STACK_DEPTH);
}
RING_FUNC(ring_get_gl_projection_stack_depth)
{
RING_API_RETNUMBER(GL_PROJECTION_STACK_DEPTH);
}
RING_FUNC(ring_get_gl_texture_stack_depth)
{
RING_API_RETNUMBER(GL_TEXTURE_STACK_DEPTH);
}
RING_FUNC(ring_get_gl_modelview_matrix)
{
RING_API_RETNUMBER(GL_MODELVIEW_MATRIX);
}
RING_FUNC(ring_get_gl_projection_matrix)
{
RING_API_RETNUMBER(GL_PROJECTION_MATRIX);
}
RING_FUNC(ring_get_gl_texture_matrix)
{
RING_API_RETNUMBER(GL_TEXTURE_MATRIX);
}
RING_FUNC(ring_get_gl_attrib_stack_depth)
{
RING_API_RETNUMBER(GL_ATTRIB_STACK_DEPTH);
}
RING_FUNC(ring_get_gl_client_attrib_stack_depth)
{
RING_API_RETNUMBER(GL_CLIENT_ATTRIB_STACK_DEPTH);
}
RING_FUNC(ring_get_gl_alpha_test)
{
RING_API_RETNUMBER(GL_ALPHA_TEST);
}
RING_FUNC(ring_get_gl_alpha_test_func)
{
RING_API_RETNUMBER(GL_ALPHA_TEST_FUNC);
}
RING_FUNC(ring_get_gl_alpha_test_ref)
{
RING_API_RETNUMBER(GL_ALPHA_TEST_REF);
}
RING_FUNC(ring_get_gl_dither)
{
RING_API_RETNUMBER(GL_DITHER);
}
RING_FUNC(ring_get_gl_blend_dst)
{
RING_API_RETNUMBER(GL_BLEND_DST);
}
RING_FUNC(ring_get_gl_blend_src)
{
RING_API_RETNUMBER(GL_BLEND_SRC);
}
RING_FUNC(ring_get_gl_blend)
{
RING_API_RETNUMBER(GL_BLEND);
}
RING_FUNC(ring_get_gl_logic_op_mode)
{
RING_API_RETNUMBER(GL_LOGIC_OP_MODE);
}
RING_FUNC(ring_get_gl_index_logic_op)
{
RING_API_RETNUMBER(GL_INDEX_LOGIC_OP);
}
RING_FUNC(ring_get_gl_color_logic_op)
{
RING_API_RETNUMBER(GL_COLOR_LOGIC_OP);
}
RING_FUNC(ring_get_gl_aux_buffers)
{
RING_API_RETNUMBER(GL_AUX_BUFFERS);
}
RING_FUNC(ring_get_gl_draw_buffer)
{
RING_API_RETNUMBER(GL_DRAW_BUFFER);
}
RING_FUNC(ring_get_gl_read_buffer)
{
RING_API_RETNUMBER(GL_READ_BUFFER);
}
RING_FUNC(ring_get_gl_scissor_box)
{
RING_API_RETNUMBER(GL_SCISSOR_BOX);
}
RING_FUNC(ring_get_gl_scissor_test)
{
RING_API_RETNUMBER(GL_SCISSOR_TEST);
}
RING_FUNC(ring_get_gl_index_clear_value)
{
RING_API_RETNUMBER(GL_INDEX_CLEAR_VALUE);
}
RING_FUNC(ring_get_gl_index_writemask)
{
RING_API_RETNUMBER(GL_INDEX_WRITEMASK);
}
RING_FUNC(ring_get_gl_color_clear_value)
{
RING_API_RETNUMBER(GL_COLOR_CLEAR_VALUE);
}
RING_FUNC(ring_get_gl_color_writemask)
{
RING_API_RETNUMBER(GL_COLOR_WRITEMASK);
}
RING_FUNC(ring_get_gl_index_mode)
{
RING_API_RETNUMBER(GL_INDEX_MODE);
}
RING_FUNC(ring_get_gl_rgba_mode)
{
RING_API_RETNUMBER(GL_RGBA_MODE);
}
RING_FUNC(ring_get_gl_doublebuffer)
{
RING_API_RETNUMBER(GL_DOUBLEBUFFER);
}
RING_FUNC(ring_get_gl_stereo)
{
RING_API_RETNUMBER(GL_STEREO);
}
RING_FUNC(ring_get_gl_render_mode)
{
RING_API_RETNUMBER(GL_RENDER_MODE);
}
RING_FUNC(ring_get_gl_perspective_correction_hint)
{
RING_API_RETNUMBER(GL_PERSPECTIVE_CORRECTION_HINT);
}
RING_FUNC(ring_get_gl_point_smooth_hint)
{
RING_API_RETNUMBER(GL_POINT_SMOOTH_HINT);
}
RING_FUNC(ring_get_gl_line_smooth_hint)
{
RING_API_RETNUMBER(GL_LINE_SMOOTH_HINT);
}
RING_FUNC(ring_get_gl_polygon_smooth_hint)
{
RING_API_RETNUMBER(GL_POLYGON_SMOOTH_HINT);
}
RING_FUNC(ring_get_gl_fog_hint)
{
RING_API_RETNUMBER(GL_FOG_HINT);
}
RING_FUNC(ring_get_gl_texture_gen_s)
{
RING_API_RETNUMBER(GL_TEXTURE_GEN_S);
}
RING_FUNC(ring_get_gl_texture_gen_t)
{
RING_API_RETNUMBER(GL_TEXTURE_GEN_T);
}
RING_FUNC(ring_get_gl_texture_gen_r)
{
RING_API_RETNUMBER(GL_TEXTURE_GEN_R);
}
RING_FUNC(ring_get_gl_texture_gen_q)
{
RING_API_RETNUMBER(GL_TEXTURE_GEN_Q);
}
RING_FUNC(ring_get_gl_pixel_map_i_to_i)
{
RING_API_RETNUMBER(GL_PIXEL_MAP_I_TO_I);
}
RING_FUNC(ring_get_gl_pixel_map_s_to_s)
{
RING_API_RETNUMBER(GL_PIXEL_MAP_S_TO_S);
}
RING_FUNC(ring_get_gl_pixel_map_i_to_r)
{
RING_API_RETNUMBER(GL_PIXEL_MAP_I_TO_R);
}
RING_FUNC(ring_get_gl_pixel_map_i_to_g)
{
RING_API_RETNUMBER(GL_PIXEL_MAP_I_TO_G);
}
RING_FUNC(ring_get_gl_pixel_map_i_to_b)
{
RING_API_RETNUMBER(GL_PIXEL_MAP_I_TO_B);
}
RING_FUNC(ring_get_gl_pixel_map_i_to_a)
{
RING_API_RETNUMBER(GL_PIXEL_MAP_I_TO_A);
}
RING_FUNC(ring_get_gl_pixel_map_r_to_r)
{
RING_API_RETNUMBER(GL_PIXEL_MAP_R_TO_R);
}
RING_FUNC(ring_get_gl_pixel_map_g_to_g)
{
RING_API_RETNUMBER(GL_PIXEL_MAP_G_TO_G);
}
RING_FUNC(ring_get_gl_pixel_map_b_to_b)
{
RING_API_RETNUMBER(GL_PIXEL_MAP_B_TO_B);
}
RING_FUNC(ring_get_gl_pixel_map_a_to_a)
{
RING_API_RETNUMBER(GL_PIXEL_MAP_A_TO_A);
}
RING_FUNC(ring_get_gl_pixel_map_i_to_i_size)
{
RING_API_RETNUMBER(GL_PIXEL_MAP_I_TO_I_SIZE);
}
RING_FUNC(ring_get_gl_pixel_map_s_to_s_size)
{
RING_API_RETNUMBER(GL_PIXEL_MAP_S_TO_S_SIZE);
}
RING_FUNC(ring_get_gl_pixel_map_i_to_r_size)
{
RING_API_RETNUMBER(GL_PIXEL_MAP_I_TO_R_SIZE);
}
RING_FUNC(ring_get_gl_pixel_map_i_to_g_size)
{
RING_API_RETNUMBER(GL_PIXEL_MAP_I_TO_G_SIZE);
}
RING_FUNC(ring_get_gl_pixel_map_i_to_b_size)
{
RING_API_RETNUMBER(GL_PIXEL_MAP_I_TO_B_SIZE);
}
RING_FUNC(ring_get_gl_pixel_map_i_to_a_size)
{
RING_API_RETNUMBER(GL_PIXEL_MAP_I_TO_A_SIZE);
}
RING_FUNC(ring_get_gl_pixel_map_r_to_r_size)
{
RING_API_RETNUMBER(GL_PIXEL_MAP_R_TO_R_SIZE);
}
RING_FUNC(ring_get_gl_pixel_map_g_to_g_size)
{
RING_API_RETNUMBER(GL_PIXEL_MAP_G_TO_G_SIZE);
}
RING_FUNC(ring_get_gl_pixel_map_b_to_b_size)
{
RING_API_RETNUMBER(GL_PIXEL_MAP_B_TO_B_SIZE);
}
RING_FUNC(ring_get_gl_pixel_map_a_to_a_size)
{
RING_API_RETNUMBER(GL_PIXEL_MAP_A_TO_A_SIZE);
}
RING_FUNC(ring_get_gl_unpack_swap_bytes)
{
RING_API_RETNUMBER(GL_UNPACK_SWAP_BYTES);
}
RING_FUNC(ring_get_gl_unpack_lsb_first)
{
RING_API_RETNUMBER(GL_UNPACK_LSB_FIRST);
}
RING_FUNC(ring_get_gl_unpack_row_length)
{
RING_API_RETNUMBER(GL_UNPACK_ROW_LENGTH);
}
RING_FUNC(ring_get_gl_unpack_skip_rows)
{
RING_API_RETNUMBER(GL_UNPACK_SKIP_ROWS);
}
RING_FUNC(ring_get_gl_unpack_skip_pixels)
{
RING_API_RETNUMBER(GL_UNPACK_SKIP_PIXELS);
}
RING_FUNC(ring_get_gl_unpack_alignment)
{
RING_API_RETNUMBER(GL_UNPACK_ALIGNMENT);
}
RING_FUNC(ring_get_gl_pack_swap_bytes)
{
RING_API_RETNUMBER(GL_PACK_SWAP_BYTES);
}
RING_FUNC(ring_get_gl_pack_lsb_first)
{
RING_API_RETNUMBER(GL_PACK_LSB_FIRST);
}
RING_FUNC(ring_get_gl_pack_row_length)
{
RING_API_RETNUMBER(GL_PACK_ROW_LENGTH);
}
RING_FUNC(ring_get_gl_pack_skip_rows)
{
RING_API_RETNUMBER(GL_PACK_SKIP_ROWS);
}
RING_FUNC(ring_get_gl_pack_skip_pixels)
{
RING_API_RETNUMBER(GL_PACK_SKIP_PIXELS);
}
RING_FUNC(ring_get_gl_pack_alignment)
{
RING_API_RETNUMBER(GL_PACK_ALIGNMENT);
}
RING_FUNC(ring_get_gl_map_color)
{
RING_API_RETNUMBER(GL_MAP_COLOR);
}
RING_FUNC(ring_get_gl_map_stencil)
{
RING_API_RETNUMBER(GL_MAP_STENCIL);
}
RING_FUNC(ring_get_gl_index_shift)
{
RING_API_RETNUMBER(GL_INDEX_SHIFT);
}
RING_FUNC(ring_get_gl_index_offset)
{
RING_API_RETNUMBER(GL_INDEX_OFFSET);
}
RING_FUNC(ring_get_gl_red_scale)
{
RING_API_RETNUMBER(GL_RED_SCALE);
}
RING_FUNC(ring_get_gl_red_bias)
{
RING_API_RETNUMBER(GL_RED_BIAS);
}
RING_FUNC(ring_get_gl_zoom_x)
{
RING_API_RETNUMBER(GL_ZOOM_X);
}
RING_FUNC(ring_get_gl_zoom_y)
{
RING_API_RETNUMBER(GL_ZOOM_Y);
}
RING_FUNC(ring_get_gl_green_scale)
{
RING_API_RETNUMBER(GL_GREEN_SCALE);
}
RING_FUNC(ring_get_gl_green_bias)
{
RING_API_RETNUMBER(GL_GREEN_BIAS);
}
RING_FUNC(ring_get_gl_blue_scale)
{
RING_API_RETNUMBER(GL_BLUE_SCALE);
}
RING_FUNC(ring_get_gl_blue_bias)
{
RING_API_RETNUMBER(GL_BLUE_BIAS);
}
RING_FUNC(ring_get_gl_alpha_scale)
{
RING_API_RETNUMBER(GL_ALPHA_SCALE);
}
RING_FUNC(ring_get_gl_alpha_bias)
{
RING_API_RETNUMBER(GL_ALPHA_BIAS);
}
RING_FUNC(ring_get_gl_depth_scale)
{
RING_API_RETNUMBER(GL_DEPTH_SCALE);
}
RING_FUNC(ring_get_gl_depth_bias)
{
RING_API_RETNUMBER(GL_DEPTH_BIAS);
}
RING_FUNC(ring_get_gl_max_eval_order)
{
RING_API_RETNUMBER(GL_MAX_EVAL_ORDER);
}
RING_FUNC(ring_get_gl_max_lights)
{
RING_API_RETNUMBER(GL_MAX_LIGHTS);
}
RING_FUNC(ring_get_gl_max_clip_planes)
{
RING_API_RETNUMBER(GL_MAX_CLIP_PLANES);
}
RING_FUNC(ring_get_gl_max_texture_size)
{
RING_API_RETNUMBER(GL_MAX_TEXTURE_SIZE);
}
RING_FUNC(ring_get_gl_max_pixel_map_table)
{
RING_API_RETNUMBER(GL_MAX_PIXEL_MAP_TABLE);
}
RING_FUNC(ring_get_gl_max_attrib_stack_depth)
{
RING_API_RETNUMBER(GL_MAX_ATTRIB_STACK_DEPTH);
}
RING_FUNC(ring_get_gl_max_modelview_stack_depth)
{
RING_API_RETNUMBER(GL_MAX_MODELVIEW_STACK_DEPTH);
}
RING_FUNC(ring_get_gl_max_name_stack_depth)
{
RING_API_RETNUMBER(GL_MAX_NAME_STACK_DEPTH);
}
RING_FUNC(ring_get_gl_max_projection_stack_depth)
{
RING_API_RETNUMBER(GL_MAX_PROJECTION_STACK_DEPTH);
}
RING_FUNC(ring_get_gl_max_texture_stack_depth)
{
RING_API_RETNUMBER(GL_MAX_TEXTURE_STACK_DEPTH);
}
RING_FUNC(ring_get_gl_max_viewport_dims)
{
RING_API_RETNUMBER(GL_MAX_VIEWPORT_DIMS);
}
RING_FUNC(ring_get_gl_max_client_attrib_stack_depth)
{
RING_API_RETNUMBER(GL_MAX_CLIENT_ATTRIB_STACK_DEPTH);
}
RING_FUNC(ring_get_gl_subpixel_bits)
{
RING_API_RETNUMBER(GL_SUBPIXEL_BITS);
}
RING_FUNC(ring_get_gl_index_bits)
{
RING_API_RETNUMBER(GL_INDEX_BITS);
}
RING_FUNC(ring_get_gl_red_bits)
{
RING_API_RETNUMBER(GL_RED_BITS);
}
RING_FUNC(ring_get_gl_green_bits)
{
RING_API_RETNUMBER(GL_GREEN_BITS);
}
RING_FUNC(ring_get_gl_blue_bits)
{
RING_API_RETNUMBER(GL_BLUE_BITS);
}
RING_FUNC(ring_get_gl_alpha_bits)
{
RING_API_RETNUMBER(GL_ALPHA_BITS);
}
RING_FUNC(ring_get_gl_depth_bits)
{
RING_API_RETNUMBER(GL_DEPTH_BITS);
}
RING_FUNC(ring_get_gl_stencil_bits)
{
RING_API_RETNUMBER(GL_STENCIL_BITS);
}
RING_FUNC(ring_get_gl_accum_red_bits)
{
RING_API_RETNUMBER(GL_ACCUM_RED_BITS);
}
RING_FUNC(ring_get_gl_accum_green_bits)
{
RING_API_RETNUMBER(GL_ACCUM_GREEN_BITS);
}
RING_FUNC(ring_get_gl_accum_blue_bits)
{
RING_API_RETNUMBER(GL_ACCUM_BLUE_BITS);
}
RING_FUNC(ring_get_gl_accum_alpha_bits)
{
RING_API_RETNUMBER(GL_ACCUM_ALPHA_BITS);
}
RING_FUNC(ring_get_gl_name_stack_depth)
{
RING_API_RETNUMBER(GL_NAME_STACK_DEPTH);
}
RING_FUNC(ring_get_gl_auto_normal)
{
RING_API_RETNUMBER(GL_AUTO_NORMAL);
}
RING_FUNC(ring_get_gl_map1_color_4)
{
RING_API_RETNUMBER(GL_MAP1_COLOR_4);
}
RING_FUNC(ring_get_gl_map1_index)
{
RING_API_RETNUMBER(GL_MAP1_INDEX);
}
RING_FUNC(ring_get_gl_map1_normal)
{
RING_API_RETNUMBER(GL_MAP1_NORMAL);
}
RING_FUNC(ring_get_gl_map1_texture_coord_1)
{
RING_API_RETNUMBER(GL_MAP1_TEXTURE_COORD_1);
}
RING_FUNC(ring_get_gl_map1_texture_coord_2)
{
RING_API_RETNUMBER(GL_MAP1_TEXTURE_COORD_2);
}
RING_FUNC(ring_get_gl_map1_texture_coord_3)
{
RING_API_RETNUMBER(GL_MAP1_TEXTURE_COORD_3);
}
RING_FUNC(ring_get_gl_map1_texture_coord_4)
{
RING_API_RETNUMBER(GL_MAP1_TEXTURE_COORD_4);
}
RING_FUNC(ring_get_gl_map1_vertex_3)
{
RING_API_RETNUMBER(GL_MAP1_VERTEX_3);
}
RING_FUNC(ring_get_gl_map1_vertex_4)
{
RING_API_RETNUMBER(GL_MAP1_VERTEX_4);
}
RING_FUNC(ring_get_gl_map2_color_4)
{
RING_API_RETNUMBER(GL_MAP2_COLOR_4);
}
RING_FUNC(ring_get_gl_map2_index)
{
RING_API_RETNUMBER(GL_MAP2_INDEX);
}
RING_FUNC(ring_get_gl_map2_normal)
{
RING_API_RETNUMBER(GL_MAP2_NORMAL);
}
RING_FUNC(ring_get_gl_map2_texture_coord_1)
{
RING_API_RETNUMBER(GL_MAP2_TEXTURE_COORD_1);
}
RING_FUNC(ring_get_gl_map2_texture_coord_2)
{
RING_API_RETNUMBER(GL_MAP2_TEXTURE_COORD_2);
}
RING_FUNC(ring_get_gl_map2_texture_coord_3)
{
RING_API_RETNUMBER(GL_MAP2_TEXTURE_COORD_3);
}
RING_FUNC(ring_get_gl_map2_texture_coord_4)
{
RING_API_RETNUMBER(GL_MAP2_TEXTURE_COORD_4);
}
RING_FUNC(ring_get_gl_map2_vertex_3)
{
RING_API_RETNUMBER(GL_MAP2_VERTEX_3);
}
RING_FUNC(ring_get_gl_map2_vertex_4)
{
RING_API_RETNUMBER(GL_MAP2_VERTEX_4);
}
RING_FUNC(ring_get_gl_map1_grid_domain)
{
RING_API_RETNUMBER(GL_MAP1_GRID_DOMAIN);
}
RING_FUNC(ring_get_gl_map1_grid_segments)
{
RING_API_RETNUMBER(GL_MAP1_GRID_SEGMENTS);
}
RING_FUNC(ring_get_gl_map2_grid_domain)
{
RING_API_RETNUMBER(GL_MAP2_GRID_DOMAIN);
}
RING_FUNC(ring_get_gl_map2_grid_segments)
{
RING_API_RETNUMBER(GL_MAP2_GRID_SEGMENTS);
}
RING_FUNC(ring_get_gl_texture_1d)
{
RING_API_RETNUMBER(GL_TEXTURE_1D);
}
RING_FUNC(ring_get_gl_texture_2d)
{
RING_API_RETNUMBER(GL_TEXTURE_2D);
}
RING_FUNC(ring_get_gl_feedback_buffer_pointer)
{
RING_API_RETNUMBER(GL_FEEDBACK_BUFFER_POINTER);
}
RING_FUNC(ring_get_gl_feedback_buffer_size)
{
RING_API_RETNUMBER(GL_FEEDBACK_BUFFER_SIZE);
}
RING_FUNC(ring_get_gl_feedback_buffer_type)
{
RING_API_RETNUMBER(GL_FEEDBACK_BUFFER_TYPE);
}
RING_FUNC(ring_get_gl_selection_buffer_pointer)
{
RING_API_RETNUMBER(GL_SELECTION_BUFFER_POINTER);
}
RING_FUNC(ring_get_gl_selection_buffer_size)
{
RING_API_RETNUMBER(GL_SELECTION_BUFFER_SIZE);
}
RING_FUNC(ring_get_gl_texture_width)
{
RING_API_RETNUMBER(GL_TEXTURE_WIDTH);
}
RING_FUNC(ring_get_gl_transform_bit)
{
RING_API_RETNUMBER(GL_TRANSFORM_BIT);
}
RING_FUNC(ring_get_gl_texture_height)
{
RING_API_RETNUMBER(GL_TEXTURE_HEIGHT);
}
RING_FUNC(ring_get_gl_texture_internal_format)
{
RING_API_RETNUMBER(GL_TEXTURE_INTERNAL_FORMAT);
}
RING_FUNC(ring_get_gl_texture_border_color)
{
RING_API_RETNUMBER(GL_TEXTURE_BORDER_COLOR);
}
RING_FUNC(ring_get_gl_texture_border)
{
RING_API_RETNUMBER(GL_TEXTURE_BORDER);
}
RING_FUNC(ring_get_gl_dont_care)
{
RING_API_RETNUMBER(GL_DONT_CARE);
}
RING_FUNC(ring_get_gl_fastest)
{
RING_API_RETNUMBER(GL_FASTEST);
}
RING_FUNC(ring_get_gl_nicest)
{
RING_API_RETNUMBER(GL_NICEST);
}
RING_FUNC(ring_get_gl_ambient)
{
RING_API_RETNUMBER(GL_AMBIENT);
}
RING_FUNC(ring_get_gl_diffuse)
{
RING_API_RETNUMBER(GL_DIFFUSE);
}
RING_FUNC(ring_get_gl_specular)
{
RING_API_RETNUMBER(GL_SPECULAR);
}
RING_FUNC(ring_get_gl_position)
{
RING_API_RETNUMBER(GL_POSITION);
}
RING_FUNC(ring_get_gl_spot_direction)
{
RING_API_RETNUMBER(GL_SPOT_DIRECTION);
}
RING_FUNC(ring_get_gl_spot_exponent)
{
RING_API_RETNUMBER(GL_SPOT_EXPONENT);
}
RING_FUNC(ring_get_gl_spot_cutoff)
{
RING_API_RETNUMBER(GL_SPOT_CUTOFF);
}
RING_FUNC(ring_get_gl_constant_attenuation)
{
RING_API_RETNUMBER(GL_CONSTANT_ATTENUATION);
}
RING_FUNC(ring_get_gl_linear_attenuation)
{
RING_API_RETNUMBER(GL_LINEAR_ATTENUATION);
}
RING_FUNC(ring_get_gl_quadratic_attenuation)
{
RING_API_RETNUMBER(GL_QUADRATIC_ATTENUATION);
}
RING_FUNC(ring_get_gl_compile)
{
RING_API_RETNUMBER(GL_COMPILE);
}
RING_FUNC(ring_get_gl_compile_and_execute)
{
RING_API_RETNUMBER(GL_COMPILE_AND_EXECUTE);
}
RING_FUNC(ring_get_gl_byte)
{
RING_API_RETNUMBER(GL_BYTE);
}
RING_FUNC(ring_get_gl_unsigned_byte)
{
RING_API_RETNUMBER(GL_UNSIGNED_BYTE);
}
RING_FUNC(ring_get_gl_short)
{
RING_API_RETNUMBER(GL_SHORT);
}
RING_FUNC(ring_get_gl_unsigned_short)
{
RING_API_RETNUMBER(GL_UNSIGNED_SHORT);
}
RING_FUNC(ring_get_gl_int)
{
RING_API_RETNUMBER(GL_INT);
}
RING_FUNC(ring_get_gl_unsigned_int)
{
RING_API_RETNUMBER(GL_UNSIGNED_INT);
}
RING_FUNC(ring_get_gl_float)
{
RING_API_RETNUMBER(GL_FLOAT);
}
RING_FUNC(ring_get_gl_2_bytes)
{
RING_API_RETNUMBER(GL_2_BYTES);
}
RING_FUNC(ring_get_gl_3_bytes)
{
RING_API_RETNUMBER(GL_3_BYTES);
}
RING_FUNC(ring_get_gl_4_bytes)
{
RING_API_RETNUMBER(GL_4_BYTES);
}
RING_FUNC(ring_get_gl_double)
{
RING_API_RETNUMBER(GL_DOUBLE);
}
RING_FUNC(ring_get_gl_clear)
{
RING_API_RETNUMBER(GL_CLEAR);
}
RING_FUNC(ring_get_gl_and)
{
RING_API_RETNUMBER(GL_AND);
}
RING_FUNC(ring_get_gl_and_reverse)
{
RING_API_RETNUMBER(GL_AND_REVERSE);
}
RING_FUNC(ring_get_gl_copy)
{
RING_API_RETNUMBER(GL_COPY);
}
RING_FUNC(ring_get_gl_and_inverted)
{
RING_API_RETNUMBER(GL_AND_INVERTED);
}
RING_FUNC(ring_get_gl_noop)
{
RING_API_RETNUMBER(GL_NOOP);
}
RING_FUNC(ring_get_gl_xor)
{
RING_API_RETNUMBER(GL_XOR);
}
RING_FUNC(ring_get_gl_or)
{
RING_API_RETNUMBER(GL_OR);
}
RING_FUNC(ring_get_gl_nor)
{
RING_API_RETNUMBER(GL_NOR);
}
RING_FUNC(ring_get_gl_equiv)
{
RING_API_RETNUMBER(GL_EQUIV);
}
RING_FUNC(ring_get_gl_invert)
{
RING_API_RETNUMBER(GL_INVERT);
}
RING_FUNC(ring_get_gl_or_reverse)
{
RING_API_RETNUMBER(GL_OR_REVERSE);
}
RING_FUNC(ring_get_gl_copy_inverted)
{
RING_API_RETNUMBER(GL_COPY_INVERTED);
}
RING_FUNC(ring_get_gl_or_inverted)
{
RING_API_RETNUMBER(GL_OR_INVERTED);
}
RING_FUNC(ring_get_gl_nand)
{
RING_API_RETNUMBER(GL_NAND);
}
RING_FUNC(ring_get_gl_set)
{
RING_API_RETNUMBER(GL_SET);
}
RING_FUNC(ring_get_gl_emission)
{
RING_API_RETNUMBER(GL_EMISSION);
}
RING_FUNC(ring_get_gl_shininess)
{
RING_API_RETNUMBER(GL_SHININESS);
}
RING_FUNC(ring_get_gl_ambient_and_diffuse)
{
RING_API_RETNUMBER(GL_AMBIENT_AND_DIFFUSE);
}
RING_FUNC(ring_get_gl_color_indexes)
{
RING_API_RETNUMBER(GL_COLOR_INDEXES);
}
RING_FUNC(ring_get_gl_modelview)
{
RING_API_RETNUMBER(GL_MODELVIEW);
}
RING_FUNC(ring_get_gl_projection)
{
RING_API_RETNUMBER(GL_PROJECTION);
}
RING_FUNC(ring_get_gl_texture)
{
RING_API_RETNUMBER(GL_TEXTURE);
}
RING_FUNC(ring_get_gl_color)
{
RING_API_RETNUMBER(GL_COLOR);
}
RING_FUNC(ring_get_gl_depth)
{
RING_API_RETNUMBER(GL_DEPTH);
}
RING_FUNC(ring_get_gl_stencil)
{
RING_API_RETNUMBER(GL_STENCIL);
}
RING_FUNC(ring_get_gl_color_index)
{
RING_API_RETNUMBER(GL_COLOR_INDEX);
}
RING_FUNC(ring_get_gl_stencil_index)
{
RING_API_RETNUMBER(GL_STENCIL_INDEX);
}
RING_FUNC(ring_get_gl_depth_component)
{
RING_API_RETNUMBER(GL_DEPTH_COMPONENT);
}
RING_FUNC(ring_get_gl_red)
{
RING_API_RETNUMBER(GL_RED);
}
RING_FUNC(ring_get_gl_green)
{
RING_API_RETNUMBER(GL_GREEN);
}
RING_FUNC(ring_get_gl_blue)
{
RING_API_RETNUMBER(GL_BLUE);
}
RING_FUNC(ring_get_gl_alpha)
{
RING_API_RETNUMBER(GL_ALPHA);
}
RING_FUNC(ring_get_gl_rgb)
{
RING_API_RETNUMBER(GL_RGB);
}
RING_FUNC(ring_get_gl_rgba)
{
RING_API_RETNUMBER(GL_RGBA);
}
RING_FUNC(ring_get_gl_luminance)
{
RING_API_RETNUMBER(GL_LUMINANCE);
}
RING_FUNC(ring_get_gl_luminance_alpha)
{
RING_API_RETNUMBER(GL_LUMINANCE_ALPHA);
}
RING_FUNC(ring_get_gl_bitmap)
{
RING_API_RETNUMBER(GL_BITMAP);
}
RING_FUNC(ring_get_gl_point)
{
RING_API_RETNUMBER(GL_POINT);
}
RING_FUNC(ring_get_gl_line)
{
RING_API_RETNUMBER(GL_LINE);
}
RING_FUNC(ring_get_gl_fill)
{
RING_API_RETNUMBER(GL_FILL);
}
RING_FUNC(ring_get_gl_render)
{
RING_API_RETNUMBER(GL_RENDER);
}
RING_FUNC(ring_get_gl_feedback)
{
RING_API_RETNUMBER(GL_FEEDBACK);
}
RING_FUNC(ring_get_gl_select)
{
RING_API_RETNUMBER(GL_SELECT);
}
RING_FUNC(ring_get_gl_flat)
{
RING_API_RETNUMBER(GL_FLAT);
}
RING_FUNC(ring_get_gl_smooth)
{
RING_API_RETNUMBER(GL_SMOOTH);
}
RING_FUNC(ring_get_gl_keep)
{
RING_API_RETNUMBER(GL_KEEP);
}
RING_FUNC(ring_get_gl_replace)
{
RING_API_RETNUMBER(GL_REPLACE);
}
RING_FUNC(ring_get_gl_incr)
{
RING_API_RETNUMBER(GL_INCR);
}
RING_FUNC(ring_get_gl_decr)
{
RING_API_RETNUMBER(GL_DECR);
}
RING_FUNC(ring_get_gl_vendor)
{
RING_API_RETNUMBER(GL_VENDOR);
}
RING_FUNC(ring_get_gl_renderer)
{
RING_API_RETNUMBER(GL_RENDERER);
}
RING_FUNC(ring_get_gl_version)
{
RING_API_RETNUMBER(GL_VERSION);
}
RING_FUNC(ring_get_gl_extensions)
{
RING_API_RETNUMBER(GL_EXTENSIONS);
}
RING_FUNC(ring_get_gl_s)
{
RING_API_RETNUMBER(GL_S);
}
RING_FUNC(ring_get_gl_enable_bit)
{
RING_API_RETNUMBER(GL_ENABLE_BIT);
}
RING_FUNC(ring_get_gl_t)
{
RING_API_RETNUMBER(GL_T);
}
RING_FUNC(ring_get_gl_r)
{
RING_API_RETNUMBER(GL_R);
}
RING_FUNC(ring_get_gl_q)
{
RING_API_RETNUMBER(GL_Q);
}
RING_FUNC(ring_get_gl_modulate)
{
RING_API_RETNUMBER(GL_MODULATE);
}
RING_FUNC(ring_get_gl_decal)
{
RING_API_RETNUMBER(GL_DECAL);
}
RING_FUNC(ring_get_gl_texture_env_mode)
{
RING_API_RETNUMBER(GL_TEXTURE_ENV_MODE);
}
RING_FUNC(ring_get_gl_texture_env_color)
{
RING_API_RETNUMBER(GL_TEXTURE_ENV_COLOR);
}
RING_FUNC(ring_get_gl_texture_env)
{
RING_API_RETNUMBER(GL_TEXTURE_ENV);
}
RING_FUNC(ring_get_gl_eye_linear)
{
RING_API_RETNUMBER(GL_EYE_LINEAR);
}
RING_FUNC(ring_get_gl_object_linear)
{
RING_API_RETNUMBER(GL_OBJECT_LINEAR);
}
RING_FUNC(ring_get_gl_sphere_map)
{
RING_API_RETNUMBER(GL_SPHERE_MAP);
}
RING_FUNC(ring_get_gl_texture_gen_mode)
{
RING_API_RETNUMBER(GL_TEXTURE_GEN_MODE);
}
RING_FUNC(ring_get_gl_object_plane)
{
RING_API_RETNUMBER(GL_OBJECT_PLANE);
}
RING_FUNC(ring_get_gl_eye_plane)
{
RING_API_RETNUMBER(GL_EYE_PLANE);
}
RING_FUNC(ring_get_gl_nearest)
{
RING_API_RETNUMBER(GL_NEAREST);
}
RING_FUNC(ring_get_gl_linear)
{
RING_API_RETNUMBER(GL_LINEAR);
}
RING_FUNC(ring_get_gl_nearest_mipmap_nearest)
{
RING_API_RETNUMBER(GL_NEAREST_MIPMAP_NEAREST);
}
RING_FUNC(ring_get_gl_linear_mipmap_nearest)
{
RING_API_RETNUMBER(GL_LINEAR_MIPMAP_NEAREST);
}
RING_FUNC(ring_get_gl_nearest_mipmap_linear)
{
RING_API_RETNUMBER(GL_NEAREST_MIPMAP_LINEAR);
}
RING_FUNC(ring_get_gl_linear_mipmap_linear)
{
RING_API_RETNUMBER(GL_LINEAR_MIPMAP_LINEAR);
}
RING_FUNC(ring_get_gl_texture_mag_filter)
{
RING_API_RETNUMBER(GL_TEXTURE_MAG_FILTER);
}
RING_FUNC(ring_get_gl_texture_min_filter)
{
RING_API_RETNUMBER(GL_TEXTURE_MIN_FILTER);
}
RING_FUNC(ring_get_gl_texture_wrap_s)
{
RING_API_RETNUMBER(GL_TEXTURE_WRAP_S);
}
RING_FUNC(ring_get_gl_texture_wrap_t)
{
RING_API_RETNUMBER(GL_TEXTURE_WRAP_T);
}
RING_FUNC(ring_get_gl_clamp)
{
RING_API_RETNUMBER(GL_CLAMP);
}
RING_FUNC(ring_get_gl_repeat)
{
RING_API_RETNUMBER(GL_REPEAT);
}
RING_FUNC(ring_get_gl_polygon_offset_units)
{
RING_API_RETNUMBER(GL_POLYGON_OFFSET_UNITS);
}
RING_FUNC(ring_get_gl_polygon_offset_point)
{
RING_API_RETNUMBER(GL_POLYGON_OFFSET_POINT);
}
RING_FUNC(ring_get_gl_polygon_offset_line)
{
RING_API_RETNUMBER(GL_POLYGON_OFFSET_LINE);
}
RING_FUNC(ring_get_gl_r3_g3_b2)
{
RING_API_RETNUMBER(GL_R3_G3_B2);
}
RING_FUNC(ring_get_gl_v2f)
{
RING_API_RETNUMBER(GL_V2F);
}
RING_FUNC(ring_get_gl_v3f)
{
RING_API_RETNUMBER(GL_V3F);
}
RING_FUNC(ring_get_gl_c4ub_v2f)
{
RING_API_RETNUMBER(GL_C4UB_V2F);
}
RING_FUNC(ring_get_gl_c4ub_v3f)
{
RING_API_RETNUMBER(GL_C4UB_V3F);
}
RING_FUNC(ring_get_gl_c3f_v3f)
{
RING_API_RETNUMBER(GL_C3F_V3F);
}
RING_FUNC(ring_get_gl_n3f_v3f)
{
RING_API_RETNUMBER(GL_N3F_V3F);
}
RING_FUNC(ring_get_gl_c4f_n3f_v3f)
{
RING_API_RETNUMBER(GL_C4F_N3F_V3F);
}
RING_FUNC(ring_get_gl_t2f_v3f)
{
RING_API_RETNUMBER(GL_T2F_V3F);
}
RING_FUNC(ring_get_gl_t4f_v4f)
{
RING_API_RETNUMBER(GL_T4F_V4F);
}
RING_FUNC(ring_get_gl_t2f_c4ub_v3f)
{
RING_API_RETNUMBER(GL_T2F_C4UB_V3F);
}
RING_FUNC(ring_get_gl_t2f_c3f_v3f)
{
RING_API_RETNUMBER(GL_T2F_C3F_V3F);
}
RING_FUNC(ring_get_gl_t2f_n3f_v3f)
{
RING_API_RETNUMBER(GL_T2F_N3F_V3F);
}
RING_FUNC(ring_get_gl_t2f_c4f_n3f_v3f)
{
RING_API_RETNUMBER(GL_T2F_C4F_N3F_V3F);
}
RING_FUNC(ring_get_gl_t4f_c4f_n3f_v4f)
{
RING_API_RETNUMBER(GL_T4F_C4F_N3F_V4F);
}
RING_FUNC(ring_get_gl_clip_plane0)
{
RING_API_RETNUMBER(GL_CLIP_PLANE0);
}
RING_FUNC(ring_get_gl_clip_plane1)
{
RING_API_RETNUMBER(GL_CLIP_PLANE1);
}
RING_FUNC(ring_get_gl_clip_plane2)
{
RING_API_RETNUMBER(GL_CLIP_PLANE2);
}
RING_FUNC(ring_get_gl_clip_plane3)
{
RING_API_RETNUMBER(GL_CLIP_PLANE3);
}
RING_FUNC(ring_get_gl_clip_plane4)
{
RING_API_RETNUMBER(GL_CLIP_PLANE4);
}
RING_FUNC(ring_get_gl_clip_plane5)
{
RING_API_RETNUMBER(GL_CLIP_PLANE5);
}
RING_FUNC(ring_get_gl_light0)
{
RING_API_RETNUMBER(GL_LIGHT0);
}
RING_FUNC(ring_get_gl_color_buffer_bit)
{
RING_API_RETNUMBER(GL_COLOR_BUFFER_BIT);
}
RING_FUNC(ring_get_gl_light1)
{
RING_API_RETNUMBER(GL_LIGHT1);
}
RING_FUNC(ring_get_gl_light2)
{
RING_API_RETNUMBER(GL_LIGHT2);
}
RING_FUNC(ring_get_gl_light3)
{
RING_API_RETNUMBER(GL_LIGHT3);
}
RING_FUNC(ring_get_gl_light4)
{
RING_API_RETNUMBER(GL_LIGHT4);
}
RING_FUNC(ring_get_gl_light5)
{
RING_API_RETNUMBER(GL_LIGHT5);
}
RING_FUNC(ring_get_gl_light6)
{
RING_API_RETNUMBER(GL_LIGHT6);
}
RING_FUNC(ring_get_gl_light7)
{
RING_API_RETNUMBER(GL_LIGHT7);
}
RING_FUNC(ring_get_gl_hint_bit)
{
RING_API_RETNUMBER(GL_HINT_BIT);
}
RING_FUNC(ring_get_gl_polygon_offset_fill)
{
RING_API_RETNUMBER(GL_POLYGON_OFFSET_FILL);
}
RING_FUNC(ring_get_gl_polygon_offset_factor)
{
RING_API_RETNUMBER(GL_POLYGON_OFFSET_FACTOR);
}
RING_FUNC(ring_get_gl_alpha4)
{
RING_API_RETNUMBER(GL_ALPHA4);
}
RING_FUNC(ring_get_gl_alpha8)
{
RING_API_RETNUMBER(GL_ALPHA8);
}
RING_FUNC(ring_get_gl_alpha12)
{
RING_API_RETNUMBER(GL_ALPHA12);
}
RING_FUNC(ring_get_gl_alpha16)
{
RING_API_RETNUMBER(GL_ALPHA16);
}
RING_FUNC(ring_get_gl_luminance4)
{
RING_API_RETNUMBER(GL_LUMINANCE4);
}
RING_FUNC(ring_get_gl_luminance8)
{
RING_API_RETNUMBER(GL_LUMINANCE8);
}
RING_FUNC(ring_get_gl_luminance12)
{
RING_API_RETNUMBER(GL_LUMINANCE12);
}
RING_FUNC(ring_get_gl_luminance16)
{
RING_API_RETNUMBER(GL_LUMINANCE16);
}
RING_FUNC(ring_get_gl_luminance4_alpha4)
{
RING_API_RETNUMBER(GL_LUMINANCE4_ALPHA4);
}
RING_FUNC(ring_get_gl_luminance6_alpha2)
{
RING_API_RETNUMBER(GL_LUMINANCE6_ALPHA2);
}
RING_FUNC(ring_get_gl_luminance8_alpha8)
{
RING_API_RETNUMBER(GL_LUMINANCE8_ALPHA8);
}
RING_FUNC(ring_get_gl_luminance12_alpha4)
{
RING_API_RETNUMBER(GL_LUMINANCE12_ALPHA4);
}
RING_FUNC(ring_get_gl_luminance12_alpha12)
{
RING_API_RETNUMBER(GL_LUMINANCE12_ALPHA12);
}
RING_FUNC(ring_get_gl_luminance16_alpha16)
{
RING_API_RETNUMBER(GL_LUMINANCE16_ALPHA16);
}
RING_FUNC(ring_get_gl_intensity)
{
RING_API_RETNUMBER(GL_INTENSITY);
}
RING_FUNC(ring_get_gl_intensity4)
{
RING_API_RETNUMBER(GL_INTENSITY4);
}
RING_FUNC(ring_get_gl_intensity8)
{
RING_API_RETNUMBER(GL_INTENSITY8);
}
RING_FUNC(ring_get_gl_intensity12)
{
RING_API_RETNUMBER(GL_INTENSITY12);
}
RING_FUNC(ring_get_gl_intensity16)
{
RING_API_RETNUMBER(GL_INTENSITY16);
}
RING_FUNC(ring_get_gl_rgb4)
{
RING_API_RETNUMBER(GL_RGB4);
}
RING_FUNC(ring_get_gl_rgb5)
{
RING_API_RETNUMBER(GL_RGB5);
}
RING_FUNC(ring_get_gl_rgb8)
{
RING_API_RETNUMBER(GL_RGB8);
}
RING_FUNC(ring_get_gl_rgb10)
{
RING_API_RETNUMBER(GL_RGB10);
}
RING_FUNC(ring_get_gl_rgb12)
{
RING_API_RETNUMBER(GL_RGB12);
}
RING_FUNC(ring_get_gl_rgb16)
{
RING_API_RETNUMBER(GL_RGB16);
}
RING_FUNC(ring_get_gl_rgba2)
{
RING_API_RETNUMBER(GL_RGBA2);
}
RING_FUNC(ring_get_gl_rgba4)
{
RING_API_RETNUMBER(GL_RGBA4);
}
RING_FUNC(ring_get_gl_rgb5_a1)
{
RING_API_RETNUMBER(GL_RGB5_A1);
}
RING_FUNC(ring_get_gl_rgba8)
{
RING_API_RETNUMBER(GL_RGBA8);
}
RING_FUNC(ring_get_gl_rgb10_a2)
{
RING_API_RETNUMBER(GL_RGB10_A2);
}
RING_FUNC(ring_get_gl_rgba12)
{
RING_API_RETNUMBER(GL_RGBA12);
}
RING_FUNC(ring_get_gl_rgba16)
{
RING_API_RETNUMBER(GL_RGBA16);
}
RING_FUNC(ring_get_gl_texture_red_size)
{
RING_API_RETNUMBER(GL_TEXTURE_RED_SIZE);
}
RING_FUNC(ring_get_gl_texture_green_size)
{
RING_API_RETNUMBER(GL_TEXTURE_GREEN_SIZE);
}
RING_FUNC(ring_get_gl_texture_blue_size)
{
RING_API_RETNUMBER(GL_TEXTURE_BLUE_SIZE);
}
RING_FUNC(ring_get_gl_texture_alpha_size)
{
RING_API_RETNUMBER(GL_TEXTURE_ALPHA_SIZE);
}
RING_FUNC(ring_get_gl_texture_luminance_size)
{
RING_API_RETNUMBER(GL_TEXTURE_LUMINANCE_SIZE);
}
RING_FUNC(ring_get_gl_texture_intensity_size)
{
RING_API_RETNUMBER(GL_TEXTURE_INTENSITY_SIZE);
}
RING_FUNC(ring_get_gl_proxy_texture_1d)
{
RING_API_RETNUMBER(GL_PROXY_TEXTURE_1D);
}
RING_FUNC(ring_get_gl_proxy_texture_2d)
{
RING_API_RETNUMBER(GL_PROXY_TEXTURE_2D);
}
RING_FUNC(ring_get_gl_texture_priority)
{
RING_API_RETNUMBER(GL_TEXTURE_PRIORITY);
}
RING_FUNC(ring_get_gl_texture_resident)
{
RING_API_RETNUMBER(GL_TEXTURE_RESIDENT);
}
RING_FUNC(ring_get_gl_texture_binding_1d)
{
RING_API_RETNUMBER(GL_TEXTURE_BINDING_1D);
}
RING_FUNC(ring_get_gl_texture_binding_2d)
{
RING_API_RETNUMBER(GL_TEXTURE_BINDING_2D);
}
RING_FUNC(ring_get_gl_vertex_array)
{
RING_API_RETNUMBER(GL_VERTEX_ARRAY);
}
RING_FUNC(ring_get_gl_normal_array)
{
RING_API_RETNUMBER(GL_NORMAL_ARRAY);
}
RING_FUNC(ring_get_gl_color_array)
{
RING_API_RETNUMBER(GL_COLOR_ARRAY);
}
RING_FUNC(ring_get_gl_index_array)
{
RING_API_RETNUMBER(GL_INDEX_ARRAY);
}
RING_FUNC(ring_get_gl_texture_coord_array)
{
RING_API_RETNUMBER(GL_TEXTURE_COORD_ARRAY);
}
RING_FUNC(ring_get_gl_edge_flag_array)
{
RING_API_RETNUMBER(GL_EDGE_FLAG_ARRAY);
}
RING_FUNC(ring_get_gl_vertex_array_size)
{
RING_API_RETNUMBER(GL_VERTEX_ARRAY_SIZE);
}
RING_FUNC(ring_get_gl_vertex_array_type)
{
RING_API_RETNUMBER(GL_VERTEX_ARRAY_TYPE);
}
RING_FUNC(ring_get_gl_vertex_array_stride)
{
RING_API_RETNUMBER(GL_VERTEX_ARRAY_STRIDE);
}
RING_FUNC(ring_get_gl_normal_array_type)
{
RING_API_RETNUMBER(GL_NORMAL_ARRAY_TYPE);
}
RING_FUNC(ring_get_gl_normal_array_stride)
{
RING_API_RETNUMBER(GL_NORMAL_ARRAY_STRIDE);
}
RING_FUNC(ring_get_gl_color_array_size)
{
RING_API_RETNUMBER(GL_COLOR_ARRAY_SIZE);
}
RING_FUNC(ring_get_gl_color_array_type)
{
RING_API_RETNUMBER(GL_COLOR_ARRAY_TYPE);
}
RING_FUNC(ring_get_gl_color_array_stride)
{
RING_API_RETNUMBER(GL_COLOR_ARRAY_STRIDE);
}
RING_FUNC(ring_get_gl_index_array_type)
{
RING_API_RETNUMBER(GL_INDEX_ARRAY_TYPE);
}
RING_FUNC(ring_get_gl_index_array_stride)
{
RING_API_RETNUMBER(GL_INDEX_ARRAY_STRIDE);
}
RING_FUNC(ring_get_gl_texture_coord_array_size)
{
RING_API_RETNUMBER(GL_TEXTURE_COORD_ARRAY_SIZE);
}
RING_FUNC(ring_get_gl_texture_coord_array_type)
{
RING_API_RETNUMBER(GL_TEXTURE_COORD_ARRAY_TYPE);
}
RING_FUNC(ring_get_gl_texture_coord_array_stride)
{
RING_API_RETNUMBER(GL_TEXTURE_COORD_ARRAY_STRIDE);
}
RING_FUNC(ring_get_gl_edge_flag_array_stride)
{
RING_API_RETNUMBER(GL_EDGE_FLAG_ARRAY_STRIDE);
}
RING_FUNC(ring_get_gl_vertex_array_pointer)
{
RING_API_RETNUMBER(GL_VERTEX_ARRAY_POINTER);
}
RING_FUNC(ring_get_gl_normal_array_pointer)
{
RING_API_RETNUMBER(GL_NORMAL_ARRAY_POINTER);
}
RING_FUNC(ring_get_gl_color_array_pointer)
{
RING_API_RETNUMBER(GL_COLOR_ARRAY_POINTER);
}
RING_FUNC(ring_get_gl_index_array_pointer)
{
RING_API_RETNUMBER(GL_INDEX_ARRAY_POINTER);
}
RING_FUNC(ring_get_gl_texture_coord_array_pointer)
{
RING_API_RETNUMBER(GL_TEXTURE_COORD_ARRAY_POINTER);
}
RING_FUNC(ring_get_gl_edge_flag_array_pointer)
{
RING_API_RETNUMBER(GL_EDGE_FLAG_ARRAY_POINTER);
}
RING_FUNC(ring_get_gl_color_index1_ext)
{
RING_API_RETNUMBER(GL_COLOR_INDEX1_EXT);
}
RING_FUNC(ring_get_gl_color_index2_ext)
{
RING_API_RETNUMBER(GL_COLOR_INDEX2_EXT);
}
RING_FUNC(ring_get_gl_color_index4_ext)
{
RING_API_RETNUMBER(GL_COLOR_INDEX4_EXT);
}
RING_FUNC(ring_get_gl_color_index8_ext)
{
RING_API_RETNUMBER(GL_COLOR_INDEX8_EXT);
}
RING_FUNC(ring_get_gl_color_index12_ext)
{
RING_API_RETNUMBER(GL_COLOR_INDEX12_EXT);
}
RING_FUNC(ring_get_gl_color_index16_ext)
{
RING_API_RETNUMBER(GL_COLOR_INDEX16_EXT);
}
RING_FUNC(ring_get_gl_eval_bit)
{
RING_API_RETNUMBER(GL_EVAL_BIT);
}
RING_FUNC(ring_get_gl_list_bit)
{
RING_API_RETNUMBER(GL_LIST_BIT);
}
RING_FUNC(ring_get_gl_texture_bit)
{
RING_API_RETNUMBER(GL_TEXTURE_BIT);
}
RING_FUNC(ring_get_gl_scissor_bit)
{
RING_API_RETNUMBER(GL_SCISSOR_BIT);
}
RING_FUNC(ring_get_gl_all_attrib_bits)
{
RING_API_RETNUMBER(GL_ALL_ATTRIB_BITS);
}
RING_FUNC(ring_get_gl_client_all_attrib_bits)
{
RING_API_RETNUMBER(GL_CLIENT_ALL_ATTRIB_BITS);
}
RING_FUNC(ring_get_gl_smooth_point_size_range)
{
RING_API_RETNUMBER(GL_SMOOTH_POINT_SIZE_RANGE);
}
RING_FUNC(ring_get_gl_smooth_point_size_granularity)
{
RING_API_RETNUMBER(GL_SMOOTH_POINT_SIZE_GRANULARITY);
}
RING_FUNC(ring_get_gl_smooth_line_width_range)
{
RING_API_RETNUMBER(GL_SMOOTH_LINE_WIDTH_RANGE);
}
RING_FUNC(ring_get_gl_smooth_line_width_granularity)
{
RING_API_RETNUMBER(GL_SMOOTH_LINE_WIDTH_GRANULARITY);
}
RING_FUNC(ring_get_gl_unsigned_byte_3_3_2)
{
RING_API_RETNUMBER(GL_UNSIGNED_BYTE_3_3_2);
}
RING_FUNC(ring_get_gl_unsigned_short_4_4_4_4)
{
RING_API_RETNUMBER(GL_UNSIGNED_SHORT_4_4_4_4);
}
RING_FUNC(ring_get_gl_unsigned_short_5_5_5_1)
{
RING_API_RETNUMBER(GL_UNSIGNED_SHORT_5_5_5_1);
}
RING_FUNC(ring_get_gl_unsigned_int_8_8_8_8)
{
RING_API_RETNUMBER(GL_UNSIGNED_INT_8_8_8_8);
}
RING_FUNC(ring_get_gl_unsigned_int_10_10_10_2)
{
RING_API_RETNUMBER(GL_UNSIGNED_INT_10_10_10_2);
}
RING_FUNC(ring_get_gl_rescale_normal)
{
RING_API_RETNUMBER(GL_RESCALE_NORMAL);
}
RING_FUNC(ring_get_gl_texture_binding_3d)
{
RING_API_RETNUMBER(GL_TEXTURE_BINDING_3D);
}
RING_FUNC(ring_get_gl_pack_skip_images)
{
RING_API_RETNUMBER(GL_PACK_SKIP_IMAGES);
}
RING_FUNC(ring_get_gl_pack_image_height)
{
RING_API_RETNUMBER(GL_PACK_IMAGE_HEIGHT);
}
RING_FUNC(ring_get_gl_unpack_skip_images)
{
RING_API_RETNUMBER(GL_UNPACK_SKIP_IMAGES);
}
RING_FUNC(ring_get_gl_unpack_image_height)
{
RING_API_RETNUMBER(GL_UNPACK_IMAGE_HEIGHT);
}
RING_FUNC(ring_get_gl_texture_3d)
{
RING_API_RETNUMBER(GL_TEXTURE_3D);
}
RING_FUNC(ring_get_gl_proxy_texture_3d)
{
RING_API_RETNUMBER(GL_PROXY_TEXTURE_3D);
}
RING_FUNC(ring_get_gl_texture_depth)
{
RING_API_RETNUMBER(GL_TEXTURE_DEPTH);
}
RING_FUNC(ring_get_gl_texture_wrap_r)
{
RING_API_RETNUMBER(GL_TEXTURE_WRAP_R);
}
RING_FUNC(ring_get_gl_max_3d_texture_size)
{
RING_API_RETNUMBER(GL_MAX_3D_TEXTURE_SIZE);
}
RING_FUNC(ring_get_gl_bgr)
{
RING_API_RETNUMBER(GL_BGR);
}
RING_FUNC(ring_get_gl_bgra)
{
RING_API_RETNUMBER(GL_BGRA);
}
RING_FUNC(ring_get_gl_max_elements_vertices)
{
RING_API_RETNUMBER(GL_MAX_ELEMENTS_VERTICES);
}
RING_FUNC(ring_get_gl_max_elements_indices)
{
RING_API_RETNUMBER(GL_MAX_ELEMENTS_INDICES);
}
RING_FUNC(ring_get_gl_clamp_to_edge)
{
RING_API_RETNUMBER(GL_CLAMP_TO_EDGE);
}
RING_FUNC(ring_get_gl_texture_min_lod)
{
RING_API_RETNUMBER(GL_TEXTURE_MIN_LOD);
}
RING_FUNC(ring_get_gl_texture_max_lod)
{
RING_API_RETNUMBER(GL_TEXTURE_MAX_LOD);
}
RING_FUNC(ring_get_gl_texture_base_level)
{
RING_API_RETNUMBER(GL_TEXTURE_BASE_LEVEL);
}
RING_FUNC(ring_get_gl_texture_max_level)
{
RING_API_RETNUMBER(GL_TEXTURE_MAX_LEVEL);
}
RING_FUNC(ring_get_gl_light_model_color_control)
{
RING_API_RETNUMBER(GL_LIGHT_MODEL_COLOR_CONTROL);
}
RING_FUNC(ring_get_gl_single_color)
{
RING_API_RETNUMBER(GL_SINGLE_COLOR);
}
RING_FUNC(ring_get_gl_separate_specular_color)
{
RING_API_RETNUMBER(GL_SEPARATE_SPECULAR_COLOR);
}
RING_FUNC(ring_get_gl_unsigned_byte_2_3_3_rev)
{
RING_API_RETNUMBER(GL_UNSIGNED_BYTE_2_3_3_REV);
}
RING_FUNC(ring_get_gl_unsigned_short_5_6_5)
{
RING_API_RETNUMBER(GL_UNSIGNED_SHORT_5_6_5);
}
RING_FUNC(ring_get_gl_unsigned_short_5_6_5_rev)
{
RING_API_RETNUMBER(GL_UNSIGNED_SHORT_5_6_5_REV);
}
RING_FUNC(ring_get_gl_unsigned_short_4_4_4_4_rev)
{
RING_API_RETNUMBER(GL_UNSIGNED_SHORT_4_4_4_4_REV);
}
RING_FUNC(ring_get_gl_unsigned_short_1_5_5_5_rev)
{
RING_API_RETNUMBER(GL_UNSIGNED_SHORT_1_5_5_5_REV);
}
RING_FUNC(ring_get_gl_unsigned_int_8_8_8_8_rev)
{
RING_API_RETNUMBER(GL_UNSIGNED_INT_8_8_8_8_REV);
}
RING_FUNC(ring_get_gl_aliased_point_size_range)
{
RING_API_RETNUMBER(GL_ALIASED_POINT_SIZE_RANGE);
}
RING_FUNC(ring_get_gl_aliased_line_width_range)
{
RING_API_RETNUMBER(GL_ALIASED_LINE_WIDTH_RANGE);
}
RING_FUNC(ring_get_gl_multisample)
{
RING_API_RETNUMBER(GL_MULTISAMPLE);
}
RING_FUNC(ring_get_gl_sample_alpha_to_coverage)
{
RING_API_RETNUMBER(GL_SAMPLE_ALPHA_TO_COVERAGE);
}
RING_FUNC(ring_get_gl_sample_alpha_to_one)
{
RING_API_RETNUMBER(GL_SAMPLE_ALPHA_TO_ONE);
}
RING_FUNC(ring_get_gl_sample_coverage)
{
RING_API_RETNUMBER(GL_SAMPLE_COVERAGE);
}
RING_FUNC(ring_get_gl_sample_buffers)
{
RING_API_RETNUMBER(GL_SAMPLE_BUFFERS);
}
RING_FUNC(ring_get_gl_samples)
{
RING_API_RETNUMBER(GL_SAMPLES);
}
RING_FUNC(ring_get_gl_sample_coverage_value)
{
RING_API_RETNUMBER(GL_SAMPLE_COVERAGE_VALUE);
}
RING_FUNC(ring_get_gl_sample_coverage_invert)
{
RING_API_RETNUMBER(GL_SAMPLE_COVERAGE_INVERT);
}
RING_FUNC(ring_get_gl_clamp_to_border)
{
RING_API_RETNUMBER(GL_CLAMP_TO_BORDER);
}
RING_FUNC(ring_get_gl_texture0)
{
RING_API_RETNUMBER(GL_TEXTURE0);
}
RING_FUNC(ring_get_gl_texture1)
{
RING_API_RETNUMBER(GL_TEXTURE1);
}
RING_FUNC(ring_get_gl_texture2)
{
RING_API_RETNUMBER(GL_TEXTURE2);
}
RING_FUNC(ring_get_gl_texture3)
{
RING_API_RETNUMBER(GL_TEXTURE3);
}
RING_FUNC(ring_get_gl_texture4)
{
RING_API_RETNUMBER(GL_TEXTURE4);
}
RING_FUNC(ring_get_gl_texture5)
{
RING_API_RETNUMBER(GL_TEXTURE5);
}
RING_FUNC(ring_get_gl_texture6)
{
RING_API_RETNUMBER(GL_TEXTURE6);
}
RING_FUNC(ring_get_gl_texture7)
{
RING_API_RETNUMBER(GL_TEXTURE7);
}
RING_FUNC(ring_get_gl_texture8)
{
RING_API_RETNUMBER(GL_TEXTURE8);
}
RING_FUNC(ring_get_gl_texture9)
{
RING_API_RETNUMBER(GL_TEXTURE9);
}
RING_FUNC(ring_get_gl_texture10)
{
RING_API_RETNUMBER(GL_TEXTURE10);
}
RING_FUNC(ring_get_gl_texture11)
{
RING_API_RETNUMBER(GL_TEXTURE11);
}
RING_FUNC(ring_get_gl_texture12)
{
RING_API_RETNUMBER(GL_TEXTURE12);
}
RING_FUNC(ring_get_gl_texture13)
{
RING_API_RETNUMBER(GL_TEXTURE13);
}
RING_FUNC(ring_get_gl_texture14)
{
RING_API_RETNUMBER(GL_TEXTURE14);
}
RING_FUNC(ring_get_gl_texture15)
{
RING_API_RETNUMBER(GL_TEXTURE15);
}
RING_FUNC(ring_get_gl_texture16)
{
RING_API_RETNUMBER(GL_TEXTURE16);
}
RING_FUNC(ring_get_gl_texture17)
{
RING_API_RETNUMBER(GL_TEXTURE17);
}
RING_FUNC(ring_get_gl_texture18)
{
RING_API_RETNUMBER(GL_TEXTURE18);
}
RING_FUNC(ring_get_gl_texture19)
{
RING_API_RETNUMBER(GL_TEXTURE19);
}
RING_FUNC(ring_get_gl_texture20)
{
RING_API_RETNUMBER(GL_TEXTURE20);
}
RING_FUNC(ring_get_gl_texture21)
{
RING_API_RETNUMBER(GL_TEXTURE21);
}
RING_FUNC(ring_get_gl_texture22)
{
RING_API_RETNUMBER(GL_TEXTURE22);
}
RING_FUNC(ring_get_gl_texture23)
{
RING_API_RETNUMBER(GL_TEXTURE23);
}
RING_FUNC(ring_get_gl_texture24)
{
RING_API_RETNUMBER(GL_TEXTURE24);
}
RING_FUNC(ring_get_gl_texture25)
{
RING_API_RETNUMBER(GL_TEXTURE25);
}
RING_FUNC(ring_get_gl_texture26)
{
RING_API_RETNUMBER(GL_TEXTURE26);
}
RING_FUNC(ring_get_gl_texture27)
{
RING_API_RETNUMBER(GL_TEXTURE27);
}
RING_FUNC(ring_get_gl_texture28)
{
RING_API_RETNUMBER(GL_TEXTURE28);
}
RING_FUNC(ring_get_gl_texture29)
{
RING_API_RETNUMBER(GL_TEXTURE29);
}
RING_FUNC(ring_get_gl_texture30)
{
RING_API_RETNUMBER(GL_TEXTURE30);
}
RING_FUNC(ring_get_gl_texture31)
{
RING_API_RETNUMBER(GL_TEXTURE31);
}
RING_FUNC(ring_get_gl_active_texture)
{
RING_API_RETNUMBER(GL_ACTIVE_TEXTURE);
}
RING_FUNC(ring_get_gl_client_active_texture)
{
RING_API_RETNUMBER(GL_CLIENT_ACTIVE_TEXTURE);
}
RING_FUNC(ring_get_gl_max_texture_units)
{
RING_API_RETNUMBER(GL_MAX_TEXTURE_UNITS);
}
RING_FUNC(ring_get_gl_transpose_modelview_matrix)
{
RING_API_RETNUMBER(GL_TRANSPOSE_MODELVIEW_MATRIX);
}
RING_FUNC(ring_get_gl_transpose_projection_matrix)
{
RING_API_RETNUMBER(GL_TRANSPOSE_PROJECTION_MATRIX);
}
RING_FUNC(ring_get_gl_transpose_texture_matrix)
{
RING_API_RETNUMBER(GL_TRANSPOSE_TEXTURE_MATRIX);
}
RING_FUNC(ring_get_gl_transpose_color_matrix)
{
RING_API_RETNUMBER(GL_TRANSPOSE_COLOR_MATRIX);
}
RING_FUNC(ring_get_gl_subtract)
{
RING_API_RETNUMBER(GL_SUBTRACT);
}
RING_FUNC(ring_get_gl_compressed_alpha)
{
RING_API_RETNUMBER(GL_COMPRESSED_ALPHA);
}
RING_FUNC(ring_get_gl_compressed_luminance)
{
RING_API_RETNUMBER(GL_COMPRESSED_LUMINANCE);
}
RING_FUNC(ring_get_gl_compressed_luminance_alpha)
{
RING_API_RETNUMBER(GL_COMPRESSED_LUMINANCE_ALPHA);
}
RING_FUNC(ring_get_gl_compressed_intensity)
{
RING_API_RETNUMBER(GL_COMPRESSED_INTENSITY);
}
RING_FUNC(ring_get_gl_compressed_rgb)
{
RING_API_RETNUMBER(GL_COMPRESSED_RGB);
}
RING_FUNC(ring_get_gl_compressed_rgba)
{
RING_API_RETNUMBER(GL_COMPRESSED_RGBA);
}
RING_FUNC(ring_get_gl_texture_compression_hint)
{
RING_API_RETNUMBER(GL_TEXTURE_COMPRESSION_HINT);
}
RING_FUNC(ring_get_gl_normal_map)
{
RING_API_RETNUMBER(GL_NORMAL_MAP);
}
RING_FUNC(ring_get_gl_reflection_map)
{
RING_API_RETNUMBER(GL_REFLECTION_MAP);
}
RING_FUNC(ring_get_gl_texture_cube_map)
{
RING_API_RETNUMBER(GL_TEXTURE_CUBE_MAP);
}
RING_FUNC(ring_get_gl_texture_binding_cube_map)
{
RING_API_RETNUMBER(GL_TEXTURE_BINDING_CUBE_MAP);
}
RING_FUNC(ring_get_gl_texture_cube_map_positive_x)
{
RING_API_RETNUMBER(GL_TEXTURE_CUBE_MAP_POSITIVE_X);
}
RING_FUNC(ring_get_gl_texture_cube_map_negative_x)
{
RING_API_RETNUMBER(GL_TEXTURE_CUBE_MAP_NEGATIVE_X);
}
RING_FUNC(ring_get_gl_texture_cube_map_positive_y)
{
RING_API_RETNUMBER(GL_TEXTURE_CUBE_MAP_POSITIVE_Y);
}
RING_FUNC(ring_get_gl_texture_cube_map_negative_y)
{
RING_API_RETNUMBER(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y);
}
RING_FUNC(ring_get_gl_texture_cube_map_positive_z)
{
RING_API_RETNUMBER(GL_TEXTURE_CUBE_MAP_POSITIVE_Z);
}
RING_FUNC(ring_get_gl_texture_cube_map_negative_z)
{
RING_API_RETNUMBER(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z);
}
RING_FUNC(ring_get_gl_proxy_texture_cube_map)
{
RING_API_RETNUMBER(GL_PROXY_TEXTURE_CUBE_MAP);
}
RING_FUNC(ring_get_gl_max_cube_map_texture_size)
{
RING_API_RETNUMBER(GL_MAX_CUBE_MAP_TEXTURE_SIZE);
}
RING_FUNC(ring_get_gl_combine)
{
RING_API_RETNUMBER(GL_COMBINE);
}
RING_FUNC(ring_get_gl_combine_rgb)
{
RING_API_RETNUMBER(GL_COMBINE_RGB);
}
RING_FUNC(ring_get_gl_combine_alpha)
{
RING_API_RETNUMBER(GL_COMBINE_ALPHA);
}
RING_FUNC(ring_get_gl_rgb_scale)
{
RING_API_RETNUMBER(GL_RGB_SCALE);
}
RING_FUNC(ring_get_gl_add_signed)
{
RING_API_RETNUMBER(GL_ADD_SIGNED);
}
RING_FUNC(ring_get_gl_interpolate)
{
RING_API_RETNUMBER(GL_INTERPOLATE);
}
RING_FUNC(ring_get_gl_constant)
{
RING_API_RETNUMBER(GL_CONSTANT);
}
RING_FUNC(ring_get_gl_primary_color)
{
RING_API_RETNUMBER(GL_PRIMARY_COLOR);
}
RING_FUNC(ring_get_gl_previous)
{
RING_API_RETNUMBER(GL_PREVIOUS);
}
RING_FUNC(ring_get_gl_source0_rgb)
{
RING_API_RETNUMBER(GL_SOURCE0_RGB);
}
RING_FUNC(ring_get_gl_source1_rgb)
{
RING_API_RETNUMBER(GL_SOURCE1_RGB);
}
RING_FUNC(ring_get_gl_source2_rgb)
{
RING_API_RETNUMBER(GL_SOURCE2_RGB);
}
RING_FUNC(ring_get_gl_source0_alpha)
{
RING_API_RETNUMBER(GL_SOURCE0_ALPHA);
}
RING_FUNC(ring_get_gl_source1_alpha)
{
RING_API_RETNUMBER(GL_SOURCE1_ALPHA);
}
RING_FUNC(ring_get_gl_source2_alpha)
{
RING_API_RETNUMBER(GL_SOURCE2_ALPHA);
}
RING_FUNC(ring_get_gl_operand0_rgb)
{
RING_API_RETNUMBER(GL_OPERAND0_RGB);
}
RING_FUNC(ring_get_gl_operand1_rgb)
{
RING_API_RETNUMBER(GL_OPERAND1_RGB);
}
RING_FUNC(ring_get_gl_operand2_rgb)
{
RING_API_RETNUMBER(GL_OPERAND2_RGB);
}
RING_FUNC(ring_get_gl_operand0_alpha)
{
RING_API_RETNUMBER(GL_OPERAND0_ALPHA);
}
RING_FUNC(ring_get_gl_operand1_alpha)
{
RING_API_RETNUMBER(GL_OPERAND1_ALPHA);
}
RING_FUNC(ring_get_gl_operand2_alpha)
{
RING_API_RETNUMBER(GL_OPERAND2_ALPHA);
}
RING_FUNC(ring_get_gl_texture_compressed_image_size)
{
RING_API_RETNUMBER(GL_TEXTURE_COMPRESSED_IMAGE_SIZE);
}
RING_FUNC(ring_get_gl_texture_compressed)
{
RING_API_RETNUMBER(GL_TEXTURE_COMPRESSED);
}
RING_FUNC(ring_get_gl_num_compressed_texture_formats)
{
RING_API_RETNUMBER(GL_NUM_COMPRESSED_TEXTURE_FORMATS);
}
RING_FUNC(ring_get_gl_compressed_texture_formats)
{
RING_API_RETNUMBER(GL_COMPRESSED_TEXTURE_FORMATS);
}
RING_FUNC(ring_get_gl_dot3_rgb)
{
RING_API_RETNUMBER(GL_DOT3_RGB);
}
RING_FUNC(ring_get_gl_dot3_rgba)
{
RING_API_RETNUMBER(GL_DOT3_RGBA);
}
RING_FUNC(ring_get_gl_multisample_bit)
{
RING_API_RETNUMBER(GL_MULTISAMPLE_BIT);
}
RING_FUNC(ring_get_gl_blend_dst_rgb)
{
RING_API_RETNUMBER(GL_BLEND_DST_RGB);
}
RING_FUNC(ring_get_gl_blend_src_rgb)
{
RING_API_RETNUMBER(GL_BLEND_SRC_RGB);
}
RING_FUNC(ring_get_gl_blend_dst_alpha)
{
RING_API_RETNUMBER(GL_BLEND_DST_ALPHA);
}
RING_FUNC(ring_get_gl_blend_src_alpha)
{
RING_API_RETNUMBER(GL_BLEND_SRC_ALPHA);
}
RING_FUNC(ring_get_gl_point_size_min)
{
RING_API_RETNUMBER(GL_POINT_SIZE_MIN);
}
RING_FUNC(ring_get_gl_point_size_max)
{
RING_API_RETNUMBER(GL_POINT_SIZE_MAX);
}
RING_FUNC(ring_get_gl_point_fade_threshold_size)
{
RING_API_RETNUMBER(GL_POINT_FADE_THRESHOLD_SIZE);
}
RING_FUNC(ring_get_gl_point_distance_attenuation)
{
RING_API_RETNUMBER(GL_POINT_DISTANCE_ATTENUATION);
}
RING_FUNC(ring_get_gl_generate_mipmap)
{
RING_API_RETNUMBER(GL_GENERATE_MIPMAP);
}
RING_FUNC(ring_get_gl_generate_mipmap_hint)
{
RING_API_RETNUMBER(GL_GENERATE_MIPMAP_HINT);
}
RING_FUNC(ring_get_gl_depth_component16)
{
RING_API_RETNUMBER(GL_DEPTH_COMPONENT16);
}
RING_FUNC(ring_get_gl_depth_component24)
{
RING_API_RETNUMBER(GL_DEPTH_COMPONENT24);
}
RING_FUNC(ring_get_gl_depth_component32)
{
RING_API_RETNUMBER(GL_DEPTH_COMPONENT32);
}
RING_FUNC(ring_get_gl_mirrored_repeat)
{
RING_API_RETNUMBER(GL_MIRRORED_REPEAT);
}
RING_FUNC(ring_get_gl_fog_coordinate_source)
{
RING_API_RETNUMBER(GL_FOG_COORDINATE_SOURCE);
}
RING_FUNC(ring_get_gl_fog_coordinate)
{
RING_API_RETNUMBER(GL_FOG_COORDINATE);
}
RING_FUNC(ring_get_gl_fragment_depth)
{
RING_API_RETNUMBER(GL_FRAGMENT_DEPTH);
}
RING_FUNC(ring_get_gl_current_fog_coordinate)
{
RING_API_RETNUMBER(GL_CURRENT_FOG_COORDINATE);
}
RING_FUNC(ring_get_gl_fog_coordinate_array_type)
{
RING_API_RETNUMBER(GL_FOG_COORDINATE_ARRAY_TYPE);
}
RING_FUNC(ring_get_gl_fog_coordinate_array_stride)
{
RING_API_RETNUMBER(GL_FOG_COORDINATE_ARRAY_STRIDE);
}
RING_FUNC(ring_get_gl_fog_coordinate_array_pointer)
{
RING_API_RETNUMBER(GL_FOG_COORDINATE_ARRAY_POINTER);
}
RING_FUNC(ring_get_gl_fog_coordinate_array)
{
RING_API_RETNUMBER(GL_FOG_COORDINATE_ARRAY);
}
RING_FUNC(ring_get_gl_color_sum)
{
RING_API_RETNUMBER(GL_COLOR_SUM);
}
RING_FUNC(ring_get_gl_current_secondary_color)
{
RING_API_RETNUMBER(GL_CURRENT_SECONDARY_COLOR);
}
RING_FUNC(ring_get_gl_secondary_color_array_size)
{
RING_API_RETNUMBER(GL_SECONDARY_COLOR_ARRAY_SIZE);
}
RING_FUNC(ring_get_gl_secondary_color_array_type)
{
RING_API_RETNUMBER(GL_SECONDARY_COLOR_ARRAY_TYPE);
}
RING_FUNC(ring_get_gl_secondary_color_array_stride)
{
RING_API_RETNUMBER(GL_SECONDARY_COLOR_ARRAY_STRIDE);
}
RING_FUNC(ring_get_gl_secondary_color_array_pointer)
{
RING_API_RETNUMBER(GL_SECONDARY_COLOR_ARRAY_POINTER);
}
RING_FUNC(ring_get_gl_secondary_color_array)
{
RING_API_RETNUMBER(GL_SECONDARY_COLOR_ARRAY);
}
RING_FUNC(ring_get_gl_max_texture_lod_bias)
{
RING_API_RETNUMBER(GL_MAX_TEXTURE_LOD_BIAS);
}
RING_FUNC(ring_get_gl_texture_filter_control)
{
RING_API_RETNUMBER(GL_TEXTURE_FILTER_CONTROL);
}
RING_FUNC(ring_get_gl_texture_lod_bias)
{
RING_API_RETNUMBER(GL_TEXTURE_LOD_BIAS);
}
RING_FUNC(ring_get_gl_incr_wrap)
{
RING_API_RETNUMBER(GL_INCR_WRAP);
}
RING_FUNC(ring_get_gl_decr_wrap)
{
RING_API_RETNUMBER(GL_DECR_WRAP);
}
RING_FUNC(ring_get_gl_texture_depth_size)
{
RING_API_RETNUMBER(GL_TEXTURE_DEPTH_SIZE);
}
RING_FUNC(ring_get_gl_depth_texture_mode)
{
RING_API_RETNUMBER(GL_DEPTH_TEXTURE_MODE);
}
RING_FUNC(ring_get_gl_texture_compare_mode)
{
RING_API_RETNUMBER(GL_TEXTURE_COMPARE_MODE);
}
RING_FUNC(ring_get_gl_texture_compare_func)
{
RING_API_RETNUMBER(GL_TEXTURE_COMPARE_FUNC);
}
RING_FUNC(ring_get_gl_compare_r_to_texture)
{
RING_API_RETNUMBER(GL_COMPARE_R_TO_TEXTURE);
}
RING_FUNC(ring_get_gl_current_fog_coord)
{
RING_API_RETNUMBER(GL_CURRENT_FOG_COORD);
}
RING_FUNC(ring_get_gl_fog_coord)
{
RING_API_RETNUMBER(GL_FOG_COORD);
}
RING_FUNC(ring_get_gl_fog_coord_array)
{
RING_API_RETNUMBER(GL_FOG_COORD_ARRAY);
}
RING_FUNC(ring_get_gl_fog_coord_array_buffer_binding)
{
RING_API_RETNUMBER(GL_FOG_COORD_ARRAY_BUFFER_BINDING);
}
RING_FUNC(ring_get_gl_fog_coord_array_pointer)
{
RING_API_RETNUMBER(GL_FOG_COORD_ARRAY_POINTER);
}
RING_FUNC(ring_get_gl_fog_coord_array_stride)
{
RING_API_RETNUMBER(GL_FOG_COORD_ARRAY_STRIDE);
}
RING_FUNC(ring_get_gl_fog_coord_array_type)
{
RING_API_RETNUMBER(GL_FOG_COORD_ARRAY_TYPE);
}
RING_FUNC(ring_get_gl_fog_coord_src)
{
RING_API_RETNUMBER(GL_FOG_COORD_SRC);
}
RING_FUNC(ring_get_gl_src0_alpha)
{
RING_API_RETNUMBER(GL_SRC0_ALPHA);
}
RING_FUNC(ring_get_gl_src0_rgb)
{
RING_API_RETNUMBER(GL_SRC0_RGB);
}
RING_FUNC(ring_get_gl_src1_alpha)
{
RING_API_RETNUMBER(GL_SRC1_ALPHA);
}
RING_FUNC(ring_get_gl_src1_rgb)
{
RING_API_RETNUMBER(GL_SRC1_RGB);
}
RING_FUNC(ring_get_gl_src2_alpha)
{
RING_API_RETNUMBER(GL_SRC2_ALPHA);
}
RING_FUNC(ring_get_gl_src2_rgb)
{
RING_API_RETNUMBER(GL_SRC2_RGB);
}
RING_FUNC(ring_get_gl_buffer_size)
{
RING_API_RETNUMBER(GL_BUFFER_SIZE);
}
RING_FUNC(ring_get_gl_buffer_usage)
{
RING_API_RETNUMBER(GL_BUFFER_USAGE);
}
RING_FUNC(ring_get_gl_query_counter_bits)
{
RING_API_RETNUMBER(GL_QUERY_COUNTER_BITS);
}
RING_FUNC(ring_get_gl_current_query)
{
RING_API_RETNUMBER(GL_CURRENT_QUERY);
}
RING_FUNC(ring_get_gl_query_result)
{
RING_API_RETNUMBER(GL_QUERY_RESULT);
}
RING_FUNC(ring_get_gl_query_result_available)
{
RING_API_RETNUMBER(GL_QUERY_RESULT_AVAILABLE);
}
RING_FUNC(ring_get_gl_array_buffer)
{
RING_API_RETNUMBER(GL_ARRAY_BUFFER);
}
RING_FUNC(ring_get_gl_element_array_buffer)
{
RING_API_RETNUMBER(GL_ELEMENT_ARRAY_BUFFER);
}
RING_FUNC(ring_get_gl_array_buffer_binding)
{
RING_API_RETNUMBER(GL_ARRAY_BUFFER_BINDING);
}
RING_FUNC(ring_get_gl_element_array_buffer_binding)
{
RING_API_RETNUMBER(GL_ELEMENT_ARRAY_BUFFER_BINDING);
}
RING_FUNC(ring_get_gl_vertex_array_buffer_binding)
{
RING_API_RETNUMBER(GL_VERTEX_ARRAY_BUFFER_BINDING);
}
RING_FUNC(ring_get_gl_normal_array_buffer_binding)
{
RING_API_RETNUMBER(GL_NORMAL_ARRAY_BUFFER_BINDING);
}
RING_FUNC(ring_get_gl_color_array_buffer_binding)
{
RING_API_RETNUMBER(GL_COLOR_ARRAY_BUFFER_BINDING);
}
RING_FUNC(ring_get_gl_index_array_buffer_binding)
{
RING_API_RETNUMBER(GL_INDEX_ARRAY_BUFFER_BINDING);
}
RING_FUNC(ring_get_gl_texture_coord_array_buffer_binding)
{
RING_API_RETNUMBER(GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING);
}
RING_FUNC(ring_get_gl_edge_flag_array_buffer_binding)
{
RING_API_RETNUMBER(GL_EDGE_FLAG_ARRAY_BUFFER_BINDING);
}
RING_FUNC(ring_get_gl_secondary_color_array_buffer_binding)
{
RING_API_RETNUMBER(GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING);
}
RING_FUNC(ring_get_gl_fog_coordinate_array_buffer_binding)
{
RING_API_RETNUMBER(GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING);
}
RING_FUNC(ring_get_gl_weight_array_buffer_binding)
{
RING_API_RETNUMBER(GL_WEIGHT_ARRAY_BUFFER_BINDING);
}
RING_FUNC(ring_get_gl_vertex_attrib_array_buffer_binding)
{
RING_API_RETNUMBER(GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING);
}
RING_FUNC(ring_get_gl_read_only)
{
RING_API_RETNUMBER(GL_READ_ONLY);
}
RING_FUNC(ring_get_gl_write_only)
{
RING_API_RETNUMBER(GL_WRITE_ONLY);
}
RING_FUNC(ring_get_gl_read_write)
{
RING_API_RETNUMBER(GL_READ_WRITE);
}
RING_FUNC(ring_get_gl_buffer_access)
{
RING_API_RETNUMBER(GL_BUFFER_ACCESS);
}
RING_FUNC(ring_get_gl_buffer_mapped)
{
RING_API_RETNUMBER(GL_BUFFER_MAPPED);
}
RING_FUNC(ring_get_gl_buffer_map_pointer)
{
RING_API_RETNUMBER(GL_BUFFER_MAP_POINTER);
}
RING_FUNC(ring_get_gl_stream_draw)
{
RING_API_RETNUMBER(GL_STREAM_DRAW);
}
RING_FUNC(ring_get_gl_stream_read)
{
RING_API_RETNUMBER(GL_STREAM_READ);
}
RING_FUNC(ring_get_gl_stream_copy)
{
RING_API_RETNUMBER(GL_STREAM_COPY);
}
RING_FUNC(ring_get_gl_static_draw)
{
RING_API_RETNUMBER(GL_STATIC_DRAW);
}
RING_FUNC(ring_get_gl_static_read)
{
RING_API_RETNUMBER(GL_STATIC_READ);
}
RING_FUNC(ring_get_gl_static_copy)
{
RING_API_RETNUMBER(GL_STATIC_COPY);
}
RING_FUNC(ring_get_gl_dynamic_draw)
{
RING_API_RETNUMBER(GL_DYNAMIC_DRAW);
}
RING_FUNC(ring_get_gl_dynamic_read)
{
RING_API_RETNUMBER(GL_DYNAMIC_READ);
}
RING_FUNC(ring_get_gl_dynamic_copy)
{
RING_API_RETNUMBER(GL_DYNAMIC_COPY);
}
RING_FUNC(ring_get_gl_samples_passed)
{
RING_API_RETNUMBER(GL_SAMPLES_PASSED);
}
RING_FUNC(ring_get_gl_blend_equation_rgb)
{
RING_API_RETNUMBER(GL_BLEND_EQUATION_RGB);
}
RING_FUNC(ring_get_gl_vertex_attrib_array_enabled)
{
RING_API_RETNUMBER(GL_VERTEX_ATTRIB_ARRAY_ENABLED);
}
RING_FUNC(ring_get_gl_vertex_attrib_array_size)
{
RING_API_RETNUMBER(GL_VERTEX_ATTRIB_ARRAY_SIZE);
}
RING_FUNC(ring_get_gl_vertex_attrib_array_stride)
{
RING_API_RETNUMBER(GL_VERTEX_ATTRIB_ARRAY_STRIDE);
}
RING_FUNC(ring_get_gl_vertex_attrib_array_type)
{
RING_API_RETNUMBER(GL_VERTEX_ATTRIB_ARRAY_TYPE);
}
RING_FUNC(ring_get_gl_current_vertex_attrib)
{
RING_API_RETNUMBER(GL_CURRENT_VERTEX_ATTRIB);
}
RING_FUNC(ring_get_gl_vertex_program_point_size)
{
RING_API_RETNUMBER(GL_VERTEX_PROGRAM_POINT_SIZE);
}
RING_FUNC(ring_get_gl_vertex_program_two_side)
{
RING_API_RETNUMBER(GL_VERTEX_PROGRAM_TWO_SIDE);
}
RING_FUNC(ring_get_gl_vertex_attrib_array_pointer)
{
RING_API_RETNUMBER(GL_VERTEX_ATTRIB_ARRAY_POINTER);
}
RING_FUNC(ring_get_gl_stencil_back_func)
{
RING_API_RETNUMBER(GL_STENCIL_BACK_FUNC);
}
RING_FUNC(ring_get_gl_stencil_back_fail)
{
RING_API_RETNUMBER(GL_STENCIL_BACK_FAIL);
}
RING_FUNC(ring_get_gl_stencil_back_pass_depth_fail)
{
RING_API_RETNUMBER(GL_STENCIL_BACK_PASS_DEPTH_FAIL);
}
RING_FUNC(ring_get_gl_stencil_back_pass_depth_pass)
{
RING_API_RETNUMBER(GL_STENCIL_BACK_PASS_DEPTH_PASS);
}
RING_FUNC(ring_get_gl_max_draw_buffers)
{
RING_API_RETNUMBER(GL_MAX_DRAW_BUFFERS);
}
RING_FUNC(ring_get_gl_draw_buffer0)
{
RING_API_RETNUMBER(GL_DRAW_BUFFER0);
}
RING_FUNC(ring_get_gl_draw_buffer1)
{
RING_API_RETNUMBER(GL_DRAW_BUFFER1);
}
RING_FUNC(ring_get_gl_draw_buffer2)
{
RING_API_RETNUMBER(GL_DRAW_BUFFER2);
}
RING_FUNC(ring_get_gl_draw_buffer3)
{
RING_API_RETNUMBER(GL_DRAW_BUFFER3);
}
RING_FUNC(ring_get_gl_draw_buffer4)
{
RING_API_RETNUMBER(GL_DRAW_BUFFER4);
}
RING_FUNC(ring_get_gl_draw_buffer5)
{
RING_API_RETNUMBER(GL_DRAW_BUFFER5);
}
RING_FUNC(ring_get_gl_draw_buffer6)
{
RING_API_RETNUMBER(GL_DRAW_BUFFER6);
}
RING_FUNC(ring_get_gl_draw_buffer7)
{
RING_API_RETNUMBER(GL_DRAW_BUFFER7);
}
RING_FUNC(ring_get_gl_draw_buffer8)
{
RING_API_RETNUMBER(GL_DRAW_BUFFER8);
}
RING_FUNC(ring_get_gl_draw_buffer9)
{
RING_API_RETNUMBER(GL_DRAW_BUFFER9);
}
RING_FUNC(ring_get_gl_draw_buffer10)
{
RING_API_RETNUMBER(GL_DRAW_BUFFER10);
}
RING_FUNC(ring_get_gl_draw_buffer11)
{
RING_API_RETNUMBER(GL_DRAW_BUFFER11);
}
RING_FUNC(ring_get_gl_draw_buffer12)
{
RING_API_RETNUMBER(GL_DRAW_BUFFER12);
}
RING_FUNC(ring_get_gl_draw_buffer13)
{
RING_API_RETNUMBER(GL_DRAW_BUFFER13);
}
RING_FUNC(ring_get_gl_draw_buffer14)
{
RING_API_RETNUMBER(GL_DRAW_BUFFER14);
}
RING_FUNC(ring_get_gl_draw_buffer15)
{
RING_API_RETNUMBER(GL_DRAW_BUFFER15);
}
RING_FUNC(ring_get_gl_blend_equation_alpha)
{
RING_API_RETNUMBER(GL_BLEND_EQUATION_ALPHA);
}
RING_FUNC(ring_get_gl_point_sprite)
{
RING_API_RETNUMBER(GL_POINT_SPRITE);
}
RING_FUNC(ring_get_gl_coord_replace)
{
RING_API_RETNUMBER(GL_COORD_REPLACE);
}
RING_FUNC(ring_get_gl_max_vertex_attribs)
{
RING_API_RETNUMBER(GL_MAX_VERTEX_ATTRIBS);
}
RING_FUNC(ring_get_gl_vertex_attrib_array_normalized)
{
RING_API_RETNUMBER(GL_VERTEX_ATTRIB_ARRAY_NORMALIZED);
}
RING_FUNC(ring_get_gl_max_texture_coords)
{
RING_API_RETNUMBER(GL_MAX_TEXTURE_COORDS);
}
RING_FUNC(ring_get_gl_max_texture_image_units)
{
RING_API_RETNUMBER(GL_MAX_TEXTURE_IMAGE_UNITS);
}
RING_FUNC(ring_get_gl_fragment_shader)
{
RING_API_RETNUMBER(GL_FRAGMENT_SHADER);
}
RING_FUNC(ring_get_gl_vertex_shader)
{
RING_API_RETNUMBER(GL_VERTEX_SHADER);
}
RING_FUNC(ring_get_gl_max_fragment_uniform_components)
{
RING_API_RETNUMBER(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS);
}
RING_FUNC(ring_get_gl_max_vertex_uniform_components)
{
RING_API_RETNUMBER(GL_MAX_VERTEX_UNIFORM_COMPONENTS);
}
RING_FUNC(ring_get_gl_max_varying_floats)
{
RING_API_RETNUMBER(GL_MAX_VARYING_FLOATS);
}
RING_FUNC(ring_get_gl_max_vertex_texture_image_units)
{
RING_API_RETNUMBER(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS);
}
RING_FUNC(ring_get_gl_max_combined_texture_image_units)
{
RING_API_RETNUMBER(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS);
}
RING_FUNC(ring_get_gl_shader_type)
{
RING_API_RETNUMBER(GL_SHADER_TYPE);
}
RING_FUNC(ring_get_gl_float_vec2)
{
RING_API_RETNUMBER(GL_FLOAT_VEC2);
}
RING_FUNC(ring_get_gl_float_vec3)
{
RING_API_RETNUMBER(GL_FLOAT_VEC3);
}
RING_FUNC(ring_get_gl_float_vec4)
{
RING_API_RETNUMBER(GL_FLOAT_VEC4);
}
RING_FUNC(ring_get_gl_int_vec2)
{
RING_API_RETNUMBER(GL_INT_VEC2);
}
RING_FUNC(ring_get_gl_int_vec3)
{
RING_API_RETNUMBER(GL_INT_VEC3);
}
RING_FUNC(ring_get_gl_int_vec4)
{
RING_API_RETNUMBER(GL_INT_VEC4);
}
RING_FUNC(ring_get_gl_bool)
{
RING_API_RETNUMBER(GL_BOOL);
}
RING_FUNC(ring_get_gl_bool_vec2)
{
RING_API_RETNUMBER(GL_BOOL_VEC2);
}
RING_FUNC(ring_get_gl_bool_vec3)
{
RING_API_RETNUMBER(GL_BOOL_VEC3);
}
RING_FUNC(ring_get_gl_bool_vec4)
{
RING_API_RETNUMBER(GL_BOOL_VEC4);
}
RING_FUNC(ring_get_gl_float_mat2)
{
RING_API_RETNUMBER(GL_FLOAT_MAT2);
}
RING_FUNC(ring_get_gl_float_mat3)
{
RING_API_RETNUMBER(GL_FLOAT_MAT3);
}
RING_FUNC(ring_get_gl_float_mat4)
{
RING_API_RETNUMBER(GL_FLOAT_MAT4);
}
RING_FUNC(ring_get_gl_sampler_1d)
{
RING_API_RETNUMBER(GL_SAMPLER_1D);
}
RING_FUNC(ring_get_gl_sampler_2d)
{
RING_API_RETNUMBER(GL_SAMPLER_2D);
}
RING_FUNC(ring_get_gl_sampler_3d)
{
RING_API_RETNUMBER(GL_SAMPLER_3D);
}
RING_FUNC(ring_get_gl_sampler_cube)
{
RING_API_RETNUMBER(GL_SAMPLER_CUBE);
}
RING_FUNC(ring_get_gl_sampler_1d_shadow)
{
RING_API_RETNUMBER(GL_SAMPLER_1D_SHADOW);
}
RING_FUNC(ring_get_gl_sampler_2d_shadow)
{
RING_API_RETNUMBER(GL_SAMPLER_2D_SHADOW);
}
RING_FUNC(ring_get_gl_delete_status)
{
RING_API_RETNUMBER(GL_DELETE_STATUS);
}
RING_FUNC(ring_get_gl_compile_status)
{
RING_API_RETNUMBER(GL_COMPILE_STATUS);
}
RING_FUNC(ring_get_gl_link_status)
{
RING_API_RETNUMBER(GL_LINK_STATUS);
}
RING_FUNC(ring_get_gl_validate_status)
{
RING_API_RETNUMBER(GL_VALIDATE_STATUS);
}
RING_FUNC(ring_get_gl_info_log_length)
{
RING_API_RETNUMBER(GL_INFO_LOG_LENGTH);
}
RING_FUNC(ring_get_gl_attached_shaders)
{
RING_API_RETNUMBER(GL_ATTACHED_SHADERS);
}
RING_FUNC(ring_get_gl_active_uniforms)
{
RING_API_RETNUMBER(GL_ACTIVE_UNIFORMS);
}
RING_FUNC(ring_get_gl_active_uniform_max_length)
{
RING_API_RETNUMBER(GL_ACTIVE_UNIFORM_MAX_LENGTH);
}
RING_FUNC(ring_get_gl_shader_source_length)
{
RING_API_RETNUMBER(GL_SHADER_SOURCE_LENGTH);
}
RING_FUNC(ring_get_gl_active_attributes)
{
RING_API_RETNUMBER(GL_ACTIVE_ATTRIBUTES);
}
RING_FUNC(ring_get_gl_active_attribute_max_length)
{
RING_API_RETNUMBER(GL_ACTIVE_ATTRIBUTE_MAX_LENGTH);
}
RING_FUNC(ring_get_gl_fragment_shader_derivative_hint)
{
RING_API_RETNUMBER(GL_FRAGMENT_SHADER_DERIVATIVE_HINT);
}
RING_FUNC(ring_get_gl_shading_language_version)
{
RING_API_RETNUMBER(GL_SHADING_LANGUAGE_VERSION);
}
RING_FUNC(ring_get_gl_current_program)
{
RING_API_RETNUMBER(GL_CURRENT_PROGRAM);
}
RING_FUNC(ring_get_gl_point_sprite_coord_origin)
{
RING_API_RETNUMBER(GL_POINT_SPRITE_COORD_ORIGIN);
}
RING_FUNC(ring_get_gl_lower_left)
{
RING_API_RETNUMBER(GL_LOWER_LEFT);
}
RING_FUNC(ring_get_gl_upper_left)
{
RING_API_RETNUMBER(GL_UPPER_LEFT);
}
RING_FUNC(ring_get_gl_stencil_back_ref)
{
RING_API_RETNUMBER(GL_STENCIL_BACK_REF);
}
RING_FUNC(ring_get_gl_stencil_back_value_mask)
{
RING_API_RETNUMBER(GL_STENCIL_BACK_VALUE_MASK);
}
RING_FUNC(ring_get_gl_stencil_back_writemask)
{
RING_API_RETNUMBER(GL_STENCIL_BACK_WRITEMASK);
}
RING_FUNC(ring_get_gl_current_raster_secondary_color)
{
RING_API_RETNUMBER(GL_CURRENT_RASTER_SECONDARY_COLOR);
}
RING_FUNC(ring_get_gl_pixel_pack_buffer)
{
RING_API_RETNUMBER(GL_PIXEL_PACK_BUFFER);
}
RING_FUNC(ring_get_gl_pixel_unpack_buffer)
{
RING_API_RETNUMBER(GL_PIXEL_UNPACK_BUFFER);
}
RING_FUNC(ring_get_gl_pixel_pack_buffer_binding)
{
RING_API_RETNUMBER(GL_PIXEL_PACK_BUFFER_BINDING);
}
RING_FUNC(ring_get_gl_pixel_unpack_buffer_binding)
{
RING_API_RETNUMBER(GL_PIXEL_UNPACK_BUFFER_BINDING);
}
RING_FUNC(ring_get_gl_float_mat2x3)
{
RING_API_RETNUMBER(GL_FLOAT_MAT2x3);
}
RING_FUNC(ring_get_gl_float_mat2x4)
{
RING_API_RETNUMBER(GL_FLOAT_MAT2x4);
}
RING_FUNC(ring_get_gl_float_mat3x2)
{
RING_API_RETNUMBER(GL_FLOAT_MAT3x2);
}
RING_FUNC(ring_get_gl_float_mat3x4)
{
RING_API_RETNUMBER(GL_FLOAT_MAT3x4);
}
RING_FUNC(ring_get_gl_float_mat4x2)
{
RING_API_RETNUMBER(GL_FLOAT_MAT4x2);
}
RING_FUNC(ring_get_gl_float_mat4x3)
{
RING_API_RETNUMBER(GL_FLOAT_MAT4x3);
}
RING_FUNC(ring_get_gl_srgb)
{
RING_API_RETNUMBER(GL_SRGB);
}
RING_FUNC(ring_get_gl_srgb8)
{
RING_API_RETNUMBER(GL_SRGB8);
}
RING_FUNC(ring_get_gl_srgb_alpha)
{
RING_API_RETNUMBER(GL_SRGB_ALPHA);
}
RING_FUNC(ring_get_gl_srgb8_alpha8)
{
RING_API_RETNUMBER(GL_SRGB8_ALPHA8);
}
RING_FUNC(ring_get_gl_sluminance_alpha)
{
RING_API_RETNUMBER(GL_SLUMINANCE_ALPHA);
}
RING_FUNC(ring_get_gl_sluminance8_alpha8)
{
RING_API_RETNUMBER(GL_SLUMINANCE8_ALPHA8);
}
RING_FUNC(ring_get_gl_sluminance)
{
RING_API_RETNUMBER(GL_SLUMINANCE);
}
RING_FUNC(ring_get_gl_sluminance8)
{
RING_API_RETNUMBER(GL_SLUMINANCE8);
}
RING_FUNC(ring_get_gl_compressed_srgb)
{
RING_API_RETNUMBER(GL_COMPRESSED_SRGB);
}
RING_FUNC(ring_get_gl_compressed_srgb_alpha)
{
RING_API_RETNUMBER(GL_COMPRESSED_SRGB_ALPHA);
}
RING_FUNC(ring_get_gl_compressed_sluminance)
{
RING_API_RETNUMBER(GL_COMPRESSED_SLUMINANCE);
}
RING_FUNC(ring_get_gl_compressed_sluminance_alpha)
{
RING_API_RETNUMBER(GL_COMPRESSED_SLUMINANCE_ALPHA);
}
RING_FUNC(ring_glAccum)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glAccum( (GLenum ) (int) RING_API_GETNUMBER(1), (GLfloat ) RING_API_GETNUMBER(2));
}
RING_FUNC(ring_glActiveTexture)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glActiveTexture( (GLenum ) (int) RING_API_GETNUMBER(1));
}
RING_FUNC(ring_glAlphaFunc)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glAlphaFunc( (GLenum ) (int) RING_API_GETNUMBER(1), (GLclampf ) (int) RING_API_GETNUMBER(2));
}
RING_FUNC(ring_glAreTexturesResident)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETNUMBER(glAreTexturesResident( (GLsizei ) (int) RING_API_GETNUMBER(1),(GLuint *) RING_API_GETCPOINTER(2,"GLuint"),(GLboolean *) RING_API_GETCPOINTER(3,"GLboolean")));
}
RING_FUNC(ring_glArrayElement)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glArrayElement( (GLint ) RING_API_GETNUMBER(1));
}
RING_FUNC(ring_glAttachShader)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glAttachShader( (GLuint ) RING_API_GETNUMBER(1), (GLuint ) RING_API_GETNUMBER(2));
}
RING_FUNC(ring_glBegin)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glBegin( (GLenum ) (int) RING_API_GETNUMBER(1));
}
RING_FUNC(ring_glBeginQuery)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glBeginQuery( (GLenum ) (int) RING_API_GETNUMBER(1), (GLuint ) RING_API_GETNUMBER(2));
}
RING_FUNC(ring_glBindAttribLocation)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glBindAttribLocation( (GLuint ) RING_API_GETNUMBER(1), (GLuint ) RING_API_GETNUMBER(2),(GLchar *) RING_API_GETCPOINTER(3,"GLchar"));
}
RING_FUNC(ring_glBindBuffer)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glBindBuffer( (GLenum ) (int) RING_API_GETNUMBER(1), (GLuint ) RING_API_GETNUMBER(2));
}
RING_FUNC(ring_glBindTexture)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glBindTexture( (GLenum ) (int) RING_API_GETNUMBER(1), (GLuint ) RING_API_GETNUMBER(2));
}
RING_FUNC(ring_glBitmap)
{
if ( RING_API_PARACOUNT != 7 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(5) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(6) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(7) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glBitmap( (GLsizei ) (int) RING_API_GETNUMBER(1), (GLsizei ) (int) RING_API_GETNUMBER(2), (GLfloat ) RING_API_GETNUMBER(3), (GLfloat ) RING_API_GETNUMBER(4), (GLfloat ) RING_API_GETNUMBER(5), (GLfloat ) RING_API_GETNUMBER(6),(GLubyte *) RING_API_GETCPOINTER(7,"GLubyte"));
}
RING_FUNC(ring_glBlendColor)
{
if ( RING_API_PARACOUNT != 4 ) {
RING_API_ERROR(RING_API_MISS4PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glBlendColor( (GLclampf ) (int) RING_API_GETNUMBER(1), (GLclampf ) (int) RING_API_GETNUMBER(2), (GLclampf ) (int) RING_API_GETNUMBER(3), (GLclampf ) (int) RING_API_GETNUMBER(4));
}
RING_FUNC(ring_glBlendEquation)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glBlendEquation( (GLenum ) (int) RING_API_GETNUMBER(1));
}
RING_FUNC(ring_glBlendEquationSeparate)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glBlendEquationSeparate( (GLenum ) (int) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2));
}
RING_FUNC(ring_glBlendFunc)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glBlendFunc( (GLenum ) (int) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2));
}
RING_FUNC(ring_glBlendFuncSeparate)
{
if ( RING_API_PARACOUNT != 4 ) {
RING_API_ERROR(RING_API_MISS4PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glBlendFuncSeparate( (GLenum ) (int) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2), (GLenum ) (int) RING_API_GETNUMBER(3), (GLenum ) (int) RING_API_GETNUMBER(4));
}
RING_FUNC(ring_glBufferData)
{
if ( RING_API_PARACOUNT != 4 ) {
RING_API_ERROR(RING_API_MISS4PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glBufferData( (GLenum ) (int) RING_API_GETNUMBER(1), (GLsizeiptr ) RING_API_GETNUMBER(2),(GLvoid *) RING_API_GETCPOINTER(3,"GLvoid"), (GLenum ) (int) RING_API_GETNUMBER(4));
}
RING_FUNC(ring_glBufferSubData)
{
if ( RING_API_PARACOUNT != 4 ) {
RING_API_ERROR(RING_API_MISS4PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glBufferSubData( (GLenum ) (int) RING_API_GETNUMBER(1), (GLintptr ) RING_API_GETNUMBER(2), (GLsizeiptr ) RING_API_GETNUMBER(3),(GLvoid *) RING_API_GETCPOINTER(4,"GLvoid"));
}
RING_FUNC(ring_glCallList)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glCallList( (GLuint ) RING_API_GETNUMBER(1));
}
RING_FUNC(ring_glCallLists)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glCallLists( (GLsizei ) (int) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2),(GLvoid *) RING_API_GETCPOINTER(3,"GLvoid"));
}
RING_FUNC(ring_glClear)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glClear( (GLbitfield ) (int) RING_API_GETNUMBER(1));
}
RING_FUNC(ring_glClearAccum)
{
if ( RING_API_PARACOUNT != 4 ) {
RING_API_ERROR(RING_API_MISS4PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glClearAccum( (GLfloat ) RING_API_GETNUMBER(1), (GLfloat ) RING_API_GETNUMBER(2), (GLfloat ) RING_API_GETNUMBER(3), (GLfloat ) RING_API_GETNUMBER(4));
}
RING_FUNC(ring_glClearColor)
{
if ( RING_API_PARACOUNT != 4 ) {
RING_API_ERROR(RING_API_MISS4PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glClearColor( (GLclampf ) (int) RING_API_GETNUMBER(1), (GLclampf ) (int) RING_API_GETNUMBER(2), (GLclampf ) (int) RING_API_GETNUMBER(3), (GLclampf ) (int) RING_API_GETNUMBER(4));
}
RING_FUNC(ring_glClearDepth)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glClearDepth( (GLclampd ) RING_API_GETNUMBER(1));
}
RING_FUNC(ring_glClearIndex)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glClearIndex( (GLfloat ) RING_API_GETNUMBER(1));
}
RING_FUNC(ring_glClearStencil)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glClearStencil( (GLint ) RING_API_GETNUMBER(1));
}
RING_FUNC(ring_glClientActiveTexture)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glClientActiveTexture( (GLenum ) (int) RING_API_GETNUMBER(1));
}
RING_FUNC(ring_glClipPlane)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glClipPlane( (GLenum ) (int) RING_API_GETNUMBER(1),(GLdouble *) RING_API_GETCPOINTER(2,"GLdouble"));
}
RING_FUNC(ring_glColor3b)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glColor3b( (GLbyte ) RING_API_GETNUMBER(1), (GLbyte ) RING_API_GETNUMBER(2), (GLbyte ) RING_API_GETNUMBER(3));
}
RING_FUNC(ring_glColor3s)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glColor3s( (GLshort ) RING_API_GETNUMBER(1), (GLshort ) RING_API_GETNUMBER(2), (GLshort ) RING_API_GETNUMBER(3));
}
RING_FUNC(ring_glColor3i)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glColor3i( (GLint ) RING_API_GETNUMBER(1), (GLint ) RING_API_GETNUMBER(2), (GLint ) RING_API_GETNUMBER(3));
}
RING_FUNC(ring_glColor3f)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glColor3f( (GLfloat ) RING_API_GETNUMBER(1), (GLfloat ) RING_API_GETNUMBER(2), (GLfloat ) RING_API_GETNUMBER(3));
}
RING_FUNC(ring_glColor3d)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glColor3d( (GLdouble ) RING_API_GETNUMBER(1), (GLdouble ) RING_API_GETNUMBER(2), (GLdouble ) RING_API_GETNUMBER(3));
}
RING_FUNC(ring_glColor3ub)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glColor3ub( (GLubyte ) RING_API_GETNUMBER(1), (GLubyte ) RING_API_GETNUMBER(2), (GLubyte ) RING_API_GETNUMBER(3));
}
RING_FUNC(ring_glColor3us)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glColor3us( (GLushort ) RING_API_GETNUMBER(1), (GLushort ) RING_API_GETNUMBER(2), (GLushort ) RING_API_GETNUMBER(3));
}
RING_FUNC(ring_glColor3ui)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glColor3ui( (GLuint ) RING_API_GETNUMBER(1), (GLuint ) RING_API_GETNUMBER(2), (GLuint ) RING_API_GETNUMBER(3));
}
RING_FUNC(ring_glColor4b)
{
if ( RING_API_PARACOUNT != 4 ) {
RING_API_ERROR(RING_API_MISS4PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glColor4b( (GLbyte ) RING_API_GETNUMBER(1), (GLbyte ) RING_API_GETNUMBER(2), (GLbyte ) RING_API_GETNUMBER(3), (GLbyte ) RING_API_GETNUMBER(4));
}
RING_FUNC(ring_glColor4s)
{
if ( RING_API_PARACOUNT != 4 ) {
RING_API_ERROR(RING_API_MISS4PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glColor4s( (GLshort ) RING_API_GETNUMBER(1), (GLshort ) RING_API_GETNUMBER(2), (GLshort ) RING_API_GETNUMBER(3), (GLshort ) RING_API_GETNUMBER(4));
}
RING_FUNC(ring_glColor4i)
{
if ( RING_API_PARACOUNT != 4 ) {
RING_API_ERROR(RING_API_MISS4PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glColor4i( (GLint ) RING_API_GETNUMBER(1), (GLint ) RING_API_GETNUMBER(2), (GLint ) RING_API_GETNUMBER(3), (GLint ) RING_API_GETNUMBER(4));
}
RING_FUNC(ring_glColor4f)
{
if ( RING_API_PARACOUNT != 4 ) {
RING_API_ERROR(RING_API_MISS4PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glColor4f( (GLfloat ) RING_API_GETNUMBER(1), (GLfloat ) RING_API_GETNUMBER(2), (GLfloat ) RING_API_GETNUMBER(3), (GLfloat ) RING_API_GETNUMBER(4));
}
RING_FUNC(ring_glColor4d)
{
if ( RING_API_PARACOUNT != 4 ) {
RING_API_ERROR(RING_API_MISS4PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glColor4d( (GLdouble ) RING_API_GETNUMBER(1), (GLdouble ) RING_API_GETNUMBER(2), (GLdouble ) RING_API_GETNUMBER(3), (GLdouble ) RING_API_GETNUMBER(4));
}
RING_FUNC(ring_glColor4ub)
{
if ( RING_API_PARACOUNT != 4 ) {
RING_API_ERROR(RING_API_MISS4PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glColor4ub( (GLubyte ) RING_API_GETNUMBER(1), (GLubyte ) RING_API_GETNUMBER(2), (GLubyte ) RING_API_GETNUMBER(3), (GLubyte ) RING_API_GETNUMBER(4));
}
RING_FUNC(ring_glColor4us)
{
if ( RING_API_PARACOUNT != 4 ) {
RING_API_ERROR(RING_API_MISS4PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glColor4us( (GLushort ) RING_API_GETNUMBER(1), (GLushort ) RING_API_GETNUMBER(2), (GLushort ) RING_API_GETNUMBER(3), (GLushort ) RING_API_GETNUMBER(4));
}
RING_FUNC(ring_glColor4ui)
{
if ( RING_API_PARACOUNT != 4 ) {
RING_API_ERROR(RING_API_MISS4PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glColor4ui( (GLuint ) RING_API_GETNUMBER(1), (GLuint ) RING_API_GETNUMBER(2), (GLuint ) RING_API_GETNUMBER(3), (GLuint ) RING_API_GETNUMBER(4));
}
RING_FUNC(ring_glColor3bv)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glColor3bv((GLbyte *) RING_API_GETCPOINTER(1,"GLbyte"));
}
RING_FUNC(ring_glColor3sv)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glColor3sv((GLshort *) RING_API_GETCPOINTER(1,"GLshort"));
}
RING_FUNC(ring_glColor3iv)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glColor3iv((GLint *) RING_API_GETCPOINTER(1,"GLint"));
}
RING_FUNC(ring_glColor3fv)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glColor3fv((GLfloat *) RING_API_GETCPOINTER(1,"GLfloat"));
}
RING_FUNC(ring_glColor3dv)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glColor3dv((GLdouble *) RING_API_GETCPOINTER(1,"GLdouble"));
}
RING_FUNC(ring_glColor3ubv)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glColor3ubv((GLubyte *) RING_API_GETCPOINTER(1,"GLubyte"));
}
RING_FUNC(ring_glColor3usv)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glColor3usv((GLushort *) RING_API_GETCPOINTER(1,"GLushort"));
}
RING_FUNC(ring_glColor3uiv)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glColor3uiv((GLuint *) RING_API_GETCPOINTER(1,"GLuint"));
}
RING_FUNC(ring_glColor4bv)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glColor4bv((GLbyte *) RING_API_GETCPOINTER(1,"GLbyte"));
}
RING_FUNC(ring_glColor4sv)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glColor4sv((GLshort *) RING_API_GETCPOINTER(1,"GLshort"));
}
RING_FUNC(ring_glColor4iv)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glColor4iv((GLint *) RING_API_GETCPOINTER(1,"GLint"));
}
RING_FUNC(ring_glColor4fv)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glColor4fv((GLfloat *) RING_API_GETCPOINTER(1,"GLfloat"));
}
RING_FUNC(ring_glColor4dv)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glColor4dv((GLdouble *) RING_API_GETCPOINTER(1,"GLdouble"));
}
RING_FUNC(ring_glColor4ubv)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glColor4ubv((GLubyte *) RING_API_GETCPOINTER(1,"GLubyte"));
}
RING_FUNC(ring_glColor4usv)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glColor4usv((GLushort *) RING_API_GETCPOINTER(1,"GLushort"));
}
RING_FUNC(ring_glColor4uiv)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glColor4uiv((GLuint *) RING_API_GETCPOINTER(1,"GLuint"));
}
RING_FUNC(ring_glColorMask)
{
if ( RING_API_PARACOUNT != 4 ) {
RING_API_ERROR(RING_API_MISS4PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glColorMask( (GLboolean ) RING_API_GETNUMBER(1), (GLboolean ) RING_API_GETNUMBER(2), (GLboolean ) RING_API_GETNUMBER(3), (GLboolean ) RING_API_GETNUMBER(4));
}
RING_FUNC(ring_glColorMaterial)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glColorMaterial( (GLenum ) (int) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2));
}
RING_FUNC(ring_glColorPointer)
{
if ( RING_API_PARACOUNT != 4 ) {
RING_API_ERROR(RING_API_MISS4PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glColorPointer( (GLint ) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2), (GLsizei ) (int) RING_API_GETNUMBER(3),(GLvoid *) RING_API_GETCPOINTER(4,"GLvoid"));
}
RING_FUNC(ring_glColorSubTable)
{
if ( RING_API_PARACOUNT != 6 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(5) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(6) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glColorSubTable( (GLenum ) (int) RING_API_GETNUMBER(1), (GLsizei ) (int) RING_API_GETNUMBER(2), (GLsizei ) (int) RING_API_GETNUMBER(3), (GLenum ) (int) RING_API_GETNUMBER(4), (GLenum ) (int) RING_API_GETNUMBER(5),(GLvoid *) RING_API_GETCPOINTER(6,"GLvoid"));
}
RING_FUNC(ring_glColorTable)
{
if ( RING_API_PARACOUNT != 6 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(5) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(6) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glColorTable( (GLenum ) (int) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2), (GLsizei ) (int) RING_API_GETNUMBER(3), (GLenum ) (int) RING_API_GETNUMBER(4), (GLenum ) (int) RING_API_GETNUMBER(5),(GLvoid *) RING_API_GETCPOINTER(6,"GLvoid"));
}
RING_FUNC(ring_glColorTableParameterfv)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glColorTableParameterfv( (GLenum ) (int) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2),(GLfloat *) RING_API_GETCPOINTER(3,"GLfloat"));
}
RING_FUNC(ring_glColorTableParameteriv)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glColorTableParameteriv( (GLenum ) (int) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2),(GLint *) RING_API_GETCPOINTER(3,"GLint"));
}
RING_FUNC(ring_glCompileShader)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glCompileShader( (GLuint ) RING_API_GETNUMBER(1));
}
RING_FUNC(ring_glCompressedTexImage1D)
{
if ( RING_API_PARACOUNT != 7 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(5) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(6) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(7) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glCompressedTexImage1D( (GLenum ) (int) RING_API_GETNUMBER(1), (GLint ) RING_API_GETNUMBER(2), (GLenum ) (int) RING_API_GETNUMBER(3), (GLsizei ) (int) RING_API_GETNUMBER(4), (GLint ) RING_API_GETNUMBER(5), (GLsizei ) (int) RING_API_GETNUMBER(6),(GLvoid *) RING_API_GETCPOINTER(7,"GLvoid"));
}
RING_FUNC(ring_glCompressedTexImage2D)
{
if ( RING_API_PARACOUNT != 8 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(5) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(6) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(7) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(8) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glCompressedTexImage2D( (GLenum ) (int) RING_API_GETNUMBER(1), (GLint ) RING_API_GETNUMBER(2), (GLenum ) (int) RING_API_GETNUMBER(3), (GLsizei ) (int) RING_API_GETNUMBER(4), (GLsizei ) (int) RING_API_GETNUMBER(5), (GLint ) RING_API_GETNUMBER(6), (GLsizei ) (int) RING_API_GETNUMBER(7),(GLvoid *) RING_API_GETCPOINTER(8,"GLvoid"));
}
RING_FUNC(ring_glCompressedTexImage3D)
{
if ( RING_API_PARACOUNT != 9 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(5) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(6) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(7) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(8) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(9) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glCompressedTexImage3D( (GLenum ) (int) RING_API_GETNUMBER(1), (GLint ) RING_API_GETNUMBER(2), (GLenum ) (int) RING_API_GETNUMBER(3), (GLsizei ) (int) RING_API_GETNUMBER(4), (GLsizei ) (int) RING_API_GETNUMBER(5), (GLsizei ) (int) RING_API_GETNUMBER(6), (GLint ) RING_API_GETNUMBER(7), (GLsizei ) (int) RING_API_GETNUMBER(8),(GLvoid *) RING_API_GETCPOINTER(9,"GLvoid"));
}
RING_FUNC(ring_glCompressedTexSubImage1D)
{
if ( RING_API_PARACOUNT != 7 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(5) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(6) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(7) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glCompressedTexSubImage1D( (GLenum ) (int) RING_API_GETNUMBER(1), (GLint ) RING_API_GETNUMBER(2), (GLint ) RING_API_GETNUMBER(3), (GLsizei ) (int) RING_API_GETNUMBER(4), (GLenum ) (int) RING_API_GETNUMBER(5), (GLsizei ) (int) RING_API_GETNUMBER(6),(GLvoid *) RING_API_GETCPOINTER(7,"GLvoid"));
}
RING_FUNC(ring_glCompressedTexSubImage2D)
{
if ( RING_API_PARACOUNT != 9 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(5) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(6) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(7) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(8) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(9) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glCompressedTexSubImage2D( (GLenum ) (int) RING_API_GETNUMBER(1), (GLint ) RING_API_GETNUMBER(2), (GLint ) RING_API_GETNUMBER(3), (GLint ) RING_API_GETNUMBER(4), (GLsizei ) (int) RING_API_GETNUMBER(5), (GLsizei ) (int) RING_API_GETNUMBER(6), (GLenum ) (int) RING_API_GETNUMBER(7), (GLsizei ) (int) RING_API_GETNUMBER(8),(GLvoid *) RING_API_GETCPOINTER(9,"GLvoid"));
}
RING_FUNC(ring_glCompressedTexSubImage3D)
{
if ( RING_API_PARACOUNT != 11 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(5) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(6) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(7) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(8) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(9) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(10) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(11) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glCompressedTexSubImage3D( (GLenum ) (int) RING_API_GETNUMBER(1), (GLint ) RING_API_GETNUMBER(2), (GLint ) RING_API_GETNUMBER(3), (GLint ) RING_API_GETNUMBER(4), (GLint ) RING_API_GETNUMBER(5), (GLsizei ) (int) RING_API_GETNUMBER(6), (GLsizei ) (int) RING_API_GETNUMBER(7), (GLsizei ) (int) RING_API_GETNUMBER(8), (GLenum ) (int) RING_API_GETNUMBER(9), (GLsizei ) (int) RING_API_GETNUMBER(10),(GLvoid *) RING_API_GETCPOINTER(11,"GLvoid"));
}
RING_FUNC(ring_glConvolutionFilter1D)
{
if ( RING_API_PARACOUNT != 6 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(5) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(6) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glConvolutionFilter1D( (GLenum ) (int) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2), (GLsizei ) (int) RING_API_GETNUMBER(3), (GLenum ) (int) RING_API_GETNUMBER(4), (GLenum ) (int) RING_API_GETNUMBER(5),(GLvoid *) RING_API_GETCPOINTER(6,"GLvoid"));
}
RING_FUNC(ring_glConvolutionFilter2D)
{
if ( RING_API_PARACOUNT != 7 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(5) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(6) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(7) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glConvolutionFilter2D( (GLenum ) (int) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2), (GLsizei ) (int) RING_API_GETNUMBER(3), (GLsizei ) (int) RING_API_GETNUMBER(4), (GLenum ) (int) RING_API_GETNUMBER(5), (GLenum ) (int) RING_API_GETNUMBER(6),(GLvoid *) RING_API_GETCPOINTER(7,"GLvoid"));
}
RING_FUNC(ring_glConvolutionParameterf)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glConvolutionParameterf( (GLenum ) (int) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2), (GLfloat ) RING_API_GETNUMBER(3));
}
RING_FUNC(ring_glConvolutionParameteri)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glConvolutionParameteri( (GLenum ) (int) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2), (GLint ) RING_API_GETNUMBER(3));
}
RING_FUNC(ring_glConvolutionParameterfv)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glConvolutionParameterfv( (GLenum ) (int) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2),(GLfloat *) RING_API_GETCPOINTER(3,"GLfloat"));
}
RING_FUNC(ring_glConvolutionParameteriv)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glConvolutionParameteriv( (GLenum ) (int) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2),(GLint *) RING_API_GETCPOINTER(3,"GLint"));
}
RING_FUNC(ring_glCopyColorSubTable)
{
if ( RING_API_PARACOUNT != 5 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(5) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glCopyColorSubTable( (GLenum ) (int) RING_API_GETNUMBER(1), (GLsizei ) (int) RING_API_GETNUMBER(2), (GLint ) RING_API_GETNUMBER(3), (GLint ) RING_API_GETNUMBER(4), (GLsizei ) (int) RING_API_GETNUMBER(5));
}
RING_FUNC(ring_glCopyColorTable)
{
if ( RING_API_PARACOUNT != 5 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(5) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glCopyColorTable( (GLenum ) (int) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2), (GLint ) RING_API_GETNUMBER(3), (GLint ) RING_API_GETNUMBER(4), (GLsizei ) (int) RING_API_GETNUMBER(5));
}
RING_FUNC(ring_glCopyConvolutionFilter1D)
{
if ( RING_API_PARACOUNT != 5 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(5) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glCopyConvolutionFilter1D( (GLenum ) (int) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2), (GLint ) RING_API_GETNUMBER(3), (GLint ) RING_API_GETNUMBER(4), (GLsizei ) (int) RING_API_GETNUMBER(5));
}
RING_FUNC(ring_glCopyConvolutionFilter2D)
{
if ( RING_API_PARACOUNT != 6 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(5) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(6) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glCopyConvolutionFilter2D( (GLenum ) (int) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2), (GLint ) RING_API_GETNUMBER(3), (GLint ) RING_API_GETNUMBER(4), (GLsizei ) (int) RING_API_GETNUMBER(5), (GLsizei ) (int) RING_API_GETNUMBER(6));
}
RING_FUNC(ring_glCopyPixels)
{
if ( RING_API_PARACOUNT != 5 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(5) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glCopyPixels( (GLint ) RING_API_GETNUMBER(1), (GLint ) RING_API_GETNUMBER(2), (GLsizei ) (int) RING_API_GETNUMBER(3), (GLsizei ) (int) RING_API_GETNUMBER(4), (GLenum ) (int) RING_API_GETNUMBER(5));
}
RING_FUNC(ring_glCopyTexImage1D)
{
if ( RING_API_PARACOUNT != 7 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(5) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(6) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(7) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glCopyTexImage1D( (GLenum ) (int) RING_API_GETNUMBER(1), (GLint ) RING_API_GETNUMBER(2), (GLenum ) (int) RING_API_GETNUMBER(3), (GLint ) RING_API_GETNUMBER(4), (GLint ) RING_API_GETNUMBER(5), (GLsizei ) (int) RING_API_GETNUMBER(6), (GLint ) RING_API_GETNUMBER(7));
}
RING_FUNC(ring_glCopyTexImage2D)
{
if ( RING_API_PARACOUNT != 8 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(5) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(6) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(7) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(8) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glCopyTexImage2D( (GLenum ) (int) RING_API_GETNUMBER(1), (GLint ) RING_API_GETNUMBER(2), (GLenum ) (int) RING_API_GETNUMBER(3), (GLint ) RING_API_GETNUMBER(4), (GLint ) RING_API_GETNUMBER(5), (GLsizei ) (int) RING_API_GETNUMBER(6), (GLsizei ) (int) RING_API_GETNUMBER(7), (GLint ) RING_API_GETNUMBER(8));
}
RING_FUNC(ring_glCopyTexSubImage1D)
{
if ( RING_API_PARACOUNT != 6 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(5) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(6) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glCopyTexSubImage1D( (GLenum ) (int) RING_API_GETNUMBER(1), (GLint ) RING_API_GETNUMBER(2), (GLint ) RING_API_GETNUMBER(3), (GLint ) RING_API_GETNUMBER(4), (GLint ) RING_API_GETNUMBER(5), (GLsizei ) (int) RING_API_GETNUMBER(6));
}
RING_FUNC(ring_glCopyTexSubImage2D)
{
if ( RING_API_PARACOUNT != 8 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(5) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(6) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(7) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(8) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glCopyTexSubImage2D( (GLenum ) (int) RING_API_GETNUMBER(1), (GLint ) RING_API_GETNUMBER(2), (GLint ) RING_API_GETNUMBER(3), (GLint ) RING_API_GETNUMBER(4), (GLint ) RING_API_GETNUMBER(5), (GLint ) RING_API_GETNUMBER(6), (GLsizei ) (int) RING_API_GETNUMBER(7), (GLsizei ) (int) RING_API_GETNUMBER(8));
}
RING_FUNC(ring_glCopyTexSubImage3D)
{
if ( RING_API_PARACOUNT != 9 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(5) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(6) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(7) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(8) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(9) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glCopyTexSubImage3D( (GLenum ) (int) RING_API_GETNUMBER(1), (GLint ) RING_API_GETNUMBER(2), (GLint ) RING_API_GETNUMBER(3), (GLint ) RING_API_GETNUMBER(4), (GLint ) RING_API_GETNUMBER(5), (GLint ) RING_API_GETNUMBER(6), (GLint ) RING_API_GETNUMBER(7), (GLsizei ) (int) RING_API_GETNUMBER(8), (GLsizei ) (int) RING_API_GETNUMBER(9));
}
RING_FUNC(ring_glCreateProgram)
{
if ( RING_API_PARACOUNT != 0 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
RING_API_RETNUMBER(glCreateProgram());
}
RING_FUNC(ring_glCreateShader)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETNUMBER(glCreateShader( (GLenum ) (int) RING_API_GETNUMBER(1)));
}
RING_FUNC(ring_glCullFace)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glCullFace( (GLenum ) (int) RING_API_GETNUMBER(1));
}
RING_FUNC(ring_glDeleteBuffers)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glDeleteBuffers( (GLsizei ) (int) RING_API_GETNUMBER(1),(GLuint *) RING_API_GETCPOINTER(2,"GLuint"));
}
RING_FUNC(ring_glDeleteLists)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glDeleteLists( (GLuint ) RING_API_GETNUMBER(1), (GLsizei ) (int) RING_API_GETNUMBER(2));
}
RING_FUNC(ring_glDeleteProgram)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glDeleteProgram( (GLuint ) RING_API_GETNUMBER(1));
}
RING_FUNC(ring_glDeleteQueries)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glDeleteQueries( (GLsizei ) (int) RING_API_GETNUMBER(1),(GLuint *) RING_API_GETCPOINTER(2,"GLuint"));
}
RING_FUNC(ring_glDeleteShader)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glDeleteShader( (GLuint ) RING_API_GETNUMBER(1));
}
RING_FUNC(ring_glDeleteTextures)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glDeleteTextures( (GLsizei ) (int) RING_API_GETNUMBER(1),(GLuint *) RING_API_GETCPOINTER(2,"GLuint"));
}
RING_FUNC(ring_glDepthFunc)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glDepthFunc( (GLenum ) (int) RING_API_GETNUMBER(1));
}
RING_FUNC(ring_glDepthMask)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glDepthMask( (GLboolean ) RING_API_GETNUMBER(1));
}
RING_FUNC(ring_glDepthRange)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glDepthRange( (GLclampd ) RING_API_GETNUMBER(1), (GLclampd ) RING_API_GETNUMBER(2));
}
RING_FUNC(ring_glDetachShader)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glDetachShader( (GLuint ) RING_API_GETNUMBER(1), (GLuint ) RING_API_GETNUMBER(2));
}
RING_FUNC(ring_glEnable)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glEnable( (GLenum ) (int) RING_API_GETNUMBER(1));
}
RING_FUNC(ring_glEnableClientState)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glEnableClientState( (GLenum ) (int) RING_API_GETNUMBER(1));
}
RING_FUNC(ring_glEnableVertexAttribArray)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glEnableVertexAttribArray( (GLuint ) RING_API_GETNUMBER(1));
}
RING_FUNC(ring_glDisableVertexAttribArray)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glDisableVertexAttribArray( (GLuint ) RING_API_GETNUMBER(1));
}
RING_FUNC(ring_glDrawArrays)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glDrawArrays( (GLenum ) (int) RING_API_GETNUMBER(1), (GLint ) RING_API_GETNUMBER(2), (GLsizei ) (int) RING_API_GETNUMBER(3));
}
RING_FUNC(ring_glDrawBuffer)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glDrawBuffer( (GLenum ) (int) RING_API_GETNUMBER(1));
}
RING_FUNC(ring_glDrawBuffers)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glDrawBuffers( (GLsizei ) (int) RING_API_GETNUMBER(1),(GLenum *) RING_API_GETCPOINTER(2,"GLenum"));
}
RING_FUNC(ring_glDrawElements)
{
if ( RING_API_PARACOUNT != 4 ) {
RING_API_ERROR(RING_API_MISS4PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glDrawElements( (GLenum ) (int) RING_API_GETNUMBER(1), (GLsizei ) (int) RING_API_GETNUMBER(2), (GLenum ) (int) RING_API_GETNUMBER(3),(GLvoid *) RING_API_GETCPOINTER(4,"GLvoid"));
}
RING_FUNC(ring_glDrawPixels)
{
if ( RING_API_PARACOUNT != 5 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(5) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glDrawPixels( (GLsizei ) (int) RING_API_GETNUMBER(1), (GLsizei ) (int) RING_API_GETNUMBER(2), (GLenum ) (int) RING_API_GETNUMBER(3), (GLenum ) (int) RING_API_GETNUMBER(4),(GLvoid *) RING_API_GETCPOINTER(5,"GLvoid"));
}
RING_FUNC(ring_glDrawRangeElements)
{
if ( RING_API_PARACOUNT != 6 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(5) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(6) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glDrawRangeElements( (GLenum ) (int) RING_API_GETNUMBER(1), (GLuint ) RING_API_GETNUMBER(2), (GLuint ) RING_API_GETNUMBER(3), (GLsizei ) (int) RING_API_GETNUMBER(4), (GLenum ) (int) RING_API_GETNUMBER(5),(GLvoid *) RING_API_GETCPOINTER(6,"GLvoid"));
}
RING_FUNC(ring_glEdgeFlag)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glEdgeFlag( (GLboolean ) RING_API_GETNUMBER(1));
}
RING_FUNC(ring_glEdgeFlagPointer)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glEdgeFlagPointer( (GLsizei ) (int) RING_API_GETNUMBER(1),(GLvoid *) RING_API_GETCPOINTER(2,"GLvoid"));
}
RING_FUNC(ring_glEnd)
{
if ( RING_API_PARACOUNT != 0 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
glEnd();
}
RING_FUNC(ring_glEndList)
{
if ( RING_API_PARACOUNT != 0 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
glEndList();
}
RING_FUNC(ring_glEndQuery)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glEndQuery( (GLenum ) (int) RING_API_GETNUMBER(1));
}
RING_FUNC(ring_glEvalCoord1f)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glEvalCoord1f( (GLfloat ) RING_API_GETNUMBER(1));
}
RING_FUNC(ring_glEvalCoord1d)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glEvalCoord1d( (GLdouble ) RING_API_GETNUMBER(1));
}
RING_FUNC(ring_glEvalCoord2f)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glEvalCoord2f( (GLfloat ) RING_API_GETNUMBER(1), (GLfloat ) RING_API_GETNUMBER(2));
}
RING_FUNC(ring_glEvalCoord2d)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glEvalCoord2d( (GLdouble ) RING_API_GETNUMBER(1), (GLdouble ) RING_API_GETNUMBER(2));
}
RING_FUNC(ring_glEvalMesh1)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glEvalMesh1( (GLenum ) (int) RING_API_GETNUMBER(1), (GLint ) RING_API_GETNUMBER(2), (GLint ) RING_API_GETNUMBER(3));
}
RING_FUNC(ring_glEvalPoint1)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glEvalPoint1( (GLint ) RING_API_GETNUMBER(1));
}
RING_FUNC(ring_glEvalPoint2)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glEvalPoint2( (GLint ) RING_API_GETNUMBER(1), (GLint ) RING_API_GETNUMBER(2));
}
RING_FUNC(ring_glFeedbackBuffer)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glFeedbackBuffer( (GLsizei ) (int) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2),(GLfloat *) RING_API_GETCPOINTER(3,"GLfloat"));
}
RING_FUNC(ring_glFinish)
{
if ( RING_API_PARACOUNT != 0 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
glFinish();
}
RING_FUNC(ring_glFlush)
{
if ( RING_API_PARACOUNT != 0 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
glFlush();
}
RING_FUNC(ring_glFogf)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glFogf( (GLenum ) (int) RING_API_GETNUMBER(1), (GLfloat ) RING_API_GETNUMBER(2));
}
RING_FUNC(ring_glFogi)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glFogi( (GLenum ) (int) RING_API_GETNUMBER(1), (GLint ) RING_API_GETNUMBER(2));
}
RING_FUNC(ring_glFogfv)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glFogfv( (GLenum ) (int) RING_API_GETNUMBER(1),(GLfloat *) RING_API_GETCPOINTER(2,"GLfloat"));
}
RING_FUNC(ring_glFogiv)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glFogiv( (GLenum ) (int) RING_API_GETNUMBER(1),(GLint *) RING_API_GETCPOINTER(2,"GLint"));
}
RING_FUNC(ring_glFogCoordd)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glFogCoordd( (GLdouble ) RING_API_GETNUMBER(1));
}
RING_FUNC(ring_glFogCoordf)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glFogCoordf( (GLfloat ) RING_API_GETNUMBER(1));
}
RING_FUNC(ring_glFogCoorddv)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glFogCoorddv((GLdouble *) RING_API_GETCPOINTER(1,"GLdouble"));
}
RING_FUNC(ring_glFogCoordfv)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glFogCoordfv((GLfloat *) RING_API_GETCPOINTER(1,"GLfloat"));
}
RING_FUNC(ring_glFogCoordPointer)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glFogCoordPointer( (GLenum ) (int) RING_API_GETNUMBER(1), (GLsizei ) (int) RING_API_GETNUMBER(2),(GLvoid *) RING_API_GETCPOINTER(3,"GLvoid"));
}
RING_FUNC(ring_glFrontFace)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glFrontFace( (GLenum ) (int) RING_API_GETNUMBER(1));
}
RING_FUNC(ring_glFrustum)
{
if ( RING_API_PARACOUNT != 6 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(5) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(6) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glFrustum( (GLdouble ) RING_API_GETNUMBER(1), (GLdouble ) RING_API_GETNUMBER(2), (GLdouble ) RING_API_GETNUMBER(3), (GLdouble ) RING_API_GETNUMBER(4), (GLdouble ) RING_API_GETNUMBER(5), (GLdouble ) RING_API_GETNUMBER(6));
}
RING_FUNC(ring_glGenBuffers)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glGenBuffers( (GLsizei ) (int) RING_API_GETNUMBER(1),(GLuint *) RING_API_GETCPOINTER(2,"GLuint"));
}
RING_FUNC(ring_glGenLists)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETNUMBER(glGenLists( (GLsizei ) (int) RING_API_GETNUMBER(1)));
}
RING_FUNC(ring_glGenQueries)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glGenQueries( (GLsizei ) (int) RING_API_GETNUMBER(1),(GLuint *) RING_API_GETCPOINTER(2,"GLuint"));
}
RING_FUNC(ring_glGenTextures)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glGenTextures( (GLsizei ) (int) RING_API_GETNUMBER(1),(GLuint *) RING_API_GETCPOINTER(2,"GLuint"));
}
RING_FUNC(ring_glGetBooleanv)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glGetBooleanv( (GLenum ) (int) RING_API_GETNUMBER(1),(GLboolean *) RING_API_GETCPOINTER(2,"GLboolean"));
}
RING_FUNC(ring_glGetDoublev)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glGetDoublev( (GLenum ) (int) RING_API_GETNUMBER(1),(GLdouble *) RING_API_GETCPOINTER(2,"GLdouble"));
}
RING_FUNC(ring_glGetFloatv)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glGetFloatv( (GLenum ) (int) RING_API_GETNUMBER(1),(GLfloat *) RING_API_GETCPOINTER(2,"GLfloat"));
}
RING_FUNC(ring_glGetIntegerv)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glGetIntegerv( (GLenum ) (int) RING_API_GETNUMBER(1),(GLint *) RING_API_GETCPOINTER(2,"GLint"));
}
RING_FUNC(ring_glGetActiveAttrib)
{
if ( RING_API_PARACOUNT != 7 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(5) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(6) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(7) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glGetActiveAttrib( (GLuint ) RING_API_GETNUMBER(1), (GLuint ) RING_API_GETNUMBER(2), (GLsizei ) (int) RING_API_GETNUMBER(3),(GLsizei *) RING_API_GETCPOINTER(4,"GLsizei"),(GLint *) RING_API_GETCPOINTER(5,"GLint"),(GLenum *) RING_API_GETCPOINTER(6,"GLenum"),(GLchar *) RING_API_GETCPOINTER(7,"GLchar"));
}
RING_FUNC(ring_glGetActiveUniform)
{
if ( RING_API_PARACOUNT != 7 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(5) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(6) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(7) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glGetActiveUniform( (GLuint ) RING_API_GETNUMBER(1), (GLuint ) RING_API_GETNUMBER(2), (GLsizei ) (int) RING_API_GETNUMBER(3),(GLsizei *) RING_API_GETCPOINTER(4,"GLsizei"),(GLint *) RING_API_GETCPOINTER(5,"GLint"),(GLenum *) RING_API_GETCPOINTER(6,"GLenum"),(GLchar *) RING_API_GETCPOINTER(7,"GLchar"));
}
RING_FUNC(ring_glGetAttachedShaders)
{
if ( RING_API_PARACOUNT != 4 ) {
RING_API_ERROR(RING_API_MISS4PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glGetAttachedShaders( (GLuint ) RING_API_GETNUMBER(1), (GLsizei ) (int) RING_API_GETNUMBER(2),(GLsizei *) RING_API_GETCPOINTER(3,"GLsizei"),(GLuint *) RING_API_GETCPOINTER(4,"GLuint"));
}
RING_FUNC(ring_glGetAttribLocation)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETNUMBER(glGetAttribLocation( (GLuint ) RING_API_GETNUMBER(1),(GLchar *) RING_API_GETCPOINTER(2,"GLchar")));
}
RING_FUNC(ring_glGetBufferParameteriv)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glGetBufferParameteriv( (GLenum ) (int) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2),(GLint *) RING_API_GETCPOINTER(3,"GLint"));
}
RING_FUNC(ring_glGetBufferPointerv)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glGetBufferPointerv( (GLenum ) (int) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2),(GLvoid **) RING_API_GETCPOINTER2POINTER(3,"GLvoid"));
}
RING_FUNC(ring_glGetBufferSubData)
{
if ( RING_API_PARACOUNT != 4 ) {
RING_API_ERROR(RING_API_MISS4PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glGetBufferSubData( (GLenum ) (int) RING_API_GETNUMBER(1), (GLintptr ) RING_API_GETNUMBER(2), (GLsizeiptr ) RING_API_GETNUMBER(3),(GLvoid *) RING_API_GETCPOINTER(4,"GLvoid"));
}
RING_FUNC(ring_glGetClipPlane)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glGetClipPlane( (GLenum ) (int) RING_API_GETNUMBER(1),(GLdouble *) RING_API_GETCPOINTER(2,"GLdouble"));
}
RING_FUNC(ring_glGetColorTable)
{
if ( RING_API_PARACOUNT != 4 ) {
RING_API_ERROR(RING_API_MISS4PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glGetColorTable( (GLenum ) (int) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2), (GLenum ) (int) RING_API_GETNUMBER(3),(GLvoid *) RING_API_GETCPOINTER(4,"GLvoid"));
}
RING_FUNC(ring_glGetColorTableParameterfv)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glGetColorTableParameterfv( (GLenum ) (int) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2),(GLfloat *) RING_API_GETCPOINTER(3,"GLfloat"));
}
RING_FUNC(ring_glGetColorTableParameteriv)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glGetColorTableParameteriv( (GLenum ) (int) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2),(GLint *) RING_API_GETCPOINTER(3,"GLint"));
}
RING_FUNC(ring_glGetCompressedTexImage)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glGetCompressedTexImage( (GLenum ) (int) RING_API_GETNUMBER(1), (GLint ) RING_API_GETNUMBER(2),(GLvoid *) RING_API_GETCPOINTER(3,"GLvoid"));
}
RING_FUNC(ring_glGetConvolutionFilter)
{
if ( RING_API_PARACOUNT != 4 ) {
RING_API_ERROR(RING_API_MISS4PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glGetConvolutionFilter( (GLenum ) (int) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2), (GLenum ) (int) RING_API_GETNUMBER(3),(GLvoid *) RING_API_GETCPOINTER(4,"GLvoid"));
}
RING_FUNC(ring_glGetConvolutionParameterfv)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glGetConvolutionParameterfv( (GLenum ) (int) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2),(GLfloat *) RING_API_GETCPOINTER(3,"GLfloat"));
}
RING_FUNC(ring_glGetConvolutionParameteriv)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glGetConvolutionParameteriv( (GLenum ) (int) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2),(GLint *) RING_API_GETCPOINTER(3,"GLint"));
}
RING_FUNC(ring_glGetError)
{
if ( RING_API_PARACOUNT != 0 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
RING_API_RETNUMBER(glGetError());
}
RING_FUNC(ring_glGetHistogram)
{
if ( RING_API_PARACOUNT != 5 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(5) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glGetHistogram( (GLenum ) (int) RING_API_GETNUMBER(1), (GLboolean ) RING_API_GETNUMBER(2), (GLenum ) (int) RING_API_GETNUMBER(3), (GLenum ) (int) RING_API_GETNUMBER(4),(GLvoid *) RING_API_GETCPOINTER(5,"GLvoid"));
}
RING_FUNC(ring_glGetHistogramParameterfv)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glGetHistogramParameterfv( (GLenum ) (int) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2),(GLfloat *) RING_API_GETCPOINTER(3,"GLfloat"));
}
RING_FUNC(ring_glGetHistogramParameteriv)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glGetHistogramParameteriv( (GLenum ) (int) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2),(GLint *) RING_API_GETCPOINTER(3,"GLint"));
}
RING_FUNC(ring_glGetLightfv)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glGetLightfv( (GLenum ) (int) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2),(GLfloat *) RING_API_GETCPOINTER(3,"GLfloat"));
}
RING_FUNC(ring_glGetLightiv)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glGetLightiv( (GLenum ) (int) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2),(GLint *) RING_API_GETCPOINTER(3,"GLint"));
}
RING_FUNC(ring_glGetMapdv)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glGetMapdv( (GLenum ) (int) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2),(GLdouble *) RING_API_GETCPOINTER(3,"GLdouble"));
}
RING_FUNC(ring_glGetMapfv)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glGetMapfv( (GLenum ) (int) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2),(GLfloat *) RING_API_GETCPOINTER(3,"GLfloat"));
}
RING_FUNC(ring_glGetMapiv)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glGetMapiv( (GLenum ) (int) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2),(GLint *) RING_API_GETCPOINTER(3,"GLint"));
}
RING_FUNC(ring_glGetMaterialfv)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glGetMaterialfv( (GLenum ) (int) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2),(GLfloat *) RING_API_GETCPOINTER(3,"GLfloat"));
}
RING_FUNC(ring_glGetMaterialiv)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glGetMaterialiv( (GLenum ) (int) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2),(GLint *) RING_API_GETCPOINTER(3,"GLint"));
}
RING_FUNC(ring_glGetMinmax)
{
if ( RING_API_PARACOUNT != 5 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(5) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glGetMinmax( (GLenum ) (int) RING_API_GETNUMBER(1), (GLboolean ) RING_API_GETNUMBER(2), (GLenum ) (int) RING_API_GETNUMBER(3), (GLenum ) (int) RING_API_GETNUMBER(4),(GLvoid *) RING_API_GETCPOINTER(5,"GLvoid"));
}
RING_FUNC(ring_glGetMinmaxParameterfv)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glGetMinmaxParameterfv( (GLenum ) (int) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2),(GLfloat *) RING_API_GETCPOINTER(3,"GLfloat"));
}
RING_FUNC(ring_glGetMinmaxParameteriv)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glGetMinmaxParameteriv( (GLenum ) (int) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2),(GLint *) RING_API_GETCPOINTER(3,"GLint"));
}
RING_FUNC(ring_glGetPixelMapfv)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glGetPixelMapfv( (GLenum ) (int) RING_API_GETNUMBER(1),(GLfloat *) RING_API_GETCPOINTER(2,"GLfloat"));
}
RING_FUNC(ring_glGetPixelMapuiv)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glGetPixelMapuiv( (GLenum ) (int) RING_API_GETNUMBER(1),(GLuint *) RING_API_GETCPOINTER(2,"GLuint"));
}
RING_FUNC(ring_glGetPixelMapusv)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glGetPixelMapusv( (GLenum ) (int) RING_API_GETNUMBER(1),(GLushort *) RING_API_GETCPOINTER(2,"GLushort"));
}
RING_FUNC(ring_glGetPointerv)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glGetPointerv( (GLenum ) (int) RING_API_GETNUMBER(1),(GLvoid **) RING_API_GETCPOINTER2POINTER(2,"GLvoid"));
}
RING_FUNC(ring_glGetPolygonStipple)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glGetPolygonStipple((GLubyte *) RING_API_GETCPOINTER(1,"GLubyte"));
}
RING_FUNC(ring_glGetProgramiv)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glGetProgramiv( (GLuint ) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2),(GLint *) RING_API_GETCPOINTER(3,"GLint"));
}
RING_FUNC(ring_glGetProgramInfoLog)
{
if ( RING_API_PARACOUNT != 4 ) {
RING_API_ERROR(RING_API_MISS4PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glGetProgramInfoLog( (GLuint ) RING_API_GETNUMBER(1), (GLsizei ) (int) RING_API_GETNUMBER(2),(GLsizei *) RING_API_GETCPOINTER(3,"GLsizei"),(GLchar *) RING_API_GETCPOINTER(4,"GLchar"));
}
RING_FUNC(ring_glGetQueryObjectiv)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glGetQueryObjectiv( (GLuint ) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2),(GLint *) RING_API_GETCPOINTER(3,"GLint"));
}
RING_FUNC(ring_glGetQueryObjectuiv)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glGetQueryObjectuiv( (GLuint ) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2),(GLuint *) RING_API_GETCPOINTER(3,"GLuint"));
}
RING_FUNC(ring_glGetQueryiv)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glGetQueryiv( (GLenum ) (int) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2),(GLint *) RING_API_GETCPOINTER(3,"GLint"));
}
RING_FUNC(ring_glGetSeparableFilter)
{
if ( RING_API_PARACOUNT != 6 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(5) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(6) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glGetSeparableFilter( (GLenum ) (int) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2), (GLenum ) (int) RING_API_GETNUMBER(3),(GLvoid *) RING_API_GETCPOINTER(4,"GLvoid"),(GLvoid *) RING_API_GETCPOINTER(5,"GLvoid"),(GLvoid *) RING_API_GETCPOINTER(6,"GLvoid"));
}
RING_FUNC(ring_glGetShaderiv)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glGetShaderiv( (GLuint ) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2),(GLint *) RING_API_GETCPOINTER(3,"GLint"));
}
RING_FUNC(ring_glGetShaderInfoLog)
{
if ( RING_API_PARACOUNT != 4 ) {
RING_API_ERROR(RING_API_MISS4PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glGetShaderInfoLog( (GLuint ) RING_API_GETNUMBER(1), (GLsizei ) (int) RING_API_GETNUMBER(2),(GLsizei *) RING_API_GETCPOINTER(3,"GLsizei"),(GLchar *) RING_API_GETCPOINTER(4,"GLchar"));
}
RING_FUNC(ring_glGetShaderSource)
{
if ( RING_API_PARACOUNT != 4 ) {
RING_API_ERROR(RING_API_MISS4PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glGetShaderSource( (GLuint ) RING_API_GETNUMBER(1), (GLsizei ) (int) RING_API_GETNUMBER(2),(GLsizei *) RING_API_GETCPOINTER(3,"GLsizei"),(GLchar *) RING_API_GETCPOINTER(4,"GLchar"));
}
RING_FUNC(ring_glGetString)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETCPOINTER(glGetString( (GLenum ) (int) RING_API_GETNUMBER(1)),"GLubyte");
}
RING_FUNC(ring_glGetTexEnvfv)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glGetTexEnvfv( (GLenum ) (int) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2),(GLfloat *) RING_API_GETCPOINTER(3,"GLfloat"));
}
RING_FUNC(ring_glGetTexEnviv)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glGetTexEnviv( (GLenum ) (int) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2),(GLint *) RING_API_GETCPOINTER(3,"GLint"));
}
RING_FUNC(ring_glGetTexGendv)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glGetTexGendv( (GLenum ) (int) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2),(GLdouble *) RING_API_GETCPOINTER(3,"GLdouble"));
}
RING_FUNC(ring_glGetTexGenfv)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glGetTexGenfv( (GLenum ) (int) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2),(GLfloat *) RING_API_GETCPOINTER(3,"GLfloat"));
}
RING_FUNC(ring_glGetTexGeniv)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glGetTexGeniv( (GLenum ) (int) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2),(GLint *) RING_API_GETCPOINTER(3,"GLint"));
}
RING_FUNC(ring_glGetTexImage)
{
if ( RING_API_PARACOUNT != 5 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(5) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glGetTexImage( (GLenum ) (int) RING_API_GETNUMBER(1), (GLint ) RING_API_GETNUMBER(2), (GLenum ) (int) RING_API_GETNUMBER(3), (GLenum ) (int) RING_API_GETNUMBER(4),(GLvoid *) RING_API_GETCPOINTER(5,"GLvoid"));
}
RING_FUNC(ring_glGetTexLevelParameterfv)
{
if ( RING_API_PARACOUNT != 4 ) {
RING_API_ERROR(RING_API_MISS4PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glGetTexLevelParameterfv( (GLenum ) (int) RING_API_GETNUMBER(1), (GLint ) RING_API_GETNUMBER(2), (GLenum ) (int) RING_API_GETNUMBER(3),(GLfloat *) RING_API_GETCPOINTER(4,"GLfloat"));
}
RING_FUNC(ring_glGetTexLevelParameteriv)
{
if ( RING_API_PARACOUNT != 4 ) {
RING_API_ERROR(RING_API_MISS4PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glGetTexLevelParameteriv( (GLenum ) (int) RING_API_GETNUMBER(1), (GLint ) RING_API_GETNUMBER(2), (GLenum ) (int) RING_API_GETNUMBER(3),(GLint *) RING_API_GETCPOINTER(4,"GLint"));
}
RING_FUNC(ring_glGetTexParameterfv)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glGetTexParameterfv( (GLenum ) (int) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2),(GLfloat *) RING_API_GETCPOINTER(3,"GLfloat"));
}
RING_FUNC(ring_glGetTexParameteriv)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glGetTexParameteriv( (GLenum ) (int) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2),(GLint *) RING_API_GETCPOINTER(3,"GLint"));
}
RING_FUNC(ring_glGetUniformfv)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glGetUniformfv( (GLuint ) RING_API_GETNUMBER(1), (GLint ) RING_API_GETNUMBER(2),(GLfloat *) RING_API_GETCPOINTER(3,"GLfloat"));
}
RING_FUNC(ring_glGetUniformiv)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glGetUniformiv( (GLuint ) RING_API_GETNUMBER(1), (GLint ) RING_API_GETNUMBER(2),(GLint *) RING_API_GETCPOINTER(3,"GLint"));
}
RING_FUNC(ring_glGetUniformLocation)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETNUMBER(glGetUniformLocation( (GLuint ) RING_API_GETNUMBER(1),(GLchar *) RING_API_GETCPOINTER(2,"GLchar")));
}
RING_FUNC(ring_glGetVertexAttribdv)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glGetVertexAttribdv( (GLuint ) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2),(GLdouble *) RING_API_GETCPOINTER(3,"GLdouble"));
}
RING_FUNC(ring_glGetVertexAttribfv)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glGetVertexAttribfv( (GLuint ) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2),(GLfloat *) RING_API_GETCPOINTER(3,"GLfloat"));
}
RING_FUNC(ring_glGetVertexAttribiv)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glGetVertexAttribiv( (GLuint ) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2),(GLint *) RING_API_GETCPOINTER(3,"GLint"));
}
RING_FUNC(ring_glGetVertexAttribPointerv)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glGetVertexAttribPointerv( (GLuint ) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2),(GLvoid **) RING_API_GETCPOINTER2POINTER(3,"GLvoid"));
}
RING_FUNC(ring_glHint)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glHint( (GLenum ) (int) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2));
}
RING_FUNC(ring_glHistogram)
{
if ( RING_API_PARACOUNT != 4 ) {
RING_API_ERROR(RING_API_MISS4PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glHistogram( (GLenum ) (int) RING_API_GETNUMBER(1), (GLsizei ) (int) RING_API_GETNUMBER(2), (GLenum ) (int) RING_API_GETNUMBER(3), (GLboolean ) RING_API_GETNUMBER(4));
}
RING_FUNC(ring_glIndexs)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glIndexs( (GLshort ) RING_API_GETNUMBER(1));
}
RING_FUNC(ring_glIndexi)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glIndexi( (GLint ) RING_API_GETNUMBER(1));
}
RING_FUNC(ring_glIndexf)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glIndexf( (GLfloat ) RING_API_GETNUMBER(1));
}
RING_FUNC(ring_glIndexd)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glIndexd( (GLdouble ) RING_API_GETNUMBER(1));
}
RING_FUNC(ring_glIndexub)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glIndexub( (GLubyte ) RING_API_GETNUMBER(1));
}
RING_FUNC(ring_glIndexsv)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glIndexsv((GLshort *) RING_API_GETCPOINTER(1,"GLshort"));
}
RING_FUNC(ring_glIndexiv)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glIndexiv((GLint *) RING_API_GETCPOINTER(1,"GLint"));
}
RING_FUNC(ring_glIndexfv)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glIndexfv((GLfloat *) RING_API_GETCPOINTER(1,"GLfloat"));
}
RING_FUNC(ring_glIndexdv)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glIndexdv((GLdouble *) RING_API_GETCPOINTER(1,"GLdouble"));
}
RING_FUNC(ring_glIndexubv)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glIndexubv((GLubyte *) RING_API_GETCPOINTER(1,"GLubyte"));
}
RING_FUNC(ring_glIndexMask)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glIndexMask( (GLuint ) RING_API_GETNUMBER(1));
}
RING_FUNC(ring_glIndexPointer)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glIndexPointer( (GLenum ) (int) RING_API_GETNUMBER(1), (GLsizei ) (int) RING_API_GETNUMBER(2),(GLvoid *) RING_API_GETCPOINTER(3,"GLvoid"));
}
RING_FUNC(ring_glInitNames)
{
if ( RING_API_PARACOUNT != 0 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
glInitNames();
}
RING_FUNC(ring_glInterleavedArrays)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glInterleavedArrays( (GLenum ) (int) RING_API_GETNUMBER(1), (GLsizei ) (int) RING_API_GETNUMBER(2),(GLvoid *) RING_API_GETCPOINTER(3,"GLvoid"));
}
RING_FUNC(ring_glIsBuffer)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETNUMBER(glIsBuffer( (GLuint ) RING_API_GETNUMBER(1)));
}
RING_FUNC(ring_glIsEnabled)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETNUMBER(glIsEnabled( (GLenum ) (int) RING_API_GETNUMBER(1)));
}
RING_FUNC(ring_glIsList)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETNUMBER(glIsList( (GLuint ) RING_API_GETNUMBER(1)));
}
RING_FUNC(ring_glIsProgram)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETNUMBER(glIsProgram( (GLuint ) RING_API_GETNUMBER(1)));
}
RING_FUNC(ring_glIsQuery)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETNUMBER(glIsQuery( (GLuint ) RING_API_GETNUMBER(1)));
}
RING_FUNC(ring_glIsShader)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETNUMBER(glIsShader( (GLuint ) RING_API_GETNUMBER(1)));
}
RING_FUNC(ring_glIsTexture)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETNUMBER(glIsTexture( (GLuint ) RING_API_GETNUMBER(1)));
}
RING_FUNC(ring_glLightf)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glLightf( (GLenum ) (int) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2), (GLfloat ) RING_API_GETNUMBER(3));
}
RING_FUNC(ring_glLighti)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glLighti( (GLenum ) (int) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2), (GLint ) RING_API_GETNUMBER(3));
}
RING_FUNC(ring_glLightfv)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glLightfv( (GLenum ) (int) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2),(GLfloat *) RING_API_GETCPOINTER(3,"GLfloat"));
}
RING_FUNC(ring_glLightiv)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glLightiv( (GLenum ) (int) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2),(GLint *) RING_API_GETCPOINTER(3,"GLint"));
}
RING_FUNC(ring_glLightModelf)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glLightModelf( (GLenum ) (int) RING_API_GETNUMBER(1), (GLfloat ) RING_API_GETNUMBER(2));
}
RING_FUNC(ring_glLightModeli)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glLightModeli( (GLenum ) (int) RING_API_GETNUMBER(1), (GLint ) RING_API_GETNUMBER(2));
}
RING_FUNC(ring_glLightModelfv)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glLightModelfv( (GLenum ) (int) RING_API_GETNUMBER(1),(GLfloat *) RING_API_GETCPOINTER(2,"GLfloat"));
}
RING_FUNC(ring_glLightModeliv)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glLightModeliv( (GLenum ) (int) RING_API_GETNUMBER(1),(GLint *) RING_API_GETCPOINTER(2,"GLint"));
}
RING_FUNC(ring_glLineStipple)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glLineStipple( (GLint ) RING_API_GETNUMBER(1), (GLushort ) RING_API_GETNUMBER(2));
}
RING_FUNC(ring_glLineWidth)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glLineWidth( (GLfloat ) RING_API_GETNUMBER(1));
}
RING_FUNC(ring_glLinkProgram)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glLinkProgram( (GLuint ) RING_API_GETNUMBER(1));
}
RING_FUNC(ring_glListBase)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glListBase( (GLuint ) RING_API_GETNUMBER(1));
}
RING_FUNC(ring_glLoadIdentity)
{
if ( RING_API_PARACOUNT != 0 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
glLoadIdentity();
}
RING_FUNC(ring_glLoadMatrixd)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glLoadMatrixd((GLdouble *) RING_API_GETCPOINTER(1,"GLdouble"));
}
RING_FUNC(ring_glLoadMatrixf)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glLoadMatrixf((GLfloat *) RING_API_GETCPOINTER(1,"GLfloat"));
}
RING_FUNC(ring_glLoadName)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glLoadName( (GLuint ) RING_API_GETNUMBER(1));
}
RING_FUNC(ring_glLoadTransposeMatrixd)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glLoadTransposeMatrixd((GLdouble *) RING_API_GETCPOINTER(1,"GLdouble"));
}
RING_FUNC(ring_glLoadTransposeMatrixf)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glLoadTransposeMatrixf((GLfloat *) RING_API_GETCPOINTER(1,"GLfloat"));
}
RING_FUNC(ring_glLogicOp)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glLogicOp( (GLenum ) (int) RING_API_GETNUMBER(1));
}
RING_FUNC(ring_glMap1f)
{
if ( RING_API_PARACOUNT != 6 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(5) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(6) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glMap1f( (GLenum ) (int) RING_API_GETNUMBER(1), (GLfloat ) RING_API_GETNUMBER(2), (GLfloat ) RING_API_GETNUMBER(3), (GLint ) RING_API_GETNUMBER(4), (GLint ) RING_API_GETNUMBER(5),(GLfloat *) RING_API_GETCPOINTER(6,"GLfloat"));
}
RING_FUNC(ring_glMap1d)
{
if ( RING_API_PARACOUNT != 6 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(5) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(6) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glMap1d( (GLenum ) (int) RING_API_GETNUMBER(1), (GLdouble ) RING_API_GETNUMBER(2), (GLdouble ) RING_API_GETNUMBER(3), (GLint ) RING_API_GETNUMBER(4), (GLint ) RING_API_GETNUMBER(5),(GLdouble *) RING_API_GETCPOINTER(6,"GLdouble"));
}
RING_FUNC(ring_glMap2f)
{
if ( RING_API_PARACOUNT != 10 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(5) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(6) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(7) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(8) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(9) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(10) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glMap2f( (GLenum ) (int) RING_API_GETNUMBER(1), (GLfloat ) RING_API_GETNUMBER(2), (GLfloat ) RING_API_GETNUMBER(3), (GLint ) RING_API_GETNUMBER(4), (GLint ) RING_API_GETNUMBER(5), (GLfloat ) RING_API_GETNUMBER(6), (GLfloat ) RING_API_GETNUMBER(7), (GLint ) RING_API_GETNUMBER(8), (GLint ) RING_API_GETNUMBER(9),(GLfloat *) RING_API_GETCPOINTER(10,"GLfloat"));
}
RING_FUNC(ring_glMap2d)
{
if ( RING_API_PARACOUNT != 10 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(5) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(6) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(7) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(8) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(9) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(10) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glMap2d( (GLenum ) (int) RING_API_GETNUMBER(1), (GLdouble ) RING_API_GETNUMBER(2), (GLdouble ) RING_API_GETNUMBER(3), (GLint ) RING_API_GETNUMBER(4), (GLint ) RING_API_GETNUMBER(5), (GLdouble ) RING_API_GETNUMBER(6), (GLdouble ) RING_API_GETNUMBER(7), (GLint ) RING_API_GETNUMBER(8), (GLint ) RING_API_GETNUMBER(9),(GLdouble *) RING_API_GETCPOINTER(10,"GLdouble"));
}
RING_FUNC(ring_glMapBuffer)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETCPOINTER(glMapBuffer( (GLenum ) (int) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2)),"void");
}
RING_FUNC(ring_glMapGrid1d)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glMapGrid1d( (GLint ) RING_API_GETNUMBER(1), (GLdouble ) RING_API_GETNUMBER(2), (GLdouble ) RING_API_GETNUMBER(3));
}
RING_FUNC(ring_glMapGrid1f)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glMapGrid1f( (GLint ) RING_API_GETNUMBER(1), (GLfloat ) RING_API_GETNUMBER(2), (GLfloat ) RING_API_GETNUMBER(3));
}
RING_FUNC(ring_glMapGrid2d)
{
if ( RING_API_PARACOUNT != 6 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(5) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(6) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glMapGrid2d( (GLint ) RING_API_GETNUMBER(1), (GLdouble ) RING_API_GETNUMBER(2), (GLdouble ) RING_API_GETNUMBER(3), (GLint ) RING_API_GETNUMBER(4), (GLdouble ) RING_API_GETNUMBER(5), (GLdouble ) RING_API_GETNUMBER(6));
}
RING_FUNC(ring_glMapGrid2f)
{
if ( RING_API_PARACOUNT != 6 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(5) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(6) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glMapGrid2f( (GLint ) RING_API_GETNUMBER(1), (GLfloat ) RING_API_GETNUMBER(2), (GLfloat ) RING_API_GETNUMBER(3), (GLint ) RING_API_GETNUMBER(4), (GLfloat ) RING_API_GETNUMBER(5), (GLfloat ) RING_API_GETNUMBER(6));
}
RING_FUNC(ring_glMaterialf)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glMaterialf( (GLenum ) (int) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2), (GLfloat ) RING_API_GETNUMBER(3));
}
RING_FUNC(ring_glMateriali)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glMateriali( (GLenum ) (int) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2), (GLint ) RING_API_GETNUMBER(3));
}
RING_FUNC(ring_glMatrixMode)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glMatrixMode( (GLenum ) (int) RING_API_GETNUMBER(1));
}
RING_FUNC(ring_glMinmax)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glMinmax( (GLenum ) (int) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2), (GLboolean ) RING_API_GETNUMBER(3));
}
RING_FUNC(ring_glMultMatrixd)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glMultMatrixd((GLdouble *) RING_API_GETCPOINTER(1,"GLdouble"));
}
RING_FUNC(ring_glMultMatrixf)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glMultMatrixf((GLfloat *) RING_API_GETCPOINTER(1,"GLfloat"));
}
RING_FUNC(ring_glMultTransposeMatrixd)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glMultTransposeMatrixd((GLdouble *) RING_API_GETCPOINTER(1,"GLdouble"));
}
RING_FUNC(ring_glMultTransposeMatrixf)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glMultTransposeMatrixf((GLfloat *) RING_API_GETCPOINTER(1,"GLfloat"));
}
RING_FUNC(ring_glMultiDrawArrays)
{
if ( RING_API_PARACOUNT != 4 ) {
RING_API_ERROR(RING_API_MISS4PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glMultiDrawArrays( (GLenum ) (int) RING_API_GETNUMBER(1),(GLint *) RING_API_GETCPOINTER(2,"GLint"),(GLsizei *) RING_API_GETCPOINTER(3,"GLsizei"), (GLsizei ) (int) RING_API_GETNUMBER(4));
}
RING_FUNC(ring_glMultiDrawElements)
{
if ( RING_API_PARACOUNT != 5 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(5) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glMultiDrawElements( (GLenum ) (int) RING_API_GETNUMBER(1),(GLsizei *) RING_API_GETCPOINTER(2,"GLsizei"), (GLenum ) (int) RING_API_GETNUMBER(3),(GLvoid **) RING_API_GETCPOINTER2POINTER(4,"GLvoid"), (GLsizei ) (int) RING_API_GETNUMBER(5));
}
RING_FUNC(ring_glMultiTexCoord1s)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glMultiTexCoord1s( (GLenum ) (int) RING_API_GETNUMBER(1), (GLshort ) RING_API_GETNUMBER(2));
}
RING_FUNC(ring_glMultiTexCoord1i)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glMultiTexCoord1i( (GLenum ) (int) RING_API_GETNUMBER(1), (GLint ) RING_API_GETNUMBER(2));
}
RING_FUNC(ring_glMultiTexCoord1f)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glMultiTexCoord1f( (GLenum ) (int) RING_API_GETNUMBER(1), (GLfloat ) RING_API_GETNUMBER(2));
}
RING_FUNC(ring_glMultiTexCoord1d)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glMultiTexCoord1d( (GLenum ) (int) RING_API_GETNUMBER(1), (GLdouble ) RING_API_GETNUMBER(2));
}
RING_FUNC(ring_glMultiTexCoord2s)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glMultiTexCoord2s( (GLenum ) (int) RING_API_GETNUMBER(1), (GLshort ) RING_API_GETNUMBER(2), (GLshort ) RING_API_GETNUMBER(3));
}
RING_FUNC(ring_glMultiTexCoord2i)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glMultiTexCoord2i( (GLenum ) (int) RING_API_GETNUMBER(1), (GLint ) RING_API_GETNUMBER(2), (GLint ) RING_API_GETNUMBER(3));
}
RING_FUNC(ring_glMultiTexCoord2f)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glMultiTexCoord2f( (GLenum ) (int) RING_API_GETNUMBER(1), (GLfloat ) RING_API_GETNUMBER(2), (GLfloat ) RING_API_GETNUMBER(3));
}
RING_FUNC(ring_glMultiTexCoord2d)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glMultiTexCoord2d( (GLenum ) (int) RING_API_GETNUMBER(1), (GLdouble ) RING_API_GETNUMBER(2), (GLdouble ) RING_API_GETNUMBER(3));
}
RING_FUNC(ring_glMultiTexCoord3s)
{
if ( RING_API_PARACOUNT != 4 ) {
RING_API_ERROR(RING_API_MISS4PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glMultiTexCoord3s( (GLenum ) (int) RING_API_GETNUMBER(1), (GLshort ) RING_API_GETNUMBER(2), (GLshort ) RING_API_GETNUMBER(3), (GLshort ) RING_API_GETNUMBER(4));
}
RING_FUNC(ring_glMultiTexCoord3i)
{
if ( RING_API_PARACOUNT != 4 ) {
RING_API_ERROR(RING_API_MISS4PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glMultiTexCoord3i( (GLenum ) (int) RING_API_GETNUMBER(1), (GLint ) RING_API_GETNUMBER(2), (GLint ) RING_API_GETNUMBER(3), (GLint ) RING_API_GETNUMBER(4));
}
RING_FUNC(ring_glMultiTexCoord3f)
{
if ( RING_API_PARACOUNT != 4 ) {
RING_API_ERROR(RING_API_MISS4PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glMultiTexCoord3f( (GLenum ) (int) RING_API_GETNUMBER(1), (GLfloat ) RING_API_GETNUMBER(2), (GLfloat ) RING_API_GETNUMBER(3), (GLfloat ) RING_API_GETNUMBER(4));
}
RING_FUNC(ring_glMultiTexCoord3d)
{
if ( RING_API_PARACOUNT != 4 ) {
RING_API_ERROR(RING_API_MISS4PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glMultiTexCoord3d( (GLenum ) (int) RING_API_GETNUMBER(1), (GLdouble ) RING_API_GETNUMBER(2), (GLdouble ) RING_API_GETNUMBER(3), (GLdouble ) RING_API_GETNUMBER(4));
}
RING_FUNC(ring_glMultiTexCoord4s)
{
if ( RING_API_PARACOUNT != 5 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(5) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glMultiTexCoord4s( (GLenum ) (int) RING_API_GETNUMBER(1), (GLshort ) RING_API_GETNUMBER(2), (GLshort ) RING_API_GETNUMBER(3), (GLshort ) RING_API_GETNUMBER(4), (GLshort ) RING_API_GETNUMBER(5));
}
RING_FUNC(ring_glMultiTexCoord4i)
{
if ( RING_API_PARACOUNT != 5 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(5) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glMultiTexCoord4i( (GLenum ) (int) RING_API_GETNUMBER(1), (GLint ) RING_API_GETNUMBER(2), (GLint ) RING_API_GETNUMBER(3), (GLint ) RING_API_GETNUMBER(4), (GLint ) RING_API_GETNUMBER(5));
}
RING_FUNC(ring_glMultiTexCoord4f)
{
if ( RING_API_PARACOUNT != 5 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(5) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glMultiTexCoord4f( (GLenum ) (int) RING_API_GETNUMBER(1), (GLfloat ) RING_API_GETNUMBER(2), (GLfloat ) RING_API_GETNUMBER(3), (GLfloat ) RING_API_GETNUMBER(4), (GLfloat ) RING_API_GETNUMBER(5));
}
RING_FUNC(ring_glMultiTexCoord4d)
{
if ( RING_API_PARACOUNT != 5 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(5) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glMultiTexCoord4d( (GLenum ) (int) RING_API_GETNUMBER(1), (GLdouble ) RING_API_GETNUMBER(2), (GLdouble ) RING_API_GETNUMBER(3), (GLdouble ) RING_API_GETNUMBER(4), (GLdouble ) RING_API_GETNUMBER(5));
}
RING_FUNC(ring_glMultiTexCoord1sv)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glMultiTexCoord1sv( (GLenum ) (int) RING_API_GETNUMBER(1),(GLshort *) RING_API_GETCPOINTER(2,"GLshort"));
}
RING_FUNC(ring_glMultiTexCoord1iv)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glMultiTexCoord1iv( (GLenum ) (int) RING_API_GETNUMBER(1),(GLint *) RING_API_GETCPOINTER(2,"GLint"));
}
RING_FUNC(ring_glMultiTexCoord1fv)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glMultiTexCoord1fv( (GLenum ) (int) RING_API_GETNUMBER(1),(GLfloat *) RING_API_GETCPOINTER(2,"GLfloat"));
}
RING_FUNC(ring_glMultiTexCoord1dv)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glMultiTexCoord1dv( (GLenum ) (int) RING_API_GETNUMBER(1),(GLdouble *) RING_API_GETCPOINTER(2,"GLdouble"));
}
RING_FUNC(ring_glMultiTexCoord2sv)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glMultiTexCoord2sv( (GLenum ) (int) RING_API_GETNUMBER(1),(GLshort *) RING_API_GETCPOINTER(2,"GLshort"));
}
RING_FUNC(ring_glMultiTexCoord2iv)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glMultiTexCoord2iv( (GLenum ) (int) RING_API_GETNUMBER(1),(GLint *) RING_API_GETCPOINTER(2,"GLint"));
}
RING_FUNC(ring_glMultiTexCoord2fv)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glMultiTexCoord2fv( (GLenum ) (int) RING_API_GETNUMBER(1),(GLfloat *) RING_API_GETCPOINTER(2,"GLfloat"));
}
RING_FUNC(ring_glMultiTexCoord2dv)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glMultiTexCoord2dv( (GLenum ) (int) RING_API_GETNUMBER(1),(GLdouble *) RING_API_GETCPOINTER(2,"GLdouble"));
}
RING_FUNC(ring_glMultiTexCoord3sv)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glMultiTexCoord3sv( (GLenum ) (int) RING_API_GETNUMBER(1),(GLshort *) RING_API_GETCPOINTER(2,"GLshort"));
}
RING_FUNC(ring_glMultiTexCoord3iv)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glMultiTexCoord3iv( (GLenum ) (int) RING_API_GETNUMBER(1),(GLint *) RING_API_GETCPOINTER(2,"GLint"));
}
RING_FUNC(ring_glMultiTexCoord3fv)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glMultiTexCoord3fv( (GLenum ) (int) RING_API_GETNUMBER(1),(GLfloat *) RING_API_GETCPOINTER(2,"GLfloat"));
}
RING_FUNC(ring_glMultiTexCoord3dv)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glMultiTexCoord3dv( (GLenum ) (int) RING_API_GETNUMBER(1),(GLdouble *) RING_API_GETCPOINTER(2,"GLdouble"));
}
RING_FUNC(ring_glMultiTexCoord4sv)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glMultiTexCoord4sv( (GLenum ) (int) RING_API_GETNUMBER(1),(GLshort *) RING_API_GETCPOINTER(2,"GLshort"));
}
RING_FUNC(ring_glMultiTexCoord4iv)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glMultiTexCoord4iv( (GLenum ) (int) RING_API_GETNUMBER(1),(GLint *) RING_API_GETCPOINTER(2,"GLint"));
}
RING_FUNC(ring_glMultiTexCoord4fv)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glMultiTexCoord4fv( (GLenum ) (int) RING_API_GETNUMBER(1),(GLfloat *) RING_API_GETCPOINTER(2,"GLfloat"));
}
RING_FUNC(ring_glMultiTexCoord4dv)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glMultiTexCoord4dv( (GLenum ) (int) RING_API_GETNUMBER(1),(GLdouble *) RING_API_GETCPOINTER(2,"GLdouble"));
}
RING_FUNC(ring_glNewList)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glNewList( (GLuint ) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2));
}
RING_FUNC(ring_glNormal3b)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glNormal3b( (GLbyte ) RING_API_GETNUMBER(1), (GLbyte ) RING_API_GETNUMBER(2), (GLbyte ) RING_API_GETNUMBER(3));
}
RING_FUNC(ring_glNormal3d)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glNormal3d( (GLdouble ) RING_API_GETNUMBER(1), (GLdouble ) RING_API_GETNUMBER(2), (GLdouble ) RING_API_GETNUMBER(3));
}
RING_FUNC(ring_glNormal3f)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glNormal3f( (GLfloat ) RING_API_GETNUMBER(1), (GLfloat ) RING_API_GETNUMBER(2), (GLfloat ) RING_API_GETNUMBER(3));
}
RING_FUNC(ring_glNormal3i)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glNormal3i( (GLint ) RING_API_GETNUMBER(1), (GLint ) RING_API_GETNUMBER(2), (GLint ) RING_API_GETNUMBER(3));
}
RING_FUNC(ring_glNormal3s)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glNormal3s( (GLshort ) RING_API_GETNUMBER(1), (GLshort ) RING_API_GETNUMBER(2), (GLshort ) RING_API_GETNUMBER(3));
}
RING_FUNC(ring_glNormal3bv)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glNormal3bv((GLbyte *) RING_API_GETCPOINTER(1,"GLbyte"));
}
RING_FUNC(ring_glNormal3dv)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glNormal3dv((GLdouble *) RING_API_GETCPOINTER(1,"GLdouble"));
}
RING_FUNC(ring_glNormal3fv)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glNormal3fv((GLfloat *) RING_API_GETCPOINTER(1,"GLfloat"));
}
RING_FUNC(ring_glNormal3iv)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glNormal3iv((GLint *) RING_API_GETCPOINTER(1,"GLint"));
}
RING_FUNC(ring_glNormal3sv)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glNormal3sv((GLshort *) RING_API_GETCPOINTER(1,"GLshort"));
}
RING_FUNC(ring_glNormalPointer)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glNormalPointer( (GLenum ) (int) RING_API_GETNUMBER(1), (GLsizei ) (int) RING_API_GETNUMBER(2),(GLvoid *) RING_API_GETCPOINTER(3,"GLvoid"));
}
RING_FUNC(ring_glOrtho)
{
if ( RING_API_PARACOUNT != 6 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(5) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(6) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glOrtho( (GLdouble ) RING_API_GETNUMBER(1), (GLdouble ) RING_API_GETNUMBER(2), (GLdouble ) RING_API_GETNUMBER(3), (GLdouble ) RING_API_GETNUMBER(4), (GLdouble ) RING_API_GETNUMBER(5), (GLdouble ) RING_API_GETNUMBER(6));
}
RING_FUNC(ring_glPassThrough)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glPassThrough( (GLfloat ) RING_API_GETNUMBER(1));
}
RING_FUNC(ring_glPixelMapfv)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glPixelMapfv( (GLenum ) (int) RING_API_GETNUMBER(1), (GLsizei ) (int) RING_API_GETNUMBER(2),(GLfloat *) RING_API_GETCPOINTER(3,"GLfloat"));
}
RING_FUNC(ring_glPixelMapuiv)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glPixelMapuiv( (GLenum ) (int) RING_API_GETNUMBER(1), (GLsizei ) (int) RING_API_GETNUMBER(2),(GLuint *) RING_API_GETCPOINTER(3,"GLuint"));
}
RING_FUNC(ring_glPixelMapusv)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glPixelMapusv( (GLenum ) (int) RING_API_GETNUMBER(1), (GLsizei ) (int) RING_API_GETNUMBER(2),(GLushort *) RING_API_GETCPOINTER(3,"GLushort"));
}
RING_FUNC(ring_glPixelStoref)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glPixelStoref( (GLenum ) (int) RING_API_GETNUMBER(1), (GLfloat ) RING_API_GETNUMBER(2));
}
RING_FUNC(ring_glPixelStorei)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glPixelStorei( (GLenum ) (int) RING_API_GETNUMBER(1), (GLint ) RING_API_GETNUMBER(2));
}
RING_FUNC(ring_glPixelTransferf)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glPixelTransferf( (GLenum ) (int) RING_API_GETNUMBER(1), (GLfloat ) RING_API_GETNUMBER(2));
}
RING_FUNC(ring_glPixelTransferi)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glPixelTransferi( (GLenum ) (int) RING_API_GETNUMBER(1), (GLint ) RING_API_GETNUMBER(2));
}
RING_FUNC(ring_glPixelZoom)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glPixelZoom( (GLfloat ) RING_API_GETNUMBER(1), (GLfloat ) RING_API_GETNUMBER(2));
}
RING_FUNC(ring_glPointParameterf)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glPointParameterf( (GLenum ) (int) RING_API_GETNUMBER(1), (GLfloat ) RING_API_GETNUMBER(2));
}
RING_FUNC(ring_glPointParameteri)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glPointParameteri( (GLenum ) (int) RING_API_GETNUMBER(1), (GLint ) RING_API_GETNUMBER(2));
}
RING_FUNC(ring_glPointSize)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glPointSize( (GLfloat ) RING_API_GETNUMBER(1));
}
RING_FUNC(ring_glPolygonMode)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glPolygonMode( (GLenum ) (int) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2));
}
RING_FUNC(ring_glPolygonOffset)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glPolygonOffset( (GLfloat ) RING_API_GETNUMBER(1), (GLfloat ) RING_API_GETNUMBER(2));
}
RING_FUNC(ring_glPolygonStipple)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glPolygonStipple((GLubyte *) RING_API_GETCPOINTER(1,"GLubyte"));
}
RING_FUNC(ring_glPushAttrib)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glPushAttrib( (GLbitfield ) (int) RING_API_GETNUMBER(1));
}
RING_FUNC(ring_glPushClientAttrib)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glPushClientAttrib( (GLbitfield ) (int) RING_API_GETNUMBER(1));
}
RING_FUNC(ring_glPushMatrix)
{
if ( RING_API_PARACOUNT != 0 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
glPushMatrix();
}
RING_FUNC(ring_glPushName)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glPushName( (GLuint ) RING_API_GETNUMBER(1));
}
RING_FUNC(ring_glPrioritizeTextures)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glPrioritizeTextures( (GLsizei ) (int) RING_API_GETNUMBER(1),(GLuint *) RING_API_GETCPOINTER(2,"GLuint"),(GLclampf *) RING_API_GETCPOINTER(3,"GLclampf"));
}
RING_FUNC(ring_glPopMatrix)
{
if ( RING_API_PARACOUNT != 0 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
glPopMatrix();
}
RING_FUNC(ring_glRasterPos2s)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glRasterPos2s( (GLshort ) RING_API_GETNUMBER(1), (GLshort ) RING_API_GETNUMBER(2));
}
RING_FUNC(ring_glRasterPos2i)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glRasterPos2i( (GLint ) RING_API_GETNUMBER(1), (GLint ) RING_API_GETNUMBER(2));
}
RING_FUNC(ring_glRasterPos2f)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glRasterPos2f( (GLfloat ) RING_API_GETNUMBER(1), (GLfloat ) RING_API_GETNUMBER(2));
}
RING_FUNC(ring_glRasterPos2d)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glRasterPos2d( (GLdouble ) RING_API_GETNUMBER(1), (GLdouble ) RING_API_GETNUMBER(2));
}
RING_FUNC(ring_glRasterPos3s)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glRasterPos3s( (GLshort ) RING_API_GETNUMBER(1), (GLshort ) RING_API_GETNUMBER(2), (GLshort ) RING_API_GETNUMBER(3));
}
RING_FUNC(ring_glRasterPos3i)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glRasterPos3i( (GLint ) RING_API_GETNUMBER(1), (GLint ) RING_API_GETNUMBER(2), (GLint ) RING_API_GETNUMBER(3));
}
RING_FUNC(ring_glRasterPos3f)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glRasterPos3f( (GLfloat ) RING_API_GETNUMBER(1), (GLfloat ) RING_API_GETNUMBER(2), (GLfloat ) RING_API_GETNUMBER(3));
}
RING_FUNC(ring_glRasterPos3d)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glRasterPos3d( (GLdouble ) RING_API_GETNUMBER(1), (GLdouble ) RING_API_GETNUMBER(2), (GLdouble ) RING_API_GETNUMBER(3));
}
RING_FUNC(ring_glRasterPos4s)
{
if ( RING_API_PARACOUNT != 4 ) {
RING_API_ERROR(RING_API_MISS4PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glRasterPos4s( (GLshort ) RING_API_GETNUMBER(1), (GLshort ) RING_API_GETNUMBER(2), (GLshort ) RING_API_GETNUMBER(3), (GLshort ) RING_API_GETNUMBER(4));
}
RING_FUNC(ring_glRasterPos4i)
{
if ( RING_API_PARACOUNT != 4 ) {
RING_API_ERROR(RING_API_MISS4PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glRasterPos4i( (GLint ) RING_API_GETNUMBER(1), (GLint ) RING_API_GETNUMBER(2), (GLint ) RING_API_GETNUMBER(3), (GLint ) RING_API_GETNUMBER(4));
}
RING_FUNC(ring_glRasterPos4f)
{
if ( RING_API_PARACOUNT != 4 ) {
RING_API_ERROR(RING_API_MISS4PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glRasterPos4f( (GLfloat ) RING_API_GETNUMBER(1), (GLfloat ) RING_API_GETNUMBER(2), (GLfloat ) RING_API_GETNUMBER(3), (GLfloat ) RING_API_GETNUMBER(4));
}
RING_FUNC(ring_glRasterPos4d)
{
if ( RING_API_PARACOUNT != 4 ) {
RING_API_ERROR(RING_API_MISS4PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glRasterPos4d( (GLdouble ) RING_API_GETNUMBER(1), (GLdouble ) RING_API_GETNUMBER(2), (GLdouble ) RING_API_GETNUMBER(3), (GLdouble ) RING_API_GETNUMBER(4));
}
RING_FUNC(ring_glReadBuffer)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glReadBuffer( (GLenum ) (int) RING_API_GETNUMBER(1));
}
RING_FUNC(ring_glReadPixels)
{
if ( RING_API_PARACOUNT != 7 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(5) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(6) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(7) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glReadPixels( (GLint ) RING_API_GETNUMBER(1), (GLint ) RING_API_GETNUMBER(2), (GLsizei ) (int) RING_API_GETNUMBER(3), (GLsizei ) (int) RING_API_GETNUMBER(4), (GLenum ) (int) RING_API_GETNUMBER(5), (GLenum ) (int) RING_API_GETNUMBER(6),(GLvoid *) RING_API_GETCPOINTER(7,"GLvoid"));
}
RING_FUNC(ring_glRectd)
{
if ( RING_API_PARACOUNT != 4 ) {
RING_API_ERROR(RING_API_MISS4PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glRectd( (GLdouble ) RING_API_GETNUMBER(1), (GLdouble ) RING_API_GETNUMBER(2), (GLdouble ) RING_API_GETNUMBER(3), (GLdouble ) RING_API_GETNUMBER(4));
}
RING_FUNC(ring_glRectf)
{
if ( RING_API_PARACOUNT != 4 ) {
RING_API_ERROR(RING_API_MISS4PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glRectf( (GLfloat ) RING_API_GETNUMBER(1), (GLfloat ) RING_API_GETNUMBER(2), (GLfloat ) RING_API_GETNUMBER(3), (GLfloat ) RING_API_GETNUMBER(4));
}
RING_FUNC(ring_glRecti)
{
if ( RING_API_PARACOUNT != 4 ) {
RING_API_ERROR(RING_API_MISS4PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glRecti( (GLint ) RING_API_GETNUMBER(1), (GLint ) RING_API_GETNUMBER(2), (GLint ) RING_API_GETNUMBER(3), (GLint ) RING_API_GETNUMBER(4));
}
RING_FUNC(ring_glRects)
{
if ( RING_API_PARACOUNT != 4 ) {
RING_API_ERROR(RING_API_MISS4PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glRects( (GLshort ) RING_API_GETNUMBER(1), (GLshort ) RING_API_GETNUMBER(2), (GLshort ) RING_API_GETNUMBER(3), (GLshort ) RING_API_GETNUMBER(4));
}
RING_FUNC(ring_glRectdv)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glRectdv((GLdouble *) RING_API_GETCPOINTER(1,"GLdouble"),(GLdouble *) RING_API_GETCPOINTER(2,"GLdouble"));
}
RING_FUNC(ring_glRectfv)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glRectfv((GLfloat *) RING_API_GETCPOINTER(1,"GLfloat"),(GLfloat *) RING_API_GETCPOINTER(2,"GLfloat"));
}
RING_FUNC(ring_glRectiv)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glRectiv((GLint *) RING_API_GETCPOINTER(1,"GLint"),(GLint *) RING_API_GETCPOINTER(2,"GLint"));
}
RING_FUNC(ring_glRectsv)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glRectsv((GLshort *) RING_API_GETCPOINTER(1,"GLshort"),(GLshort *) RING_API_GETCPOINTER(2,"GLshort"));
}
RING_FUNC(ring_glRenderMode)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETNUMBER(glRenderMode( (GLenum ) (int) RING_API_GETNUMBER(1)));
}
RING_FUNC(ring_glResetHistogram)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glResetHistogram( (GLenum ) (int) RING_API_GETNUMBER(1));
}
RING_FUNC(ring_glRotated)
{
if ( RING_API_PARACOUNT != 4 ) {
RING_API_ERROR(RING_API_MISS4PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glRotated( (GLdouble ) RING_API_GETNUMBER(1), (GLdouble ) RING_API_GETNUMBER(2), (GLdouble ) RING_API_GETNUMBER(3), (GLdouble ) RING_API_GETNUMBER(4));
}
RING_FUNC(ring_glRotatef)
{
if ( RING_API_PARACOUNT != 4 ) {
RING_API_ERROR(RING_API_MISS4PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glRotatef( (GLfloat ) RING_API_GETNUMBER(1), (GLfloat ) RING_API_GETNUMBER(2), (GLfloat ) RING_API_GETNUMBER(3), (GLfloat ) RING_API_GETNUMBER(4));
}
RING_FUNC(ring_glSampleCoverage)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glSampleCoverage( (GLclampf ) (int) RING_API_GETNUMBER(1), (GLboolean ) RING_API_GETNUMBER(2));
}
RING_FUNC(ring_glScaled)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glScaled( (GLdouble ) RING_API_GETNUMBER(1), (GLdouble ) RING_API_GETNUMBER(2), (GLdouble ) RING_API_GETNUMBER(3));
}
RING_FUNC(ring_glScalef)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glScalef( (GLfloat ) RING_API_GETNUMBER(1), (GLfloat ) RING_API_GETNUMBER(2), (GLfloat ) RING_API_GETNUMBER(3));
}
RING_FUNC(ring_glScissor)
{
if ( RING_API_PARACOUNT != 4 ) {
RING_API_ERROR(RING_API_MISS4PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glScissor( (GLint ) RING_API_GETNUMBER(1), (GLint ) RING_API_GETNUMBER(2), (GLsizei ) (int) RING_API_GETNUMBER(3), (GLsizei ) (int) RING_API_GETNUMBER(4));
}
RING_FUNC(ring_glSecondaryColor3b)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glSecondaryColor3b( (GLbyte ) RING_API_GETNUMBER(1), (GLbyte ) RING_API_GETNUMBER(2), (GLbyte ) RING_API_GETNUMBER(3));
}
RING_FUNC(ring_glSecondaryColor3s)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glSecondaryColor3s( (GLshort ) RING_API_GETNUMBER(1), (GLshort ) RING_API_GETNUMBER(2), (GLshort ) RING_API_GETNUMBER(3));
}
RING_FUNC(ring_glSecondaryColor3i)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glSecondaryColor3i( (GLint ) RING_API_GETNUMBER(1), (GLint ) RING_API_GETNUMBER(2), (GLint ) RING_API_GETNUMBER(3));
}
RING_FUNC(ring_glSecondaryColor3f)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glSecondaryColor3f( (GLfloat ) RING_API_GETNUMBER(1), (GLfloat ) RING_API_GETNUMBER(2), (GLfloat ) RING_API_GETNUMBER(3));
}
RING_FUNC(ring_glSecondaryColor3d)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glSecondaryColor3d( (GLdouble ) RING_API_GETNUMBER(1), (GLdouble ) RING_API_GETNUMBER(2), (GLdouble ) RING_API_GETNUMBER(3));
}
RING_FUNC(ring_glSecondaryColor3ub)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glSecondaryColor3ub( (GLubyte ) RING_API_GETNUMBER(1), (GLubyte ) RING_API_GETNUMBER(2), (GLubyte ) RING_API_GETNUMBER(3));
}
RING_FUNC(ring_glSecondaryColor3us)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glSecondaryColor3us( (GLushort ) RING_API_GETNUMBER(1), (GLushort ) RING_API_GETNUMBER(2), (GLushort ) RING_API_GETNUMBER(3));
}
RING_FUNC(ring_glSecondaryColor3ui)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glSecondaryColor3ui( (GLuint ) RING_API_GETNUMBER(1), (GLuint ) RING_API_GETNUMBER(2), (GLuint ) RING_API_GETNUMBER(3));
}
RING_FUNC(ring_glSecondaryColor3bv)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glSecondaryColor3bv((GLbyte *) RING_API_GETCPOINTER(1,"GLbyte"));
}
RING_FUNC(ring_glSecondaryColor3sv)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glSecondaryColor3sv((GLshort *) RING_API_GETCPOINTER(1,"GLshort"));
}
RING_FUNC(ring_glSecondaryColor3iv)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glSecondaryColor3iv((GLint *) RING_API_GETCPOINTER(1,"GLint"));
}
RING_FUNC(ring_glSecondaryColor3fv)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glSecondaryColor3fv((GLfloat *) RING_API_GETCPOINTER(1,"GLfloat"));
}
RING_FUNC(ring_glSecondaryColor3dv)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glSecondaryColor3dv((GLdouble *) RING_API_GETCPOINTER(1,"GLdouble"));
}
RING_FUNC(ring_glSecondaryColor3ubv)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glSecondaryColor3ubv((GLubyte *) RING_API_GETCPOINTER(1,"GLubyte"));
}
RING_FUNC(ring_glSecondaryColor3usv)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glSecondaryColor3usv((GLushort *) RING_API_GETCPOINTER(1,"GLushort"));
}
RING_FUNC(ring_glSecondaryColor3uiv)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glSecondaryColor3uiv((GLuint *) RING_API_GETCPOINTER(1,"GLuint"));
}
RING_FUNC(ring_glSecondaryColorPointer)
{
if ( RING_API_PARACOUNT != 4 ) {
RING_API_ERROR(RING_API_MISS4PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glSecondaryColorPointer( (GLint ) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2), (GLsizei ) (int) RING_API_GETNUMBER(3),(GLvoid *) RING_API_GETCPOINTER(4,"GLvoid"));
}
RING_FUNC(ring_glSelectBuffer)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glSelectBuffer( (GLsizei ) (int) RING_API_GETNUMBER(1),(GLuint *) RING_API_GETCPOINTER(2,"GLuint"));
}
RING_FUNC(ring_glSeparableFilter2D)
{
if ( RING_API_PARACOUNT != 8 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(5) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(6) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(7) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(8) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glSeparableFilter2D( (GLenum ) (int) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2), (GLsizei ) (int) RING_API_GETNUMBER(3), (GLsizei ) (int) RING_API_GETNUMBER(4), (GLenum ) (int) RING_API_GETNUMBER(5), (GLenum ) (int) RING_API_GETNUMBER(6),(GLvoid *) RING_API_GETCPOINTER(7,"GLvoid"),(GLvoid *) RING_API_GETCPOINTER(8,"GLvoid"));
}
RING_FUNC(ring_glShadeModel)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glShadeModel( (GLenum ) (int) RING_API_GETNUMBER(1));
}
RING_FUNC(ring_glShaderSource)
{
if ( RING_API_PARACOUNT != 4 ) {
RING_API_ERROR(RING_API_MISS4PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glShaderSource( (GLuint ) RING_API_GETNUMBER(1), (GLsizei ) (int) RING_API_GETNUMBER(2),(GLchar **) RING_API_GETCPOINTER2POINTER(3,"GLchar"),(GLint *) RING_API_GETCPOINTER(4,"GLint"));
}
RING_FUNC(ring_glStencilFunc)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glStencilFunc( (GLenum ) (int) RING_API_GETNUMBER(1), (GLint ) RING_API_GETNUMBER(2), (GLuint ) RING_API_GETNUMBER(3));
}
RING_FUNC(ring_glStencilFuncSeparate)
{
if ( RING_API_PARACOUNT != 4 ) {
RING_API_ERROR(RING_API_MISS4PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glStencilFuncSeparate( (GLenum ) (int) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2), (GLint ) RING_API_GETNUMBER(3), (GLuint ) RING_API_GETNUMBER(4));
}
RING_FUNC(ring_glStencilMask)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glStencilMask( (GLuint ) RING_API_GETNUMBER(1));
}
RING_FUNC(ring_glStencilMaskSeparate)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glStencilMaskSeparate( (GLenum ) (int) RING_API_GETNUMBER(1), (GLuint ) RING_API_GETNUMBER(2));
}
RING_FUNC(ring_glStencilOp)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glStencilOp( (GLenum ) (int) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2), (GLenum ) (int) RING_API_GETNUMBER(3));
}
RING_FUNC(ring_glStencilOpSeparate)
{
if ( RING_API_PARACOUNT != 4 ) {
RING_API_ERROR(RING_API_MISS4PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glStencilOpSeparate( (GLenum ) (int) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2), (GLenum ) (int) RING_API_GETNUMBER(3), (GLenum ) (int) RING_API_GETNUMBER(4));
}
RING_FUNC(ring_glTexCoord1s)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glTexCoord1s( (GLshort ) RING_API_GETNUMBER(1));
}
RING_FUNC(ring_glTexCoord1i)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glTexCoord1i( (GLint ) RING_API_GETNUMBER(1));
}
RING_FUNC(ring_glTexCoord1f)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glTexCoord1f( (GLfloat ) RING_API_GETNUMBER(1));
}
RING_FUNC(ring_glTexCoord1d)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glTexCoord1d( (GLdouble ) RING_API_GETNUMBER(1));
}
RING_FUNC(ring_glTexCoord2s)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glTexCoord2s( (GLshort ) RING_API_GETNUMBER(1), (GLshort ) RING_API_GETNUMBER(2));
}
RING_FUNC(ring_glTexCoord2i)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glTexCoord2i( (GLint ) RING_API_GETNUMBER(1), (GLint ) RING_API_GETNUMBER(2));
}
RING_FUNC(ring_glTexCoord2f)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glTexCoord2f( (GLfloat ) RING_API_GETNUMBER(1), (GLfloat ) RING_API_GETNUMBER(2));
}
RING_FUNC(ring_glTexCoord2d)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glTexCoord2d( (GLdouble ) RING_API_GETNUMBER(1), (GLdouble ) RING_API_GETNUMBER(2));
}
RING_FUNC(ring_glTexCoord3s)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glTexCoord3s( (GLshort ) RING_API_GETNUMBER(1), (GLshort ) RING_API_GETNUMBER(2), (GLshort ) RING_API_GETNUMBER(3));
}
RING_FUNC(ring_glTexCoord3i)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glTexCoord3i( (GLint ) RING_API_GETNUMBER(1), (GLint ) RING_API_GETNUMBER(2), (GLint ) RING_API_GETNUMBER(3));
}
RING_FUNC(ring_glTexCoord3f)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glTexCoord3f( (GLfloat ) RING_API_GETNUMBER(1), (GLfloat ) RING_API_GETNUMBER(2), (GLfloat ) RING_API_GETNUMBER(3));
}
RING_FUNC(ring_glTexCoord3d)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glTexCoord3d( (GLdouble ) RING_API_GETNUMBER(1), (GLdouble ) RING_API_GETNUMBER(2), (GLdouble ) RING_API_GETNUMBER(3));
}
RING_FUNC(ring_glTexCoord4s)
{
if ( RING_API_PARACOUNT != 4 ) {
RING_API_ERROR(RING_API_MISS4PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glTexCoord4s( (GLshort ) RING_API_GETNUMBER(1), (GLshort ) RING_API_GETNUMBER(2), (GLshort ) RING_API_GETNUMBER(3), (GLshort ) RING_API_GETNUMBER(4));
}
RING_FUNC(ring_glTexCoord4i)
{
if ( RING_API_PARACOUNT != 4 ) {
RING_API_ERROR(RING_API_MISS4PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glTexCoord4i( (GLint ) RING_API_GETNUMBER(1), (GLint ) RING_API_GETNUMBER(2), (GLint ) RING_API_GETNUMBER(3), (GLint ) RING_API_GETNUMBER(4));
}
RING_FUNC(ring_glTexCoord4f)
{
if ( RING_API_PARACOUNT != 4 ) {
RING_API_ERROR(RING_API_MISS4PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glTexCoord4f( (GLfloat ) RING_API_GETNUMBER(1), (GLfloat ) RING_API_GETNUMBER(2), (GLfloat ) RING_API_GETNUMBER(3), (GLfloat ) RING_API_GETNUMBER(4));
}
RING_FUNC(ring_glTexCoord4d)
{
if ( RING_API_PARACOUNT != 4 ) {
RING_API_ERROR(RING_API_MISS4PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glTexCoord4d( (GLdouble ) RING_API_GETNUMBER(1), (GLdouble ) RING_API_GETNUMBER(2), (GLdouble ) RING_API_GETNUMBER(3), (GLdouble ) RING_API_GETNUMBER(4));
}
RING_FUNC(ring_glTexCoord1sv)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glTexCoord1sv((GLshort *) RING_API_GETCPOINTER(1,"GLshort"));
}
RING_FUNC(ring_glTexCoord1iv)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glTexCoord1iv((GLint *) RING_API_GETCPOINTER(1,"GLint"));
}
RING_FUNC(ring_glTexCoord1fv)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glTexCoord1fv((GLfloat *) RING_API_GETCPOINTER(1,"GLfloat"));
}
RING_FUNC(ring_glTexCoord1dv)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glTexCoord1dv((GLdouble *) RING_API_GETCPOINTER(1,"GLdouble"));
}
RING_FUNC(ring_glTexCoord2sv)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glTexCoord2sv((GLshort *) RING_API_GETCPOINTER(1,"GLshort"));
}
RING_FUNC(ring_glTexCoord2iv)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glTexCoord2iv((GLint *) RING_API_GETCPOINTER(1,"GLint"));
}
RING_FUNC(ring_glTexCoord2fv)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glTexCoord2fv((GLfloat *) RING_API_GETCPOINTER(1,"GLfloat"));
}
RING_FUNC(ring_glTexCoord2dv)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glTexCoord2dv((GLdouble *) RING_API_GETCPOINTER(1,"GLdouble"));
}
RING_FUNC(ring_glTexCoord3sv)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glTexCoord3sv((GLshort *) RING_API_GETCPOINTER(1,"GLshort"));
}
RING_FUNC(ring_glTexCoord3iv)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glTexCoord3iv((GLint *) RING_API_GETCPOINTER(1,"GLint"));
}
RING_FUNC(ring_glTexCoord3fv)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glTexCoord3fv((GLfloat *) RING_API_GETCPOINTER(1,"GLfloat"));
}
RING_FUNC(ring_glTexCoord3dv)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glTexCoord3dv((GLdouble *) RING_API_GETCPOINTER(1,"GLdouble"));
}
RING_FUNC(ring_glTexCoord4sv)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glTexCoord4sv((GLshort *) RING_API_GETCPOINTER(1,"GLshort"));
}
RING_FUNC(ring_glTexCoord4iv)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glTexCoord4iv((GLint *) RING_API_GETCPOINTER(1,"GLint"));
}
RING_FUNC(ring_glTexCoord4fv)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glTexCoord4fv((GLfloat *) RING_API_GETCPOINTER(1,"GLfloat"));
}
RING_FUNC(ring_glTexCoord4dv)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glTexCoord4dv((GLdouble *) RING_API_GETCPOINTER(1,"GLdouble"));
}
RING_FUNC(ring_glTexCoordPointer)
{
if ( RING_API_PARACOUNT != 4 ) {
RING_API_ERROR(RING_API_MISS4PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glTexCoordPointer( (GLint ) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2), (GLsizei ) (int) RING_API_GETNUMBER(3),(GLvoid *) RING_API_GETCPOINTER(4,"GLvoid"));
}
RING_FUNC(ring_glTexEnvf)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glTexEnvf( (GLenum ) (int) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2), (GLfloat ) RING_API_GETNUMBER(3));
}
RING_FUNC(ring_glTexEnvi)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glTexEnvi( (GLenum ) (int) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2), (GLint ) RING_API_GETNUMBER(3));
}
RING_FUNC(ring_glTexGeni)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glTexGeni( (GLenum ) (int) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2), (GLint ) RING_API_GETNUMBER(3));
}
RING_FUNC(ring_glTexGenf)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glTexGenf( (GLenum ) (int) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2), (GLfloat ) RING_API_GETNUMBER(3));
}
RING_FUNC(ring_glTexGend)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glTexGend( (GLenum ) (int) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2), (GLdouble ) RING_API_GETNUMBER(3));
}
RING_FUNC(ring_glTexGeniv)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glTexGeniv( (GLenum ) (int) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2),(GLint *) RING_API_GETCPOINTER(3,"GLint"));
}
RING_FUNC(ring_glTexGenfv)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glTexGenfv( (GLenum ) (int) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2),(GLfloat *) RING_API_GETCPOINTER(3,"GLfloat"));
}
RING_FUNC(ring_glTexGendv)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glTexGendv( (GLenum ) (int) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2),(GLdouble *) RING_API_GETCPOINTER(3,"GLdouble"));
}
RING_FUNC(ring_glTexImage1D)
{
if ( RING_API_PARACOUNT != 8 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(5) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(6) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(7) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(8) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glTexImage1D( (GLenum ) (int) RING_API_GETNUMBER(1), (GLint ) RING_API_GETNUMBER(2), (GLint ) RING_API_GETNUMBER(3), (GLsizei ) (int) RING_API_GETNUMBER(4), (GLint ) RING_API_GETNUMBER(5), (GLenum ) (int) RING_API_GETNUMBER(6), (GLenum ) (int) RING_API_GETNUMBER(7),(GLvoid *) RING_API_GETCPOINTER(8,"GLvoid"));
}
RING_FUNC(ring_glTexImage2D)
{
if ( RING_API_PARACOUNT != 9 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(5) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(6) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(7) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(8) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(9) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glTexImage2D( (GLenum ) (int) RING_API_GETNUMBER(1), (GLint ) RING_API_GETNUMBER(2), (GLint ) RING_API_GETNUMBER(3), (GLsizei ) (int) RING_API_GETNUMBER(4), (GLsizei ) (int) RING_API_GETNUMBER(5), (GLint ) RING_API_GETNUMBER(6), (GLenum ) (int) RING_API_GETNUMBER(7), (GLenum ) (int) RING_API_GETNUMBER(8),(GLvoid *) RING_API_GETCPOINTER(9,"GLvoid"));
}
RING_FUNC(ring_glTexImage3D)
{
if ( RING_API_PARACOUNT != 10 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(5) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(6) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(7) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(8) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(9) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(10) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glTexImage3D( (GLenum ) (int) RING_API_GETNUMBER(1), (GLint ) RING_API_GETNUMBER(2), (GLint ) RING_API_GETNUMBER(3), (GLsizei ) (int) RING_API_GETNUMBER(4), (GLsizei ) (int) RING_API_GETNUMBER(5), (GLsizei ) (int) RING_API_GETNUMBER(6), (GLint ) RING_API_GETNUMBER(7), (GLenum ) (int) RING_API_GETNUMBER(8), (GLenum ) (int) RING_API_GETNUMBER(9),(GLvoid *) RING_API_GETCPOINTER(10,"GLvoid"));
}
RING_FUNC(ring_glTexParameterf)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glTexParameterf( (GLenum ) (int) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2), (GLfloat ) RING_API_GETNUMBER(3));
}
RING_FUNC(ring_glTexParameteri)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glTexParameteri( (GLenum ) (int) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2), (GLint ) RING_API_GETNUMBER(3));
}
RING_FUNC(ring_glTexParameterfv)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glTexParameterfv( (GLenum ) (int) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2),(GLfloat *) RING_API_GETCPOINTER(3,"GLfloat"));
}
RING_FUNC(ring_glTexParameteriv)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glTexParameteriv( (GLenum ) (int) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2),(GLint *) RING_API_GETCPOINTER(3,"GLint"));
}
RING_FUNC(ring_glTexSubImage1D)
{
if ( RING_API_PARACOUNT != 7 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(5) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(6) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(7) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glTexSubImage1D( (GLenum ) (int) RING_API_GETNUMBER(1), (GLint ) RING_API_GETNUMBER(2), (GLint ) RING_API_GETNUMBER(3), (GLsizei ) (int) RING_API_GETNUMBER(4), (GLenum ) (int) RING_API_GETNUMBER(5), (GLenum ) (int) RING_API_GETNUMBER(6),(GLvoid *) RING_API_GETCPOINTER(7,"GLvoid"));
}
RING_FUNC(ring_glTexSubImage2D)
{
if ( RING_API_PARACOUNT != 9 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(5) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(6) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(7) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(8) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(9) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glTexSubImage2D( (GLenum ) (int) RING_API_GETNUMBER(1), (GLint ) RING_API_GETNUMBER(2), (GLint ) RING_API_GETNUMBER(3), (GLint ) RING_API_GETNUMBER(4), (GLsizei ) (int) RING_API_GETNUMBER(5), (GLsizei ) (int) RING_API_GETNUMBER(6), (GLenum ) (int) RING_API_GETNUMBER(7), (GLenum ) (int) RING_API_GETNUMBER(8),(GLvoid *) RING_API_GETCPOINTER(9,"GLvoid"));
}
RING_FUNC(ring_glTexSubImage3D)
{
if ( RING_API_PARACOUNT != 11 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(5) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(6) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(7) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(8) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(9) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(10) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(11) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glTexSubImage3D( (GLenum ) (int) RING_API_GETNUMBER(1), (GLint ) RING_API_GETNUMBER(2), (GLint ) RING_API_GETNUMBER(3), (GLint ) RING_API_GETNUMBER(4), (GLint ) RING_API_GETNUMBER(5), (GLsizei ) (int) RING_API_GETNUMBER(6), (GLsizei ) (int) RING_API_GETNUMBER(7), (GLsizei ) (int) RING_API_GETNUMBER(8), (GLenum ) (int) RING_API_GETNUMBER(9), (GLenum ) (int) RING_API_GETNUMBER(10),(GLvoid *) RING_API_GETCPOINTER(11,"GLvoid"));
}
RING_FUNC(ring_glTranslated)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glTranslated( (GLdouble ) RING_API_GETNUMBER(1), (GLdouble ) RING_API_GETNUMBER(2), (GLdouble ) RING_API_GETNUMBER(3));
}
RING_FUNC(ring_glTranslatef)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glTranslatef( (GLfloat ) RING_API_GETNUMBER(1), (GLfloat ) RING_API_GETNUMBER(2), (GLfloat ) RING_API_GETNUMBER(3));
}
RING_FUNC(ring_glUniform1f)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glUniform1f( (GLint ) RING_API_GETNUMBER(1), (GLfloat ) RING_API_GETNUMBER(2));
}
RING_FUNC(ring_glUniform2f)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glUniform2f( (GLint ) RING_API_GETNUMBER(1), (GLfloat ) RING_API_GETNUMBER(2), (GLfloat ) RING_API_GETNUMBER(3));
}
RING_FUNC(ring_glUniform3f)
{
if ( RING_API_PARACOUNT != 4 ) {
RING_API_ERROR(RING_API_MISS4PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glUniform3f( (GLint ) RING_API_GETNUMBER(1), (GLfloat ) RING_API_GETNUMBER(2), (GLfloat ) RING_API_GETNUMBER(3), (GLfloat ) RING_API_GETNUMBER(4));
}
RING_FUNC(ring_glUniform4f)
{
if ( RING_API_PARACOUNT != 5 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(5) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glUniform4f( (GLint ) RING_API_GETNUMBER(1), (GLfloat ) RING_API_GETNUMBER(2), (GLfloat ) RING_API_GETNUMBER(3), (GLfloat ) RING_API_GETNUMBER(4), (GLfloat ) RING_API_GETNUMBER(5));
}
RING_FUNC(ring_glUniform1i)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glUniform1i( (GLint ) RING_API_GETNUMBER(1), (GLint ) RING_API_GETNUMBER(2));
}
RING_FUNC(ring_glUniform2i)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glUniform2i( (GLint ) RING_API_GETNUMBER(1), (GLint ) RING_API_GETNUMBER(2), (GLint ) RING_API_GETNUMBER(3));
}
RING_FUNC(ring_glUniform3i)
{
if ( RING_API_PARACOUNT != 4 ) {
RING_API_ERROR(RING_API_MISS4PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glUniform3i( (GLint ) RING_API_GETNUMBER(1), (GLint ) RING_API_GETNUMBER(2), (GLint ) RING_API_GETNUMBER(3), (GLint ) RING_API_GETNUMBER(4));
}
RING_FUNC(ring_glUniform4i)
{
if ( RING_API_PARACOUNT != 5 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(5) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glUniform4i( (GLint ) RING_API_GETNUMBER(1), (GLint ) RING_API_GETNUMBER(2), (GLint ) RING_API_GETNUMBER(3), (GLint ) RING_API_GETNUMBER(4), (GLint ) RING_API_GETNUMBER(5));
}
RING_FUNC(ring_glUniform1fv)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glUniform1fv( (GLint ) RING_API_GETNUMBER(1), (GLsizei ) (int) RING_API_GETNUMBER(2),(GLfloat *) RING_API_GETCPOINTER(3,"GLfloat"));
}
RING_FUNC(ring_glUniform2fv)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glUniform2fv( (GLint ) RING_API_GETNUMBER(1), (GLsizei ) (int) RING_API_GETNUMBER(2),(GLfloat *) RING_API_GETCPOINTER(3,"GLfloat"));
}
RING_FUNC(ring_glUniform3fv)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glUniform3fv( (GLint ) RING_API_GETNUMBER(1), (GLsizei ) (int) RING_API_GETNUMBER(2),(GLfloat *) RING_API_GETCPOINTER(3,"GLfloat"));
}
RING_FUNC(ring_glUniform4fv)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glUniform4fv( (GLint ) RING_API_GETNUMBER(1), (GLsizei ) (int) RING_API_GETNUMBER(2),(GLfloat *) RING_API_GETCPOINTER(3,"GLfloat"));
}
RING_FUNC(ring_glUniform1iv)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glUniform1iv( (GLint ) RING_API_GETNUMBER(1), (GLsizei ) (int) RING_API_GETNUMBER(2),(GLint *) RING_API_GETCPOINTER(3,"GLint"));
}
RING_FUNC(ring_glUniform2iv)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glUniform2iv( (GLint ) RING_API_GETNUMBER(1), (GLsizei ) (int) RING_API_GETNUMBER(2),(GLint *) RING_API_GETCPOINTER(3,"GLint"));
}
RING_FUNC(ring_glUniform3iv)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glUniform3iv( (GLint ) RING_API_GETNUMBER(1), (GLsizei ) (int) RING_API_GETNUMBER(2),(GLint *) RING_API_GETCPOINTER(3,"GLint"));
}
RING_FUNC(ring_glUniform4iv)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glUniform4iv( (GLint ) RING_API_GETNUMBER(1), (GLsizei ) (int) RING_API_GETNUMBER(2),(GLint *) RING_API_GETCPOINTER(3,"GLint"));
}
RING_FUNC(ring_glUniformMatrix2fv)
{
if ( RING_API_PARACOUNT != 4 ) {
RING_API_ERROR(RING_API_MISS4PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glUniformMatrix2fv( (GLint ) RING_API_GETNUMBER(1), (GLsizei ) (int) RING_API_GETNUMBER(2), (GLboolean ) RING_API_GETNUMBER(3),(GLfloat *) RING_API_GETCPOINTER(4,"GLfloat"));
}
RING_FUNC(ring_glUniformMatrix3fv)
{
if ( RING_API_PARACOUNT != 4 ) {
RING_API_ERROR(RING_API_MISS4PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glUniformMatrix3fv( (GLint ) RING_API_GETNUMBER(1), (GLsizei ) (int) RING_API_GETNUMBER(2), (GLboolean ) RING_API_GETNUMBER(3),(GLfloat *) RING_API_GETCPOINTER(4,"GLfloat"));
}
RING_FUNC(ring_glUniformMatrix4fv)
{
if ( RING_API_PARACOUNT != 4 ) {
RING_API_ERROR(RING_API_MISS4PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glUniformMatrix4fv( (GLint ) RING_API_GETNUMBER(1), (GLsizei ) (int) RING_API_GETNUMBER(2), (GLboolean ) RING_API_GETNUMBER(3),(GLfloat *) RING_API_GETCPOINTER(4,"GLfloat"));
}
RING_FUNC(ring_glUniformMatrix2x3fv)
{
if ( RING_API_PARACOUNT != 4 ) {
RING_API_ERROR(RING_API_MISS4PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glUniformMatrix2x3fv( (GLint ) RING_API_GETNUMBER(1), (GLsizei ) (int) RING_API_GETNUMBER(2), (GLboolean ) RING_API_GETNUMBER(3),(GLfloat *) RING_API_GETCPOINTER(4,"GLfloat"));
}
RING_FUNC(ring_glUniformMatrix3x2fv)
{
if ( RING_API_PARACOUNT != 4 ) {
RING_API_ERROR(RING_API_MISS4PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glUniformMatrix3x2fv( (GLint ) RING_API_GETNUMBER(1), (GLsizei ) (int) RING_API_GETNUMBER(2), (GLboolean ) RING_API_GETNUMBER(3),(GLfloat *) RING_API_GETCPOINTER(4,"GLfloat"));
}
RING_FUNC(ring_glUniformMatrix2x4fv)
{
if ( RING_API_PARACOUNT != 4 ) {
RING_API_ERROR(RING_API_MISS4PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glUniformMatrix2x4fv( (GLint ) RING_API_GETNUMBER(1), (GLsizei ) (int) RING_API_GETNUMBER(2), (GLboolean ) RING_API_GETNUMBER(3),(GLfloat *) RING_API_GETCPOINTER(4,"GLfloat"));
}
RING_FUNC(ring_glUniformMatrix4x2fv)
{
if ( RING_API_PARACOUNT != 4 ) {
RING_API_ERROR(RING_API_MISS4PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glUniformMatrix4x2fv( (GLint ) RING_API_GETNUMBER(1), (GLsizei ) (int) RING_API_GETNUMBER(2), (GLboolean ) RING_API_GETNUMBER(3),(GLfloat *) RING_API_GETCPOINTER(4,"GLfloat"));
}
RING_FUNC(ring_glUniformMatrix3x4fv)
{
if ( RING_API_PARACOUNT != 4 ) {
RING_API_ERROR(RING_API_MISS4PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glUniformMatrix3x4fv( (GLint ) RING_API_GETNUMBER(1), (GLsizei ) (int) RING_API_GETNUMBER(2), (GLboolean ) RING_API_GETNUMBER(3),(GLfloat *) RING_API_GETCPOINTER(4,"GLfloat"));
}
RING_FUNC(ring_glUniformMatrix4x3fv)
{
if ( RING_API_PARACOUNT != 4 ) {
RING_API_ERROR(RING_API_MISS4PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glUniformMatrix4x3fv( (GLint ) RING_API_GETNUMBER(1), (GLsizei ) (int) RING_API_GETNUMBER(2), (GLboolean ) RING_API_GETNUMBER(3),(GLfloat *) RING_API_GETCPOINTER(4,"GLfloat"));
}
RING_FUNC(ring_glUseProgram)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glUseProgram( (GLuint ) RING_API_GETNUMBER(1));
}
RING_FUNC(ring_glValidateProgram)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glValidateProgram( (GLuint ) RING_API_GETNUMBER(1));
}
RING_FUNC(ring_glVertex2s)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glVertex2s( (GLshort ) RING_API_GETNUMBER(1), (GLshort ) RING_API_GETNUMBER(2));
}
RING_FUNC(ring_glVertex2i)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glVertex2i( (GLint ) RING_API_GETNUMBER(1), (GLint ) RING_API_GETNUMBER(2));
}
RING_FUNC(ring_glVertex2f)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glVertex2f( (GLfloat ) RING_API_GETNUMBER(1), (GLfloat ) RING_API_GETNUMBER(2));
}
RING_FUNC(ring_glVertex2d)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glVertex2d( (GLdouble ) RING_API_GETNUMBER(1), (GLdouble ) RING_API_GETNUMBER(2));
}
RING_FUNC(ring_glVertex3s)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glVertex3s( (GLshort ) RING_API_GETNUMBER(1), (GLshort ) RING_API_GETNUMBER(2), (GLshort ) RING_API_GETNUMBER(3));
}
RING_FUNC(ring_glVertex3i)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glVertex3i( (GLint ) RING_API_GETNUMBER(1), (GLint ) RING_API_GETNUMBER(2), (GLint ) RING_API_GETNUMBER(3));
}
RING_FUNC(ring_glVertex3f)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glVertex3f( (GLfloat ) RING_API_GETNUMBER(1), (GLfloat ) RING_API_GETNUMBER(2), (GLfloat ) RING_API_GETNUMBER(3));
}
RING_FUNC(ring_glVertex3d)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glVertex3d( (GLdouble ) RING_API_GETNUMBER(1), (GLdouble ) RING_API_GETNUMBER(2), (GLdouble ) RING_API_GETNUMBER(3));
}
RING_FUNC(ring_glVertex4s)
{
if ( RING_API_PARACOUNT != 4 ) {
RING_API_ERROR(RING_API_MISS4PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glVertex4s( (GLshort ) RING_API_GETNUMBER(1), (GLshort ) RING_API_GETNUMBER(2), (GLshort ) RING_API_GETNUMBER(3), (GLshort ) RING_API_GETNUMBER(4));
}
RING_FUNC(ring_glVertex4i)
{
if ( RING_API_PARACOUNT != 4 ) {
RING_API_ERROR(RING_API_MISS4PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glVertex4i( (GLint ) RING_API_GETNUMBER(1), (GLint ) RING_API_GETNUMBER(2), (GLint ) RING_API_GETNUMBER(3), (GLint ) RING_API_GETNUMBER(4));
}
RING_FUNC(ring_glVertex4f)
{
if ( RING_API_PARACOUNT != 4 ) {
RING_API_ERROR(RING_API_MISS4PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glVertex4f( (GLfloat ) RING_API_GETNUMBER(1), (GLfloat ) RING_API_GETNUMBER(2), (GLfloat ) RING_API_GETNUMBER(3), (GLfloat ) RING_API_GETNUMBER(4));
}
RING_FUNC(ring_glVertex4d)
{
if ( RING_API_PARACOUNT != 4 ) {
RING_API_ERROR(RING_API_MISS4PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glVertex4d( (GLdouble ) RING_API_GETNUMBER(1), (GLdouble ) RING_API_GETNUMBER(2), (GLdouble ) RING_API_GETNUMBER(3), (GLdouble ) RING_API_GETNUMBER(4));
}
RING_FUNC(ring_glVertex2sv)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glVertex2sv((GLshort *) RING_API_GETCPOINTER(1,"GLshort"));
}
RING_FUNC(ring_glVertex2iv)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glVertex2iv((GLint *) RING_API_GETCPOINTER(1,"GLint"));
}
RING_FUNC(ring_glVertex2fv)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glVertex2fv((GLfloat *) RING_API_GETCPOINTER(1,"GLfloat"));
}
RING_FUNC(ring_glVertex2dv)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glVertex2dv((GLdouble *) RING_API_GETCPOINTER(1,"GLdouble"));
}
RING_FUNC(ring_glVertex3sv)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glVertex3sv((GLshort *) RING_API_GETCPOINTER(1,"GLshort"));
}
RING_FUNC(ring_glVertex3iv)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glVertex3iv((GLint *) RING_API_GETCPOINTER(1,"GLint"));
}
RING_FUNC(ring_glVertex3fv)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glVertex3fv((GLfloat *) RING_API_GETCPOINTER(1,"GLfloat"));
}
RING_FUNC(ring_glVertex3dv)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glVertex3dv((GLdouble *) RING_API_GETCPOINTER(1,"GLdouble"));
}
RING_FUNC(ring_glVertex4sv)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glVertex4sv((GLshort *) RING_API_GETCPOINTER(1,"GLshort"));
}
RING_FUNC(ring_glVertex4iv)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glVertex4iv((GLint *) RING_API_GETCPOINTER(1,"GLint"));
}
RING_FUNC(ring_glVertex4fv)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glVertex4fv((GLfloat *) RING_API_GETCPOINTER(1,"GLfloat"));
}
RING_FUNC(ring_glVertex4dv)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glVertex4dv((GLdouble *) RING_API_GETCPOINTER(1,"GLdouble"));
}
RING_FUNC(ring_glVertexAttrib1f)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glVertexAttrib1f( (GLuint ) RING_API_GETNUMBER(1), (GLfloat ) RING_API_GETNUMBER(2));
}
RING_FUNC(ring_glVertexAttrib1s)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glVertexAttrib1s( (GLuint ) RING_API_GETNUMBER(1), (GLshort ) RING_API_GETNUMBER(2));
}
RING_FUNC(ring_glVertexAttrib1d)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glVertexAttrib1d( (GLuint ) RING_API_GETNUMBER(1), (GLdouble ) RING_API_GETNUMBER(2));
}
RING_FUNC(ring_glVertexAttrib2f)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glVertexAttrib2f( (GLuint ) RING_API_GETNUMBER(1), (GLfloat ) RING_API_GETNUMBER(2), (GLfloat ) RING_API_GETNUMBER(3));
}
RING_FUNC(ring_glVertexAttrib2s)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glVertexAttrib2s( (GLuint ) RING_API_GETNUMBER(1), (GLshort ) RING_API_GETNUMBER(2), (GLshort ) RING_API_GETNUMBER(3));
}
RING_FUNC(ring_glVertexAttrib2d)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glVertexAttrib2d( (GLuint ) RING_API_GETNUMBER(1), (GLdouble ) RING_API_GETNUMBER(2), (GLdouble ) RING_API_GETNUMBER(3));
}
RING_FUNC(ring_glVertexAttrib3f)
{
if ( RING_API_PARACOUNT != 4 ) {
RING_API_ERROR(RING_API_MISS4PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glVertexAttrib3f( (GLuint ) RING_API_GETNUMBER(1), (GLfloat ) RING_API_GETNUMBER(2), (GLfloat ) RING_API_GETNUMBER(3), (GLfloat ) RING_API_GETNUMBER(4));
}
RING_FUNC(ring_glVertexAttrib3s)
{
if ( RING_API_PARACOUNT != 4 ) {
RING_API_ERROR(RING_API_MISS4PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glVertexAttrib3s( (GLuint ) RING_API_GETNUMBER(1), (GLshort ) RING_API_GETNUMBER(2), (GLshort ) RING_API_GETNUMBER(3), (GLshort ) RING_API_GETNUMBER(4));
}
RING_FUNC(ring_glVertexAttrib3d)
{
if ( RING_API_PARACOUNT != 4 ) {
RING_API_ERROR(RING_API_MISS4PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glVertexAttrib3d( (GLuint ) RING_API_GETNUMBER(1), (GLdouble ) RING_API_GETNUMBER(2), (GLdouble ) RING_API_GETNUMBER(3), (GLdouble ) RING_API_GETNUMBER(4));
}
RING_FUNC(ring_glVertexAttrib4f)
{
if ( RING_API_PARACOUNT != 5 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(5) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glVertexAttrib4f( (GLuint ) RING_API_GETNUMBER(1), (GLfloat ) RING_API_GETNUMBER(2), (GLfloat ) RING_API_GETNUMBER(3), (GLfloat ) RING_API_GETNUMBER(4), (GLfloat ) RING_API_GETNUMBER(5));
}
RING_FUNC(ring_glVertexAttrib4s)
{
if ( RING_API_PARACOUNT != 5 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(5) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glVertexAttrib4s( (GLuint ) RING_API_GETNUMBER(1), (GLshort ) RING_API_GETNUMBER(2), (GLshort ) RING_API_GETNUMBER(3), (GLshort ) RING_API_GETNUMBER(4), (GLshort ) RING_API_GETNUMBER(5));
}
RING_FUNC(ring_glVertexAttrib4d)
{
if ( RING_API_PARACOUNT != 5 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(5) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glVertexAttrib4d( (GLuint ) RING_API_GETNUMBER(1), (GLdouble ) RING_API_GETNUMBER(2), (GLdouble ) RING_API_GETNUMBER(3), (GLdouble ) RING_API_GETNUMBER(4), (GLdouble ) RING_API_GETNUMBER(5));
}
RING_FUNC(ring_glVertexAttrib4Nub)
{
if ( RING_API_PARACOUNT != 5 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(5) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glVertexAttrib4Nub( (GLuint ) RING_API_GETNUMBER(1), (GLubyte ) RING_API_GETNUMBER(2), (GLubyte ) RING_API_GETNUMBER(3), (GLubyte ) RING_API_GETNUMBER(4), (GLubyte ) RING_API_GETNUMBER(5));
}
RING_FUNC(ring_glVertexAttrib1fv)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glVertexAttrib1fv( (GLuint ) RING_API_GETNUMBER(1),(GLfloat *) RING_API_GETCPOINTER(2,"GLfloat"));
}
RING_FUNC(ring_glVertexAttrib1sv)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glVertexAttrib1sv( (GLuint ) RING_API_GETNUMBER(1),(GLshort *) RING_API_GETCPOINTER(2,"GLshort"));
}
RING_FUNC(ring_glVertexAttrib1dv)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glVertexAttrib1dv( (GLuint ) RING_API_GETNUMBER(1),(GLdouble *) RING_API_GETCPOINTER(2,"GLdouble"));
}
RING_FUNC(ring_glVertexAttrib2fv)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glVertexAttrib2fv( (GLuint ) RING_API_GETNUMBER(1),(GLfloat *) RING_API_GETCPOINTER(2,"GLfloat"));
}
RING_FUNC(ring_glVertexAttrib2sv)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glVertexAttrib2sv( (GLuint ) RING_API_GETNUMBER(1),(GLshort *) RING_API_GETCPOINTER(2,"GLshort"));
}
RING_FUNC(ring_glVertexAttrib2dv)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glVertexAttrib2dv( (GLuint ) RING_API_GETNUMBER(1),(GLdouble *) RING_API_GETCPOINTER(2,"GLdouble"));
}
RING_FUNC(ring_glVertexAttrib3fv)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glVertexAttrib3fv( (GLuint ) RING_API_GETNUMBER(1),(GLfloat *) RING_API_GETCPOINTER(2,"GLfloat"));
}
RING_FUNC(ring_glVertexAttrib3sv)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glVertexAttrib3sv( (GLuint ) RING_API_GETNUMBER(1),(GLshort *) RING_API_GETCPOINTER(2,"GLshort"));
}
RING_FUNC(ring_glVertexAttrib3dv)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glVertexAttrib3dv( (GLuint ) RING_API_GETNUMBER(1),(GLdouble *) RING_API_GETCPOINTER(2,"GLdouble"));
}
RING_FUNC(ring_glVertexAttrib4fv)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glVertexAttrib4fv( (GLuint ) RING_API_GETNUMBER(1),(GLfloat *) RING_API_GETCPOINTER(2,"GLfloat"));
}
RING_FUNC(ring_glVertexAttrib4sv)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glVertexAttrib4sv( (GLuint ) RING_API_GETNUMBER(1),(GLshort *) RING_API_GETCPOINTER(2,"GLshort"));
}
RING_FUNC(ring_glVertexAttrib4dv)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glVertexAttrib4dv( (GLuint ) RING_API_GETNUMBER(1),(GLdouble *) RING_API_GETCPOINTER(2,"GLdouble"));
}
RING_FUNC(ring_glVertexAttrib4iv)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glVertexAttrib4iv( (GLuint ) RING_API_GETNUMBER(1),(GLint *) RING_API_GETCPOINTER(2,"GLint"));
}
RING_FUNC(ring_glVertexAttrib4bv)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glVertexAttrib4bv( (GLuint ) RING_API_GETNUMBER(1),(GLbyte *) RING_API_GETCPOINTER(2,"GLbyte"));
}
RING_FUNC(ring_glVertexAttrib4ubv)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glVertexAttrib4ubv( (GLuint ) RING_API_GETNUMBER(1),(GLubyte *) RING_API_GETCPOINTER(2,"GLubyte"));
}
RING_FUNC(ring_glVertexAttrib4usv)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glVertexAttrib4usv( (GLuint ) RING_API_GETNUMBER(1),(GLushort *) RING_API_GETCPOINTER(2,"GLushort"));
}
RING_FUNC(ring_glVertexAttrib4uiv)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glVertexAttrib4uiv( (GLuint ) RING_API_GETNUMBER(1),(GLuint *) RING_API_GETCPOINTER(2,"GLuint"));
}
RING_FUNC(ring_glVertexAttribPointer)
{
if ( RING_API_PARACOUNT != 6 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(5) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(6) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glVertexAttribPointer( (GLuint ) RING_API_GETNUMBER(1), (GLint ) RING_API_GETNUMBER(2), (GLenum ) (int) RING_API_GETNUMBER(3), (GLboolean ) RING_API_GETNUMBER(4), (GLsizei ) (int) RING_API_GETNUMBER(5),(GLvoid *) RING_API_GETCPOINTER(6,"GLvoid"));
}
RING_FUNC(ring_glVertexPointer)
{
if ( RING_API_PARACOUNT != 4 ) {
RING_API_ERROR(RING_API_MISS4PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glVertexPointer( (GLint ) RING_API_GETNUMBER(1), (GLenum ) (int) RING_API_GETNUMBER(2), (GLsizei ) (int) RING_API_GETNUMBER(3),(GLvoid *) RING_API_GETCPOINTER(4,"GLvoid"));
}
RING_FUNC(ring_glViewport)
{
if ( RING_API_PARACOUNT != 4 ) {
RING_API_ERROR(RING_API_MISS4PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glViewport( (GLint ) RING_API_GETNUMBER(1), (GLint ) RING_API_GETNUMBER(2), (GLsizei ) (int) RING_API_GETNUMBER(3), (GLsizei ) (int) RING_API_GETNUMBER(4));
}
RING_FUNC(ring_glWindowPos2s)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glWindowPos2s( (GLshort ) RING_API_GETNUMBER(1), (GLshort ) RING_API_GETNUMBER(2));
}
RING_FUNC(ring_glWindowPos2i)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glWindowPos2i( (GLint ) RING_API_GETNUMBER(1), (GLint ) RING_API_GETNUMBER(2));
}
RING_FUNC(ring_glWindowPos2f)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glWindowPos2f( (GLfloat ) RING_API_GETNUMBER(1), (GLfloat ) RING_API_GETNUMBER(2));
}
RING_FUNC(ring_glWindowPos2d)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glWindowPos2d( (GLdouble ) RING_API_GETNUMBER(1), (GLdouble ) RING_API_GETNUMBER(2));
}
RING_FUNC(ring_glWindowPos3s)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glWindowPos3s( (GLshort ) RING_API_GETNUMBER(1), (GLshort ) RING_API_GETNUMBER(2), (GLshort ) RING_API_GETNUMBER(3));
}
RING_FUNC(ring_glWindowPos3i)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glWindowPos3i( (GLint ) RING_API_GETNUMBER(1), (GLint ) RING_API_GETNUMBER(2), (GLint ) RING_API_GETNUMBER(3));
}
RING_FUNC(ring_glWindowPos3f)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glWindowPos3f( (GLfloat ) RING_API_GETNUMBER(1), (GLfloat ) RING_API_GETNUMBER(2), (GLfloat ) RING_API_GETNUMBER(3));
}
RING_FUNC(ring_glWindowPos3d)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glWindowPos3d( (GLdouble ) RING_API_GETNUMBER(1), (GLdouble ) RING_API_GETNUMBER(2), (GLdouble ) RING_API_GETNUMBER(3));
}
RING_FUNC(ring_glWindowPos2sv)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glWindowPos2sv((GLshort *) RING_API_GETCPOINTER(1,"GLshort"));
}
RING_FUNC(ring_glWindowPos2iv)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glWindowPos2iv((GLint *) RING_API_GETCPOINTER(1,"GLint"));
}
RING_FUNC(ring_glWindowPos2fv)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glWindowPos2fv((GLfloat *) RING_API_GETCPOINTER(1,"GLfloat"));
}
RING_FUNC(ring_glWindowPos2dv)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glWindowPos2dv((GLdouble *) RING_API_GETCPOINTER(1,"GLdouble"));
}
RING_FUNC(ring_glWindowPos3sv)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glWindowPos3sv((GLshort *) RING_API_GETCPOINTER(1,"GLshort"));
}
RING_FUNC(ring_glWindowPos3iv)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glWindowPos3iv((GLint *) RING_API_GETCPOINTER(1,"GLint"));
}
RING_FUNC(ring_glWindowPos3fv)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glWindowPos3fv((GLfloat *) RING_API_GETCPOINTER(1,"GLfloat"));
}
RING_FUNC(ring_glWindowPos3dv)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glWindowPos3dv((GLdouble *) RING_API_GETCPOINTER(1,"GLdouble"));
}
RING_FUNC(ring_gluBeginCurve)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
gluBeginCurve((GLUnurbs *) RING_API_GETCPOINTER(1,"GLUnurbs"));
}
RING_FUNC(ring_gluBeginPolygon)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
gluBeginPolygon((GLUtesselator *) RING_API_GETCPOINTER(1,"GLUtesselator"));
}
RING_FUNC(ring_gluBeginSurface)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
gluBeginSurface((GLUnurbs *) RING_API_GETCPOINTER(1,"GLUnurbs"));
}
RING_FUNC(ring_gluBeginTrim)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
gluBeginTrim((GLUnurbs *) RING_API_GETCPOINTER(1,"GLUnurbs"));
}
RING_FUNC(ring_gluCylinder)
{
if ( RING_API_PARACOUNT != 6 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(5) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(6) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
gluCylinder((GLUquadric *) RING_API_GETCPOINTER(1,"GLUquadric"), (GLdouble ) RING_API_GETNUMBER(2), (GLdouble ) RING_API_GETNUMBER(3), (GLdouble ) RING_API_GETNUMBER(4), (GLint ) RING_API_GETNUMBER(5), (GLint ) RING_API_GETNUMBER(6));
}
RING_FUNC(ring_gluDeleteNurbsRenderer)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
gluDeleteNurbsRenderer((GLUnurbs *) RING_API_GETCPOINTER(1,"GLUnurbs"));
}
RING_FUNC(ring_gluDeleteQuadric)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
gluDeleteQuadric((GLUquadric *) RING_API_GETCPOINTER(1,"GLUquadric"));
}
RING_FUNC(ring_gluDeleteTess)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
gluDeleteTess((GLUtesselator *) RING_API_GETCPOINTER(1,"GLUtesselator"));
}
RING_FUNC(ring_gluDisk)
{
if ( RING_API_PARACOUNT != 5 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(5) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
gluDisk((GLUquadric *) RING_API_GETCPOINTER(1,"GLUquadric"), (GLdouble ) RING_API_GETNUMBER(2), (GLdouble ) RING_API_GETNUMBER(3), (GLint ) RING_API_GETNUMBER(4), (GLint ) RING_API_GETNUMBER(5));
}
RING_FUNC(ring_gluEndCurve)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
gluEndCurve((GLUnurbs *) RING_API_GETCPOINTER(1,"GLUnurbs"));
}
RING_FUNC(ring_gluEndPolygon)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
gluEndPolygon((GLUtesselator *) RING_API_GETCPOINTER(1,"GLUtesselator"));
}
RING_FUNC(ring_gluEndSurface)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
gluEndSurface((GLUnurbs *) RING_API_GETCPOINTER(1,"GLUnurbs"));
}
RING_FUNC(ring_gluEndTrim)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
gluEndTrim((GLUnurbs *) RING_API_GETCPOINTER(1,"GLUnurbs"));
}
RING_FUNC(ring_gluErrorString)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETCPOINTER(gluErrorString( (GLenum ) (int) RING_API_GETNUMBER(1)),"GLubyte");
}
RING_FUNC(ring_gluGetNurbsProperty)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
gluGetNurbsProperty((GLUnurbs *) RING_API_GETCPOINTER(1,"GLUnurbs"), (GLenum ) (int) RING_API_GETNUMBER(2),(GLfloat *) RING_API_GETCPOINTER(3,"GLfloat"));
}
RING_FUNC(ring_gluGetString)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETCPOINTER(gluGetString( (GLenum ) (int) RING_API_GETNUMBER(1)),"GLubyte");
}
RING_FUNC(ring_gluGetTessProperty)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
gluGetTessProperty((GLUtesselator *) RING_API_GETCPOINTER(1,"GLUtesselator"), (GLenum ) (int) RING_API_GETNUMBER(2),(GLdouble *) RING_API_GETCPOINTER(3,"GLdouble"));
}
RING_FUNC(ring_gluLoadSamplingMatrices)
{
if ( RING_API_PARACOUNT != 4 ) {
RING_API_ERROR(RING_API_MISS4PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
gluLoadSamplingMatrices((GLUnurbs *) RING_API_GETCPOINTER(1,"GLUnurbs"),(GLfloat *) RING_API_GETCPOINTER(2,"GLfloat"),(GLfloat *) RING_API_GETCPOINTER(3,"GLfloat"),(GLint *) RING_API_GETCPOINTER(4,"GLint"));
}
RING_FUNC(ring_gluLookAt)
{
if ( RING_API_PARACOUNT != 9 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(5) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(6) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(7) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(8) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(9) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
gluLookAt( (GLdouble ) RING_API_GETNUMBER(1), (GLdouble ) RING_API_GETNUMBER(2), (GLdouble ) RING_API_GETNUMBER(3), (GLdouble ) RING_API_GETNUMBER(4), (GLdouble ) RING_API_GETNUMBER(5), (GLdouble ) RING_API_GETNUMBER(6), (GLdouble ) RING_API_GETNUMBER(7), (GLdouble ) RING_API_GETNUMBER(8), (GLdouble ) RING_API_GETNUMBER(9));
}
RING_FUNC(ring_gluNewNurbsRenderer)
{
if ( RING_API_PARACOUNT != 0 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
RING_API_RETCPOINTER(gluNewNurbsRenderer(),"GLUnurbs");
}
RING_FUNC(ring_gluNewQuadric)
{
if ( RING_API_PARACOUNT != 0 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
RING_API_RETCPOINTER(gluNewQuadric(),"GLUquadric");
}
RING_FUNC(ring_gluNewTess)
{
if ( RING_API_PARACOUNT != 0 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
RING_API_RETCPOINTER(gluNewTess(),"GLUtesselator");
}
RING_FUNC(ring_gluNextContour)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
gluNextContour((GLUtesselator *) RING_API_GETCPOINTER(1,"GLUtesselator"), (GLenum ) (int) RING_API_GETNUMBER(2));
}
RING_FUNC(ring_gluNurbsCurve)
{
if ( RING_API_PARACOUNT != 7 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(5) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(6) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(7) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
gluNurbsCurve((GLUnurbs *) RING_API_GETCPOINTER(1,"GLUnurbs"), (GLint ) RING_API_GETNUMBER(2),(GLfloat *) RING_API_GETCPOINTER(3,"GLfloat"), (GLint ) RING_API_GETNUMBER(4),(GLfloat *) RING_API_GETCPOINTER(5,"GLfloat"), (GLint ) RING_API_GETNUMBER(6), (GLenum ) (int) RING_API_GETNUMBER(7));
}
RING_FUNC(ring_gluNurbsProperty)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
gluNurbsProperty((GLUnurbs *) RING_API_GETCPOINTER(1,"GLUnurbs"), (GLenum ) (int) RING_API_GETNUMBER(2), (GLfloat ) RING_API_GETNUMBER(3));
}
RING_FUNC(ring_gluNurbsSurface)
{
if ( RING_API_PARACOUNT != 11 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(5) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(6) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(7) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(8) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(9) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(10) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(11) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
gluNurbsSurface((GLUnurbs *) RING_API_GETCPOINTER(1,"GLUnurbs"), (GLint ) RING_API_GETNUMBER(2),(GLfloat *) RING_API_GETCPOINTER(3,"GLfloat"), (GLint ) RING_API_GETNUMBER(4),(GLfloat *) RING_API_GETCPOINTER(5,"GLfloat"), (GLint ) RING_API_GETNUMBER(6), (GLint ) RING_API_GETNUMBER(7),(GLfloat *) RING_API_GETCPOINTER(8,"GLfloat"), (GLint ) RING_API_GETNUMBER(9), (GLint ) RING_API_GETNUMBER(10), (GLenum ) (int) RING_API_GETNUMBER(11));
}
RING_FUNC(ring_gluOrtho2D)
{
if ( RING_API_PARACOUNT != 4 ) {
RING_API_ERROR(RING_API_MISS4PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
gluOrtho2D( (GLdouble ) RING_API_GETNUMBER(1), (GLdouble ) RING_API_GETNUMBER(2), (GLdouble ) RING_API_GETNUMBER(3), (GLdouble ) RING_API_GETNUMBER(4));
}
RING_FUNC(ring_gluPartialDisk)
{
if ( RING_API_PARACOUNT != 7 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(5) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(6) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(7) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
gluPartialDisk((GLUquadric *) RING_API_GETCPOINTER(1,"GLUquadric"), (GLdouble ) RING_API_GETNUMBER(2), (GLdouble ) RING_API_GETNUMBER(3), (GLint ) RING_API_GETNUMBER(4), (GLint ) RING_API_GETNUMBER(5), (GLdouble ) RING_API_GETNUMBER(6), (GLdouble ) RING_API_GETNUMBER(7));
}
RING_FUNC(ring_gluPerspective)
{
if ( RING_API_PARACOUNT != 4 ) {
RING_API_ERROR(RING_API_MISS4PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
gluPerspective( (GLdouble ) RING_API_GETNUMBER(1), (GLdouble ) RING_API_GETNUMBER(2), (GLdouble ) RING_API_GETNUMBER(3), (GLdouble ) RING_API_GETNUMBER(4));
}
RING_FUNC(ring_gluPickMatrix)
{
if ( RING_API_PARACOUNT != 5 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(5) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
gluPickMatrix( (GLdouble ) RING_API_GETNUMBER(1), (GLdouble ) RING_API_GETNUMBER(2), (GLdouble ) RING_API_GETNUMBER(3), (GLdouble ) RING_API_GETNUMBER(4),(GLint *) RING_API_GETCPOINTER(5,"GLint"));
}
RING_FUNC(ring_gluProject)
{
if ( RING_API_PARACOUNT != 9 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(5) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(6) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(7) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(8) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(9) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETNUMBER(gluProject( (GLdouble ) RING_API_GETNUMBER(1), (GLdouble ) RING_API_GETNUMBER(2), (GLdouble ) RING_API_GETNUMBER(3),(GLdouble *) RING_API_GETCPOINTER(4,"GLdouble"),(GLdouble *) RING_API_GETCPOINTER(5,"GLdouble"),(GLint *) RING_API_GETCPOINTER(6,"GLint"),(GLdouble *) RING_API_GETCPOINTER(7,"GLdouble"),(GLdouble *) RING_API_GETCPOINTER(8,"GLdouble"),(GLdouble *) RING_API_GETCPOINTER(9,"GLdouble")));
}
RING_FUNC(ring_gluPwlCurve)
{
if ( RING_API_PARACOUNT != 5 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(5) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
gluPwlCurve((GLUnurbs *) RING_API_GETCPOINTER(1,"GLUnurbs"), (GLint ) RING_API_GETNUMBER(2),(GLfloat *) RING_API_GETCPOINTER(3,"GLfloat"), (GLint ) RING_API_GETNUMBER(4), (GLenum ) (int) RING_API_GETNUMBER(5));
}
RING_FUNC(ring_gluQuadricDrawStyle)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
gluQuadricDrawStyle((GLUquadric *) RING_API_GETCPOINTER(1,"GLUquadric"), (GLenum ) (int) RING_API_GETNUMBER(2));
}
RING_FUNC(ring_gluQuadricNormals)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
gluQuadricNormals((GLUquadric *) RING_API_GETCPOINTER(1,"GLUquadric"), (GLenum ) (int) RING_API_GETNUMBER(2));
}
RING_FUNC(ring_gluQuadricOrientation)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
gluQuadricOrientation((GLUquadric *) RING_API_GETCPOINTER(1,"GLUquadric"), (GLenum ) (int) RING_API_GETNUMBER(2));
}
RING_FUNC(ring_gluQuadricTexture)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
gluQuadricTexture((GLUquadric *) RING_API_GETCPOINTER(1,"GLUquadric"), (GLboolean ) RING_API_GETNUMBER(2));
}
RING_FUNC(ring_gluScaleImage)
{
if ( RING_API_PARACOUNT != 9 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(5) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(6) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(7) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(8) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(9) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETNUMBER(gluScaleImage( (GLenum ) (int) RING_API_GETNUMBER(1), (GLsizei ) (int) RING_API_GETNUMBER(2), (GLsizei ) (int) RING_API_GETNUMBER(3), (GLenum ) (int) RING_API_GETNUMBER(4),(void *) RING_API_GETCPOINTER(5,"void"), (GLsizei ) (int) RING_API_GETNUMBER(6), (GLsizei ) (int) RING_API_GETNUMBER(7), (GLenum ) (int) RING_API_GETNUMBER(8),(GLvoid *) RING_API_GETCPOINTER(9,"GLvoid")));
}
RING_FUNC(ring_gluSphere)
{
if ( RING_API_PARACOUNT != 4 ) {
RING_API_ERROR(RING_API_MISS4PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
gluSphere((GLUquadric *) RING_API_GETCPOINTER(1,"GLUquadric"), (GLdouble ) RING_API_GETNUMBER(2), (GLint ) RING_API_GETNUMBER(3), (GLint ) RING_API_GETNUMBER(4));
}
RING_FUNC(ring_gluTessBeginContour)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
gluTessBeginContour((GLUtesselator *) RING_API_GETCPOINTER(1,"GLUtesselator"));
}
RING_FUNC(ring_gluTessBeginPolygon)
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
gluTessBeginPolygon((GLUtesselator *) RING_API_GETCPOINTER(1,"GLUtesselator"),(GLvoid *) RING_API_GETCPOINTER(2,"GLvoid"));
}
RING_FUNC(ring_gluTessEndContour)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
gluTessEndContour((GLUtesselator *) RING_API_GETCPOINTER(1,"GLUtesselator"));
}
RING_FUNC(ring_gluTessEndPolygon)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
gluTessEndPolygon((GLUtesselator *) RING_API_GETCPOINTER(1,"GLUtesselator"));
}
RING_FUNC(ring_gluTessNormal)
{
if ( RING_API_PARACOUNT != 4 ) {
RING_API_ERROR(RING_API_MISS4PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
gluTessNormal((GLUtesselator *) RING_API_GETCPOINTER(1,"GLUtesselator"), (GLdouble ) RING_API_GETNUMBER(2), (GLdouble ) RING_API_GETNUMBER(3), (GLdouble ) RING_API_GETNUMBER(4));
}
RING_FUNC(ring_gluTessProperty)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
gluTessProperty((GLUtesselator *) RING_API_GETCPOINTER(1,"GLUtesselator"), (GLenum ) (int) RING_API_GETNUMBER(2), (GLdouble ) RING_API_GETNUMBER(3));
}
RING_FUNC(ring_gluTessVertex)
{
if ( RING_API_PARACOUNT != 3 ) {
RING_API_ERROR(RING_API_MISS3PARA);
return ;
}
if ( ! RING_API_ISPOINTER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
gluTessVertex((GLUtesselator *) RING_API_GETCPOINTER(1,"GLUtesselator"),(GLdouble *) RING_API_GETCPOINTER(2,"GLdouble"),(GLvoid *) RING_API_GETCPOINTER(3,"GLvoid"));
}
RING_FUNC(ring_gluUnProject)
{
if ( RING_API_PARACOUNT != 9 ) {
RING_API_ERROR(RING_API_BADPARACOUNT);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(2) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISNUMBER(3) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(4) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(5) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(6) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(7) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(8) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( ! RING_API_ISPOINTER(9) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
RING_API_RETNUMBER(gluUnProject( (GLdouble ) RING_API_GETNUMBER(1), (GLdouble ) RING_API_GETNUMBER(2), (GLdouble ) RING_API_GETNUMBER(3),(GLdouble *) RING_API_GETCPOINTER(4,"GLdouble"),(GLdouble *) RING_API_GETCPOINTER(5,"GLdouble"),(GLint *) RING_API_GETCPOINTER(6,"GLint"),(GLdouble *) RING_API_GETCPOINTER(7,"GLdouble"),(GLdouble *) RING_API_GETCPOINTER(8,"GLdouble"),(GLdouble *) RING_API_GETCPOINTER(9,"GLdouble")));
}
RING_FUNC(ring_glDisable)
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( ! RING_API_ISNUMBER(1) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
glDisable( (GLenum ) (int) RING_API_GETNUMBER(1));
}
RING_API void ringlib_init(RingState *pRingState)
{
ring_vm_funcregister("glaccum",ring_glAccum);
ring_vm_funcregister("glactivetexture",ring_glActiveTexture);
ring_vm_funcregister("glalphafunc",ring_glAlphaFunc);
ring_vm_funcregister("glaretexturesresident",ring_glAreTexturesResident);
ring_vm_funcregister("glarrayelement",ring_glArrayElement);
ring_vm_funcregister("glattachshader",ring_glAttachShader);
ring_vm_funcregister("glbegin",ring_glBegin);
ring_vm_funcregister("glbeginquery",ring_glBeginQuery);
ring_vm_funcregister("glbindattriblocation",ring_glBindAttribLocation);
ring_vm_funcregister("glbindbuffer",ring_glBindBuffer);
ring_vm_funcregister("glbindtexture",ring_glBindTexture);
ring_vm_funcregister("glbitmap",ring_glBitmap);
ring_vm_funcregister("glblendcolor",ring_glBlendColor);
ring_vm_funcregister("glblendequation",ring_glBlendEquation);
ring_vm_funcregister("glblendequationseparate",ring_glBlendEquationSeparate);
ring_vm_funcregister("glblendfunc",ring_glBlendFunc);
ring_vm_funcregister("glblendfuncseparate",ring_glBlendFuncSeparate);
ring_vm_funcregister("glbufferdata",ring_glBufferData);
ring_vm_funcregister("glbuffersubdata",ring_glBufferSubData);
ring_vm_funcregister("glcalllist",ring_glCallList);
ring_vm_funcregister("glcalllists",ring_glCallLists);
ring_vm_funcregister("glclear",ring_glClear);
ring_vm_funcregister("glclearaccum",ring_glClearAccum);
ring_vm_funcregister("glclearcolor",ring_glClearColor);
ring_vm_funcregister("glcleardepth",ring_glClearDepth);
ring_vm_funcregister("glclearindex",ring_glClearIndex);
ring_vm_funcregister("glclearstencil",ring_glClearStencil);
ring_vm_funcregister("glclientactivetexture",ring_glClientActiveTexture);
ring_vm_funcregister("glclipplane",ring_glClipPlane);
ring_vm_funcregister("glcolor3b",ring_glColor3b);
ring_vm_funcregister("glcolor3s",ring_glColor3s);
ring_vm_funcregister("glcolor3i",ring_glColor3i);
ring_vm_funcregister("glcolor3f",ring_glColor3f);
ring_vm_funcregister("glcolor3d",ring_glColor3d);
ring_vm_funcregister("glcolor3ub",ring_glColor3ub);
ring_vm_funcregister("glcolor3us",ring_glColor3us);
ring_vm_funcregister("glcolor3ui",ring_glColor3ui);
ring_vm_funcregister("glcolor4b",ring_glColor4b);
ring_vm_funcregister("glcolor4s",ring_glColor4s);
ring_vm_funcregister("glcolor4i",ring_glColor4i);
ring_vm_funcregister("glcolor4f",ring_glColor4f);
ring_vm_funcregister("glcolor4d",ring_glColor4d);
ring_vm_funcregister("glcolor4ub",ring_glColor4ub);
ring_vm_funcregister("glcolor4us",ring_glColor4us);
ring_vm_funcregister("glcolor4ui",ring_glColor4ui);
ring_vm_funcregister("glcolor3bv",ring_glColor3bv);
ring_vm_funcregister("glcolor3sv",ring_glColor3sv);
ring_vm_funcregister("glcolor3iv",ring_glColor3iv);
ring_vm_funcregister("glcolor3fv",ring_glColor3fv);
ring_vm_funcregister("glcolor3dv",ring_glColor3dv);
ring_vm_funcregister("glcolor3ubv",ring_glColor3ubv);
ring_vm_funcregister("glcolor3usv",ring_glColor3usv);
ring_vm_funcregister("glcolor3uiv",ring_glColor3uiv);
ring_vm_funcregister("glcolor4bv",ring_glColor4bv);
ring_vm_funcregister("glcolor4sv",ring_glColor4sv);
ring_vm_funcregister("glcolor4iv",ring_glColor4iv);
ring_vm_funcregister("glcolor4fv",ring_glColor4fv);
ring_vm_funcregister("glcolor4dv",ring_glColor4dv);
ring_vm_funcregister("glcolor4ubv",ring_glColor4ubv);
ring_vm_funcregister("glcolor4usv",ring_glColor4usv);
ring_vm_funcregister("glcolor4uiv",ring_glColor4uiv);
ring_vm_funcregister("glcolormask",ring_glColorMask);
ring_vm_funcregister("glcolormaterial",ring_glColorMaterial);
ring_vm_funcregister("glcolorpointer",ring_glColorPointer);
ring_vm_funcregister("glcolorsubtable",ring_glColorSubTable);
ring_vm_funcregister("glcolortable",ring_glColorTable);
ring_vm_funcregister("glcolortableparameterfv",ring_glColorTableParameterfv);
ring_vm_funcregister("glcolortableparameteriv",ring_glColorTableParameteriv);
ring_vm_funcregister("glcompileshader",ring_glCompileShader);
ring_vm_funcregister("glcompressedteximage1d",ring_glCompressedTexImage1D);
ring_vm_funcregister("glcompressedteximage2d",ring_glCompressedTexImage2D);
ring_vm_funcregister("glcompressedteximage3d",ring_glCompressedTexImage3D);
ring_vm_funcregister("glcompressedtexsubimage1d",ring_glCompressedTexSubImage1D);
ring_vm_funcregister("glcompressedtexsubimage2d",ring_glCompressedTexSubImage2D);
ring_vm_funcregister("glcompressedtexsubimage3d",ring_glCompressedTexSubImage3D);
ring_vm_funcregister("glconvolutionfilter1d",ring_glConvolutionFilter1D);
ring_vm_funcregister("glconvolutionfilter2d",ring_glConvolutionFilter2D);
ring_vm_funcregister("glconvolutionparameterf",ring_glConvolutionParameterf);
ring_vm_funcregister("glconvolutionparameteri",ring_glConvolutionParameteri);
ring_vm_funcregister("glconvolutionparameterfv",ring_glConvolutionParameterfv);
ring_vm_funcregister("glconvolutionparameteriv",ring_glConvolutionParameteriv);
ring_vm_funcregister("glcopycolorsubtable",ring_glCopyColorSubTable);
ring_vm_funcregister("glcopycolortable",ring_glCopyColorTable);
ring_vm_funcregister("glcopyconvolutionfilter1d",ring_glCopyConvolutionFilter1D);
ring_vm_funcregister("glcopyconvolutionfilter2d",ring_glCopyConvolutionFilter2D);
ring_vm_funcregister("glcopypixels",ring_glCopyPixels);
ring_vm_funcregister("glcopyteximage1d",ring_glCopyTexImage1D);
ring_vm_funcregister("glcopyteximage2d",ring_glCopyTexImage2D);
ring_vm_funcregister("glcopytexsubimage1d",ring_glCopyTexSubImage1D);
ring_vm_funcregister("glcopytexsubimage2d",ring_glCopyTexSubImage2D);
ring_vm_funcregister("glcopytexsubimage3d",ring_glCopyTexSubImage3D);
ring_vm_funcregister("glcreateprogram",ring_glCreateProgram);
ring_vm_funcregister("glcreateshader",ring_glCreateShader);
ring_vm_funcregister("glcullface",ring_glCullFace);
ring_vm_funcregister("gldeletebuffers",ring_glDeleteBuffers);
ring_vm_funcregister("gldeletelists",ring_glDeleteLists);
ring_vm_funcregister("gldeleteprogram",ring_glDeleteProgram);
ring_vm_funcregister("gldeletequeries",ring_glDeleteQueries);
ring_vm_funcregister("gldeleteshader",ring_glDeleteShader);
ring_vm_funcregister("gldeletetextures",ring_glDeleteTextures);
ring_vm_funcregister("gldepthfunc",ring_glDepthFunc);
ring_vm_funcregister("gldepthmask",ring_glDepthMask);
ring_vm_funcregister("gldepthrange",ring_glDepthRange);
ring_vm_funcregister("gldetachshader",ring_glDetachShader);
ring_vm_funcregister("glenable",ring_glEnable);
ring_vm_funcregister("glenableclientstate",ring_glEnableClientState);
ring_vm_funcregister("glenablevertexattribarray",ring_glEnableVertexAttribArray);
ring_vm_funcregister("gldisablevertexattribarray",ring_glDisableVertexAttribArray);
ring_vm_funcregister("gldrawarrays",ring_glDrawArrays);
ring_vm_funcregister("gldrawbuffer",ring_glDrawBuffer);
ring_vm_funcregister("gldrawbuffers",ring_glDrawBuffers);
ring_vm_funcregister("gldrawelements",ring_glDrawElements);
ring_vm_funcregister("gldrawpixels",ring_glDrawPixels);
ring_vm_funcregister("gldrawrangeelements",ring_glDrawRangeElements);
ring_vm_funcregister("gledgeflag",ring_glEdgeFlag);
ring_vm_funcregister("gledgeflagpointer",ring_glEdgeFlagPointer);
ring_vm_funcregister("glend",ring_glEnd);
ring_vm_funcregister("glendlist",ring_glEndList);
ring_vm_funcregister("glendquery",ring_glEndQuery);
ring_vm_funcregister("glevalcoord1f",ring_glEvalCoord1f);
ring_vm_funcregister("glevalcoord1d",ring_glEvalCoord1d);
ring_vm_funcregister("glevalcoord2f",ring_glEvalCoord2f);
ring_vm_funcregister("glevalcoord2d",ring_glEvalCoord2d);
ring_vm_funcregister("glevalmesh1",ring_glEvalMesh1);
ring_vm_funcregister("glevalpoint1",ring_glEvalPoint1);
ring_vm_funcregister("glevalpoint2",ring_glEvalPoint2);
ring_vm_funcregister("glfeedbackbuffer",ring_glFeedbackBuffer);
ring_vm_funcregister("glfinish",ring_glFinish);
ring_vm_funcregister("glflush",ring_glFlush);
ring_vm_funcregister("glfogf",ring_glFogf);
ring_vm_funcregister("glfogi",ring_glFogi);
ring_vm_funcregister("glfogfv",ring_glFogfv);
ring_vm_funcregister("glfogiv",ring_glFogiv);
ring_vm_funcregister("glfogcoordd",ring_glFogCoordd);
ring_vm_funcregister("glfogcoordf",ring_glFogCoordf);
ring_vm_funcregister("glfogcoorddv",ring_glFogCoorddv);
ring_vm_funcregister("glfogcoordfv",ring_glFogCoordfv);
ring_vm_funcregister("glfogcoordpointer",ring_glFogCoordPointer);
ring_vm_funcregister("glfrontface",ring_glFrontFace);
ring_vm_funcregister("glfrustum",ring_glFrustum);
ring_vm_funcregister("glgenbuffers",ring_glGenBuffers);
ring_vm_funcregister("glgenlists",ring_glGenLists);
ring_vm_funcregister("glgenqueries",ring_glGenQueries);
ring_vm_funcregister("glgentextures",ring_glGenTextures);
ring_vm_funcregister("glgetbooleanv",ring_glGetBooleanv);
ring_vm_funcregister("glgetdoublev",ring_glGetDoublev);
ring_vm_funcregister("glgetfloatv",ring_glGetFloatv);
ring_vm_funcregister("glgetintegerv",ring_glGetIntegerv);
ring_vm_funcregister("glgetactiveattrib",ring_glGetActiveAttrib);
ring_vm_funcregister("glgetactiveuniform",ring_glGetActiveUniform);
ring_vm_funcregister("glgetattachedshaders",ring_glGetAttachedShaders);
ring_vm_funcregister("glgetattriblocation",ring_glGetAttribLocation);
ring_vm_funcregister("glgetbufferparameteriv",ring_glGetBufferParameteriv);
ring_vm_funcregister("glgetbufferpointerv",ring_glGetBufferPointerv);
ring_vm_funcregister("glgetbuffersubdata",ring_glGetBufferSubData);
ring_vm_funcregister("glgetclipplane",ring_glGetClipPlane);
ring_vm_funcregister("glgetcolortable",ring_glGetColorTable);
ring_vm_funcregister("glgetcolortableparameterfv",ring_glGetColorTableParameterfv);
ring_vm_funcregister("glgetcolortableparameteriv",ring_glGetColorTableParameteriv);
ring_vm_funcregister("glgetcompressedteximage",ring_glGetCompressedTexImage);
ring_vm_funcregister("glgetconvolutionfilter",ring_glGetConvolutionFilter);
ring_vm_funcregister("glgetconvolutionparameterfv",ring_glGetConvolutionParameterfv);
ring_vm_funcregister("glgetconvolutionparameteriv",ring_glGetConvolutionParameteriv);
ring_vm_funcregister("glgeterror",ring_glGetError);
ring_vm_funcregister("glgethistogram",ring_glGetHistogram);
ring_vm_funcregister("glgethistogramparameterfv",ring_glGetHistogramParameterfv);
ring_vm_funcregister("glgethistogramparameteriv",ring_glGetHistogramParameteriv);
ring_vm_funcregister("glgetlightfv",ring_glGetLightfv);
ring_vm_funcregister("glgetlightiv",ring_glGetLightiv);
ring_vm_funcregister("glgetmapdv",ring_glGetMapdv);
ring_vm_funcregister("glgetmapfv",ring_glGetMapfv);
ring_vm_funcregister("glgetmapiv",ring_glGetMapiv);
ring_vm_funcregister("glgetmaterialfv",ring_glGetMaterialfv);
ring_vm_funcregister("glgetmaterialiv",ring_glGetMaterialiv);
ring_vm_funcregister("glgetminmax",ring_glGetMinmax);
ring_vm_funcregister("glgetminmaxparameterfv",ring_glGetMinmaxParameterfv);
ring_vm_funcregister("glgetminmaxparameteriv",ring_glGetMinmaxParameteriv);
ring_vm_funcregister("glgetpixelmapfv",ring_glGetPixelMapfv);
ring_vm_funcregister("glgetpixelmapuiv",ring_glGetPixelMapuiv);
ring_vm_funcregister("glgetpixelmapusv",ring_glGetPixelMapusv);
ring_vm_funcregister("glgetpointerv",ring_glGetPointerv);
ring_vm_funcregister("glgetpolygonstipple",ring_glGetPolygonStipple);
ring_vm_funcregister("glgetprogramiv",ring_glGetProgramiv);
ring_vm_funcregister("glgetprograminfolog",ring_glGetProgramInfoLog);
ring_vm_funcregister("glgetqueryobjectiv",ring_glGetQueryObjectiv);
ring_vm_funcregister("glgetqueryobjectuiv",ring_glGetQueryObjectuiv);
ring_vm_funcregister("glgetqueryiv",ring_glGetQueryiv);
ring_vm_funcregister("glgetseparablefilter",ring_glGetSeparableFilter);
ring_vm_funcregister("glgetshaderiv",ring_glGetShaderiv);
ring_vm_funcregister("glgetshaderinfolog",ring_glGetShaderInfoLog);
ring_vm_funcregister("glgetshadersource",ring_glGetShaderSource);
ring_vm_funcregister("glgetstring",ring_glGetString);
ring_vm_funcregister("glgettexenvfv",ring_glGetTexEnvfv);
ring_vm_funcregister("glgettexenviv",ring_glGetTexEnviv);
ring_vm_funcregister("glgettexgendv",ring_glGetTexGendv);
ring_vm_funcregister("glgettexgenfv",ring_glGetTexGenfv);
ring_vm_funcregister("glgettexgeniv",ring_glGetTexGeniv);
ring_vm_funcregister("glgetteximage",ring_glGetTexImage);
ring_vm_funcregister("glgettexlevelparameterfv",ring_glGetTexLevelParameterfv);
ring_vm_funcregister("glgettexlevelparameteriv",ring_glGetTexLevelParameteriv);
ring_vm_funcregister("glgettexparameterfv",ring_glGetTexParameterfv);
ring_vm_funcregister("glgettexparameteriv",ring_glGetTexParameteriv);
ring_vm_funcregister("glgetuniformfv",ring_glGetUniformfv);
ring_vm_funcregister("glgetuniformiv",ring_glGetUniformiv);
ring_vm_funcregister("glgetuniformlocation",ring_glGetUniformLocation);
ring_vm_funcregister("glgetvertexattribdv",ring_glGetVertexAttribdv);
ring_vm_funcregister("glgetvertexattribfv",ring_glGetVertexAttribfv);
ring_vm_funcregister("glgetvertexattribiv",ring_glGetVertexAttribiv);
ring_vm_funcregister("glgetvertexattribpointerv",ring_glGetVertexAttribPointerv);
ring_vm_funcregister("glhint",ring_glHint);
ring_vm_funcregister("glhistogram",ring_glHistogram);
ring_vm_funcregister("glindexs",ring_glIndexs);
ring_vm_funcregister("glindexi",ring_glIndexi);
ring_vm_funcregister("glindexf",ring_glIndexf);
ring_vm_funcregister("glindexd",ring_glIndexd);
ring_vm_funcregister("glindexub",ring_glIndexub);
ring_vm_funcregister("glindexsv",ring_glIndexsv);
ring_vm_funcregister("glindexiv",ring_glIndexiv);
ring_vm_funcregister("glindexfv",ring_glIndexfv);
ring_vm_funcregister("glindexdv",ring_glIndexdv);
ring_vm_funcregister("glindexubv",ring_glIndexubv);
ring_vm_funcregister("glindexmask",ring_glIndexMask);
ring_vm_funcregister("glindexpointer",ring_glIndexPointer);
ring_vm_funcregister("glinitnames",ring_glInitNames);
ring_vm_funcregister("glinterleavedarrays",ring_glInterleavedArrays);
ring_vm_funcregister("glisbuffer",ring_glIsBuffer);
ring_vm_funcregister("glisenabled",ring_glIsEnabled);
ring_vm_funcregister("glislist",ring_glIsList);
ring_vm_funcregister("glisprogram",ring_glIsProgram);
ring_vm_funcregister("glisquery",ring_glIsQuery);
ring_vm_funcregister("glisshader",ring_glIsShader);
ring_vm_funcregister("glistexture",ring_glIsTexture);
ring_vm_funcregister("gllightf",ring_glLightf);
ring_vm_funcregister("gllighti",ring_glLighti);
ring_vm_funcregister("gllightfv",ring_glLightfv);
ring_vm_funcregister("gllightiv",ring_glLightiv);
ring_vm_funcregister("gllightmodelf",ring_glLightModelf);
ring_vm_funcregister("gllightmodeli",ring_glLightModeli);
ring_vm_funcregister("gllightmodelfv",ring_glLightModelfv);
ring_vm_funcregister("gllightmodeliv",ring_glLightModeliv);
ring_vm_funcregister("gllinestipple",ring_glLineStipple);
ring_vm_funcregister("gllinewidth",ring_glLineWidth);
ring_vm_funcregister("gllinkprogram",ring_glLinkProgram);
ring_vm_funcregister("gllistbase",ring_glListBase);
ring_vm_funcregister("glloadidentity",ring_glLoadIdentity);
ring_vm_funcregister("glloadmatrixd",ring_glLoadMatrixd);
ring_vm_funcregister("glloadmatrixf",ring_glLoadMatrixf);
ring_vm_funcregister("glloadname",ring_glLoadName);
ring_vm_funcregister("glloadtransposematrixd",ring_glLoadTransposeMatrixd);
ring_vm_funcregister("glloadtransposematrixf",ring_glLoadTransposeMatrixf);
ring_vm_funcregister("gllogicop",ring_glLogicOp);
ring_vm_funcregister("glmap1f",ring_glMap1f);
ring_vm_funcregister("glmap1d",ring_glMap1d);
ring_vm_funcregister("glmap2f",ring_glMap2f);
ring_vm_funcregister("glmap2d",ring_glMap2d);
ring_vm_funcregister("glmapbuffer",ring_glMapBuffer);
ring_vm_funcregister("glmapgrid1d",ring_glMapGrid1d);
ring_vm_funcregister("glmapgrid1f",ring_glMapGrid1f);
ring_vm_funcregister("glmapgrid2d",ring_glMapGrid2d);
ring_vm_funcregister("glmapgrid2f",ring_glMapGrid2f);
ring_vm_funcregister("glmaterialf",ring_glMaterialf);
ring_vm_funcregister("glmateriali",ring_glMateriali);
ring_vm_funcregister("glmatrixmode",ring_glMatrixMode);
ring_vm_funcregister("glminmax",ring_glMinmax);
ring_vm_funcregister("glmultmatrixd",ring_glMultMatrixd);
ring_vm_funcregister("glmultmatrixf",ring_glMultMatrixf);
ring_vm_funcregister("glmulttransposematrixd",ring_glMultTransposeMatrixd);
ring_vm_funcregister("glmulttransposematrixf",ring_glMultTransposeMatrixf);
ring_vm_funcregister("glmultidrawarrays",ring_glMultiDrawArrays);
ring_vm_funcregister("glmultidrawelements",ring_glMultiDrawElements);
ring_vm_funcregister("glmultitexcoord1s",ring_glMultiTexCoord1s);
ring_vm_funcregister("glmultitexcoord1i",ring_glMultiTexCoord1i);
ring_vm_funcregister("glmultitexcoord1f",ring_glMultiTexCoord1f);
ring_vm_funcregister("glmultitexcoord1d",ring_glMultiTexCoord1d);
ring_vm_funcregister("glmultitexcoord2s",ring_glMultiTexCoord2s);
ring_vm_funcregister("glmultitexcoord2i",ring_glMultiTexCoord2i);
ring_vm_funcregister("glmultitexcoord2f",ring_glMultiTexCoord2f);
ring_vm_funcregister("glmultitexcoord2d",ring_glMultiTexCoord2d);
ring_vm_funcregister("glmultitexcoord3s",ring_glMultiTexCoord3s);
ring_vm_funcregister("glmultitexcoord3i",ring_glMultiTexCoord3i);
ring_vm_funcregister("glmultitexcoord3f",ring_glMultiTexCoord3f);
ring_vm_funcregister("glmultitexcoord3d",ring_glMultiTexCoord3d);
ring_vm_funcregister("glmultitexcoord4s",ring_glMultiTexCoord4s);
ring_vm_funcregister("glmultitexcoord4i",ring_glMultiTexCoord4i);
ring_vm_funcregister("glmultitexcoord4f",ring_glMultiTexCoord4f);
ring_vm_funcregister("glmultitexcoord4d",ring_glMultiTexCoord4d);
ring_vm_funcregister("glmultitexcoord1sv",ring_glMultiTexCoord1sv);
ring_vm_funcregister("glmultitexcoord1iv",ring_glMultiTexCoord1iv);
ring_vm_funcregister("glmultitexcoord1fv",ring_glMultiTexCoord1fv);
ring_vm_funcregister("glmultitexcoord1dv",ring_glMultiTexCoord1dv);
ring_vm_funcregister("glmultitexcoord2sv",ring_glMultiTexCoord2sv);
ring_vm_funcregister("glmultitexcoord2iv",ring_glMultiTexCoord2iv);
ring_vm_funcregister("glmultitexcoord2fv",ring_glMultiTexCoord2fv);
ring_vm_funcregister("glmultitexcoord2dv",ring_glMultiTexCoord2dv);
ring_vm_funcregister("glmultitexcoord3sv",ring_glMultiTexCoord3sv);
ring_vm_funcregister("glmultitexcoord3iv",ring_glMultiTexCoord3iv);
ring_vm_funcregister("glmultitexcoord3fv",ring_glMultiTexCoord3fv);
ring_vm_funcregister("glmultitexcoord3dv",ring_glMultiTexCoord3dv);
ring_vm_funcregister("glmultitexcoord4sv",ring_glMultiTexCoord4sv);
ring_vm_funcregister("glmultitexcoord4iv",ring_glMultiTexCoord4iv);
ring_vm_funcregister("glmultitexcoord4fv",ring_glMultiTexCoord4fv);
ring_vm_funcregister("glmultitexcoord4dv",ring_glMultiTexCoord4dv);
ring_vm_funcregister("glnewlist",ring_glNewList);
ring_vm_funcregister("glnormal3b",ring_glNormal3b);
ring_vm_funcregister("glnormal3d",ring_glNormal3d);
ring_vm_funcregister("glnormal3f",ring_glNormal3f);
ring_vm_funcregister("glnormal3i",ring_glNormal3i);
ring_vm_funcregister("glnormal3s",ring_glNormal3s);
ring_vm_funcregister("glnormal3bv",ring_glNormal3bv);
ring_vm_funcregister("glnormal3dv",ring_glNormal3dv);
ring_vm_funcregister("glnormal3fv",ring_glNormal3fv);
ring_vm_funcregister("glnormal3iv",ring_glNormal3iv);
ring_vm_funcregister("glnormal3sv",ring_glNormal3sv);
ring_vm_funcregister("glnormalpointer",ring_glNormalPointer);
ring_vm_funcregister("glortho",ring_glOrtho);
ring_vm_funcregister("glpassthrough",ring_glPassThrough);
ring_vm_funcregister("glpixelmapfv",ring_glPixelMapfv);
ring_vm_funcregister("glpixelmapuiv",ring_glPixelMapuiv);
ring_vm_funcregister("glpixelmapusv",ring_glPixelMapusv);
ring_vm_funcregister("glpixelstoref",ring_glPixelStoref);
ring_vm_funcregister("glpixelstorei",ring_glPixelStorei);
ring_vm_funcregister("glpixeltransferf",ring_glPixelTransferf);
ring_vm_funcregister("glpixeltransferi",ring_glPixelTransferi);
ring_vm_funcregister("glpixelzoom",ring_glPixelZoom);
ring_vm_funcregister("glpointparameterf",ring_glPointParameterf);
ring_vm_funcregister("glpointparameteri",ring_glPointParameteri);
ring_vm_funcregister("glpointsize",ring_glPointSize);
ring_vm_funcregister("glpolygonmode",ring_glPolygonMode);
ring_vm_funcregister("glpolygonoffset",ring_glPolygonOffset);
ring_vm_funcregister("glpolygonstipple",ring_glPolygonStipple);
ring_vm_funcregister("glpushattrib",ring_glPushAttrib);
ring_vm_funcregister("glpushclientattrib",ring_glPushClientAttrib);
ring_vm_funcregister("glpushmatrix",ring_glPushMatrix);
ring_vm_funcregister("glpushname",ring_glPushName);
ring_vm_funcregister("glprioritizetextures",ring_glPrioritizeTextures);
ring_vm_funcregister("glpopmatrix",ring_glPopMatrix);
ring_vm_funcregister("glrasterpos2s",ring_glRasterPos2s);
ring_vm_funcregister("glrasterpos2i",ring_glRasterPos2i);
ring_vm_funcregister("glrasterpos2f",ring_glRasterPos2f);
ring_vm_funcregister("glrasterpos2d",ring_glRasterPos2d);
ring_vm_funcregister("glrasterpos3s",ring_glRasterPos3s);
ring_vm_funcregister("glrasterpos3i",ring_glRasterPos3i);
ring_vm_funcregister("glrasterpos3f",ring_glRasterPos3f);
ring_vm_funcregister("glrasterpos3d",ring_glRasterPos3d);
ring_vm_funcregister("glrasterpos4s",ring_glRasterPos4s);
ring_vm_funcregister("glrasterpos4i",ring_glRasterPos4i);
ring_vm_funcregister("glrasterpos4f",ring_glRasterPos4f);
ring_vm_funcregister("glrasterpos4d",ring_glRasterPos4d);
ring_vm_funcregister("glreadbuffer",ring_glReadBuffer);
ring_vm_funcregister("glreadpixels",ring_glReadPixels);
ring_vm_funcregister("glrectd",ring_glRectd);
ring_vm_funcregister("glrectf",ring_glRectf);
ring_vm_funcregister("glrecti",ring_glRecti);
ring_vm_funcregister("glrects",ring_glRects);
ring_vm_funcregister("glrectdv",ring_glRectdv);
ring_vm_funcregister("glrectfv",ring_glRectfv);
ring_vm_funcregister("glrectiv",ring_glRectiv);
ring_vm_funcregister("glrectsv",ring_glRectsv);
ring_vm_funcregister("glrendermode",ring_glRenderMode);
ring_vm_funcregister("glresethistogram",ring_glResetHistogram);
ring_vm_funcregister("glrotated",ring_glRotated);
ring_vm_funcregister("glrotatef",ring_glRotatef);
ring_vm_funcregister("glsamplecoverage",ring_glSampleCoverage);
ring_vm_funcregister("glscaled",ring_glScaled);
ring_vm_funcregister("glscalef",ring_glScalef);
ring_vm_funcregister("glscissor",ring_glScissor);
ring_vm_funcregister("glsecondarycolor3b",ring_glSecondaryColor3b);
ring_vm_funcregister("glsecondarycolor3s",ring_glSecondaryColor3s);
ring_vm_funcregister("glsecondarycolor3i",ring_glSecondaryColor3i);
ring_vm_funcregister("glsecondarycolor3f",ring_glSecondaryColor3f);
ring_vm_funcregister("glsecondarycolor3d",ring_glSecondaryColor3d);
ring_vm_funcregister("glsecondarycolor3ub",ring_glSecondaryColor3ub);
ring_vm_funcregister("glsecondarycolor3us",ring_glSecondaryColor3us);
ring_vm_funcregister("glsecondarycolor3ui",ring_glSecondaryColor3ui);
ring_vm_funcregister("glsecondarycolor3bv",ring_glSecondaryColor3bv);
ring_vm_funcregister("glsecondarycolor3sv",ring_glSecondaryColor3sv);
ring_vm_funcregister("glsecondarycolor3iv",ring_glSecondaryColor3iv);
ring_vm_funcregister("glsecondarycolor3fv",ring_glSecondaryColor3fv);
ring_vm_funcregister("glsecondarycolor3dv",ring_glSecondaryColor3dv);
ring_vm_funcregister("glsecondarycolor3ubv",ring_glSecondaryColor3ubv);
ring_vm_funcregister("glsecondarycolor3usv",ring_glSecondaryColor3usv);
ring_vm_funcregister("glsecondarycolor3uiv",ring_glSecondaryColor3uiv);
ring_vm_funcregister("glsecondarycolorpointer",ring_glSecondaryColorPointer);
ring_vm_funcregister("glselectbuffer",ring_glSelectBuffer);
ring_vm_funcregister("glseparablefilter2d",ring_glSeparableFilter2D);
ring_vm_funcregister("glshademodel",ring_glShadeModel);
ring_vm_funcregister("glshadersource",ring_glShaderSource);
ring_vm_funcregister("glstencilfunc",ring_glStencilFunc);
ring_vm_funcregister("glstencilfuncseparate",ring_glStencilFuncSeparate);
ring_vm_funcregister("glstencilmask",ring_glStencilMask);
ring_vm_funcregister("glstencilmaskseparate",ring_glStencilMaskSeparate);
ring_vm_funcregister("glstencilop",ring_glStencilOp);
ring_vm_funcregister("glstencilopseparate",ring_glStencilOpSeparate);
ring_vm_funcregister("gltexcoord1s",ring_glTexCoord1s);
ring_vm_funcregister("gltexcoord1i",ring_glTexCoord1i);
ring_vm_funcregister("gltexcoord1f",ring_glTexCoord1f);
ring_vm_funcregister("gltexcoord1d",ring_glTexCoord1d);
ring_vm_funcregister("gltexcoord2s",ring_glTexCoord2s);
ring_vm_funcregister("gltexcoord2i",ring_glTexCoord2i);
ring_vm_funcregister("gltexcoord2f",ring_glTexCoord2f);
ring_vm_funcregister("gltexcoord2d",ring_glTexCoord2d);
ring_vm_funcregister("gltexcoord3s",ring_glTexCoord3s);
ring_vm_funcregister("gltexcoord3i",ring_glTexCoord3i);
ring_vm_funcregister("gltexcoord3f",ring_glTexCoord3f);
ring_vm_funcregister("gltexcoord3d",ring_glTexCoord3d);
ring_vm_funcregister("gltexcoord4s",ring_glTexCoord4s);
ring_vm_funcregister("gltexcoord4i",ring_glTexCoord4i);
ring_vm_funcregister("gltexcoord4f",ring_glTexCoord4f);
ring_vm_funcregister("gltexcoord4d",ring_glTexCoord4d);
ring_vm_funcregister("gltexcoord1sv",ring_glTexCoord1sv);
ring_vm_funcregister("gltexcoord1iv",ring_glTexCoord1iv);
ring_vm_funcregister("gltexcoord1fv",ring_glTexCoord1fv);
ring_vm_funcregister("gltexcoord1dv",ring_glTexCoord1dv);
ring_vm_funcregister("gltexcoord2sv",ring_glTexCoord2sv);
ring_vm_funcregister("gltexcoord2iv",ring_glTexCoord2iv);
ring_vm_funcregister("gltexcoord2fv",ring_glTexCoord2fv);
ring_vm_funcregister("gltexcoord2dv",ring_glTexCoord2dv);
ring_vm_funcregister("gltexcoord3sv",ring_glTexCoord3sv);
ring_vm_funcregister("gltexcoord3iv",ring_glTexCoord3iv);
ring_vm_funcregister("gltexcoord3fv",ring_glTexCoord3fv);
ring_vm_funcregister("gltexcoord3dv",ring_glTexCoord3dv);
ring_vm_funcregister("gltexcoord4sv",ring_glTexCoord4sv);
ring_vm_funcregister("gltexcoord4iv",ring_glTexCoord4iv);
ring_vm_funcregister("gltexcoord4fv",ring_glTexCoord4fv);
ring_vm_funcregister("gltexcoord4dv",ring_glTexCoord4dv);
ring_vm_funcregister("gltexcoordpointer",ring_glTexCoordPointer);
ring_vm_funcregister("gltexenvf",ring_glTexEnvf);
ring_vm_funcregister("gltexenvi",ring_glTexEnvi);
ring_vm_funcregister("gltexgeni",ring_glTexGeni);
ring_vm_funcregister("gltexgenf",ring_glTexGenf);
ring_vm_funcregister("gltexgend",ring_glTexGend);
ring_vm_funcregister("gltexgeniv",ring_glTexGeniv);
ring_vm_funcregister("gltexgenfv",ring_glTexGenfv);
ring_vm_funcregister("gltexgendv",ring_glTexGendv);
ring_vm_funcregister("glteximage1d",ring_glTexImage1D);
ring_vm_funcregister("glteximage2d",ring_glTexImage2D);
ring_vm_funcregister("glteximage3d",ring_glTexImage3D);
ring_vm_funcregister("gltexparameterf",ring_glTexParameterf);
ring_vm_funcregister("gltexparameteri",ring_glTexParameteri);
ring_vm_funcregister("gltexparameterfv",ring_glTexParameterfv);
ring_vm_funcregister("gltexparameteriv",ring_glTexParameteriv);
ring_vm_funcregister("gltexsubimage1d",ring_glTexSubImage1D);
ring_vm_funcregister("gltexsubimage2d",ring_glTexSubImage2D);
ring_vm_funcregister("gltexsubimage3d",ring_glTexSubImage3D);
ring_vm_funcregister("gltranslated",ring_glTranslated);
ring_vm_funcregister("gltranslatef",ring_glTranslatef);
ring_vm_funcregister("gluniform1f",ring_glUniform1f);
ring_vm_funcregister("gluniform2f",ring_glUniform2f);
ring_vm_funcregister("gluniform3f",ring_glUniform3f);
ring_vm_funcregister("gluniform4f",ring_glUniform4f);
ring_vm_funcregister("gluniform1i",ring_glUniform1i);
ring_vm_funcregister("gluniform2i",ring_glUniform2i);
ring_vm_funcregister("gluniform3i",ring_glUniform3i);
ring_vm_funcregister("gluniform4i",ring_glUniform4i);
ring_vm_funcregister("gluniform1fv",ring_glUniform1fv);
ring_vm_funcregister("gluniform2fv",ring_glUniform2fv);
ring_vm_funcregister("gluniform3fv",ring_glUniform3fv);
ring_vm_funcregister("gluniform4fv",ring_glUniform4fv);
ring_vm_funcregister("gluniform1iv",ring_glUniform1iv);
ring_vm_funcregister("gluniform2iv",ring_glUniform2iv);
ring_vm_funcregister("gluniform3iv",ring_glUniform3iv);
ring_vm_funcregister("gluniform4iv",ring_glUniform4iv);
ring_vm_funcregister("gluniformmatrix2fv",ring_glUniformMatrix2fv);
ring_vm_funcregister("gluniformmatrix3fv",ring_glUniformMatrix3fv);
ring_vm_funcregister("gluniformmatrix4fv",ring_glUniformMatrix4fv);
ring_vm_funcregister("gluniformmatrix2x3fv",ring_glUniformMatrix2x3fv);
ring_vm_funcregister("gluniformmatrix3x2fv",ring_glUniformMatrix3x2fv);
ring_vm_funcregister("gluniformmatrix2x4fv",ring_glUniformMatrix2x4fv);
ring_vm_funcregister("gluniformmatrix4x2fv",ring_glUniformMatrix4x2fv);
ring_vm_funcregister("gluniformmatrix3x4fv",ring_glUniformMatrix3x4fv);
ring_vm_funcregister("gluniformmatrix4x3fv",ring_glUniformMatrix4x3fv);
ring_vm_funcregister("gluseprogram",ring_glUseProgram);
ring_vm_funcregister("glvalidateprogram",ring_glValidateProgram);
ring_vm_funcregister("glvertex2s",ring_glVertex2s);
ring_vm_funcregister("glvertex2i",ring_glVertex2i);
ring_vm_funcregister("glvertex2f",ring_glVertex2f);
ring_vm_funcregister("glvertex2d",ring_glVertex2d);
ring_vm_funcregister("glvertex3s",ring_glVertex3s);
ring_vm_funcregister("glvertex3i",ring_glVertex3i);
ring_vm_funcregister("glvertex3f",ring_glVertex3f);
ring_vm_funcregister("glvertex3d",ring_glVertex3d);
ring_vm_funcregister("glvertex4s",ring_glVertex4s);
ring_vm_funcregister("glvertex4i",ring_glVertex4i);
ring_vm_funcregister("glvertex4f",ring_glVertex4f);
ring_vm_funcregister("glvertex4d",ring_glVertex4d);
ring_vm_funcregister("glvertex2sv",ring_glVertex2sv);
ring_vm_funcregister("glvertex2iv",ring_glVertex2iv);
ring_vm_funcregister("glvertex2fv",ring_glVertex2fv);
ring_vm_funcregister("glvertex2dv",ring_glVertex2dv);
ring_vm_funcregister("glvertex3sv",ring_glVertex3sv);
ring_vm_funcregister("glvertex3iv",ring_glVertex3iv);
ring_vm_funcregister("glvertex3fv",ring_glVertex3fv);
ring_vm_funcregister("glvertex3dv",ring_glVertex3dv);
ring_vm_funcregister("glvertex4sv",ring_glVertex4sv);
ring_vm_funcregister("glvertex4iv",ring_glVertex4iv);
ring_vm_funcregister("glvertex4fv",ring_glVertex4fv);
ring_vm_funcregister("glvertex4dv",ring_glVertex4dv);
ring_vm_funcregister("glvertexattrib1f",ring_glVertexAttrib1f);
ring_vm_funcregister("glvertexattrib1s",ring_glVertexAttrib1s);
ring_vm_funcregister("glvertexattrib1d",ring_glVertexAttrib1d);
ring_vm_funcregister("glvertexattrib2f",ring_glVertexAttrib2f);
ring_vm_funcregister("glvertexattrib2s",ring_glVertexAttrib2s);
ring_vm_funcregister("glvertexattrib2d",ring_glVertexAttrib2d);
ring_vm_funcregister("glvertexattrib3f",ring_glVertexAttrib3f);
ring_vm_funcregister("glvertexattrib3s",ring_glVertexAttrib3s);
ring_vm_funcregister("glvertexattrib3d",ring_glVertexAttrib3d);
ring_vm_funcregister("glvertexattrib4f",ring_glVertexAttrib4f);
ring_vm_funcregister("glvertexattrib4s",ring_glVertexAttrib4s);
ring_vm_funcregister("glvertexattrib4d",ring_glVertexAttrib4d);
ring_vm_funcregister("glvertexattrib4nub",ring_glVertexAttrib4Nub);
ring_vm_funcregister("glvertexattrib1fv",ring_glVertexAttrib1fv);
ring_vm_funcregister("glvertexattrib1sv",ring_glVertexAttrib1sv);
ring_vm_funcregister("glvertexattrib1dv",ring_glVertexAttrib1dv);
ring_vm_funcregister("glvertexattrib2fv",ring_glVertexAttrib2fv);
ring_vm_funcregister("glvertexattrib2sv",ring_glVertexAttrib2sv);
ring_vm_funcregister("glvertexattrib2dv",ring_glVertexAttrib2dv);
ring_vm_funcregister("glvertexattrib3fv",ring_glVertexAttrib3fv);
ring_vm_funcregister("glvertexattrib3sv",ring_glVertexAttrib3sv);
ring_vm_funcregister("glvertexattrib3dv",ring_glVertexAttrib3dv);
ring_vm_funcregister("glvertexattrib4fv",ring_glVertexAttrib4fv);
ring_vm_funcregister("glvertexattrib4sv",ring_glVertexAttrib4sv);
ring_vm_funcregister("glvertexattrib4dv",ring_glVertexAttrib4dv);
ring_vm_funcregister("glvertexattrib4iv",ring_glVertexAttrib4iv);
ring_vm_funcregister("glvertexattrib4bv",ring_glVertexAttrib4bv);
ring_vm_funcregister("glvertexattrib4ubv",ring_glVertexAttrib4ubv);
ring_vm_funcregister("glvertexattrib4usv",ring_glVertexAttrib4usv);
ring_vm_funcregister("glvertexattrib4uiv",ring_glVertexAttrib4uiv);
ring_vm_funcregister("glvertexattribpointer",ring_glVertexAttribPointer);
ring_vm_funcregister("glvertexpointer",ring_glVertexPointer);
ring_vm_funcregister("glviewport",ring_glViewport);
ring_vm_funcregister("glwindowpos2s",ring_glWindowPos2s);
ring_vm_funcregister("glwindowpos2i",ring_glWindowPos2i);
ring_vm_funcregister("glwindowpos2f",ring_glWindowPos2f);
ring_vm_funcregister("glwindowpos2d",ring_glWindowPos2d);
ring_vm_funcregister("glwindowpos3s",ring_glWindowPos3s);
ring_vm_funcregister("glwindowpos3i",ring_glWindowPos3i);
ring_vm_funcregister("glwindowpos3f",ring_glWindowPos3f);
ring_vm_funcregister("glwindowpos3d",ring_glWindowPos3d);
ring_vm_funcregister("glwindowpos2sv",ring_glWindowPos2sv);
ring_vm_funcregister("glwindowpos2iv",ring_glWindowPos2iv);
ring_vm_funcregister("glwindowpos2fv",ring_glWindowPos2fv);
ring_vm_funcregister("glwindowpos2dv",ring_glWindowPos2dv);
ring_vm_funcregister("glwindowpos3sv",ring_glWindowPos3sv);
ring_vm_funcregister("glwindowpos3iv",ring_glWindowPos3iv);
ring_vm_funcregister("glwindowpos3fv",ring_glWindowPos3fv);
ring_vm_funcregister("glwindowpos3dv",ring_glWindowPos3dv);
ring_vm_funcregister("glubegincurve",ring_gluBeginCurve);
ring_vm_funcregister("glubeginpolygon",ring_gluBeginPolygon);
ring_vm_funcregister("glubeginsurface",ring_gluBeginSurface);
ring_vm_funcregister("glubegintrim",ring_gluBeginTrim);
ring_vm_funcregister("glucylinder",ring_gluCylinder);
ring_vm_funcregister("gludeletenurbsrenderer",ring_gluDeleteNurbsRenderer);
ring_vm_funcregister("gludeletequadric",ring_gluDeleteQuadric);
ring_vm_funcregister("gludeletetess",ring_gluDeleteTess);
ring_vm_funcregister("gludisk",ring_gluDisk);
ring_vm_funcregister("gluendcurve",ring_gluEndCurve);
ring_vm_funcregister("gluendpolygon",ring_gluEndPolygon);
ring_vm_funcregister("gluendsurface",ring_gluEndSurface);
ring_vm_funcregister("gluendtrim",ring_gluEndTrim);
ring_vm_funcregister("gluerrorstring",ring_gluErrorString);
ring_vm_funcregister("glugetnurbsproperty",ring_gluGetNurbsProperty);
ring_vm_funcregister("glugetstring",ring_gluGetString);
ring_vm_funcregister("glugettessproperty",ring_gluGetTessProperty);
ring_vm_funcregister("gluloadsamplingmatrices",ring_gluLoadSamplingMatrices);
ring_vm_funcregister("glulookat",ring_gluLookAt);
ring_vm_funcregister("glunewnurbsrenderer",ring_gluNewNurbsRenderer);
ring_vm_funcregister("glunewquadric",ring_gluNewQuadric);
ring_vm_funcregister("glunewtess",ring_gluNewTess);
ring_vm_funcregister("glunextcontour",ring_gluNextContour);
ring_vm_funcregister("glunurbscurve",ring_gluNurbsCurve);
ring_vm_funcregister("glunurbsproperty",ring_gluNurbsProperty);
ring_vm_funcregister("glunurbssurface",ring_gluNurbsSurface);
ring_vm_funcregister("gluortho2d",ring_gluOrtho2D);
ring_vm_funcregister("glupartialdisk",ring_gluPartialDisk);
ring_vm_funcregister("gluperspective",ring_gluPerspective);
ring_vm_funcregister("glupickmatrix",ring_gluPickMatrix);
ring_vm_funcregister("gluproject",ring_gluProject);
ring_vm_funcregister("glupwlcurve",ring_gluPwlCurve);
ring_vm_funcregister("gluquadricdrawstyle",ring_gluQuadricDrawStyle);
ring_vm_funcregister("gluquadricnormals",ring_gluQuadricNormals);
ring_vm_funcregister("gluquadricorientation",ring_gluQuadricOrientation);
ring_vm_funcregister("gluquadrictexture",ring_gluQuadricTexture);
ring_vm_funcregister("gluscaleimage",ring_gluScaleImage);
ring_vm_funcregister("glusphere",ring_gluSphere);
ring_vm_funcregister("glutessbegincontour",ring_gluTessBeginContour);
ring_vm_funcregister("glutessbeginpolygon",ring_gluTessBeginPolygon);
ring_vm_funcregister("glutessendcontour",ring_gluTessEndContour);
ring_vm_funcregister("glutessendpolygon",ring_gluTessEndPolygon);
ring_vm_funcregister("glutessnormal",ring_gluTessNormal);
ring_vm_funcregister("glutessproperty",ring_gluTessProperty);
ring_vm_funcregister("glutessvertex",ring_gluTessVertex);
ring_vm_funcregister("gluunproject",ring_gluUnProject);
ring_vm_funcregister("gldisable",ring_glDisable);
ring_vm_funcregister("get_gl_zero",ring_get_gl_zero);
ring_vm_funcregister("get_gl_false",ring_get_gl_false);
ring_vm_funcregister("get_gl_logic_op",ring_get_gl_logic_op);
ring_vm_funcregister("get_gl_none",ring_get_gl_none);
ring_vm_funcregister("get_gl_texture_components",ring_get_gl_texture_components);
ring_vm_funcregister("get_gl_no_error",ring_get_gl_no_error);
ring_vm_funcregister("get_gl_points",ring_get_gl_points);
ring_vm_funcregister("get_gl_current_bit",ring_get_gl_current_bit);
ring_vm_funcregister("get_gl_true",ring_get_gl_true);
ring_vm_funcregister("get_gl_one",ring_get_gl_one);
ring_vm_funcregister("get_gl_client_pixel_store_bit",ring_get_gl_client_pixel_store_bit);
ring_vm_funcregister("get_gl_lines",ring_get_gl_lines);
ring_vm_funcregister("get_gl_line_loop",ring_get_gl_line_loop);
ring_vm_funcregister("get_gl_point_bit",ring_get_gl_point_bit);
ring_vm_funcregister("get_gl_client_vertex_array_bit",ring_get_gl_client_vertex_array_bit);
ring_vm_funcregister("get_gl_line_strip",ring_get_gl_line_strip);
ring_vm_funcregister("get_gl_line_bit",ring_get_gl_line_bit);
ring_vm_funcregister("get_gl_triangles",ring_get_gl_triangles);
ring_vm_funcregister("get_gl_triangle_strip",ring_get_gl_triangle_strip);
ring_vm_funcregister("get_gl_triangle_fan",ring_get_gl_triangle_fan);
ring_vm_funcregister("get_gl_quads",ring_get_gl_quads);
ring_vm_funcregister("get_gl_quad_strip",ring_get_gl_quad_strip);
ring_vm_funcregister("get_gl_polygon_bit",ring_get_gl_polygon_bit);
ring_vm_funcregister("get_gl_polygon",ring_get_gl_polygon);
ring_vm_funcregister("get_gl_polygon_stipple_bit",ring_get_gl_polygon_stipple_bit);
ring_vm_funcregister("get_gl_pixel_mode_bit",ring_get_gl_pixel_mode_bit);
ring_vm_funcregister("get_gl_lighting_bit",ring_get_gl_lighting_bit);
ring_vm_funcregister("get_gl_fog_bit",ring_get_gl_fog_bit);
ring_vm_funcregister("get_gl_depth_buffer_bit",ring_get_gl_depth_buffer_bit);
ring_vm_funcregister("get_gl_accum",ring_get_gl_accum);
ring_vm_funcregister("get_gl_load",ring_get_gl_load);
ring_vm_funcregister("get_gl_return",ring_get_gl_return);
ring_vm_funcregister("get_gl_mult",ring_get_gl_mult);
ring_vm_funcregister("get_gl_add",ring_get_gl_add);
ring_vm_funcregister("get_gl_never",ring_get_gl_never);
ring_vm_funcregister("get_gl_accum_buffer_bit",ring_get_gl_accum_buffer_bit);
ring_vm_funcregister("get_gl_less",ring_get_gl_less);
ring_vm_funcregister("get_gl_equal",ring_get_gl_equal);
ring_vm_funcregister("get_gl_lequal",ring_get_gl_lequal);
ring_vm_funcregister("get_gl_greater",ring_get_gl_greater);
ring_vm_funcregister("get_gl_notequal",ring_get_gl_notequal);
ring_vm_funcregister("get_gl_gequal",ring_get_gl_gequal);
ring_vm_funcregister("get_gl_always",ring_get_gl_always);
ring_vm_funcregister("get_gl_src_color",ring_get_gl_src_color);
ring_vm_funcregister("get_gl_one_minus_src_color",ring_get_gl_one_minus_src_color);
ring_vm_funcregister("get_gl_src_alpha",ring_get_gl_src_alpha);
ring_vm_funcregister("get_gl_one_minus_src_alpha",ring_get_gl_one_minus_src_alpha);
ring_vm_funcregister("get_gl_dst_alpha",ring_get_gl_dst_alpha);
ring_vm_funcregister("get_gl_one_minus_dst_alpha",ring_get_gl_one_minus_dst_alpha);
ring_vm_funcregister("get_gl_dst_color",ring_get_gl_dst_color);
ring_vm_funcregister("get_gl_one_minus_dst_color",ring_get_gl_one_minus_dst_color);
ring_vm_funcregister("get_gl_src_alpha_saturate",ring_get_gl_src_alpha_saturate);
ring_vm_funcregister("get_gl_stencil_buffer_bit",ring_get_gl_stencil_buffer_bit);
ring_vm_funcregister("get_gl_front_left",ring_get_gl_front_left);
ring_vm_funcregister("get_gl_front_right",ring_get_gl_front_right);
ring_vm_funcregister("get_gl_back_left",ring_get_gl_back_left);
ring_vm_funcregister("get_gl_back_right",ring_get_gl_back_right);
ring_vm_funcregister("get_gl_front",ring_get_gl_front);
ring_vm_funcregister("get_gl_back",ring_get_gl_back);
ring_vm_funcregister("get_gl_left",ring_get_gl_left);
ring_vm_funcregister("get_gl_right",ring_get_gl_right);
ring_vm_funcregister("get_gl_front_and_back",ring_get_gl_front_and_back);
ring_vm_funcregister("get_gl_aux0",ring_get_gl_aux0);
ring_vm_funcregister("get_gl_aux1",ring_get_gl_aux1);
ring_vm_funcregister("get_gl_aux2",ring_get_gl_aux2);
ring_vm_funcregister("get_gl_aux3",ring_get_gl_aux3);
ring_vm_funcregister("get_gl_invalid_enum",ring_get_gl_invalid_enum);
ring_vm_funcregister("get_gl_invalid_value",ring_get_gl_invalid_value);
ring_vm_funcregister("get_gl_invalid_operation",ring_get_gl_invalid_operation);
ring_vm_funcregister("get_gl_stack_overflow",ring_get_gl_stack_overflow);
ring_vm_funcregister("get_gl_stack_underflow",ring_get_gl_stack_underflow);
ring_vm_funcregister("get_gl_out_of_memory",ring_get_gl_out_of_memory);
ring_vm_funcregister("get_gl_2d",ring_get_gl_2d);
ring_vm_funcregister("get_gl_3d",ring_get_gl_3d);
ring_vm_funcregister("get_gl_3d_color",ring_get_gl_3d_color);
ring_vm_funcregister("get_gl_3d_color_texture",ring_get_gl_3d_color_texture);
ring_vm_funcregister("get_gl_4d_color_texture",ring_get_gl_4d_color_texture);
ring_vm_funcregister("get_gl_pass_through_token",ring_get_gl_pass_through_token);
ring_vm_funcregister("get_gl_point_token",ring_get_gl_point_token);
ring_vm_funcregister("get_gl_line_token",ring_get_gl_line_token);
ring_vm_funcregister("get_gl_polygon_token",ring_get_gl_polygon_token);
ring_vm_funcregister("get_gl_bitmap_token",ring_get_gl_bitmap_token);
ring_vm_funcregister("get_gl_draw_pixel_token",ring_get_gl_draw_pixel_token);
ring_vm_funcregister("get_gl_copy_pixel_token",ring_get_gl_copy_pixel_token);
ring_vm_funcregister("get_gl_line_reset_token",ring_get_gl_line_reset_token);
ring_vm_funcregister("get_gl_exp",ring_get_gl_exp);
ring_vm_funcregister("get_gl_viewport_bit",ring_get_gl_viewport_bit);
ring_vm_funcregister("get_gl_exp2",ring_get_gl_exp2);
ring_vm_funcregister("get_gl_cw",ring_get_gl_cw);
ring_vm_funcregister("get_gl_ccw",ring_get_gl_ccw);
ring_vm_funcregister("get_gl_coeff",ring_get_gl_coeff);
ring_vm_funcregister("get_gl_order",ring_get_gl_order);
ring_vm_funcregister("get_gl_domain",ring_get_gl_domain);
ring_vm_funcregister("get_gl_current_color",ring_get_gl_current_color);
ring_vm_funcregister("get_gl_current_index",ring_get_gl_current_index);
ring_vm_funcregister("get_gl_current_normal",ring_get_gl_current_normal);
ring_vm_funcregister("get_gl_current_texture_coords",ring_get_gl_current_texture_coords);
ring_vm_funcregister("get_gl_current_raster_color",ring_get_gl_current_raster_color);
ring_vm_funcregister("get_gl_current_raster_index",ring_get_gl_current_raster_index);
ring_vm_funcregister("get_gl_current_raster_texture_coords",ring_get_gl_current_raster_texture_coords);
ring_vm_funcregister("get_gl_current_raster_position",ring_get_gl_current_raster_position);
ring_vm_funcregister("get_gl_current_raster_position_valid",ring_get_gl_current_raster_position_valid);
ring_vm_funcregister("get_gl_current_raster_distance",ring_get_gl_current_raster_distance);
ring_vm_funcregister("get_gl_point_smooth",ring_get_gl_point_smooth);
ring_vm_funcregister("get_gl_point_size",ring_get_gl_point_size);
ring_vm_funcregister("get_gl_point_size_range",ring_get_gl_point_size_range);
ring_vm_funcregister("get_gl_point_size_granularity",ring_get_gl_point_size_granularity);
ring_vm_funcregister("get_gl_line_smooth",ring_get_gl_line_smooth);
ring_vm_funcregister("get_gl_line_width",ring_get_gl_line_width);
ring_vm_funcregister("get_gl_line_width_range",ring_get_gl_line_width_range);
ring_vm_funcregister("get_gl_line_width_granularity",ring_get_gl_line_width_granularity);
ring_vm_funcregister("get_gl_line_stipple",ring_get_gl_line_stipple);
ring_vm_funcregister("get_gl_line_stipple_pattern",ring_get_gl_line_stipple_pattern);
ring_vm_funcregister("get_gl_line_stipple_repeat",ring_get_gl_line_stipple_repeat);
ring_vm_funcregister("get_gl_list_mode",ring_get_gl_list_mode);
ring_vm_funcregister("get_gl_max_list_nesting",ring_get_gl_max_list_nesting);
ring_vm_funcregister("get_gl_list_base",ring_get_gl_list_base);
ring_vm_funcregister("get_gl_list_index",ring_get_gl_list_index);
ring_vm_funcregister("get_gl_polygon_mode",ring_get_gl_polygon_mode);
ring_vm_funcregister("get_gl_polygon_smooth",ring_get_gl_polygon_smooth);
ring_vm_funcregister("get_gl_polygon_stipple",ring_get_gl_polygon_stipple);
ring_vm_funcregister("get_gl_edge_flag",ring_get_gl_edge_flag);
ring_vm_funcregister("get_gl_cull_face",ring_get_gl_cull_face);
ring_vm_funcregister("get_gl_cull_face_mode",ring_get_gl_cull_face_mode);
ring_vm_funcregister("get_gl_front_face",ring_get_gl_front_face);
ring_vm_funcregister("get_gl_lighting",ring_get_gl_lighting);
ring_vm_funcregister("get_gl_light_model_local_viewer",ring_get_gl_light_model_local_viewer);
ring_vm_funcregister("get_gl_light_model_two_side",ring_get_gl_light_model_two_side);
ring_vm_funcregister("get_gl_light_model_ambient",ring_get_gl_light_model_ambient);
ring_vm_funcregister("get_gl_shade_model",ring_get_gl_shade_model);
ring_vm_funcregister("get_gl_color_material_face",ring_get_gl_color_material_face);
ring_vm_funcregister("get_gl_color_material_parameter",ring_get_gl_color_material_parameter);
ring_vm_funcregister("get_gl_color_material",ring_get_gl_color_material);
ring_vm_funcregister("get_gl_fog",ring_get_gl_fog);
ring_vm_funcregister("get_gl_fog_index",ring_get_gl_fog_index);
ring_vm_funcregister("get_gl_fog_density",ring_get_gl_fog_density);
ring_vm_funcregister("get_gl_fog_start",ring_get_gl_fog_start);
ring_vm_funcregister("get_gl_fog_end",ring_get_gl_fog_end);
ring_vm_funcregister("get_gl_fog_mode",ring_get_gl_fog_mode);
ring_vm_funcregister("get_gl_fog_color",ring_get_gl_fog_color);
ring_vm_funcregister("get_gl_depth_range",ring_get_gl_depth_range);
ring_vm_funcregister("get_gl_depth_test",ring_get_gl_depth_test);
ring_vm_funcregister("get_gl_depth_writemask",ring_get_gl_depth_writemask);
ring_vm_funcregister("get_gl_depth_clear_value",ring_get_gl_depth_clear_value);
ring_vm_funcregister("get_gl_depth_func",ring_get_gl_depth_func);
ring_vm_funcregister("get_gl_accum_clear_value",ring_get_gl_accum_clear_value);
ring_vm_funcregister("get_gl_stencil_test",ring_get_gl_stencil_test);
ring_vm_funcregister("get_gl_stencil_clear_value",ring_get_gl_stencil_clear_value);
ring_vm_funcregister("get_gl_stencil_func",ring_get_gl_stencil_func);
ring_vm_funcregister("get_gl_stencil_value_mask",ring_get_gl_stencil_value_mask);
ring_vm_funcregister("get_gl_stencil_fail",ring_get_gl_stencil_fail);
ring_vm_funcregister("get_gl_stencil_pass_depth_fail",ring_get_gl_stencil_pass_depth_fail);
ring_vm_funcregister("get_gl_stencil_pass_depth_pass",ring_get_gl_stencil_pass_depth_pass);
ring_vm_funcregister("get_gl_stencil_ref",ring_get_gl_stencil_ref);
ring_vm_funcregister("get_gl_stencil_writemask",ring_get_gl_stencil_writemask);
ring_vm_funcregister("get_gl_matrix_mode",ring_get_gl_matrix_mode);
ring_vm_funcregister("get_gl_normalize",ring_get_gl_normalize);
ring_vm_funcregister("get_gl_viewport",ring_get_gl_viewport);
ring_vm_funcregister("get_gl_modelview_stack_depth",ring_get_gl_modelview_stack_depth);
ring_vm_funcregister("get_gl_projection_stack_depth",ring_get_gl_projection_stack_depth);
ring_vm_funcregister("get_gl_texture_stack_depth",ring_get_gl_texture_stack_depth);
ring_vm_funcregister("get_gl_modelview_matrix",ring_get_gl_modelview_matrix);
ring_vm_funcregister("get_gl_projection_matrix",ring_get_gl_projection_matrix);
ring_vm_funcregister("get_gl_texture_matrix",ring_get_gl_texture_matrix);
ring_vm_funcregister("get_gl_attrib_stack_depth",ring_get_gl_attrib_stack_depth);
ring_vm_funcregister("get_gl_client_attrib_stack_depth",ring_get_gl_client_attrib_stack_depth);
ring_vm_funcregister("get_gl_alpha_test",ring_get_gl_alpha_test);
ring_vm_funcregister("get_gl_alpha_test_func",ring_get_gl_alpha_test_func);
ring_vm_funcregister("get_gl_alpha_test_ref",ring_get_gl_alpha_test_ref);
ring_vm_funcregister("get_gl_dither",ring_get_gl_dither);
ring_vm_funcregister("get_gl_blend_dst",ring_get_gl_blend_dst);
ring_vm_funcregister("get_gl_blend_src",ring_get_gl_blend_src);
ring_vm_funcregister("get_gl_blend",ring_get_gl_blend);
ring_vm_funcregister("get_gl_logic_op_mode",ring_get_gl_logic_op_mode);
ring_vm_funcregister("get_gl_index_logic_op",ring_get_gl_index_logic_op);
ring_vm_funcregister("get_gl_color_logic_op",ring_get_gl_color_logic_op);
ring_vm_funcregister("get_gl_aux_buffers",ring_get_gl_aux_buffers);
ring_vm_funcregister("get_gl_draw_buffer",ring_get_gl_draw_buffer);
ring_vm_funcregister("get_gl_read_buffer",ring_get_gl_read_buffer);
ring_vm_funcregister("get_gl_scissor_box",ring_get_gl_scissor_box);
ring_vm_funcregister("get_gl_scissor_test",ring_get_gl_scissor_test);
ring_vm_funcregister("get_gl_index_clear_value",ring_get_gl_index_clear_value);
ring_vm_funcregister("get_gl_index_writemask",ring_get_gl_index_writemask);
ring_vm_funcregister("get_gl_color_clear_value",ring_get_gl_color_clear_value);
ring_vm_funcregister("get_gl_color_writemask",ring_get_gl_color_writemask);
ring_vm_funcregister("get_gl_index_mode",ring_get_gl_index_mode);
ring_vm_funcregister("get_gl_rgba_mode",ring_get_gl_rgba_mode);
ring_vm_funcregister("get_gl_doublebuffer",ring_get_gl_doublebuffer);
ring_vm_funcregister("get_gl_stereo",ring_get_gl_stereo);
ring_vm_funcregister("get_gl_render_mode",ring_get_gl_render_mode);
ring_vm_funcregister("get_gl_perspective_correction_hint",ring_get_gl_perspective_correction_hint);
ring_vm_funcregister("get_gl_point_smooth_hint",ring_get_gl_point_smooth_hint);
ring_vm_funcregister("get_gl_line_smooth_hint",ring_get_gl_line_smooth_hint);
ring_vm_funcregister("get_gl_polygon_smooth_hint",ring_get_gl_polygon_smooth_hint);
ring_vm_funcregister("get_gl_fog_hint",ring_get_gl_fog_hint);
ring_vm_funcregister("get_gl_texture_gen_s",ring_get_gl_texture_gen_s);
ring_vm_funcregister("get_gl_texture_gen_t",ring_get_gl_texture_gen_t);
ring_vm_funcregister("get_gl_texture_gen_r",ring_get_gl_texture_gen_r);
ring_vm_funcregister("get_gl_texture_gen_q",ring_get_gl_texture_gen_q);
ring_vm_funcregister("get_gl_pixel_map_i_to_i",ring_get_gl_pixel_map_i_to_i);
ring_vm_funcregister("get_gl_pixel_map_s_to_s",ring_get_gl_pixel_map_s_to_s);
ring_vm_funcregister("get_gl_pixel_map_i_to_r",ring_get_gl_pixel_map_i_to_r);
ring_vm_funcregister("get_gl_pixel_map_i_to_g",ring_get_gl_pixel_map_i_to_g);
ring_vm_funcregister("get_gl_pixel_map_i_to_b",ring_get_gl_pixel_map_i_to_b);
ring_vm_funcregister("get_gl_pixel_map_i_to_a",ring_get_gl_pixel_map_i_to_a);
ring_vm_funcregister("get_gl_pixel_map_r_to_r",ring_get_gl_pixel_map_r_to_r);
ring_vm_funcregister("get_gl_pixel_map_g_to_g",ring_get_gl_pixel_map_g_to_g);
ring_vm_funcregister("get_gl_pixel_map_b_to_b",ring_get_gl_pixel_map_b_to_b);
ring_vm_funcregister("get_gl_pixel_map_a_to_a",ring_get_gl_pixel_map_a_to_a);
ring_vm_funcregister("get_gl_pixel_map_i_to_i_size",ring_get_gl_pixel_map_i_to_i_size);
ring_vm_funcregister("get_gl_pixel_map_s_to_s_size",ring_get_gl_pixel_map_s_to_s_size);
ring_vm_funcregister("get_gl_pixel_map_i_to_r_size",ring_get_gl_pixel_map_i_to_r_size);
ring_vm_funcregister("get_gl_pixel_map_i_to_g_size",ring_get_gl_pixel_map_i_to_g_size);
ring_vm_funcregister("get_gl_pixel_map_i_to_b_size",ring_get_gl_pixel_map_i_to_b_size);
ring_vm_funcregister("get_gl_pixel_map_i_to_a_size",ring_get_gl_pixel_map_i_to_a_size);
ring_vm_funcregister("get_gl_pixel_map_r_to_r_size",ring_get_gl_pixel_map_r_to_r_size);
ring_vm_funcregister("get_gl_pixel_map_g_to_g_size",ring_get_gl_pixel_map_g_to_g_size);
ring_vm_funcregister("get_gl_pixel_map_b_to_b_size",ring_get_gl_pixel_map_b_to_b_size);
ring_vm_funcregister("get_gl_pixel_map_a_to_a_size",ring_get_gl_pixel_map_a_to_a_size);
ring_vm_funcregister("get_gl_unpack_swap_bytes",ring_get_gl_unpack_swap_bytes);
ring_vm_funcregister("get_gl_unpack_lsb_first",ring_get_gl_unpack_lsb_first);
ring_vm_funcregister("get_gl_unpack_row_length",ring_get_gl_unpack_row_length);
ring_vm_funcregister("get_gl_unpack_skip_rows",ring_get_gl_unpack_skip_rows);
ring_vm_funcregister("get_gl_unpack_skip_pixels",ring_get_gl_unpack_skip_pixels);
ring_vm_funcregister("get_gl_unpack_alignment",ring_get_gl_unpack_alignment);
ring_vm_funcregister("get_gl_pack_swap_bytes",ring_get_gl_pack_swap_bytes);
ring_vm_funcregister("get_gl_pack_lsb_first",ring_get_gl_pack_lsb_first);
ring_vm_funcregister("get_gl_pack_row_length",ring_get_gl_pack_row_length);
ring_vm_funcregister("get_gl_pack_skip_rows",ring_get_gl_pack_skip_rows);
ring_vm_funcregister("get_gl_pack_skip_pixels",ring_get_gl_pack_skip_pixels);
ring_vm_funcregister("get_gl_pack_alignment",ring_get_gl_pack_alignment);
ring_vm_funcregister("get_gl_map_color",ring_get_gl_map_color);
ring_vm_funcregister("get_gl_map_stencil",ring_get_gl_map_stencil);
ring_vm_funcregister("get_gl_index_shift",ring_get_gl_index_shift);
ring_vm_funcregister("get_gl_index_offset",ring_get_gl_index_offset);
ring_vm_funcregister("get_gl_red_scale",ring_get_gl_red_scale);
ring_vm_funcregister("get_gl_red_bias",ring_get_gl_red_bias);
ring_vm_funcregister("get_gl_zoom_x",ring_get_gl_zoom_x);
ring_vm_funcregister("get_gl_zoom_y",ring_get_gl_zoom_y);
ring_vm_funcregister("get_gl_green_scale",ring_get_gl_green_scale);
ring_vm_funcregister("get_gl_green_bias",ring_get_gl_green_bias);
ring_vm_funcregister("get_gl_blue_scale",ring_get_gl_blue_scale);
ring_vm_funcregister("get_gl_blue_bias",ring_get_gl_blue_bias);
ring_vm_funcregister("get_gl_alpha_scale",ring_get_gl_alpha_scale);
ring_vm_funcregister("get_gl_alpha_bias",ring_get_gl_alpha_bias);
ring_vm_funcregister("get_gl_depth_scale",ring_get_gl_depth_scale);
ring_vm_funcregister("get_gl_depth_bias",ring_get_gl_depth_bias);
ring_vm_funcregister("get_gl_max_eval_order",ring_get_gl_max_eval_order);
ring_vm_funcregister("get_gl_max_lights",ring_get_gl_max_lights);
ring_vm_funcregister("get_gl_max_clip_planes",ring_get_gl_max_clip_planes);
ring_vm_funcregister("get_gl_max_texture_size",ring_get_gl_max_texture_size);
ring_vm_funcregister("get_gl_max_pixel_map_table",ring_get_gl_max_pixel_map_table);
ring_vm_funcregister("get_gl_max_attrib_stack_depth",ring_get_gl_max_attrib_stack_depth);
ring_vm_funcregister("get_gl_max_modelview_stack_depth",ring_get_gl_max_modelview_stack_depth);
ring_vm_funcregister("get_gl_max_name_stack_depth",ring_get_gl_max_name_stack_depth);
ring_vm_funcregister("get_gl_max_projection_stack_depth",ring_get_gl_max_projection_stack_depth);
ring_vm_funcregister("get_gl_max_texture_stack_depth",ring_get_gl_max_texture_stack_depth);
ring_vm_funcregister("get_gl_max_viewport_dims",ring_get_gl_max_viewport_dims);
ring_vm_funcregister("get_gl_max_client_attrib_stack_depth",ring_get_gl_max_client_attrib_stack_depth);
ring_vm_funcregister("get_gl_subpixel_bits",ring_get_gl_subpixel_bits);
ring_vm_funcregister("get_gl_index_bits",ring_get_gl_index_bits);
ring_vm_funcregister("get_gl_red_bits",ring_get_gl_red_bits);
ring_vm_funcregister("get_gl_green_bits",ring_get_gl_green_bits);
ring_vm_funcregister("get_gl_blue_bits",ring_get_gl_blue_bits);
ring_vm_funcregister("get_gl_alpha_bits",ring_get_gl_alpha_bits);
ring_vm_funcregister("get_gl_depth_bits",ring_get_gl_depth_bits);
ring_vm_funcregister("get_gl_stencil_bits",ring_get_gl_stencil_bits);
ring_vm_funcregister("get_gl_accum_red_bits",ring_get_gl_accum_red_bits);
ring_vm_funcregister("get_gl_accum_green_bits",ring_get_gl_accum_green_bits);
ring_vm_funcregister("get_gl_accum_blue_bits",ring_get_gl_accum_blue_bits);
ring_vm_funcregister("get_gl_accum_alpha_bits",ring_get_gl_accum_alpha_bits);
ring_vm_funcregister("get_gl_name_stack_depth",ring_get_gl_name_stack_depth);
ring_vm_funcregister("get_gl_auto_normal",ring_get_gl_auto_normal);
ring_vm_funcregister("get_gl_map1_color_4",ring_get_gl_map1_color_4);
ring_vm_funcregister("get_gl_map1_index",ring_get_gl_map1_index);
ring_vm_funcregister("get_gl_map1_normal",ring_get_gl_map1_normal);
ring_vm_funcregister("get_gl_map1_texture_coord_1",ring_get_gl_map1_texture_coord_1);
ring_vm_funcregister("get_gl_map1_texture_coord_2",ring_get_gl_map1_texture_coord_2);
ring_vm_funcregister("get_gl_map1_texture_coord_3",ring_get_gl_map1_texture_coord_3);
ring_vm_funcregister("get_gl_map1_texture_coord_4",ring_get_gl_map1_texture_coord_4);
ring_vm_funcregister("get_gl_map1_vertex_3",ring_get_gl_map1_vertex_3);
ring_vm_funcregister("get_gl_map1_vertex_4",ring_get_gl_map1_vertex_4);
ring_vm_funcregister("get_gl_map2_color_4",ring_get_gl_map2_color_4);
ring_vm_funcregister("get_gl_map2_index",ring_get_gl_map2_index);
ring_vm_funcregister("get_gl_map2_normal",ring_get_gl_map2_normal);
ring_vm_funcregister("get_gl_map2_texture_coord_1",ring_get_gl_map2_texture_coord_1);
ring_vm_funcregister("get_gl_map2_texture_coord_2",ring_get_gl_map2_texture_coord_2);
ring_vm_funcregister("get_gl_map2_texture_coord_3",ring_get_gl_map2_texture_coord_3);
ring_vm_funcregister("get_gl_map2_texture_coord_4",ring_get_gl_map2_texture_coord_4);
ring_vm_funcregister("get_gl_map2_vertex_3",ring_get_gl_map2_vertex_3);
ring_vm_funcregister("get_gl_map2_vertex_4",ring_get_gl_map2_vertex_4);
ring_vm_funcregister("get_gl_map1_grid_domain",ring_get_gl_map1_grid_domain);
ring_vm_funcregister("get_gl_map1_grid_segments",ring_get_gl_map1_grid_segments);
ring_vm_funcregister("get_gl_map2_grid_domain",ring_get_gl_map2_grid_domain);
ring_vm_funcregister("get_gl_map2_grid_segments",ring_get_gl_map2_grid_segments);
ring_vm_funcregister("get_gl_texture_1d",ring_get_gl_texture_1d);
ring_vm_funcregister("get_gl_texture_2d",ring_get_gl_texture_2d);
ring_vm_funcregister("get_gl_feedback_buffer_pointer",ring_get_gl_feedback_buffer_pointer);
ring_vm_funcregister("get_gl_feedback_buffer_size",ring_get_gl_feedback_buffer_size);
ring_vm_funcregister("get_gl_feedback_buffer_type",ring_get_gl_feedback_buffer_type);
ring_vm_funcregister("get_gl_selection_buffer_pointer",ring_get_gl_selection_buffer_pointer);
ring_vm_funcregister("get_gl_selection_buffer_size",ring_get_gl_selection_buffer_size);
ring_vm_funcregister("get_gl_texture_width",ring_get_gl_texture_width);
ring_vm_funcregister("get_gl_transform_bit",ring_get_gl_transform_bit);
ring_vm_funcregister("get_gl_texture_height",ring_get_gl_texture_height);
ring_vm_funcregister("get_gl_texture_internal_format",ring_get_gl_texture_internal_format);
ring_vm_funcregister("get_gl_texture_border_color",ring_get_gl_texture_border_color);
ring_vm_funcregister("get_gl_texture_border",ring_get_gl_texture_border);
ring_vm_funcregister("get_gl_dont_care",ring_get_gl_dont_care);
ring_vm_funcregister("get_gl_fastest",ring_get_gl_fastest);
ring_vm_funcregister("get_gl_nicest",ring_get_gl_nicest);
ring_vm_funcregister("get_gl_ambient",ring_get_gl_ambient);
ring_vm_funcregister("get_gl_diffuse",ring_get_gl_diffuse);
ring_vm_funcregister("get_gl_specular",ring_get_gl_specular);
ring_vm_funcregister("get_gl_position",ring_get_gl_position);
ring_vm_funcregister("get_gl_spot_direction",ring_get_gl_spot_direction);
ring_vm_funcregister("get_gl_spot_exponent",ring_get_gl_spot_exponent);
ring_vm_funcregister("get_gl_spot_cutoff",ring_get_gl_spot_cutoff);
ring_vm_funcregister("get_gl_constant_attenuation",ring_get_gl_constant_attenuation);
ring_vm_funcregister("get_gl_linear_attenuation",ring_get_gl_linear_attenuation);
ring_vm_funcregister("get_gl_quadratic_attenuation",ring_get_gl_quadratic_attenuation);
ring_vm_funcregister("get_gl_compile",ring_get_gl_compile);
ring_vm_funcregister("get_gl_compile_and_execute",ring_get_gl_compile_and_execute);
ring_vm_funcregister("get_gl_byte",ring_get_gl_byte);
ring_vm_funcregister("get_gl_unsigned_byte",ring_get_gl_unsigned_byte);
ring_vm_funcregister("get_gl_short",ring_get_gl_short);
ring_vm_funcregister("get_gl_unsigned_short",ring_get_gl_unsigned_short);
ring_vm_funcregister("get_gl_int",ring_get_gl_int);
ring_vm_funcregister("get_gl_unsigned_int",ring_get_gl_unsigned_int);
ring_vm_funcregister("get_gl_float",ring_get_gl_float);
ring_vm_funcregister("get_gl_2_bytes",ring_get_gl_2_bytes);
ring_vm_funcregister("get_gl_3_bytes",ring_get_gl_3_bytes);
ring_vm_funcregister("get_gl_4_bytes",ring_get_gl_4_bytes);
ring_vm_funcregister("get_gl_double",ring_get_gl_double);
ring_vm_funcregister("get_gl_clear",ring_get_gl_clear);
ring_vm_funcregister("get_gl_and",ring_get_gl_and);
ring_vm_funcregister("get_gl_and_reverse",ring_get_gl_and_reverse);
ring_vm_funcregister("get_gl_copy",ring_get_gl_copy);
ring_vm_funcregister("get_gl_and_inverted",ring_get_gl_and_inverted);
ring_vm_funcregister("get_gl_noop",ring_get_gl_noop);
ring_vm_funcregister("get_gl_xor",ring_get_gl_xor);
ring_vm_funcregister("get_gl_or",ring_get_gl_or);
ring_vm_funcregister("get_gl_nor",ring_get_gl_nor);
ring_vm_funcregister("get_gl_equiv",ring_get_gl_equiv);
ring_vm_funcregister("get_gl_invert",ring_get_gl_invert);
ring_vm_funcregister("get_gl_or_reverse",ring_get_gl_or_reverse);
ring_vm_funcregister("get_gl_copy_inverted",ring_get_gl_copy_inverted);
ring_vm_funcregister("get_gl_or_inverted",ring_get_gl_or_inverted);
ring_vm_funcregister("get_gl_nand",ring_get_gl_nand);
ring_vm_funcregister("get_gl_set",ring_get_gl_set);
ring_vm_funcregister("get_gl_emission",ring_get_gl_emission);
ring_vm_funcregister("get_gl_shininess",ring_get_gl_shininess);
ring_vm_funcregister("get_gl_ambient_and_diffuse",ring_get_gl_ambient_and_diffuse);
ring_vm_funcregister("get_gl_color_indexes",ring_get_gl_color_indexes);
ring_vm_funcregister("get_gl_modelview",ring_get_gl_modelview);
ring_vm_funcregister("get_gl_projection",ring_get_gl_projection);
ring_vm_funcregister("get_gl_texture",ring_get_gl_texture);
ring_vm_funcregister("get_gl_color",ring_get_gl_color);
ring_vm_funcregister("get_gl_depth",ring_get_gl_depth);
ring_vm_funcregister("get_gl_stencil",ring_get_gl_stencil);
ring_vm_funcregister("get_gl_color_index",ring_get_gl_color_index);
ring_vm_funcregister("get_gl_stencil_index",ring_get_gl_stencil_index);
ring_vm_funcregister("get_gl_depth_component",ring_get_gl_depth_component);
ring_vm_funcregister("get_gl_red",ring_get_gl_red);
ring_vm_funcregister("get_gl_green",ring_get_gl_green);
ring_vm_funcregister("get_gl_blue",ring_get_gl_blue);
ring_vm_funcregister("get_gl_alpha",ring_get_gl_alpha);
ring_vm_funcregister("get_gl_rgb",ring_get_gl_rgb);
ring_vm_funcregister("get_gl_rgba",ring_get_gl_rgba);
ring_vm_funcregister("get_gl_luminance",ring_get_gl_luminance);
ring_vm_funcregister("get_gl_luminance_alpha",ring_get_gl_luminance_alpha);
ring_vm_funcregister("get_gl_bitmap",ring_get_gl_bitmap);
ring_vm_funcregister("get_gl_point",ring_get_gl_point);
ring_vm_funcregister("get_gl_line",ring_get_gl_line);
ring_vm_funcregister("get_gl_fill",ring_get_gl_fill);
ring_vm_funcregister("get_gl_render",ring_get_gl_render);
ring_vm_funcregister("get_gl_feedback",ring_get_gl_feedback);
ring_vm_funcregister("get_gl_select",ring_get_gl_select);
ring_vm_funcregister("get_gl_flat",ring_get_gl_flat);
ring_vm_funcregister("get_gl_smooth",ring_get_gl_smooth);
ring_vm_funcregister("get_gl_keep",ring_get_gl_keep);
ring_vm_funcregister("get_gl_replace",ring_get_gl_replace);
ring_vm_funcregister("get_gl_incr",ring_get_gl_incr);
ring_vm_funcregister("get_gl_decr",ring_get_gl_decr);
ring_vm_funcregister("get_gl_vendor",ring_get_gl_vendor);
ring_vm_funcregister("get_gl_renderer",ring_get_gl_renderer);
ring_vm_funcregister("get_gl_version",ring_get_gl_version);
ring_vm_funcregister("get_gl_extensions",ring_get_gl_extensions);
ring_vm_funcregister("get_gl_s",ring_get_gl_s);
ring_vm_funcregister("get_gl_enable_bit",ring_get_gl_enable_bit);
ring_vm_funcregister("get_gl_t",ring_get_gl_t);
ring_vm_funcregister("get_gl_r",ring_get_gl_r);
ring_vm_funcregister("get_gl_q",ring_get_gl_q);
ring_vm_funcregister("get_gl_modulate",ring_get_gl_modulate);
ring_vm_funcregister("get_gl_decal",ring_get_gl_decal);
ring_vm_funcregister("get_gl_texture_env_mode",ring_get_gl_texture_env_mode);
ring_vm_funcregister("get_gl_texture_env_color",ring_get_gl_texture_env_color);
ring_vm_funcregister("get_gl_texture_env",ring_get_gl_texture_env);
ring_vm_funcregister("get_gl_eye_linear",ring_get_gl_eye_linear);
ring_vm_funcregister("get_gl_object_linear",ring_get_gl_object_linear);
ring_vm_funcregister("get_gl_sphere_map",ring_get_gl_sphere_map);
ring_vm_funcregister("get_gl_texture_gen_mode",ring_get_gl_texture_gen_mode);
ring_vm_funcregister("get_gl_object_plane",ring_get_gl_object_plane);
ring_vm_funcregister("get_gl_eye_plane",ring_get_gl_eye_plane);
ring_vm_funcregister("get_gl_nearest",ring_get_gl_nearest);
ring_vm_funcregister("get_gl_linear",ring_get_gl_linear);
ring_vm_funcregister("get_gl_nearest_mipmap_nearest",ring_get_gl_nearest_mipmap_nearest);
ring_vm_funcregister("get_gl_linear_mipmap_nearest",ring_get_gl_linear_mipmap_nearest);
ring_vm_funcregister("get_gl_nearest_mipmap_linear",ring_get_gl_nearest_mipmap_linear);
ring_vm_funcregister("get_gl_linear_mipmap_linear",ring_get_gl_linear_mipmap_linear);
ring_vm_funcregister("get_gl_texture_mag_filter",ring_get_gl_texture_mag_filter);
ring_vm_funcregister("get_gl_texture_min_filter",ring_get_gl_texture_min_filter);
ring_vm_funcregister("get_gl_texture_wrap_s",ring_get_gl_texture_wrap_s);
ring_vm_funcregister("get_gl_texture_wrap_t",ring_get_gl_texture_wrap_t);
ring_vm_funcregister("get_gl_clamp",ring_get_gl_clamp);
ring_vm_funcregister("get_gl_repeat",ring_get_gl_repeat);
ring_vm_funcregister("get_gl_polygon_offset_units",ring_get_gl_polygon_offset_units);
ring_vm_funcregister("get_gl_polygon_offset_point",ring_get_gl_polygon_offset_point);
ring_vm_funcregister("get_gl_polygon_offset_line",ring_get_gl_polygon_offset_line);
ring_vm_funcregister("get_gl_r3_g3_b2",ring_get_gl_r3_g3_b2);
ring_vm_funcregister("get_gl_v2f",ring_get_gl_v2f);
ring_vm_funcregister("get_gl_v3f",ring_get_gl_v3f);
ring_vm_funcregister("get_gl_c4ub_v2f",ring_get_gl_c4ub_v2f);
ring_vm_funcregister("get_gl_c4ub_v3f",ring_get_gl_c4ub_v3f);
ring_vm_funcregister("get_gl_c3f_v3f",ring_get_gl_c3f_v3f);
ring_vm_funcregister("get_gl_n3f_v3f",ring_get_gl_n3f_v3f);
ring_vm_funcregister("get_gl_c4f_n3f_v3f",ring_get_gl_c4f_n3f_v3f);
ring_vm_funcregister("get_gl_t2f_v3f",ring_get_gl_t2f_v3f);
ring_vm_funcregister("get_gl_t4f_v4f",ring_get_gl_t4f_v4f);
ring_vm_funcregister("get_gl_t2f_c4ub_v3f",ring_get_gl_t2f_c4ub_v3f);
ring_vm_funcregister("get_gl_t2f_c3f_v3f",ring_get_gl_t2f_c3f_v3f);
ring_vm_funcregister("get_gl_t2f_n3f_v3f",ring_get_gl_t2f_n3f_v3f);
ring_vm_funcregister("get_gl_t2f_c4f_n3f_v3f",ring_get_gl_t2f_c4f_n3f_v3f);
ring_vm_funcregister("get_gl_t4f_c4f_n3f_v4f",ring_get_gl_t4f_c4f_n3f_v4f);
ring_vm_funcregister("get_gl_clip_plane0",ring_get_gl_clip_plane0);
ring_vm_funcregister("get_gl_clip_plane1",ring_get_gl_clip_plane1);
ring_vm_funcregister("get_gl_clip_plane2",ring_get_gl_clip_plane2);
ring_vm_funcregister("get_gl_clip_plane3",ring_get_gl_clip_plane3);
ring_vm_funcregister("get_gl_clip_plane4",ring_get_gl_clip_plane4);
ring_vm_funcregister("get_gl_clip_plane5",ring_get_gl_clip_plane5);
ring_vm_funcregister("get_gl_light0",ring_get_gl_light0);
ring_vm_funcregister("get_gl_color_buffer_bit",ring_get_gl_color_buffer_bit);
ring_vm_funcregister("get_gl_light1",ring_get_gl_light1);
ring_vm_funcregister("get_gl_light2",ring_get_gl_light2);
ring_vm_funcregister("get_gl_light3",ring_get_gl_light3);
ring_vm_funcregister("get_gl_light4",ring_get_gl_light4);
ring_vm_funcregister("get_gl_light5",ring_get_gl_light5);
ring_vm_funcregister("get_gl_light6",ring_get_gl_light6);
ring_vm_funcregister("get_gl_light7",ring_get_gl_light7);
ring_vm_funcregister("get_gl_hint_bit",ring_get_gl_hint_bit);
ring_vm_funcregister("get_gl_polygon_offset_fill",ring_get_gl_polygon_offset_fill);
ring_vm_funcregister("get_gl_polygon_offset_factor",ring_get_gl_polygon_offset_factor);
ring_vm_funcregister("get_gl_alpha4",ring_get_gl_alpha4);
ring_vm_funcregister("get_gl_alpha8",ring_get_gl_alpha8);
ring_vm_funcregister("get_gl_alpha12",ring_get_gl_alpha12);
ring_vm_funcregister("get_gl_alpha16",ring_get_gl_alpha16);
ring_vm_funcregister("get_gl_luminance4",ring_get_gl_luminance4);
ring_vm_funcregister("get_gl_luminance8",ring_get_gl_luminance8);
ring_vm_funcregister("get_gl_luminance12",ring_get_gl_luminance12);
ring_vm_funcregister("get_gl_luminance16",ring_get_gl_luminance16);
ring_vm_funcregister("get_gl_luminance4_alpha4",ring_get_gl_luminance4_alpha4);
ring_vm_funcregister("get_gl_luminance6_alpha2",ring_get_gl_luminance6_alpha2);
ring_vm_funcregister("get_gl_luminance8_alpha8",ring_get_gl_luminance8_alpha8);
ring_vm_funcregister("get_gl_luminance12_alpha4",ring_get_gl_luminance12_alpha4);
ring_vm_funcregister("get_gl_luminance12_alpha12",ring_get_gl_luminance12_alpha12);
ring_vm_funcregister("get_gl_luminance16_alpha16",ring_get_gl_luminance16_alpha16);
ring_vm_funcregister("get_gl_intensity",ring_get_gl_intensity);
ring_vm_funcregister("get_gl_intensity4",ring_get_gl_intensity4);
ring_vm_funcregister("get_gl_intensity8",ring_get_gl_intensity8);
ring_vm_funcregister("get_gl_intensity12",ring_get_gl_intensity12);
ring_vm_funcregister("get_gl_intensity16",ring_get_gl_intensity16);
ring_vm_funcregister("get_gl_rgb4",ring_get_gl_rgb4);
ring_vm_funcregister("get_gl_rgb5",ring_get_gl_rgb5);
ring_vm_funcregister("get_gl_rgb8",ring_get_gl_rgb8);
ring_vm_funcregister("get_gl_rgb10",ring_get_gl_rgb10);
ring_vm_funcregister("get_gl_rgb12",ring_get_gl_rgb12);
ring_vm_funcregister("get_gl_rgb16",ring_get_gl_rgb16);
ring_vm_funcregister("get_gl_rgba2",ring_get_gl_rgba2);
ring_vm_funcregister("get_gl_rgba4",ring_get_gl_rgba4);
ring_vm_funcregister("get_gl_rgb5_a1",ring_get_gl_rgb5_a1);
ring_vm_funcregister("get_gl_rgba8",ring_get_gl_rgba8);
ring_vm_funcregister("get_gl_rgb10_a2",ring_get_gl_rgb10_a2);
ring_vm_funcregister("get_gl_rgba12",ring_get_gl_rgba12);
ring_vm_funcregister("get_gl_rgba16",ring_get_gl_rgba16);
ring_vm_funcregister("get_gl_texture_red_size",ring_get_gl_texture_red_size);
ring_vm_funcregister("get_gl_texture_green_size",ring_get_gl_texture_green_size);
ring_vm_funcregister("get_gl_texture_blue_size",ring_get_gl_texture_blue_size);
ring_vm_funcregister("get_gl_texture_alpha_size",ring_get_gl_texture_alpha_size);
ring_vm_funcregister("get_gl_texture_luminance_size",ring_get_gl_texture_luminance_size);
ring_vm_funcregister("get_gl_texture_intensity_size",ring_get_gl_texture_intensity_size);
ring_vm_funcregister("get_gl_proxy_texture_1d",ring_get_gl_proxy_texture_1d);
ring_vm_funcregister("get_gl_proxy_texture_2d",ring_get_gl_proxy_texture_2d);
ring_vm_funcregister("get_gl_texture_priority",ring_get_gl_texture_priority);
ring_vm_funcregister("get_gl_texture_resident",ring_get_gl_texture_resident);
ring_vm_funcregister("get_gl_texture_binding_1d",ring_get_gl_texture_binding_1d);
ring_vm_funcregister("get_gl_texture_binding_2d",ring_get_gl_texture_binding_2d);
ring_vm_funcregister("get_gl_vertex_array",ring_get_gl_vertex_array);
ring_vm_funcregister("get_gl_normal_array",ring_get_gl_normal_array);
ring_vm_funcregister("get_gl_color_array",ring_get_gl_color_array);
ring_vm_funcregister("get_gl_index_array",ring_get_gl_index_array);
ring_vm_funcregister("get_gl_texture_coord_array",ring_get_gl_texture_coord_array);
ring_vm_funcregister("get_gl_edge_flag_array",ring_get_gl_edge_flag_array);
ring_vm_funcregister("get_gl_vertex_array_size",ring_get_gl_vertex_array_size);
ring_vm_funcregister("get_gl_vertex_array_type",ring_get_gl_vertex_array_type);
ring_vm_funcregister("get_gl_vertex_array_stride",ring_get_gl_vertex_array_stride);
ring_vm_funcregister("get_gl_normal_array_type",ring_get_gl_normal_array_type);
ring_vm_funcregister("get_gl_normal_array_stride",ring_get_gl_normal_array_stride);
ring_vm_funcregister("get_gl_color_array_size",ring_get_gl_color_array_size);
ring_vm_funcregister("get_gl_color_array_type",ring_get_gl_color_array_type);
ring_vm_funcregister("get_gl_color_array_stride",ring_get_gl_color_array_stride);
ring_vm_funcregister("get_gl_index_array_type",ring_get_gl_index_array_type);
ring_vm_funcregister("get_gl_index_array_stride",ring_get_gl_index_array_stride);
ring_vm_funcregister("get_gl_texture_coord_array_size",ring_get_gl_texture_coord_array_size);
ring_vm_funcregister("get_gl_texture_coord_array_type",ring_get_gl_texture_coord_array_type);
ring_vm_funcregister("get_gl_texture_coord_array_stride",ring_get_gl_texture_coord_array_stride);
ring_vm_funcregister("get_gl_edge_flag_array_stride",ring_get_gl_edge_flag_array_stride);
ring_vm_funcregister("get_gl_vertex_array_pointer",ring_get_gl_vertex_array_pointer);
ring_vm_funcregister("get_gl_normal_array_pointer",ring_get_gl_normal_array_pointer);
ring_vm_funcregister("get_gl_color_array_pointer",ring_get_gl_color_array_pointer);
ring_vm_funcregister("get_gl_index_array_pointer",ring_get_gl_index_array_pointer);
ring_vm_funcregister("get_gl_texture_coord_array_pointer",ring_get_gl_texture_coord_array_pointer);
ring_vm_funcregister("get_gl_edge_flag_array_pointer",ring_get_gl_edge_flag_array_pointer);
ring_vm_funcregister("get_gl_color_index1_ext",ring_get_gl_color_index1_ext);
ring_vm_funcregister("get_gl_color_index2_ext",ring_get_gl_color_index2_ext);
ring_vm_funcregister("get_gl_color_index4_ext",ring_get_gl_color_index4_ext);
ring_vm_funcregister("get_gl_color_index8_ext",ring_get_gl_color_index8_ext);
ring_vm_funcregister("get_gl_color_index12_ext",ring_get_gl_color_index12_ext);
ring_vm_funcregister("get_gl_color_index16_ext",ring_get_gl_color_index16_ext);
ring_vm_funcregister("get_gl_eval_bit",ring_get_gl_eval_bit);
ring_vm_funcregister("get_gl_list_bit",ring_get_gl_list_bit);
ring_vm_funcregister("get_gl_texture_bit",ring_get_gl_texture_bit);
ring_vm_funcregister("get_gl_scissor_bit",ring_get_gl_scissor_bit);
ring_vm_funcregister("get_gl_all_attrib_bits",ring_get_gl_all_attrib_bits);
ring_vm_funcregister("get_gl_client_all_attrib_bits",ring_get_gl_client_all_attrib_bits);
ring_vm_funcregister("get_gl_smooth_point_size_range",ring_get_gl_smooth_point_size_range);
ring_vm_funcregister("get_gl_smooth_point_size_granularity",ring_get_gl_smooth_point_size_granularity);
ring_vm_funcregister("get_gl_smooth_line_width_range",ring_get_gl_smooth_line_width_range);
ring_vm_funcregister("get_gl_smooth_line_width_granularity",ring_get_gl_smooth_line_width_granularity);
ring_vm_funcregister("get_gl_unsigned_byte_3_3_2",ring_get_gl_unsigned_byte_3_3_2);
ring_vm_funcregister("get_gl_unsigned_short_4_4_4_4",ring_get_gl_unsigned_short_4_4_4_4);
ring_vm_funcregister("get_gl_unsigned_short_5_5_5_1",ring_get_gl_unsigned_short_5_5_5_1);
ring_vm_funcregister("get_gl_unsigned_int_8_8_8_8",ring_get_gl_unsigned_int_8_8_8_8);
ring_vm_funcregister("get_gl_unsigned_int_10_10_10_2",ring_get_gl_unsigned_int_10_10_10_2);
ring_vm_funcregister("get_gl_rescale_normal",ring_get_gl_rescale_normal);
ring_vm_funcregister("get_gl_texture_binding_3d",ring_get_gl_texture_binding_3d);
ring_vm_funcregister("get_gl_pack_skip_images",ring_get_gl_pack_skip_images);
ring_vm_funcregister("get_gl_pack_image_height",ring_get_gl_pack_image_height);
ring_vm_funcregister("get_gl_unpack_skip_images",ring_get_gl_unpack_skip_images);
ring_vm_funcregister("get_gl_unpack_image_height",ring_get_gl_unpack_image_height);
ring_vm_funcregister("get_gl_texture_3d",ring_get_gl_texture_3d);
ring_vm_funcregister("get_gl_proxy_texture_3d",ring_get_gl_proxy_texture_3d);
ring_vm_funcregister("get_gl_texture_depth",ring_get_gl_texture_depth);
ring_vm_funcregister("get_gl_texture_wrap_r",ring_get_gl_texture_wrap_r);
ring_vm_funcregister("get_gl_max_3d_texture_size",ring_get_gl_max_3d_texture_size);
ring_vm_funcregister("get_gl_bgr",ring_get_gl_bgr);
ring_vm_funcregister("get_gl_bgra",ring_get_gl_bgra);
ring_vm_funcregister("get_gl_max_elements_vertices",ring_get_gl_max_elements_vertices);
ring_vm_funcregister("get_gl_max_elements_indices",ring_get_gl_max_elements_indices);
ring_vm_funcregister("get_gl_clamp_to_edge",ring_get_gl_clamp_to_edge);
ring_vm_funcregister("get_gl_texture_min_lod",ring_get_gl_texture_min_lod);
ring_vm_funcregister("get_gl_texture_max_lod",ring_get_gl_texture_max_lod);
ring_vm_funcregister("get_gl_texture_base_level",ring_get_gl_texture_base_level);
ring_vm_funcregister("get_gl_texture_max_level",ring_get_gl_texture_max_level);
ring_vm_funcregister("get_gl_light_model_color_control",ring_get_gl_light_model_color_control);
ring_vm_funcregister("get_gl_single_color",ring_get_gl_single_color);
ring_vm_funcregister("get_gl_separate_specular_color",ring_get_gl_separate_specular_color);
ring_vm_funcregister("get_gl_unsigned_byte_2_3_3_rev",ring_get_gl_unsigned_byte_2_3_3_rev);
ring_vm_funcregister("get_gl_unsigned_short_5_6_5",ring_get_gl_unsigned_short_5_6_5);
ring_vm_funcregister("get_gl_unsigned_short_5_6_5_rev",ring_get_gl_unsigned_short_5_6_5_rev);
ring_vm_funcregister("get_gl_unsigned_short_4_4_4_4_rev",ring_get_gl_unsigned_short_4_4_4_4_rev);
ring_vm_funcregister("get_gl_unsigned_short_1_5_5_5_rev",ring_get_gl_unsigned_short_1_5_5_5_rev);
ring_vm_funcregister("get_gl_unsigned_int_8_8_8_8_rev",ring_get_gl_unsigned_int_8_8_8_8_rev);
ring_vm_funcregister("get_gl_aliased_point_size_range",ring_get_gl_aliased_point_size_range);
ring_vm_funcregister("get_gl_aliased_line_width_range",ring_get_gl_aliased_line_width_range);
ring_vm_funcregister("get_gl_multisample",ring_get_gl_multisample);
ring_vm_funcregister("get_gl_sample_alpha_to_coverage",ring_get_gl_sample_alpha_to_coverage);
ring_vm_funcregister("get_gl_sample_alpha_to_one",ring_get_gl_sample_alpha_to_one);
ring_vm_funcregister("get_gl_sample_coverage",ring_get_gl_sample_coverage);
ring_vm_funcregister("get_gl_sample_buffers",ring_get_gl_sample_buffers);
ring_vm_funcregister("get_gl_samples",ring_get_gl_samples);
ring_vm_funcregister("get_gl_sample_coverage_value",ring_get_gl_sample_coverage_value);
ring_vm_funcregister("get_gl_sample_coverage_invert",ring_get_gl_sample_coverage_invert);
ring_vm_funcregister("get_gl_clamp_to_border",ring_get_gl_clamp_to_border);
ring_vm_funcregister("get_gl_texture0",ring_get_gl_texture0);
ring_vm_funcregister("get_gl_texture1",ring_get_gl_texture1);
ring_vm_funcregister("get_gl_texture2",ring_get_gl_texture2);
ring_vm_funcregister("get_gl_texture3",ring_get_gl_texture3);
ring_vm_funcregister("get_gl_texture4",ring_get_gl_texture4);
ring_vm_funcregister("get_gl_texture5",ring_get_gl_texture5);
ring_vm_funcregister("get_gl_texture6",ring_get_gl_texture6);
ring_vm_funcregister("get_gl_texture7",ring_get_gl_texture7);
ring_vm_funcregister("get_gl_texture8",ring_get_gl_texture8);
ring_vm_funcregister("get_gl_texture9",ring_get_gl_texture9);
ring_vm_funcregister("get_gl_texture10",ring_get_gl_texture10);
ring_vm_funcregister("get_gl_texture11",ring_get_gl_texture11);
ring_vm_funcregister("get_gl_texture12",ring_get_gl_texture12);
ring_vm_funcregister("get_gl_texture13",ring_get_gl_texture13);
ring_vm_funcregister("get_gl_texture14",ring_get_gl_texture14);
ring_vm_funcregister("get_gl_texture15",ring_get_gl_texture15);
ring_vm_funcregister("get_gl_texture16",ring_get_gl_texture16);
ring_vm_funcregister("get_gl_texture17",ring_get_gl_texture17);
ring_vm_funcregister("get_gl_texture18",ring_get_gl_texture18);
ring_vm_funcregister("get_gl_texture19",ring_get_gl_texture19);
ring_vm_funcregister("get_gl_texture20",ring_get_gl_texture20);
ring_vm_funcregister("get_gl_texture21",ring_get_gl_texture21);
ring_vm_funcregister("get_gl_texture22",ring_get_gl_texture22);
ring_vm_funcregister("get_gl_texture23",ring_get_gl_texture23);
ring_vm_funcregister("get_gl_texture24",ring_get_gl_texture24);
ring_vm_funcregister("get_gl_texture25",ring_get_gl_texture25);
ring_vm_funcregister("get_gl_texture26",ring_get_gl_texture26);
ring_vm_funcregister("get_gl_texture27",ring_get_gl_texture27);
ring_vm_funcregister("get_gl_texture28",ring_get_gl_texture28);
ring_vm_funcregister("get_gl_texture29",ring_get_gl_texture29);
ring_vm_funcregister("get_gl_texture30",ring_get_gl_texture30);
ring_vm_funcregister("get_gl_texture31",ring_get_gl_texture31);
ring_vm_funcregister("get_gl_active_texture",ring_get_gl_active_texture);
ring_vm_funcregister("get_gl_client_active_texture",ring_get_gl_client_active_texture);
ring_vm_funcregister("get_gl_max_texture_units",ring_get_gl_max_texture_units);
ring_vm_funcregister("get_gl_transpose_modelview_matrix",ring_get_gl_transpose_modelview_matrix);
ring_vm_funcregister("get_gl_transpose_projection_matrix",ring_get_gl_transpose_projection_matrix);
ring_vm_funcregister("get_gl_transpose_texture_matrix",ring_get_gl_transpose_texture_matrix);
ring_vm_funcregister("get_gl_transpose_color_matrix",ring_get_gl_transpose_color_matrix);
ring_vm_funcregister("get_gl_subtract",ring_get_gl_subtract);
ring_vm_funcregister("get_gl_compressed_alpha",ring_get_gl_compressed_alpha);
ring_vm_funcregister("get_gl_compressed_luminance",ring_get_gl_compressed_luminance);
ring_vm_funcregister("get_gl_compressed_luminance_alpha",ring_get_gl_compressed_luminance_alpha);
ring_vm_funcregister("get_gl_compressed_intensity",ring_get_gl_compressed_intensity);
ring_vm_funcregister("get_gl_compressed_rgb",ring_get_gl_compressed_rgb);
ring_vm_funcregister("get_gl_compressed_rgba",ring_get_gl_compressed_rgba);
ring_vm_funcregister("get_gl_texture_compression_hint",ring_get_gl_texture_compression_hint);
ring_vm_funcregister("get_gl_normal_map",ring_get_gl_normal_map);
ring_vm_funcregister("get_gl_reflection_map",ring_get_gl_reflection_map);
ring_vm_funcregister("get_gl_texture_cube_map",ring_get_gl_texture_cube_map);
ring_vm_funcregister("get_gl_texture_binding_cube_map",ring_get_gl_texture_binding_cube_map);
ring_vm_funcregister("get_gl_texture_cube_map_positive_x",ring_get_gl_texture_cube_map_positive_x);
ring_vm_funcregister("get_gl_texture_cube_map_negative_x",ring_get_gl_texture_cube_map_negative_x);
ring_vm_funcregister("get_gl_texture_cube_map_positive_y",ring_get_gl_texture_cube_map_positive_y);
ring_vm_funcregister("get_gl_texture_cube_map_negative_y",ring_get_gl_texture_cube_map_negative_y);
ring_vm_funcregister("get_gl_texture_cube_map_positive_z",ring_get_gl_texture_cube_map_positive_z);
ring_vm_funcregister("get_gl_texture_cube_map_negative_z",ring_get_gl_texture_cube_map_negative_z);
ring_vm_funcregister("get_gl_proxy_texture_cube_map",ring_get_gl_proxy_texture_cube_map);
ring_vm_funcregister("get_gl_max_cube_map_texture_size",ring_get_gl_max_cube_map_texture_size);
ring_vm_funcregister("get_gl_combine",ring_get_gl_combine);
ring_vm_funcregister("get_gl_combine_rgb",ring_get_gl_combine_rgb);
ring_vm_funcregister("get_gl_combine_alpha",ring_get_gl_combine_alpha);
ring_vm_funcregister("get_gl_rgb_scale",ring_get_gl_rgb_scale);
ring_vm_funcregister("get_gl_add_signed",ring_get_gl_add_signed);
ring_vm_funcregister("get_gl_interpolate",ring_get_gl_interpolate);
ring_vm_funcregister("get_gl_constant",ring_get_gl_constant);
ring_vm_funcregister("get_gl_primary_color",ring_get_gl_primary_color);
ring_vm_funcregister("get_gl_previous",ring_get_gl_previous);
ring_vm_funcregister("get_gl_source0_rgb",ring_get_gl_source0_rgb);
ring_vm_funcregister("get_gl_source1_rgb",ring_get_gl_source1_rgb);
ring_vm_funcregister("get_gl_source2_rgb",ring_get_gl_source2_rgb);
ring_vm_funcregister("get_gl_source0_alpha",ring_get_gl_source0_alpha);
ring_vm_funcregister("get_gl_source1_alpha",ring_get_gl_source1_alpha);
ring_vm_funcregister("get_gl_source2_alpha",ring_get_gl_source2_alpha);
ring_vm_funcregister("get_gl_operand0_rgb",ring_get_gl_operand0_rgb);
ring_vm_funcregister("get_gl_operand1_rgb",ring_get_gl_operand1_rgb);
ring_vm_funcregister("get_gl_operand2_rgb",ring_get_gl_operand2_rgb);
ring_vm_funcregister("get_gl_operand0_alpha",ring_get_gl_operand0_alpha);
ring_vm_funcregister("get_gl_operand1_alpha",ring_get_gl_operand1_alpha);
ring_vm_funcregister("get_gl_operand2_alpha",ring_get_gl_operand2_alpha);
ring_vm_funcregister("get_gl_texture_compressed_image_size",ring_get_gl_texture_compressed_image_size);
ring_vm_funcregister("get_gl_texture_compressed",ring_get_gl_texture_compressed);
ring_vm_funcregister("get_gl_num_compressed_texture_formats",ring_get_gl_num_compressed_texture_formats);
ring_vm_funcregister("get_gl_compressed_texture_formats",ring_get_gl_compressed_texture_formats);
ring_vm_funcregister("get_gl_dot3_rgb",ring_get_gl_dot3_rgb);
ring_vm_funcregister("get_gl_dot3_rgba",ring_get_gl_dot3_rgba);
ring_vm_funcregister("get_gl_multisample_bit",ring_get_gl_multisample_bit);
ring_vm_funcregister("get_gl_blend_dst_rgb",ring_get_gl_blend_dst_rgb);
ring_vm_funcregister("get_gl_blend_src_rgb",ring_get_gl_blend_src_rgb);
ring_vm_funcregister("get_gl_blend_dst_alpha",ring_get_gl_blend_dst_alpha);
ring_vm_funcregister("get_gl_blend_src_alpha",ring_get_gl_blend_src_alpha);
ring_vm_funcregister("get_gl_point_size_min",ring_get_gl_point_size_min);
ring_vm_funcregister("get_gl_point_size_max",ring_get_gl_point_size_max);
ring_vm_funcregister("get_gl_point_fade_threshold_size",ring_get_gl_point_fade_threshold_size);
ring_vm_funcregister("get_gl_point_distance_attenuation",ring_get_gl_point_distance_attenuation);
ring_vm_funcregister("get_gl_generate_mipmap",ring_get_gl_generate_mipmap);
ring_vm_funcregister("get_gl_generate_mipmap_hint",ring_get_gl_generate_mipmap_hint);
ring_vm_funcregister("get_gl_depth_component16",ring_get_gl_depth_component16);
ring_vm_funcregister("get_gl_depth_component24",ring_get_gl_depth_component24);
ring_vm_funcregister("get_gl_depth_component32",ring_get_gl_depth_component32);
ring_vm_funcregister("get_gl_mirrored_repeat",ring_get_gl_mirrored_repeat);
ring_vm_funcregister("get_gl_fog_coordinate_source",ring_get_gl_fog_coordinate_source);
ring_vm_funcregister("get_gl_fog_coordinate",ring_get_gl_fog_coordinate);
ring_vm_funcregister("get_gl_fragment_depth",ring_get_gl_fragment_depth);
ring_vm_funcregister("get_gl_current_fog_coordinate",ring_get_gl_current_fog_coordinate);
ring_vm_funcregister("get_gl_fog_coordinate_array_type",ring_get_gl_fog_coordinate_array_type);
ring_vm_funcregister("get_gl_fog_coordinate_array_stride",ring_get_gl_fog_coordinate_array_stride);
ring_vm_funcregister("get_gl_fog_coordinate_array_pointer",ring_get_gl_fog_coordinate_array_pointer);
ring_vm_funcregister("get_gl_fog_coordinate_array",ring_get_gl_fog_coordinate_array);
ring_vm_funcregister("get_gl_color_sum",ring_get_gl_color_sum);
ring_vm_funcregister("get_gl_current_secondary_color",ring_get_gl_current_secondary_color);
ring_vm_funcregister("get_gl_secondary_color_array_size",ring_get_gl_secondary_color_array_size);
ring_vm_funcregister("get_gl_secondary_color_array_type",ring_get_gl_secondary_color_array_type);
ring_vm_funcregister("get_gl_secondary_color_array_stride",ring_get_gl_secondary_color_array_stride);
ring_vm_funcregister("get_gl_secondary_color_array_pointer",ring_get_gl_secondary_color_array_pointer);
ring_vm_funcregister("get_gl_secondary_color_array",ring_get_gl_secondary_color_array);
ring_vm_funcregister("get_gl_max_texture_lod_bias",ring_get_gl_max_texture_lod_bias);
ring_vm_funcregister("get_gl_texture_filter_control",ring_get_gl_texture_filter_control);
ring_vm_funcregister("get_gl_texture_lod_bias",ring_get_gl_texture_lod_bias);
ring_vm_funcregister("get_gl_incr_wrap",ring_get_gl_incr_wrap);
ring_vm_funcregister("get_gl_decr_wrap",ring_get_gl_decr_wrap);
ring_vm_funcregister("get_gl_texture_depth_size",ring_get_gl_texture_depth_size);
ring_vm_funcregister("get_gl_depth_texture_mode",ring_get_gl_depth_texture_mode);
ring_vm_funcregister("get_gl_texture_compare_mode",ring_get_gl_texture_compare_mode);
ring_vm_funcregister("get_gl_texture_compare_func",ring_get_gl_texture_compare_func);
ring_vm_funcregister("get_gl_compare_r_to_texture",ring_get_gl_compare_r_to_texture);
ring_vm_funcregister("get_gl_current_fog_coord",ring_get_gl_current_fog_coord);
ring_vm_funcregister("get_gl_fog_coord",ring_get_gl_fog_coord);
ring_vm_funcregister("get_gl_fog_coord_array",ring_get_gl_fog_coord_array);
ring_vm_funcregister("get_gl_fog_coord_array_buffer_binding",ring_get_gl_fog_coord_array_buffer_binding);
ring_vm_funcregister("get_gl_fog_coord_array_pointer",ring_get_gl_fog_coord_array_pointer);
ring_vm_funcregister("get_gl_fog_coord_array_stride",ring_get_gl_fog_coord_array_stride);
ring_vm_funcregister("get_gl_fog_coord_array_type",ring_get_gl_fog_coord_array_type);
ring_vm_funcregister("get_gl_fog_coord_src",ring_get_gl_fog_coord_src);
ring_vm_funcregister("get_gl_src0_alpha",ring_get_gl_src0_alpha);
ring_vm_funcregister("get_gl_src0_rgb",ring_get_gl_src0_rgb);
ring_vm_funcregister("get_gl_src1_alpha",ring_get_gl_src1_alpha);
ring_vm_funcregister("get_gl_src1_rgb",ring_get_gl_src1_rgb);
ring_vm_funcregister("get_gl_src2_alpha",ring_get_gl_src2_alpha);
ring_vm_funcregister("get_gl_src2_rgb",ring_get_gl_src2_rgb);
ring_vm_funcregister("get_gl_buffer_size",ring_get_gl_buffer_size);
ring_vm_funcregister("get_gl_buffer_usage",ring_get_gl_buffer_usage);
ring_vm_funcregister("get_gl_query_counter_bits",ring_get_gl_query_counter_bits);
ring_vm_funcregister("get_gl_current_query",ring_get_gl_current_query);
ring_vm_funcregister("get_gl_query_result",ring_get_gl_query_result);
ring_vm_funcregister("get_gl_query_result_available",ring_get_gl_query_result_available);
ring_vm_funcregister("get_gl_array_buffer",ring_get_gl_array_buffer);
ring_vm_funcregister("get_gl_element_array_buffer",ring_get_gl_element_array_buffer);
ring_vm_funcregister("get_gl_array_buffer_binding",ring_get_gl_array_buffer_binding);
ring_vm_funcregister("get_gl_element_array_buffer_binding",ring_get_gl_element_array_buffer_binding);
ring_vm_funcregister("get_gl_vertex_array_buffer_binding",ring_get_gl_vertex_array_buffer_binding);
ring_vm_funcregister("get_gl_normal_array_buffer_binding",ring_get_gl_normal_array_buffer_binding);
ring_vm_funcregister("get_gl_color_array_buffer_binding",ring_get_gl_color_array_buffer_binding);
ring_vm_funcregister("get_gl_index_array_buffer_binding",ring_get_gl_index_array_buffer_binding);
ring_vm_funcregister("get_gl_texture_coord_array_buffer_binding",ring_get_gl_texture_coord_array_buffer_binding);
ring_vm_funcregister("get_gl_edge_flag_array_buffer_binding",ring_get_gl_edge_flag_array_buffer_binding);
ring_vm_funcregister("get_gl_secondary_color_array_buffer_binding",ring_get_gl_secondary_color_array_buffer_binding);
ring_vm_funcregister("get_gl_fog_coordinate_array_buffer_binding",ring_get_gl_fog_coordinate_array_buffer_binding);
ring_vm_funcregister("get_gl_weight_array_buffer_binding",ring_get_gl_weight_array_buffer_binding);
ring_vm_funcregister("get_gl_vertex_attrib_array_buffer_binding",ring_get_gl_vertex_attrib_array_buffer_binding);
ring_vm_funcregister("get_gl_read_only",ring_get_gl_read_only);
ring_vm_funcregister("get_gl_write_only",ring_get_gl_write_only);
ring_vm_funcregister("get_gl_read_write",ring_get_gl_read_write);
ring_vm_funcregister("get_gl_buffer_access",ring_get_gl_buffer_access);
ring_vm_funcregister("get_gl_buffer_mapped",ring_get_gl_buffer_mapped);
ring_vm_funcregister("get_gl_buffer_map_pointer",ring_get_gl_buffer_map_pointer);
ring_vm_funcregister("get_gl_stream_draw",ring_get_gl_stream_draw);
ring_vm_funcregister("get_gl_stream_read",ring_get_gl_stream_read);
ring_vm_funcregister("get_gl_stream_copy",ring_get_gl_stream_copy);
ring_vm_funcregister("get_gl_static_draw",ring_get_gl_static_draw);
ring_vm_funcregister("get_gl_static_read",ring_get_gl_static_read);
ring_vm_funcregister("get_gl_static_copy",ring_get_gl_static_copy);
ring_vm_funcregister("get_gl_dynamic_draw",ring_get_gl_dynamic_draw);
ring_vm_funcregister("get_gl_dynamic_read",ring_get_gl_dynamic_read);
ring_vm_funcregister("get_gl_dynamic_copy",ring_get_gl_dynamic_copy);
ring_vm_funcregister("get_gl_samples_passed",ring_get_gl_samples_passed);
ring_vm_funcregister("get_gl_blend_equation_rgb",ring_get_gl_blend_equation_rgb);
ring_vm_funcregister("get_gl_vertex_attrib_array_enabled",ring_get_gl_vertex_attrib_array_enabled);
ring_vm_funcregister("get_gl_vertex_attrib_array_size",ring_get_gl_vertex_attrib_array_size);
ring_vm_funcregister("get_gl_vertex_attrib_array_stride",ring_get_gl_vertex_attrib_array_stride);
ring_vm_funcregister("get_gl_vertex_attrib_array_type",ring_get_gl_vertex_attrib_array_type);
ring_vm_funcregister("get_gl_current_vertex_attrib",ring_get_gl_current_vertex_attrib);
ring_vm_funcregister("get_gl_vertex_program_point_size",ring_get_gl_vertex_program_point_size);
ring_vm_funcregister("get_gl_vertex_program_two_side",ring_get_gl_vertex_program_two_side);
ring_vm_funcregister("get_gl_vertex_attrib_array_pointer",ring_get_gl_vertex_attrib_array_pointer);
ring_vm_funcregister("get_gl_stencil_back_func",ring_get_gl_stencil_back_func);
ring_vm_funcregister("get_gl_stencil_back_fail",ring_get_gl_stencil_back_fail);
ring_vm_funcregister("get_gl_stencil_back_pass_depth_fail",ring_get_gl_stencil_back_pass_depth_fail);
ring_vm_funcregister("get_gl_stencil_back_pass_depth_pass",ring_get_gl_stencil_back_pass_depth_pass);
ring_vm_funcregister("get_gl_max_draw_buffers",ring_get_gl_max_draw_buffers);
ring_vm_funcregister("get_gl_draw_buffer0",ring_get_gl_draw_buffer0);
ring_vm_funcregister("get_gl_draw_buffer1",ring_get_gl_draw_buffer1);
ring_vm_funcregister("get_gl_draw_buffer2",ring_get_gl_draw_buffer2);
ring_vm_funcregister("get_gl_draw_buffer3",ring_get_gl_draw_buffer3);
ring_vm_funcregister("get_gl_draw_buffer4",ring_get_gl_draw_buffer4);
ring_vm_funcregister("get_gl_draw_buffer5",ring_get_gl_draw_buffer5);
ring_vm_funcregister("get_gl_draw_buffer6",ring_get_gl_draw_buffer6);
ring_vm_funcregister("get_gl_draw_buffer7",ring_get_gl_draw_buffer7);
ring_vm_funcregister("get_gl_draw_buffer8",ring_get_gl_draw_buffer8);
ring_vm_funcregister("get_gl_draw_buffer9",ring_get_gl_draw_buffer9);
ring_vm_funcregister("get_gl_draw_buffer10",ring_get_gl_draw_buffer10);
ring_vm_funcregister("get_gl_draw_buffer11",ring_get_gl_draw_buffer11);
ring_vm_funcregister("get_gl_draw_buffer12",ring_get_gl_draw_buffer12);
ring_vm_funcregister("get_gl_draw_buffer13",ring_get_gl_draw_buffer13);
ring_vm_funcregister("get_gl_draw_buffer14",ring_get_gl_draw_buffer14);
ring_vm_funcregister("get_gl_draw_buffer15",ring_get_gl_draw_buffer15);
ring_vm_funcregister("get_gl_blend_equation_alpha",ring_get_gl_blend_equation_alpha);
ring_vm_funcregister("get_gl_point_sprite",ring_get_gl_point_sprite);
ring_vm_funcregister("get_gl_coord_replace",ring_get_gl_coord_replace);
ring_vm_funcregister("get_gl_max_vertex_attribs",ring_get_gl_max_vertex_attribs);
ring_vm_funcregister("get_gl_vertex_attrib_array_normalized",ring_get_gl_vertex_attrib_array_normalized);
ring_vm_funcregister("get_gl_max_texture_coords",ring_get_gl_max_texture_coords);
ring_vm_funcregister("get_gl_max_texture_image_units",ring_get_gl_max_texture_image_units);
ring_vm_funcregister("get_gl_fragment_shader",ring_get_gl_fragment_shader);
ring_vm_funcregister("get_gl_vertex_shader",ring_get_gl_vertex_shader);
ring_vm_funcregister("get_gl_max_fragment_uniform_components",ring_get_gl_max_fragment_uniform_components);
ring_vm_funcregister("get_gl_max_vertex_uniform_components",ring_get_gl_max_vertex_uniform_components);
ring_vm_funcregister("get_gl_max_varying_floats",ring_get_gl_max_varying_floats);
ring_vm_funcregister("get_gl_max_vertex_texture_image_units",ring_get_gl_max_vertex_texture_image_units);
ring_vm_funcregister("get_gl_max_combined_texture_image_units",ring_get_gl_max_combined_texture_image_units);
ring_vm_funcregister("get_gl_shader_type",ring_get_gl_shader_type);
ring_vm_funcregister("get_gl_float_vec2",ring_get_gl_float_vec2);
ring_vm_funcregister("get_gl_float_vec3",ring_get_gl_float_vec3);
ring_vm_funcregister("get_gl_float_vec4",ring_get_gl_float_vec4);
ring_vm_funcregister("get_gl_int_vec2",ring_get_gl_int_vec2);
ring_vm_funcregister("get_gl_int_vec3",ring_get_gl_int_vec3);
ring_vm_funcregister("get_gl_int_vec4",ring_get_gl_int_vec4);
ring_vm_funcregister("get_gl_bool",ring_get_gl_bool);
ring_vm_funcregister("get_gl_bool_vec2",ring_get_gl_bool_vec2);
ring_vm_funcregister("get_gl_bool_vec3",ring_get_gl_bool_vec3);
ring_vm_funcregister("get_gl_bool_vec4",ring_get_gl_bool_vec4);
ring_vm_funcregister("get_gl_float_mat2",ring_get_gl_float_mat2);
ring_vm_funcregister("get_gl_float_mat3",ring_get_gl_float_mat3);
ring_vm_funcregister("get_gl_float_mat4",ring_get_gl_float_mat4);
ring_vm_funcregister("get_gl_sampler_1d",ring_get_gl_sampler_1d);
ring_vm_funcregister("get_gl_sampler_2d",ring_get_gl_sampler_2d);
ring_vm_funcregister("get_gl_sampler_3d",ring_get_gl_sampler_3d);
ring_vm_funcregister("get_gl_sampler_cube",ring_get_gl_sampler_cube);
ring_vm_funcregister("get_gl_sampler_1d_shadow",ring_get_gl_sampler_1d_shadow);
ring_vm_funcregister("get_gl_sampler_2d_shadow",ring_get_gl_sampler_2d_shadow);
ring_vm_funcregister("get_gl_delete_status",ring_get_gl_delete_status);
ring_vm_funcregister("get_gl_compile_status",ring_get_gl_compile_status);
ring_vm_funcregister("get_gl_link_status",ring_get_gl_link_status);
ring_vm_funcregister("get_gl_validate_status",ring_get_gl_validate_status);
ring_vm_funcregister("get_gl_info_log_length",ring_get_gl_info_log_length);
ring_vm_funcregister("get_gl_attached_shaders",ring_get_gl_attached_shaders);
ring_vm_funcregister("get_gl_active_uniforms",ring_get_gl_active_uniforms);
ring_vm_funcregister("get_gl_active_uniform_max_length",ring_get_gl_active_uniform_max_length);
ring_vm_funcregister("get_gl_shader_source_length",ring_get_gl_shader_source_length);
ring_vm_funcregister("get_gl_active_attributes",ring_get_gl_active_attributes);
ring_vm_funcregister("get_gl_active_attribute_max_length",ring_get_gl_active_attribute_max_length);
ring_vm_funcregister("get_gl_fragment_shader_derivative_hint",ring_get_gl_fragment_shader_derivative_hint);
ring_vm_funcregister("get_gl_shading_language_version",ring_get_gl_shading_language_version);
ring_vm_funcregister("get_gl_current_program",ring_get_gl_current_program);
ring_vm_funcregister("get_gl_point_sprite_coord_origin",ring_get_gl_point_sprite_coord_origin);
ring_vm_funcregister("get_gl_lower_left",ring_get_gl_lower_left);
ring_vm_funcregister("get_gl_upper_left",ring_get_gl_upper_left);
ring_vm_funcregister("get_gl_stencil_back_ref",ring_get_gl_stencil_back_ref);
ring_vm_funcregister("get_gl_stencil_back_value_mask",ring_get_gl_stencil_back_value_mask);
ring_vm_funcregister("get_gl_stencil_back_writemask",ring_get_gl_stencil_back_writemask);
ring_vm_funcregister("get_gl_current_raster_secondary_color",ring_get_gl_current_raster_secondary_color);
ring_vm_funcregister("get_gl_pixel_pack_buffer",ring_get_gl_pixel_pack_buffer);
ring_vm_funcregister("get_gl_pixel_unpack_buffer",ring_get_gl_pixel_unpack_buffer);
ring_vm_funcregister("get_gl_pixel_pack_buffer_binding",ring_get_gl_pixel_pack_buffer_binding);
ring_vm_funcregister("get_gl_pixel_unpack_buffer_binding",ring_get_gl_pixel_unpack_buffer_binding);
ring_vm_funcregister("get_gl_float_mat2x3",ring_get_gl_float_mat2x3);
ring_vm_funcregister("get_gl_float_mat2x4",ring_get_gl_float_mat2x4);
ring_vm_funcregister("get_gl_float_mat3x2",ring_get_gl_float_mat3x2);
ring_vm_funcregister("get_gl_float_mat3x4",ring_get_gl_float_mat3x4);
ring_vm_funcregister("get_gl_float_mat4x2",ring_get_gl_float_mat4x2);
ring_vm_funcregister("get_gl_float_mat4x3",ring_get_gl_float_mat4x3);
ring_vm_funcregister("get_gl_srgb",ring_get_gl_srgb);
ring_vm_funcregister("get_gl_srgb8",ring_get_gl_srgb8);
ring_vm_funcregister("get_gl_srgb_alpha",ring_get_gl_srgb_alpha);
ring_vm_funcregister("get_gl_srgb8_alpha8",ring_get_gl_srgb8_alpha8);
ring_vm_funcregister("get_gl_sluminance_alpha",ring_get_gl_sluminance_alpha);
ring_vm_funcregister("get_gl_sluminance8_alpha8",ring_get_gl_sluminance8_alpha8);
ring_vm_funcregister("get_gl_sluminance",ring_get_gl_sluminance);
ring_vm_funcregister("get_gl_sluminance8",ring_get_gl_sluminance8);
ring_vm_funcregister("get_gl_compressed_srgb",ring_get_gl_compressed_srgb);
ring_vm_funcregister("get_gl_compressed_srgb_alpha",ring_get_gl_compressed_srgb_alpha);
ring_vm_funcregister("get_gl_compressed_sluminance",ring_get_gl_compressed_sluminance);
ring_vm_funcregister("get_gl_compressed_sluminance_alpha",ring_get_gl_compressed_sluminance_alpha);
}
|
480702.c | /*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| [email protected] so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Brad Lafountain <[email protected]> |
| Shane Caraveo <[email protected]> |
| Dmitry Stogov <[email protected]> |
+----------------------------------------------------------------------+
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "php_soap.h"
#if HAVE_PHP_SESSION && !defined(COMPILE_DL_SESSION)
#include "ext/session/php_session.h"
#endif
#include "soap_arginfo.h"
#include "zend_exceptions.h"
static int le_sdl = 0;
int le_url = 0;
static int le_service = 0;
static int le_typemap = 0;
typedef struct _soapHeader {
sdlFunctionPtr function;
zval function_name;
int mustUnderstand;
int num_params;
zval *parameters;
zval retval;
sdlSoapBindingFunctionHeaderPtr hdr;
struct _soapHeader *next;
} soapHeader;
/* Local functions */
static void function_to_string(sdlFunctionPtr function, smart_str *buf);
static void type_to_string(sdlTypePtr type, smart_str *buf, int level);
static void clear_soap_fault(zval *obj);
static void set_soap_fault(zval *obj, char *fault_code_ns, char *fault_code, char *fault_string, char *fault_actor, zval *fault_detail, char *name);
static void add_soap_fault_ex(zval *fault, zval *obj, char *fault_code, char *fault_string, char *fault_actor, zval *fault_detail);
static ZEND_NORETURN void soap_server_fault(char* code, char* string, char *actor, zval* details, char *name);
static void soap_server_fault_ex(sdlFunctionPtr function, zval* fault, soapHeader* hdr);
static sdlParamPtr get_param(sdlFunctionPtr function, char *param_name, int index, int);
static sdlFunctionPtr get_function(sdlPtr sdl, const char *function_name);
static sdlFunctionPtr get_doc_function(sdlPtr sdl, xmlNodePtr node);
static sdlFunctionPtr deserialize_function_call(sdlPtr sdl, xmlDocPtr request, char* actor, zval *function_name, int *num_params, zval **parameters, int *version, soapHeader **headers);
static xmlDocPtr serialize_response_call(sdlFunctionPtr function, char *function_name,char *uri,zval *ret, soapHeader *headers, int version);
static xmlDocPtr serialize_function_call(zval *this_ptr, sdlFunctionPtr function, char *function_name, char *uri, zval *arguments, int arg_count, int version, HashTable *soap_headers);
static xmlNodePtr serialize_parameter(sdlParamPtr param,zval *param_val,int index,char *name, int style, xmlNodePtr parent);
static xmlNodePtr serialize_zval(zval *val, sdlParamPtr param, char *paramName, int style, xmlNodePtr parent);
static void delete_service(void *service);
static void delete_url(void *handle);
static void delete_hashtable(void *hashtable);
static void soap_error_handler(int error_num, const char *error_filename, const uint32_t error_lineno, const char *format, va_list args);
#define SOAP_SERVER_BEGIN_CODE() \
zend_bool _old_handler = SOAP_GLOBAL(use_soap_error_handler);\
char* _old_error_code = SOAP_GLOBAL(error_code);\
zend_object* _old_error_object = Z_OBJ(SOAP_GLOBAL(error_object));\
int _old_soap_version = SOAP_GLOBAL(soap_version);\
SOAP_GLOBAL(use_soap_error_handler) = 1;\
SOAP_GLOBAL(error_code) = "Server";\
Z_OBJ(SOAP_GLOBAL(error_object)) = Z_OBJ_P(ZEND_THIS);
#define SOAP_SERVER_END_CODE() \
SOAP_GLOBAL(use_soap_error_handler) = _old_handler;\
SOAP_GLOBAL(error_code) = _old_error_code;\
Z_OBJ(SOAP_GLOBAL(error_object)) = _old_error_object;\
SOAP_GLOBAL(soap_version) = _old_soap_version;
#define SOAP_CLIENT_BEGIN_CODE() \
zend_bool _old_handler = SOAP_GLOBAL(use_soap_error_handler);\
char* _old_error_code = SOAP_GLOBAL(error_code);\
zend_object* _old_error_object = Z_OBJ(SOAP_GLOBAL(error_object));\
int _old_soap_version = SOAP_GLOBAL(soap_version);\
zend_bool _old_in_compilation = CG(in_compilation); \
zend_execute_data *_old_current_execute_data = EG(current_execute_data); \
zval *_old_stack_top = EG(vm_stack_top); \
int _bailout = 0;\
SOAP_GLOBAL(use_soap_error_handler) = 1;\
SOAP_GLOBAL(error_code) = "Client";\
Z_OBJ(SOAP_GLOBAL(error_object)) = Z_OBJ_P(ZEND_THIS);\
zend_try {
#define SOAP_CLIENT_END_CODE() \
} zend_catch {\
CG(in_compilation) = _old_in_compilation; \
EG(current_execute_data) = _old_current_execute_data; \
if (EG(exception) == NULL || \
!instanceof_function(EG(exception)->ce, soap_fault_class_entry)) {\
_bailout = 1;\
}\
if (_old_stack_top != EG(vm_stack_top)) { \
while (EG(vm_stack)->prev != NULL && \
((char*)_old_stack_top < (char*)EG(vm_stack) || \
(char*) _old_stack_top > (char*)EG(vm_stack)->end)) { \
zend_vm_stack tmp = EG(vm_stack)->prev; \
efree(EG(vm_stack)); \
EG(vm_stack) = tmp; \
EG(vm_stack_end) = tmp->end; \
} \
EG(vm_stack)->top = _old_stack_top; \
} \
} zend_end_try();\
SOAP_GLOBAL(use_soap_error_handler) = _old_handler;\
SOAP_GLOBAL(error_code) = _old_error_code;\
Z_OBJ(SOAP_GLOBAL(error_object)) = _old_error_object;\
SOAP_GLOBAL(soap_version) = _old_soap_version;\
if (_bailout) {\
zend_bailout();\
}
#define FETCH_THIS_SDL(ss) \
{ \
zval *__tmp; \
if(FIND_SDL_PROPERTY(ZEND_THIS, __tmp) != NULL) { \
FETCH_SDL_RES(ss,__tmp); \
} else { \
ss = NULL; \
} \
}
#define FIND_SDL_PROPERTY(ss,tmp) (tmp = zend_hash_str_find(Z_OBJPROP_P(ss), "sdl", sizeof("sdl")-1))
#define FETCH_SDL_RES(ss,tmp) ss = (sdlPtr) zend_fetch_resource_ex(tmp, "sdl", le_sdl)
#define FIND_TYPEMAP_PROPERTY(ss,tmp) (tmp = zend_hash_str_find(Z_OBJPROP_P(ss), "typemap", sizeof("typemap")-1))
#define FETCH_TYPEMAP_RES(ss,tmp) ss = (HashTable*) zend_fetch_resource_ex(tmp, "typemap", le_typemap)
#define FETCH_THIS_SERVICE(ss) \
{ \
zval *tmp; \
if ((tmp = zend_hash_str_find(Z_OBJPROP_P(ZEND_THIS),"service", sizeof("service")-1)) != NULL) { \
ss = (soapServicePtr)zend_fetch_resource_ex(tmp, "service", le_service); \
} else { \
php_error_docref(NULL, E_WARNING, "Can not fetch service object"); \
SOAP_SERVER_END_CODE(); \
return; \
} \
}
static zend_class_entry* soap_class_entry;
static zend_class_entry* soap_server_class_entry;
static zend_class_entry* soap_fault_class_entry;
static zend_class_entry* soap_header_class_entry;
static zend_class_entry* soap_param_class_entry;
zend_class_entry* soap_var_class_entry;
ZEND_DECLARE_MODULE_GLOBALS(soap)
static void (*old_error_handler)(int, const char *, const uint32_t, const char*, va_list);
#define call_old_error_handler(error_num, error_filename, error_lineno, format, args) \
{ \
va_list copy; \
va_copy(copy, args); \
old_error_handler(error_num, error_filename, error_lineno, format, copy); \
va_end(copy); \
}
#define PHP_SOAP_SERVER_CLASSNAME "SoapServer"
#define PHP_SOAP_CLIENT_CLASSNAME "SoapClient"
#define PHP_SOAP_VAR_CLASSNAME "SoapVar"
#define PHP_SOAP_FAULT_CLASSNAME "SoapFault"
#define PHP_SOAP_PARAM_CLASSNAME "SoapParam"
#define PHP_SOAP_HEADER_CLASSNAME "SoapHeader"
PHP_RINIT_FUNCTION(soap);
PHP_MINIT_FUNCTION(soap);
PHP_MSHUTDOWN_FUNCTION(soap);
PHP_MINFO_FUNCTION(soap);
zend_module_entry soap_module_entry = {
#ifdef STANDARD_MODULE_HEADER
STANDARD_MODULE_HEADER,
#endif
"soap",
ext_functions,
PHP_MINIT(soap),
PHP_MSHUTDOWN(soap),
PHP_RINIT(soap),
NULL,
PHP_MINFO(soap),
#ifdef STANDARD_MODULE_HEADER
PHP_SOAP_VERSION,
#endif
STANDARD_MODULE_PROPERTIES,
};
#ifdef COMPILE_DL_SOAP
#ifdef ZTS
ZEND_TSRMLS_CACHE_DEFINE()
#endif
ZEND_GET_MODULE(soap)
#endif
ZEND_INI_MH(OnUpdateCacheMode)
{
char *p;
#ifndef ZTS
char *base = (char *) mh_arg2;
#else
char *base = (char *) ts_resource(*((int *) mh_arg2));
#endif
p = (char*) (base+(size_t) mh_arg1);
*p = (char)atoi(ZSTR_VAL(new_value));
return SUCCESS;
}
static PHP_INI_MH(OnUpdateCacheDir)
{
/* Only do the open_basedir check at runtime */
if (stage == PHP_INI_STAGE_RUNTIME || stage == PHP_INI_STAGE_HTACCESS) {
char *p;
if (memchr(ZSTR_VAL(new_value), '\0', ZSTR_LEN(new_value)) != NULL) {
return FAILURE;
}
/* we do not use zend_memrchr() since path can contain ; itself */
if ((p = strchr(ZSTR_VAL(new_value), ';'))) {
char *p2;
p++;
if ((p2 = strchr(p, ';'))) {
p = p2 + 1;
}
} else {
p = ZSTR_VAL(new_value);
}
if (PG(open_basedir) && *p && php_check_open_basedir(p)) {
return FAILURE;
}
}
OnUpdateString(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage);
return SUCCESS;
}
PHP_INI_BEGIN()
STD_PHP_INI_ENTRY("soap.wsdl_cache_enabled", "1", PHP_INI_ALL, OnUpdateBool,
cache_enabled, zend_soap_globals, soap_globals)
STD_PHP_INI_ENTRY("soap.wsdl_cache_dir", "/tmp", PHP_INI_ALL, OnUpdateCacheDir,
cache_dir, zend_soap_globals, soap_globals)
STD_PHP_INI_ENTRY("soap.wsdl_cache_ttl", "86400", PHP_INI_ALL, OnUpdateLong,
cache_ttl, zend_soap_globals, soap_globals)
STD_PHP_INI_ENTRY("soap.wsdl_cache", "1", PHP_INI_ALL, OnUpdateCacheMode,
cache_mode, zend_soap_globals, soap_globals)
STD_PHP_INI_ENTRY("soap.wsdl_cache_limit", "5", PHP_INI_ALL, OnUpdateLong,
cache_limit, zend_soap_globals, soap_globals)
PHP_INI_END()
static HashTable defEnc, defEncIndex, defEncNs;
static void php_soap_prepare_globals()
{
int i;
const encode* enc;
zend_hash_init(&defEnc, 0, NULL, NULL, 1);
zend_hash_init(&defEncIndex, 0, NULL, NULL, 1);
zend_hash_init(&defEncNs, 0, NULL, NULL, 1);
i = 0;
do {
enc = &defaultEncoding[i];
/* If has a ns and a str_type then index it */
if (defaultEncoding[i].details.type_str) {
if (defaultEncoding[i].details.ns != NULL) {
char *ns_type;
spprintf(&ns_type, 0, "%s:%s", defaultEncoding[i].details.ns, defaultEncoding[i].details.type_str);
zend_hash_str_add_ptr(&defEnc, ns_type, strlen(ns_type), (void*)enc);
efree(ns_type);
} else {
zend_hash_str_add_ptr(&defEnc, defaultEncoding[i].details.type_str, strlen(defaultEncoding[i].details.type_str), (void*)enc);
}
}
/* Index everything by number */
zend_hash_index_add_ptr(&defEncIndex, defaultEncoding[i].details.type, (void*)enc);
i++;
} while (defaultEncoding[i].details.type != END_KNOWN_TYPES);
/* hash by namespace */
zend_hash_str_add_ptr(&defEncNs, XSD_1999_NAMESPACE, sizeof(XSD_1999_NAMESPACE)-1, XSD_NS_PREFIX);
zend_hash_str_add_ptr(&defEncNs, XSD_NAMESPACE, sizeof(XSD_NAMESPACE)-1, XSD_NS_PREFIX);
zend_hash_str_add_ptr(&defEncNs, XSI_NAMESPACE, sizeof(XSI_NAMESPACE)-1, XSI_NS_PREFIX);
zend_hash_str_add_ptr(&defEncNs, XML_NAMESPACE, sizeof(XML_NAMESPACE)-1, XML_NS_PREFIX);
zend_hash_str_add_ptr(&defEncNs, SOAP_1_1_ENC_NAMESPACE, sizeof(SOAP_1_1_ENC_NAMESPACE)-1, SOAP_1_1_ENC_NS_PREFIX);
zend_hash_str_add_ptr(&defEncNs, SOAP_1_2_ENC_NAMESPACE, sizeof(SOAP_1_2_ENC_NAMESPACE)-1, SOAP_1_2_ENC_NS_PREFIX);
}
static void php_soap_init_globals(zend_soap_globals *soap_globals)
{
#if defined(COMPILE_DL_SOAP) && defined(ZTS)
ZEND_TSRMLS_CACHE_UPDATE();
#endif
soap_globals->defEnc = defEnc;
soap_globals->defEncIndex = defEncIndex;
soap_globals->defEncNs = defEncNs;
soap_globals->typemap = NULL;
soap_globals->use_soap_error_handler = 0;
soap_globals->error_code = NULL;
ZVAL_OBJ(&soap_globals->error_object, NULL);
soap_globals->sdl = NULL;
soap_globals->soap_version = SOAP_1_1;
soap_globals->mem_cache = NULL;
soap_globals->ref_map = NULL;
}
PHP_MSHUTDOWN_FUNCTION(soap)
{
zend_error_cb = old_error_handler;
zend_hash_destroy(&SOAP_GLOBAL(defEnc));
zend_hash_destroy(&SOAP_GLOBAL(defEncIndex));
zend_hash_destroy(&SOAP_GLOBAL(defEncNs));
if (SOAP_GLOBAL(mem_cache)) {
zend_hash_destroy(SOAP_GLOBAL(mem_cache));
free(SOAP_GLOBAL(mem_cache));
}
UNREGISTER_INI_ENTRIES();
return SUCCESS;
}
PHP_RINIT_FUNCTION(soap)
{
SOAP_GLOBAL(typemap) = NULL;
SOAP_GLOBAL(use_soap_error_handler) = 0;
SOAP_GLOBAL(error_code) = NULL;
ZVAL_OBJ(&SOAP_GLOBAL(error_object), NULL);
SOAP_GLOBAL(sdl) = NULL;
SOAP_GLOBAL(soap_version) = SOAP_1_1;
SOAP_GLOBAL(encoding) = NULL;
SOAP_GLOBAL(class_map) = NULL;
SOAP_GLOBAL(features) = 0;
SOAP_GLOBAL(ref_map) = NULL;
return SUCCESS;
}
static void delete_sdl_res(zend_resource *res)
{
delete_sdl(res->ptr);
}
static void delete_url_res(zend_resource *res)
{
delete_url(res->ptr);
}
static void delete_service_res(zend_resource *res)
{
delete_service(res->ptr);
}
static void delete_hashtable_res(zend_resource *res)
{
delete_hashtable(res->ptr);
}
PHP_MINIT_FUNCTION(soap)
{
zend_class_entry ce;
/* TODO: add ini entry for always use soap errors */
php_soap_prepare_globals();
ZEND_INIT_MODULE_GLOBALS(soap, php_soap_init_globals, NULL);
REGISTER_INI_ENTRIES();
/* Register SoapClient class */
/* BIG NOTE : THIS EMITS AN COMPILATION WARNING UNDER ZE2 - handle_function_call deprecated.
soap_call_function_handler should be of type zend_function, not (*handle_function_call).
*/
{
INIT_CLASS_ENTRY(ce, PHP_SOAP_CLIENT_CLASSNAME, class_SoapClient_methods);
soap_class_entry = zend_register_internal_class(&ce);
}
/* Register SoapVar class */
INIT_CLASS_ENTRY(ce, PHP_SOAP_VAR_CLASSNAME, class_SoapVar_methods);
soap_var_class_entry = zend_register_internal_class(&ce);
/* Register SoapServer class */
INIT_CLASS_ENTRY(ce, PHP_SOAP_SERVER_CLASSNAME, class_SoapServer_methods);
soap_server_class_entry = zend_register_internal_class(&ce);
/* Register SoapFault class */
INIT_CLASS_ENTRY(ce, PHP_SOAP_FAULT_CLASSNAME, class_SoapFault_methods);
soap_fault_class_entry = zend_register_internal_class_ex(&ce, zend_ce_exception);
/* Register SoapParam class */
INIT_CLASS_ENTRY(ce, PHP_SOAP_PARAM_CLASSNAME, class_SoapParam_methods);
soap_param_class_entry = zend_register_internal_class(&ce);
INIT_CLASS_ENTRY(ce, PHP_SOAP_HEADER_CLASSNAME, class_SoapHeader_methods);
soap_header_class_entry = zend_register_internal_class(&ce);
le_sdl = zend_register_list_destructors_ex(delete_sdl_res, NULL, "SOAP SDL", module_number);
le_url = zend_register_list_destructors_ex(delete_url_res, NULL, "SOAP URL", module_number);
le_service = zend_register_list_destructors_ex(delete_service_res, NULL, "SOAP service", module_number);
le_typemap = zend_register_list_destructors_ex(delete_hashtable_res, NULL, "SOAP table", module_number);
REGISTER_LONG_CONSTANT("SOAP_1_1", SOAP_1_1, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SOAP_1_2", SOAP_1_2, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SOAP_PERSISTENCE_SESSION", SOAP_PERSISTENCE_SESSION, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SOAP_PERSISTENCE_REQUEST", SOAP_PERSISTENCE_REQUEST, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SOAP_FUNCTIONS_ALL", SOAP_FUNCTIONS_ALL, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SOAP_ENCODED", SOAP_ENCODED, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SOAP_LITERAL", SOAP_LITERAL, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SOAP_RPC", SOAP_RPC, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SOAP_DOCUMENT", SOAP_DOCUMENT, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SOAP_ACTOR_NEXT", SOAP_ACTOR_NEXT, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SOAP_ACTOR_NONE", SOAP_ACTOR_NONE, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SOAP_ACTOR_UNLIMATERECEIVER", SOAP_ACTOR_UNLIMATERECEIVER, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SOAP_COMPRESSION_ACCEPT", SOAP_COMPRESSION_ACCEPT, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SOAP_COMPRESSION_GZIP", SOAP_COMPRESSION_GZIP, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SOAP_COMPRESSION_DEFLATE", SOAP_COMPRESSION_DEFLATE, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SOAP_AUTHENTICATION_BASIC", SOAP_AUTHENTICATION_BASIC, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SOAP_AUTHENTICATION_DIGEST", SOAP_AUTHENTICATION_DIGEST, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("UNKNOWN_TYPE", UNKNOWN_TYPE, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_STRING", XSD_STRING, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_BOOLEAN", XSD_BOOLEAN, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_DECIMAL", XSD_DECIMAL, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_FLOAT", XSD_FLOAT, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_DOUBLE", XSD_DOUBLE, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_DURATION", XSD_DURATION, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_DATETIME", XSD_DATETIME, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_TIME", XSD_TIME, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_DATE", XSD_DATE, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_GYEARMONTH", XSD_GYEARMONTH, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_GYEAR", XSD_GYEAR, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_GMONTHDAY", XSD_GMONTHDAY, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_GDAY", XSD_GDAY, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_GMONTH", XSD_GMONTH, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_HEXBINARY", XSD_HEXBINARY, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_BASE64BINARY", XSD_BASE64BINARY, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_ANYURI", XSD_ANYURI, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_QNAME", XSD_QNAME, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_NOTATION", XSD_NOTATION, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_NORMALIZEDSTRING", XSD_NORMALIZEDSTRING, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_TOKEN", XSD_TOKEN, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_LANGUAGE", XSD_LANGUAGE, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_NMTOKEN", XSD_NMTOKEN, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_NAME", XSD_NAME, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_NCNAME", XSD_NCNAME, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_ID", XSD_ID, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_IDREF", XSD_IDREF, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_IDREFS", XSD_IDREFS, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_ENTITY", XSD_ENTITY, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_ENTITIES", XSD_ENTITIES, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_INTEGER", XSD_INTEGER, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_NONPOSITIVEINTEGER", XSD_NONPOSITIVEINTEGER, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_NEGATIVEINTEGER", XSD_NEGATIVEINTEGER, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_LONG", XSD_LONG, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_INT", XSD_INT, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_SHORT", XSD_SHORT, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_BYTE", XSD_BYTE, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_NONNEGATIVEINTEGER", XSD_NONNEGATIVEINTEGER, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_UNSIGNEDLONG", XSD_UNSIGNEDLONG, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_UNSIGNEDINT", XSD_UNSIGNEDINT, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_UNSIGNEDSHORT", XSD_UNSIGNEDSHORT, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_UNSIGNEDBYTE", XSD_UNSIGNEDBYTE, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_POSITIVEINTEGER", XSD_POSITIVEINTEGER, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_NMTOKENS", XSD_NMTOKENS, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_ANYTYPE", XSD_ANYTYPE, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_ANYXML", XSD_ANYXML, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("APACHE_MAP", APACHE_MAP, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SOAP_ENC_OBJECT", SOAP_ENC_OBJECT, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SOAP_ENC_ARRAY", SOAP_ENC_ARRAY, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_1999_TIMEINSTANT", XSD_1999_TIMEINSTANT, CONST_CS | CONST_PERSISTENT);
REGISTER_STRING_CONSTANT("XSD_NAMESPACE", XSD_NAMESPACE, CONST_CS | CONST_PERSISTENT);
REGISTER_STRING_CONSTANT("XSD_1999_NAMESPACE", XSD_1999_NAMESPACE, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SOAP_SINGLE_ELEMENT_ARRAYS", SOAP_SINGLE_ELEMENT_ARRAYS, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SOAP_WAIT_ONE_WAY_CALLS", SOAP_WAIT_ONE_WAY_CALLS, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SOAP_USE_XSI_ARRAY_TYPE", SOAP_USE_XSI_ARRAY_TYPE, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("WSDL_CACHE_NONE", WSDL_CACHE_NONE, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("WSDL_CACHE_DISK", WSDL_CACHE_DISK, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("WSDL_CACHE_MEMORY", WSDL_CACHE_MEMORY, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("WSDL_CACHE_BOTH", WSDL_CACHE_BOTH, CONST_CS | CONST_PERSISTENT);
/* New SOAP SSL Method Constants */
REGISTER_LONG_CONSTANT("SOAP_SSL_METHOD_TLS", SOAP_SSL_METHOD_TLS, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SOAP_SSL_METHOD_SSLv2", SOAP_SSL_METHOD_SSLv2, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SOAP_SSL_METHOD_SSLv3", SOAP_SSL_METHOD_SSLv3, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SOAP_SSL_METHOD_SSLv23", SOAP_SSL_METHOD_SSLv23, CONST_CS | CONST_PERSISTENT);
old_error_handler = zend_error_cb;
zend_error_cb = soap_error_handler;
return SUCCESS;
}
PHP_MINFO_FUNCTION(soap)
{
php_info_print_table_start();
php_info_print_table_row(2, "Soap Client", "enabled");
php_info_print_table_row(2, "Soap Server", "enabled");
php_info_print_table_end();
DISPLAY_INI_ENTRIES();
}
/* {{{ proto object SoapParam::__construct(mixed data, string name)
SoapParam constructor */
PHP_METHOD(SoapParam, __construct)
{
zval *data;
char *name;
size_t name_length;
zval *this_ptr;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "zs", &data, &name, &name_length) == FAILURE) {
RETURN_THROWS();
}
if (name_length == 0) {
php_error_docref(NULL, E_WARNING, "Invalid parameter name");
return;
}
this_ptr = ZEND_THIS;
add_property_stringl(this_ptr, "param_name", name, name_length);
add_property_zval(this_ptr, "param_data", data);
}
/* }}} */
/* {{{ proto object SoapHeader::__construct(string namespace, string name [, mixed data [, bool mustUnderstand [, mixed actor]]])
SoapHeader constructor */
PHP_METHOD(SoapHeader, __construct)
{
zval *data = NULL, *actor = NULL;
char *name, *ns;
size_t name_len, ns_len;
zend_bool must_understand = 0;
zval *this_ptr;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss|zbz", &ns, &ns_len, &name, &name_len, &data, &must_understand, &actor) == FAILURE) {
RETURN_THROWS();
}
if (ns_len == 0) {
php_error_docref(NULL, E_WARNING, "Invalid namespace");
return;
}
if (name_len == 0) {
php_error_docref(NULL, E_WARNING, "Invalid header name");
return;
}
this_ptr = ZEND_THIS;
add_property_stringl(this_ptr, "namespace", ns, ns_len);
add_property_stringl(this_ptr, "name", name, name_len);
if (data) {
add_property_zval(this_ptr, "data", data);
}
add_property_bool(this_ptr, "mustUnderstand", must_understand);
if (actor == NULL) {
} else if (Z_TYPE_P(actor) == IS_LONG &&
(Z_LVAL_P(actor) == SOAP_ACTOR_NEXT ||
Z_LVAL_P(actor) == SOAP_ACTOR_NONE ||
Z_LVAL_P(actor) == SOAP_ACTOR_UNLIMATERECEIVER)) {
add_property_long(this_ptr, "actor", Z_LVAL_P(actor));
} else if (Z_TYPE_P(actor) == IS_STRING && Z_STRLEN_P(actor) > 0) {
add_property_stringl(this_ptr, "actor", Z_STRVAL_P(actor), Z_STRLEN_P(actor));
} else {
php_error_docref(NULL, E_WARNING, "Invalid actor");
}
}
/* }}} */
/* {{{ proto object SoapFault::__construct(string faultcode, string faultstring [, string faultactor [, mixed detail [, string faultname [, mixed headerfault]]]])
SoapFault constructor */
PHP_METHOD(SoapFault, __construct)
{
char *fault_string = NULL, *fault_code = NULL, *fault_actor = NULL, *name = NULL, *fault_code_ns = NULL;
size_t fault_string_len, fault_actor_len = 0, name_len = 0, fault_code_len = 0;
zval *code = NULL, *details = NULL, *headerfault = NULL, *this_ptr;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "zs|s!z!s!z!",
&code,
&fault_string, &fault_string_len,
&fault_actor, &fault_actor_len,
&details, &name, &name_len, &headerfault) == FAILURE) {
RETURN_THROWS();
}
if (Z_TYPE_P(code) == IS_NULL) {
} else if (Z_TYPE_P(code) == IS_STRING) {
fault_code = Z_STRVAL_P(code);
fault_code_len = Z_STRLEN_P(code);
} else if (Z_TYPE_P(code) == IS_ARRAY && zend_hash_num_elements(Z_ARRVAL_P(code)) == 2) {
zval *t_ns = zend_hash_index_find(Z_ARRVAL_P(code), 0);
zval *t_code = zend_hash_index_find(Z_ARRVAL_P(code), 1);
if (t_ns && t_code && Z_TYPE_P(t_ns) == IS_STRING && Z_TYPE_P(t_code) == IS_STRING) {
fault_code_ns = Z_STRVAL_P(t_ns);
fault_code = Z_STRVAL_P(t_code);
fault_code_len = Z_STRLEN_P(t_code);
} else {
php_error_docref(NULL, E_WARNING, "Invalid fault code");
return;
}
} else {
php_error_docref(NULL, E_WARNING, "Invalid fault code");
return;
}
if (fault_code != NULL && fault_code_len == 0) {
php_error_docref(NULL, E_WARNING, "Invalid fault code");
return;
}
if (name != NULL && name_len == 0) {
name = NULL;
}
this_ptr = ZEND_THIS;
set_soap_fault(this_ptr, fault_code_ns, fault_code, fault_string, fault_actor, details, name);
if (headerfault != NULL) {
add_property_zval(this_ptr, "headerfault", headerfault);
}
}
/* }}} */
/* {{{ proto object SoapFault::SoapFault(string faultcode, string faultstring [, string faultactor [, mixed detail [, string faultname [, mixed headerfault]]]])
SoapFault constructor */
PHP_METHOD(SoapFault, __toString)
{
zval *faultcode, *faultstring, *file, *line, trace, rv1, rv2, rv3, rv4;
zend_string *str;
zend_fcall_info fci;
zval *this_ptr;
zend_string *faultcode_val, *faultstring_val, *file_val;
zend_long line_val;
if (zend_parse_parameters_none() == FAILURE) {
RETURN_THROWS();
}
this_ptr = ZEND_THIS;
faultcode = zend_read_property(soap_fault_class_entry, this_ptr, "faultcode", sizeof("faultcode")-1, 1, &rv1);
faultstring = zend_read_property(soap_fault_class_entry, this_ptr, "faultstring", sizeof("faultstring")-1, 1, &rv2);
file = zend_read_property(soap_fault_class_entry, this_ptr, "file", sizeof("file")-1, 1, &rv3);
line = zend_read_property(soap_fault_class_entry, this_ptr, "line", sizeof("line")-1, 1, &rv4);
fci.size = sizeof(fci);
ZVAL_STRINGL(&fci.function_name, "gettraceasstring", sizeof("gettraceasstring")-1);
fci.object = Z_OBJ_P(ZEND_THIS);
fci.retval = &trace;
fci.param_count = 0;
fci.params = NULL;
fci.no_separation = 1;
zend_call_function(&fci, NULL);
zval_ptr_dtor(&fci.function_name);
faultcode_val = zval_get_string(faultcode);
faultstring_val = zval_get_string(faultstring);
file_val = zval_get_string(file);
line_val = zval_get_long(line);
convert_to_string(&trace);
str = strpprintf(0, "SoapFault exception: [%s] %s in %s:" ZEND_LONG_FMT "\nStack trace:\n%s",
ZSTR_VAL(faultcode_val), ZSTR_VAL(faultstring_val), ZSTR_VAL(file_val), line_val,
Z_STRLEN(trace) ? Z_STRVAL(trace) : "#0 {main}\n");
zend_string_release_ex(file_val, 0);
zend_string_release_ex(faultstring_val, 0);
zend_string_release_ex(faultcode_val, 0);
zval_ptr_dtor(&trace);
RETVAL_STR(str);
}
/* }}} */
/* {{{ proto object SoapVar::__construct(mixed data, int encoding [, string type_name [, string type_namespace [, string node_name [, string node_namespace]]]])
SoapVar constructor */
PHP_METHOD(SoapVar, __construct)
{
zval *data, *type, *this_ptr;
char *stype = NULL, *ns = NULL, *name = NULL, *namens = NULL;
size_t stype_len = 0, ns_len = 0, name_len = 0, namens_len = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "z!z|ssss", &data, &type, &stype, &stype_len, &ns, &ns_len, &name, &name_len, &namens, &namens_len) == FAILURE) {
RETURN_THROWS();
}
this_ptr = ZEND_THIS;
if (Z_TYPE_P(type) == IS_NULL) {
add_property_long(this_ptr, "enc_type", UNKNOWN_TYPE);
} else {
if (zend_hash_index_exists(&SOAP_GLOBAL(defEncIndex), Z_LVAL_P(type))) {
add_property_long(this_ptr, "enc_type", Z_LVAL_P(type));
} else {
php_error_docref(NULL, E_WARNING, "Invalid type ID");
return;
}
}
if (data) {
add_property_zval(this_ptr, "enc_value", data);
}
if (stype && stype_len > 0) {
add_property_stringl(this_ptr, "enc_stype", stype, stype_len);
}
if (ns && ns_len > 0) {
add_property_stringl(this_ptr, "enc_ns", ns, ns_len);
}
if (name && name_len > 0) {
add_property_stringl(this_ptr, "enc_name", name, name_len);
}
if (namens && namens_len > 0) {
add_property_stringl(this_ptr, "enc_namens", namens, namens_len);
}
}
/* }}} */
static HashTable* soap_create_typemap(sdlPtr sdl, HashTable *ht) /* {{{ */
{
zval *tmp;
HashTable *ht2;
HashTable *typemap = NULL;
ZEND_HASH_FOREACH_VAL(ht, tmp) {
char *type_name = NULL;
char *type_ns = NULL;
zval *to_xml = NULL;
zval *to_zval = NULL;
encodePtr enc, new_enc;
zend_string *name;
if (Z_TYPE_P(tmp) != IS_ARRAY) {
php_error_docref(NULL, E_WARNING, "Wrong 'typemap' option");
return NULL;
}
ht2 = Z_ARRVAL_P(tmp);
ZEND_HASH_FOREACH_STR_KEY_VAL(ht2, name, tmp) {
if (name) {
if (ZSTR_LEN(name) == sizeof("type_name")-1 &&
strncmp(ZSTR_VAL(name), "type_name", sizeof("type_name")-1) == 0) {
if (Z_TYPE_P(tmp) == IS_STRING) {
type_name = Z_STRVAL_P(tmp);
} else if (Z_TYPE_P(tmp) != IS_NULL) {
}
} else if (ZSTR_LEN(name) == sizeof("type_ns")-1 &&
strncmp(ZSTR_VAL(name), "type_ns", sizeof("type_ns")-1) == 0) {
if (Z_TYPE_P(tmp) == IS_STRING) {
type_ns = Z_STRVAL_P(tmp);
} else if (Z_TYPE_P(tmp) != IS_NULL) {
}
} else if (ZSTR_LEN(name) == sizeof("to_xml")-1 &&
strncmp(ZSTR_VAL(name), "to_xml", sizeof("to_xml")-1) == 0) {
to_xml = tmp;
} else if (ZSTR_LEN(name) == sizeof("from_xml")-1 &&
strncmp(ZSTR_VAL(name), "from_xml", sizeof("from_xml")-1) == 0) {
to_zval = tmp;
}
}
} ZEND_HASH_FOREACH_END();
if (type_name) {
smart_str nscat = {0};
if (type_ns) {
enc = get_encoder(sdl, type_ns, type_name);
} else {
enc = get_encoder_ex(sdl, type_name, strlen(type_name));
}
new_enc = emalloc(sizeof(encode));
memset(new_enc, 0, sizeof(encode));
if (enc) {
new_enc->details.type = enc->details.type;
new_enc->details.ns = estrdup(enc->details.ns);
new_enc->details.type_str = estrdup(enc->details.type_str);
new_enc->details.sdl_type = enc->details.sdl_type;
} else {
enc = get_conversion(UNKNOWN_TYPE);
new_enc->details.type = enc->details.type;
if (type_ns) {
new_enc->details.ns = estrdup(type_ns);
}
new_enc->details.type_str = estrdup(type_name);
}
new_enc->to_xml = enc->to_xml;
new_enc->to_zval = enc->to_zval;
new_enc->details.map = emalloc(sizeof(soapMapping));
memset(new_enc->details.map, 0, sizeof(soapMapping));
if (to_xml) {
ZVAL_COPY(&new_enc->details.map->to_xml, to_xml);
new_enc->to_xml = to_xml_user;
} else if (enc->details.map && Z_TYPE(enc->details.map->to_xml) != IS_UNDEF) {
ZVAL_COPY(&new_enc->details.map->to_xml, &enc->details.map->to_xml);
}
if (to_zval) {
ZVAL_COPY(&new_enc->details.map->to_zval, to_zval);
new_enc->to_zval = to_zval_user;
} else if (enc->details.map && Z_TYPE(enc->details.map->to_zval) != IS_UNDEF) {
ZVAL_COPY(&new_enc->details.map->to_zval, &enc->details.map->to_zval);
}
if (!typemap) {
typemap = emalloc(sizeof(HashTable));
zend_hash_init(typemap, 0, NULL, delete_encoder, 0);
}
if (type_ns) {
smart_str_appends(&nscat, type_ns);
smart_str_appendc(&nscat, ':');
}
smart_str_appends(&nscat, type_name);
smart_str_0(&nscat);
zend_hash_update_ptr(typemap, nscat.s, new_enc);
smart_str_free(&nscat);
}
} ZEND_HASH_FOREACH_END();
return typemap;
}
/* }}} */
/* {{{ proto object SoapServer::__construct(mixed wsdl [, array options])
SoapServer constructor */
PHP_METHOD(SoapServer, __construct)
{
soapServicePtr service;
zval *wsdl = NULL, *options = NULL;
zend_resource *res;
int version = SOAP_1_1;
zend_long cache_wsdl;
HashTable *typemap_ht = NULL;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "z|a", &wsdl, &options) == FAILURE) {
RETURN_THROWS();
}
SOAP_SERVER_BEGIN_CODE();
if (Z_TYPE_P(wsdl) != IS_STRING && Z_TYPE_P(wsdl) != IS_NULL) {
php_error_docref(NULL, E_ERROR, "Invalid parameters");
}
service = emalloc(sizeof(soapService));
memset(service, 0, sizeof(soapService));
service->send_errors = 1;
cache_wsdl = SOAP_GLOBAL(cache_enabled) ? SOAP_GLOBAL(cache_mode) : 0;
if (options != NULL) {
HashTable *ht = Z_ARRVAL_P(options);
zval *tmp;
if ((tmp = zend_hash_str_find(ht, "soap_version", sizeof("soap_version")-1)) != NULL) {
if (Z_TYPE_P(tmp) == IS_LONG &&
(Z_LVAL_P(tmp) == SOAP_1_1 || Z_LVAL_P(tmp) == SOAP_1_2)) {
version = Z_LVAL_P(tmp);
} else {
php_error_docref(NULL, E_ERROR, "'soap_version' option must be SOAP_1_1 or SOAP_1_2");
}
}
if ((tmp = zend_hash_str_find(ht, "uri", sizeof("uri")-1)) != NULL &&
Z_TYPE_P(tmp) == IS_STRING) {
service->uri = estrndup(Z_STRVAL_P(tmp), Z_STRLEN_P(tmp));
} else if (Z_TYPE_P(wsdl) == IS_NULL) {
php_error_docref(NULL, E_ERROR, "'uri' option is required in nonWSDL mode");
}
if ((tmp = zend_hash_str_find(ht, "actor", sizeof("actor")-1)) != NULL &&
Z_TYPE_P(tmp) == IS_STRING) {
service->actor = estrndup(Z_STRVAL_P(tmp), Z_STRLEN_P(tmp));
}
if ((tmp = zend_hash_str_find(ht, "encoding", sizeof("encoding")-1)) != NULL &&
Z_TYPE_P(tmp) == IS_STRING) {
xmlCharEncodingHandlerPtr encoding;
encoding = xmlFindCharEncodingHandler(Z_STRVAL_P(tmp));
if (encoding == NULL) {
php_error_docref(NULL, E_ERROR, "Invalid 'encoding' option - '%s'", Z_STRVAL_P(tmp));
} else {
service->encoding = encoding;
}
}
if ((tmp = zend_hash_str_find(ht, "classmap", sizeof("classmap")-1)) != NULL &&
Z_TYPE_P(tmp) == IS_ARRAY) {
service->class_map = zend_array_dup(Z_ARRVAL_P(tmp));
}
if ((tmp = zend_hash_str_find(ht, "typemap", sizeof("typemap")-1)) != NULL &&
Z_TYPE_P(tmp) == IS_ARRAY &&
zend_hash_num_elements(Z_ARRVAL_P(tmp)) > 0) {
typemap_ht = Z_ARRVAL_P(tmp);
}
if ((tmp = zend_hash_str_find(ht, "features", sizeof("features")-1)) != NULL &&
Z_TYPE_P(tmp) == IS_LONG) {
service->features = Z_LVAL_P(tmp);
}
if ((tmp = zend_hash_str_find(ht, "cache_wsdl", sizeof("cache_wsdl")-1)) != NULL &&
Z_TYPE_P(tmp) == IS_LONG) {
cache_wsdl = Z_LVAL_P(tmp);
}
if ((tmp = zend_hash_str_find(ht, "send_errors", sizeof("send_errors")-1)) != NULL) {
if (Z_TYPE_P(tmp) == IS_FALSE) {
service->send_errors = 0;
} else if (Z_TYPE_P(tmp) == IS_TRUE) {
service->send_errors = 1;
} else if (Z_TYPE_P(tmp) == IS_LONG) {
service->send_errors = Z_LVAL_P(tmp);
}
}
} else if (Z_TYPE_P(wsdl) == IS_NULL) {
php_error_docref(NULL, E_ERROR, "'uri' option is required in nonWSDL mode");
}
service->version = version;
service->type = SOAP_FUNCTIONS;
service->soap_functions.functions_all = FALSE;
service->soap_functions.ft = zend_new_array(0);
if (Z_TYPE_P(wsdl) != IS_NULL) {
service->sdl = get_sdl(ZEND_THIS, Z_STRVAL_P(wsdl), cache_wsdl);
if (service->uri == NULL) {
if (service->sdl->target_ns) {
service->uri = estrdup(service->sdl->target_ns);
} else {
/*FIXME*/
service->uri = estrdup("http://unknown-uri/");
}
}
}
if (typemap_ht) {
service->typemap = soap_create_typemap(service->sdl, typemap_ht);
}
res = zend_register_resource(service, le_service);
add_property_resource(ZEND_THIS, "service", res);
SOAP_SERVER_END_CODE();
}
/* }}} */
/* {{{ proto object SoapServer::setPersistence(int mode )
Sets persistence mode of SoapServer */
PHP_METHOD(SoapServer, setPersistence)
{
soapServicePtr service;
zend_long value;
SOAP_SERVER_BEGIN_CODE();
FETCH_THIS_SERVICE(service);
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &value) != FAILURE) {
if (service->type == SOAP_CLASS) {
if (value == SOAP_PERSISTENCE_SESSION ||
value == SOAP_PERSISTENCE_REQUEST) {
service->soap_class.persistence = value;
} else {
php_error_docref(NULL, E_WARNING, "Tried to set persistence with bogus value (" ZEND_LONG_FMT ")", value);
return;
}
} else {
php_error_docref(NULL, E_WARNING, "Tried to set persistence when you are using you SOAP SERVER in function mode, no persistence needed");
return;
}
}
SOAP_SERVER_END_CODE();
}
/* }}} */
/* {{{ proto void SoapServer::setClass(string class_name [, mixed args])
Sets class which will handle SOAP requests */
PHP_METHOD(SoapServer, setClass)
{
soapServicePtr service;
zend_string *classname;
zend_class_entry *ce;
int num_args = 0;
zval *argv = NULL;
SOAP_SERVER_BEGIN_CODE();
FETCH_THIS_SERVICE(service);
if (zend_parse_parameters(ZEND_NUM_ARGS(), "S*", &classname, &argv, &num_args) == FAILURE) {
RETURN_THROWS();
}
ce = zend_lookup_class(classname);
if (ce) {
service->type = SOAP_CLASS;
service->soap_class.ce = ce;
service->soap_class.persistence = SOAP_PERSISTENCE_REQUEST;
service->soap_class.argc = num_args;
if (service->soap_class.argc > 0) {
int i;
service->soap_class.argv = safe_emalloc(sizeof(zval), service->soap_class.argc, 0);
for (i = 0;i < service->soap_class.argc;i++) {
ZVAL_COPY(&service->soap_class.argv[i], &argv[i]);
}
}
} else {
php_error_docref(NULL, E_WARNING, "Tried to set a non existent class (%s)", ZSTR_VAL(classname));
return;
}
SOAP_SERVER_END_CODE();
}
/* }}} */
/* {{{ proto void SoapServer::setObject(object obj)
Sets object which will handle SOAP requests */
PHP_METHOD(SoapServer, setObject)
{
soapServicePtr service;
zval *obj;
SOAP_SERVER_BEGIN_CODE();
FETCH_THIS_SERVICE(service);
if (zend_parse_parameters(ZEND_NUM_ARGS(), "o", &obj) == FAILURE) {
RETURN_THROWS();
}
service->type = SOAP_OBJECT;
Z_ADDREF_P(obj);
ZVAL_OBJ(&service->soap_object, Z_OBJ_P(obj));
SOAP_SERVER_END_CODE();
}
/* }}} */
/* {{{ proto array SoapServer::getFunctions(void)
Returns list of defined functions */
PHP_METHOD(SoapServer, getFunctions)
{
soapServicePtr service;
HashTable *ft = NULL;
SOAP_SERVER_BEGIN_CODE();
if (zend_parse_parameters_none() == FAILURE) {
RETURN_THROWS();
}
FETCH_THIS_SERVICE(service);
array_init(return_value);
if (service->type == SOAP_OBJECT) {
ft = &(Z_OBJCE(service->soap_object)->function_table);
} else if (service->type == SOAP_CLASS) {
ft = &service->soap_class.ce->function_table;
} else if (service->soap_functions.functions_all == TRUE) {
ft = EG(function_table);
} else if (service->soap_functions.ft != NULL) {
zval *name;
ZEND_HASH_FOREACH_VAL(service->soap_functions.ft, name) {
add_next_index_str(return_value, zend_string_copy(Z_STR_P(name)));
} ZEND_HASH_FOREACH_END();
}
if (ft != NULL) {
zend_function *f;
ZEND_HASH_FOREACH_PTR(ft, f) {
if ((service->type != SOAP_OBJECT && service->type != SOAP_CLASS) || (f->common.fn_flags & ZEND_ACC_PUBLIC)) {
add_next_index_str(return_value, zend_string_copy(f->common.function_name));
}
} ZEND_HASH_FOREACH_END();
}
SOAP_SERVER_END_CODE();
}
/* }}} */
/* {{{ proto void SoapServer::addFunction(mixed functions)
Adds one or several functions those will handle SOAP requests */
PHP_METHOD(SoapServer, addFunction)
{
soapServicePtr service;
zval *function_name, function_copy;
SOAP_SERVER_BEGIN_CODE();
FETCH_THIS_SERVICE(service);
if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &function_name) == FAILURE) {
RETURN_THROWS();
}
/* TODO: could use zend_is_callable here */
if (Z_TYPE_P(function_name) == IS_ARRAY) {
if (service->type == SOAP_FUNCTIONS) {
zval *tmp_function;
if (service->soap_functions.ft == NULL) {
service->soap_functions.functions_all = FALSE;
service->soap_functions.ft = zend_new_array(zend_hash_num_elements(Z_ARRVAL_P(function_name)));
}
ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(function_name), tmp_function) {
zend_string *key;
zend_function *f;
if (Z_TYPE_P(tmp_function) != IS_STRING) {
php_error_docref(NULL, E_WARNING, "Tried to add a function that isn't a string");
return;
}
key = zend_string_tolower(Z_STR_P(tmp_function));
if ((f = zend_hash_find_ptr(EG(function_table), key)) == NULL) {
php_error_docref(NULL, E_WARNING, "Tried to add a non existent function '%s'", Z_STRVAL_P(tmp_function));
return;
}
ZVAL_STR_COPY(&function_copy, f->common.function_name);
zend_hash_update(service->soap_functions.ft, key, &function_copy);
zend_string_release_ex(key, 0);
} ZEND_HASH_FOREACH_END();
}
} else if (Z_TYPE_P(function_name) == IS_STRING) {
zend_string *key;
zend_function *f;
key = zend_string_tolower(Z_STR_P(function_name));
if ((f = zend_hash_find_ptr(EG(function_table), key)) == NULL) {
php_error_docref(NULL, E_WARNING, "Tried to add a non existent function '%s'", Z_STRVAL_P(function_name));
return;
}
if (service->soap_functions.ft == NULL) {
service->soap_functions.functions_all = FALSE;
service->soap_functions.ft = zend_new_array(0);
}
ZVAL_STR_COPY(&function_copy, f->common.function_name);
zend_hash_update(service->soap_functions.ft, key, &function_copy);
zend_string_release_ex(key, 0);
} else if (Z_TYPE_P(function_name) == IS_LONG) {
if (Z_LVAL_P(function_name) == SOAP_FUNCTIONS_ALL) {
if (service->soap_functions.ft != NULL) {
zend_hash_destroy(service->soap_functions.ft);
efree(service->soap_functions.ft);
service->soap_functions.ft = NULL;
}
service->soap_functions.functions_all = TRUE;
} else {
php_error_docref(NULL, E_WARNING, "Invalid value passed");
return;
}
}
SOAP_SERVER_END_CODE();
}
/* }}} */
static void _soap_server_exception(soapServicePtr service, sdlFunctionPtr function, zval *this_ptr) /* {{{ */
{
zval exception_object;
ZVAL_OBJ(&exception_object, EG(exception));
if (instanceof_function(Z_OBJCE(exception_object), soap_fault_class_entry)) {
soap_server_fault_ex(function, &exception_object, NULL);
} else if (instanceof_function(Z_OBJCE(exception_object), zend_ce_error)) {
if (service->send_errors) {
zval rv;
zend_string *msg = zval_get_string(zend_read_property(zend_ce_error, &exception_object, "message", sizeof("message")-1, 0, &rv));
add_soap_fault_ex(&exception_object, this_ptr, "Server", ZSTR_VAL(msg), NULL, NULL);
zend_string_release_ex(msg, 0);
} else {
add_soap_fault_ex(&exception_object, this_ptr, "Server", "Internal Error", NULL, NULL);
}
soap_server_fault_ex(function, &exception_object, NULL);
}
}
/* }}} */
/* {{{ proto void SoapServer::handle([string soap_request])
Handles a SOAP request */
PHP_METHOD(SoapServer, handle)
{
int soap_version, old_soap_version;
sdlPtr old_sdl = NULL;
soapServicePtr service;
xmlDocPtr doc_request = NULL, doc_return = NULL;
zval function_name, *params, *soap_obj, retval;
char *fn_name, cont_len[30];
int num_params = 0, size, i, call_status = 0;
xmlChar *buf;
HashTable *function_table;
soapHeader *soap_headers = NULL;
sdlFunctionPtr function;
char *arg = NULL;
size_t arg_len = 0;
xmlCharEncodingHandlerPtr old_encoding;
HashTable *old_class_map, *old_typemap;
int old_features;
zval tmp_soap;
SOAP_SERVER_BEGIN_CODE();
FETCH_THIS_SERVICE(service);
SOAP_GLOBAL(soap_version) = service->version;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s", &arg, &arg_len) == FAILURE) {
RETURN_THROWS();
}
if (ZEND_NUM_ARGS() > 0 && ZEND_SIZE_T_INT_OVFL(arg_len)) {
soap_server_fault("Server", "Input string is too long", NULL, NULL, NULL);
return;
}
if (SG(request_info).request_method &&
strcmp(SG(request_info).request_method, "GET") == 0 &&
SG(request_info).query_string &&
stricmp(SG(request_info).query_string, "wsdl") == 0) {
if (service->sdl) {
/*
char *hdr = emalloc(sizeof("Location: ")+strlen(service->sdl->source));
strcpy(hdr,"Location: ");
strcat(hdr,service->sdl->source);
sapi_add_header(hdr, sizeof("Location: ")+strlen(service->sdl->source)-1, 1);
efree(hdr);
*/
zval readfile, readfile_ret, param;
sapi_add_header("Content-Type: text/xml; charset=utf-8", sizeof("Content-Type: text/xml; charset=utf-8")-1, 1);
ZVAL_STRING(¶m, service->sdl->source);
ZVAL_STRING(&readfile, "readfile");
if (call_user_function(EG(function_table), NULL, &readfile, &readfile_ret, 1, ¶m ) == FAILURE) {
soap_server_fault("Server", "Couldn't find WSDL", NULL, NULL, NULL);
}
zval_ptr_dtor(¶m);
zval_ptr_dtor_str(&readfile);
zval_ptr_dtor(&readfile_ret);
SOAP_SERVER_END_CODE();
return;
} else {
soap_server_fault("Server", "WSDL generation is not supported yet", NULL, NULL, NULL);
/*
sapi_add_header("Content-Type: text/xml; charset=utf-8", sizeof("Content-Type: text/xml; charset=utf-8"), 1);
PUTS("<?xml version=\"1.0\" ?>\n<definitions\n");
PUTS(" xmlns=\"http://schemas.xmlsoap.org/wsdl/\"\n");
PUTS(" targetNamespace=\"");
PUTS(service->uri);
PUTS("\">\n");
PUTS("</definitions>");
*/
SOAP_SERVER_END_CODE();
return;
}
}
ZVAL_NULL(&retval);
if (php_output_start_default() != SUCCESS) {
php_error_docref(NULL, E_ERROR,"ob_start failed");
}
if (ZEND_NUM_ARGS() == 0) {
if (SG(request_info).request_body && 0 == php_stream_rewind(SG(request_info).request_body)) {
zval *server_vars, *encoding;
php_stream_filter *zf = NULL;
zend_string *server = zend_string_init("_SERVER", sizeof("_SERVER") - 1, 0);
zend_is_auto_global(server);
if ((server_vars = zend_hash_find(&EG(symbol_table), server)) != NULL &&
Z_TYPE_P(server_vars) == IS_ARRAY &&
(encoding = zend_hash_str_find(Z_ARRVAL_P(server_vars), "HTTP_CONTENT_ENCODING", sizeof("HTTP_CONTENT_ENCODING")-1)) != NULL &&
Z_TYPE_P(encoding) == IS_STRING) {
if (strcmp(Z_STRVAL_P(encoding),"gzip") == 0
|| strcmp(Z_STRVAL_P(encoding),"x-gzip") == 0
|| strcmp(Z_STRVAL_P(encoding),"deflate") == 0
) {
zval filter_params;
array_init_size(&filter_params, 1);
add_assoc_long_ex(&filter_params, "window", sizeof("window")-1, 0x2f); /* ANY WBITS */
zf = php_stream_filter_create("zlib.inflate", &filter_params, 0);
zend_array_destroy(Z_ARR(filter_params));
if (zf) {
php_stream_filter_append(&SG(request_info).request_body->readfilters, zf);
} else {
php_error_docref(NULL, E_WARNING,"Can't uncompress compressed request");
zend_string_release_ex(server, 0);
return;
}
} else {
php_error_docref(NULL, E_WARNING,"Request is compressed with unknown compression '%s'",Z_STRVAL_P(encoding));
zend_string_release_ex(server, 0);
return;
}
}
zend_string_release_ex(server, 0);
doc_request = soap_xmlParseFile("php://input");
if (zf) {
php_stream_filter_remove(zf, 1);
}
} else {
zval_ptr_dtor(&retval);
return;
}
} else {
doc_request = soap_xmlParseMemory(arg,arg_len);
}
if (doc_request == NULL) {
soap_server_fault("Client", "Bad Request", NULL, NULL, NULL);
}
if (xmlGetIntSubset(doc_request) != NULL) {
xmlNodePtr env = get_node(doc_request->children,"Envelope");
if (env && env->ns) {
if (strcmp((char*)env->ns->href, SOAP_1_1_ENV_NAMESPACE) == 0) {
SOAP_GLOBAL(soap_version) = SOAP_1_1;
} else if (strcmp((char*)env->ns->href,SOAP_1_2_ENV_NAMESPACE) == 0) {
SOAP_GLOBAL(soap_version) = SOAP_1_2;
}
}
xmlFreeDoc(doc_request);
soap_server_fault("Server", "DTD are not supported by SOAP", NULL, NULL, NULL);
}
old_sdl = SOAP_GLOBAL(sdl);
SOAP_GLOBAL(sdl) = service->sdl;
old_encoding = SOAP_GLOBAL(encoding);
SOAP_GLOBAL(encoding) = service->encoding;
old_class_map = SOAP_GLOBAL(class_map);
SOAP_GLOBAL(class_map) = service->class_map;
old_typemap = SOAP_GLOBAL(typemap);
SOAP_GLOBAL(typemap) = service->typemap;
old_features = SOAP_GLOBAL(features);
SOAP_GLOBAL(features) = service->features;
old_soap_version = SOAP_GLOBAL(soap_version);
zend_try {
function = deserialize_function_call(service->sdl, doc_request, service->actor, &function_name, &num_params, ¶ms, &soap_version, &soap_headers);
} zend_catch {
/* Avoid leaking persistent memory */
xmlFreeDoc(doc_request);
zend_bailout();
} zend_end_try();
xmlFreeDoc(doc_request);
if (EG(exception)) {
php_output_discard();
_soap_server_exception(service, function, ZEND_THIS);
goto fail;
}
service->soap_headers_ptr = &soap_headers;
soap_obj = NULL;
if (service->type == SOAP_OBJECT) {
soap_obj = &service->soap_object;
function_table = &((Z_OBJCE_P(soap_obj))->function_table);
} else if (service->type == SOAP_CLASS) {
#if HAVE_PHP_SESSION && !defined(COMPILE_DL_SESSION)
/* If persistent then set soap_obj from from the previous created session (if available) */
if (service->soap_class.persistence == SOAP_PERSISTENCE_SESSION) {
zval *session_vars, *tmp_soap_p;
if (PS(session_status) != php_session_active &&
PS(session_status) != php_session_disabled) {
php_session_start();
}
/* Find the soap object and assign */
session_vars = &PS(http_session_vars);
ZVAL_DEREF(session_vars);
if (Z_TYPE_P(session_vars) == IS_ARRAY &&
(tmp_soap_p = zend_hash_str_find(Z_ARRVAL_P(session_vars), "_bogus_session_name", sizeof("_bogus_session_name")-1)) != NULL &&
Z_TYPE_P(tmp_soap_p) == IS_OBJECT &&
Z_OBJCE_P(tmp_soap_p) == service->soap_class.ce) {
soap_obj = tmp_soap_p;
}
}
#endif
/* If new session or something weird happned */
if (soap_obj == NULL) {
object_init_ex(&tmp_soap, service->soap_class.ce);
/* Call constructor */
if (zend_hash_str_exists(&Z_OBJCE(tmp_soap)->function_table, ZEND_CONSTRUCTOR_FUNC_NAME, sizeof(ZEND_CONSTRUCTOR_FUNC_NAME)-1)) {
zval c_ret, constructor;
ZVAL_STRING(&constructor, ZEND_CONSTRUCTOR_FUNC_NAME);
if (call_user_function(NULL, &tmp_soap, &constructor, &c_ret, service->soap_class.argc, service->soap_class.argv) == FAILURE) {
php_error_docref(NULL, E_ERROR, "Error calling constructor");
}
if (EG(exception)) {
php_output_discard();
_soap_server_exception(service, function, ZEND_THIS);
zval_ptr_dtor_str(&constructor);
zval_ptr_dtor(&c_ret);
zval_ptr_dtor(&tmp_soap);
goto fail;
}
zval_ptr_dtor_str(&constructor);
zval_ptr_dtor(&c_ret);
} else {
int class_name_len = ZSTR_LEN(service->soap_class.ce->name);
char *class_name = emalloc(class_name_len+1);
memcpy(class_name, ZSTR_VAL(service->soap_class.ce->name), class_name_len+1);
if (zend_hash_str_exists(&Z_OBJCE(tmp_soap)->function_table, php_strtolower(class_name, class_name_len), class_name_len)) {
zval c_ret, constructor;
ZVAL_STR_COPY(&constructor, service->soap_class.ce->name);
if (call_user_function(NULL, &tmp_soap, &constructor, &c_ret, service->soap_class.argc, service->soap_class.argv) == FAILURE) {
php_error_docref(NULL, E_ERROR, "Error calling constructor");
}
if (EG(exception)) {
php_output_discard();
_soap_server_exception(service, function, ZEND_THIS);
zval_ptr_dtor_str(&constructor);
zval_ptr_dtor(&c_ret);
efree(class_name);
zval_ptr_dtor(&tmp_soap);
goto fail;
}
zval_ptr_dtor_str(&constructor);
zval_ptr_dtor(&c_ret);
}
efree(class_name);
}
#if HAVE_PHP_SESSION && !defined(COMPILE_DL_SESSION)
/* If session then update session hash with new object */
if (service->soap_class.persistence == SOAP_PERSISTENCE_SESSION) {
zval *session_vars = &PS(http_session_vars), *tmp_soap_p;
ZVAL_DEREF(session_vars);
if (Z_TYPE_P(session_vars) == IS_ARRAY &&
(tmp_soap_p = zend_hash_str_update(Z_ARRVAL_P(session_vars), "_bogus_session_name", sizeof("_bogus_session_name")-1, &tmp_soap)) != NULL) {
soap_obj = tmp_soap_p;
} else {
soap_obj = &tmp_soap;
}
} else {
soap_obj = &tmp_soap;
}
#else
soap_obj = &tmp_soap;
#endif
}
function_table = &((Z_OBJCE_P(soap_obj))->function_table);
} else {
if (service->soap_functions.functions_all == TRUE) {
function_table = EG(function_table);
} else {
function_table = service->soap_functions.ft;
}
}
/* Process soap headers */
if (soap_headers != NULL) {
soapHeader *header = soap_headers;
while (header != NULL) {
soapHeader *h = header;
header = header->next;
#if 0
if (service->sdl && !h->function && !h->hdr) {
if (h->mustUnderstand) {
soap_server_fault("MustUnderstand","Header not understood", NULL, NULL, NULL);
} else {
continue;
}
}
#endif
fn_name = estrndup(Z_STRVAL(h->function_name),Z_STRLEN(h->function_name));
if (zend_hash_str_exists(function_table, php_strtolower(fn_name, Z_STRLEN(h->function_name)), Z_STRLEN(h->function_name)) ||
((service->type == SOAP_CLASS || service->type == SOAP_OBJECT) &&
zend_hash_str_exists(function_table, ZEND_CALL_FUNC_NAME, sizeof(ZEND_CALL_FUNC_NAME)-1))) {
if (service->type == SOAP_CLASS || service->type == SOAP_OBJECT) {
call_status = call_user_function(NULL, soap_obj, &h->function_name, &h->retval, h->num_params, h->parameters);
} else {
call_status = call_user_function(EG(function_table), NULL, &h->function_name, &h->retval, h->num_params, h->parameters);
}
if (call_status != SUCCESS) {
php_error_docref(NULL, E_WARNING, "Function '%s' call failed", Z_STRVAL(h->function_name));
return;
}
if (Z_TYPE(h->retval) == IS_OBJECT &&
instanceof_function(Z_OBJCE(h->retval), soap_fault_class_entry)) {
zval *tmp;
if ((tmp = zend_hash_str_find(Z_OBJPROP(h->retval), "headerfault", sizeof("headerfault")-1)) != NULL &&
Z_TYPE_P(tmp) != IS_NULL) {
}
php_output_discard();
soap_server_fault_ex(function, &h->retval, h);
efree(fn_name);
if (service->type == SOAP_CLASS && soap_obj) {zval_ptr_dtor(soap_obj);}
goto fail;
} else if (EG(exception)) {
php_output_discard();
_soap_server_exception(service, function, ZEND_THIS);
efree(fn_name);
if (service->type == SOAP_CLASS && soap_obj) {zval_ptr_dtor(soap_obj);}
goto fail;
}
} else if (h->mustUnderstand) {
soap_server_fault("MustUnderstand","Header not understood", NULL, NULL, NULL);
}
efree(fn_name);
}
}
fn_name = estrndup(Z_STRVAL(function_name),Z_STRLEN(function_name));
if (zend_hash_str_exists(function_table, php_strtolower(fn_name, Z_STRLEN(function_name)), Z_STRLEN(function_name)) ||
((service->type == SOAP_CLASS || service->type == SOAP_OBJECT) &&
zend_hash_str_exists(function_table, ZEND_CALL_FUNC_NAME, sizeof(ZEND_CALL_FUNC_NAME)-1))) {
if (service->type == SOAP_CLASS || service->type == SOAP_OBJECT) {
call_status = call_user_function(NULL, soap_obj, &function_name, &retval, num_params, params);
if (service->type == SOAP_CLASS) {
#if HAVE_PHP_SESSION && !defined(COMPILE_DL_SESSION)
if (service->soap_class.persistence != SOAP_PERSISTENCE_SESSION) {
zval_ptr_dtor(soap_obj);
soap_obj = NULL;
}
#else
zval_ptr_dtor(soap_obj);
soap_obj = NULL;
#endif
}
} else {
call_status = call_user_function(EG(function_table), NULL, &function_name, &retval, num_params, params);
}
} else {
php_error(E_ERROR, "Function '%s' doesn't exist", Z_STRVAL(function_name));
}
efree(fn_name);
if (EG(exception)) {
php_output_discard();
_soap_server_exception(service, function, ZEND_THIS);
if (service->type == SOAP_CLASS) {
#if HAVE_PHP_SESSION && !defined(COMPILE_DL_SESSION)
if (soap_obj && service->soap_class.persistence != SOAP_PERSISTENCE_SESSION) {
#else
if (soap_obj) {
#endif
zval_ptr_dtor(soap_obj);
}
}
goto fail;
}
if (call_status == SUCCESS) {
char *response_name;
if (Z_TYPE(retval) == IS_OBJECT &&
instanceof_function(Z_OBJCE(retval), soap_fault_class_entry)) {
php_output_discard();
soap_server_fault_ex(function, &retval, NULL);
goto fail;
}
if (function && function->responseName) {
response_name = estrdup(function->responseName);
} else {
response_name = emalloc(Z_STRLEN(function_name) + sizeof("Response"));
memcpy(response_name,Z_STRVAL(function_name),Z_STRLEN(function_name));
memcpy(response_name+Z_STRLEN(function_name),"Response",sizeof("Response"));
}
doc_return = serialize_response_call(function, response_name, service->uri, &retval, soap_headers, soap_version);
efree(response_name);
} else {
php_error_docref(NULL, E_WARNING, "Function '%s' call failed", Z_STRVAL(function_name));
return;
}
if (EG(exception)) {
php_output_discard();
_soap_server_exception(service, function, ZEND_THIS);
if (service->type == SOAP_CLASS) {
#if HAVE_PHP_SESSION && !defined(COMPILE_DL_SESSION)
if (soap_obj && service->soap_class.persistence != SOAP_PERSISTENCE_SESSION) {
#else
if (soap_obj) {
#endif
zval_ptr_dtor(soap_obj);
}
}
goto fail;
}
/* Flush buffer */
php_output_discard();
if (doc_return) {
/* xmlDocDumpMemoryEnc(doc_return, &buf, &size, XML_CHAR_ENCODING_UTF8); */
xmlDocDumpMemory(doc_return, &buf, &size);
if (size == 0) {
php_error_docref(NULL, E_ERROR, "Dump memory failed");
}
if (soap_version == SOAP_1_2) {
sapi_add_header("Content-Type: application/soap+xml; charset=utf-8", sizeof("Content-Type: application/soap+xml; charset=utf-8")-1, 1);
} else {
sapi_add_header("Content-Type: text/xml; charset=utf-8", sizeof("Content-Type: text/xml; charset=utf-8")-1, 1);
}
if (zend_ini_long("zlib.output_compression", sizeof("zlib.output_compression"), 0)) {
sapi_add_header("Connection: close", sizeof("Connection: close")-1, 1);
} else {
snprintf(cont_len, sizeof(cont_len), "Content-Length: %d", size);
sapi_add_header(cont_len, strlen(cont_len), 1);
}
php_write(buf, size);
xmlFree(buf);
} else {
sapi_add_header("HTTP/1.1 202 Accepted", sizeof("HTTP/1.1 202 Accepted")-1, 1);
sapi_add_header("Content-Length: 0", sizeof("Content-Length: 0")-1, 1);
}
fail:
SOAP_GLOBAL(soap_version) = old_soap_version;
SOAP_GLOBAL(encoding) = old_encoding;
SOAP_GLOBAL(sdl) = old_sdl;
SOAP_GLOBAL(class_map) = old_class_map;
SOAP_GLOBAL(typemap) = old_typemap;
SOAP_GLOBAL(features) = old_features;
if (doc_return) {
xmlFreeDoc(doc_return);
}
/* Free soap headers */
zval_ptr_dtor(&retval);
while (soap_headers != NULL) {
soapHeader *h = soap_headers;
int i;
soap_headers = soap_headers->next;
if (h->parameters) {
i = h->num_params;
while (i > 0) {
zval_ptr_dtor(&h->parameters[--i]);
}
efree(h->parameters);
}
zval_ptr_dtor_str(&h->function_name);
zval_ptr_dtor(&h->retval);
efree(h);
}
service->soap_headers_ptr = NULL;
/* Free Memory */
if (num_params > 0) {
for (i = 0; i < num_params;i++) {
zval_ptr_dtor(¶ms[i]);
}
efree(params);
}
zval_ptr_dtor_str(&function_name);
SOAP_SERVER_END_CODE();
}
/* }}} */
/* {{{ proto SoapServer::fault ( staring code, string string [, string actor [, mixed details [, string name]]] )
Issue SoapFault indicating an error */
PHP_METHOD(SoapServer, fault)
{
char *code, *string, *actor=NULL, *name=NULL;
size_t code_len, string_len, actor_len = 0, name_len = 0;
zval* details = NULL;
soapServicePtr service;
xmlCharEncodingHandlerPtr old_encoding;
SOAP_SERVER_BEGIN_CODE();
FETCH_THIS_SERVICE(service);
old_encoding = SOAP_GLOBAL(encoding);
SOAP_GLOBAL(encoding) = service->encoding;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss|szs",
&code, &code_len, &string, &string_len, &actor, &actor_len, &details,
&name, &name_len) == FAILURE) {
RETURN_THROWS();
}
soap_server_fault(code, string, actor, details, name);
SOAP_GLOBAL(encoding) = old_encoding;
SOAP_SERVER_END_CODE();
}
/* }}} */
/* {{{ proto SoapServer::addSoapHeader(SoapHeader $object) */
PHP_METHOD(SoapServer, addSoapHeader)
{
soapServicePtr service;
zval *fault;
soapHeader **p;
SOAP_SERVER_BEGIN_CODE();
if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &fault, soap_header_class_entry) == FAILURE) {
RETURN_THROWS();
}
FETCH_THIS_SERVICE(service);
if (!service || !service->soap_headers_ptr) {
php_error_docref(NULL, E_WARNING, "The SoapServer::addSoapHeader function may be called only during SOAP request processing");
return;
}
p = service->soap_headers_ptr;
while (*p != NULL) {
p = &(*p)->next;
}
*p = emalloc(sizeof(soapHeader));
memset(*p, 0, sizeof(soapHeader));
ZVAL_NULL(&(*p)->function_name);
Z_ADDREF_P(fault);
ZVAL_OBJ(&(*p)->retval, Z_OBJ_P(fault));
SOAP_SERVER_END_CODE();
}
/* }}} */
static void soap_server_fault_ex(sdlFunctionPtr function, zval* fault, soapHeader *hdr) /* {{{ */
{
int soap_version;
xmlChar *buf;
char cont_len[30];
int size;
xmlDocPtr doc_return;
zval *agent_name;
int use_http_error_status = 1;
soap_version = SOAP_GLOBAL(soap_version);
doc_return = serialize_response_call(function, NULL, NULL, fault, hdr, soap_version);
xmlDocDumpMemory(doc_return, &buf, &size);
if ((Z_TYPE(PG(http_globals)[TRACK_VARS_SERVER]) == IS_ARRAY || zend_is_auto_global_str(ZEND_STRL("_SERVER"))) &&
(agent_name = zend_hash_str_find(Z_ARRVAL(PG(http_globals)[TRACK_VARS_SERVER]), "HTTP_USER_AGENT", sizeof("HTTP_USER_AGENT")-1)) != NULL &&
Z_TYPE_P(agent_name) == IS_STRING) {
if (strncmp(Z_STRVAL_P(agent_name), "Shockwave Flash", sizeof("Shockwave Flash")-1) == 0) {
use_http_error_status = 0;
}
}
/*
Want to return HTTP 500 but apache wants to over write
our fault code with their own handling... Figure this out later
*/
if (use_http_error_status) {
sapi_add_header("HTTP/1.1 500 Internal Service Error", sizeof("HTTP/1.1 500 Internal Service Error")-1, 1);
}
if (zend_ini_long("zlib.output_compression", sizeof("zlib.output_compression"), 0)) {
sapi_add_header("Connection: close", sizeof("Connection: close")-1, 1);
} else {
snprintf(cont_len, sizeof(cont_len), "Content-Length: %d", size);
sapi_add_header(cont_len, strlen(cont_len), 1);
}
if (soap_version == SOAP_1_2) {
sapi_add_header("Content-Type: application/soap+xml; charset=utf-8", sizeof("Content-Type: application/soap+xml; charset=utf-8")-1, 1);
} else {
sapi_add_header("Content-Type: text/xml; charset=utf-8", sizeof("Content-Type: text/xml; charset=utf-8")-1, 1);
}
php_write(buf, size);
xmlFreeDoc(doc_return);
xmlFree(buf);
zend_clear_exception();
}
/* }}} */
static ZEND_NORETURN void soap_server_fault(char* code, char* string, char *actor, zval* details, char* name) /* {{{ */
{
zval ret;
ZVAL_NULL(&ret);
set_soap_fault(&ret, NULL, code, string, actor, details, name);
/* TODO: Which function */
soap_server_fault_ex(NULL, &ret, NULL);
zend_bailout();
}
/* }}} */
static zend_never_inline ZEND_COLD void soap_real_error_handler(int error_num, const char *error_filename, const uint32_t error_lineno, const char *format, va_list args) /* {{{ */
{
zend_bool _old_in_compilation;
zend_execute_data *_old_current_execute_data;
int _old_http_response_code;
char *_old_http_status_line;
_old_in_compilation = CG(in_compilation);
_old_current_execute_data = EG(current_execute_data);
_old_http_response_code = SG(sapi_headers).http_response_code;
_old_http_status_line = SG(sapi_headers).http_status_line;
if (Z_OBJ(SOAP_GLOBAL(error_object)) &&
instanceof_function(Z_OBJCE(SOAP_GLOBAL(error_object)), soap_class_entry)) {
zval *tmp;
int use_exceptions = 0;
if ((tmp = zend_hash_str_find(Z_OBJPROP(SOAP_GLOBAL(error_object)), "_exceptions", sizeof("_exceptions")-1)) == NULL ||
Z_TYPE_P(tmp) != IS_FALSE) {
use_exceptions = 1;
}
if ((error_num == E_USER_ERROR ||
error_num == E_COMPILE_ERROR ||
error_num == E_CORE_ERROR ||
error_num == E_ERROR ||
error_num == E_PARSE) &&
use_exceptions) {
zval fault;
char* code = SOAP_GLOBAL(error_code);
char buffer[1024];
size_t buffer_len;
va_list argcopy;
va_copy(argcopy, args);
buffer_len = vslprintf(buffer, sizeof(buffer)-1, format, argcopy);
va_end(argcopy);
buffer[sizeof(buffer)-1]=0;
if (buffer_len > sizeof(buffer) - 1 || buffer_len == (size_t)-1) {
buffer_len = sizeof(buffer) - 1;
}
if (code == NULL) {
code = "Client";
}
add_soap_fault_ex(&fault, &SOAP_GLOBAL(error_object), code, buffer, NULL, NULL);
Z_ADDREF(fault);
zend_throw_exception_object(&fault);
zend_bailout();
} else if (!use_exceptions ||
!SOAP_GLOBAL(error_code) ||
strcmp(SOAP_GLOBAL(error_code),"WSDL") != 0) {
/* Ignore libxml warnings during WSDL parsing */
call_old_error_handler(error_num, error_filename, error_lineno, format, args);
}
} else {
int old = PG(display_errors);
int fault = 0;
zval fault_obj;
va_list argcopy;
if (error_num == E_USER_ERROR ||
error_num == E_COMPILE_ERROR ||
error_num == E_CORE_ERROR ||
error_num == E_ERROR ||
error_num == E_PARSE) {
char* code = SOAP_GLOBAL(error_code);
char buffer[1024];
zval outbuf;
zval *tmp;
soapServicePtr service;
ZVAL_UNDEF(&outbuf);
if (code == NULL) {
code = "Server";
}
if (Z_OBJ(SOAP_GLOBAL(error_object)) &&
instanceof_function(Z_OBJCE(SOAP_GLOBAL(error_object)), soap_server_class_entry) &&
(tmp = zend_hash_str_find(Z_OBJPROP(SOAP_GLOBAL(error_object)), "service", sizeof("service")-1)) != NULL &&
(service = (soapServicePtr)zend_fetch_resource_ex(tmp, "service", le_service)) &&
!service->send_errors) {
strcpy(buffer, "Internal Error");
} else {
size_t buffer_len;
zval outbuflen;
va_copy(argcopy, args);
buffer_len = vslprintf(buffer, sizeof(buffer)-1, format, argcopy);
va_end(argcopy);
buffer[sizeof(buffer)-1]=0;
if (buffer_len > sizeof(buffer) - 1 || buffer_len == (size_t)-1) {
buffer_len = sizeof(buffer) - 1;
}
/* Get output buffer and send as fault detials */
if (php_output_get_length(&outbuflen) != FAILURE && Z_LVAL(outbuflen) != 0) {
php_output_get_contents(&outbuf);
}
php_output_discard();
}
ZVAL_NULL(&fault_obj);
set_soap_fault(&fault_obj, NULL, code, buffer, NULL, &outbuf, NULL);
fault = 1;
}
PG(display_errors) = 0;
SG(sapi_headers).http_status_line = NULL;
zend_try {
call_old_error_handler(error_num, error_filename, error_lineno, format, args);
} zend_catch {
CG(in_compilation) = _old_in_compilation;
EG(current_execute_data) = _old_current_execute_data;
if (SG(sapi_headers).http_status_line) {
efree(SG(sapi_headers).http_status_line);
}
SG(sapi_headers).http_status_line = _old_http_status_line;
SG(sapi_headers).http_response_code = _old_http_response_code;
} zend_end_try();
PG(display_errors) = old;
if (fault) {
soap_server_fault_ex(NULL, &fault_obj, NULL);
zend_bailout();
}
}
}
/* }}} */
static void soap_error_handler(int error_num, const char *error_filename, const uint32_t error_lineno, const char *format, va_list args) /* {{{ */
{
if (EXPECTED(!SOAP_GLOBAL(use_soap_error_handler))) {
call_old_error_handler(error_num, error_filename, error_lineno, format, args);
} else {
soap_real_error_handler(error_num, error_filename, error_lineno, format, args);
}
}
/* }}} */
/* {{{ proto use_soap_error_handler([bool $handler = TRUE]) */
PHP_FUNCTION(use_soap_error_handler)
{
zend_bool handler = 1;
ZVAL_BOOL(return_value, SOAP_GLOBAL(use_soap_error_handler));
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|b", &handler) == SUCCESS) {
SOAP_GLOBAL(use_soap_error_handler) = handler;
}
}
/* }}} */
/* {{{ proto is_soap_fault(mixed $object) */
PHP_FUNCTION(is_soap_fault)
{
zval *fault;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &fault) == SUCCESS &&
Z_TYPE_P(fault) == IS_OBJECT &&
instanceof_function(Z_OBJCE_P(fault), soap_fault_class_entry)) {
RETURN_TRUE;
}
RETURN_FALSE;
}
/* }}} */
/* SoapClient functions */
/* {{{ proto object SoapClient::__construct(mixed wsdl [, array options])
SoapClient constructor */
PHP_METHOD(SoapClient, __construct)
{
zval *wsdl, *options = NULL;
int soap_version = SOAP_1_1;
php_stream_context *context = NULL;
zend_long cache_wsdl;
sdlPtr sdl = NULL;
HashTable *typemap_ht = NULL;
zval *this_ptr = ZEND_THIS;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "z|a", &wsdl, &options) == FAILURE) {
RETURN_THROWS();
}
SOAP_CLIENT_BEGIN_CODE();
if (Z_TYPE_P(wsdl) != IS_STRING && Z_TYPE_P(wsdl) != IS_NULL) {
php_error_docref(NULL, E_ERROR, "$wsdl must be string or null");
}
cache_wsdl = SOAP_GLOBAL(cache_enabled) ? SOAP_GLOBAL(cache_mode) : 0;
if (options != NULL) {
HashTable *ht = Z_ARRVAL_P(options);
zval *tmp, tmp2;
if (Z_TYPE_P(wsdl) == IS_NULL) {
/* Fetching non-WSDL mode options */
if ((tmp = zend_hash_str_find(ht, "uri", sizeof("uri")-1)) != NULL &&
Z_TYPE_P(tmp) == IS_STRING) {
add_property_str(this_ptr, "uri", zend_string_copy(Z_STR_P(tmp)));
} else {
php_error_docref(NULL, E_ERROR, "'uri' option is required in nonWSDL mode");
}
if ((tmp = zend_hash_str_find(ht, "style", sizeof("style")-1)) != NULL &&
Z_TYPE_P(tmp) == IS_LONG &&
(Z_LVAL_P(tmp) == SOAP_RPC || Z_LVAL_P(tmp) == SOAP_DOCUMENT)) {
add_property_long(this_ptr, "style", Z_LVAL_P(tmp));
}
if ((tmp = zend_hash_str_find(ht, "use", sizeof("use")-1)) != NULL &&
Z_TYPE_P(tmp) == IS_LONG &&
(Z_LVAL_P(tmp) == SOAP_LITERAL || Z_LVAL_P(tmp) == SOAP_ENCODED)) {
add_property_long(this_ptr, "use", Z_LVAL_P(tmp));
}
}
if ((tmp = zend_hash_str_find(ht, "stream_context", sizeof("stream_context")-1)) != NULL &&
Z_TYPE_P(tmp) == IS_RESOURCE) {
context = php_stream_context_from_zval(tmp, 1);
Z_ADDREF_P(tmp);
} else {
context = php_stream_context_alloc();
}
if ((tmp = zend_hash_str_find(ht, "location", sizeof("location")-1)) != NULL &&
Z_TYPE_P(tmp) == IS_STRING) {
add_property_str(this_ptr, "location", zend_string_copy(Z_STR_P(tmp)));
} else if (Z_TYPE_P(wsdl) == IS_NULL) {
php_error_docref(NULL, E_ERROR, "'location' option is required in nonWSDL mode");
}
if ((tmp = zend_hash_str_find(ht, "soap_version", sizeof("soap_version")-1)) != NULL) {
if (Z_TYPE_P(tmp) == IS_LONG ||
(Z_LVAL_P(tmp) == SOAP_1_1 && Z_LVAL_P(tmp) == SOAP_1_2)) {
soap_version = Z_LVAL_P(tmp);
}
}
if ((tmp = zend_hash_str_find(ht, "login", sizeof("login")-1)) != NULL &&
Z_TYPE_P(tmp) == IS_STRING) {
add_property_str(this_ptr, "_login", zend_string_copy(Z_STR_P(tmp)));
if ((tmp = zend_hash_str_find(ht, "password", sizeof("password")-1)) != NULL &&
Z_TYPE_P(tmp) == IS_STRING) {
add_property_str(this_ptr, "_password", zend_string_copy(Z_STR_P(tmp)));
}
if ((tmp = zend_hash_str_find(ht, "authentication", sizeof("authentication")-1)) != NULL &&
Z_TYPE_P(tmp) == IS_LONG &&
Z_LVAL_P(tmp) == SOAP_AUTHENTICATION_DIGEST) {
add_property_null(this_ptr, "_digest");
}
}
if ((tmp = zend_hash_str_find(ht, "proxy_host", sizeof("proxy_host")-1)) != NULL &&
Z_TYPE_P(tmp) == IS_STRING) {
add_property_str(this_ptr, "_proxy_host", zend_string_copy(Z_STR_P(tmp)));
if ((tmp = zend_hash_str_find(ht, "proxy_port", sizeof("proxy_port")-1)) != NULL) {
if (Z_TYPE_P(tmp) != IS_LONG) {
ZVAL_LONG(&tmp2, zval_get_long(tmp));
tmp = &tmp2;
}
add_property_long(this_ptr, "_proxy_port", Z_LVAL_P(tmp));
}
if ((tmp = zend_hash_str_find(ht, "proxy_login", sizeof("proxy_login")-1)) != NULL &&
Z_TYPE_P(tmp) == IS_STRING) {
add_property_str(this_ptr, "_proxy_login", zend_string_copy(Z_STR_P(tmp)));
if ((tmp = zend_hash_str_find(ht, "proxy_password", sizeof("proxy_password")-1)) != NULL &&
Z_TYPE_P(tmp) == IS_STRING) {
add_property_str(this_ptr, "_proxy_password", zend_string_copy(Z_STR_P(tmp)));
}
}
}
if ((tmp = zend_hash_str_find(ht, "local_cert", sizeof("local_cert")-1)) != NULL &&
Z_TYPE_P(tmp) == IS_STRING) {
if (!context) {
context = php_stream_context_alloc();
}
php_stream_context_set_option(context, "ssl", "local_cert", tmp);
if ((tmp = zend_hash_str_find(ht, "passphrase", sizeof("passphrase")-1)) != NULL &&
Z_TYPE_P(tmp) == IS_STRING) {
php_stream_context_set_option(context, "ssl", "passphrase", tmp);
}
}
if ((tmp = zend_hash_str_find(ht, "trace", sizeof("trace")-1)) != NULL &&
(Z_TYPE_P(tmp) == IS_TRUE ||
(Z_TYPE_P(tmp) == IS_LONG && Z_LVAL_P(tmp) == 1))) {
add_property_long(this_ptr, "trace", 1);
}
if ((tmp = zend_hash_str_find(ht, "exceptions", sizeof("exceptions")-1)) != NULL &&
(Z_TYPE_P(tmp) == IS_FALSE ||
(Z_TYPE_P(tmp) == IS_LONG && Z_LVAL_P(tmp) == 0))) {
add_property_bool(this_ptr, "_exceptions", 0);
}
if ((tmp = zend_hash_str_find(ht, "compression", sizeof("compression")-1)) != NULL &&
Z_TYPE_P(tmp) == IS_LONG &&
zend_hash_str_exists(EG(function_table), "gzinflate", sizeof("gzinflate")-1) &&
zend_hash_str_exists(EG(function_table), "gzdeflate", sizeof("gzdeflate")-1) &&
zend_hash_str_exists(EG(function_table), "gzuncompress", sizeof("gzuncompress")-1) &&
zend_hash_str_exists(EG(function_table), "gzcompress", sizeof("gzcompress")-1) &&
zend_hash_str_exists(EG(function_table), "gzencode", sizeof("gzencode")-1)) {
add_property_long(this_ptr, "compression", Z_LVAL_P(tmp));
}
if ((tmp = zend_hash_str_find(ht, "encoding", sizeof("encoding")-1)) != NULL &&
Z_TYPE_P(tmp) == IS_STRING) {
xmlCharEncodingHandlerPtr encoding;
encoding = xmlFindCharEncodingHandler(Z_STRVAL_P(tmp));
if (encoding == NULL) {
php_error_docref(NULL, E_ERROR, "Invalid 'encoding' option - '%s'", Z_STRVAL_P(tmp));
} else {
xmlCharEncCloseFunc(encoding);
add_property_str(this_ptr, "_encoding", zend_string_copy(Z_STR_P(tmp)));
}
}
if ((tmp = zend_hash_str_find(ht, "classmap", sizeof("classmap")-1)) != NULL &&
Z_TYPE_P(tmp) == IS_ARRAY) {
add_property_zval(this_ptr, "_classmap", tmp);
}
if ((tmp = zend_hash_str_find(ht, "typemap", sizeof("typemap")-1)) != NULL &&
Z_TYPE_P(tmp) == IS_ARRAY &&
zend_hash_num_elements(Z_ARRVAL_P(tmp)) > 0) {
typemap_ht = Z_ARRVAL_P(tmp);
}
if ((tmp = zend_hash_str_find(ht, "features", sizeof("features")-1)) != NULL &&
Z_TYPE_P(tmp) == IS_LONG) {
add_property_long(this_ptr, "_features", Z_LVAL_P(tmp));
}
if ((tmp = zend_hash_str_find(ht, "connection_timeout", sizeof("connection_timeout")-1)) != NULL) {
if (Z_TYPE_P(tmp) != IS_LONG) {
ZVAL_LONG(&tmp2, zval_get_long(tmp));
tmp = &tmp2;
}
if (Z_LVAL_P(tmp) > 0) {
add_property_long(this_ptr, "_connection_timeout", Z_LVAL_P(tmp));
}
}
if (context) {
add_property_resource(this_ptr, "_stream_context", context->res);
}
if ((tmp = zend_hash_str_find(ht, "cache_wsdl", sizeof("cache_wsdl")-1)) != NULL &&
Z_TYPE_P(tmp) == IS_LONG) {
cache_wsdl = Z_LVAL_P(tmp);
}
if ((tmp = zend_hash_str_find(ht, "user_agent", sizeof("user_agent")-1)) != NULL &&
Z_TYPE_P(tmp) == IS_STRING) {
add_property_str(this_ptr, "_user_agent", zend_string_copy(Z_STR_P(tmp)));
}
if ((tmp = zend_hash_str_find(ht, "keep_alive", sizeof("keep_alive")-1)) != NULL &&
(Z_TYPE_P(tmp) == IS_FALSE ||
(Z_TYPE_P(tmp) == IS_LONG && Z_LVAL_P(tmp) == 0))) {
add_property_long(this_ptr, "_keep_alive", 0);
}
if ((tmp = zend_hash_str_find(ht, "ssl_method", sizeof("ssl_method")-1)) != NULL &&
Z_TYPE_P(tmp) == IS_LONG) {
add_property_long(this_ptr, "_ssl_method", Z_LVAL_P(tmp));
}
} else if (Z_TYPE_P(wsdl) == IS_NULL) {
php_error_docref(NULL, E_ERROR, "'location' and 'uri' options are required in nonWSDL mode");
}
add_property_long(this_ptr, "_soap_version", soap_version);
if (Z_TYPE_P(wsdl) != IS_NULL) {
int old_soap_version;
zend_resource *res;
old_soap_version = SOAP_GLOBAL(soap_version);
SOAP_GLOBAL(soap_version) = soap_version;
sdl = get_sdl(this_ptr, Z_STRVAL_P(wsdl), cache_wsdl);
res = zend_register_resource(sdl, le_sdl);
add_property_resource(this_ptr, "sdl", res);
SOAP_GLOBAL(soap_version) = old_soap_version;
}
if (typemap_ht) {
HashTable *typemap = soap_create_typemap(sdl, typemap_ht);
if (typemap) {
zend_resource *res;
res = zend_register_resource(typemap, le_typemap);
add_property_resource(this_ptr, "typemap", res);
}
}
SOAP_CLIENT_END_CODE();
}
/* }}} */
static int do_request(zval *this_ptr, xmlDoc *request, char *location, char *action, int version, int one_way, zval *response) /* {{{ */
{
int ret = TRUE;
char *buf;
int buf_size;
zval func;
zval params[5];
zval *trace;
zval *fault;
int _bailout = 0;
ZVAL_NULL(response);
xmlDocDumpMemory(request, (xmlChar**)&buf, &buf_size);
if (!buf) {
add_soap_fault(this_ptr, "HTTP", "Error build soap request", NULL, NULL);
return FALSE;
}
zend_try {
if ((trace = zend_hash_str_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace")-1)) != NULL &&
(Z_TYPE_P(trace) == IS_TRUE || (Z_TYPE_P(trace) == IS_LONG && Z_LVAL_P(trace) != 0))) {
add_property_stringl(this_ptr, "__last_request", buf, buf_size);
}
ZVAL_STRINGL(&func,"__doRequest",sizeof("__doRequest")-1);
ZVAL_STRINGL(¶ms[0], buf, buf_size);
if (location == NULL) {
ZVAL_NULL(¶ms[1]);
} else {
ZVAL_STRING(¶ms[1], location);
}
if (action == NULL) {
ZVAL_NULL(¶ms[2]);
} else {
ZVAL_STRING(¶ms[2], action);
}
ZVAL_LONG(¶ms[3], version);
ZVAL_LONG(¶ms[4], one_way);
if (call_user_function(NULL, this_ptr, &func, response, 5, params) != SUCCESS) {
add_soap_fault(this_ptr, "Client", "SoapClient::__doRequest() failed", NULL, NULL);
ret = FALSE;
} else if (Z_TYPE_P(response) != IS_STRING) {
if (EG(exception) && instanceof_function(EG(exception)->ce, zend_ce_error)) {
zval rv;
zend_string *msg;
zval exception_object;
ZVAL_OBJ(&exception_object, EG(exception));
msg = zval_get_string(zend_read_property(zend_ce_error, &exception_object, "message", sizeof("message")-1, 0, &rv));
/* change class */
EG(exception)->ce = soap_fault_class_entry;
set_soap_fault(&exception_object, NULL, "Client", ZSTR_VAL(msg), NULL, NULL, NULL);
zend_string_release_ex(msg, 0);
} else if ((fault = zend_hash_str_find(Z_OBJPROP_P(this_ptr), "__soap_fault", sizeof("__soap_fault")-1)) == NULL) {
add_soap_fault(this_ptr, "Client", "SoapClient::__doRequest() returned non string value", NULL, NULL);
}
ret = FALSE;
} else if ((trace = zend_hash_str_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace")-1)) != NULL &&
(Z_TYPE_P(trace) == IS_TRUE || (Z_TYPE_P(trace) == IS_LONG && Z_LVAL_P(trace) != 0))) {
add_property_str(this_ptr, "__last_response", zend_string_copy(Z_STR_P(response)));
}
} zend_catch {
_bailout = 1;
} zend_end_try();
zval_ptr_dtor(&func);
zval_ptr_dtor(¶ms[2]);
zval_ptr_dtor(¶ms[1]);
zval_ptr_dtor(¶ms[0]);
xmlFree(buf);
if (_bailout) {
zend_bailout();
}
if (ret && (fault = zend_hash_str_find(Z_OBJPROP_P(this_ptr), "__soap_fault", sizeof("__soap_fault")-1)) != NULL) {
ret = FALSE;
}
return ret;
}
/* }}} */
static void do_soap_call(zend_execute_data *execute_data,
zval* this_ptr,
char* function,
size_t function_len,
int arg_count,
zval* real_args,
zval* return_value,
char* location,
char* soap_action,
char* call_uri,
HashTable* soap_headers,
zval* output_headers
) /* {{{ */
{
zval *tmp;
zval *trace;
sdlPtr sdl = NULL;
sdlPtr old_sdl = NULL;
sdlFunctionPtr fn;
xmlDocPtr request = NULL;
int ret = FALSE;
int soap_version;
zval response;
xmlCharEncodingHandlerPtr old_encoding;
HashTable *old_class_map;
int old_features;
HashTable *old_typemap, *typemap = NULL;
smart_str action = {0};
int bailout = 0;
SOAP_CLIENT_BEGIN_CODE();
if ((trace = zend_hash_str_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace")-1)) != NULL &&
(Z_TYPE_P(trace) == IS_TRUE || (Z_TYPE_P(trace) == IS_LONG && Z_LVAL_P(trace) != 0))) {
zend_hash_str_del(Z_OBJPROP_P(this_ptr), "__last_request", sizeof("__last_request")-1);
zend_hash_str_del(Z_OBJPROP_P(this_ptr), "__last_response", sizeof("__last_response")-1);
}
if ((tmp = zend_hash_str_find(Z_OBJPROP_P(this_ptr), "_soap_version", sizeof("_soap_version")-1)) != NULL &&
Z_TYPE_P(tmp) == IS_LONG && Z_LVAL_P(tmp) == SOAP_1_2) {
soap_version = SOAP_1_2;
} else {
soap_version = SOAP_1_1;
}
if (location == NULL) {
if ((tmp = zend_hash_str_find(Z_OBJPROP_P(this_ptr), "location", sizeof("location")-1)) != NULL &&
Z_TYPE_P(tmp) == IS_STRING) {
location = Z_STRVAL_P(tmp);
}
}
if (FIND_SDL_PROPERTY(this_ptr,tmp) != NULL) {
FETCH_SDL_RES(sdl,tmp);
}
if (FIND_TYPEMAP_PROPERTY(this_ptr,tmp) != NULL) {
FETCH_TYPEMAP_RES(typemap,tmp);
}
clear_soap_fault(this_ptr);
SOAP_GLOBAL(soap_version) = soap_version;
old_sdl = SOAP_GLOBAL(sdl);
SOAP_GLOBAL(sdl) = sdl;
old_encoding = SOAP_GLOBAL(encoding);
if ((tmp = zend_hash_str_find(Z_OBJPROP_P(this_ptr), "_encoding", sizeof("_encoding")-1)) != NULL &&
Z_TYPE_P(tmp) == IS_STRING) {
SOAP_GLOBAL(encoding) = xmlFindCharEncodingHandler(Z_STRVAL_P(tmp));
} else {
SOAP_GLOBAL(encoding) = NULL;
}
old_class_map = SOAP_GLOBAL(class_map);
if ((tmp = zend_hash_str_find(Z_OBJPROP_P(this_ptr), "_classmap", sizeof("_classmap")-1)) != NULL &&
Z_TYPE_P(tmp) == IS_ARRAY) {
SOAP_GLOBAL(class_map) = Z_ARRVAL_P(tmp);
} else {
SOAP_GLOBAL(class_map) = NULL;
}
old_typemap = SOAP_GLOBAL(typemap);
SOAP_GLOBAL(typemap) = typemap;
old_features = SOAP_GLOBAL(features);
if ((tmp = zend_hash_str_find(Z_OBJPROP_P(this_ptr), "_features", sizeof("_features")-1)) != NULL &&
Z_TYPE_P(tmp) == IS_LONG) {
SOAP_GLOBAL(features) = Z_LVAL_P(tmp);
} else {
SOAP_GLOBAL(features) = 0;
}
zend_try {
if (sdl != NULL) {
fn = get_function(sdl, function);
if (fn != NULL) {
sdlBindingPtr binding = fn->binding;
int one_way = 0;
if (fn->responseName == NULL &&
fn->responseParameters == NULL &&
soap_headers == NULL) {
one_way = 1;
}
if (location == NULL) {
location = binding->location;
}
if (binding->bindingType == BINDING_SOAP) {
sdlSoapBindingFunctionPtr fnb = (sdlSoapBindingFunctionPtr)fn->bindingAttributes;
request = serialize_function_call(this_ptr, fn, NULL, fnb->input.ns, real_args, arg_count, soap_version, soap_headers);
ret = do_request(this_ptr, request, location, fnb->soapAction, soap_version, one_way, &response);
} else {
request = serialize_function_call(this_ptr, fn, NULL, sdl->target_ns, real_args, arg_count, soap_version, soap_headers);
ret = do_request(this_ptr, request, location, NULL, soap_version, one_way, &response);
}
xmlFreeDoc(request);
request = NULL;
if (ret && Z_TYPE(response) == IS_STRING) {
encode_reset_ns();
ret = parse_packet_soap(this_ptr, Z_STRVAL(response), Z_STRLEN(response), fn, NULL, return_value, output_headers);
encode_finish();
}
zval_ptr_dtor(&response);
} else {
smart_str error = {0};
smart_str_appends(&error,"Function (\"");
smart_str_appends(&error,function);
smart_str_appends(&error,"\") is not a valid method for this service");
smart_str_0(&error);
add_soap_fault(this_ptr, "Client", ZSTR_VAL(error.s), NULL, NULL);
smart_str_free(&error);
}
} else {
zval *uri;
if ((uri = zend_hash_str_find(Z_OBJPROP_P(this_ptr), "uri", sizeof("uri")-1)) == NULL || Z_TYPE_P(uri) != IS_STRING) {
add_soap_fault(this_ptr, "Client", "Error finding \"uri\" property", NULL, NULL);
} else if (location == NULL) {
add_soap_fault(this_ptr, "Client", "Error could not find \"location\" property", NULL, NULL);
} else {
if (call_uri == NULL) {
call_uri = Z_STRVAL_P(uri);
}
request = serialize_function_call(this_ptr, NULL, function, call_uri, real_args, arg_count, soap_version, soap_headers);
if (soap_action == NULL) {
smart_str_appends(&action, call_uri);
smart_str_appendc(&action, '#');
smart_str_appends(&action, function);
} else {
smart_str_appends(&action, soap_action);
}
smart_str_0(&action);
ret = do_request(this_ptr, request, location, ZSTR_VAL(action.s), soap_version, 0, &response);
smart_str_free(&action);
xmlFreeDoc(request);
request = NULL;
if (ret && Z_TYPE(response) == IS_STRING) {
encode_reset_ns();
ret = parse_packet_soap(this_ptr, Z_STRVAL(response), Z_STRLEN(response), NULL, function, return_value, output_headers);
encode_finish();
}
zval_ptr_dtor(&response);
}
}
if (!ret) {
zval* fault;
if ((fault = zend_hash_str_find(Z_OBJPROP_P(this_ptr), "__soap_fault", sizeof("__soap_fault")-1)) != NULL) {
ZVAL_COPY(return_value, fault);
} else {
add_soap_fault_ex(return_value, this_ptr, "Client", "Unknown Error", NULL, NULL);
Z_ADDREF_P(return_value);
}
} else {
zval* fault;
if ((fault = zend_hash_str_find(Z_OBJPROP_P(this_ptr), "__soap_fault", sizeof("__soap_fault")-1)) != NULL) {
ZVAL_COPY(return_value, fault);
}
}
if (!EG(exception) &&
Z_TYPE_P(return_value) == IS_OBJECT &&
instanceof_function(Z_OBJCE_P(return_value), soap_fault_class_entry) &&
((tmp = zend_hash_str_find(Z_OBJPROP_P(this_ptr), "_exceptions", sizeof("_exceptions")-1)) == NULL ||
Z_TYPE_P(tmp) != IS_FALSE)) {
Z_ADDREF_P(return_value);
zend_throw_exception_object(return_value);
}
} zend_catch {
bailout = 1;
} zend_end_try();
if (SOAP_GLOBAL(encoding) != NULL) {
xmlCharEncCloseFunc(SOAP_GLOBAL(encoding));
}
SOAP_GLOBAL(features) = old_features;
SOAP_GLOBAL(typemap) = old_typemap;
SOAP_GLOBAL(class_map) = old_class_map;
SOAP_GLOBAL(encoding) = old_encoding;
SOAP_GLOBAL(sdl) = old_sdl;
if (bailout) {
smart_str_free(&action);
if (request) {
xmlFreeDoc(request);
}
zend_bailout();
}
SOAP_CLIENT_END_CODE();
}
/* }}} */
static void verify_soap_headers_array(HashTable *ht) /* {{{ */
{
zval *tmp;
ZEND_HASH_FOREACH_VAL(ht, tmp) {
if (Z_TYPE_P(tmp) != IS_OBJECT ||
!instanceof_function(Z_OBJCE_P(tmp), soap_header_class_entry)) {
php_error_docref(NULL, E_ERROR, "Invalid SOAP header");
}
} ZEND_HASH_FOREACH_END();
}
/* }}} */
/* {{{ proto mixed SoapClient::__call(string function_name, array arguments [, array options [, array input_headers [, array &output_headers]]])
Calls a SOAP function */
PHP_METHOD(SoapClient, __call)
{
char *function, *location=NULL, *soap_action = NULL, *uri = NULL;
size_t function_len;
int i = 0;
HashTable* soap_headers = NULL;
zval *options = NULL;
zval *headers = NULL;
zval *output_headers = NULL;
zval *args;
zval *real_args = NULL;
zval *param;
int arg_count;
zval *tmp;
zend_bool free_soap_headers = 0;
zval *this_ptr;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "sa|a!zz",
&function, &function_len, &args, &options, &headers, &output_headers) == FAILURE) {
RETURN_THROWS();
}
if (options) {
HashTable *hto = Z_ARRVAL_P(options);
if ((tmp = zend_hash_str_find(hto, "location", sizeof("location")-1)) != NULL &&
Z_TYPE_P(tmp) == IS_STRING) {
location = Z_STRVAL_P(tmp);
}
if ((tmp = zend_hash_str_find(hto, "soapaction", sizeof("soapaction")-1)) != NULL &&
Z_TYPE_P(tmp) == IS_STRING) {
soap_action = Z_STRVAL_P(tmp);
}
if ((tmp = zend_hash_str_find(hto, "uri", sizeof("uri")-1)) != NULL &&
Z_TYPE_P(tmp) == IS_STRING) {
uri = Z_STRVAL_P(tmp);
}
}
if (headers == NULL || Z_TYPE_P(headers) == IS_NULL) {
} else if (Z_TYPE_P(headers) == IS_ARRAY) {
soap_headers = Z_ARRVAL_P(headers);
verify_soap_headers_array(soap_headers);
free_soap_headers = 0;
} else if (Z_TYPE_P(headers) == IS_OBJECT &&
instanceof_function(Z_OBJCE_P(headers), soap_header_class_entry)) {
soap_headers = zend_new_array(0);
zend_hash_next_index_insert(soap_headers, headers);
Z_ADDREF_P(headers);
free_soap_headers = 1;
} else{
php_error_docref(NULL, E_WARNING, "Invalid SOAP header");
return;
}
/* Add default headers */
this_ptr = ZEND_THIS;
if ((tmp = zend_hash_str_find(Z_OBJPROP_P(this_ptr), "__default_headers", sizeof("__default_headers")-1)) != NULL && Z_TYPE_P(tmp) == IS_ARRAY) {
HashTable *default_headers = Z_ARRVAL_P(tmp);
if (soap_headers) {
if (!free_soap_headers) {
soap_headers = zend_array_dup(soap_headers);
free_soap_headers = 1;
}
ZEND_HASH_FOREACH_VAL(default_headers, tmp) {
if(Z_TYPE_P(tmp) == IS_OBJECT) {
Z_ADDREF_P(tmp);
zend_hash_next_index_insert(soap_headers, tmp);
}
} ZEND_HASH_FOREACH_END();
} else {
soap_headers = Z_ARRVAL_P(tmp);
free_soap_headers = 0;
}
}
arg_count = zend_hash_num_elements(Z_ARRVAL_P(args));
if (arg_count > 0) {
real_args = safe_emalloc(sizeof(zval), arg_count, 0);
ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(args), param) {
/*zval_add_ref(param);*/
ZVAL_DEREF(param);
ZVAL_COPY_VALUE(&real_args[i], param);
i++;
} ZEND_HASH_FOREACH_END();
}
if (output_headers) {
output_headers = zend_try_array_init(output_headers);
if (!output_headers) {
goto cleanup;
}
}
do_soap_call(execute_data, this_ptr, function, function_len, arg_count, real_args, return_value, location, soap_action, uri, soap_headers, output_headers);
cleanup:
if (arg_count > 0) {
efree(real_args);
}
if (soap_headers && free_soap_headers) {
zend_hash_destroy(soap_headers);
efree(soap_headers);
}
}
/* }}} */
/* {{{ proto array SoapClient::__getFunctions(void)
Returns list of SOAP functions */
PHP_METHOD(SoapClient, __getFunctions)
{
sdlPtr sdl;
FETCH_THIS_SDL(sdl);
if (zend_parse_parameters_none() == FAILURE) {
RETURN_THROWS();
}
if (sdl) {
smart_str buf = {0};
sdlFunctionPtr function;
array_init(return_value);
ZEND_HASH_FOREACH_PTR(&sdl->functions, function) {
function_to_string(function, &buf);
add_next_index_stringl(return_value, ZSTR_VAL(buf.s), ZSTR_LEN(buf.s));
smart_str_free(&buf);
} ZEND_HASH_FOREACH_END();
}
}
/* }}} */
/* {{{ proto array SoapClient::__getTypes(void)
Returns list of SOAP types */
PHP_METHOD(SoapClient, __getTypes)
{
sdlPtr sdl;
FETCH_THIS_SDL(sdl);
if (zend_parse_parameters_none() == FAILURE) {
RETURN_THROWS();
}
if (sdl) {
sdlTypePtr type;
smart_str buf = {0};
array_init(return_value);
if (sdl->types) {
ZEND_HASH_FOREACH_PTR(sdl->types, type) {
type_to_string(type, &buf, 0);
add_next_index_stringl(return_value, ZSTR_VAL(buf.s), ZSTR_LEN(buf.s));
smart_str_free(&buf);
} ZEND_HASH_FOREACH_END();
}
}
}
/* }}} */
/* {{{ proto string SoapClient::__getLastRequest(void)
Returns last SOAP request */
PHP_METHOD(SoapClient, __getLastRequest)
{
zval *tmp;
if (zend_parse_parameters_none() == FAILURE) {
RETURN_THROWS();
}
if ((tmp = zend_hash_str_find(Z_OBJPROP_P(ZEND_THIS), "__last_request", sizeof("__last_request")-1)) != NULL &&
Z_TYPE_P(tmp) == IS_STRING) {
RETURN_STR_COPY(Z_STR_P(tmp));
}
RETURN_NULL();
}
/* }}} */
/* {{{ proto object SoapClient::__getLastResponse(void)
Returns last SOAP response */
PHP_METHOD(SoapClient, __getLastResponse)
{
zval *tmp;
if (zend_parse_parameters_none() == FAILURE) {
RETURN_THROWS();
}
if ((tmp = zend_hash_str_find(Z_OBJPROP_P(ZEND_THIS), "__last_response", sizeof("__last_response")-1)) != NULL &&
Z_TYPE_P(tmp) == IS_STRING) {
RETURN_STR_COPY(Z_STR_P(tmp));
}
RETURN_NULL();
}
/* }}} */
/* {{{ proto string SoapClient::__getLastRequestHeaders(void)
Returns last SOAP request headers */
PHP_METHOD(SoapClient, __getLastRequestHeaders)
{
zval *tmp;
if (zend_parse_parameters_none() == FAILURE) {
RETURN_THROWS();
}
if ((tmp = zend_hash_str_find(Z_OBJPROP_P(ZEND_THIS), "__last_request_headers", sizeof("__last_request_headers")-1)) != NULL &&
Z_TYPE_P(tmp) == IS_STRING) {
RETURN_STR_COPY(Z_STR_P(tmp));
}
RETURN_NULL();
}
/* }}} */
/* {{{ proto string SoapClient::__getLastResponseHeaders(void)
Returns last SOAP response headers */
PHP_METHOD(SoapClient, __getLastResponseHeaders)
{
zval *tmp;
if (zend_parse_parameters_none() == FAILURE) {
RETURN_THROWS();
}
if ((tmp = zend_hash_str_find(Z_OBJPROP_P(ZEND_THIS), "__last_response_headers", sizeof("__last_response_headers")-1)) != NULL &&
Z_TYPE_P(tmp) == IS_STRING) {
RETURN_STR_COPY(Z_STR_P(tmp));
}
RETURN_NULL();
}
/* }}} */
/* {{{ proto string SoapClient::__doRequest()
SoapClient::__doRequest() */
PHP_METHOD(SoapClient, __doRequest)
{
zend_string *buf;
char *location, *action;
size_t location_size, action_size;
zend_long version;
zend_long one_way = 0;
zval *this_ptr = ZEND_THIS;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "Sssl|l",
&buf,
&location, &location_size,
&action, &action_size,
&version, &one_way) == FAILURE) {
RETURN_THROWS();
}
if (SOAP_GLOBAL(features) & SOAP_WAIT_ONE_WAY_CALLS) {
one_way = 0;
}
if (one_way) {
if (make_http_soap_request(this_ptr, buf, location, action, version, NULL)) {
RETURN_EMPTY_STRING();
}
} else if (make_http_soap_request(this_ptr, buf, location, action, version,
return_value)) {
return;
}
RETURN_NULL();
}
/* }}} */
/* {{{ proto void SoapClient::__setCookie(string name [, strung value])
Sets cookie thet will sent with SOAP request.
The call to this function will effect all following calls of SOAP methods.
If value is not specified cookie is removed. */
PHP_METHOD(SoapClient, __setCookie)
{
char *name;
char *val = NULL;
size_t name_len, val_len = 0;
zval *cookies;
zval *this_ptr = ZEND_THIS;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s!", &name, &name_len, &val, &val_len) == FAILURE) {
RETURN_THROWS();
}
if (val == NULL) {
if ((cookies = zend_hash_str_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies")-1)) != NULL &&
Z_TYPE_P(cookies) == IS_ARRAY) {
zend_hash_str_del(Z_ARRVAL_P(cookies), name, name_len);
}
} else {
zval zcookie;
if ((cookies = zend_hash_str_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies")-1)) == NULL ||
Z_TYPE_P(cookies) != IS_ARRAY) {
zval tmp_cookies;
array_init(&tmp_cookies);
cookies = zend_hash_str_update(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies")-1, &tmp_cookies);
}
array_init(&zcookie);
add_index_stringl(&zcookie, 0, val, val_len);
add_assoc_zval_ex(cookies, name, name_len, &zcookie);
}
}
/* }}} */
/* {{{ proto array SoapClient::__getCookies(void)
Returns list of cookies */
PHP_METHOD(SoapClient, __getCookies)
{
zval *cookies;
if (zend_parse_parameters_none() == FAILURE) {
RETURN_THROWS();
}
if ((cookies = zend_hash_str_find(Z_OBJPROP_P(ZEND_THIS), "_cookies", sizeof("_cookies")-1)) != NULL &&
Z_TYPE_P(cookies) == IS_ARRAY) {
RETURN_ARR(zend_array_dup(Z_ARRVAL_P(cookies)));
} else {
array_init(return_value);
}
}
/* }}} */
/* {{{ proto void SoapClient::__setSoapHeaders(array SoapHeaders)
Sets SOAP headers for subsequent calls (replaces any previous
values).
If no value is specified, all of the headers are removed. */
PHP_METHOD(SoapClient, __setSoapHeaders)
{
zval *headers = NULL;
zval *this_ptr = ZEND_THIS;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|z", &headers) == FAILURE) {
RETURN_THROWS();
}
if (headers == NULL || Z_TYPE_P(headers) == IS_NULL) {
zend_hash_str_del(Z_OBJPROP_P(this_ptr), "__default_headers", sizeof("__default_headers")-1);
} else if (Z_TYPE_P(headers) == IS_ARRAY) {
verify_soap_headers_array(Z_ARRVAL_P(headers));
add_property_zval(this_ptr, "__default_headers", headers);
} else if (Z_TYPE_P(headers) == IS_OBJECT &&
instanceof_function(Z_OBJCE_P(headers), soap_header_class_entry)) {
zval default_headers;
array_init(&default_headers);
Z_ADDREF_P(headers);
add_next_index_zval(&default_headers, headers);
add_property_zval(this_ptr, "__default_headers", &default_headers);
Z_DELREF_P(&default_headers);
} else{
php_error_docref(NULL, E_WARNING, "Invalid SOAP header");
}
RETURN_TRUE;
}
/* }}} */
/* {{{ proto string SoapClient::__setLocation([string new_location])
Sets the location option (the endpoint URL that will be touched by the
following SOAP requests).
If new_location is not specified or null then SoapClient will use endpoint
from WSDL file.
The function returns old value of location options. */
PHP_METHOD(SoapClient, __setLocation)
{
char *location = NULL;
size_t location_len = 0;
zval *tmp;
zval *this_ptr = ZEND_THIS;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s", &location, &location_len) == FAILURE) {
RETURN_THROWS();
}
if ((tmp = zend_hash_str_find(Z_OBJPROP_P(this_ptr), "location", sizeof("location")-1)) != NULL && Z_TYPE_P(tmp) == IS_STRING) {
RETVAL_STR_COPY(Z_STR_P(tmp));
} else {
RETVAL_NULL();
}
if (location && location_len) {
add_property_stringl(this_ptr, "location", location, location_len);
} else {
zend_hash_str_del(Z_OBJPROP_P(this_ptr), "location", sizeof("location")-1);
}
}
/* }}} */
static void clear_soap_fault(zval *obj) /* {{{ */
{
if (obj != NULL && Z_TYPE_P(obj) == IS_OBJECT) {
zend_hash_str_del(Z_OBJPROP_P(obj), "__soap_fault", sizeof("__soap_fault")-1);
}
}
/* }}} */
static void add_soap_fault_ex(zval *fault, zval *obj, char *fault_code, char *fault_string, char *fault_actor, zval *fault_detail) /* {{{ */
{
ZVAL_NULL(fault);
set_soap_fault(fault, NULL, fault_code, fault_string, fault_actor, fault_detail, NULL);
add_property_zval(obj, "__soap_fault", fault);
Z_DELREF_P(fault);
}
/* }}} */
void add_soap_fault(zval *obj, char *fault_code, char *fault_string, char *fault_actor, zval *fault_detail) /* {{{ */
{
zval fault;
ZVAL_NULL(&fault);
set_soap_fault(&fault, NULL, fault_code, fault_string, fault_actor, fault_detail, NULL);
add_property_zval(obj, "__soap_fault", &fault);
Z_DELREF(fault);
}
/* }}} */
static void set_soap_fault(zval *obj, char *fault_code_ns, char *fault_code, char *fault_string, char *fault_actor, zval *fault_detail, char *name) /* {{{ */
{
if (Z_TYPE_P(obj) != IS_OBJECT) {
object_init_ex(obj, soap_fault_class_entry);
}
add_property_string(obj, "faultstring", fault_string ? fault_string : "");
zend_update_property_string(zend_ce_exception, obj, "message", sizeof("message")-1, (fault_string ? fault_string : ""));
if (fault_code != NULL) {
int soap_version = SOAP_GLOBAL(soap_version);
if (fault_code_ns) {
add_property_string(obj, "faultcode", fault_code);
add_property_string(obj, "faultcodens", fault_code_ns);
} else {
if (soap_version == SOAP_1_1) {
add_property_string(obj, "faultcode", fault_code);
if (strcmp(fault_code,"Client") == 0 ||
strcmp(fault_code,"Server") == 0 ||
strcmp(fault_code,"VersionMismatch") == 0 ||
strcmp(fault_code,"MustUnderstand") == 0) {
add_property_string(obj, "faultcodens", SOAP_1_1_ENV_NAMESPACE);
}
} else if (soap_version == SOAP_1_2) {
if (strcmp(fault_code,"Client") == 0) {
add_property_string(obj, "faultcode", "Sender");
add_property_string(obj, "faultcodens", SOAP_1_2_ENV_NAMESPACE);
} else if (strcmp(fault_code,"Server") == 0) {
add_property_string(obj, "faultcode", "Receiver");
add_property_string(obj, "faultcodens", SOAP_1_2_ENV_NAMESPACE);
} else if (strcmp(fault_code,"VersionMismatch") == 0 ||
strcmp(fault_code,"MustUnderstand") == 0 ||
strcmp(fault_code,"DataEncodingUnknown") == 0) {
add_property_string(obj, "faultcode", fault_code);
add_property_string(obj, "faultcodens", SOAP_1_2_ENV_NAMESPACE);
} else {
add_property_string(obj, "faultcode", fault_code);
}
}
}
}
if (fault_actor != NULL) {
add_property_string(obj, "faultactor", fault_actor);
}
if (fault_detail != NULL && Z_TYPE_P(fault_detail) != IS_UNDEF) {
add_property_zval(obj, "detail", fault_detail);
}
if (name != NULL) {
add_property_string(obj, "_name", name);
}
}
/* }}} */
static void deserialize_parameters(xmlNodePtr params, sdlFunctionPtr function, int *num_params, zval **parameters) /* {{{ */
{
int cur_param = 0,num_of_params = 0;
zval *tmp_parameters = NULL;
if (function != NULL) {
sdlParamPtr param;
xmlNodePtr val;
int use_names = 0;
if (function->requestParameters == NULL) {
return;
}
num_of_params = zend_hash_num_elements(function->requestParameters);
ZEND_HASH_FOREACH_PTR(function->requestParameters, param) {
if (get_node(params, param->paramName) != NULL) {
use_names = 1;
}
} ZEND_HASH_FOREACH_END();
if (use_names) {
tmp_parameters = safe_emalloc(num_of_params, sizeof(zval), 0);
ZEND_HASH_FOREACH_PTR(function->requestParameters, param) {
val = get_node(params, param->paramName);
if (!val) {
/* TODO: may be "nil" is not OK? */
ZVAL_NULL(&tmp_parameters[cur_param]);
} else {
master_to_zval(&tmp_parameters[cur_param], param->encode, val);
}
cur_param++;
} ZEND_HASH_FOREACH_END();
*parameters = tmp_parameters;
*num_params = num_of_params;
return;
}
}
if (params) {
xmlNodePtr trav;
num_of_params = 0;
trav = params;
while (trav != NULL) {
if (trav->type == XML_ELEMENT_NODE) {
num_of_params++;
}
trav = trav->next;
}
if (num_of_params == 1 &&
function &&
function->binding &&
function->binding->bindingType == BINDING_SOAP &&
((sdlSoapBindingFunctionPtr)function->bindingAttributes)->style == SOAP_DOCUMENT &&
(function->requestParameters == NULL ||
zend_hash_num_elements(function->requestParameters) == 0) &&
strcmp((char *)params->name, function->functionName) == 0) {
num_of_params = 0;
} else if (num_of_params > 0) {
tmp_parameters = safe_emalloc(num_of_params, sizeof(zval), 0);
trav = params;
while (trav != 0 && cur_param < num_of_params) {
if (trav->type == XML_ELEMENT_NODE) {
encodePtr enc;
sdlParamPtr param = NULL;
if (function != NULL &&
(param = zend_hash_index_find_ptr(function->requestParameters, cur_param)) == NULL) {
soap_server_fault("Client", "Error cannot find parameter", NULL, NULL, NULL);
}
if (param == NULL) {
enc = NULL;
} else {
enc = param->encode;
}
master_to_zval(&tmp_parameters[cur_param], enc, trav);
cur_param++;
}
trav = trav->next;
}
}
}
if (num_of_params > cur_param) {
soap_server_fault("Client","Missing parameter", NULL, NULL, NULL);
}
(*parameters) = tmp_parameters;
(*num_params) = num_of_params;
}
/* }}} */
static sdlFunctionPtr find_function(sdlPtr sdl, xmlNodePtr func, zval* function_name) /* {{{ */
{
sdlFunctionPtr function;
function = get_function(sdl, (char*)func->name);
if (function && function->binding && function->binding->bindingType == BINDING_SOAP) {
sdlSoapBindingFunctionPtr fnb = (sdlSoapBindingFunctionPtr)function->bindingAttributes;
if (fnb->style == SOAP_DOCUMENT) {
if (func->children != NULL ||
(function->requestParameters != NULL &&
zend_hash_num_elements(function->requestParameters) > 0)) {
function = NULL;
}
}
}
if (sdl != NULL && function == NULL) {
function = get_doc_function(sdl, func);
}
if (function != NULL) {
ZVAL_STRING(function_name, (char *)function->functionName);
} else {
ZVAL_STRING(function_name, (char *)func->name);
}
return function;
}
/* }}} */
static xmlNodePtr get_envelope(xmlNodePtr trav, int *version, char **envelope_ns) {
while (trav != NULL) {
if (trav->type == XML_ELEMENT_NODE) {
if (node_is_equal_ex(trav,"Envelope",SOAP_1_1_ENV_NAMESPACE)) {
*version = SOAP_1_1;
*envelope_ns = SOAP_1_1_ENV_NAMESPACE;
SOAP_GLOBAL(soap_version) = SOAP_1_1;
return trav;
}
if (node_is_equal_ex(trav,"Envelope",SOAP_1_2_ENV_NAMESPACE)) {
*version = SOAP_1_2;
*envelope_ns = SOAP_1_2_ENV_NAMESPACE;
SOAP_GLOBAL(soap_version) = SOAP_1_2;
return trav;
}
soap_server_fault("VersionMismatch", "Wrong Version", NULL, NULL, NULL);
}
trav = trav->next;
}
return NULL;
}
static sdlFunctionPtr deserialize_function_call(sdlPtr sdl, xmlDocPtr request, char* actor, zval *function_name, int *num_params, zval **parameters, int *version, soapHeader **headers) /* {{{ */
{
char* envelope_ns = NULL;
xmlNodePtr trav,env,head,body,func;
xmlAttrPtr attr;
sdlFunctionPtr function;
encode_reset_ns();
/* Get <Envelope> element */
env = get_envelope(request->children, version, &envelope_ns);
if (!env) {
soap_server_fault("Client", "looks like we got XML without \"Envelope\" element", NULL, NULL, NULL);
}
attr = env->properties;
while (attr != NULL) {
if (attr->ns == NULL) {
soap_server_fault("Client", "A SOAP Envelope element cannot have non Namespace qualified attributes", NULL, NULL, NULL);
} else if (attr_is_equal_ex(attr,"encodingStyle",SOAP_1_2_ENV_NAMESPACE)) {
if (*version == SOAP_1_2) {
soap_server_fault("Client", "encodingStyle cannot be specified on the Envelope", NULL, NULL, NULL);
} else if (strcmp((char*)attr->children->content,SOAP_1_1_ENC_NAMESPACE) != 0) {
soap_server_fault("Client", "Unknown data encoding style", NULL, NULL, NULL);
}
}
attr = attr->next;
}
/* Get <Header> element */
head = NULL;
trav = env->children;
while (trav != NULL && trav->type != XML_ELEMENT_NODE) {
trav = trav->next;
}
if (trav != NULL && node_is_equal_ex(trav,"Header",envelope_ns)) {
head = trav;
trav = trav->next;
}
/* Get <Body> element */
body = NULL;
while (trav != NULL && trav->type != XML_ELEMENT_NODE) {
trav = trav->next;
}
if (trav != NULL && node_is_equal_ex(trav,"Body",envelope_ns)) {
body = trav;
trav = trav->next;
}
while (trav != NULL && trav->type != XML_ELEMENT_NODE) {
trav = trav->next;
}
if (body == NULL) {
soap_server_fault("Client", "Body must be present in a SOAP envelope", NULL, NULL, NULL);
}
attr = body->properties;
while (attr != NULL) {
if (attr->ns == NULL) {
if (*version == SOAP_1_2) {
soap_server_fault("Client", "A SOAP Body element cannot have non Namespace qualified attributes", NULL, NULL, NULL);
}
} else if (attr_is_equal_ex(attr,"encodingStyle",SOAP_1_2_ENV_NAMESPACE)) {
if (*version == SOAP_1_2) {
soap_server_fault("Client", "encodingStyle cannot be specified on the Body", NULL, NULL, NULL);
} else if (strcmp((char*)attr->children->content,SOAP_1_1_ENC_NAMESPACE) != 0) {
soap_server_fault("Client", "Unknown data encoding style", NULL, NULL, NULL);
}
}
attr = attr->next;
}
if (trav != NULL && *version == SOAP_1_2) {
soap_server_fault("Client", "A SOAP 1.2 envelope can contain only Header and Body", NULL, NULL, NULL);
}
func = NULL;
trav = body->children;
while (trav != NULL) {
if (trav->type == XML_ELEMENT_NODE) {
/*
if (func != NULL) {
soap_server_fault("Client", "looks like we got \"Body\" with several functions call", NULL, NULL, NULL);
}
*/
func = trav;
break; /* FIXME: the rest of body is ignored */
}
trav = trav->next;
}
if (func == NULL) {
function = get_doc_function(sdl, NULL);
if (function != NULL) {
ZVAL_STRING(function_name, (char *)function->functionName);
} else {
soap_server_fault("Client", "looks like we got \"Body\" without function call", NULL, NULL, NULL);
}
} else {
if (*version == SOAP_1_1) {
attr = get_attribute_ex(func->properties,"encodingStyle",SOAP_1_1_ENV_NAMESPACE);
if (attr && strcmp((char*)attr->children->content,SOAP_1_1_ENC_NAMESPACE) != 0) {
soap_server_fault("Client","Unknown Data Encoding Style", NULL, NULL, NULL);
}
} else {
attr = get_attribute_ex(func->properties,"encodingStyle",SOAP_1_2_ENV_NAMESPACE);
if (attr && strcmp((char*)attr->children->content,SOAP_1_2_ENC_NAMESPACE) != 0) {
soap_server_fault("DataEncodingUnknown","Unknown Data Encoding Style", NULL, NULL, NULL);
}
}
function = find_function(sdl, func, function_name);
if (sdl != NULL && function == NULL) {
if (*version == SOAP_1_2) {
soap_server_fault("rpc:ProcedureNotPresent","Procedure not present", NULL, NULL, NULL);
} else {
php_error(E_ERROR, "Procedure '%s' not present", func->name);
}
}
}
*headers = NULL;
if (head) {
soapHeader *h, *last = NULL;
attr = head->properties;
while (attr != NULL) {
if (attr->ns == NULL) {
soap_server_fault("Client", "A SOAP Header element cannot have non Namespace qualified attributes", NULL, NULL, NULL);
} else if (attr_is_equal_ex(attr,"encodingStyle",SOAP_1_2_ENV_NAMESPACE)) {
if (*version == SOAP_1_2) {
soap_server_fault("Client", "encodingStyle cannot be specified on the Header", NULL, NULL, NULL);
} else if (strcmp((char*)attr->children->content,SOAP_1_1_ENC_NAMESPACE) != 0) {
soap_server_fault("Client", "Unknown data encoding style", NULL, NULL, NULL);
}
}
attr = attr->next;
}
trav = head->children;
while (trav != NULL) {
if (trav->type == XML_ELEMENT_NODE) {
xmlNodePtr hdr_func = trav;
int mustUnderstand = 0;
if (*version == SOAP_1_1) {
attr = get_attribute_ex(hdr_func->properties,"encodingStyle",SOAP_1_1_ENV_NAMESPACE);
if (attr && strcmp((char*)attr->children->content,SOAP_1_1_ENC_NAMESPACE) != 0) {
soap_server_fault("Client","Unknown Data Encoding Style", NULL, NULL, NULL);
}
attr = get_attribute_ex(hdr_func->properties,"actor",envelope_ns);
if (attr != NULL) {
if (strcmp((char*)attr->children->content,SOAP_1_1_ACTOR_NEXT) != 0 &&
(actor == NULL || strcmp((char*)attr->children->content,actor) != 0)) {
goto ignore_header;
}
}
} else if (*version == SOAP_1_2) {
attr = get_attribute_ex(hdr_func->properties,"encodingStyle",SOAP_1_2_ENV_NAMESPACE);
if (attr && strcmp((char*)attr->children->content,SOAP_1_2_ENC_NAMESPACE) != 0) {
soap_server_fault("DataEncodingUnknown","Unknown Data Encoding Style", NULL, NULL, NULL);
}
attr = get_attribute_ex(hdr_func->properties,"role",envelope_ns);
if (attr != NULL) {
if (strcmp((char*)attr->children->content,SOAP_1_2_ACTOR_UNLIMATERECEIVER) != 0 &&
strcmp((char*)attr->children->content,SOAP_1_2_ACTOR_NEXT) != 0 &&
(actor == NULL || strcmp((char*)attr->children->content,actor) != 0)) {
goto ignore_header;
}
}
}
attr = get_attribute_ex(hdr_func->properties,"mustUnderstand",envelope_ns);
if (attr) {
if (strcmp((char*)attr->children->content,"1") == 0 ||
strcmp((char*)attr->children->content,"true") == 0) {
mustUnderstand = 1;
} else if (strcmp((char*)attr->children->content,"0") == 0 ||
strcmp((char*)attr->children->content,"false") == 0) {
mustUnderstand = 0;
} else {
soap_server_fault("Client","mustUnderstand value is not boolean", NULL, NULL, NULL);
}
}
h = emalloc(sizeof(soapHeader));
memset(h, 0, sizeof(soapHeader));
h->mustUnderstand = mustUnderstand;
h->function = find_function(sdl, hdr_func, &h->function_name);
if (!h->function && sdl && function && function->binding && function->binding->bindingType == BINDING_SOAP) {
sdlSoapBindingFunctionHeaderPtr hdr;
sdlSoapBindingFunctionPtr fnb = (sdlSoapBindingFunctionPtr)function->bindingAttributes;
if (fnb->input.headers) {
smart_str key = {0};
if (hdr_func->ns) {
smart_str_appends(&key, (char*)hdr_func->ns->href);
smart_str_appendc(&key, ':');
}
smart_str_appendl(&key, Z_STRVAL(h->function_name), Z_STRLEN(h->function_name));
smart_str_0(&key);
if ((hdr = zend_hash_find_ptr(fnb->input.headers, key.s)) != NULL) {
h->hdr = hdr;
}
smart_str_free(&key);
}
}
if (h->hdr) {
h->num_params = 1;
h->parameters = emalloc(sizeof(zval));
master_to_zval(&h->parameters[0], h->hdr->encode, hdr_func);
} else {
if (h->function && h->function->binding && h->function->binding->bindingType == BINDING_SOAP) {
sdlSoapBindingFunctionPtr fnb = (sdlSoapBindingFunctionPtr)h->function->bindingAttributes;
if (fnb->style == SOAP_RPC) {
hdr_func = hdr_func->children;
}
}
deserialize_parameters(hdr_func, h->function, &h->num_params, &h->parameters);
}
ZVAL_NULL(&h->retval);
if (last == NULL) {
*headers = h;
} else {
last->next = h;
}
last = h;
}
ignore_header:
trav = trav->next;
}
}
if (function && function->binding && function->binding->bindingType == BINDING_SOAP) {
sdlSoapBindingFunctionPtr fnb = (sdlSoapBindingFunctionPtr)function->bindingAttributes;
if (fnb->style == SOAP_RPC) {
func = func->children;
}
} else {
func = func->children;
}
deserialize_parameters(func, function, num_params, parameters);
encode_finish();
return function;
}
/* }}} */
static void set_soap_header_attributes(xmlNodePtr h, HashTable *ht, int version) /* {{{ */
{
zval *tmp;
if ((tmp = zend_hash_str_find(ht, "mustUnderstand", sizeof("mustUnderstand")-1)) != NULL &&
Z_TYPE_P(tmp) == IS_TRUE) {
if (version == SOAP_1_1) {
xmlSetProp(h, BAD_CAST(SOAP_1_1_ENV_NS_PREFIX":mustUnderstand"), BAD_CAST("1"));
} else {
xmlSetProp(h, BAD_CAST(SOAP_1_2_ENV_NS_PREFIX":mustUnderstand"), BAD_CAST("true"));
}
}
if ((tmp = zend_hash_str_find(ht, "actor", sizeof("actor")-1)) != NULL) {
if (Z_TYPE_P(tmp) == IS_STRING) {
if (version == SOAP_1_1) {
xmlSetProp(h, BAD_CAST(SOAP_1_1_ENV_NS_PREFIX":actor"), BAD_CAST(Z_STRVAL_P(tmp)));
} else {
xmlSetProp(h, BAD_CAST(SOAP_1_2_ENV_NS_PREFIX":role"), BAD_CAST(Z_STRVAL_P(tmp)));
}
} else if (Z_TYPE_P(tmp) == IS_LONG) {
if (version == SOAP_1_1) {
if (Z_LVAL_P(tmp) == SOAP_ACTOR_NEXT) {
xmlSetProp(h, BAD_CAST(SOAP_1_1_ENV_NS_PREFIX":actor"), BAD_CAST(SOAP_1_1_ACTOR_NEXT));
}
} else {
if (Z_LVAL_P(tmp) == SOAP_ACTOR_NEXT) {
xmlSetProp(h, BAD_CAST(SOAP_1_2_ENV_NS_PREFIX":role"), BAD_CAST(SOAP_1_2_ACTOR_NEXT));
} else if (Z_LVAL_P(tmp) == SOAP_ACTOR_NONE) {
xmlSetProp(h, BAD_CAST(SOAP_1_2_ENV_NS_PREFIX":role"), BAD_CAST(SOAP_1_2_ACTOR_NONE));
} else if (Z_LVAL_P(tmp) == SOAP_ACTOR_UNLIMATERECEIVER) {
xmlSetProp(h, BAD_CAST(SOAP_1_2_ENV_NS_PREFIX":role"), BAD_CAST(SOAP_1_2_ACTOR_UNLIMATERECEIVER));
}
}
}
}
}
/* }}} */
static int serialize_response_call2(xmlNodePtr body, sdlFunctionPtr function, char *function_name, char *uri, zval *ret, int version, int main, xmlNodePtr *node) /* {{{ */
{
xmlNodePtr method = NULL, param;
sdlParamPtr parameter = NULL;
int param_count;
int style, use;
xmlNsPtr ns = NULL;
if (function != NULL && function->binding->bindingType == BINDING_SOAP) {
sdlSoapBindingFunctionPtr fnb = (sdlSoapBindingFunctionPtr)function->bindingAttributes;
style = fnb->style;
use = fnb->output.use;
if (style == SOAP_RPC) {
ns = encode_add_ns(body, fnb->output.ns);
if (function->responseName) {
method = xmlNewChild(body, ns, BAD_CAST(function->responseName), NULL);
} else if (function->responseParameters) {
method = xmlNewChild(body, ns, BAD_CAST(function->functionName), NULL);
}
}
} else {
style = main?SOAP_RPC:SOAP_DOCUMENT;
use = main?SOAP_ENCODED:SOAP_LITERAL;
if (style == SOAP_RPC) {
ns = encode_add_ns(body, uri);
method = xmlNewChild(body, ns, BAD_CAST(function_name), NULL);
}
}
if (function != NULL) {
if (function->responseParameters) {
param_count = zend_hash_num_elements(function->responseParameters);
} else {
param_count = 0;
}
} else {
param_count = 1;
}
if (param_count == 1) {
parameter = get_param(function, NULL, 0, TRUE);
if (style == SOAP_RPC) {
xmlNode *rpc_result;
if (main && version == SOAP_1_2) {
xmlNs *rpc_ns = xmlNewNs(body, BAD_CAST(RPC_SOAP12_NAMESPACE), BAD_CAST(RPC_SOAP12_NS_PREFIX));
rpc_result = xmlNewChild(method, rpc_ns, BAD_CAST("result"), NULL);
param = serialize_parameter(parameter, ret, 0, "return", use, method);
xmlNodeSetContent(rpc_result,param->name);
} else {
param = serialize_parameter(parameter, ret, 0, "return", use, method);
}
} else {
param = serialize_parameter(parameter, ret, 0, "return", use, body);
if (function && function->binding->bindingType == BINDING_SOAP) {
if (parameter && parameter->element) {
ns = encode_add_ns(param, parameter->element->namens);
xmlNodeSetName(param, BAD_CAST(parameter->element->name));
xmlSetNs(param, ns);
}
} else if (strcmp((char*)param->name,"return") == 0) {
ns = encode_add_ns(param, uri);
xmlNodeSetName(param, BAD_CAST(function_name));
xmlSetNs(param, ns);
}
}
} else if (param_count > 1 && Z_TYPE_P(ret) == IS_ARRAY) {
zval *data;
int i = 0;
zend_string *param_name;
zend_ulong param_index = i;
ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(ret), param_index, param_name, data) {
parameter = get_param(function, ZSTR_VAL(param_name), param_index, TRUE);
if (style == SOAP_RPC) {
param = serialize_parameter(parameter, data, i, ZSTR_VAL(param_name), use, method);
} else {
param = serialize_parameter(parameter, data, i, ZSTR_VAL(param_name), use, body);
if (function && function->binding->bindingType == BINDING_SOAP) {
if (parameter && parameter->element) {
ns = encode_add_ns(param, parameter->element->namens);
xmlNodeSetName(param, BAD_CAST(parameter->element->name));
xmlSetNs(param, ns);
}
}
}
i++;
param_index = i;
} ZEND_HASH_FOREACH_END();
}
if (use == SOAP_ENCODED && version == SOAP_1_2 && method != NULL) {
xmlSetNsProp(method, body->ns, BAD_CAST("encodingStyle"), BAD_CAST(SOAP_1_2_ENC_NAMESPACE));
}
if (node) {
*node = method;
}
return use;
}
/* }}} */
static xmlDocPtr serialize_response_call(sdlFunctionPtr function, char *function_name, char *uri, zval *ret, soapHeader* headers, int version) /* {{{ */
{
xmlDocPtr doc;
xmlNodePtr envelope = NULL, body, param;
xmlNsPtr ns = NULL;
int use = SOAP_LITERAL;
xmlNodePtr head = NULL;
encode_reset_ns();
doc = xmlNewDoc(BAD_CAST("1.0"));
zend_try {
doc->charset = XML_CHAR_ENCODING_UTF8;
doc->encoding = xmlCharStrdup("UTF-8");
if (version == SOAP_1_1) {
envelope = xmlNewDocNode(doc, NULL, BAD_CAST("Envelope"), NULL);
ns = xmlNewNs(envelope, BAD_CAST(SOAP_1_1_ENV_NAMESPACE), BAD_CAST(SOAP_1_1_ENV_NS_PREFIX));
xmlSetNs(envelope,ns);
} else if (version == SOAP_1_2) {
envelope = xmlNewDocNode(doc, NULL, BAD_CAST("Envelope"), NULL);
ns = xmlNewNs(envelope, BAD_CAST(SOAP_1_2_ENV_NAMESPACE), BAD_CAST(SOAP_1_2_ENV_NS_PREFIX));
xmlSetNs(envelope,ns);
} else {
soap_server_fault("Server", "Unknown SOAP version", NULL, NULL, NULL);
}
xmlDocSetRootElement(doc, envelope);
if (Z_TYPE_P(ret) == IS_OBJECT &&
instanceof_function(Z_OBJCE_P(ret), soap_fault_class_entry)) {
char *detail_name;
HashTable* prop;
zval *tmp;
sdlFaultPtr fault = NULL;
char *fault_ns = NULL;
prop = Z_OBJPROP_P(ret);
if (headers &&
(tmp = zend_hash_str_find(prop, "headerfault", sizeof("headerfault")-1)) != NULL) {
encodePtr hdr_enc = NULL;
int hdr_use = SOAP_LITERAL;
zval *hdr_ret = tmp;
char *hdr_ns = headers->hdr?headers->hdr->ns:NULL;
char *hdr_name = Z_STRVAL(headers->function_name);
head = xmlNewChild(envelope, ns, BAD_CAST("Header"), NULL);
if (Z_TYPE_P(hdr_ret) == IS_OBJECT &&
instanceof_function(Z_OBJCE_P(hdr_ret), soap_header_class_entry)) {
HashTable* ht = Z_OBJPROP_P(hdr_ret);
sdlSoapBindingFunctionHeaderPtr hdr;
smart_str key = {0};
if ((tmp = zend_hash_str_find(ht, "namespace", sizeof("namespace")-1)) != NULL &&
Z_TYPE_P(tmp) == IS_STRING) {
smart_str_appendl(&key, Z_STRVAL_P(tmp), Z_STRLEN_P(tmp));
smart_str_appendc(&key, ':');
hdr_ns = Z_STRVAL_P(tmp);
}
if ((tmp = zend_hash_str_find(ht, "name", sizeof("name")-1)) != NULL &&
Z_TYPE_P(tmp) == IS_STRING) {
smart_str_appendl(&key, Z_STRVAL_P(tmp), Z_STRLEN_P(tmp));
hdr_name = Z_STRVAL_P(tmp);
}
smart_str_0(&key);
if (headers->hdr && headers->hdr->headerfaults &&
(hdr = zend_hash_find_ptr(headers->hdr->headerfaults, key.s)) != NULL) {
hdr_enc = hdr->encode;
hdr_use = hdr->use;
}
smart_str_free(&key);
if ((tmp = zend_hash_str_find(ht, "data", sizeof("data")-1)) != NULL) {
hdr_ret = tmp;
} else {
hdr_ret = NULL;
}
}
if (headers->function) {
if (serialize_response_call2(head, headers->function, Z_STRVAL(headers->function_name), uri, hdr_ret, version, 0, NULL) == SOAP_ENCODED) {
use = SOAP_ENCODED;
}
} else {
xmlNodePtr xmlHdr = master_to_xml(hdr_enc, hdr_ret, hdr_use, head);
if (hdr_name) {
xmlNodeSetName(xmlHdr, BAD_CAST(hdr_name));
}
if (hdr_ns) {
xmlNsPtr nsptr = encode_add_ns(xmlHdr, hdr_ns);
xmlSetNs(xmlHdr, nsptr);
}
}
}
body = xmlNewChild(envelope, ns, BAD_CAST("Body"), NULL);
param = xmlNewChild(body, ns, BAD_CAST("Fault"), NULL);
if ((tmp = zend_hash_str_find(prop, "faultcodens", sizeof("faultcodens")-1)) != NULL && Z_TYPE_P(tmp) == IS_STRING) {
fault_ns = Z_STRVAL_P(tmp);
}
use = SOAP_LITERAL;
if ((tmp = zend_hash_str_find(prop, "_name", sizeof("_name")-1)) != NULL && Z_TYPE_P(tmp) == IS_STRING) {
sdlFaultPtr tmp_fault;
if (function && function->faults &&
(tmp_fault = zend_hash_find_ptr(function->faults, Z_STR_P(tmp))) != NULL) {
fault = tmp_fault;
if (function->binding &&
function->binding->bindingType == BINDING_SOAP &&
fault->bindingAttributes) {
sdlSoapBindingFunctionFaultPtr fb = (sdlSoapBindingFunctionFaultPtr)fault->bindingAttributes;
use = fb->use;
if (fault_ns == NULL) {
fault_ns = fb->ns;
}
}
}
} else if (function && function->faults &&
zend_hash_num_elements(function->faults) == 1) {
zend_hash_internal_pointer_reset(function->faults);
fault = zend_hash_get_current_data_ptr(function->faults);
if (function->binding &&
function->binding->bindingType == BINDING_SOAP &&
fault->bindingAttributes) {
sdlSoapBindingFunctionFaultPtr fb = (sdlSoapBindingFunctionFaultPtr)fault->bindingAttributes;
use = fb->use;
if (fault_ns == NULL) {
fault_ns = fb->ns;
}
}
}
if (fault_ns == NULL &&
fault &&
fault->details &&
zend_hash_num_elements(fault->details) == 1) {
sdlParamPtr sparam;
zend_hash_internal_pointer_reset(fault->details);
sparam = zend_hash_get_current_data_ptr(fault->details);
if (sparam->element) {
fault_ns = sparam->element->namens;
}
}
if (version == SOAP_1_1) {
if ((tmp = zend_hash_str_find(prop, "faultcode", sizeof("faultcode")-1)) != NULL &&
Z_TYPE_P(tmp) == IS_STRING) {
xmlNodePtr node = xmlNewNode(NULL, BAD_CAST("faultcode"));
zend_string *str = php_escape_html_entities((unsigned char*)Z_STRVAL_P(tmp), Z_STRLEN_P(tmp), 0, 0, NULL);
xmlAddChild(param, node);
if (fault_ns) {
xmlNsPtr nsptr = encode_add_ns(node, fault_ns);
xmlChar *code = xmlBuildQName(BAD_CAST(ZSTR_VAL(str)), nsptr->prefix, NULL, 0);
xmlNodeSetContent(node, code);
xmlFree(code);
} else {
xmlNodeSetContentLen(node, BAD_CAST(ZSTR_VAL(str)), (int)ZSTR_LEN(str));
}
zend_string_release_ex(str, 0);
}
if ((tmp = zend_hash_str_find(prop, "faultstring", sizeof("faultstring")-1)) != NULL) {
xmlNodePtr node = master_to_xml(get_conversion(IS_STRING), tmp, SOAP_LITERAL, param);
xmlNodeSetName(node, BAD_CAST("faultstring"));
}
if ((tmp = zend_hash_str_find(prop, "faultactor", sizeof("faultactor")-1)) != NULL) {
xmlNodePtr node = master_to_xml(get_conversion(IS_STRING), tmp, SOAP_LITERAL, param);
xmlNodeSetName(node, BAD_CAST("faultactor"));
}
detail_name = "detail";
} else {
if ((tmp = zend_hash_str_find(prop, "faultcode", sizeof("faultcode")-1)) != NULL &&
Z_TYPE_P(tmp) == IS_STRING) {
xmlNodePtr node = xmlNewChild(param, ns, BAD_CAST("Code"), NULL);
zend_string *str = php_escape_html_entities((unsigned char*)Z_STRVAL_P(tmp), Z_STRLEN_P(tmp), 0, 0, NULL);
node = xmlNewChild(node, ns, BAD_CAST("Value"), NULL);
if (fault_ns) {
xmlNsPtr nsptr = encode_add_ns(node, fault_ns);
xmlChar *code = xmlBuildQName(BAD_CAST(ZSTR_VAL(str)), nsptr->prefix, NULL, 0);
xmlNodeSetContent(node, code);
xmlFree(code);
} else {
xmlNodeSetContentLen(node, BAD_CAST(ZSTR_VAL(str)), (int)ZSTR_LEN(str));
}
zend_string_release_ex(str, 0);
}
if ((tmp = zend_hash_str_find(prop, "faultstring", sizeof("faultstring")-1)) != NULL) {
xmlNodePtr node = xmlNewChild(param, ns, BAD_CAST("Reason"), NULL);
node = master_to_xml(get_conversion(IS_STRING), tmp, SOAP_LITERAL, node);
xmlNodeSetName(node, BAD_CAST("Text"));
xmlSetNs(node, ns);
}
detail_name = SOAP_1_2_ENV_NS_PREFIX":Detail";
}
if (fault && fault->details && zend_hash_num_elements(fault->details) == 1) {
xmlNodePtr node;
zval *detail = NULL;
sdlParamPtr sparam;
xmlNodePtr x;
if ((tmp = zend_hash_str_find(prop, "detail", sizeof("detail")-1)) != NULL &&
Z_TYPE_P(tmp) != IS_NULL) {
detail = tmp;
}
node = xmlNewNode(NULL, BAD_CAST(detail_name));
xmlAddChild(param, node);
zend_hash_internal_pointer_reset(fault->details);
sparam = zend_hash_get_current_data_ptr(fault->details);
if (detail &&
Z_TYPE_P(detail) == IS_OBJECT &&
sparam->element &&
zend_hash_num_elements(Z_OBJPROP_P(detail)) == 1 &&
(tmp = zend_hash_str_find(Z_OBJPROP_P(detail), sparam->element->name, strlen(sparam->element->name))) != NULL) {
detail = tmp;
}
x = serialize_parameter(sparam, detail, 1, NULL, use, node);
if (function &&
function->binding &&
function->binding->bindingType == BINDING_SOAP &&
function->bindingAttributes) {
sdlSoapBindingFunctionPtr fnb = (sdlSoapBindingFunctionPtr)function->bindingAttributes;
if (fnb->style == SOAP_RPC && !sparam->element) {
if (fault->bindingAttributes) {
sdlSoapBindingFunctionFaultPtr fb = (sdlSoapBindingFunctionFaultPtr)fault->bindingAttributes;
if (fb->ns) {
xmlNsPtr ns = encode_add_ns(x, fb->ns);
xmlSetNs(x, ns);
}
}
} else {
if (sparam->element) {
ns = encode_add_ns(x, sparam->element->namens);
xmlNodeSetName(x, BAD_CAST(sparam->element->name));
xmlSetNs(x, ns);
}
}
}
if (use == SOAP_ENCODED && version == SOAP_1_2) {
xmlSetNsProp(x, envelope->ns, BAD_CAST("encodingStyle"), BAD_CAST(SOAP_1_2_ENC_NAMESPACE));
}
} else if ((tmp = zend_hash_str_find(prop, "detail", sizeof("detail")-1)) != NULL &&
Z_TYPE_P(tmp) != IS_NULL) {
serialize_zval(tmp, NULL, detail_name, use, param);
}
} else {
if (headers) {
soapHeader *h;
head = xmlNewChild(envelope, ns, BAD_CAST("Header"), NULL);
h = headers;
while (h != NULL) {
if (Z_TYPE(h->retval) != IS_NULL) {
encodePtr hdr_enc = NULL;
int hdr_use = SOAP_LITERAL;
zval *hdr_ret = &h->retval;
char *hdr_ns = h->hdr?h->hdr->ns:NULL;
char *hdr_name = Z_TYPE(h->function_name) == IS_STRING
? Z_STRVAL(h->function_name) : NULL;
HashTable *ht = NULL;
if (Z_TYPE(h->retval) == IS_OBJECT &&
instanceof_function(Z_OBJCE(h->retval), soap_header_class_entry)) {
zval *tmp;
sdlSoapBindingFunctionHeaderPtr hdr;
smart_str key = {0};
ht = Z_OBJPROP(h->retval);
if ((tmp = zend_hash_str_find(ht, "namespace", sizeof("namespace")-1)) != NULL &&
Z_TYPE_P(tmp) == IS_STRING) {
smart_str_appendl(&key, Z_STRVAL_P(tmp), Z_STRLEN_P(tmp));
smart_str_appendc(&key, ':');
hdr_ns = Z_STRVAL_P(tmp);
}
if ((tmp = zend_hash_str_find(ht, "name", sizeof("name")-1)) != NULL &&
Z_TYPE_P(tmp) == IS_STRING) {
smart_str_appendl(&key, Z_STRVAL_P(tmp), Z_STRLEN_P(tmp));
hdr_name = Z_STRVAL_P(tmp);
}
smart_str_0(&key);
if (function && function->binding && function->binding->bindingType == BINDING_SOAP) {
sdlSoapBindingFunctionPtr fnb = (sdlSoapBindingFunctionPtr)function->bindingAttributes;
if (fnb->output.headers &&
(hdr = zend_hash_find_ptr(fnb->output.headers, key.s)) != NULL) {
hdr_enc = hdr->encode;
hdr_use = hdr->use;
}
}
smart_str_free(&key);
if ((tmp = zend_hash_str_find(ht, "data", sizeof("data")-1)) != NULL) {
hdr_ret = tmp;
} else {
hdr_ret = NULL;
}
}
if (h->function) {
xmlNodePtr xmlHdr = NULL;
if (serialize_response_call2(head, h->function, Z_STRVAL(h->function_name), uri, hdr_ret, version, 0, &xmlHdr) == SOAP_ENCODED) {
use = SOAP_ENCODED;
}
if (ht) {
set_soap_header_attributes(xmlHdr, ht, version);
}
} else {
xmlNodePtr xmlHdr = master_to_xml(hdr_enc, hdr_ret, hdr_use, head);
if (hdr_name) {
xmlNodeSetName(xmlHdr, BAD_CAST(hdr_name));
}
if (hdr_ns) {
xmlNsPtr nsptr = encode_add_ns(xmlHdr,hdr_ns);
xmlSetNs(xmlHdr, nsptr);
}
if (ht) {
set_soap_header_attributes(xmlHdr, ht, version);
}
}
}
h = h->next;
}
if (head->children == NULL) {
xmlUnlinkNode(head);
xmlFreeNode(head);
}
}
body = xmlNewChild(envelope, ns, BAD_CAST("Body"), NULL);
if (serialize_response_call2(body, function, function_name, uri, ret, version, 1, NULL) == SOAP_ENCODED) {
use = SOAP_ENCODED;
}
}
if (use == SOAP_ENCODED) {
xmlNewNs(envelope, BAD_CAST(XSD_NAMESPACE), BAD_CAST(XSD_NS_PREFIX));
if (version == SOAP_1_1) {
xmlNewNs(envelope, BAD_CAST(SOAP_1_1_ENC_NAMESPACE), BAD_CAST(SOAP_1_1_ENC_NS_PREFIX));
xmlSetNsProp(envelope, envelope->ns, BAD_CAST("encodingStyle"), BAD_CAST(SOAP_1_1_ENC_NAMESPACE));
} else if (version == SOAP_1_2) {
xmlNewNs(envelope, BAD_CAST(SOAP_1_2_ENC_NAMESPACE), BAD_CAST(SOAP_1_2_ENC_NS_PREFIX));
}
}
encode_finish();
} zend_catch {
/* Avoid persistent memory leak. */
xmlFreeDoc(doc);
zend_bailout();
} zend_end_try();
if (function && function->responseName == NULL &&
body->children == NULL && head == NULL) {
xmlFreeDoc(doc);
return NULL;
}
return doc;
}
/* }}} */
static xmlDocPtr serialize_function_call(zval *this_ptr, sdlFunctionPtr function, char *function_name, char *uri, zval *arguments, int arg_count, int version, HashTable *soap_headers) /* {{{ */
{
xmlDoc *doc;
xmlNodePtr envelope = NULL, body, method = NULL, head = NULL;
xmlNsPtr ns = NULL;
zval *zstyle, *zuse;
int i, style, use;
HashTable *hdrs = NULL;
encode_reset_ns();
doc = xmlNewDoc(BAD_CAST("1.0"));
zend_try {
doc->encoding = xmlCharStrdup("UTF-8");
doc->charset = XML_CHAR_ENCODING_UTF8;
if (version == SOAP_1_1) {
envelope = xmlNewDocNode(doc, NULL, BAD_CAST("Envelope"), NULL);
ns = xmlNewNs(envelope, BAD_CAST(SOAP_1_1_ENV_NAMESPACE), BAD_CAST(SOAP_1_1_ENV_NS_PREFIX));
xmlSetNs(envelope, ns);
} else if (version == SOAP_1_2) {
envelope = xmlNewDocNode(doc, NULL, BAD_CAST("Envelope"), NULL);
ns = xmlNewNs(envelope, BAD_CAST(SOAP_1_2_ENV_NAMESPACE), BAD_CAST(SOAP_1_2_ENV_NS_PREFIX));
xmlSetNs(envelope, ns);
} else {
soap_error0(E_ERROR, "Unknown SOAP version");
}
xmlDocSetRootElement(doc, envelope);
if (soap_headers) {
head = xmlNewChild(envelope, ns, BAD_CAST("Header"), NULL);
}
body = xmlNewChild(envelope, ns, BAD_CAST("Body"), NULL);
if (function && function->binding->bindingType == BINDING_SOAP) {
sdlSoapBindingFunctionPtr fnb = (sdlSoapBindingFunctionPtr)function->bindingAttributes;
hdrs = fnb->input.headers;
style = fnb->style;
/*FIXME: how to pass method name if style is SOAP_DOCUMENT */
/*style = SOAP_RPC;*/
use = fnb->input.use;
if (style == SOAP_RPC) {
ns = encode_add_ns(body, fnb->input.ns);
if (function->requestName) {
method = xmlNewChild(body, ns, BAD_CAST(function->requestName), NULL);
} else {
method = xmlNewChild(body, ns, BAD_CAST(function->functionName), NULL);
}
}
} else {
if ((zstyle = zend_hash_str_find(Z_OBJPROP_P(this_ptr), "style", sizeof("style")-1)) != NULL &&
Z_TYPE_P(zstyle) == IS_LONG) {
style = Z_LVAL_P(zstyle);
} else {
style = SOAP_RPC;
}
/*FIXME: how to pass method name if style is SOAP_DOCUMENT */
/*style = SOAP_RPC;*/
if (style == SOAP_RPC) {
ns = encode_add_ns(body, uri);
if (function_name) {
method = xmlNewChild(body, ns, BAD_CAST(function_name), NULL);
} else if (function && function->requestName) {
method = xmlNewChild(body, ns, BAD_CAST(function->requestName), NULL);
} else if (function && function->functionName) {
method = xmlNewChild(body, ns, BAD_CAST(function->functionName), NULL);
} else {
method = body;
}
} else {
method = body;
}
if ((zuse = zend_hash_str_find(Z_OBJPROP_P(this_ptr), "use", sizeof("use")-1)) != NULL &&
Z_TYPE_P(zuse) == IS_LONG && Z_LVAL_P(zuse) == SOAP_LITERAL) {
use = SOAP_LITERAL;
} else {
use = SOAP_ENCODED;
}
}
for (i = 0;i < arg_count;i++) {
xmlNodePtr param;
sdlParamPtr parameter = get_param(function, NULL, i, FALSE);
if (style == SOAP_RPC) {
param = serialize_parameter(parameter, &arguments[i], i, NULL, use, method);
} else if (style == SOAP_DOCUMENT) {
param = serialize_parameter(parameter, &arguments[i], i, NULL, use, body);
if (function && function->binding->bindingType == BINDING_SOAP) {
if (parameter && parameter->element) {
ns = encode_add_ns(param, parameter->element->namens);
xmlNodeSetName(param, BAD_CAST(parameter->element->name));
xmlSetNs(param, ns);
}
}
}
}
if (function && function->requestParameters) {
int n = zend_hash_num_elements(function->requestParameters);
if (n > arg_count) {
for (i = arg_count; i < n; i++) {
xmlNodePtr param;
sdlParamPtr parameter = get_param(function, NULL, i, FALSE);
if (style == SOAP_RPC) {
param = serialize_parameter(parameter, NULL, i, NULL, use, method);
} else if (style == SOAP_DOCUMENT) {
param = serialize_parameter(parameter, NULL, i, NULL, use, body);
if (function && function->binding->bindingType == BINDING_SOAP) {
if (parameter && parameter->element) {
ns = encode_add_ns(param, parameter->element->namens);
xmlNodeSetName(param, BAD_CAST(parameter->element->name));
xmlSetNs(param, ns);
}
}
}
}
}
}
if (head) {
zval* header;
ZEND_HASH_FOREACH_VAL(soap_headers, header) {
HashTable *ht;
zval *name, *ns, *tmp;
if (Z_TYPE_P(header) != IS_OBJECT) {
continue;
}
ht = Z_OBJPROP_P(header);
if ((name = zend_hash_str_find(ht, "name", sizeof("name")-1)) != NULL &&
Z_TYPE_P(name) == IS_STRING &&
(ns = zend_hash_str_find(ht, "namespace", sizeof("namespace")-1)) != NULL &&
Z_TYPE_P(ns) == IS_STRING) {
xmlNodePtr h;
xmlNsPtr nsptr;
int hdr_use = SOAP_LITERAL;
encodePtr enc = NULL;
if (hdrs) {
smart_str key = {0};
sdlSoapBindingFunctionHeaderPtr hdr;
smart_str_appendl(&key, Z_STRVAL_P(ns), Z_STRLEN_P(ns));
smart_str_appendc(&key, ':');
smart_str_appendl(&key, Z_STRVAL_P(name), Z_STRLEN_P(name));
smart_str_0(&key);
if ((hdr = zend_hash_find_ptr(hdrs, key.s)) != NULL) {
hdr_use = hdr->use;
enc = hdr->encode;
if (hdr_use == SOAP_ENCODED) {
use = SOAP_ENCODED;
}
}
smart_str_free(&key);
}
if ((tmp = zend_hash_str_find(ht, "data", sizeof("data")-1)) != NULL) {
h = master_to_xml(enc, tmp, hdr_use, head);
xmlNodeSetName(h, BAD_CAST(Z_STRVAL_P(name)));
} else {
h = xmlNewNode(NULL, BAD_CAST(Z_STRVAL_P(name)));
xmlAddChild(head, h);
}
nsptr = encode_add_ns(h, Z_STRVAL_P(ns));
xmlSetNs(h, nsptr);
set_soap_header_attributes(h, ht, version);
}
} ZEND_HASH_FOREACH_END();
}
if (use == SOAP_ENCODED) {
xmlNewNs(envelope, BAD_CAST(XSD_NAMESPACE), BAD_CAST(XSD_NS_PREFIX));
if (version == SOAP_1_1) {
xmlNewNs(envelope, BAD_CAST(SOAP_1_1_ENC_NAMESPACE), BAD_CAST(SOAP_1_1_ENC_NS_PREFIX));
xmlSetNsProp(envelope, envelope->ns, BAD_CAST("encodingStyle"), BAD_CAST(SOAP_1_1_ENC_NAMESPACE));
} else if (version == SOAP_1_2) {
xmlNewNs(envelope, BAD_CAST(SOAP_1_2_ENC_NAMESPACE), BAD_CAST(SOAP_1_2_ENC_NS_PREFIX));
if (method) {
xmlSetNsProp(method, envelope->ns, BAD_CAST("encodingStyle"), BAD_CAST(SOAP_1_2_ENC_NAMESPACE));
}
}
}
encode_finish();
} zend_catch {
/* Avoid persistent memory leak. */
xmlFreeDoc(doc);
zend_bailout();
} zend_end_try();
return doc;
}
/* }}} */
static xmlNodePtr serialize_parameter(sdlParamPtr param, zval *param_val, int index, char *name, int style, xmlNodePtr parent) /* {{{ */
{
char *paramName;
xmlNodePtr xmlParam;
char paramNameBuf[10];
if (param_val &&
Z_TYPE_P(param_val) == IS_OBJECT &&
Z_OBJCE_P(param_val) == soap_param_class_entry) {
zval *param_name;
zval *param_data;
if ((param_name = zend_hash_str_find(Z_OBJPROP_P(param_val), "param_name", sizeof("param_name")-1)) != NULL &&
Z_TYPE_P(param_name) == IS_STRING &&
(param_data = zend_hash_str_find(Z_OBJPROP_P(param_val), "param_data", sizeof("param_data")-1)) != NULL) {
param_val = param_data;
name = Z_STRVAL_P(param_name);
}
}
if (param != NULL && param->paramName != NULL) {
paramName = param->paramName;
} else {
if (name == NULL) {
paramName = paramNameBuf;
snprintf(paramName, sizeof(paramNameBuf), "param%d",index);
} else {
paramName = name;
}
}
xmlParam = serialize_zval(param_val, param, paramName, style, parent);
return xmlParam;
}
/* }}} */
static xmlNodePtr serialize_zval(zval *val, sdlParamPtr param, char *paramName, int style, xmlNodePtr parent) /* {{{ */
{
xmlNodePtr xmlParam;
encodePtr enc;
zval defval;
ZVAL_UNDEF(&defval);
if (param != NULL) {
enc = param->encode;
if (val == NULL) {
if (param->element) {
if (param->element->fixed) {
ZVAL_STRING(&defval, param->element->fixed);
val = &defval;
} else if (param->element->def && !param->element->nillable) {
ZVAL_STRING(&defval, param->element->def);
val = &defval;
}
}
}
} else {
enc = NULL;
}
xmlParam = master_to_xml(enc, val, style, parent);
zval_ptr_dtor(&defval);
if (!strcmp((char*)xmlParam->name, "BOGUS")) {
xmlNodeSetName(xmlParam, BAD_CAST(paramName));
}
return xmlParam;
}
/* }}} */
static sdlParamPtr get_param(sdlFunctionPtr function, char *param_name, int index, int response) /* {{{ */
{
sdlParamPtr tmp;
HashTable *ht;
if (function == NULL) {
return NULL;
}
if (response == FALSE) {
ht = function->requestParameters;
} else {
ht = function->responseParameters;
}
if (ht == NULL) {
return NULL;
}
if (param_name != NULL) {
if ((tmp = zend_hash_str_find_ptr(ht, param_name, strlen(param_name))) != NULL) {
return tmp;
} else {
ZEND_HASH_FOREACH_PTR(ht, tmp) {
if (tmp->paramName && strcmp(param_name, tmp->paramName) == 0) {
return tmp;
}
} ZEND_HASH_FOREACH_END();
}
} else {
if ((tmp = zend_hash_index_find_ptr(ht, index)) != NULL) {
return tmp;
}
}
return NULL;
}
/* }}} */
static sdlFunctionPtr get_function(sdlPtr sdl, const char *function_name) /* {{{ */
{
sdlFunctionPtr tmp;
int len = strlen(function_name);
char *str = estrndup(function_name,len);
php_strtolower(str,len);
if (sdl != NULL) {
if ((tmp = zend_hash_str_find_ptr(&sdl->functions, str, len)) != NULL) {
efree(str);
return tmp;
} else if (sdl->requests != NULL && (tmp = zend_hash_str_find_ptr(sdl->requests, str, len)) != NULL) {
efree(str);
return tmp;
}
}
efree(str);
return NULL;
}
/* }}} */
static sdlFunctionPtr get_doc_function(sdlPtr sdl, xmlNodePtr params) /* {{{ */
{
if (sdl) {
sdlFunctionPtr tmp;
sdlParamPtr param;
ZEND_HASH_FOREACH_PTR(&sdl->functions, tmp) {
if (tmp->binding && tmp->binding->bindingType == BINDING_SOAP) {
sdlSoapBindingFunctionPtr fnb = (sdlSoapBindingFunctionPtr)tmp->bindingAttributes;
if (fnb->style == SOAP_DOCUMENT) {
if (params == NULL) {
if (tmp->requestParameters == NULL ||
zend_hash_num_elements(tmp->requestParameters) == 0) {
return tmp;
}
} else if (tmp->requestParameters != NULL &&
zend_hash_num_elements(tmp->requestParameters) > 0) {
int ok = 1;
xmlNodePtr node = params;
ZEND_HASH_FOREACH_PTR(tmp->requestParameters, param) {
if (param->element) {
if (strcmp(param->element->name, (char*)node->name) != 0) {
ok = 0;
break;
}
if (param->element->namens != NULL && node->ns != NULL) {
if (strcmp(param->element->namens, (char*)node->ns->href) != 0) {
ok = 0;
break;
}
} else if ((void*)param->element->namens != (void*)node->ns) {
ok = 0;
break;
}
} else if (strcmp(param->paramName, (char*)node->name) != 0) {
ok = 0;
break;
}
node = node->next;
} ZEND_HASH_FOREACH_END();
if (ok /*&& node == NULL*/) {
return tmp;
}
}
}
}
} ZEND_HASH_FOREACH_END();
}
return NULL;
}
/* }}} */
static void function_to_string(sdlFunctionPtr function, smart_str *buf) /* {{{ */
{
int i = 0;
sdlParamPtr param;
if (function->responseParameters &&
zend_hash_num_elements(function->responseParameters) > 0) {
if (zend_hash_num_elements(function->responseParameters) == 1) {
zend_hash_internal_pointer_reset(function->responseParameters);
param = zend_hash_get_current_data_ptr(function->responseParameters);
if (param->encode && param->encode->details.type_str) {
smart_str_appendl(buf, param->encode->details.type_str, strlen(param->encode->details.type_str));
smart_str_appendc(buf, ' ');
} else {
smart_str_appendl(buf, "UNKNOWN ", 8);
}
} else {
i = 0;
smart_str_appendl(buf, "list(", 5);
ZEND_HASH_FOREACH_PTR(function->responseParameters, param) {
if (i > 0) {
smart_str_appendl(buf, ", ", 2);
}
if (param->encode && param->encode->details.type_str) {
smart_str_appendl(buf, param->encode->details.type_str, strlen(param->encode->details.type_str));
} else {
smart_str_appendl(buf, "UNKNOWN", 7);
}
smart_str_appendl(buf, " $", 2);
smart_str_appendl(buf, param->paramName, strlen(param->paramName));
i++;
} ZEND_HASH_FOREACH_END();
smart_str_appendl(buf, ") ", 2);
}
} else {
smart_str_appendl(buf, "void ", 5);
}
smart_str_appendl(buf, function->functionName, strlen(function->functionName));
smart_str_appendc(buf, '(');
if (function->requestParameters) {
i = 0;
ZEND_HASH_FOREACH_PTR(function->requestParameters, param) {
if (i > 0) {
smart_str_appendl(buf, ", ", 2);
}
if (param->encode && param->encode->details.type_str) {
smart_str_appendl(buf, param->encode->details.type_str, strlen(param->encode->details.type_str));
} else {
smart_str_appendl(buf, "UNKNOWN", 7);
}
smart_str_appendl(buf, " $", 2);
smart_str_appendl(buf, param->paramName, strlen(param->paramName));
i++;
} ZEND_HASH_FOREACH_END();
}
smart_str_appendc(buf, ')');
smart_str_0(buf);
}
/* }}} */
static void model_to_string(sdlContentModelPtr model, smart_str *buf, int level) /* {{{ */
{
int i;
switch (model->kind) {
case XSD_CONTENT_ELEMENT:
type_to_string(model->u.element, buf, level);
smart_str_appendl(buf, ";\n", 2);
break;
case XSD_CONTENT_ANY:
for (i = 0;i < level;i++) {
smart_str_appendc(buf, ' ');
}
smart_str_appendl(buf, "<anyXML> any;\n", sizeof("<anyXML> any;\n")-1);
break;
case XSD_CONTENT_SEQUENCE:
case XSD_CONTENT_ALL:
case XSD_CONTENT_CHOICE: {
sdlContentModelPtr tmp;
ZEND_HASH_FOREACH_PTR(model->u.content, tmp) {
model_to_string(tmp, buf, level);
} ZEND_HASH_FOREACH_END();
break;
}
case XSD_CONTENT_GROUP:
model_to_string(model->u.group->model, buf, level);
default:
break;
}
}
/* }}} */
static void type_to_string(sdlTypePtr type, smart_str *buf, int level) /* {{{ */
{
int i;
smart_str spaces = {0};
for (i = 0;i < level;i++) {
smart_str_appendc(&spaces, ' ');
}
if (spaces.s) {
smart_str_appendl(buf, ZSTR_VAL(spaces.s), ZSTR_LEN(spaces.s));
}
switch (type->kind) {
case XSD_TYPEKIND_SIMPLE:
if (type->encode) {
smart_str_appendl(buf, type->encode->details.type_str, strlen(type->encode->details.type_str));
smart_str_appendc(buf, ' ');
} else {
smart_str_appendl(buf, "anyType ", sizeof("anyType ")-1);
}
smart_str_appendl(buf, type->name, strlen(type->name));
break;
case XSD_TYPEKIND_LIST:
smart_str_appendl(buf, "list ", 5);
smart_str_appendl(buf, type->name, strlen(type->name));
if (type->elements) {
sdlTypePtr item_type;
smart_str_appendl(buf, " {", 2);
ZEND_HASH_FOREACH_PTR(type->elements, item_type) {
smart_str_appendl(buf, item_type->name, strlen(item_type->name));
} ZEND_HASH_FOREACH_END();
smart_str_appendc(buf, '}');
}
break;
case XSD_TYPEKIND_UNION:
smart_str_appendl(buf, "union ", 6);
smart_str_appendl(buf, type->name, strlen(type->name));
if (type->elements) {
sdlTypePtr item_type;
int first = 0;
smart_str_appendl(buf, " {", 2);
ZEND_HASH_FOREACH_PTR(type->elements, item_type) {
if (!first) {
smart_str_appendc(buf, ',');
first = 0;
}
smart_str_appendl(buf, item_type->name, strlen(item_type->name));
} ZEND_HASH_FOREACH_END();
smart_str_appendc(buf, '}');
}
break;
case XSD_TYPEKIND_COMPLEX:
case XSD_TYPEKIND_RESTRICTION:
case XSD_TYPEKIND_EXTENSION:
if (type->encode &&
(type->encode->details.type == IS_ARRAY ||
type->encode->details.type == SOAP_ENC_ARRAY)) {
sdlAttributePtr attr;
sdlExtraAttributePtr ext;
if (type->attributes &&
(attr = zend_hash_str_find_ptr(type->attributes, SOAP_1_1_ENC_NAMESPACE":arrayType",
sizeof(SOAP_1_1_ENC_NAMESPACE":arrayType")-1)) != NULL &&
attr->extraAttributes &&
(ext = zend_hash_str_find_ptr(attr->extraAttributes, WSDL_NAMESPACE":arrayType", sizeof(WSDL_NAMESPACE":arrayType")-1)) != NULL) {
char *end = strchr(ext->val, '[');
int len;
if (end == NULL) {
len = strlen(ext->val);
} else {
len = end - ext->val;
}
if (len == 0) {
smart_str_appendl(buf, "anyType", sizeof("anyType")-1);
} else {
smart_str_appendl(buf, ext->val, len);
}
smart_str_appendc(buf, ' ');
smart_str_appendl(buf, type->name, strlen(type->name));
if (end != NULL) {
smart_str_appends(buf, end);
}
} else {
sdlTypePtr elementType;
if (type->attributes &&
(attr = zend_hash_str_find_ptr(type->attributes, SOAP_1_2_ENC_NAMESPACE":itemType",
sizeof(SOAP_1_2_ENC_NAMESPACE":itemType")-1)) != NULL &&
attr->extraAttributes &&
(ext = zend_hash_str_find_ptr(attr->extraAttributes, WSDL_NAMESPACE":itemType", sizeof(WSDL_NAMESPACE":arrayType")-1)) != NULL) {
smart_str_appends(buf, ext->val);
smart_str_appendc(buf, ' ');
} else if (type->elements &&
zend_hash_num_elements(type->elements) == 1 &&
(zend_hash_internal_pointer_reset(type->elements),
(elementType = zend_hash_get_current_data_ptr(type->elements)) != NULL) &&
elementType->encode && elementType->encode->details.type_str) {
smart_str_appends(buf, elementType->encode->details.type_str);
smart_str_appendc(buf, ' ');
} else {
smart_str_appendl(buf, "anyType ", 8);
}
smart_str_appendl(buf, type->name, strlen(type->name));
if (type->attributes &&
(attr = zend_hash_str_find_ptr(type->attributes, SOAP_1_2_ENC_NAMESPACE":arraySize",
sizeof(SOAP_1_2_ENC_NAMESPACE":arraySize")-1)) != NULL &&
attr->extraAttributes &&
(ext = zend_hash_str_find_ptr(attr->extraAttributes, WSDL_NAMESPACE":itemType", sizeof(WSDL_NAMESPACE":arraySize")-1)) != NULL) {
smart_str_appendc(buf, '[');
smart_str_appends(buf, ext->val);
smart_str_appendc(buf, ']');
} else {
smart_str_appendl(buf, "[]", 2);
}
}
} else {
smart_str_appendl(buf, "struct ", 7);
smart_str_appendl(buf, type->name, strlen(type->name));
smart_str_appendc(buf, ' ');
smart_str_appendl(buf, "{\n", 2);
if ((type->kind == XSD_TYPEKIND_RESTRICTION ||
type->kind == XSD_TYPEKIND_EXTENSION) && type->encode) {
encodePtr enc = type->encode;
while (enc && enc->details.sdl_type &&
enc != enc->details.sdl_type->encode &&
enc->details.sdl_type->kind != XSD_TYPEKIND_SIMPLE &&
enc->details.sdl_type->kind != XSD_TYPEKIND_LIST &&
enc->details.sdl_type->kind != XSD_TYPEKIND_UNION) {
enc = enc->details.sdl_type->encode;
}
if (enc) {
if (spaces.s) {
smart_str_appendl(buf, ZSTR_VAL(spaces.s), ZSTR_LEN(spaces.s));
}
smart_str_appendc(buf, ' ');
smart_str_appendl(buf, type->encode->details.type_str, strlen(type->encode->details.type_str));
smart_str_appendl(buf, " _;\n", 4);
}
}
if (type->model) {
model_to_string(type->model, buf, level+1);
}
if (type->attributes) {
sdlAttributePtr attr;
ZEND_HASH_FOREACH_PTR(type->attributes, attr) {
if (spaces.s) {
smart_str_appendl(buf, ZSTR_VAL(spaces.s), ZSTR_LEN(spaces.s));
}
smart_str_appendc(buf, ' ');
if (attr->encode && attr->encode->details.type_str) {
smart_str_appends(buf, attr->encode->details.type_str);
smart_str_appendc(buf, ' ');
} else {
smart_str_appendl(buf, "UNKNOWN ", 8);
}
smart_str_appends(buf, attr->name);
smart_str_appendl(buf, ";\n", 2);
} ZEND_HASH_FOREACH_END();
}
if (spaces.s) {
smart_str_appendl(buf, ZSTR_VAL(spaces.s), ZSTR_LEN(spaces.s));
}
smart_str_appendc(buf, '}');
}
break;
default:
break;
}
smart_str_free(&spaces);
smart_str_0(buf);
}
/* }}} */
static void delete_url(void *handle) /* {{{ */
{
php_url_free((php_url*)handle);
}
/* }}} */
static void delete_service(void *data) /* {{{ */
{
soapServicePtr service = (soapServicePtr)data;
if (service->soap_functions.ft) {
zend_hash_destroy(service->soap_functions.ft);
efree(service->soap_functions.ft);
}
if (service->typemap) {
zend_hash_destroy(service->typemap);
efree(service->typemap);
}
if (service->soap_class.argc) {
int i;
for (i = 0; i < service->soap_class.argc;i++) {
zval_ptr_dtor(&service->soap_class.argv[i]);
}
efree(service->soap_class.argv);
}
if (service->actor) {
efree(service->actor);
}
if (service->uri) {
efree(service->uri);
}
if (service->sdl) {
delete_sdl(service->sdl);
}
if (service->encoding) {
xmlCharEncCloseFunc(service->encoding);
}
if (service->class_map) {
zend_hash_destroy(service->class_map);
FREE_HASHTABLE(service->class_map);
}
zval_ptr_dtor(&service->soap_object);
efree(service);
}
/* }}} */
static void delete_hashtable(void *data) /* {{{ */
{
HashTable *ht = (HashTable*)data;
zend_hash_destroy(ht);
efree(ht);
}
/* }}} */
|
408806.c | /*-------------------------------------------------------------------------
*
* bitmapset.c
* PostgreSQL generic bitmap set package
*
* A bitmap set can represent any set of nonnegative integers, although
* it is mainly intended for sets where the maximum value is not large,
* say at most a few hundred. By convention, a NULL pointer is always
* accepted by all operations to represent the empty set. (But beware
* that this is not the only representation of the empty set. Use
* bms_is_empty() in preference to testing for NULL.)
*
*
* Copyright (c) 2003-2016, PostgreSQL Global Development Group
*
* IDENTIFICATION
* src/backend/nodes/bitmapset.c
*
*-------------------------------------------------------------------------
*/
#include "postgres.h"
#include "access/hash.h"
#define WORDNUM(x) ((x) / BITS_PER_BITMAPWORD)
#define BITNUM(x) ((x) % BITS_PER_BITMAPWORD)
#define BITMAPSET_SIZE(nwords) \
(offsetof(Bitmapset, words) + (nwords) * sizeof(bitmapword))
/*----------
* This is a well-known cute trick for isolating the rightmost one-bit
* in a word. It assumes two's complement arithmetic. Consider any
* nonzero value, and focus attention on the rightmost one. The value is
* then something like
* xxxxxx10000
* where x's are unspecified bits. The two's complement negative is formed
* by inverting all the bits and adding one. Inversion gives
* yyyyyy01111
* where each y is the inverse of the corresponding x. Incrementing gives
* yyyyyy10000
* and then ANDing with the original value gives
* 00000010000
* This works for all cases except original value = zero, where of course
* we get zero.
*----------
*/
#define RIGHTMOST_ONE(x) ((signedbitmapword) (x) & -((signedbitmapword) (x)))
#define HAS_MULTIPLE_ONES(x) ((bitmapword) RIGHTMOST_ONE(x) != (x))
/*
* Lookup tables to avoid need for bit-by-bit groveling
*
* rightmost_one_pos[x] gives the bit number (0-7) of the rightmost one bit
* in a nonzero byte value x. The entry for x=0 is never used.
*
* number_of_ones[x] gives the number of one-bits (0-8) in a byte value x.
*
* We could make these tables larger and reduce the number of iterations
* in the functions that use them, but bytewise shifts and masks are
* especially fast on many machines, so working a byte at a time seems best.
*/
static const uint8 rightmost_one_pos[256] = {
0, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
7, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0
};
static const uint8 number_of_ones[256] = {
0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4,
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8
};
/*
* bms_copy - make a palloc'd copy of a bitmapset
*/
Bitmapset *
bms_copy(const Bitmapset *a)
{
Bitmapset *result;
size_t size;
if (a == NULL)
return NULL;
size = BITMAPSET_SIZE(a->nwords);
result = (Bitmapset *) palloc(size);
memcpy(result, a, size);
return result;
}
/*
* bms_equal - are two bitmapsets equal?
*
* This is logical not physical equality; in particular, a NULL pointer will
* be reported as equal to a palloc'd value containing no members.
*/
bool
bms_equal(const Bitmapset *a, const Bitmapset *b)
{
const Bitmapset *shorter;
const Bitmapset *longer;
int shortlen;
int longlen;
int i;
/* Handle cases where either input is NULL */
if (a == NULL)
{
if (b == NULL)
return true;
return bms_is_empty(b);
}
else if (b == NULL)
return bms_is_empty(a);
/* Identify shorter and longer input */
if (a->nwords <= b->nwords)
{
shorter = a;
longer = b;
}
else
{
shorter = b;
longer = a;
}
/* And process */
shortlen = shorter->nwords;
for (i = 0; i < shortlen; i++)
{
if (shorter->words[i] != longer->words[i])
return false;
}
longlen = longer->nwords;
for (; i < longlen; i++)
{
if (longer->words[i] != 0)
return false;
}
return true;
}
/*
* bms_make_singleton - build a bitmapset containing a single member
*/
Bitmapset *
bms_make_singleton(int x)
{
Bitmapset *result;
int wordnum,
bitnum;
if (x < 0)
elog(ERROR, "negative bitmapset member not allowed");
wordnum = WORDNUM(x);
bitnum = BITNUM(x);
result = (Bitmapset *) palloc0(BITMAPSET_SIZE(wordnum + 1));
result->nwords = wordnum + 1;
result->words[wordnum] = ((bitmapword) 1 << bitnum);
return result;
}
/*
* bms_free - free a bitmapset
*
* Same as pfree except for allowing NULL input
*/
void
bms_free(Bitmapset *a)
{
if (a)
pfree(a);
}
/*
* These operations all make a freshly palloc'd result,
* leaving their inputs untouched
*/
/*
* bms_union - set union
*/
Bitmapset *
bms_union(const Bitmapset *a, const Bitmapset *b)
{
Bitmapset *result;
const Bitmapset *other;
int otherlen;
int i;
/* Handle cases where either input is NULL */
if (a == NULL)
return bms_copy(b);
if (b == NULL)
return bms_copy(a);
/* Identify shorter and longer input; copy the longer one */
if (a->nwords <= b->nwords)
{
result = bms_copy(b);
other = a;
}
else
{
result = bms_copy(a);
other = b;
}
/* And union the shorter input into the result */
otherlen = other->nwords;
for (i = 0; i < otherlen; i++)
result->words[i] |= other->words[i];
return result;
}
/*
* bms_intersect - set intersection
*/
Bitmapset *
bms_intersect(const Bitmapset *a, const Bitmapset *b)
{
Bitmapset *result;
const Bitmapset *other;
int resultlen;
int i;
/* Handle cases where either input is NULL */
if (a == NULL || b == NULL)
return NULL;
/* Identify shorter and longer input; copy the shorter one */
if (a->nwords <= b->nwords)
{
result = bms_copy(a);
other = b;
}
else
{
result = bms_copy(b);
other = a;
}
/* And intersect the longer input with the result */
resultlen = result->nwords;
for (i = 0; i < resultlen; i++)
result->words[i] &= other->words[i];
return result;
}
/*
* bms_difference - set difference (ie, A without members of B)
*/
Bitmapset *
bms_difference(const Bitmapset *a, const Bitmapset *b)
{
Bitmapset *result;
int shortlen;
int i;
/* Handle cases where either input is NULL */
if (a == NULL)
return NULL;
if (b == NULL)
return bms_copy(a);
/* Copy the left input */
result = bms_copy(a);
/* And remove b's bits from result */
shortlen = Min(a->nwords, b->nwords);
for (i = 0; i < shortlen; i++)
result->words[i] &= ~b->words[i];
return result;
}
/*
* bms_is_subset - is A a subset of B?
*/
bool
bms_is_subset(const Bitmapset *a, const Bitmapset *b)
{
int shortlen;
int longlen;
int i;
/* Handle cases where either input is NULL */
if (a == NULL)
return true; /* empty set is a subset of anything */
if (b == NULL)
return bms_is_empty(a);
/* Check common words */
shortlen = Min(a->nwords, b->nwords);
for (i = 0; i < shortlen; i++)
{
if ((a->words[i] & ~b->words[i]) != 0)
return false;
}
/* Check extra words */
if (a->nwords > b->nwords)
{
longlen = a->nwords;
for (; i < longlen; i++)
{
if (a->words[i] != 0)
return false;
}
}
return true;
}
/*
* bms_subset_compare - compare A and B for equality/subset relationships
*
* This is more efficient than testing bms_is_subset in both directions.
*/
BMS_Comparison
bms_subset_compare(const Bitmapset *a, const Bitmapset *b)
{
BMS_Comparison result;
int shortlen;
int longlen;
int i;
/* Handle cases where either input is NULL */
if (a == NULL)
{
if (b == NULL)
return BMS_EQUAL;
return bms_is_empty(b) ? BMS_EQUAL : BMS_SUBSET1;
}
if (b == NULL)
return bms_is_empty(a) ? BMS_EQUAL : BMS_SUBSET2;
/* Check common words */
result = BMS_EQUAL; /* status so far */
shortlen = Min(a->nwords, b->nwords);
for (i = 0; i < shortlen; i++)
{
bitmapword aword = a->words[i];
bitmapword bword = b->words[i];
if ((aword & ~bword) != 0)
{
/* a is not a subset of b */
if (result == BMS_SUBSET1)
return BMS_DIFFERENT;
result = BMS_SUBSET2;
}
if ((bword & ~aword) != 0)
{
/* b is not a subset of a */
if (result == BMS_SUBSET2)
return BMS_DIFFERENT;
result = BMS_SUBSET1;
}
}
/* Check extra words */
if (a->nwords > b->nwords)
{
longlen = a->nwords;
for (; i < longlen; i++)
{
if (a->words[i] != 0)
{
/* a is not a subset of b */
if (result == BMS_SUBSET1)
return BMS_DIFFERENT;
result = BMS_SUBSET2;
}
}
}
else if (a->nwords < b->nwords)
{
longlen = b->nwords;
for (; i < longlen; i++)
{
if (b->words[i] != 0)
{
/* b is not a subset of a */
if (result == BMS_SUBSET2)
return BMS_DIFFERENT;
result = BMS_SUBSET1;
}
}
}
return result;
}
/*
* bms_is_member - is X a member of A?
*/
bool
bms_is_member(int x, const Bitmapset *a)
{
int wordnum,
bitnum;
/* XXX better to just return false for x<0 ? */
if (x < 0)
elog(ERROR, "negative bitmapset member not allowed");
if (a == NULL)
return false;
wordnum = WORDNUM(x);
bitnum = BITNUM(x);
if (wordnum >= a->nwords)
return false;
if ((a->words[wordnum] & ((bitmapword) 1 << bitnum)) != 0)
return true;
return false;
}
/*
* bms_overlap - do sets overlap (ie, have a nonempty intersection)?
*/
bool
bms_overlap(const Bitmapset *a, const Bitmapset *b)
{
int shortlen;
int i;
/* Handle cases where either input is NULL */
if (a == NULL || b == NULL)
return false;
/* Check words in common */
shortlen = Min(a->nwords, b->nwords);
for (i = 0; i < shortlen; i++)
{
if ((a->words[i] & b->words[i]) != 0)
return true;
}
return false;
}
/*
* bms_nonempty_difference - do sets have a nonempty difference?
*/
bool
bms_nonempty_difference(const Bitmapset *a, const Bitmapset *b)
{
int shortlen;
int i;
/* Handle cases where either input is NULL */
if (a == NULL)
return false;
if (b == NULL)
return !bms_is_empty(a);
/* Check words in common */
shortlen = Min(a->nwords, b->nwords);
for (i = 0; i < shortlen; i++)
{
if ((a->words[i] & ~b->words[i]) != 0)
return true;
}
/* Check extra words in a */
for (; i < a->nwords; i++)
{
if (a->words[i] != 0)
return true;
}
return false;
}
/*
* bms_singleton_member - return the sole integer member of set
*
* Raises error if |a| is not 1.
*/
int
bms_singleton_member(const Bitmapset *a)
{
int result = -1;
int nwords;
int wordnum;
if (a == NULL)
elog(ERROR, "bitmapset is empty");
nwords = a->nwords;
for (wordnum = 0; wordnum < nwords; wordnum++)
{
bitmapword w = a->words[wordnum];
if (w != 0)
{
if (result >= 0 || HAS_MULTIPLE_ONES(w))
elog(ERROR, "bitmapset has multiple members");
result = wordnum * BITS_PER_BITMAPWORD;
while ((w & 255) == 0)
{
w >>= 8;
result += 8;
}
result += rightmost_one_pos[w & 255];
}
}
if (result < 0)
elog(ERROR, "bitmapset is empty");
return result;
}
/*
* bms_get_singleton_member
*
* Test whether the given set is a singleton.
* If so, set *member to the value of its sole member, and return TRUE.
* If not, return FALSE, without changing *member.
*
* This is more convenient and faster than calling bms_membership() and then
* bms_singleton_member(), if we don't care about distinguishing empty sets
* from multiple-member sets.
*/
bool
bms_get_singleton_member(const Bitmapset *a, int *member)
{
int result = -1;
int nwords;
int wordnum;
if (a == NULL)
return false;
nwords = a->nwords;
for (wordnum = 0; wordnum < nwords; wordnum++)
{
bitmapword w = a->words[wordnum];
if (w != 0)
{
if (result >= 0 || HAS_MULTIPLE_ONES(w))
return false;
result = wordnum * BITS_PER_BITMAPWORD;
while ((w & 255) == 0)
{
w >>= 8;
result += 8;
}
result += rightmost_one_pos[w & 255];
}
}
if (result < 0)
return false;
*member = result;
return true;
}
/*
* bms_num_members - count members of set
*/
int
bms_num_members(const Bitmapset *a)
{
int result = 0;
int nwords;
int wordnum;
if (a == NULL)
return 0;
nwords = a->nwords;
for (wordnum = 0; wordnum < nwords; wordnum++)
{
bitmapword w = a->words[wordnum];
/* we assume here that bitmapword is an unsigned type */
while (w != 0)
{
result += number_of_ones[w & 255];
w >>= 8;
}
}
return result;
}
/*
* bms_membership - does a set have zero, one, or multiple members?
*
* This is faster than making an exact count with bms_num_members().
*/
BMS_Membership
bms_membership(const Bitmapset *a)
{
BMS_Membership result = BMS_EMPTY_SET;
int nwords;
int wordnum;
if (a == NULL)
return BMS_EMPTY_SET;
nwords = a->nwords;
for (wordnum = 0; wordnum < nwords; wordnum++)
{
bitmapword w = a->words[wordnum];
if (w != 0)
{
if (result != BMS_EMPTY_SET || HAS_MULTIPLE_ONES(w))
return BMS_MULTIPLE;
result = BMS_SINGLETON;
}
}
return result;
}
/*
* bms_is_empty - is a set empty?
*
* This is even faster than bms_membership().
*/
bool
bms_is_empty(const Bitmapset *a)
{
int nwords;
int wordnum;
if (a == NULL)
return true;
nwords = a->nwords;
for (wordnum = 0; wordnum < nwords; wordnum++)
{
bitmapword w = a->words[wordnum];
if (w != 0)
return false;
}
return true;
}
/*
* These operations all "recycle" their non-const inputs, ie, either
* return the modified input or pfree it if it can't hold the result.
*
* These should generally be used in the style
*
* foo = bms_add_member(foo, x);
*/
/*
* bms_add_member - add a specified member to set
*
* Input set is modified or recycled!
*/
Bitmapset *
bms_add_member(Bitmapset *a, int x)
{
int wordnum,
bitnum;
if (x < 0)
elog(ERROR, "negative bitmapset member not allowed");
if (a == NULL)
return bms_make_singleton(x);
wordnum = WORDNUM(x);
bitnum = BITNUM(x);
/* enlarge the set if necessary */
if (wordnum >= a->nwords)
{
int oldnwords = a->nwords;
int i;
a = (Bitmapset *) repalloc(a, BITMAPSET_SIZE(wordnum + 1));
a->nwords = wordnum + 1;
/* zero out the enlarged portion */
for (i = oldnwords; i < a->nwords; i++)
a->words[i] = 0;
}
a->words[wordnum] |= ((bitmapword) 1 << bitnum);
return a;
}
/*
* bms_del_member - remove a specified member from set
*
* No error if x is not currently a member of set
*
* Input set is modified in-place!
*/
Bitmapset *
bms_del_member(Bitmapset *a, int x)
{
int wordnum,
bitnum;
if (x < 0)
elog(ERROR, "negative bitmapset member not allowed");
if (a == NULL)
return NULL;
wordnum = WORDNUM(x);
bitnum = BITNUM(x);
if (wordnum < a->nwords)
a->words[wordnum] &= ~((bitmapword) 1 << bitnum);
return a;
}
/*
* bms_add_members - like bms_union, but left input is recycled
*/
Bitmapset *
bms_add_members(Bitmapset *a, const Bitmapset *b)
{
Bitmapset *result;
const Bitmapset *other;
int otherlen;
int i;
/* Handle cases where either input is NULL */
if (a == NULL)
return bms_copy(b);
if (b == NULL)
return a;
/* Identify shorter and longer input; copy the longer one if needed */
if (a->nwords < b->nwords)
{
result = bms_copy(b);
other = a;
}
else
{
result = a;
other = b;
}
/* And union the shorter input into the result */
otherlen = other->nwords;
for (i = 0; i < otherlen; i++)
result->words[i] |= other->words[i];
if (result != a)
pfree(a);
return result;
}
/*
* bms_int_members - like bms_intersect, but left input is recycled
*/
Bitmapset *
bms_int_members(Bitmapset *a, const Bitmapset *b)
{
int shortlen;
int i;
/* Handle cases where either input is NULL */
if (a == NULL)
return NULL;
if (b == NULL)
{
pfree(a);
return NULL;
}
/* Intersect b into a; we need never copy */
shortlen = Min(a->nwords, b->nwords);
for (i = 0; i < shortlen; i++)
a->words[i] &= b->words[i];
for (; i < a->nwords; i++)
a->words[i] = 0;
return a;
}
/*
* bms_del_members - like bms_difference, but left input is recycled
*/
Bitmapset *
bms_del_members(Bitmapset *a, const Bitmapset *b)
{
int shortlen;
int i;
/* Handle cases where either input is NULL */
if (a == NULL)
return NULL;
if (b == NULL)
return a;
/* Remove b's bits from a; we need never copy */
shortlen = Min(a->nwords, b->nwords);
for (i = 0; i < shortlen; i++)
a->words[i] &= ~b->words[i];
return a;
}
/*
* bms_join - like bms_union, but *both* inputs are recycled
*/
Bitmapset *
bms_join(Bitmapset *a, Bitmapset *b)
{
Bitmapset *result;
Bitmapset *other;
int otherlen;
int i;
/* Handle cases where either input is NULL */
if (a == NULL)
return b;
if (b == NULL)
return a;
/* Identify shorter and longer input; use longer one as result */
if (a->nwords < b->nwords)
{
result = b;
other = a;
}
else
{
result = a;
other = b;
}
/* And union the shorter input into the result */
otherlen = other->nwords;
for (i = 0; i < otherlen; i++)
result->words[i] |= other->words[i];
if (other != result) /* pure paranoia */
pfree(other);
return result;
}
/*
* bms_first_member - find and remove first member of a set
*
* Returns -1 if set is empty. NB: set is destructively modified!
*
* This is intended as support for iterating through the members of a set.
* The typical pattern is
*
* while ((x = bms_first_member(inputset)) >= 0)
* process member x;
*
* CAUTION: this destroys the content of "inputset". If the set must
* not be modified, use bms_next_member instead.
*/
int
bms_first_member(Bitmapset *a)
{
int nwords;
int wordnum;
if (a == NULL)
return -1;
nwords = a->nwords;
for (wordnum = 0; wordnum < nwords; wordnum++)
{
bitmapword w = a->words[wordnum];
if (w != 0)
{
int result;
w = RIGHTMOST_ONE(w);
a->words[wordnum] &= ~w;
result = wordnum * BITS_PER_BITMAPWORD;
while ((w & 255) == 0)
{
w >>= 8;
result += 8;
}
result += rightmost_one_pos[w & 255];
return result;
}
}
return -1;
}
/*
* bms_next_member - find next member of a set
*
* Returns smallest member greater than "prevbit", or -2 if there is none.
* "prevbit" must NOT be less than -1, or the behavior is unpredictable.
*
* This is intended as support for iterating through the members of a set.
* The typical pattern is
*
* x = -1;
* while ((x = bms_next_member(inputset, x)) >= 0)
* process member x;
*
* Notice that when there are no more members, we return -2, not -1 as you
* might expect. The rationale for that is to allow distinguishing the
* loop-not-started state (x == -1) from the loop-completed state (x == -2).
* It makes no difference in simple loop usage, but complex iteration logic
* might need such an ability.
*/
int
bms_next_member(const Bitmapset *a, int prevbit)
{
int nwords;
int wordnum;
bitmapword mask;
if (a == NULL)
return -2;
nwords = a->nwords;
prevbit++;
mask = (~(bitmapword) 0) << BITNUM(prevbit);
for (wordnum = WORDNUM(prevbit); wordnum < nwords; wordnum++)
{
bitmapword w = a->words[wordnum];
/* ignore bits before prevbit */
w &= mask;
if (w != 0)
{
int result;
result = wordnum * BITS_PER_BITMAPWORD;
while ((w & 255) == 0)
{
w >>= 8;
result += 8;
}
result += rightmost_one_pos[w & 255];
return result;
}
/* in subsequent words, consider all bits */
mask = (~(bitmapword) 0);
}
return -2;
}
/*
* bms_hash_value - compute a hash key for a Bitmapset
*
* Note: we must ensure that any two bitmapsets that are bms_equal() will
* hash to the same value; in practice this means that trailing all-zero
* words must not affect the result. Hence we strip those before applying
* hash_any().
*/
uint32
bms_hash_value(const Bitmapset *a)
{
int lastword;
if (a == NULL)
return 0; /* All empty sets hash to 0 */
for (lastword = a->nwords; --lastword >= 0;)
{
if (a->words[lastword] != 0)
break;
}
if (lastword < 0)
return 0; /* All empty sets hash to 0 */
return DatumGetUInt32(hash_any((const unsigned char *) a->words,
(lastword + 1) * sizeof(bitmapword)));
}
|
569231.c | /* evilwm - Minimalist Window Manager for X
* Copyright (C) 1999-2011 Ciaran Anscomb
* see README for license and other details. */
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "log.h"
#include "xconfig.h"
/* Break a space-separated string into an array of strings.
* Backslash escapes next character. */
static char **split_string(const char *arg) {
int nelem = 0, elem = 0;
char **list = NULL;
char *string, *head, *tail;
head = tail = string = malloc(strlen(arg) + 1);
if (string == NULL)
return NULL;
for (;;) {
if (*arg == '\\' && *(arg+1) != 0) {
arg++;
*(tail++) = *(arg++);
} else if (*arg == 0 || isspace(*arg)) {
*tail = 0;
if (*head) {
if ((elem + 1) >= nelem) {
char **nlist;
nelem += 4;
nlist = realloc(list, nelem * sizeof(char *));
if (nlist == NULL) {
if (list)
free(list);
free(string);
return NULL;
}
list = nlist;
}
list[elem++] = head;
tail++;
head = tail;
}
while (isspace(*arg)) {
arg++;
}
if (*arg == 0) {
break;
}
} else {
*(tail++) = *(arg++);
}
}
if (elem == 0) {
free(string);
return NULL;
}
list[elem] = NULL;
return list;
}
static struct xconfig_option *find_option(struct xconfig_option *options,
const char *opt) {
int i;
for (i = 0; options[i].type != XCONFIG_END; i++) {
if (0 == strcmp(options[i].name, opt)) {
return &options[i];
}
}
return NULL;
}
static void set_option(struct xconfig_option *option, const char *arg) {
switch (option->type) {
case XCONFIG_BOOL:
*(int *)option->dest = 1;
break;
case XCONFIG_INT:
*(int *)option->dest = strtol(arg, NULL, 0);
break;
case XCONFIG_STRING:
*(char **)option->dest = strdup(arg);
break;
case XCONFIG_STR_LIST:
*(char ***)option->dest = split_string(arg);
break;
case XCONFIG_CALL_0:
((void (*)(void))option->dest)();
break;
case XCONFIG_CALL_1:
((void (*)(const char *))option->dest)(arg);
break;
default:
break;
}
}
/* Simple parser: one directive per line, "option argument" */
enum xconfig_result xconfig_parse_file(struct xconfig_option *options,
const char *filename) {
struct xconfig_option *option;
char buf[256];
char *line, *opt, *arg;
FILE *cfg;
cfg = fopen(filename, "r");
if (cfg == NULL) return XCONFIG_FILE_ERROR;
while ((line = fgets(buf, sizeof(buf), cfg))) {
while (isspace((int)*line))
line++;
if (*line == 0 || *line == '#')
continue;
opt = strtok(line, "\t\n\v\f\r =");
if (opt == NULL) continue;
option = find_option(options, opt);
if (option == NULL) {
LOG_INFO("Ignoring unknown option `%s'\n", opt);
continue;
}
if (option->type == XCONFIG_STR_LIST) {
/* special case: spaces here mean something */
arg = strtok(NULL, "\n\v\f\r");
while (isspace(*arg) || *arg == '=') {
arg++;
}
} else {
arg = strtok(NULL, "\t\n\v\f\r =");
}
set_option(option, arg);
}
fclose(cfg);
return XCONFIG_OK;
}
enum xconfig_result xconfig_parse_cli(struct xconfig_option *options,
int argc, char **argv, int *argn) {
struct xconfig_option *option;
int _argn;
char *optstr;
_argn = argn ? *argn : 1;
while (_argn < argc) {
if (argv[_argn][0] != '-') {
break;
}
if (0 == strcmp("--", argv[_argn])) {
_argn++;
break;
}
optstr = argv[_argn]+1;
if (*optstr == '-') optstr++;
option = find_option(options, optstr);
if (option == NULL) {
if (argn) *argn = _argn;
return XCONFIG_BAD_OPTION;
}
if (option->type == XCONFIG_BOOL
|| option->type == XCONFIG_CALL_0) {
set_option(option, NULL);
_argn++;
continue;
}
if ((_argn + 1) >= argc) {
if (argn) *argn = _argn;
return XCONFIG_MISSING_ARG;
}
set_option(option, argv[_argn+1]);
_argn += 2;
}
if (argn) *argn = _argn;
return XCONFIG_OK;
}
|
39507.c |
/*! @file ilu_ddrop_row.c
* \brief Drop small rows from L
*
* <pre>
* -- SuperLU routine (version 4.1) --
* Lawrence Berkeley National Laboratory.
* June 30, 2009
* </pre>
*/
#include <math.h>
#include <stdlib.h>
#include "slu_ddefs.h"
extern void dswap_(int *, double [], int *, double [], int *);
extern void daxpy_(int *, double *, double [], int *, double [], int *);
extern void dcopy_(int *, double [], int *, double [], int *);
extern double dasum_(int *, double *, int *);
extern double dnrm2_(int *, double *, int *);
extern double dnrm2_(int *, double [], int *);
extern int idamax_(int *, double [], int *);
static double *A; /* used in _compare_ only */
static int _compare_(const void *a, const void *b)
{
register int *x = (int *)a, *y = (int *)b;
if (A[*x] - A[*y] > 0.0) return -1;
else if (A[*x] - A[*y] < 0.0) return 1;
else return 0;
}
/*! \brief
* <pre>
* Purpose
* =======
* ilu_ddrop_row() - Drop some small rows from the previous
* supernode (L-part only).
* </pre>
*/
int ilu_ddrop_row(
superlu_options_t *options, /* options */
int first, /* index of the first column in the supernode */
int last, /* index of the last column in the supernode */
double drop_tol, /* dropping parameter */
int quota, /* maximum nonzero entries allowed */
int *nnzLj, /* in/out number of nonzeros in L(:, 1:last) */
double *fill_tol, /* in/out - on exit, fill_tol=-num_zero_pivots,
* does not change if options->ILU_MILU != SMILU1 */
GlobalLU_t *Glu, /* modified */
double dwork[], /* working space
* the length of dwork[] should be no less than
* the number of rows in the supernode */
double dwork2[], /* working space with the same size as dwork[],
* used only by the second dropping rule */
int lastc /* if lastc == 0, there is nothing after the
* working supernode [first:last];
* if lastc == 1, there is one more column after
* the working supernode. */ )
{
register int i, j, k, m1;
register int nzlc; /* number of nonzeros in column last+1 */
register int xlusup_first, xlsub_first;
int m, n; /* m x n is the size of the supernode */
int r = 0; /* number of dropped rows */
register double *temp;
register double *lusup = Glu->lusup;
register int *lsub = Glu->lsub;
register int *xlsub = Glu->xlsub;
register int *xlusup = Glu->xlusup;
register double d_max = 0.0, d_min = 1.0;
int drop_rule = options->ILU_DropRule;
milu_t milu = options->ILU_MILU;
norm_t nrm = options->ILU_Norm;
double zero = 0.0;
double one = 1.0;
double none = -1.0;
int i_1 = 1;
int inc_diag; /* inc_diag = m + 1 */
int nzp = 0; /* number of zero pivots */
double alpha = pow((double)(Glu->n), -1.0 / options->ILU_MILU_Dim);
xlusup_first = xlusup[first];
xlsub_first = xlsub[first];
m = xlusup[first + 1] - xlusup_first;
n = last - first + 1;
m1 = m - 1;
inc_diag = m + 1;
nzlc = lastc ? (xlusup[last + 2] - xlusup[last + 1]) : 0;
temp = dwork - n;
/* Quick return if nothing to do. */
if (m == 0 || m == n || drop_rule == NODROP)
{
*nnzLj += m * n;
return 0;
}
/* basic dropping: ILU(tau) */
for (i = n; i <= m1; )
{
/* the average abs value of ith row */
switch (nrm)
{
case ONE_NORM:
temp[i] = dasum_(&n, &lusup[xlusup_first + i], &m) / (double)n;
break;
case TWO_NORM:
temp[i] = dnrm2_(&n, &lusup[xlusup_first + i], &m)
/ sqrt((double)n);
break;
case INF_NORM:
default:
k = idamax_(&n, &lusup[xlusup_first + i], &m) - 1;
temp[i] = fabs(lusup[xlusup_first + i + m * k]);
break;
}
/* drop small entries due to drop_tol */
if (drop_rule & DROP_BASIC && temp[i] < drop_tol)
{
r++;
/* drop the current row and move the last undropped row here */
if (r > 1) /* add to last row */
{
/* accumulate the sum (for MILU) */
switch (milu)
{
case SMILU_1:
case SMILU_2:
daxpy_(&n, &one, &lusup[xlusup_first + i], &m,
&lusup[xlusup_first + m - 1], &m);
break;
case SMILU_3:
for (j = 0; j < n; j++)
lusup[xlusup_first + (m - 1) + j * m] +=
fabs(lusup[xlusup_first + i + j * m]);
break;
case SILU:
default:
break;
}
dcopy_(&n, &lusup[xlusup_first + m1], &m,
&lusup[xlusup_first + i], &m);
} /* if (r > 1) */
else /* move to last row */
{
dswap_(&n, &lusup[xlusup_first + m1], &m,
&lusup[xlusup_first + i], &m);
if (milu == SMILU_3)
for (j = 0; j < n; j++) {
lusup[xlusup_first + m1 + j * m] =
fabs(lusup[xlusup_first + m1 + j * m]);
}
}
lsub[xlsub_first + i] = lsub[xlsub_first + m1];
m1--;
continue;
} /* if dropping */
else
{
if (temp[i] > d_max) d_max = temp[i];
if (temp[i] < d_min) d_min = temp[i];
}
i++;
} /* for */
/* Secondary dropping: drop more rows according to the quota. */
quota = ceil((double)quota / (double)n);
if (drop_rule & DROP_SECONDARY && m - r > quota)
{
register double tol = d_max;
/* Calculate the second dropping tolerance */
if (quota > n)
{
if (drop_rule & DROP_INTERP) /* by interpolation */
{
d_max = 1.0 / d_max; d_min = 1.0 / d_min;
tol = 1.0 / (d_max + (d_min - d_max) * quota / (m - n - r));
}
else /* by quick select */
{
int len = m1 - n + 1;
dcopy_(&len, dwork, &i_1, dwork2, &i_1);
tol = dqselect(len, dwork2, quota - n);
#if 0
register int *itemp = iwork - n;
A = temp;
for (i = n; i <= m1; i++) itemp[i] = i;
qsort(iwork, m1 - n + 1, sizeof(int), _compare_);
tol = temp[itemp[quota]];
#endif
}
}
for (i = n; i <= m1; )
{
if (temp[i] <= tol)
{
register int j;
r++;
/* drop the current row and move the last undropped row here */
if (r > 1) /* add to last row */
{
/* accumulate the sum (for MILU) */
switch (milu)
{
case SMILU_1:
case SMILU_2:
daxpy_(&n, &one, &lusup[xlusup_first + i], &m,
&lusup[xlusup_first + m - 1], &m);
break;
case SMILU_3:
for (j = 0; j < n; j++)
lusup[xlusup_first + (m - 1) + j * m] +=
fabs(lusup[xlusup_first + i + j * m]);
break;
case SILU:
default:
break;
}
dcopy_(&n, &lusup[xlusup_first + m1], &m,
&lusup[xlusup_first + i], &m);
} /* if (r > 1) */
else /* move to last row */
{
dswap_(&n, &lusup[xlusup_first + m1], &m,
&lusup[xlusup_first + i], &m);
if (milu == SMILU_3)
for (j = 0; j < n; j++) {
lusup[xlusup_first + m1 + j * m] =
fabs(lusup[xlusup_first + m1 + j * m]);
}
}
lsub[xlsub_first + i] = lsub[xlsub_first + m1];
m1--;
temp[i] = temp[m1];
continue;
}
i++;
} /* for */
} /* if secondary dropping */
for (i = n; i < m; i++) temp[i] = 0.0;
if (r == 0)
{
*nnzLj += m * n;
return 0;
}
/* add dropped entries to the diagnal */
if (milu != SILU)
{
register int j;
double t;
double omega;
for (j = 0; j < n; j++)
{
t = lusup[xlusup_first + (m - 1) + j * m];
if (t == zero) continue;
if (t > zero)
omega = SUPERLU_MIN(2.0 * (1.0 - alpha) / t, 1.0);
else
omega = SUPERLU_MAX(2.0 * (1.0 - alpha) / t, -1.0);
t *= omega;
switch (milu)
{
case SMILU_1:
if (t != none) {
lusup[xlusup_first + j * inc_diag] *= (one + t);
}
else
{
lusup[xlusup_first + j * inc_diag] *= *fill_tol;
#ifdef DEBUG
printf("[1] ZERO PIVOT: FILL col %d.\n", first + j);
fflush(stdout);
#endif
nzp++;
}
break;
case SMILU_2:
lusup[xlusup_first + j * inc_diag] *= (1.0 + fabs(t));
break;
case SMILU_3:
lusup[xlusup_first + j * inc_diag] *= (one + t);
break;
case SILU:
default:
break;
}
}
if (nzp > 0) *fill_tol = -nzp;
}
/* Remove dropped entries from the memory and fix the pointers. */
m1 = m - r;
for (j = 1; j < n; j++)
{
register int tmp1, tmp2;
tmp1 = xlusup_first + j * m1;
tmp2 = xlusup_first + j * m;
for (i = 0; i < m1; i++)
lusup[i + tmp1] = lusup[i + tmp2];
}
for (i = 0; i < nzlc; i++)
lusup[xlusup_first + i + n * m1] = lusup[xlusup_first + i + n * m];
for (i = 0; i < nzlc; i++)
lsub[xlsub[last + 1] - r + i] = lsub[xlsub[last + 1] + i];
for (i = first + 1; i <= last + 1; i++)
{
xlusup[i] -= r * (i - first);
xlsub[i] -= r;
}
if (lastc)
{
xlusup[last + 2] -= r * n;
xlsub[last + 2] -= r;
}
*nnzLj += (m - r) * n;
return r;
}
|
786821.c | /*******************************************************************************
NAME PAKSZ
PURPOSE: This function converts a packed DMS angle to seconds. The
standard packed DMS format is:
degrees * 1000000 + minutes * 1000 + seconds
Example: ang = 120025045.25 yields
deg = 120
min = 25
sec = 45.25
The algorithm used for the conversion is as follows:
1. The absolute value of the angle is used.
2. The degrees are separated out:
deg = ang/1000000 (fractional portion truncated)
3. The minutes are separated out:
min = (ang - deg * 1000000) / 1000 (fractional
portion truncated)
4. The seconds are then computed:
sec = ang - deg * 1000000 - min * 1000
5. The total angle in seconds is computed:
sec = deg * 3600.0 + min * 60.0 + sec
6. The sign of sec is set to that of the input angle.
PROGRAMMER DATE
---------- ----
T. Mittan MARCH, 1993
ALGORITHM REFERENCES
1. Snyder, John P., "Map Projections--A Working Manual", U.S. Geological
Survey Proffesional Paper 1395 (Supersedes USGS Bulletin 1532), United
State Government Printing Office, Washington D.C., 1987.
2. Snyder, John P. and Voxland, Philip M., "An Album of Map Projections",
U.S. Geological Survey Professional Paper 1453 , United State Government
Printing Office, Washington D.C., 1989.
*******************************************************************************/
#include "cproj.h"
/* Convert DMS packed angle into deg
----------------------------------*/
double paksz(ang,iflg)
double ang; /* angle which in DMS */
long *iflg; /* error flag number */
{
double fac; /* sign flag */
double deg; /* degree variable */
double min; /* minute variable */
double sec; /* seconds variable */
double tmp; /* temporary variable */
long i; /* temporary variable */
*iflg = 0;
if (ang < 0.0)
fac = -1;
else
fac = 1;
/* find degrees
-------------*/
sec = fabs(ang);
tmp = 1000000.0;
i = (long) sec/tmp;
if (i > 360)
{
p_error("Illegal DMS field","paksz-deg");
*iflg = 1116;
return(ERROR);
}
else
deg = i;
/* find minutes
-------------*/
sec = sec - deg * tmp;
tmp = 1000;
i = (long) sec / tmp;
if (i > 60)
{
p_error("Illegal DMS field","paksz-min");
*iflg = 1116;
return(ERROR);
}
else
min = i;
/* find seconds
-------------*/
sec = sec - min * tmp;
if (sec > 60)
{
p_error("Illegal DMS field","paksz-sec");
*iflg = 1116;
return(ERROR);
}
else
sec = fac * (deg * 3600.0 + min * 60.0 + sec);
deg = sec / 3600.0;
return(deg);
}
|
729063.c | /*
* Copyright (C) 2010, Chris Moeller,
* All rights reserved.
* Optimizations by Gumboot
* Additional work by Burt P.
* Original code reverse engineered from HDCD decoder library by Christopher Key,
* which was likely reverse engineered from Windows Media Player.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The names of its contributors may not be used to endorse or promote
* products derived from this software without specific prior written
* permission.
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* HDCD is High Definition Compatible Digital
* http://wiki.hydrogenaud.io/index.php?title=High_Definition_Compatible_Digital
*
* More information about HDCD-encoded audio CDs:
* http://www.audiomisc.co.uk/HFN/HDCD/Enigma.html
* http://www.audiomisc.co.uk/HFN/HDCD/Examined.html
*/
/**
* @file
* HDCD decoding filter
*/
#include "libavutil/opt.h"
#include "libavutil/avassert.h"
#include "avfilter.h"
#include "internal.h"
#include "audio.h"
#define PEAK_EXT_LEVEL 0x5981 /* + sizeof(peaktab)-1 = 0x8000 */
static const uint32_t peaktab[0x2680] = {
0x2cc08300, 0x2cc10600, 0x2cc18900, 0x2cc20c00, 0x2cc28f00, 0x2cc31200, 0x2cc39500, 0x2cc41800, 0x2cc49b00, 0x2cc51e00, 0x2cc5a100, 0x2cc62400, 0x2cc6a700, 0x2cc72a00, 0x2cc7ad00, 0x2cc83000,
0x2cc8b300, 0x2cc93600, 0x2cc9b900, 0x2cca3c00, 0x2ccabf00, 0x2ccb4200, 0x2ccbc500, 0x2ccc4800, 0x2ccccb00, 0x2ccd4e00, 0x2ccdd100, 0x2cce5400, 0x2cced700, 0x2ccf5a00, 0x2ccfdd00, 0x2cd06000,
0x2cd0e300, 0x2cd16600, 0x2cd1e900, 0x2cd26c00, 0x2cd2ef00, 0x2cd37200, 0x2cd3f500, 0x2cd47800, 0x2cd4fb00, 0x2cd57e00, 0x2cd60100, 0x2cd68400, 0x2cd70700, 0x2cd78a00, 0x2cd80d00, 0x2cd89000,
0x2cd91300, 0x2cd99600, 0x2cda1900, 0x2cda9c00, 0x2cdb1f00, 0x2cdba200, 0x2cdc2500, 0x2cdca800, 0x2cdd2b00, 0x2cddae00, 0x2cde3100, 0x2cdeb400, 0x2cdf3700, 0x2cdfba00, 0x2ce03d00, 0x2ce0c000,
0x2ce14300, 0x2ce1c600, 0x2ce24900, 0x2ce2cc00, 0x2ce34f00, 0x2ce3d200, 0x2ce45500, 0x2ce4d800, 0x2ce55b00, 0x2ce5de00, 0x2ce66100, 0x2ce6e400, 0x2ce76700, 0x2ce7ea00, 0x2ce86d00, 0x2ce8f000,
0x2ce97300, 0x2ce9f600, 0x2cea7900, 0x2ceafc00, 0x2ceb7f00, 0x2cec0200, 0x2cec8500, 0x2ced0800, 0x2ced8b00, 0x2cee0e00, 0x2cee9100, 0x2cef1400, 0x2cef9700, 0x2cf01a00, 0x2cf09d00, 0x2cf12000,
0x2cf1a300, 0x2cf22600, 0x2cf2a900, 0x2cf32c00, 0x2cf3af00, 0x2cf43200, 0x2cf4b500, 0x2cf53800, 0x2cf5bb00, 0x2cf63e00, 0x2cf6c100, 0x2cf74400, 0x2cf7c700, 0x2cf84a00, 0x2cf8cd00, 0x2cf95000,
0x2cf9d300, 0x2cfa5600, 0x2cfad900, 0x2cfb5c00, 0x2cfbdf00, 0x2cfc6200, 0x2cfce500, 0x2cfd6800, 0x2cfdeb00, 0x2cfe6e00, 0x2cfef100, 0x2cff7400, 0x2cfff700, 0x2d007a00, 0x2d00fd00, 0x2d018000,
0x2d020300, 0x2d028600, 0x2d030900, 0x2d038c00, 0x2d040f00, 0x2d049200, 0x2d051500, 0x2d059800, 0x2d061b00, 0x2d069e00, 0x2d072100, 0x2d07a400, 0x2d082700, 0x2d08aa00, 0x2d092d00, 0x2d09b000,
0x2d0a3300, 0x2d0ab600, 0x2d0b3900, 0x2d0bbc00, 0x2d0c3f00, 0x2d0cc200, 0x2d0d4500, 0x2d0dc800, 0x2d0e4b00, 0x2d0ece00, 0x2d0f5100, 0x2d0fd400, 0x2d105700, 0x2d10da00, 0x2d115d00, 0x2d11e000,
0x2d126300, 0x2d12e600, 0x2d136900, 0x2d13ec00, 0x2d146f00, 0x2d14f200, 0x2d157500, 0x2d15f800, 0x2d167b00, 0x2d16fe00, 0x2d178100, 0x2d180400, 0x2d188700, 0x2d190a00, 0x2d198d00, 0x2d1a1000,
0x2d1a9300, 0x2d1b1600, 0x2d1b9900, 0x2d1c1c00, 0x2d1c9f00, 0x2d1d2200, 0x2d1da500, 0x2d1e2800, 0x2d1eab00, 0x2d1f2e00, 0x2d1fb100, 0x2d203400, 0x2d20b700, 0x2d213a00, 0x2d21bd00, 0x2d224000,
0x2d22c300, 0x2d234600, 0x2d23c900, 0x2d244c00, 0x2d24cf00, 0x2d255200, 0x2d25d500, 0x2d265800, 0x2d26db00, 0x2d275e00, 0x2d27e100, 0x2d286400, 0x2d28e700, 0x2d296a00, 0x2d29ed00, 0x2d2a7000,
0x2d2af300, 0x2d2b7600, 0x2d2bf900, 0x2d2c7c00, 0x2d2cff00, 0x2d2d8200, 0x2d2e0500, 0x2d2e8800, 0x2d2f0b00, 0x2d2f8e00, 0x2d301100, 0x2d309400, 0x2d311700, 0x2d319a00, 0x2d321d00, 0x2d32a000,
0x2d332300, 0x2d33a600, 0x2d342900, 0x2d34ac00, 0x2d352f00, 0x2d35b200, 0x2d363500, 0x2d36b800, 0x2d373b00, 0x2d37be00, 0x2d384100, 0x2d38c400, 0x2d394700, 0x2d39ca00, 0x2d3a4d00, 0x2d3ad000,
0x2d3b5300, 0x2d3bd600, 0x2d3c5900, 0x2d3cdc00, 0x2d3d5f00, 0x2d3de200, 0x2d3e6500, 0x2d3ee800, 0x2d3f6b00, 0x2d3fee00, 0x2d407100, 0x2d40f400, 0x2d417700, 0x2d41fa00, 0x2d427d00, 0x2d430000,
0x2d438300, 0x2d440600, 0x2d448900, 0x2d450c00, 0x2d458f00, 0x2d461200, 0x2d469500, 0x2d471800, 0x2d479b00, 0x2d481e00, 0x2d48a100, 0x2d492400, 0x2d49a700, 0x2d4a2a00, 0x2d4aad00, 0x2d4b3000,
0x2d4bb300, 0x2d4c3600, 0x2d4cb900, 0x2d4d3c00, 0x2d4dbf00, 0x2d4e4200, 0x2d4ec500, 0x2d4f4800, 0x2d4fcb00, 0x2d504e00, 0x2d50d100, 0x2d515400, 0x2d51d700, 0x2d525a00, 0x2d52dd00, 0x2d536000,
0x2d53e300, 0x2d546600, 0x2d54e900, 0x2d556c00, 0x2d55ef00, 0x2d567200, 0x2d56f500, 0x2d577800, 0x2d57fb00, 0x2d587e00, 0x2d590100, 0x2d598400, 0x2d5a0700, 0x2d5a8a00, 0x2d5b0d00, 0x2d5b9000,
0x2d5c1300, 0x2d5c9600, 0x2d5d1900, 0x2d5d9c00, 0x2d5e1f00, 0x2d5ea200, 0x2d5f2500, 0x2d5fa800, 0x2d602b00, 0x2d60ae00, 0x2d613100, 0x2d61b400, 0x2d623700, 0x2d62ba00, 0x2d633d00, 0x2d63c000,
0x2d644300, 0x2d64c600, 0x2d654900, 0x2d65cc00, 0x2d664f00, 0x2d66d200, 0x2d675500, 0x2d67d800, 0x2d685b00, 0x2d68de00, 0x2d696100, 0x2d69e400, 0x2d6a6700, 0x2d6aea00, 0x2d6b6d00, 0x2d6bf000,
0x2d6c7300, 0x2d6cf600, 0x2d6d7900, 0x2d6dfc00, 0x2d6e7f00, 0x2d6f0200, 0x2d6f8500, 0x2d700800, 0x2d708b00, 0x2d710e00, 0x2d719100, 0x2d721400, 0x2d729700, 0x2d731a00, 0x2d739d00, 0x2d742000,
0x2d74a300, 0x2d752600, 0x2d75a900, 0x2d762c00, 0x2d76af00, 0x2d773200, 0x2d77b500, 0x2d783800, 0x2d78bb00, 0x2d793e00, 0x2d79c100, 0x2d7a4400, 0x2d7ac700, 0x2d7b4a00, 0x2d7bcd00, 0x2d7c5000,
0x2d7cd300, 0x2d7d5600, 0x2d7dd900, 0x2d7e5c00, 0x2d7edf00, 0x2d7f6200, 0x2d7fe500, 0x2d806800, 0x2d80eb00, 0x2d816e00, 0x2d81f100, 0x2d827400, 0x2d82f700, 0x2d837a00, 0x2d83fd00, 0x2d848000,
0x2d850300, 0x2d858600, 0x2d860900, 0x2d868c00, 0x2d870f00, 0x2d879200, 0x2d881500, 0x2d889800, 0x2d891b00, 0x2d899e00, 0x2d8a2100, 0x2d8aa400, 0x2d8b2700, 0x2d8baa00, 0x2d8c2d00, 0x2d8cb000,
0x2d8d3300, 0x2d8db600, 0x2d8e3900, 0x2d8ebc00, 0x2d8f3f00, 0x2d8fc200, 0x2d904500, 0x2d90c800, 0x2d914b00, 0x2d91ce00, 0x2d925100, 0x2d92d400, 0x2d935700, 0x2d93da00, 0x2d945d00, 0x2d94e000,
0x2d956300, 0x2d95e600, 0x2d966900, 0x2d96ec00, 0x2d976f00, 0x2d97f200, 0x2d987500, 0x2d98f800, 0x2d997b00, 0x2d99fe00, 0x2d9a8100, 0x2d9b0400, 0x2d9b8700, 0x2d9c0a00, 0x2d9c8d00, 0x2d9d1000,
0x2d9d9300, 0x2d9e1600, 0x2d9e9900, 0x2d9f1c00, 0x2d9f9f00, 0x2da02200, 0x2da0a500, 0x2da12800, 0x2da1ab00, 0x2da22e00, 0x2da2b100, 0x2da33400, 0x2da3b700, 0x2da43a00, 0x2da4bd00, 0x2da54000,
0x2da5c300, 0x2da64600, 0x2da6c900, 0x2da74c00, 0x2da7cf00, 0x2da85200, 0x2da8d500, 0x2da95800, 0x2da9db00, 0x2daa5e00, 0x2daae100, 0x2dab6400, 0x2dabe700, 0x2dac6a00, 0x2daced00, 0x2dad7000,
0x2dadf300, 0x2dae7600, 0x2daef900, 0x2daf7c00, 0x2dafff00, 0x2db08200, 0x2db10500, 0x2db18800, 0x2db20b00, 0x2db28e00, 0x2db31100, 0x2db39400, 0x2db41700, 0x2db49a00, 0x2db51d00, 0x2db5a000,
0x2db62300, 0x2db6a600, 0x2db72900, 0x2db7ac00, 0x2db82f00, 0x2db8b200, 0x2db93500, 0x2db9b800, 0x2dba3b00, 0x2dbabe00, 0x2dbb4100, 0x2dbbc400, 0x2dbc4700, 0x2dbcca00, 0x2dbd4d00, 0x2dbdd000,
0x2dbe5300, 0x2dbed600, 0x2dbf5900, 0x2dbfdc00, 0x2dc05f00, 0x2dc0e200, 0x2dc16500, 0x2dc1e800, 0x2dc26b00, 0x2dc2ee00, 0x2dc37100, 0x2dc3f400, 0x2dc47700, 0x2dc4fa00, 0x2dc57d00, 0x2dc60000,
0x2dc68700, 0x2dc70e00, 0x2dc79500, 0x2dc81c00, 0x2dc8a300, 0x2dc92a00, 0x2dc9b100, 0x2dca3800, 0x2dcabf00, 0x2dcb4600, 0x2dcbcd00, 0x2dcc5400, 0x2dccdb00, 0x2dcd6200, 0x2dcde900, 0x2dce7000,
0x2dcef700, 0x2dcf7e00, 0x2dd00500, 0x2dd08c00, 0x2dd11300, 0x2dd19a00, 0x2dd22100, 0x2dd2a800, 0x2dd32f00, 0x2dd3b600, 0x2dd43d00, 0x2dd4c400, 0x2dd54b00, 0x2dd5d200, 0x2dd65900, 0x2dd6e000,
0x2dd76700, 0x2dd7ee00, 0x2dd87500, 0x2dd8fc00, 0x2dd98300, 0x2dda0a00, 0x2dda9100, 0x2ddb1800, 0x2ddb9f00, 0x2ddc2600, 0x2ddcad00, 0x2ddd3400, 0x2dddbb00, 0x2dde4200, 0x2ddec900, 0x2ddf5000,
0x2ddfd700, 0x2de05e00, 0x2de0e500, 0x2de16c00, 0x2de1f300, 0x2de27a00, 0x2de30100, 0x2de38800, 0x2de40f00, 0x2de49600, 0x2de51d00, 0x2de5a400, 0x2de62b00, 0x2de6b200, 0x2de73900, 0x2de7c000,
0x2de84700, 0x2de8ce00, 0x2de95500, 0x2de9dc00, 0x2dea6300, 0x2deaea00, 0x2deb7100, 0x2debf800, 0x2dec7f00, 0x2ded0600, 0x2ded8d00, 0x2dee1400, 0x2dee9b00, 0x2def2200, 0x2defa900, 0x2df03000,
0x2df0b700, 0x2df13e00, 0x2df1c500, 0x2df24c00, 0x2df2d300, 0x2df35a00, 0x2df3e100, 0x2df46800, 0x2df4ef00, 0x2df57600, 0x2df5fd00, 0x2df68400, 0x2df70b00, 0x2df79200, 0x2df81900, 0x2df8a000,
0x2df92700, 0x2df9ae00, 0x2dfa3500, 0x2dfabc00, 0x2dfb4300, 0x2dfbca00, 0x2dfc5100, 0x2dfcd800, 0x2dfd5f00, 0x2dfde600, 0x2dfe6d00, 0x2dfef400, 0x2dff7b00, 0x2e000200, 0x2e008900, 0x2e011000,
0x2e019700, 0x2e021e00, 0x2e02a500, 0x2e032c00, 0x2e03b300, 0x2e043a00, 0x2e04c100, 0x2e054800, 0x2e05cf00, 0x2e065600, 0x2e06dd00, 0x2e076400, 0x2e07eb00, 0x2e087200, 0x2e08f900, 0x2e098000,
0x2e0a0700, 0x2e0a8e00, 0x2e0b1500, 0x2e0b9c00, 0x2e0c2300, 0x2e0caa00, 0x2e0d3100, 0x2e0db800, 0x2e0e3f00, 0x2e0ec600, 0x2e0f4d00, 0x2e0fd400, 0x2e105b00, 0x2e10e200, 0x2e116900, 0x2e11f000,
0x2e127700, 0x2e12fe00, 0x2e138500, 0x2e140c00, 0x2e149300, 0x2e151a00, 0x2e15a100, 0x2e162800, 0x2e16af00, 0x2e173600, 0x2e17bd00, 0x2e184400, 0x2e18cb00, 0x2e195200, 0x2e19d900, 0x2e1a6000,
0x2e1ae700, 0x2e1b6e00, 0x2e1bf500, 0x2e1c7c00, 0x2e1d0300, 0x2e1d8a00, 0x2e1e1100, 0x2e1e9800, 0x2e1f1f00, 0x2e1fa600, 0x2e202d00, 0x2e20b400, 0x2e213b00, 0x2e21c200, 0x2e224900, 0x2e22d000,
0x2e235700, 0x2e23de00, 0x2e246500, 0x2e24ec00, 0x2e257300, 0x2e25fa00, 0x2e268100, 0x2e270800, 0x2e278f00, 0x2e281600, 0x2e289d00, 0x2e292400, 0x2e29ab00, 0x2e2a3200, 0x2e2ab900, 0x2e2b4000,
0x2e2bc700, 0x2e2c4e00, 0x2e2cd500, 0x2e2d5c00, 0x2e2de300, 0x2e2e6a00, 0x2e2ef100, 0x2e2f7800, 0x2e2fff00, 0x2e308600, 0x2e310d00, 0x2e319400, 0x2e321b00, 0x2e32a200, 0x2e332900, 0x2e33b000,
0x2e343700, 0x2e34be00, 0x2e354500, 0x2e35cc00, 0x2e365300, 0x2e36da00, 0x2e376100, 0x2e37e800, 0x2e386f00, 0x2e38f600, 0x2e397d00, 0x2e3a0400, 0x2e3a8b00, 0x2e3b1200, 0x2e3b9900, 0x2e3c2000,
0x2e3ca700, 0x2e3d2e00, 0x2e3db500, 0x2e3e3c00, 0x2e3ec300, 0x2e3f4a00, 0x2e3fd100, 0x2e405800, 0x2e40df00, 0x2e416600, 0x2e41ed00, 0x2e427400, 0x2e42fb00, 0x2e438200, 0x2e440900, 0x2e449000,
0x2e451700, 0x2e459e00, 0x2e462500, 0x2e46ac00, 0x2e473300, 0x2e47ba00, 0x2e484100, 0x2e48c800, 0x2e494f00, 0x2e49d600, 0x2e4a5d00, 0x2e4ae400, 0x2e4b6b00, 0x2e4bf200, 0x2e4c7900, 0x2e4d0000,
0x2e4d8700, 0x2e4e0e00, 0x2e4e9500, 0x2e4f1c00, 0x2e4fa300, 0x2e502a00, 0x2e50b100, 0x2e513800, 0x2e51bf00, 0x2e524600, 0x2e52cd00, 0x2e535400, 0x2e53db00, 0x2e546200, 0x2e54e900, 0x2e557000,
0x2e55f700, 0x2e567e00, 0x2e570500, 0x2e578c00, 0x2e581300, 0x2e589a00, 0x2e592100, 0x2e59a800, 0x2e5a2f00, 0x2e5ab600, 0x2e5b3d00, 0x2e5bc400, 0x2e5c4b00, 0x2e5cd200, 0x2e5d5900, 0x2e5de000,
0x2e5e6700, 0x2e5eee00, 0x2e5f7500, 0x2e5ffc00, 0x2e608300, 0x2e610a00, 0x2e619100, 0x2e621800, 0x2e629f00, 0x2e632600, 0x2e63ad00, 0x2e643400, 0x2e64bb00, 0x2e654200, 0x2e65c900, 0x2e665000,
0x2e66d700, 0x2e675e00, 0x2e67e500, 0x2e686c00, 0x2e68f300, 0x2e697a00, 0x2e6a0100, 0x2e6a8800, 0x2e6b0f00, 0x2e6b9600, 0x2e6c1d00, 0x2e6ca400, 0x2e6d2b00, 0x2e6db200, 0x2e6e3900, 0x2e6ec000,
0x2e6f4700, 0x2e6fce00, 0x2e705500, 0x2e70dc00, 0x2e716300, 0x2e71ea00, 0x2e727100, 0x2e72f800, 0x2e737f00, 0x2e740600, 0x2e748d00, 0x2e751400, 0x2e759b00, 0x2e762200, 0x2e76a900, 0x2e773000,
0x2e77b700, 0x2e783e00, 0x2e78c500, 0x2e794c00, 0x2e79d300, 0x2e7a5a00, 0x2e7ae100, 0x2e7b6800, 0x2e7bef00, 0x2e7c7600, 0x2e7cfd00, 0x2e7d8400, 0x2e7e0b00, 0x2e7e9200, 0x2e7f1900, 0x2e7fa000,
0x2e802700, 0x2e80ae00, 0x2e813500, 0x2e81bc00, 0x2e824300, 0x2e82ca00, 0x2e835100, 0x2e83d800, 0x2e845f00, 0x2e84e600, 0x2e856d00, 0x2e85f400, 0x2e867b00, 0x2e870200, 0x2e878900, 0x2e881000,
0x2e889700, 0x2e891e00, 0x2e89a500, 0x2e8a2c00, 0x2e8ab300, 0x2e8b3a00, 0x2e8bc100, 0x2e8c4800, 0x2e8ccf00, 0x2e8d5600, 0x2e8ddd00, 0x2e8e6400, 0x2e8eeb00, 0x2e8f7200, 0x2e8ff900, 0x2e908000,
0x2e910700, 0x2e918e00, 0x2e921500, 0x2e929c00, 0x2e932300, 0x2e93aa00, 0x2e943100, 0x2e94b800, 0x2e953f00, 0x2e95c600, 0x2e964d00, 0x2e96d400, 0x2e975b00, 0x2e97e200, 0x2e986900, 0x2e98f000,
0x2e997700, 0x2e99fe00, 0x2e9a8500, 0x2e9b0c00, 0x2e9b9300, 0x2e9c1a00, 0x2e9ca100, 0x2e9d2800, 0x2e9daf00, 0x2e9e3600, 0x2e9ebd00, 0x2e9f4400, 0x2e9fcb00, 0x2ea05200, 0x2ea0d900, 0x2ea16000,
0x2ea1e700, 0x2ea26e00, 0x2ea2f500, 0x2ea37c00, 0x2ea40300, 0x2ea48a00, 0x2ea51100, 0x2ea59800, 0x2ea61f00, 0x2ea6a600, 0x2ea72d00, 0x2ea7b400, 0x2ea83b00, 0x2ea8c200, 0x2ea94900, 0x2ea9d000,
0x2eaa5700, 0x2eaade00, 0x2eab6500, 0x2eabec00, 0x2eac7300, 0x2eacfa00, 0x2ead8100, 0x2eae0800, 0x2eae8f00, 0x2eaf1600, 0x2eaf9d00, 0x2eb02400, 0x2eb0ab00, 0x2eb13200, 0x2eb1b900, 0x2eb24000,
0x2eb2c700, 0x2eb34e00, 0x2eb3d500, 0x2eb45c00, 0x2eb4e300, 0x2eb56a00, 0x2eb5f100, 0x2eb67800, 0x2eb6ff00, 0x2eb78600, 0x2eb80d00, 0x2eb89400, 0x2eb91b00, 0x2eb9a200, 0x2eba2900, 0x2ebab000,
0x2ebb3700, 0x2ebbbe00, 0x2ebc4500, 0x2ebccc00, 0x2ebd5300, 0x2ebdda00, 0x2ebe6100, 0x2ebee800, 0x2ebf6f00, 0x2ebff600, 0x2ec07d00, 0x2ec10400, 0x2ec18b00, 0x2ec21200, 0x2ec29900, 0x2ec32000,
0x2ec3a700, 0x2ec42e00, 0x2ec4b500, 0x2ec53c00, 0x2ec5c300, 0x2ec64a00, 0x2ec6d100, 0x2ec75800, 0x2ec7df00, 0x2ec86600, 0x2ec8ed00, 0x2ec97400, 0x2ec9fb00, 0x2eca8200, 0x2ecb0900, 0x2ecb9000,
0x2ecc1700, 0x2ecc9e00, 0x2ecd2500, 0x2ecdac00, 0x2ece3300, 0x2eceba00, 0x2ecf4100, 0x2ecfc800, 0x2ed04f00, 0x2ed0d600, 0x2ed15d00, 0x2ed1e400, 0x2ed26b00, 0x2ed2f200, 0x2ed37900, 0x2ed40000,
0x2ed48700, 0x2ed50e00, 0x2ed59500, 0x2ed61c00, 0x2ed6a300, 0x2ed72a00, 0x2ed7b100, 0x2ed83800, 0x2ed8bf00, 0x2ed94600, 0x2ed9cd00, 0x2eda5400, 0x2edadb00, 0x2edb6200, 0x2edbe900, 0x2edc7000,
0x2edcf700, 0x2edd7e00, 0x2ede0500, 0x2ede8c00, 0x2edf1300, 0x2edf9a00, 0x2ee02100, 0x2ee0a800, 0x2ee12f00, 0x2ee1b600, 0x2ee23d00, 0x2ee2c400, 0x2ee34b00, 0x2ee3d200, 0x2ee45900, 0x2ee4e000,
0x2ee56700, 0x2ee5ee00, 0x2ee67500, 0x2ee6fc00, 0x2ee78300, 0x2ee80a00, 0x2ee89100, 0x2ee91800, 0x2ee99f00, 0x2eea2600, 0x2eeaad00, 0x2eeb3400, 0x2eebbb00, 0x2eec4200, 0x2eecc900, 0x2eed5000,
0x2eedd700, 0x2eee5e00, 0x2eeee500, 0x2eef6c00, 0x2eeff300, 0x2ef07a00, 0x2ef10100, 0x2ef18800, 0x2ef20f00, 0x2ef29600, 0x2ef31d00, 0x2ef3a400, 0x2ef42b00, 0x2ef4b200, 0x2ef53900, 0x2ef5c000,
0x2ef64700, 0x2ef6ce00, 0x2ef75500, 0x2ef7dc00, 0x2ef86300, 0x2ef8ea00, 0x2ef97100, 0x2ef9f800, 0x2efa7f00, 0x2efb0600, 0x2efb8d00, 0x2efc1400, 0x2efc9b00, 0x2efd2200, 0x2efda900, 0x2efe3000,
0x2efeb700, 0x2eff3e00, 0x2effc500, 0x2f004c00, 0x2f00d300, 0x2f015a00, 0x2f01e100, 0x2f026800, 0x2f02ef00, 0x2f037600, 0x2f03fd00, 0x2f048400, 0x2f050b00, 0x2f059200, 0x2f061900, 0x2f06a000,
0x2f072700, 0x2f07ae00, 0x2f083500, 0x2f08bc00, 0x2f094300, 0x2f09ca00, 0x2f0a5100, 0x2f0ad800, 0x2f0b5f00, 0x2f0be600, 0x2f0c6d00, 0x2f0cf400, 0x2f0d7b00, 0x2f0e0200, 0x2f0e8900, 0x2f0f1000,
0x2f0f9700, 0x2f101e00, 0x2f10a500, 0x2f112c00, 0x2f11b300, 0x2f123a00, 0x2f12c100, 0x2f134800, 0x2f13cf00, 0x2f145600, 0x2f14dd00, 0x2f156400, 0x2f15eb00, 0x2f167200, 0x2f16f900, 0x2f178000,
0x2f180700, 0x2f188e00, 0x2f191500, 0x2f199c00, 0x2f1a2300, 0x2f1aaa00, 0x2f1b3100, 0x2f1bb800, 0x2f1c3f00, 0x2f1cc600, 0x2f1d4d00, 0x2f1dd400, 0x2f1e5b00, 0x2f1ee200, 0x2f1f6900, 0x2f1ff000,
0x2f207700, 0x2f20fe00, 0x2f218500, 0x2f220c00, 0x2f229300, 0x2f231a00, 0x2f23a100, 0x2f242800, 0x2f24af00, 0x2f253600, 0x2f25bd00, 0x2f264400, 0x2f26cb00, 0x2f275200, 0x2f27d900, 0x2f286000,
0x2f28e700, 0x2f296e00, 0x2f29f500, 0x2f2a7c00, 0x2f2b0300, 0x2f2b8a00, 0x2f2c1100, 0x2f2c9800, 0x2f2d1f00, 0x2f2da600, 0x2f2e2d00, 0x2f2eb400, 0x2f2f3b00, 0x2f2fc200, 0x2f304900, 0x2f30d000,
0x2f315700, 0x2f31de00, 0x2f326500, 0x2f32ec00, 0x2f337300, 0x2f33fa00, 0x2f348100, 0x2f350800, 0x2f358f00, 0x2f361600, 0x2f369d00, 0x2f372400, 0x2f37ab00, 0x2f383200, 0x2f38b900, 0x2f394000,
0x2f39c700, 0x2f3a4e00, 0x2f3ad500, 0x2f3b5c00, 0x2f3be300, 0x2f3c6a00, 0x2f3cf100, 0x2f3d7800, 0x2f3dff00, 0x2f3e8600, 0x2f3f0d00, 0x2f3f9400, 0x2f401b00, 0x2f40a200, 0x2f412900, 0x2f41b000,
0x2f423700, 0x2f42be00, 0x2f434500, 0x2f43cc00, 0x2f445300, 0x2f44da00, 0x2f456100, 0x2f45e800, 0x2f466f00, 0x2f46f600, 0x2f477d00, 0x2f480400, 0x2f488b00, 0x2f491200, 0x2f499900, 0x2f4a2000,
0x2f4aa700, 0x2f4b2e00, 0x2f4bb500, 0x2f4c3c00, 0x2f4cc300, 0x2f4d4a00, 0x2f4dd100, 0x2f4e5800, 0x2f4edf00, 0x2f4f6600, 0x2f4fed00, 0x2f507400, 0x2f50fb00, 0x2f518200, 0x2f520900, 0x2f529000,
0x2f531700, 0x2f539e00, 0x2f542500, 0x2f54ac00, 0x2f553300, 0x2f55ba00, 0x2f564100, 0x2f56c800, 0x2f574f00, 0x2f57d600, 0x2f585d00, 0x2f58e400, 0x2f596b00, 0x2f59f200, 0x2f5a7900, 0x2f5b0000,
0x2f5b8700, 0x2f5c0e00, 0x2f5c9500, 0x2f5d1c00, 0x2f5da300, 0x2f5e2a00, 0x2f5eb100, 0x2f5f3800, 0x2f5fbf00, 0x2f604600, 0x2f60cd00, 0x2f615400, 0x2f61db00, 0x2f626200, 0x2f62e900, 0x2f637000,
0x2f63f700, 0x2f647e00, 0x2f650500, 0x2f658c00, 0x2f661300, 0x2f669a00, 0x2f672100, 0x2f67a800, 0x2f682f00, 0x2f68b600, 0x2f693d00, 0x2f69c400, 0x2f6a4b00, 0x2f6ad200, 0x2f6b5900, 0x2f6be000,
0x2f6c6700, 0x2f6cee00, 0x2f6d7500, 0x2f6dfc00, 0x2f6e8300, 0x2f6f0a00, 0x2f6f9100, 0x2f701800, 0x2f709f00, 0x2f712600, 0x2f71ad00, 0x2f723400, 0x2f72bb00, 0x2f734200, 0x2f73c900, 0x2f745000,
0x2f74d700, 0x2f755e00, 0x2f75e500, 0x2f766c00, 0x2f76f300, 0x2f777a00, 0x2f780100, 0x2f788800, 0x2f790f00, 0x2f799600, 0x2f7a1d00, 0x2f7aa400, 0x2f7b2b00, 0x2f7bb200, 0x2f7c3900, 0x2f7cc000,
0x2f7d4700, 0x2f7dce00, 0x2f7e5500, 0x2f7edc00, 0x2f7f6300, 0x2f7fea00, 0x2f807100, 0x2f80f800, 0x2f817f00, 0x2f820600, 0x2f828d00, 0x2f831400, 0x2f839b00, 0x2f842200, 0x2f84a900, 0x2f853000,
0x2f85b700, 0x2f863e00, 0x2f86c500, 0x2f874c00, 0x2f87d300, 0x2f885a00, 0x2f88e100, 0x2f896800, 0x2f89ef00, 0x2f8a7600, 0x2f8afd00, 0x2f8b8400, 0x2f8c0b00, 0x2f8c9200, 0x2f8d1900, 0x2f8da000,
0x2f8e2700, 0x2f8eae00, 0x2f8f3500, 0x2f8fbc00, 0x2f904300, 0x2f90ca00, 0x2f915100, 0x2f91d800, 0x2f925f00, 0x2f92e600, 0x2f936d00, 0x2f93f400, 0x2f947b00, 0x2f950200, 0x2f958900, 0x2f961000,
0x2f969700, 0x2f971e00, 0x2f97a500, 0x2f982c00, 0x2f98b300, 0x2f993a00, 0x2f99c100, 0x2f9a4800, 0x2f9acf00, 0x2f9b5600, 0x2f9bdd00, 0x2f9c6400, 0x2f9ceb00, 0x2f9d7200, 0x2f9df900, 0x2f9e8000,
0x2f9f0700, 0x2f9f8e00, 0x2fa01500, 0x2fa09c00, 0x2fa12300, 0x2fa1aa00, 0x2fa23100, 0x2fa2b800, 0x2fa33f00, 0x2fa3c600, 0x2fa44d00, 0x2fa4d400, 0x2fa55b00, 0x2fa5e200, 0x2fa66900, 0x2fa6f000,
0x2fa77700, 0x2fa7fe00, 0x2fa88500, 0x2fa90c00, 0x2fa99300, 0x2faa1a00, 0x2faaa100, 0x2fab2800, 0x2fabaf00, 0x2fac3600, 0x2facbd00, 0x2fad4400, 0x2fadcb00, 0x2fae5200, 0x2faed900, 0x2faf6000,
0x2fafe700, 0x2fb06e00, 0x2fb0f500, 0x2fb17c00, 0x2fb20300, 0x2fb28a00, 0x2fb31100, 0x2fb39800, 0x2fb41f00, 0x2fb4a600, 0x2fb52d00, 0x2fb5b400, 0x2fb63b00, 0x2fb6c200, 0x2fb74900, 0x2fb7d000,
0x2fb85700, 0x2fb8de00, 0x2fb96500, 0x2fb9ec00, 0x2fba7300, 0x2fbafa00, 0x2fbb8100, 0x2fbc0800, 0x2fbc8f00, 0x2fbd1600, 0x2fbd9d00, 0x2fbe2400, 0x2fbeab00, 0x2fbf3200, 0x2fbfb900, 0x2fc04000,
0x2fc0c700, 0x2fc14e00, 0x2fc1d500, 0x2fc25c00, 0x2fc2e300, 0x2fc36a00, 0x2fc3f100, 0x2fc47800, 0x2fc4ff00, 0x2fc58600, 0x2fc60d00, 0x2fc69400, 0x2fc71b00, 0x2fc7a200, 0x2fc82900, 0x2fc8b000,
0x2fc93700, 0x2fc9be00, 0x2fca4500, 0x2fcacc00, 0x2fcb5300, 0x2fcbda00, 0x2fcc6100, 0x2fcce800, 0x2fcd6f00, 0x2fcdf600, 0x2fce7d00, 0x2fcf0400, 0x2fcf8b00, 0x2fd01200, 0x2fd09900, 0x2fd12000,
0x2fd1a700, 0x2fd22e00, 0x2fd2b500, 0x2fd33c00, 0x2fd3c300, 0x2fd44a00, 0x2fd4d100, 0x2fd55800, 0x2fd5df00, 0x2fd66600, 0x2fd6ed00, 0x2fd77400, 0x2fd7fb00, 0x2fd88200, 0x2fd90900, 0x2fd99000,
0x2fda1700, 0x2fda9e00, 0x2fdb2500, 0x2fdbac00, 0x2fdc3300, 0x2fdcba00, 0x2fdd4100, 0x2fddc800, 0x2fde4f00, 0x2fded600, 0x2fdf5d00, 0x2fdfe400, 0x2fe06b00, 0x2fe0f200, 0x2fe17900, 0x2fe20000,
0x2fe29600, 0x2fe32c00, 0x2fe3c200, 0x2fe45800, 0x2fe4ee00, 0x2fe58400, 0x2fe61a00, 0x2fe6b000, 0x2fe74600, 0x2fe7dc00, 0x2fe87200, 0x2fe90800, 0x2fe99e00, 0x2fea3400, 0x2feaca00, 0x2feb6000,
0x2febf600, 0x2fec8c00, 0x2fed2200, 0x2fedb800, 0x2fee4e00, 0x2feee400, 0x2fef7a00, 0x2ff01000, 0x2ff0a600, 0x2ff13c00, 0x2ff1d200, 0x2ff26800, 0x2ff2fe00, 0x2ff39400, 0x2ff42a00, 0x2ff4c000,
0x2ff55600, 0x2ff5ec00, 0x2ff68200, 0x2ff71800, 0x2ff7ae00, 0x2ff84400, 0x2ff8da00, 0x2ff97000, 0x2ffa0600, 0x2ffa9c00, 0x2ffb3200, 0x2ffbc800, 0x2ffc5e00, 0x2ffcf400, 0x2ffd8a00, 0x2ffe2000,
0x2ffeb600, 0x2fff4c00, 0x2fffe200, 0x30007800, 0x30010e00, 0x3001a400, 0x30023a00, 0x3002d000, 0x30036600, 0x3003fc00, 0x30049200, 0x30052800, 0x3005be00, 0x30065400, 0x3006ea00, 0x30078000,
0x30081600, 0x3008ac00, 0x30094200, 0x3009d800, 0x300a6e00, 0x300b0400, 0x300b9a00, 0x300c3000, 0x300cc600, 0x300d5c00, 0x300df200, 0x300e8800, 0x300f1e00, 0x300fb400, 0x30104a00, 0x3010e000,
0x30117600, 0x30120c00, 0x3012a200, 0x30133800, 0x3013ce00, 0x30146400, 0x3014fa00, 0x30159000, 0x30162600, 0x3016bc00, 0x30175200, 0x3017e800, 0x30187e00, 0x30191400, 0x3019aa00, 0x301a4000,
0x301ad600, 0x301b6c00, 0x301c0200, 0x301c9800, 0x301d2e00, 0x301dc400, 0x301e5a00, 0x301ef000, 0x301f8600, 0x30201c00, 0x3020b200, 0x30214800, 0x3021de00, 0x30227400, 0x30230a00, 0x3023a000,
0x30243600, 0x3024cc00, 0x30256200, 0x3025f800, 0x30268e00, 0x30272400, 0x3027ba00, 0x30285000, 0x3028e600, 0x30297c00, 0x302a1200, 0x302aa800, 0x302b3e00, 0x302bd400, 0x302c6a00, 0x302d0000,
0x302d9600, 0x302e2c00, 0x302ec200, 0x302f5800, 0x302fee00, 0x30308400, 0x30311a00, 0x3031b000, 0x30324600, 0x3032dc00, 0x30337200, 0x30340800, 0x30349e00, 0x30353400, 0x3035ca00, 0x30366000,
0x3036f600, 0x30378c00, 0x30382200, 0x3038b800, 0x30394e00, 0x3039e400, 0x303a7a00, 0x303b1000, 0x303ba600, 0x303c3c00, 0x303cd200, 0x303d6800, 0x303dfe00, 0x303e9400, 0x303f2a00, 0x303fc000,
0x30405600, 0x3040ec00, 0x30418200, 0x30421800, 0x3042ae00, 0x30434400, 0x3043da00, 0x30447000, 0x30450600, 0x30459c00, 0x30463200, 0x3046c800, 0x30475e00, 0x3047f400, 0x30488a00, 0x30492000,
0x3049b600, 0x304a4c00, 0x304ae200, 0x304b7800, 0x304c0e00, 0x304ca400, 0x304d3a00, 0x304dd000, 0x304e6600, 0x304efc00, 0x304f9200, 0x30502800, 0x3050be00, 0x30515400, 0x3051ea00, 0x30528000,
0x30531600, 0x3053ac00, 0x30544200, 0x3054d800, 0x30556e00, 0x30560400, 0x30569a00, 0x30573000, 0x3057c600, 0x30585c00, 0x3058f200, 0x30598800, 0x305a1e00, 0x305ab400, 0x305b4a00, 0x305be000,
0x305c7600, 0x305d0c00, 0x305da200, 0x305e3800, 0x305ece00, 0x305f6400, 0x305ffa00, 0x30609000, 0x30612600, 0x3061bc00, 0x30625200, 0x3062e800, 0x30637e00, 0x30641400, 0x3064aa00, 0x30654000,
0x3065d600, 0x30666c00, 0x30670200, 0x30679800, 0x30682e00, 0x3068c400, 0x30695a00, 0x3069f000, 0x306a8600, 0x306b1c00, 0x306bb200, 0x306c4800, 0x306cde00, 0x306d7400, 0x306e0a00, 0x306ea000,
0x306f3600, 0x306fcc00, 0x30706200, 0x3070f800, 0x30718e00, 0x30722400, 0x3072ba00, 0x30735000, 0x3073e600, 0x30747c00, 0x30751200, 0x3075a800, 0x30763e00, 0x3076d400, 0x30776a00, 0x30780000,
0x30789600, 0x30792c00, 0x3079c200, 0x307a5800, 0x307aee00, 0x307b8400, 0x307c1a00, 0x307cb000, 0x307d4600, 0x307ddc00, 0x307e7200, 0x307f0800, 0x307f9e00, 0x30803400, 0x3080ca00, 0x30816000,
0x3081f600, 0x30828c00, 0x30832200, 0x3083b800, 0x30844e00, 0x3084e400, 0x30857a00, 0x30861000, 0x3086a600, 0x30873c00, 0x3087d200, 0x30886800, 0x3088fe00, 0x30899400, 0x308a2a00, 0x308ac000,
0x308b5600, 0x308bec00, 0x308c8200, 0x308d1800, 0x308dae00, 0x308e4400, 0x308eda00, 0x308f7000, 0x30900600, 0x30909c00, 0x30913200, 0x3091c800, 0x30925e00, 0x3092f400, 0x30938a00, 0x30942000,
0x3094b600, 0x30954c00, 0x3095e200, 0x30967800, 0x30970e00, 0x3097a400, 0x30983a00, 0x3098d000, 0x30996600, 0x3099fc00, 0x309a9200, 0x309b2800, 0x309bbe00, 0x309c5400, 0x309cea00, 0x309d8000,
0x309e1600, 0x309eac00, 0x309f4200, 0x309fd800, 0x30a06e00, 0x30a10400, 0x30a19a00, 0x30a23000, 0x30a2c600, 0x30a35c00, 0x30a3f200, 0x30a48800, 0x30a51e00, 0x30a5b400, 0x30a64a00, 0x30a6e000,
0x30a77600, 0x30a80c00, 0x30a8a200, 0x30a93800, 0x30a9ce00, 0x30aa6400, 0x30aafa00, 0x30ab9000, 0x30ac2600, 0x30acbc00, 0x30ad5200, 0x30ade800, 0x30ae7e00, 0x30af1400, 0x30afaa00, 0x30b04000,
0x30b0d600, 0x30b16c00, 0x30b20200, 0x30b29800, 0x30b32e00, 0x30b3c400, 0x30b45a00, 0x30b4f000, 0x30b58600, 0x30b61c00, 0x30b6b200, 0x30b74800, 0x30b7de00, 0x30b87400, 0x30b90a00, 0x30b9a000,
0x30ba3600, 0x30bacc00, 0x30bb6200, 0x30bbf800, 0x30bc8e00, 0x30bd2400, 0x30bdba00, 0x30be5000, 0x30bee600, 0x30bf7c00, 0x30c01200, 0x30c0a800, 0x30c13e00, 0x30c1d400, 0x30c26a00, 0x30c30000,
0x30c39600, 0x30c42c00, 0x30c4c200, 0x30c55800, 0x30c5ee00, 0x30c68400, 0x30c71a00, 0x30c7b000, 0x30c84600, 0x30c8dc00, 0x30c97200, 0x30ca0800, 0x30ca9e00, 0x30cb3400, 0x30cbca00, 0x30cc6000,
0x30ccf600, 0x30cd8c00, 0x30ce2200, 0x30ceb800, 0x30cf4e00, 0x30cfe400, 0x30d07a00, 0x30d11000, 0x30d1a600, 0x30d23c00, 0x30d2d200, 0x30d36800, 0x30d3fe00, 0x30d49400, 0x30d52a00, 0x30d5c000,
0x30d65600, 0x30d6ec00, 0x30d78200, 0x30d81800, 0x30d8ae00, 0x30d94400, 0x30d9da00, 0x30da7000, 0x30db0600, 0x30db9c00, 0x30dc3200, 0x30dcc800, 0x30dd5e00, 0x30ddf400, 0x30de8a00, 0x30df2000,
0x30dfb600, 0x30e04c00, 0x30e0e200, 0x30e17800, 0x30e20e00, 0x30e2a400, 0x30e33a00, 0x30e3d000, 0x30e46600, 0x30e4fc00, 0x30e59200, 0x30e62800, 0x30e6be00, 0x30e75400, 0x30e7ea00, 0x30e88000,
0x30e91600, 0x30e9ac00, 0x30ea4200, 0x30ead800, 0x30eb6e00, 0x30ec0400, 0x30ec9a00, 0x30ed3000, 0x30edc600, 0x30ee5c00, 0x30eef200, 0x30ef8800, 0x30f01e00, 0x30f0b400, 0x30f14a00, 0x30f1e000,
0x30f27600, 0x30f30c00, 0x30f3a200, 0x30f43800, 0x30f4ce00, 0x30f56400, 0x30f5fa00, 0x30f69000, 0x30f72600, 0x30f7bc00, 0x30f85200, 0x30f8e800, 0x30f97e00, 0x30fa1400, 0x30faaa00, 0x30fb4000,
0x30fbd600, 0x30fc6c00, 0x30fd0200, 0x30fd9800, 0x30fe2e00, 0x30fec400, 0x30ff5a00, 0x30fff000, 0x31008600, 0x31011c00, 0x3101b200, 0x31024800, 0x3102de00, 0x31037400, 0x31040a00, 0x3104a000,
0x31053600, 0x3105cc00, 0x31066200, 0x3106f800, 0x31078e00, 0x31082400, 0x3108ba00, 0x31095000, 0x3109e600, 0x310a7c00, 0x310b1200, 0x310ba800, 0x310c3e00, 0x310cd400, 0x310d6a00, 0x310e0000,
0x310e9600, 0x310f2c00, 0x310fc200, 0x31105800, 0x3110ee00, 0x31118400, 0x31121a00, 0x3112b000, 0x31134600, 0x3113dc00, 0x31147200, 0x31150800, 0x31159e00, 0x31163400, 0x3116ca00, 0x31176000,
0x3117f600, 0x31188c00, 0x31192200, 0x3119b800, 0x311a4e00, 0x311ae400, 0x311b7a00, 0x311c1000, 0x311ca600, 0x311d3c00, 0x311dd200, 0x311e6800, 0x311efe00, 0x311f9400, 0x31202a00, 0x3120c000,
0x31215600, 0x3121ec00, 0x31228200, 0x31231800, 0x3123ae00, 0x31244400, 0x3124da00, 0x31257000, 0x31260600, 0x31269c00, 0x31273200, 0x3127c800, 0x31285e00, 0x3128f400, 0x31298a00, 0x312a2000,
0x312ab600, 0x312b4c00, 0x312be200, 0x312c7800, 0x312d0e00, 0x312da400, 0x312e3a00, 0x312ed000, 0x312f6600, 0x312ffc00, 0x31309200, 0x31312800, 0x3131be00, 0x31325400, 0x3132ea00, 0x31338000,
0x31341600, 0x3134ac00, 0x31354200, 0x3135d800, 0x31366e00, 0x31370400, 0x31379a00, 0x31383000, 0x3138c600, 0x31395c00, 0x3139f200, 0x313a8800, 0x313b1e00, 0x313bb400, 0x313c4a00, 0x313ce000,
0x313d7600, 0x313e0c00, 0x313ea200, 0x313f3800, 0x313fce00, 0x31406300, 0x3140f900, 0x31418f00, 0x31422500, 0x3142bb00, 0x31435100, 0x3143e700, 0x31447d00, 0x31451300, 0x3145a900, 0x31463f00,
0x3146d500, 0x31476b00, 0x31480100, 0x31489700, 0x31492d00, 0x3149c300, 0x314a5900, 0x314aef00, 0x314b8500, 0x314c1b00, 0x314cb100, 0x314d4700, 0x314ddd00, 0x314e7300, 0x314f0900, 0x314f9f00,
0x31503500, 0x3150cb00, 0x31516100, 0x3151f700, 0x31528d00, 0x31532300, 0x3153b900, 0x31544f00, 0x3154e500, 0x31557b00, 0x31561100, 0x3156a700, 0x31573d00, 0x3157d300, 0x31586900, 0x3158ff00,
0x31599500, 0x315a2b00, 0x315ac100, 0x315b5700, 0x315bed00, 0x315c8300, 0x315d1900, 0x315daf00, 0x315e4500, 0x315edb00, 0x315f7100, 0x31600700, 0x31609d00, 0x31613300, 0x3161c900, 0x31625f00,
0x3162f500, 0x31638b00, 0x31642100, 0x3164b700, 0x31654d00, 0x3165e300, 0x31667900, 0x31670f00, 0x3167a500, 0x31683b00, 0x3168d100, 0x31696700, 0x3169fd00, 0x316a9300, 0x316b2900, 0x316bbf00,
0x316c5500, 0x316ceb00, 0x316d8100, 0x316e1700, 0x316ead00, 0x316f4300, 0x316fd900, 0x31706f00, 0x31710500, 0x31719b00, 0x31723100, 0x3172c700, 0x31735d00, 0x3173f300, 0x31748900, 0x31751f00,
0x3175b500, 0x31764b00, 0x3176e100, 0x31777700, 0x31780d00, 0x3178a300, 0x31793900, 0x3179cf00, 0x317a6500, 0x317afb00, 0x317b9100, 0x317c2700, 0x317cbd00, 0x317d5300, 0x317de900, 0x317e7f00,
0x317f1500, 0x317fab00, 0x31804100, 0x3180d700, 0x31816d00, 0x31820300, 0x31829900, 0x31832f00, 0x3183c500, 0x31845b00, 0x3184f100, 0x31858700, 0x31861d00, 0x3186b300, 0x31874900, 0x3187df00,
0x31887500, 0x31890b00, 0x3189a100, 0x318a3700, 0x318acd00, 0x318b6300, 0x318bf900, 0x318c8f00, 0x318d2500, 0x318dbb00, 0x318e5100, 0x318ee700, 0x318f7d00, 0x31901300, 0x3190a900, 0x31913f00,
0x3191d500, 0x31926b00, 0x31930100, 0x31939700, 0x31942d00, 0x3194c300, 0x31955900, 0x3195ef00, 0x31968500, 0x31971b00, 0x3197b100, 0x31984700, 0x3198dd00, 0x31997300, 0x319a0900, 0x319a9f00,
0x319b3500, 0x319bcb00, 0x319c6100, 0x319cf700, 0x319d8d00, 0x319e2300, 0x319eb900, 0x319f4f00, 0x319fe500, 0x31a07b00, 0x31a11100, 0x31a1a700, 0x31a23d00, 0x31a2d300, 0x31a36900, 0x31a3ff00,
0x31a49500, 0x31a52b00, 0x31a5c100, 0x31a65700, 0x31a6ed00, 0x31a78300, 0x31a81900, 0x31a8af00, 0x31a94500, 0x31a9db00, 0x31aa7100, 0x31ab0700, 0x31ab9d00, 0x31ac3300, 0x31acc900, 0x31ad5f00,
0x31adf500, 0x31ae8b00, 0x31af2100, 0x31afb700, 0x31b04d00, 0x31b0e300, 0x31b17900, 0x31b20f00, 0x31b2a500, 0x31b33b00, 0x31b3d100, 0x31b46700, 0x31b4fd00, 0x31b59300, 0x31b62900, 0x31b6bf00,
0x31b75500, 0x31b7eb00, 0x31b88100, 0x31b91700, 0x31b9ad00, 0x31ba4300, 0x31bad900, 0x31bb6f00, 0x31bc0500, 0x31bc9b00, 0x31bd3100, 0x31bdc700, 0x31be5d00, 0x31bef300, 0x31bf8900, 0x31c01f00,
0x31c0b500, 0x31c14b00, 0x31c1e100, 0x31c27700, 0x31c30d00, 0x31c3a300, 0x31c43900, 0x31c4cf00, 0x31c56500, 0x31c5fb00, 0x31c69100, 0x31c72700, 0x31c7bd00, 0x31c85300, 0x31c8e900, 0x31c97f00,
0x31ca1500, 0x31caab00, 0x31cb4100, 0x31cbd700, 0x31cc6d00, 0x31cd0300, 0x31cd9900, 0x31ce2f00, 0x31cec500, 0x31cf5b00, 0x31cff100, 0x31d08700, 0x31d11d00, 0x31d1b300, 0x31d24900, 0x31d2df00,
0x31d37500, 0x31d40b00, 0x31d4a100, 0x31d53700, 0x31d5cd00, 0x31d66300, 0x31d6f900, 0x31d78f00, 0x31d82500, 0x31d8bb00, 0x31d95100, 0x31d9e700, 0x31da7d00, 0x31db1300, 0x31dba900, 0x31dc3f00,
0x31dcd500, 0x31dd6b00, 0x31de0100, 0x31de9700, 0x31df2d00, 0x31dfc300, 0x31e05900, 0x31e0ef00, 0x31e18500, 0x31e21b00, 0x31e2b100, 0x31e34700, 0x31e3dd00, 0x31e47300, 0x31e50900, 0x31e59f00,
0x31e63500, 0x31e6cb00, 0x31e76100, 0x31e7f700, 0x31e88d00, 0x31e92300, 0x31e9b900, 0x31ea4f00, 0x31eae500, 0x31eb7b00, 0x31ec1100, 0x31eca700, 0x31ed3d00, 0x31edd300, 0x31ee6900, 0x31eeff00,
0x31ef9500, 0x31f02b00, 0x31f0c100, 0x31f15700, 0x31f1ed00, 0x31f28300, 0x31f31900, 0x31f3af00, 0x31f44500, 0x31f4db00, 0x31f57100, 0x31f60700, 0x31f69d00, 0x31f73300, 0x31f7c900, 0x31f85f00,
0x31f8f500, 0x31f98b00, 0x31fa2100, 0x31fab700, 0x31fb4d00, 0x31fbe300, 0x31fc7900, 0x31fd0f00, 0x31fda500, 0x31fe3b00, 0x31fed100, 0x31ff6700, 0x31fffd00, 0x32009300, 0x32012900, 0x3201bf00,
0x32025500, 0x3202eb00, 0x32038100, 0x32041700, 0x3204ad00, 0x32054300, 0x3205d900, 0x32066f00, 0x32070500, 0x32079b00, 0x32083100, 0x3208c700, 0x32095d00, 0x3209f300, 0x320a8900, 0x320b1f00,
0x320bb500, 0x320c4b00, 0x320ce100, 0x320d7700, 0x320e0d00, 0x320ea300, 0x320f3900, 0x320fcf00, 0x32106500, 0x3210fb00, 0x32119100, 0x32122700, 0x3212bd00, 0x32135300, 0x3213e900, 0x32147f00,
0x32151500, 0x3215ab00, 0x32164100, 0x3216d700, 0x32176d00, 0x32180300, 0x32189900, 0x32192f00, 0x3219c500, 0x321a5b00, 0x321af100, 0x321b8700, 0x321c1d00, 0x321cb300, 0x321d4900, 0x321ddf00,
0x321e7500, 0x321f0b00, 0x321fa100, 0x32203700, 0x3220cd00, 0x32216300, 0x3221f900, 0x32228f00, 0x32232500, 0x3223bb00, 0x32245100, 0x3224e700, 0x32257d00, 0x32261300, 0x3226a900, 0x32273f00,
0x3227d500, 0x32286b00, 0x32290100, 0x32299700, 0x322a2d00, 0x322ac300, 0x322b5900, 0x322bef00, 0x322c8500, 0x322d1b00, 0x322db100, 0x322e4700, 0x322edd00, 0x322f7300, 0x32300900, 0x32309f00,
0x32313500, 0x3231cb00, 0x32326100, 0x3232f700, 0x32338d00, 0x32342300, 0x3234b900, 0x32354f00, 0x3235e500, 0x32367b00, 0x32371100, 0x3237a700, 0x32383d00, 0x3238d300, 0x32396900, 0x3239ff00,
0x323aa400, 0x323b4900, 0x323bee00, 0x323c9300, 0x323d3800, 0x323ddd00, 0x323e8200, 0x323f2700, 0x323fcc00, 0x32407100, 0x32411600, 0x3241bb00, 0x32426000, 0x32430500, 0x3243aa00, 0x32444f00,
0x3244f400, 0x32459900, 0x32463e00, 0x3246e300, 0x32478800, 0x32482d00, 0x3248d200, 0x32497700, 0x324a1c00, 0x324ac100, 0x324b6600, 0x324c0b00, 0x324cb000, 0x324d5500, 0x324dfa00, 0x324e9f00,
0x324f4400, 0x324fe900, 0x32508e00, 0x32513300, 0x3251d800, 0x32527d00, 0x32532200, 0x3253c700, 0x32546c00, 0x32551100, 0x3255b600, 0x32565b00, 0x32570000, 0x3257a500, 0x32584a00, 0x3258ef00,
0x32599400, 0x325a3900, 0x325ade00, 0x325b8300, 0x325c2800, 0x325ccd00, 0x325d7200, 0x325e1700, 0x325ebc00, 0x325f6100, 0x32600600, 0x3260ab00, 0x32615000, 0x3261f500, 0x32629a00, 0x32633f00,
0x3263e400, 0x32648900, 0x32652e00, 0x3265d300, 0x32667800, 0x32671d00, 0x3267c200, 0x32686700, 0x32690c00, 0x3269b100, 0x326a5600, 0x326afb00, 0x326ba000, 0x326c4500, 0x326cea00, 0x326d8f00,
0x326e3400, 0x326ed900, 0x326f7e00, 0x32702300, 0x3270c800, 0x32716d00, 0x32721200, 0x3272b700, 0x32735c00, 0x32740100, 0x3274a600, 0x32754b00, 0x3275f000, 0x32769500, 0x32773a00, 0x3277df00,
0x32788400, 0x32792900, 0x3279ce00, 0x327a7300, 0x327b1800, 0x327bbd00, 0x327c6200, 0x327d0700, 0x327dac00, 0x327e5100, 0x327ef600, 0x327f9b00, 0x32804000, 0x3280e500, 0x32818a00, 0x32822f00,
0x3282d400, 0x32837900, 0x32841e00, 0x3284c300, 0x32856800, 0x32860d00, 0x3286b200, 0x32875700, 0x3287fc00, 0x3288a100, 0x32894600, 0x3289eb00, 0x328a9000, 0x328b3500, 0x328bda00, 0x328c7f00,
0x328d2400, 0x328dc900, 0x328e6e00, 0x328f1300, 0x328fb800, 0x32905d00, 0x32910200, 0x3291a700, 0x32924c00, 0x3292f100, 0x32939600, 0x32943b00, 0x3294e000, 0x32958500, 0x32962a00, 0x3296cf00,
0x32977400, 0x32981900, 0x3298be00, 0x32996300, 0x329a0800, 0x329aad00, 0x329b5200, 0x329bf700, 0x329c9c00, 0x329d4100, 0x329de600, 0x329e8b00, 0x329f3000, 0x329fd500, 0x32a07a00, 0x32a11f00,
0x32a1c400, 0x32a26900, 0x32a30e00, 0x32a3b300, 0x32a45800, 0x32a4fd00, 0x32a5a200, 0x32a64700, 0x32a6ec00, 0x32a79100, 0x32a83600, 0x32a8db00, 0x32a98000, 0x32aa2500, 0x32aaca00, 0x32ab6f00,
0x32ac1400, 0x32acb900, 0x32ad5e00, 0x32ae0300, 0x32aea800, 0x32af4d00, 0x32aff200, 0x32b09700, 0x32b13c00, 0x32b1e100, 0x32b28600, 0x32b32b00, 0x32b3d000, 0x32b47500, 0x32b51a00, 0x32b5bf00,
0x32b66400, 0x32b70900, 0x32b7ae00, 0x32b85300, 0x32b8f800, 0x32b99d00, 0x32ba4200, 0x32bae700, 0x32bb8c00, 0x32bc3100, 0x32bcd600, 0x32bd7b00, 0x32be2000, 0x32bec500, 0x32bf6a00, 0x32c00f00,
0x32c0b400, 0x32c15900, 0x32c1fe00, 0x32c2a300, 0x32c34800, 0x32c3ed00, 0x32c49200, 0x32c53700, 0x32c5dc00, 0x32c68100, 0x32c72600, 0x32c7cb00, 0x32c87000, 0x32c91500, 0x32c9ba00, 0x32ca5f00,
0x32cb0400, 0x32cba900, 0x32cc4e00, 0x32ccf300, 0x32cd9800, 0x32ce3d00, 0x32cee200, 0x32cf8700, 0x32d02c00, 0x32d0d100, 0x32d17600, 0x32d21b00, 0x32d2c000, 0x32d36500, 0x32d40a00, 0x32d4af00,
0x32d55400, 0x32d5f900, 0x32d69e00, 0x32d74300, 0x32d7e800, 0x32d88d00, 0x32d93200, 0x32d9d700, 0x32da7c00, 0x32db2100, 0x32dbc600, 0x32dc6b00, 0x32dd1000, 0x32ddb500, 0x32de5a00, 0x32deff00,
0x32dfa400, 0x32e04900, 0x32e0ee00, 0x32e19300, 0x32e23800, 0x32e2dd00, 0x32e38200, 0x32e42700, 0x32e4cc00, 0x32e57100, 0x32e61600, 0x32e6bb00, 0x32e76000, 0x32e80500, 0x32e8aa00, 0x32e94f00,
0x32e9f400, 0x32ea9900, 0x32eb3e00, 0x32ebe300, 0x32ec8800, 0x32ed2d00, 0x32edd200, 0x32ee7700, 0x32ef1c00, 0x32efc100, 0x32f06600, 0x32f10b00, 0x32f1b000, 0x32f25500, 0x32f2fa00, 0x32f39f00,
0x32f44400, 0x32f4e900, 0x32f58e00, 0x32f63300, 0x32f6d800, 0x32f77d00, 0x32f82200, 0x32f8c700, 0x32f96c00, 0x32fa1100, 0x32fab600, 0x32fb5b00, 0x32fc0000, 0x32fca500, 0x32fd4a00, 0x32fdef00,
0x32fe9400, 0x32ff3900, 0x32ffde00, 0x33008300, 0x33012800, 0x3301cd00, 0x33027200, 0x33031700, 0x3303bc00, 0x33046100, 0x33050600, 0x3305ab00, 0x33065000, 0x3306f500, 0x33079a00, 0x33083f00,
0x3308e400, 0x33098900, 0x330a2e00, 0x330ad300, 0x330b7800, 0x330c1d00, 0x330cc200, 0x330d6700, 0x330e0c00, 0x330eb100, 0x330f5600, 0x330ffb00, 0x3310a000, 0x33114500, 0x3311ea00, 0x33128f00,
0x33133400, 0x3313d900, 0x33147e00, 0x33152300, 0x3315c800, 0x33166d00, 0x33171200, 0x3317b700, 0x33185c00, 0x33190100, 0x3319a600, 0x331a4b00, 0x331af000, 0x331b9500, 0x331c3a00, 0x331cdf00,
0x331d8400, 0x331e2900, 0x331ece00, 0x331f7300, 0x33201800, 0x3320bd00, 0x33216200, 0x33220700, 0x3322ac00, 0x33235100, 0x3323f600, 0x33249b00, 0x33254000, 0x3325e500, 0x33268a00, 0x33272f00,
0x3327d400, 0x33287900, 0x33291e00, 0x3329c300, 0x332a6800, 0x332b0d00, 0x332bb200, 0x332c5700, 0x332cfc00, 0x332da100, 0x332e4600, 0x332eeb00, 0x332f9000, 0x33303500, 0x3330da00, 0x33317f00,
0x33322400, 0x3332c900, 0x33336e00, 0x33341300, 0x3334b800, 0x33355d00, 0x33360200, 0x3336a700, 0x33374c00, 0x3337f100, 0x33389600, 0x33393b00, 0x3339e000, 0x333a8500, 0x333b2a00, 0x333bcf00,
0x333c7400, 0x333d1900, 0x333dbe00, 0x333e6300, 0x333f0800, 0x333fad00, 0x33405200, 0x3340f700, 0x33419c00, 0x33424100, 0x3342e600, 0x33438b00, 0x33443000, 0x3344d500, 0x33457a00, 0x33461f00,
0x3346c400, 0x33476900, 0x33480e00, 0x3348b300, 0x33495800, 0x3349fd00, 0x334aa200, 0x334b4700, 0x334bec00, 0x334c9100, 0x334d3600, 0x334ddb00, 0x334e8000, 0x334f2500, 0x334fca00, 0x33506f00,
0x33511400, 0x3351b900, 0x33525e00, 0x33530300, 0x3353a800, 0x33544d00, 0x3354f200, 0x33559700, 0x33563c00, 0x3356e100, 0x33578600, 0x33582b00, 0x3358d000, 0x33597500, 0x335a1a00, 0x335abf00,
0x335b6400, 0x335c0900, 0x335cae00, 0x335d5300, 0x335df800, 0x335e9d00, 0x335f4200, 0x335fe700, 0x33608c00, 0x33613100, 0x3361d600, 0x33627b00, 0x33632000, 0x3363c500, 0x33646a00, 0x33650f00,
0x3365b400, 0x33665900, 0x3366fe00, 0x3367a300, 0x33684800, 0x3368ed00, 0x33699200, 0x336a3700, 0x336adc00, 0x336b8100, 0x336c2600, 0x336ccb00, 0x336d7000, 0x336e1500, 0x336eba00, 0x336f5f00,
0x33700400, 0x3370a900, 0x33714e00, 0x3371f300, 0x33729800, 0x33733d00, 0x3373e200, 0x33748700, 0x33752c00, 0x3375d100, 0x33767600, 0x33771b00, 0x3377c000, 0x33786500, 0x33790a00, 0x3379af00,
0x337a5400, 0x337af900, 0x337b9e00, 0x337c4300, 0x337ce800, 0x337d8d00, 0x337e3200, 0x337ed700, 0x337f7c00, 0x33802100, 0x3380c600, 0x33816b00, 0x33821000, 0x3382b500, 0x33835a00, 0x3383ff00,
0x3384a700, 0x33854f00, 0x3385f700, 0x33869f00, 0x33874700, 0x3387ef00, 0x33889700, 0x33893f00, 0x3389e700, 0x338a8f00, 0x338b3700, 0x338bdf00, 0x338c8700, 0x338d2f00, 0x338dd700, 0x338e7f00,
0x338f2700, 0x338fcf00, 0x33907700, 0x33911f00, 0x3391c700, 0x33926f00, 0x33931700, 0x3393bf00, 0x33946700, 0x33950f00, 0x3395b700, 0x33965f00, 0x33970700, 0x3397af00, 0x33985700, 0x3398ff00,
0x3399a700, 0x339a4f00, 0x339af700, 0x339b9f00, 0x339c4700, 0x339cef00, 0x339d9700, 0x339e3f00, 0x339ee700, 0x339f8f00, 0x33a03700, 0x33a0df00, 0x33a18700, 0x33a22f00, 0x33a2d700, 0x33a37f00,
0x33a42700, 0x33a4cf00, 0x33a57700, 0x33a61f00, 0x33a6c700, 0x33a76f00, 0x33a81700, 0x33a8bf00, 0x33a96700, 0x33aa0f00, 0x33aab700, 0x33ab5f00, 0x33ac0700, 0x33acaf00, 0x33ad5700, 0x33adff00,
0x33aea700, 0x33af4f00, 0x33aff700, 0x33b09f00, 0x33b14700, 0x33b1ef00, 0x33b29700, 0x33b33f00, 0x33b3e700, 0x33b48f00, 0x33b53700, 0x33b5df00, 0x33b68700, 0x33b72f00, 0x33b7d700, 0x33b87f00,
0x33b92700, 0x33b9cf00, 0x33ba7700, 0x33bb1f00, 0x33bbc700, 0x33bc6f00, 0x33bd1700, 0x33bdbf00, 0x33be6700, 0x33bf0f00, 0x33bfb700, 0x33c05f00, 0x33c10700, 0x33c1af00, 0x33c25700, 0x33c2ff00,
0x33c3a700, 0x33c44f00, 0x33c4f700, 0x33c59f00, 0x33c64700, 0x33c6ef00, 0x33c79700, 0x33c83f00, 0x33c8e700, 0x33c98f00, 0x33ca3700, 0x33cadf00, 0x33cb8700, 0x33cc2f00, 0x33ccd700, 0x33cd7f00,
0x33ce2700, 0x33cecf00, 0x33cf7700, 0x33d01f00, 0x33d0c700, 0x33d16f00, 0x33d21700, 0x33d2bf00, 0x33d36700, 0x33d40f00, 0x33d4b700, 0x33d55f00, 0x33d60700, 0x33d6af00, 0x33d75700, 0x33d80000,
0x33d8a800, 0x33d95000, 0x33d9f800, 0x33daa000, 0x33db4800, 0x33dbf000, 0x33dc9800, 0x33dd4000, 0x33dde800, 0x33de9000, 0x33df3800, 0x33dfe000, 0x33e08800, 0x33e13000, 0x33e1d800, 0x33e28000,
0x33e32800, 0x33e3d000, 0x33e47800, 0x33e52000, 0x33e5c800, 0x33e67000, 0x33e71800, 0x33e7c000, 0x33e86800, 0x33e91000, 0x33e9b800, 0x33ea6000, 0x33eb0800, 0x33ebb000, 0x33ec5800, 0x33ed0000,
0x33eda800, 0x33ee5000, 0x33eef800, 0x33efa000, 0x33f04800, 0x33f0f000, 0x33f19800, 0x33f24000, 0x33f2e800, 0x33f39000, 0x33f43800, 0x33f4e000, 0x33f58800, 0x33f63000, 0x33f6d800, 0x33f78000,
0x33f82800, 0x33f8d000, 0x33f97800, 0x33fa2000, 0x33fac800, 0x33fb7000, 0x33fc1800, 0x33fcc000, 0x33fd6800, 0x33fe1000, 0x33feb800, 0x33ff6000, 0x34000800, 0x3400b000, 0x34015800, 0x34020000,
0x3402a800, 0x34035000, 0x3403f800, 0x3404a000, 0x34054800, 0x3405f000, 0x34069800, 0x34074000, 0x3407e800, 0x34089000, 0x34093800, 0x3409e000, 0x340a8800, 0x340b3000, 0x340bd800, 0x340c8000,
0x340d2800, 0x340dd000, 0x340e7800, 0x340f2000, 0x340fc800, 0x34107000, 0x34111800, 0x3411c000, 0x34126800, 0x34131000, 0x3413b800, 0x34146000, 0x34150800, 0x3415b000, 0x34165800, 0x34170000,
0x3417a800, 0x34185000, 0x3418f800, 0x3419a000, 0x341a4800, 0x341af000, 0x341b9800, 0x341c4000, 0x341ce800, 0x341d9000, 0x341e3800, 0x341ee000, 0x341f8800, 0x34203000, 0x3420d800, 0x34218000,
0x34222800, 0x3422d000, 0x34237800, 0x34242000, 0x3424c800, 0x34257000, 0x34261800, 0x3426c000, 0x34276800, 0x34281000, 0x3428b800, 0x34296000, 0x342a0800, 0x342ab000, 0x342b5800, 0x342c0000,
0x342ca800, 0x342d5000, 0x342df800, 0x342ea000, 0x342f4800, 0x342ff000, 0x34309800, 0x34314000, 0x3431e800, 0x34329000, 0x34333800, 0x3433e000, 0x34348800, 0x34353000, 0x3435d800, 0x34368000,
0x34372800, 0x3437d000, 0x34387800, 0x34392000, 0x3439c800, 0x343a7000, 0x343b1800, 0x343bc000, 0x343c6800, 0x343d1000, 0x343db800, 0x343e6000, 0x343f0800, 0x343fb000, 0x34405800, 0x34410000,
0x3441a800, 0x34425000, 0x3442f800, 0x3443a000, 0x34444800, 0x3444f000, 0x34459800, 0x34464000, 0x3446e800, 0x34479000, 0x34483800, 0x3448e000, 0x34498800, 0x344a3000, 0x344ad800, 0x344b8000,
0x344c2800, 0x344cd000, 0x344d7800, 0x344e2000, 0x344ec800, 0x344f7000, 0x34501800, 0x3450c000, 0x34516800, 0x34521000, 0x3452b800, 0x34536000, 0x34540800, 0x3454b000, 0x34555800, 0x34560000,
0x3456a800, 0x34575000, 0x3457f800, 0x3458a000, 0x34594800, 0x3459f000, 0x345a9800, 0x345b4000, 0x345be800, 0x345c9000, 0x345d3800, 0x345de000, 0x345e8800, 0x345f3000, 0x345fd800, 0x34608000,
0x34612800, 0x3461d000, 0x34627800, 0x34632000, 0x3463c800, 0x34647000, 0x34651800, 0x3465c000, 0x34666800, 0x34671000, 0x3467b800, 0x34686000, 0x34690800, 0x3469b000, 0x346a5800, 0x346b0000,
0x346ba800, 0x346c5000, 0x346cf800, 0x346da000, 0x346e4800, 0x346ef000, 0x346f9800, 0x34704000, 0x3470e800, 0x34719000, 0x34723800, 0x3472e000, 0x34738800, 0x34743000, 0x3474d800, 0x34758000,
0x34762800, 0x3476d000, 0x34777800, 0x34782000, 0x3478c800, 0x34797000, 0x347a1800, 0x347ac000, 0x347b6800, 0x347c1000, 0x347cb800, 0x347d6000, 0x347e0800, 0x347eb000, 0x347f5800, 0x34800000,
0x3480a800, 0x34815000, 0x3481f800, 0x3482a000, 0x34834800, 0x3483f000, 0x34849800, 0x34854000, 0x3485e800, 0x34869000, 0x34873800, 0x3487e000, 0x34888800, 0x34893000, 0x3489d800, 0x348a8000,
0x348b2800, 0x348bd000, 0x348c7800, 0x348d2000, 0x348dc800, 0x348e7000, 0x348f1800, 0x348fc000, 0x34906800, 0x34911000, 0x3491b800, 0x34926000, 0x34930800, 0x3493b000, 0x34945800, 0x34950000,
0x3495a800, 0x34965000, 0x3496f800, 0x3497a000, 0x34984800, 0x3498f000, 0x34999800, 0x349a4000, 0x349ae800, 0x349b9000, 0x349c3800, 0x349ce000, 0x349d8800, 0x349e3000, 0x349ed800, 0x349f8000,
0x34a02800, 0x34a0d000, 0x34a17800, 0x34a22000, 0x34a2c800, 0x34a37000, 0x34a41800, 0x34a4c000, 0x34a56800, 0x34a61000, 0x34a6b800, 0x34a76000, 0x34a80800, 0x34a8b000, 0x34a95800, 0x34aa0000,
0x34aaa800, 0x34ab5000, 0x34abf800, 0x34aca000, 0x34ad4800, 0x34adf000, 0x34ae9800, 0x34af4000, 0x34afe800, 0x34b09000, 0x34b13800, 0x34b1e000, 0x34b28800, 0x34b33000, 0x34b3d800, 0x34b48000,
0x34b52800, 0x34b5d000, 0x34b67800, 0x34b72000, 0x34b7c800, 0x34b87000, 0x34b91800, 0x34b9c000, 0x34ba6800, 0x34bb1000, 0x34bbb800, 0x34bc6000, 0x34bd0800, 0x34bdb000, 0x34be5800, 0x34bf0000,
0x34bfa800, 0x34c05000, 0x34c0f800, 0x34c1a000, 0x34c24800, 0x34c2f000, 0x34c39800, 0x34c44000, 0x34c4e800, 0x34c59000, 0x34c63800, 0x34c6e000, 0x34c78800, 0x34c83000, 0x34c8d800, 0x34c98000,
0x34ca2800, 0x34cad000, 0x34cb7800, 0x34cc2000, 0x34ccc800, 0x34cd7000, 0x34ce1800, 0x34cec000, 0x34cf6800, 0x34d01000, 0x34d0b800, 0x34d16000, 0x34d20800, 0x34d2b000, 0x34d35800, 0x34d40000,
0x34d4bb00, 0x34d57600, 0x34d63100, 0x34d6ec00, 0x34d7a700, 0x34d86200, 0x34d91d00, 0x34d9d800, 0x34da9300, 0x34db4e00, 0x34dc0900, 0x34dcc400, 0x34dd7f00, 0x34de3a00, 0x34def500, 0x34dfb000,
0x34e06b00, 0x34e12600, 0x34e1e100, 0x34e29c00, 0x34e35700, 0x34e41200, 0x34e4cd00, 0x34e58800, 0x34e64300, 0x34e6fe00, 0x34e7b900, 0x34e87400, 0x34e92f00, 0x34e9ea00, 0x34eaa500, 0x34eb6000,
0x34ec1b00, 0x34ecd600, 0x34ed9100, 0x34ee4c00, 0x34ef0700, 0x34efc200, 0x34f07d00, 0x34f13800, 0x34f1f300, 0x34f2ae00, 0x34f36900, 0x34f42400, 0x34f4df00, 0x34f59a00, 0x34f65500, 0x34f71000,
0x34f7cb00, 0x34f88600, 0x34f94100, 0x34f9fc00, 0x34fab700, 0x34fb7200, 0x34fc2d00, 0x34fce800, 0x34fda300, 0x34fe5e00, 0x34ff1900, 0x34ffd400, 0x35008f00, 0x35014a00, 0x35020500, 0x3502c000,
0x35037b00, 0x35043600, 0x3504f100, 0x3505ac00, 0x35066700, 0x35072200, 0x3507dd00, 0x35089800, 0x35095300, 0x350a0e00, 0x350ac900, 0x350b8400, 0x350c3f00, 0x350cfa00, 0x350db500, 0x350e7000,
0x350f2b00, 0x350fe600, 0x3510a100, 0x35115c00, 0x35121700, 0x3512d200, 0x35138d00, 0x35144800, 0x35150300, 0x3515be00, 0x35167900, 0x35173400, 0x3517ef00, 0x3518aa00, 0x35196500, 0x351a2000,
0x351adb00, 0x351b9600, 0x351c5100, 0x351d0c00, 0x351dc700, 0x351e8200, 0x351f3d00, 0x351ff800, 0x3520b300, 0x35216e00, 0x35222900, 0x3522e400, 0x35239f00, 0x35245a00, 0x35251500, 0x3525d000,
0x35268b00, 0x35274600, 0x35280100, 0x3528bc00, 0x35297700, 0x352a3200, 0x352aed00, 0x352ba800, 0x352c6300, 0x352d1e00, 0x352dd900, 0x352e9400, 0x352f4f00, 0x35300a00, 0x3530c500, 0x35318000,
0x35323b00, 0x3532f600, 0x3533b100, 0x35346c00, 0x35352700, 0x3535e200, 0x35369d00, 0x35375800, 0x35381300, 0x3538ce00, 0x35398900, 0x353a4400, 0x353aff00, 0x353bba00, 0x353c7500, 0x353d3000,
0x353deb00, 0x353ea600, 0x353f6100, 0x35401c00, 0x3540d700, 0x35419200, 0x35424d00, 0x35430800, 0x3543c300, 0x35447e00, 0x35453900, 0x3545f400, 0x3546af00, 0x35476a00, 0x35482500, 0x3548e000,
0x35499b00, 0x354a5600, 0x354b1100, 0x354bcc00, 0x354c8700, 0x354d4200, 0x354dfd00, 0x354eb800, 0x354f7300, 0x35502e00, 0x3550e900, 0x3551a400, 0x35525f00, 0x35531a00, 0x3553d500, 0x35549000,
0x35554b00, 0x35560600, 0x3556c100, 0x35577c00, 0x35583700, 0x3558f200, 0x3559ad00, 0x355a6800, 0x355b2300, 0x355bde00, 0x355c9900, 0x355d5400, 0x355e0f00, 0x355eca00, 0x355f8500, 0x35604000,
0x3560fb00, 0x3561b600, 0x35627100, 0x35632c00, 0x3563e700, 0x3564a200, 0x35655d00, 0x35661800, 0x3566d300, 0x35678e00, 0x35684900, 0x35690400, 0x3569bf00, 0x356a7a00, 0x356b3500, 0x356bf000,
0x356cab00, 0x356d6600, 0x356e2100, 0x356edc00, 0x356f9700, 0x35705200, 0x35710d00, 0x3571c800, 0x35728300, 0x35733e00, 0x3573f900, 0x3574b400, 0x35756f00, 0x35762a00, 0x3576e500, 0x3577a000,
0x35785b00, 0x35791600, 0x3579d100, 0x357a8c00, 0x357b4700, 0x357c0200, 0x357cbd00, 0x357d7800, 0x357e3300, 0x357eee00, 0x357fa900, 0x35806400, 0x35811f00, 0x3581da00, 0x35829500, 0x35835000,
0x35840b00, 0x3584c600, 0x35858100, 0x35863c00, 0x3586f700, 0x3587b200, 0x35886d00, 0x35892800, 0x3589e300, 0x358a9e00, 0x358b5900, 0x358c1400, 0x358ccf00, 0x358d8a00, 0x358e4500, 0x358f0000,
0x358fbb00, 0x35907600, 0x35913100, 0x3591ec00, 0x3592a700, 0x35936200, 0x35941d00, 0x3594d800, 0x35959300, 0x35964e00, 0x35970900, 0x3597c400, 0x35987f00, 0x35993a00, 0x3599f500, 0x359ab000,
0x359b6b00, 0x359c2600, 0x359ce100, 0x359d9c00, 0x359e5700, 0x359f1200, 0x359fcd00, 0x35a08800, 0x35a14300, 0x35a1fe00, 0x35a2b900, 0x35a37400, 0x35a42f00, 0x35a4ea00, 0x35a5a500, 0x35a66000,
0x35a71b00, 0x35a7d600, 0x35a89100, 0x35a94c00, 0x35aa0700, 0x35aac200, 0x35ab7d00, 0x35ac3800, 0x35acf300, 0x35adae00, 0x35ae6900, 0x35af2400, 0x35afdf00, 0x35b09a00, 0x35b15500, 0x35b21000,
0x35b2cb00, 0x35b38600, 0x35b44100, 0x35b4fc00, 0x35b5b700, 0x35b67200, 0x35b72d00, 0x35b7e800, 0x35b8a300, 0x35b95e00, 0x35ba1900, 0x35bad400, 0x35bb8f00, 0x35bc4a00, 0x35bd0500, 0x35bdc000,
0x35be7b00, 0x35bf3600, 0x35bff100, 0x35c0ac00, 0x35c16700, 0x35c22200, 0x35c2dd00, 0x35c39800, 0x35c45300, 0x35c50e00, 0x35c5c900, 0x35c68400, 0x35c73f00, 0x35c7fa00, 0x35c8b500, 0x35c97000,
0x35ca2b00, 0x35cae600, 0x35cba100, 0x35cc5c00, 0x35cd1700, 0x35cdd200, 0x35ce8d00, 0x35cf4800, 0x35d00300, 0x35d0be00, 0x35d17900, 0x35d23400, 0x35d2ef00, 0x35d3aa00, 0x35d46500, 0x35d52000,
0x35d5db00, 0x35d69600, 0x35d75100, 0x35d80c00, 0x35d8c700, 0x35d98200, 0x35da3d00, 0x35daf800, 0x35dbb300, 0x35dc6e00, 0x35dd2900, 0x35dde400, 0x35de9f00, 0x35df5a00, 0x35e01500, 0x35e0d000,
0x35e18b00, 0x35e24600, 0x35e30100, 0x35e3bc00, 0x35e47700, 0x35e53200, 0x35e5ed00, 0x35e6a800, 0x35e76300, 0x35e81e00, 0x35e8d900, 0x35e99400, 0x35ea4f00, 0x35eb0a00, 0x35ebc500, 0x35ec8000,
0x35ed3b00, 0x35edf600, 0x35eeb100, 0x35ef6c00, 0x35f02700, 0x35f0e200, 0x35f19d00, 0x35f25800, 0x35f31300, 0x35f3ce00, 0x35f48900, 0x35f54400, 0x35f5ff00, 0x35f6ba00, 0x35f77500, 0x35f83000,
0x35f8eb00, 0x35f9a600, 0x35fa6100, 0x35fb1c00, 0x35fbd700, 0x35fc9200, 0x35fd4d00, 0x35fe0800, 0x35fec300, 0x35ff7e00, 0x36003900, 0x3600f400, 0x3601af00, 0x36026a00, 0x36032500, 0x3603e000,
0x36049b00, 0x36055600, 0x36061100, 0x3606cc00, 0x36078700, 0x36084200, 0x3608fd00, 0x3609b800, 0x360a7300, 0x360b2e00, 0x360be900, 0x360ca400, 0x360d5f00, 0x360e1a00, 0x360ed500, 0x360f9000,
0x36104b00, 0x36110600, 0x3611c100, 0x36127c00, 0x36133700, 0x3613f200, 0x3614ad00, 0x36156800, 0x36162300, 0x3616de00, 0x36179900, 0x36185400, 0x36190f00, 0x3619ca00, 0x361a8500, 0x361b4000,
0x361bfb00, 0x361cb600, 0x361d7100, 0x361e2c00, 0x361ee700, 0x361fa200, 0x36205d00, 0x36211800, 0x3621d300, 0x36228e00, 0x36234900, 0x36240400, 0x3624bf00, 0x36257a00, 0x36263500, 0x3626f000,
0x3627ab00, 0x36286600, 0x36292100, 0x3629dc00, 0x362a9700, 0x362b5200, 0x362c0d00, 0x362cc800, 0x362d8300, 0x362e3e00, 0x362ef900, 0x362fb400, 0x36306f00, 0x36312a00, 0x3631e500, 0x3632a000,
0x36335b00, 0x36341600, 0x3634d100, 0x36358c00, 0x36364700, 0x36370200, 0x3637bd00, 0x36387800, 0x36393300, 0x3639ee00, 0x363aa900, 0x363b6400, 0x363c1f00, 0x363cda00, 0x363d9500, 0x363e5000,
0x363f0b00, 0x363fc600, 0x36408100, 0x36413c00, 0x3641f700, 0x3642b200, 0x36436d00, 0x36442800, 0x3644e300, 0x36459e00, 0x36465900, 0x36471400, 0x3647cf00, 0x36488a00, 0x36494500, 0x364a0000,
0x364ac000, 0x364b8000, 0x364c4000, 0x364d0000, 0x364dc000, 0x364e8000, 0x364f4000, 0x36500000, 0x3650c000, 0x36518000, 0x36524000, 0x36530000, 0x3653c000, 0x36548000, 0x36554000, 0x36560000,
0x3656c000, 0x36578000, 0x36584000, 0x36590000, 0x3659c000, 0x365a8000, 0x365b4000, 0x365c0000, 0x365cc000, 0x365d8000, 0x365e4000, 0x365f0000, 0x365fc000, 0x36608000, 0x36614000, 0x36620000,
0x3662c000, 0x36638000, 0x36644000, 0x36650000, 0x3665c000, 0x36668000, 0x36674000, 0x36680000, 0x3668c000, 0x36698000, 0x366a4000, 0x366b0000, 0x366bc000, 0x366c8000, 0x366d4000, 0x366e0000,
0x366ec000, 0x366f8000, 0x36704000, 0x36710000, 0x3671c000, 0x36728000, 0x36734000, 0x36740000, 0x3674c000, 0x36758000, 0x36764000, 0x36770000, 0x3677c000, 0x36788000, 0x36794000, 0x367a0000,
0x367ac000, 0x367b8000, 0x367c4000, 0x367d0000, 0x367dc000, 0x367e8000, 0x367f4000, 0x36800000, 0x3680c000, 0x36818000, 0x36824000, 0x36830000, 0x3683c000, 0x36848000, 0x36854000, 0x36860000,
0x3686c000, 0x36878000, 0x36884000, 0x36890000, 0x3689c000, 0x368a8000, 0x368b4000, 0x368c0000, 0x368cc000, 0x368d8000, 0x368e4000, 0x368f0000, 0x368fc000, 0x36908000, 0x36914000, 0x36920000,
0x3692c000, 0x36938000, 0x36944000, 0x36950000, 0x3695c000, 0x36968000, 0x36974000, 0x36980000, 0x3698c000, 0x36998000, 0x369a4000, 0x369b0000, 0x369bc000, 0x369c8000, 0x369d4000, 0x369e0000,
0x369ec000, 0x369f8000, 0x36a04000, 0x36a10000, 0x36a1c000, 0x36a28000, 0x36a34000, 0x36a40000, 0x36a4c000, 0x36a58000, 0x36a64000, 0x36a70000, 0x36a7c000, 0x36a88000, 0x36a94000, 0x36aa0000,
0x36aac000, 0x36ab8000, 0x36ac4000, 0x36ad0000, 0x36adc000, 0x36ae8000, 0x36af4000, 0x36b00000, 0x36b0c000, 0x36b18000, 0x36b24000, 0x36b30000, 0x36b3c000, 0x36b48000, 0x36b54000, 0x36b60000,
0x36b6c000, 0x36b78000, 0x36b84000, 0x36b90000, 0x36b9c000, 0x36ba8000, 0x36bb4000, 0x36bc0000, 0x36bcc000, 0x36bd8000, 0x36be4000, 0x36bf0000, 0x36bfc000, 0x36c08000, 0x36c14000, 0x36c20000,
0x36c2c000, 0x36c38000, 0x36c44000, 0x36c50000, 0x36c5c000, 0x36c68000, 0x36c74000, 0x36c80000, 0x36c8c000, 0x36c98000, 0x36ca4000, 0x36cb0000, 0x36cbc000, 0x36cc8000, 0x36cd4000, 0x36ce0000,
0x36cec000, 0x36cf8000, 0x36d04000, 0x36d10000, 0x36d1c000, 0x36d28000, 0x36d34000, 0x36d40000, 0x36d4c000, 0x36d58000, 0x36d64000, 0x36d70000, 0x36d7c000, 0x36d88000, 0x36d94000, 0x36da0000,
0x36dac000, 0x36db8000, 0x36dc4000, 0x36dd0000, 0x36ddc000, 0x36de8000, 0x36df4000, 0x36e00000, 0x36e0c000, 0x36e18000, 0x36e24000, 0x36e30000, 0x36e3c000, 0x36e48000, 0x36e54000, 0x36e60000,
0x36e6c000, 0x36e78000, 0x36e84000, 0x36e90000, 0x36e9c000, 0x36ea8000, 0x36eb4000, 0x36ec0000, 0x36ecc000, 0x36ed8000, 0x36ee4000, 0x36ef0000, 0x36efc000, 0x36f08000, 0x36f14000, 0x36f20000,
0x36f2c000, 0x36f38000, 0x36f44000, 0x36f50000, 0x36f5c000, 0x36f68000, 0x36f74000, 0x36f80000, 0x36f8c000, 0x36f98000, 0x36fa4000, 0x36fb0000, 0x36fbc000, 0x36fc8000, 0x36fd4000, 0x36fe0000,
0x36fec000, 0x36ff8000, 0x37004000, 0x37010000, 0x3701c000, 0x37028000, 0x37034000, 0x37040000, 0x3704c000, 0x37058000, 0x37064000, 0x37070000, 0x3707c000, 0x37088000, 0x37094000, 0x370a0000,
0x370ac000, 0x370b8000, 0x370c4000, 0x370d0000, 0x370dc000, 0x370e8000, 0x370f4000, 0x37100000, 0x3710c000, 0x37118000, 0x37124000, 0x37130000, 0x3713c000, 0x37148000, 0x37154000, 0x37160000,
0x3716c000, 0x37178000, 0x37184000, 0x37190000, 0x3719c000, 0x371a8000, 0x371b4000, 0x371c0000, 0x371cc000, 0x371d8000, 0x371e4000, 0x371f0000, 0x371fc000, 0x37208000, 0x37214000, 0x37220000,
0x3722c000, 0x37238000, 0x37244000, 0x37250000, 0x3725c000, 0x37268000, 0x37274000, 0x37280000, 0x3728c000, 0x37298000, 0x372a4000, 0x372b0000, 0x372bc000, 0x372c8000, 0x372d4000, 0x372e0000,
0x372ec000, 0x372f8000, 0x37304000, 0x37310000, 0x3731c000, 0x37328000, 0x37334000, 0x37340000, 0x3734c000, 0x37358000, 0x37364000, 0x37370000, 0x3737c000, 0x37388000, 0x37394000, 0x373a0000,
0x373ac000, 0x373b8000, 0x373c4000, 0x373d0000, 0x373dc000, 0x373e8000, 0x373f4000, 0x37400000, 0x3740c000, 0x37418000, 0x37424000, 0x37430000, 0x3743c000, 0x37448000, 0x37454000, 0x37460000,
0x3746c000, 0x37478000, 0x37484000, 0x37490000, 0x3749c000, 0x374a8000, 0x374b4000, 0x374c0000, 0x374cc000, 0x374d8000, 0x374e4000, 0x374f0000, 0x374fc000, 0x37508000, 0x37514000, 0x37520000,
0x3752c000, 0x37538000, 0x37544000, 0x37550000, 0x3755c000, 0x37568000, 0x37574000, 0x37580000, 0x3758c000, 0x37598000, 0x375a4000, 0x375b0000, 0x375bc000, 0x375c8000, 0x375d4000, 0x375e0000,
0x375ec000, 0x375f8000, 0x37604000, 0x37610000, 0x3761c000, 0x37628000, 0x37634000, 0x37640000, 0x3764c000, 0x37658000, 0x37664000, 0x37670000, 0x3767c000, 0x37688000, 0x37694000, 0x376a0000,
0x376ac000, 0x376b8000, 0x376c4000, 0x376d0000, 0x376dc000, 0x376e8000, 0x376f4000, 0x37700000, 0x3770c000, 0x37718000, 0x37724000, 0x37730000, 0x3773c000, 0x37748000, 0x37754000, 0x37760000,
0x3776c000, 0x37778000, 0x37784000, 0x37790000, 0x3779c000, 0x377a8000, 0x377b4000, 0x377c0000, 0x377cc000, 0x377d8000, 0x377e4000, 0x377f0000, 0x377fc000, 0x37808000, 0x37814000, 0x37820000,
0x3782c000, 0x37838000, 0x37844000, 0x37850000, 0x3785c000, 0x37868000, 0x37874000, 0x37880000, 0x3788c000, 0x37898000, 0x378a4000, 0x378b0000, 0x378bc000, 0x378c8000, 0x378d4000, 0x378e0000,
0x378ec000, 0x378f8000, 0x37904000, 0x37910000, 0x3791c000, 0x37928000, 0x37934000, 0x37940000, 0x3794c000, 0x37958000, 0x37964000, 0x37970000, 0x3797c000, 0x37988000, 0x37994000, 0x379a0000,
0x379ac000, 0x379b8000, 0x379c4000, 0x379d0000, 0x379dc000, 0x379e8000, 0x379f4000, 0x37a00000, 0x37a0c000, 0x37a18000, 0x37a24000, 0x37a30000, 0x37a3c000, 0x37a48000, 0x37a54000, 0x37a60000,
0x37a6c000, 0x37a78000, 0x37a84000, 0x37a90000, 0x37a9c000, 0x37aa8000, 0x37ab4000, 0x37ac0000, 0x37acc000, 0x37ad8000, 0x37ae4000, 0x37af0000, 0x37afc000, 0x37b08000, 0x37b14000, 0x37b20000,
0x37b2c000, 0x37b38000, 0x37b44000, 0x37b50000, 0x37b5c000, 0x37b68000, 0x37b74000, 0x37b80000, 0x37b8c000, 0x37b98000, 0x37ba4000, 0x37bb0000, 0x37bbc000, 0x37bc8000, 0x37bd4000, 0x37be0000,
0x37bec000, 0x37bf8000, 0x37c04000, 0x37c10000, 0x37c1c000, 0x37c28000, 0x37c34000, 0x37c40000, 0x37c4c000, 0x37c58000, 0x37c64000, 0x37c70000, 0x37c7c000, 0x37c88000, 0x37c94000, 0x37ca0000,
0x37cad800, 0x37cbb000, 0x37cc8800, 0x37cd6000, 0x37ce3800, 0x37cf1000, 0x37cfe800, 0x37d0c000, 0x37d19800, 0x37d27000, 0x37d34800, 0x37d42000, 0x37d4f800, 0x37d5d000, 0x37d6a800, 0x37d78000,
0x37d85800, 0x37d93000, 0x37da0800, 0x37dae000, 0x37dbb800, 0x37dc9000, 0x37dd6800, 0x37de4000, 0x37df1800, 0x37dff000, 0x37e0c800, 0x37e1a000, 0x37e27800, 0x37e35000, 0x37e42800, 0x37e50000,
0x37e5d800, 0x37e6b000, 0x37e78800, 0x37e86000, 0x37e93800, 0x37ea1000, 0x37eae800, 0x37ebc000, 0x37ec9800, 0x37ed7000, 0x37ee4800, 0x37ef2000, 0x37eff800, 0x37f0d000, 0x37f1a800, 0x37f28000,
0x37f35800, 0x37f43000, 0x37f50800, 0x37f5e000, 0x37f6b800, 0x37f79000, 0x37f86800, 0x37f94000, 0x37fa1800, 0x37faf000, 0x37fbc800, 0x37fca000, 0x37fd7800, 0x37fe5000, 0x37ff2800, 0x38000000,
0x3800d800, 0x3801b000, 0x38028800, 0x38036000, 0x38043800, 0x38051000, 0x3805e800, 0x3806c000, 0x38079800, 0x38087000, 0x38094800, 0x380a2000, 0x380af800, 0x380bd000, 0x380ca800, 0x380d8000,
0x380e5800, 0x380f3000, 0x38100800, 0x3810e000, 0x3811b800, 0x38129000, 0x38136800, 0x38144000, 0x38151800, 0x3815f000, 0x3816c800, 0x3817a000, 0x38187800, 0x38195000, 0x381a2800, 0x381b0000,
0x381bd800, 0x381cb000, 0x381d8800, 0x381e6000, 0x381f3800, 0x38201000, 0x3820e800, 0x3821c000, 0x38229800, 0x38237000, 0x38244800, 0x38252000, 0x3825f800, 0x3826d000, 0x3827a800, 0x38288000,
0x38295800, 0x382a3000, 0x382b0800, 0x382be000, 0x382cb800, 0x382d9000, 0x382e6800, 0x382f4000, 0x38301800, 0x3830f000, 0x3831c800, 0x3832a000, 0x38337800, 0x38345000, 0x38352800, 0x38360000,
0x3836d800, 0x3837b000, 0x38388800, 0x38396000, 0x383a3800, 0x383b1000, 0x383be800, 0x383cc000, 0x383d9800, 0x383e7000, 0x383f4800, 0x38402000, 0x3840f800, 0x3841d000, 0x3842a800, 0x38438000,
0x38445800, 0x38453000, 0x38460800, 0x3846e000, 0x3847b800, 0x38489000, 0x38496800, 0x384a4000, 0x384b1800, 0x384bf000, 0x384cc800, 0x384da000, 0x384e7800, 0x384f5000, 0x38502800, 0x38510000,
0x3851d800, 0x3852b000, 0x38538800, 0x38546000, 0x38553800, 0x38561000, 0x3856e800, 0x3857c000, 0x38589800, 0x38597000, 0x385a4800, 0x385b2000, 0x385bf800, 0x385cd000, 0x385da800, 0x385e8000,
0x385f5800, 0x38603000, 0x38610800, 0x3861e000, 0x3862b800, 0x38639000, 0x38646800, 0x38654000, 0x38661800, 0x3866f000, 0x3867c800, 0x3868a000, 0x38697800, 0x386a5000, 0x386b2800, 0x386c0000,
0x386cd700, 0x386daf00, 0x386e8700, 0x386f5f00, 0x38703700, 0x38710f00, 0x3871e700, 0x3872bf00, 0x38739700, 0x38746f00, 0x38754700, 0x38761f00, 0x3876f700, 0x3877cf00, 0x3878a700, 0x38797f00,
0x387a5700, 0x387b2f00, 0x387c0700, 0x387cdf00, 0x387db700, 0x387e8f00, 0x387f6700, 0x38803f00, 0x38811700, 0x3881ef00, 0x3882c700, 0x38839f00, 0x38847700, 0x38854f00, 0x38862700, 0x3886ff00,
0x3887d700, 0x3888af00, 0x38898700, 0x388a5f00, 0x388b3700, 0x388c0f00, 0x388ce700, 0x388dbf00, 0x388e9700, 0x388f6f00, 0x38904700, 0x38911f00, 0x3891f700, 0x3892cf00, 0x3893a700, 0x38947f00,
0x38955700, 0x38962f00, 0x38970700, 0x3897df00, 0x3898b700, 0x38998f00, 0x389a6700, 0x389b3f00, 0x389c1700, 0x389cef00, 0x389dc700, 0x389e9f00, 0x389f7700, 0x38a04f00, 0x38a12700, 0x38a1ff00,
0x38a2d700, 0x38a3af00, 0x38a48700, 0x38a55f00, 0x38a63700, 0x38a70f00, 0x38a7e700, 0x38a8bf00, 0x38a99700, 0x38aa6f00, 0x38ab4700, 0x38ac1f00, 0x38acf700, 0x38adcf00, 0x38aea700, 0x38af7f00,
0x38b05700, 0x38b12f00, 0x38b20700, 0x38b2df00, 0x38b3b700, 0x38b48f00, 0x38b56700, 0x38b63f00, 0x38b71700, 0x38b7ef00, 0x38b8c700, 0x38b99f00, 0x38ba7700, 0x38bb4f00, 0x38bc2700, 0x38bcff00,
0x38bdd700, 0x38beaf00, 0x38bf8700, 0x38c05f00, 0x38c13700, 0x38c20f00, 0x38c2e700, 0x38c3bf00, 0x38c49700, 0x38c56f00, 0x38c64700, 0x38c71f00, 0x38c7f700, 0x38c8cf00, 0x38c9a700, 0x38ca7f00,
0x38cb5700, 0x38cc2f00, 0x38cd0700, 0x38cddf00, 0x38ceb700, 0x38cf8f00, 0x38d06700, 0x38d13f00, 0x38d21700, 0x38d2ef00, 0x38d3c700, 0x38d49f00, 0x38d57700, 0x38d64f00, 0x38d72700, 0x38d7ff00,
0x38d8d700, 0x38d9af00, 0x38da8700, 0x38db5f00, 0x38dc3700, 0x38dd0f00, 0x38dde700, 0x38debf00, 0x38df9700, 0x38e06f00, 0x38e14700, 0x38e21f00, 0x38e2f700, 0x38e3cf00, 0x38e4a700, 0x38e57f00,
0x38e65700, 0x38e72f00, 0x38e80700, 0x38e8df00, 0x38e9b700, 0x38ea8f00, 0x38eb6700, 0x38ec3f00, 0x38ed1700, 0x38edef00, 0x38eec700, 0x38ef9f00, 0x38f07700, 0x38f14f00, 0x38f22700, 0x38f2ff00,
0x38f3d700, 0x38f4af00, 0x38f58700, 0x38f65f00, 0x38f73700, 0x38f80f00, 0x38f8e700, 0x38f9bf00, 0x38fa9700, 0x38fb6f00, 0x38fc4700, 0x38fd1f00, 0x38fdf700, 0x38fecf00, 0x38ffa700, 0x39007f00,
0x39015700, 0x39022f00, 0x39030700, 0x3903df00, 0x3904b700, 0x39058f00, 0x39066700, 0x39073f00, 0x39081700, 0x3908ef00, 0x3909c700, 0x390a9f00, 0x390b7700, 0x390c4f00, 0x390d2700, 0x390dff00,
0x390ed700, 0x390faf00, 0x39108700, 0x39115f00, 0x39123700, 0x39130f00, 0x3913e700, 0x3914bf00, 0x39159700, 0x39166f00, 0x39174700, 0x39181f00, 0x3918f700, 0x3919cf00, 0x391aa700, 0x391b7f00,
0x391c5700, 0x391d2f00, 0x391e0700, 0x391edf00, 0x391fb700, 0x39208f00, 0x39216700, 0x39223f00, 0x39231700, 0x3923ef00, 0x3924c700, 0x39259f00, 0x39267700, 0x39274f00, 0x39282700, 0x3928ff00,
0x3929d700, 0x392aaf00, 0x392b8700, 0x392c5f00, 0x392d3700, 0x392e0f00, 0x392ee700, 0x392fbf00, 0x39309700, 0x39316f00, 0x39324700, 0x39331f00, 0x3933f700, 0x3934cf00, 0x3935a700, 0x39367f00,
0x39375700, 0x39382f00, 0x39390700, 0x3939df00, 0x393ab700, 0x393b8f00, 0x393c6700, 0x393d3f00, 0x393e1700, 0x393eef00, 0x393fc700, 0x39409f00, 0x39417700, 0x39424f00, 0x39432700, 0x3943ff00,
0x3944d700, 0x3945af00, 0x39468700, 0x39475f00, 0x39483700, 0x39490f00, 0x3949e700, 0x394abf00, 0x394b9700, 0x394c6f00, 0x394d4700, 0x394e1f00, 0x394ef700, 0x394fcf00, 0x3950a700, 0x39517f00,
0x39525700, 0x39532f00, 0x39540700, 0x3954df00, 0x3955b700, 0x39568f00, 0x39576700, 0x39583f00, 0x39591700, 0x3959ef00, 0x395ac700, 0x395b9f00, 0x395c7700, 0x395d4f00, 0x395e2700, 0x395eff00,
0x395fd700, 0x3960af00, 0x39618700, 0x39625f00, 0x39633700, 0x39640f00, 0x3964e700, 0x3965bf00, 0x39669700, 0x39676f00, 0x39684700, 0x39691f00, 0x3969f700, 0x396acf00, 0x396ba700, 0x396c7f00,
0x396d5700, 0x396e2f00, 0x396f0700, 0x396fdf00, 0x3970b700, 0x39718f00, 0x39726700, 0x39733f00, 0x39741700, 0x3974ef00, 0x3975c700, 0x39769f00, 0x39777700, 0x39784f00, 0x39792700, 0x3979ff00,
0x397ae900, 0x397bd300, 0x397cbd00, 0x397da700, 0x397e9100, 0x397f7b00, 0x39806500, 0x39814f00, 0x39823900, 0x39832300, 0x39840d00, 0x3984f700, 0x3985e100, 0x3986cb00, 0x3987b500, 0x39889f00,
0x39898900, 0x398a7300, 0x398b5d00, 0x398c4700, 0x398d3100, 0x398e1b00, 0x398f0500, 0x398fef00, 0x3990d900, 0x3991c300, 0x3992ad00, 0x39939700, 0x39948100, 0x39956b00, 0x39965500, 0x39973f00,
0x39982900, 0x39991300, 0x3999fd00, 0x399ae700, 0x399bd100, 0x399cbb00, 0x399da500, 0x399e8f00, 0x399f7900, 0x39a06300, 0x39a14d00, 0x39a23700, 0x39a32100, 0x39a40b00, 0x39a4f500, 0x39a5df00,
0x39a6c900, 0x39a7b300, 0x39a89d00, 0x39a98700, 0x39aa7100, 0x39ab5b00, 0x39ac4500, 0x39ad2f00, 0x39ae1900, 0x39af0300, 0x39afed00, 0x39b0d700, 0x39b1c100, 0x39b2ab00, 0x39b39500, 0x39b47f00,
0x39b56900, 0x39b65300, 0x39b73d00, 0x39b82700, 0x39b91100, 0x39b9fb00, 0x39bae500, 0x39bbcf00, 0x39bcb900, 0x39bda300, 0x39be8d00, 0x39bf7700, 0x39c06100, 0x39c14b00, 0x39c23500, 0x39c31f00,
0x39c40900, 0x39c4f300, 0x39c5dd00, 0x39c6c700, 0x39c7b100, 0x39c89b00, 0x39c98500, 0x39ca6f00, 0x39cb5900, 0x39cc4300, 0x39cd2d00, 0x39ce1700, 0x39cf0100, 0x39cfeb00, 0x39d0d500, 0x39d1bf00,
0x39d2a900, 0x39d39300, 0x39d47d00, 0x39d56700, 0x39d65100, 0x39d73b00, 0x39d82500, 0x39d90f00, 0x39d9f900, 0x39dae300, 0x39dbcd00, 0x39dcb700, 0x39dda100, 0x39de8b00, 0x39df7500, 0x39e05f00,
0x39e14900, 0x39e23300, 0x39e31d00, 0x39e40700, 0x39e4f100, 0x39e5db00, 0x39e6c500, 0x39e7af00, 0x39e89900, 0x39e98300, 0x39ea6d00, 0x39eb5700, 0x39ec4100, 0x39ed2b00, 0x39ee1500, 0x39eeff00,
0x39efe900, 0x39f0d300, 0x39f1bd00, 0x39f2a700, 0x39f39100, 0x39f47b00, 0x39f56500, 0x39f64f00, 0x39f73900, 0x39f82300, 0x39f90d00, 0x39f9f700, 0x39fae100, 0x39fbcb00, 0x39fcb500, 0x39fd9f00,
0x39fe8900, 0x39ff7300, 0x3a005d00, 0x3a014700, 0x3a023100, 0x3a031b00, 0x3a040500, 0x3a04ef00, 0x3a05d900, 0x3a06c300, 0x3a07ad00, 0x3a089700, 0x3a098100, 0x3a0a6b00, 0x3a0b5500, 0x3a0c3f00,
0x3a0d2900, 0x3a0e1300, 0x3a0efd00, 0x3a0fe700, 0x3a10d100, 0x3a11bb00, 0x3a12a500, 0x3a138f00, 0x3a147900, 0x3a156300, 0x3a164d00, 0x3a173700, 0x3a182100, 0x3a190b00, 0x3a19f500, 0x3a1adf00,
0x3a1bc900, 0x3a1cb300, 0x3a1d9d00, 0x3a1e8700, 0x3a1f7100, 0x3a205b00, 0x3a214500, 0x3a222f00, 0x3a231900, 0x3a240300, 0x3a24ed00, 0x3a25d700, 0x3a26c100, 0x3a27ab00, 0x3a289500, 0x3a297f00,
0x3a2a6900, 0x3a2b5300, 0x3a2c3d00, 0x3a2d2700, 0x3a2e1100, 0x3a2efb00, 0x3a2fe500, 0x3a30cf00, 0x3a31b900, 0x3a32a300, 0x3a338d00, 0x3a347700, 0x3a356100, 0x3a364b00, 0x3a373500, 0x3a381f00,
0x3a390900, 0x3a39f300, 0x3a3add00, 0x3a3bc700, 0x3a3cb100, 0x3a3d9b00, 0x3a3e8500, 0x3a3f6f00, 0x3a405900, 0x3a414300, 0x3a422d00, 0x3a431700, 0x3a440100, 0x3a44eb00, 0x3a45d500, 0x3a46bf00,
0x3a47a900, 0x3a489300, 0x3a497d00, 0x3a4a6700, 0x3a4b5100, 0x3a4c3b00, 0x3a4d2500, 0x3a4e0f00, 0x3a4ef900, 0x3a4fe300, 0x3a50cd00, 0x3a51b700, 0x3a52a100, 0x3a538b00, 0x3a547500, 0x3a555f00,
0x3a564900, 0x3a573300, 0x3a581d00, 0x3a590700, 0x3a59f100, 0x3a5adb00, 0x3a5bc500, 0x3a5caf00, 0x3a5d9900, 0x3a5e8300, 0x3a5f6d00, 0x3a605700, 0x3a614100, 0x3a622b00, 0x3a631500, 0x3a63ff00,
0x3a64e900, 0x3a65d300, 0x3a66bd00, 0x3a67a700, 0x3a689100, 0x3a697b00, 0x3a6a6500, 0x3a6b4f00, 0x3a6c3900, 0x3a6d2300, 0x3a6e0d00, 0x3a6ef700, 0x3a6fe100, 0x3a70cb00, 0x3a71b500, 0x3a729f00,
0x3a738900, 0x3a747300, 0x3a755d00, 0x3a764700, 0x3a773100, 0x3a781b00, 0x3a790500, 0x3a79ef00, 0x3a7ad900, 0x3a7bc300, 0x3a7cad00, 0x3a7d9700, 0x3a7e8100, 0x3a7f6b00, 0x3a805500, 0x3a813f00,
0x3a822900, 0x3a831300, 0x3a83fd00, 0x3a84e700, 0x3a85d100, 0x3a86bb00, 0x3a87a500, 0x3a888f00, 0x3a897900, 0x3a8a6300, 0x3a8b4d00, 0x3a8c3700, 0x3a8d2100, 0x3a8e0b00, 0x3a8ef500, 0x3a8fdf00,
0x3a90c900, 0x3a91b300, 0x3a929d00, 0x3a938700, 0x3a947100, 0x3a955b00, 0x3a964500, 0x3a972f00, 0x3a981900, 0x3a990300, 0x3a99ed00, 0x3a9ad700, 0x3a9bc100, 0x3a9cab00, 0x3a9d9500, 0x3a9e7f00,
0x3a9f6900, 0x3aa05300, 0x3aa13d00, 0x3aa22700, 0x3aa31100, 0x3aa3fb00, 0x3aa4e500, 0x3aa5cf00, 0x3aa6b900, 0x3aa7a300, 0x3aa88d00, 0x3aa97700, 0x3aaa6100, 0x3aab4b00, 0x3aac3500, 0x3aad1f00,
0x3aae0900, 0x3aaef300, 0x3aafdd00, 0x3ab0c700, 0x3ab1b100, 0x3ab29b00, 0x3ab38500, 0x3ab46f00, 0x3ab55900, 0x3ab64300, 0x3ab72d00, 0x3ab81700, 0x3ab90100, 0x3ab9eb00, 0x3abad500, 0x3abbbf00,
0x3abca900, 0x3abd9300, 0x3abe7d00, 0x3abf6700, 0x3ac05100, 0x3ac13b00, 0x3ac22500, 0x3ac30f00, 0x3ac3f900, 0x3ac4e300, 0x3ac5cd00, 0x3ac6b700, 0x3ac7a100, 0x3ac88b00, 0x3ac97500, 0x3aca5f00,
0x3acb4900, 0x3acc3300, 0x3acd1d00, 0x3ace0700, 0x3acef100, 0x3acfdb00, 0x3ad0c500, 0x3ad1af00, 0x3ad29900, 0x3ad38300, 0x3ad46d00, 0x3ad55700, 0x3ad64100, 0x3ad72b00, 0x3ad81500, 0x3ad8ff00,
0x3ad9e900, 0x3adad300, 0x3adbbd00, 0x3adca700, 0x3add9100, 0x3ade7b00, 0x3adf6500, 0x3ae04f00, 0x3ae13900, 0x3ae22300, 0x3ae30d00, 0x3ae3f700, 0x3ae4e100, 0x3ae5cb00, 0x3ae6b500, 0x3ae79f00,
0x3ae88900, 0x3ae97300, 0x3aea5d00, 0x3aeb4700, 0x3aec3100, 0x3aed1b00, 0x3aee0500, 0x3aeeef00, 0x3aefd900, 0x3af0c300, 0x3af1ad00, 0x3af29700, 0x3af38100, 0x3af46b00, 0x3af55500, 0x3af63f00,
0x3af72900, 0x3af81300, 0x3af8fd00, 0x3af9e700, 0x3afad100, 0x3afbbb00, 0x3afca500, 0x3afd8f00, 0x3afe7900, 0x3aff6300, 0x3b004e00, 0x3b013800, 0x3b022200, 0x3b030c00, 0x3b03f600, 0x3b04e000,
0x3b05ca00, 0x3b06b400, 0x3b079e00, 0x3b088800, 0x3b097200, 0x3b0a5c00, 0x3b0b4600, 0x3b0c3000, 0x3b0d1a00, 0x3b0e0400, 0x3b0eee00, 0x3b0fd800, 0x3b10c200, 0x3b11ac00, 0x3b129600, 0x3b138000,
0x3b146a00, 0x3b155400, 0x3b163e00, 0x3b172800, 0x3b181200, 0x3b18fc00, 0x3b19e600, 0x3b1ad000, 0x3b1bba00, 0x3b1ca400, 0x3b1d8e00, 0x3b1e7800, 0x3b1f6200, 0x3b204c00, 0x3b213600, 0x3b222000,
0x3b230a00, 0x3b23f400, 0x3b24de00, 0x3b25c800, 0x3b26b200, 0x3b279c00, 0x3b288600, 0x3b297000, 0x3b2a5a00, 0x3b2b4400, 0x3b2c2e00, 0x3b2d1800, 0x3b2e0200, 0x3b2eec00, 0x3b2fd600, 0x3b30c000,
0x3b31aa00, 0x3b329400, 0x3b337e00, 0x3b346800, 0x3b355200, 0x3b363c00, 0x3b372600, 0x3b381000, 0x3b38fa00, 0x3b39e400, 0x3b3ace00, 0x3b3bb800, 0x3b3ca200, 0x3b3d8c00, 0x3b3e7600, 0x3b3f6000,
0x3b404a00, 0x3b413400, 0x3b421e00, 0x3b430800, 0x3b43f200, 0x3b44dc00, 0x3b45c600, 0x3b46b000, 0x3b479a00, 0x3b488400, 0x3b496e00, 0x3b4a5800, 0x3b4b4200, 0x3b4c2c00, 0x3b4d1600, 0x3b4e0000,
0x3b4f0000, 0x3b500000, 0x3b510000, 0x3b520000, 0x3b530000, 0x3b540000, 0x3b550000, 0x3b560000, 0x3b570000, 0x3b580000, 0x3b590000, 0x3b5a0000, 0x3b5b0000, 0x3b5c0000, 0x3b5d0000, 0x3b5e0000,
0x3b5f0000, 0x3b600000, 0x3b610000, 0x3b620000, 0x3b630000, 0x3b640000, 0x3b650000, 0x3b660000, 0x3b670000, 0x3b680000, 0x3b690000, 0x3b6a0000, 0x3b6b0000, 0x3b6c0000, 0x3b6d0000, 0x3b6e0000,
0x3b6f0000, 0x3b700000, 0x3b710000, 0x3b720000, 0x3b730000, 0x3b740000, 0x3b750000, 0x3b760000, 0x3b770000, 0x3b780000, 0x3b790000, 0x3b7a0000, 0x3b7b0000, 0x3b7c0000, 0x3b7d0000, 0x3b7e0000,
0x3b7f0000, 0x3b800000, 0x3b810000, 0x3b820000, 0x3b830000, 0x3b840000, 0x3b850000, 0x3b860000, 0x3b870000, 0x3b880000, 0x3b890000, 0x3b8a0000, 0x3b8b0000, 0x3b8c0000, 0x3b8d0000, 0x3b8e0000,
0x3b8f0000, 0x3b900000, 0x3b910000, 0x3b920000, 0x3b930000, 0x3b940000, 0x3b950000, 0x3b960000, 0x3b970000, 0x3b980000, 0x3b990000, 0x3b9a0000, 0x3b9b0000, 0x3b9c0000, 0x3b9d0000, 0x3b9e0000,
0x3b9f0000, 0x3ba00000, 0x3ba10000, 0x3ba20000, 0x3ba30000, 0x3ba40000, 0x3ba50000, 0x3ba60000, 0x3ba70000, 0x3ba80000, 0x3ba90000, 0x3baa0000, 0x3bab0000, 0x3bac0000, 0x3bad0000, 0x3bae0000,
0x3baf0000, 0x3bb00000, 0x3bb10000, 0x3bb20000, 0x3bb30000, 0x3bb40000, 0x3bb50000, 0x3bb60000, 0x3bb70000, 0x3bb80000, 0x3bb90000, 0x3bba0000, 0x3bbb0000, 0x3bbc0000, 0x3bbd0000, 0x3bbe0000,
0x3bbf0000, 0x3bc00000, 0x3bc10000, 0x3bc20000, 0x3bc30000, 0x3bc40000, 0x3bc50000, 0x3bc60000, 0x3bc70000, 0x3bc80000, 0x3bc90000, 0x3bca0000, 0x3bcb0000, 0x3bcc0000, 0x3bcd0000, 0x3bce0000,
0x3bcf0000, 0x3bd00000, 0x3bd10000, 0x3bd20000, 0x3bd30000, 0x3bd40000, 0x3bd50000, 0x3bd60000, 0x3bd70000, 0x3bd80000, 0x3bd90000, 0x3bda0000, 0x3bdb0000, 0x3bdc0000, 0x3bdd0000, 0x3bde0000,
0x3bdf0000, 0x3be00000, 0x3be10000, 0x3be20000, 0x3be30000, 0x3be40000, 0x3be50000, 0x3be60000, 0x3be70000, 0x3be80000, 0x3be90000, 0x3bea0000, 0x3beb0000, 0x3bec0000, 0x3bed0000, 0x3bee0000,
0x3bef0000, 0x3bf00000, 0x3bf10000, 0x3bf20000, 0x3bf30000, 0x3bf40000, 0x3bf50000, 0x3bf60000, 0x3bf70000, 0x3bf80000, 0x3bf90000, 0x3bfa0000, 0x3bfb0000, 0x3bfc0000, 0x3bfd0000, 0x3bfe0000,
0x3bff0000, 0x3c000000, 0x3c010000, 0x3c020000, 0x3c030000, 0x3c040000, 0x3c050000, 0x3c060000, 0x3c070000, 0x3c080000, 0x3c090000, 0x3c0a0000, 0x3c0b0000, 0x3c0c0000, 0x3c0d0000, 0x3c0e0000,
0x3c0f0000, 0x3c100000, 0x3c110000, 0x3c120000, 0x3c130000, 0x3c140000, 0x3c150000, 0x3c160000, 0x3c170000, 0x3c180000, 0x3c190000, 0x3c1a0000, 0x3c1b0000, 0x3c1c0000, 0x3c1d0000, 0x3c1e0000,
0x3c1f0000, 0x3c200000, 0x3c210000, 0x3c220000, 0x3c230000, 0x3c240000, 0x3c250000, 0x3c260000, 0x3c270000, 0x3c280000, 0x3c290000, 0x3c2a0000, 0x3c2b0000, 0x3c2c0000, 0x3c2d0000, 0x3c2e0000,
0x3c2f0000, 0x3c300000, 0x3c310000, 0x3c320000, 0x3c330000, 0x3c340000, 0x3c350000, 0x3c360000, 0x3c370000, 0x3c380000, 0x3c390000, 0x3c3a0000, 0x3c3b0000, 0x3c3c0000, 0x3c3d0000, 0x3c3e0000,
0x3c3f0000, 0x3c400000, 0x3c410000, 0x3c420000, 0x3c430000, 0x3c440000, 0x3c450000, 0x3c460000, 0x3c470000, 0x3c480000, 0x3c490000, 0x3c4a0000, 0x3c4b0000, 0x3c4c0000, 0x3c4d0000, 0x3c4e0000,
0x3c4f0000, 0x3c500000, 0x3c510000, 0x3c520000, 0x3c530000, 0x3c540000, 0x3c550000, 0x3c560000, 0x3c570000, 0x3c580000, 0x3c590000, 0x3c5a0000, 0x3c5b0000, 0x3c5c0000, 0x3c5d0000, 0x3c5e0000,
0x3c5f0000, 0x3c600000, 0x3c610000, 0x3c620000, 0x3c630000, 0x3c640000, 0x3c650000, 0x3c660000, 0x3c670000, 0x3c680000, 0x3c690000, 0x3c6a0000, 0x3c6b0000, 0x3c6c0000, 0x3c6d0000, 0x3c6e0000,
0x3c6f0000, 0x3c700000, 0x3c710000, 0x3c720000, 0x3c730000, 0x3c740000, 0x3c750000, 0x3c760000, 0x3c770000, 0x3c780000, 0x3c790000, 0x3c7a0000, 0x3c7b0000, 0x3c7c0000, 0x3c7d0000, 0x3c7e0000,
0x3c7f0000, 0x3c800000, 0x3c810000, 0x3c820000, 0x3c830000, 0x3c840000, 0x3c850000, 0x3c860000, 0x3c870000, 0x3c880000, 0x3c890000, 0x3c8a0000, 0x3c8b0000, 0x3c8c0000, 0x3c8d0000, 0x3c8e0000,
0x3c8f0000, 0x3c900000, 0x3c910000, 0x3c920000, 0x3c930000, 0x3c940000, 0x3c950000, 0x3c960000, 0x3c970000, 0x3c980000, 0x3c990000, 0x3c9a0000, 0x3c9b0000, 0x3c9c0000, 0x3c9d0000, 0x3c9e0000,
0x3c9f0000, 0x3ca00000, 0x3ca10000, 0x3ca20000, 0x3ca30000, 0x3ca40000, 0x3ca50000, 0x3ca60000, 0x3ca70000, 0x3ca80000, 0x3ca90000, 0x3caa0000, 0x3cab0000, 0x3cac0000, 0x3cad0000, 0x3cae0000,
0x3caf0000, 0x3cb00000, 0x3cb10000, 0x3cb20000, 0x3cb30000, 0x3cb40000, 0x3cb50000, 0x3cb60000, 0x3cb70000, 0x3cb80000, 0x3cb90000, 0x3cba0000, 0x3cbb0000, 0x3cbc0000, 0x3cbd0000, 0x3cbe0000,
0x3cbf0000, 0x3cc00000, 0x3cc10000, 0x3cc20000, 0x3cc30000, 0x3cc40000, 0x3cc50000, 0x3cc60000, 0x3cc70000, 0x3cc80000, 0x3cc90000, 0x3cca0000, 0x3ccb0000, 0x3ccc0000, 0x3ccd0000, 0x3cce0000,
0x3ccf0000, 0x3cd00000, 0x3cd10000, 0x3cd20000, 0x3cd30000, 0x3cd40000, 0x3cd50000, 0x3cd60000, 0x3cd70000, 0x3cd80000, 0x3cd90000, 0x3cda0000, 0x3cdb0000, 0x3cdc0000, 0x3cdd0000, 0x3cde0000,
0x3cdf0000, 0x3ce00000, 0x3ce10000, 0x3ce20000, 0x3ce30000, 0x3ce40000, 0x3ce50000, 0x3ce60000, 0x3ce70000, 0x3ce80000, 0x3ce90000, 0x3cea0000, 0x3ceb0000, 0x3cec0000, 0x3ced0000, 0x3cee0000,
0x3cef0000, 0x3cf00000, 0x3cf10000, 0x3cf20000, 0x3cf30000, 0x3cf40000, 0x3cf50000, 0x3cf60000, 0x3cf70000, 0x3cf80000, 0x3cf90000, 0x3cfa0000, 0x3cfb0000, 0x3cfc0000, 0x3cfd0000, 0x3cfe0000,
0x3cff0000, 0x3d000000, 0x3d010000, 0x3d020000, 0x3d030000, 0x3d040000, 0x3d050000, 0x3d060000, 0x3d070000, 0x3d080000, 0x3d090000, 0x3d0a0000, 0x3d0b0000, 0x3d0c0000, 0x3d0d0000, 0x3d0e0000,
0x3d0f0000, 0x3d100000, 0x3d110000, 0x3d120000, 0x3d130000, 0x3d140000, 0x3d150000, 0x3d160000, 0x3d170000, 0x3d180000, 0x3d190000, 0x3d1a0000, 0x3d1b0000, 0x3d1c0000, 0x3d1d0000, 0x3d1e0000,
0x3d1f0000, 0x3d200000, 0x3d210000, 0x3d220000, 0x3d230000, 0x3d240000, 0x3d250000, 0x3d260000, 0x3d270000, 0x3d280000, 0x3d290000, 0x3d2a0000, 0x3d2b0000, 0x3d2c0000, 0x3d2d0000, 0x3d2e0000,
0x3d2f0000, 0x3d300000, 0x3d310000, 0x3d320000, 0x3d330000, 0x3d340000, 0x3d350000, 0x3d360000, 0x3d370000, 0x3d380000, 0x3d390000, 0x3d3a0000, 0x3d3b0000, 0x3d3c0000, 0x3d3d0000, 0x3d3e0000,
0x3d3f0000, 0x3d400000, 0x3d410000, 0x3d420000, 0x3d430000, 0x3d440000, 0x3d450000, 0x3d460000, 0x3d470000, 0x3d480000, 0x3d490000, 0x3d4a0000, 0x3d4b0000, 0x3d4c0000, 0x3d4d0000, 0x3d4e0000,
0x3d4f2200, 0x3d504400, 0x3d516600, 0x3d528800, 0x3d53aa00, 0x3d54cc00, 0x3d55ee00, 0x3d571000, 0x3d583200, 0x3d595400, 0x3d5a7600, 0x3d5b9800, 0x3d5cba00, 0x3d5ddc00, 0x3d5efe00, 0x3d602000,
0x3d614200, 0x3d626400, 0x3d638600, 0x3d64a800, 0x3d65ca00, 0x3d66ec00, 0x3d680e00, 0x3d693000, 0x3d6a5200, 0x3d6b7400, 0x3d6c9600, 0x3d6db800, 0x3d6eda00, 0x3d6ffc00, 0x3d711e00, 0x3d724000,
0x3d736200, 0x3d748400, 0x3d75a600, 0x3d76c800, 0x3d77ea00, 0x3d790c00, 0x3d7a2e00, 0x3d7b5000, 0x3d7c7200, 0x3d7d9400, 0x3d7eb600, 0x3d7fd800, 0x3d80fa00, 0x3d821c00, 0x3d833e00, 0x3d846000,
0x3d858200, 0x3d86a400, 0x3d87c600, 0x3d88e800, 0x3d8a0a00, 0x3d8b2c00, 0x3d8c4e00, 0x3d8d7000, 0x3d8e9200, 0x3d8fb400, 0x3d90d600, 0x3d91f800, 0x3d931a00, 0x3d943c00, 0x3d955e00, 0x3d968000,
0x3d97a200, 0x3d98c400, 0x3d99e600, 0x3d9b0800, 0x3d9c2a00, 0x3d9d4c00, 0x3d9e6e00, 0x3d9f9000, 0x3da0b200, 0x3da1d400, 0x3da2f600, 0x3da41800, 0x3da53a00, 0x3da65c00, 0x3da77e00, 0x3da8a000,
0x3da9c200, 0x3daae400, 0x3dac0600, 0x3dad2800, 0x3dae4a00, 0x3daf6c00, 0x3db08e00, 0x3db1b000, 0x3db2d200, 0x3db3f400, 0x3db51600, 0x3db63800, 0x3db75a00, 0x3db87c00, 0x3db99e00, 0x3dbac000,
0x3dbbe200, 0x3dbd0400, 0x3dbe2600, 0x3dbf4800, 0x3dc06a00, 0x3dc18c00, 0x3dc2ae00, 0x3dc3d000, 0x3dc4f200, 0x3dc61400, 0x3dc73600, 0x3dc85800, 0x3dc97a00, 0x3dca9c00, 0x3dcbbe00, 0x3dcce000,
0x3dce0200, 0x3dcf2400, 0x3dd04600, 0x3dd16800, 0x3dd28a00, 0x3dd3ac00, 0x3dd4ce00, 0x3dd5f000, 0x3dd71200, 0x3dd83400, 0x3dd95600, 0x3dda7800, 0x3ddb9a00, 0x3ddcbc00, 0x3dddde00, 0x3ddf0000,
0x3de02200, 0x3de14400, 0x3de26600, 0x3de38800, 0x3de4aa00, 0x3de5cc00, 0x3de6ee00, 0x3de81000, 0x3de93200, 0x3dea5400, 0x3deb7600, 0x3dec9800, 0x3dedba00, 0x3deedc00, 0x3deffe00, 0x3df12000,
0x3df24200, 0x3df36400, 0x3df48600, 0x3df5a800, 0x3df6ca00, 0x3df7ec00, 0x3df90e00, 0x3dfa3000, 0x3dfb5200, 0x3dfc7400, 0x3dfd9600, 0x3dfeb800, 0x3dffda00, 0x3e00fc00, 0x3e021e00, 0x3e034000,
0x3e046200, 0x3e058400, 0x3e06a600, 0x3e07c800, 0x3e08ea00, 0x3e0a0c00, 0x3e0b2e00, 0x3e0c5000, 0x3e0d7200, 0x3e0e9400, 0x3e0fb600, 0x3e10d800, 0x3e11fa00, 0x3e131c00, 0x3e143e00, 0x3e156000,
0x3e168200, 0x3e17a400, 0x3e18c600, 0x3e19e800, 0x3e1b0a00, 0x3e1c2c00, 0x3e1d4e00, 0x3e1e7000, 0x3e1f9200, 0x3e20b400, 0x3e21d600, 0x3e22f800, 0x3e241a00, 0x3e253c00, 0x3e265e00, 0x3e278000,
0x3e28a200, 0x3e29c400, 0x3e2ae600, 0x3e2c0800, 0x3e2d2a00, 0x3e2e4c00, 0x3e2f6e00, 0x3e309000, 0x3e31b200, 0x3e32d400, 0x3e33f600, 0x3e351800, 0x3e363a00, 0x3e375c00, 0x3e387e00, 0x3e39a000,
0x3e3ac200, 0x3e3be400, 0x3e3d0600, 0x3e3e2800, 0x3e3f4a00, 0x3e406c00, 0x3e418e00, 0x3e42b000, 0x3e43d200, 0x3e44f400, 0x3e461600, 0x3e473800, 0x3e485a00, 0x3e497c00, 0x3e4a9e00, 0x3e4bc000,
0x3e4ce200, 0x3e4e0400, 0x3e4f2600, 0x3e504800, 0x3e516a00, 0x3e528c00, 0x3e53ae00, 0x3e54d000, 0x3e55f200, 0x3e571400, 0x3e583600, 0x3e595800, 0x3e5a7a00, 0x3e5b9c00, 0x3e5cbe00, 0x3e5de000,
0x3e5f0200, 0x3e602400, 0x3e614600, 0x3e626800, 0x3e638a00, 0x3e64ac00, 0x3e65ce00, 0x3e66f000, 0x3e681200, 0x3e693400, 0x3e6a5600, 0x3e6b7800, 0x3e6c9a00, 0x3e6dbc00, 0x3e6ede00, 0x3e700000,
0x3e712100, 0x3e724300, 0x3e736500, 0x3e748700, 0x3e75a900, 0x3e76cb00, 0x3e77ed00, 0x3e790f00, 0x3e7a3100, 0x3e7b5300, 0x3e7c7500, 0x3e7d9700, 0x3e7eb900, 0x3e7fdb00, 0x3e80fd00, 0x3e821f00,
0x3e834100, 0x3e846300, 0x3e858500, 0x3e86a700, 0x3e87c900, 0x3e88eb00, 0x3e8a0d00, 0x3e8b2f00, 0x3e8c5100, 0x3e8d7300, 0x3e8e9500, 0x3e8fb700, 0x3e90d900, 0x3e91fb00, 0x3e931d00, 0x3e943f00,
0x3e956100, 0x3e968300, 0x3e97a500, 0x3e98c700, 0x3e99e900, 0x3e9b0b00, 0x3e9c2d00, 0x3e9d4f00, 0x3e9e7100, 0x3e9f9300, 0x3ea0b500, 0x3ea1d700, 0x3ea2f900, 0x3ea41b00, 0x3ea53d00, 0x3ea65f00,
0x3ea78100, 0x3ea8a300, 0x3ea9c500, 0x3eaae700, 0x3eac0900, 0x3ead2b00, 0x3eae4d00, 0x3eaf6f00, 0x3eb09100, 0x3eb1b300, 0x3eb2d500, 0x3eb3f700, 0x3eb51900, 0x3eb63b00, 0x3eb75d00, 0x3eb87f00,
0x3eb9a100, 0x3ebac300, 0x3ebbe500, 0x3ebd0700, 0x3ebe2900, 0x3ebf4b00, 0x3ec06d00, 0x3ec18f00, 0x3ec2b100, 0x3ec3d300, 0x3ec4f500, 0x3ec61700, 0x3ec73900, 0x3ec85b00, 0x3ec97d00, 0x3eca9f00,
0x3ecbc100, 0x3ecce300, 0x3ece0500, 0x3ecf2700, 0x3ed04900, 0x3ed16b00, 0x3ed28d00, 0x3ed3af00, 0x3ed4d100, 0x3ed5f300, 0x3ed71500, 0x3ed83700, 0x3ed95900, 0x3eda7b00, 0x3edb9d00, 0x3edcbf00,
0x3edde100, 0x3edf0300, 0x3ee02500, 0x3ee14700, 0x3ee26900, 0x3ee38b00, 0x3ee4ad00, 0x3ee5cf00, 0x3ee6f100, 0x3ee81300, 0x3ee93500, 0x3eea5700, 0x3eeb7900, 0x3eec9b00, 0x3eedbd00, 0x3eeedf00,
0x3ef00100, 0x3ef12300, 0x3ef24500, 0x3ef36700, 0x3ef48900, 0x3ef5ab00, 0x3ef6cd00, 0x3ef7ef00, 0x3ef91100, 0x3efa3300, 0x3efb5500, 0x3efc7700, 0x3efd9900, 0x3efebb00, 0x3effdd00, 0x3f00ff00,
0x3f022100, 0x3f034300, 0x3f046500, 0x3f058700, 0x3f06a900, 0x3f07cb00, 0x3f08ed00, 0x3f0a0f00, 0x3f0b3100, 0x3f0c5300, 0x3f0d7500, 0x3f0e9700, 0x3f0fb900, 0x3f10db00, 0x3f11fd00, 0x3f131f00,
0x3f144100, 0x3f156300, 0x3f168500, 0x3f17a700, 0x3f18c900, 0x3f19eb00, 0x3f1b0d00, 0x3f1c2f00, 0x3f1d5100, 0x3f1e7300, 0x3f1f9500, 0x3f20b700, 0x3f21d900, 0x3f22fb00, 0x3f241d00, 0x3f253f00,
0x3f266100, 0x3f278300, 0x3f28a500, 0x3f29c700, 0x3f2ae900, 0x3f2c0b00, 0x3f2d2d00, 0x3f2e4f00, 0x3f2f7100, 0x3f309300, 0x3f31b500, 0x3f32d700, 0x3f33f900, 0x3f351b00, 0x3f363d00, 0x3f375f00,
0x3f388100, 0x3f39a300, 0x3f3ac500, 0x3f3be700, 0x3f3d0900, 0x3f3e2b00, 0x3f3f4d00, 0x3f406f00, 0x3f419100, 0x3f42b300, 0x3f43d500, 0x3f44f700, 0x3f461900, 0x3f473b00, 0x3f485d00, 0x3f497f00,
0x3f4aa100, 0x3f4bc300, 0x3f4ce500, 0x3f4e0700, 0x3f4f2900, 0x3f504b00, 0x3f516d00, 0x3f528f00, 0x3f53b100, 0x3f54d300, 0x3f55f500, 0x3f571700, 0x3f583900, 0x3f595b00, 0x3f5a7d00, 0x3f5b9f00,
0x3f5cc100, 0x3f5de300, 0x3f5f0500, 0x3f602700, 0x3f614900, 0x3f626b00, 0x3f638d00, 0x3f64af00, 0x3f65d100, 0x3f66f300, 0x3f681500, 0x3f693700, 0x3f6a5900, 0x3f6b7b00, 0x3f6c9d00, 0x3f6dbf00,
0x3f6ee100, 0x3f700300, 0x3f712500, 0x3f724700, 0x3f736900, 0x3f748b00, 0x3f75ad00, 0x3f76cf00, 0x3f77f100, 0x3f791300, 0x3f7a3500, 0x3f7b5700, 0x3f7c7900, 0x3f7d9b00, 0x3f7ebd00, 0x3f7fdf00,
0x3f810100, 0x3f822300, 0x3f834500, 0x3f846700, 0x3f858900, 0x3f86ab00, 0x3f87cd00, 0x3f88ef00, 0x3f8a1100, 0x3f8b3300, 0x3f8c5500, 0x3f8d7700, 0x3f8e9900, 0x3f8fbb00, 0x3f90dd00, 0x3f91ff00,
0x3f935300, 0x3f94a700, 0x3f95fb00, 0x3f974f00, 0x3f98a300, 0x3f99f700, 0x3f9b4b00, 0x3f9c9f00, 0x3f9df300, 0x3f9f4700, 0x3fa09b00, 0x3fa1ef00, 0x3fa34300, 0x3fa49700, 0x3fa5eb00, 0x3fa73f00,
0x3fa89300, 0x3fa9e700, 0x3fab3b00, 0x3fac8f00, 0x3fade300, 0x3faf3700, 0x3fb08b00, 0x3fb1df00, 0x3fb33300, 0x3fb48700, 0x3fb5db00, 0x3fb72f00, 0x3fb88300, 0x3fb9d700, 0x3fbb2b00, 0x3fbc7f00,
0x3fbdd300, 0x3fbf2700, 0x3fc07b00, 0x3fc1cf00, 0x3fc32300, 0x3fc47700, 0x3fc5cb00, 0x3fc71f00, 0x3fc87300, 0x3fc9c700, 0x3fcb1b00, 0x3fcc6f00, 0x3fcdc300, 0x3fcf1700, 0x3fd06b00, 0x3fd1bf00,
0x3fd31300, 0x3fd46700, 0x3fd5bb00, 0x3fd70f00, 0x3fd86300, 0x3fd9b700, 0x3fdb0b00, 0x3fdc5f00, 0x3fddb300, 0x3fdf0700, 0x3fe05b00, 0x3fe1af00, 0x3fe30300, 0x3fe45700, 0x3fe5ab00, 0x3fe6ff00,
0x3fe85300, 0x3fe9a700, 0x3feafb00, 0x3fec4f00, 0x3feda300, 0x3feef700, 0x3ff04b00, 0x3ff19f00, 0x3ff2f300, 0x3ff44700, 0x3ff59b00, 0x3ff6ef00, 0x3ff84300, 0x3ff99700, 0x3ffaeb00, 0x3ffc3f00,
0x3ffd9300, 0x3ffee700, 0x40003b00, 0x40018f00, 0x4002e300, 0x40043700, 0x40058b00, 0x4006df00, 0x40083300, 0x40098700, 0x400adb00, 0x400c2f00, 0x400d8300, 0x400ed700, 0x40102b00, 0x40117f00,
0x4012d300, 0x40142700, 0x40157b00, 0x4016cf00, 0x40182300, 0x40197700, 0x401acb00, 0x401c1f00, 0x401d7300, 0x401ec700, 0x40201b00, 0x40216f00, 0x4022c300, 0x40241700, 0x40256b00, 0x4026bf00,
0x40281300, 0x40296700, 0x402abb00, 0x402c0f00, 0x402d6300, 0x402eb700, 0x40300b00, 0x40315f00, 0x4032b300, 0x40340700, 0x40355b00, 0x4036af00, 0x40380300, 0x40395700, 0x403aab00, 0x403bff00,
0x403d5300, 0x403ea700, 0x403ffb00, 0x40414f00, 0x4042a300, 0x4043f700, 0x40454b00, 0x40469f00, 0x4047f300, 0x40494700, 0x404a9b00, 0x404bef00, 0x404d4300, 0x404e9700, 0x404feb00, 0x40513f00,
0x40529300, 0x4053e700, 0x40553b00, 0x40568f00, 0x4057e300, 0x40593700, 0x405a8b00, 0x405bdf00, 0x405d3300, 0x405e8700, 0x405fdb00, 0x40612f00, 0x40628300, 0x4063d700, 0x40652b00, 0x40667f00,
0x4067d300, 0x40692700, 0x406a7b00, 0x406bcf00, 0x406d2300, 0x406e7700, 0x406fcb00, 0x40711f00, 0x40727300, 0x4073c700, 0x40751b00, 0x40766f00, 0x4077c300, 0x40791700, 0x407a6b00, 0x407bbf00,
0x407d1300, 0x407e6700, 0x407fbb00, 0x40810f00, 0x40826300, 0x4083b700, 0x40850b00, 0x40865f00, 0x4087b300, 0x40890700, 0x408a5b00, 0x408baf00, 0x408d0300, 0x408e5700, 0x408fab00, 0x4090ff00,
0x40925300, 0x4093a700, 0x4094fb00, 0x40964f00, 0x4097a300, 0x4098f700, 0x409a4b00, 0x409b9f00, 0x409cf300, 0x409e4700, 0x409f9b00, 0x40a0ef00, 0x40a24300, 0x40a39700, 0x40a4eb00, 0x40a63f00,
0x40a79300, 0x40a8e700, 0x40aa3b00, 0x40ab8f00, 0x40ace300, 0x40ae3700, 0x40af8b00, 0x40b0df00, 0x40b23300, 0x40b38700, 0x40b4db00, 0x40b62f00, 0x40b78300, 0x40b8d700, 0x40ba2b00, 0x40bb7f00,
0x40bcd300, 0x40be2700, 0x40bf7b00, 0x40c0cf00, 0x40c22300, 0x40c37700, 0x40c4cb00, 0x40c61f00, 0x40c77300, 0x40c8c700, 0x40ca1b00, 0x40cb6f00, 0x40ccc300, 0x40ce1700, 0x40cf6b00, 0x40d0bf00,
0x40d21300, 0x40d36700, 0x40d4bb00, 0x40d60f00, 0x40d76300, 0x40d8b700, 0x40da0b00, 0x40db5f00, 0x40dcb300, 0x40de0700, 0x40df5b00, 0x40e0af00, 0x40e20300, 0x40e35700, 0x40e4ab00, 0x40e5ff00,
0x40e75300, 0x40e8a700, 0x40e9fb00, 0x40eb4f00, 0x40eca300, 0x40edf700, 0x40ef4b00, 0x40f09f00, 0x40f1f300, 0x40f34700, 0x40f49b00, 0x40f5ef00, 0x40f74300, 0x40f89700, 0x40f9eb00, 0x40fb3f00,
0x40fc9300, 0x40fde700, 0x40ff3b00, 0x41008f00, 0x4101e300, 0x41033700, 0x41048b00, 0x4105df00, 0x41073300, 0x41088700, 0x4109db00, 0x410b2f00, 0x410c8300, 0x410dd700, 0x410f2b00, 0x41107f00,
0x4111d300, 0x41132700, 0x41147b00, 0x4115cf00, 0x41172300, 0x41187700, 0x4119cb00, 0x411b1f00, 0x411c7300, 0x411dc700, 0x411f1b00, 0x41206f00, 0x4121c300, 0x41231700, 0x41246b00, 0x4125bf00,
0x41271300, 0x41286700, 0x4129bb00, 0x412b0f00, 0x412c6300, 0x412db700, 0x412f0b00, 0x41305f00, 0x4131b300, 0x41330700, 0x41345b00, 0x4135af00, 0x41370300, 0x41385700, 0x4139ab00, 0x413aff00,
0x413c5300, 0x413da700, 0x413efb00, 0x41404f00, 0x4141a300, 0x4142f700, 0x41444b00, 0x41459f00, 0x4146f300, 0x41484700, 0x41499b00, 0x414aef00, 0x414c4300, 0x414d9700, 0x414eeb00, 0x41503f00,
0x41519300, 0x4152e700, 0x41543b00, 0x41558f00, 0x4156e300, 0x41583700, 0x41598b00, 0x415adf00, 0x415c3300, 0x415d8700, 0x415edb00, 0x41602f00, 0x41618300, 0x4162d700, 0x41642b00, 0x41657f00,
0x4166d300, 0x41682700, 0x41697b00, 0x416acf00, 0x416c2300, 0x416d7700, 0x416ecb00, 0x41701f00, 0x41717300, 0x4172c700, 0x41741b00, 0x41756f00, 0x4176c300, 0x41781700, 0x41796b00, 0x417abf00,
0x417c1300, 0x417d6700, 0x417ebb00, 0x41800f00, 0x41816300, 0x4182b700, 0x41840b00, 0x41855f00, 0x4186b300, 0x41880700, 0x41895b00, 0x418aaf00, 0x418c0300, 0x418d5700, 0x418eab00, 0x418fff00,
0x41915300, 0x4192a700, 0x4193fb00, 0x41954f00, 0x4196a300, 0x4197f700, 0x41994b00, 0x419a9f00, 0x419bf300, 0x419d4700, 0x419e9b00, 0x419fef00, 0x41a14300, 0x41a29700, 0x41a3eb00, 0x41a53f00,
0x41a69300, 0x41a7e700, 0x41a93b00, 0x41aa8f00, 0x41abe300, 0x41ad3700, 0x41ae8b00, 0x41afdf00, 0x41b13300, 0x41b28700, 0x41b3db00, 0x41b52f00, 0x41b68300, 0x41b7d700, 0x41b92b00, 0x41ba7f00,
0x41bbd300, 0x41bd2700, 0x41be7b00, 0x41bfcf00, 0x41c12300, 0x41c27700, 0x41c3cb00, 0x41c51f00, 0x41c67300, 0x41c7c700, 0x41c91b00, 0x41ca6f00, 0x41cbc300, 0x41cd1700, 0x41ce6b00, 0x41cfbf00,
0x41d11300, 0x41d26700, 0x41d3bb00, 0x41d50f00, 0x41d66300, 0x41d7b700, 0x41d90b00, 0x41da5f00, 0x41dbb300, 0x41dd0700, 0x41de5b00, 0x41dfaf00, 0x41e10300, 0x41e25700, 0x41e3ab00, 0x41e4ff00,
0x41e65300, 0x41e7a700, 0x41e8fb00, 0x41ea4f00, 0x41eba300, 0x41ecf700, 0x41ee4b00, 0x41ef9f00, 0x41f0f300, 0x41f24700, 0x41f39b00, 0x41f4ef00, 0x41f64300, 0x41f79700, 0x41f8eb00, 0x41fa3f00,
0x41fb9300, 0x41fce700, 0x41fe3b00, 0x41ff8f00, 0x4200e300, 0x42023700, 0x42038b00, 0x4204df00, 0x42063300, 0x42078700, 0x4208db00, 0x420a2f00, 0x420b8300, 0x420cd700, 0x420e2b00, 0x420f7f00,
0x4210d300, 0x42122700, 0x42137b00, 0x4214cf00, 0x42162300, 0x42177700, 0x4218cb00, 0x421a1f00, 0x421b7300, 0x421cc700, 0x421e1b00, 0x421f6f00, 0x4220c300, 0x42221700, 0x42236b00, 0x4224bf00,
0x42261300, 0x42276700, 0x4228bb00, 0x422a0f00, 0x422b6300, 0x422cb700, 0x422e0b00, 0x422f5f00, 0x4230b300, 0x42320700, 0x42335b00, 0x4234af00, 0x42360300, 0x42375700, 0x4238ab00, 0x4239ff00,
0x423b9d00, 0x423d3b00, 0x423ed900, 0x42407700, 0x42421500, 0x4243b300, 0x42455100, 0x4246ef00, 0x42488d00, 0x424a2b00, 0x424bc900, 0x424d6700, 0x424f0500, 0x4250a300, 0x42524100, 0x4253df00,
0x42557d00, 0x42571b00, 0x4258b900, 0x425a5700, 0x425bf500, 0x425d9300, 0x425f3100, 0x4260cf00, 0x42626d00, 0x42640b00, 0x4265a900, 0x42674700, 0x4268e500, 0x426a8300, 0x426c2100, 0x426dbf00,
0x426f5d00, 0x4270fb00, 0x42729900, 0x42743700, 0x4275d500, 0x42777300, 0x42791100, 0x427aaf00, 0x427c4d00, 0x427deb00, 0x427f8900, 0x42812700, 0x4282c500, 0x42846300, 0x42860100, 0x42879f00,
0x42893d00, 0x428adb00, 0x428c7900, 0x428e1700, 0x428fb500, 0x42915300, 0x4292f100, 0x42948f00, 0x42962d00, 0x4297cb00, 0x42996900, 0x429b0700, 0x429ca500, 0x429e4300, 0x429fe100, 0x42a17f00,
0x42a31d00, 0x42a4bb00, 0x42a65900, 0x42a7f700, 0x42a99500, 0x42ab3300, 0x42acd100, 0x42ae6f00, 0x42b00d00, 0x42b1ab00, 0x42b34900, 0x42b4e700, 0x42b68500, 0x42b82300, 0x42b9c100, 0x42bb5f00,
0x42bcfd00, 0x42be9b00, 0x42c03900, 0x42c1d700, 0x42c37500, 0x42c51300, 0x42c6b100, 0x42c84f00, 0x42c9ed00, 0x42cb8b00, 0x42cd2900, 0x42cec700, 0x42d06500, 0x42d20300, 0x42d3a100, 0x42d53f00,
0x42d6dd00, 0x42d87b00, 0x42da1900, 0x42dbb700, 0x42dd5500, 0x42def300, 0x42e09100, 0x42e22f00, 0x42e3cd00, 0x42e56b00, 0x42e70900, 0x42e8a700, 0x42ea4500, 0x42ebe300, 0x42ed8100, 0x42ef1f00,
0x42f0bd00, 0x42f25b00, 0x42f3f900, 0x42f59700, 0x42f73500, 0x42f8d300, 0x42fa7100, 0x42fc0f00, 0x42fdad00, 0x42ff4b00, 0x4300e900, 0x43028700, 0x43042500, 0x4305c300, 0x43076100, 0x4308ff00,
0x430a9d00, 0x430c3b00, 0x430dd900, 0x430f7700, 0x43111500, 0x4312b300, 0x43145100, 0x4315ef00, 0x43178d00, 0x43192b00, 0x431ac900, 0x431c6700, 0x431e0500, 0x431fa300, 0x43214100, 0x4322df00,
0x43247d00, 0x43261b00, 0x4327b900, 0x43295700, 0x432af500, 0x432c9300, 0x432e3100, 0x432fcf00, 0x43316d00, 0x43330b00, 0x4334a900, 0x43364700, 0x4337e500, 0x43398300, 0x433b2100, 0x433cbf00,
0x433e5d00, 0x433ffb00, 0x43419900, 0x43433700, 0x4344d500, 0x43467300, 0x43481100, 0x4349af00, 0x434b4d00, 0x434ceb00, 0x434e8900, 0x43502700, 0x4351c500, 0x43536300, 0x43550100, 0x43569f00,
0x43583d00, 0x4359db00, 0x435b7900, 0x435d1700, 0x435eb500, 0x43605300, 0x4361f100, 0x43638f00, 0x43652d00, 0x4366cb00, 0x43686900, 0x436a0700, 0x436ba500, 0x436d4300, 0x436ee100, 0x43707f00,
0x43721d00, 0x4373bb00, 0x43755900, 0x4376f700, 0x43789500, 0x437a3300, 0x437bd100, 0x437d6f00, 0x437f0d00, 0x4380ab00, 0x43824900, 0x4383e700, 0x43858500, 0x43872300, 0x4388c100, 0x438a5f00,
0x438bfd00, 0x438d9b00, 0x438f3900, 0x4390d700, 0x43927500, 0x43941300, 0x4395b100, 0x43974f00, 0x4398ed00, 0x439a8b00, 0x439c2900, 0x439dc700, 0x439f6500, 0x43a10300, 0x43a2a100, 0x43a43f00,
0x43a5dd00, 0x43a77b00, 0x43a91900, 0x43aab700, 0x43ac5500, 0x43adf300, 0x43af9100, 0x43b12f00, 0x43b2cd00, 0x43b46b00, 0x43b60900, 0x43b7a700, 0x43b94500, 0x43bae300, 0x43bc8100, 0x43be1f00,
0x43bfbd00, 0x43c15b00, 0x43c2f900, 0x43c49700, 0x43c63500, 0x43c7d300, 0x43c97100, 0x43cb0f00, 0x43ccad00, 0x43ce4b00, 0x43cfe900, 0x43d18700, 0x43d32500, 0x43d4c300, 0x43d66100, 0x43d7ff00,
0x43d99d00, 0x43db3b00, 0x43dcd900, 0x43de7700, 0x43e01500, 0x43e1b300, 0x43e35100, 0x43e4ef00, 0x43e68d00, 0x43e82b00, 0x43e9c900, 0x43eb6700, 0x43ed0500, 0x43eea300, 0x43f04100, 0x43f1df00,
0x43f37d00, 0x43f51b00, 0x43f6b900, 0x43f85700, 0x43f9f500, 0x43fb9300, 0x43fd3100, 0x43fecf00, 0x44006d00, 0x44020b00, 0x4403a900, 0x44054700, 0x4406e500, 0x44088300, 0x440a2100, 0x440bbf00,
0x440d5d00, 0x440efb00, 0x44109900, 0x44123700, 0x4413d500, 0x44157300, 0x44171100, 0x4418af00, 0x441a4d00, 0x441beb00, 0x441d8900, 0x441f2700, 0x4420c500, 0x44226300, 0x44240100, 0x44259f00,
0x44273d00, 0x4428db00, 0x442a7900, 0x442c1700, 0x442db500, 0x442f5300, 0x4430f100, 0x44328f00, 0x44342d00, 0x4435cb00, 0x44376900, 0x44390700, 0x443aa500, 0x443c4300, 0x443de100, 0x443f7f00,
0x44411d00, 0x4442bb00, 0x44445900, 0x4445f700, 0x44479500, 0x44493300, 0x444ad100, 0x444c6f00, 0x444e0d00, 0x444fab00, 0x44514900, 0x4452e700, 0x44548500, 0x44562300, 0x4457c100, 0x44595f00,
0x445afd00, 0x445c9b00, 0x445e3900, 0x445fd700, 0x44617500, 0x44631300, 0x4464b100, 0x44664f00, 0x4467ed00, 0x44698b00, 0x446b2900, 0x446cc700, 0x446e6500, 0x44700300, 0x4471a100, 0x44733f00,
0x4474dd00, 0x44767b00, 0x44781900, 0x4479b700, 0x447b5500, 0x447cf300, 0x447e9100, 0x44802f00, 0x4481cd00, 0x44836b00, 0x44850900, 0x4486a700, 0x44884500, 0x4489e300, 0x448b8100, 0x448d1f00,
0x448ebd00, 0x44905b00, 0x4491f900, 0x44939700, 0x44953500, 0x4496d300, 0x44987100, 0x449a0f00, 0x449bad00, 0x449d4b00, 0x449ee900, 0x44a08700, 0x44a22500, 0x44a3c300, 0x44a56100, 0x44a6ff00,
0x44a89d00, 0x44aa3b00, 0x44abd900, 0x44ad7700, 0x44af1500, 0x44b0b300, 0x44b25100, 0x44b3ef00, 0x44b58d00, 0x44b72b00, 0x44b8c900, 0x44ba6700, 0x44bc0500, 0x44bda300, 0x44bf4100, 0x44c0df00,
0x44c27d00, 0x44c41b00, 0x44c5b900, 0x44c75700, 0x44c8f500, 0x44ca9300, 0x44cc3100, 0x44cdcf00, 0x44cf6d00, 0x44d10b00, 0x44d2a900, 0x44d44700, 0x44d5e500, 0x44d78300, 0x44d92100, 0x44dabf00,
0x44dc5d00, 0x44ddfb00, 0x44df9900, 0x44e13700, 0x44e2d500, 0x44e47300, 0x44e61100, 0x44e7af00, 0x44e94d00, 0x44eaeb00, 0x44ec8900, 0x44ee2700, 0x44efc500, 0x44f16300, 0x44f30100, 0x44f49f00,
0x44f63d00, 0x44f7db00, 0x44f97900, 0x44fb1700, 0x44fcb500, 0x44fe5300, 0x44fff100, 0x45018f00, 0x45032d00, 0x4504cb00, 0x45066900, 0x45080700, 0x4509a500, 0x450b4300, 0x450ce100, 0x450e7f00,
0x45101d00, 0x4511bb00, 0x45135900, 0x4514f700, 0x45169500, 0x45183300, 0x4519d100, 0x451b6f00, 0x451d0d00, 0x451eab00, 0x45204900, 0x4521e700, 0x45238500, 0x45252300, 0x4526c100, 0x45285f00,
0x4529fd00, 0x452b9b00, 0x452d3900, 0x452ed700, 0x45307500, 0x45321300, 0x4533b100, 0x45354f00, 0x4536ed00, 0x45388b00, 0x453a2900, 0x453bc700, 0x453d6500, 0x453f0300, 0x4540a100, 0x45423f00,
0x4543dd00, 0x45457b00, 0x45471900, 0x4548b700, 0x454a5500, 0x454bf300, 0x454d9100, 0x454f2f00, 0x4550cd00, 0x45526b00, 0x45540900, 0x4555a700, 0x45574500, 0x4558e300, 0x455a8100, 0x455c1f00,
0x455dbd00, 0x455f5b00, 0x4560f900, 0x45629700, 0x45643500, 0x4565d300, 0x45677100, 0x45690f00, 0x456aad00, 0x456c4b00, 0x456de900, 0x456f8700, 0x45712500, 0x4572c300, 0x45746100, 0x4575ff00,
0x4577e300, 0x4579c700, 0x457bab00, 0x457d8f00, 0x457f7300, 0x45815700, 0x45833b00, 0x45851f00, 0x45870300, 0x4588e700, 0x458acb00, 0x458caf00, 0x458e9300, 0x45907700, 0x45925b00, 0x45943f00,
0x45962300, 0x45980700, 0x4599eb00, 0x459bcf00, 0x459db300, 0x459f9700, 0x45a17b00, 0x45a35f00, 0x45a54300, 0x45a72700, 0x45a90b00, 0x45aaef00, 0x45acd300, 0x45aeb700, 0x45b09b00, 0x45b27f00,
0x45b46300, 0x45b64700, 0x45b82b00, 0x45ba0f00, 0x45bbf300, 0x45bdd700, 0x45bfbb00, 0x45c19f00, 0x45c38300, 0x45c56700, 0x45c74b00, 0x45c92f00, 0x45cb1300, 0x45ccf700, 0x45cedb00, 0x45d0bf00,
0x45d2a300, 0x45d48700, 0x45d66b00, 0x45d84f00, 0x45da3300, 0x45dc1700, 0x45ddfb00, 0x45dfdf00, 0x45e1c300, 0x45e3a700, 0x45e58b00, 0x45e76f00, 0x45e95300, 0x45eb3700, 0x45ed1b00, 0x45eeff00,
0x45f0e300, 0x45f2c700, 0x45f4ab00, 0x45f68f00, 0x45f87300, 0x45fa5700, 0x45fc3b00, 0x45fe1f00, 0x46000300, 0x4601e700, 0x4603cb00, 0x4605af00, 0x46079300, 0x46097700, 0x460b5b00, 0x460d3f00,
0x460f2300, 0x46110700, 0x4612eb00, 0x4614cf00, 0x4616b300, 0x46189700, 0x461a7b00, 0x461c5f00, 0x461e4300, 0x46202700, 0x46220b00, 0x4623ef00, 0x4625d300, 0x4627b700, 0x46299b00, 0x462b7f00,
0x462d6300, 0x462f4700, 0x46312b00, 0x46330f00, 0x4634f300, 0x4636d700, 0x4638bb00, 0x463a9f00, 0x463c8300, 0x463e6700, 0x46404b00, 0x46422f00, 0x46441300, 0x4645f700, 0x4647db00, 0x4649bf00,
0x464ba300, 0x464d8700, 0x464f6b00, 0x46514f00, 0x46533300, 0x46551700, 0x4656fb00, 0x4658df00, 0x465ac300, 0x465ca700, 0x465e8b00, 0x46606f00, 0x46625300, 0x46643700, 0x46661b00, 0x4667ff00,
0x4669e300, 0x466bc700, 0x466dab00, 0x466f8f00, 0x46717300, 0x46735700, 0x46753b00, 0x46771f00, 0x46790300, 0x467ae700, 0x467ccb00, 0x467eaf00, 0x46809300, 0x46827700, 0x46845b00, 0x46863f00,
0x46882300, 0x468a0700, 0x468beb00, 0x468dcf00, 0x468fb300, 0x46919700, 0x46937b00, 0x46955f00, 0x46974300, 0x46992700, 0x469b0b00, 0x469cef00, 0x469ed300, 0x46a0b700, 0x46a29b00, 0x46a47f00,
0x46a66300, 0x46a84700, 0x46aa2b00, 0x46ac0f00, 0x46adf300, 0x46afd700, 0x46b1bb00, 0x46b39f00, 0x46b58300, 0x46b76700, 0x46b94b00, 0x46bb2f00, 0x46bd1300, 0x46bef700, 0x46c0db00, 0x46c2bf00,
0x46c4a300, 0x46c68700, 0x46c86b00, 0x46ca4f00, 0x46cc3300, 0x46ce1700, 0x46cffb00, 0x46d1df00, 0x46d3c300, 0x46d5a700, 0x46d78b00, 0x46d96f00, 0x46db5300, 0x46dd3700, 0x46df1b00, 0x46e0ff00,
0x46e2e300, 0x46e4c700, 0x46e6ab00, 0x46e88f00, 0x46ea7300, 0x46ec5700, 0x46ee3b00, 0x46f01f00, 0x46f20300, 0x46f3e700, 0x46f5cb00, 0x46f7af00, 0x46f99300, 0x46fb7700, 0x46fd5b00, 0x46ff3f00,
0x47012300, 0x47030700, 0x4704eb00, 0x4706cf00, 0x4708b300, 0x470a9700, 0x470c7b00, 0x470e5f00, 0x47104300, 0x47122700, 0x47140b00, 0x4715ef00, 0x4717d300, 0x4719b700, 0x471b9b00, 0x471d7f00,
0x471f6300, 0x47214700, 0x47232b00, 0x47250f00, 0x4726f300, 0x4728d700, 0x472abb00, 0x472c9f00, 0x472e8300, 0x47306700, 0x47324b00, 0x47342f00, 0x47361300, 0x4737f700, 0x4739db00, 0x473bbf00,
0x473da300, 0x473f8700, 0x47416b00, 0x47434f00, 0x47453300, 0x47471700, 0x4748fb00, 0x474adf00, 0x474cc300, 0x474ea700, 0x47508b00, 0x47526f00, 0x47545300, 0x47563700, 0x47581b00, 0x4759ff00,
0x475c3f00, 0x475e7f00, 0x4760bf00, 0x4762ff00, 0x47653f00, 0x47677f00, 0x4769bf00, 0x476bff00, 0x476e3f00, 0x47707f00, 0x4772bf00, 0x4774ff00, 0x47773f00, 0x47797f00, 0x477bbf00, 0x477dff00,
0x47803f00, 0x47827f00, 0x4784bf00, 0x4786ff00, 0x47893f00, 0x478b7f00, 0x478dbf00, 0x478fff00, 0x47923f00, 0x47947f00, 0x4796bf00, 0x4798ff00, 0x479b3f00, 0x479d7f00, 0x479fbf00, 0x47a1ff00,
0x47a43f00, 0x47a67f00, 0x47a8bf00, 0x47aaff00, 0x47ad3f00, 0x47af7f00, 0x47b1bf00, 0x47b3ff00, 0x47b63f00, 0x47b87f00, 0x47babf00, 0x47bcff00, 0x47bf3f00, 0x47c17f00, 0x47c3bf00, 0x47c5ff00,
0x47c83f00, 0x47ca7f00, 0x47ccbf00, 0x47ceff00, 0x47d13f00, 0x47d37f00, 0x47d5bf00, 0x47d7ff00, 0x47da3f00, 0x47dc7f00, 0x47debf00, 0x47e0ff00, 0x47e33f00, 0x47e57f00, 0x47e7bf00, 0x47e9ff00,
0x47ec3f00, 0x47ee7f00, 0x47f0bf00, 0x47f2ff00, 0x47f53f00, 0x47f77f00, 0x47f9bf00, 0x47fbff00, 0x47fe3f00, 0x48007f00, 0x4802bf00, 0x4804ff00, 0x48073f00, 0x48097f00, 0x480bbf00, 0x480dff00,
0x48103f00, 0x48127f00, 0x4814bf00, 0x4816ff00, 0x48193f00, 0x481b7f00, 0x481dbf00, 0x481fff00, 0x48223f00, 0x48247f00, 0x4826bf00, 0x4828ff00, 0x482b3f00, 0x482d7f00, 0x482fbf00, 0x4831ff00,
0x48343f00, 0x48367f00, 0x4838bf00, 0x483aff00, 0x483d3f00, 0x483f7f00, 0x4841bf00, 0x4843ff00, 0x48463f00, 0x48487f00, 0x484abf00, 0x484cff00, 0x484f3f00, 0x48517f00, 0x4853bf00, 0x4855ff00,
0x48583f00, 0x485a7f00, 0x485cbf00, 0x485eff00, 0x48613f00, 0x48637f00, 0x4865bf00, 0x4867ff00, 0x486a3f00, 0x486c7f00, 0x486ebf00, 0x4870ff00, 0x48733f00, 0x48757f00, 0x4877bf00, 0x4879ff00,
0x487c3f00, 0x487e7f00, 0x4880bf00, 0x4882ff00, 0x48853f00, 0x48877f00, 0x4889bf00, 0x488bff00, 0x488e3f00, 0x48907f00, 0x4892bf00, 0x4894ff00, 0x48973f00, 0x48997f00, 0x489bbf00, 0x489dff00,
0x48a03f00, 0x48a27f00, 0x48a4bf00, 0x48a6ff00, 0x48a93f00, 0x48ab7f00, 0x48adbf00, 0x48afff00, 0x48b23f00, 0x48b47f00, 0x48b6bf00, 0x48b8ff00, 0x48bb3f00, 0x48bd7f00, 0x48bfbf00, 0x48c1ff00,
0x48c43f00, 0x48c67f00, 0x48c8bf00, 0x48caff00, 0x48cd3f00, 0x48cf7f00, 0x48d1bf00, 0x48d3ff00, 0x48d63f00, 0x48d87f00, 0x48dabf00, 0x48dcff00, 0x48df3f00, 0x48e17f00, 0x48e3bf00, 0x48e5ff00,
0x48e83f00, 0x48ea7f00, 0x48ecbf00, 0x48eeff00, 0x48f13f00, 0x48f37f00, 0x48f5bf00, 0x48f7ff00, 0x48fa3f00, 0x48fc7f00, 0x48febf00, 0x4900ff00, 0x49033f00, 0x49057f00, 0x4907bf00, 0x4909ff00,
0x490c3f00, 0x490e7f00, 0x4910bf00, 0x4912ff00, 0x49153f00, 0x49177f00, 0x4919bf00, 0x491bff00, 0x491e3f00, 0x49207f00, 0x4922bf00, 0x4924ff00, 0x49273f00, 0x49297f00, 0x492bbf00, 0x492dff00,
0x49303f00, 0x49327f00, 0x4934bf00, 0x4936ff00, 0x49393f00, 0x493b7f00, 0x493dbf00, 0x493fff00, 0x49423f00, 0x49447f00, 0x4946bf00, 0x4948ff00, 0x494b3f00, 0x494d7f00, 0x494fbf00, 0x4951ff00,
0x49543f00, 0x49567f00, 0x4958bf00, 0x495aff00, 0x495d3f00, 0x495f7f00, 0x4961bf00, 0x4963ff00, 0x49663f00, 0x49687f00, 0x496abf00, 0x496cff00, 0x496f3f00, 0x49717f00, 0x4973bf00, 0x4975ff00,
0x49783f00, 0x497a7f00, 0x497cbf00, 0x497eff00, 0x49813f00, 0x49837f00, 0x4985bf00, 0x4987ff00, 0x498a3f00, 0x498c7f00, 0x498ebf00, 0x4990ff00, 0x49933f00, 0x49957f00, 0x4997bf00, 0x4999ff00,
0x499cb300, 0x499f6700, 0x49a21b00, 0x49a4cf00, 0x49a78300, 0x49aa3700, 0x49aceb00, 0x49af9f00, 0x49b25300, 0x49b50700, 0x49b7bb00, 0x49ba6f00, 0x49bd2300, 0x49bfd700, 0x49c28b00, 0x49c53f00,
0x49c7f300, 0x49caa700, 0x49cd5b00, 0x49d00f00, 0x49d2c300, 0x49d57700, 0x49d82b00, 0x49dadf00, 0x49dd9300, 0x49e04700, 0x49e2fb00, 0x49e5af00, 0x49e86300, 0x49eb1700, 0x49edcb00, 0x49f07f00,
0x49f33300, 0x49f5e700, 0x49f89b00, 0x49fb4f00, 0x49fe0300, 0x4a00b700, 0x4a036b00, 0x4a061f00, 0x4a08d300, 0x4a0b8700, 0x4a0e3b00, 0x4a10ef00, 0x4a13a300, 0x4a165700, 0x4a190b00, 0x4a1bbf00,
0x4a1e7300, 0x4a212700, 0x4a23db00, 0x4a268f00, 0x4a294300, 0x4a2bf700, 0x4a2eab00, 0x4a315f00, 0x4a341300, 0x4a36c700, 0x4a397c00, 0x4a3c3000, 0x4a3ee400, 0x4a419800, 0x4a444c00, 0x4a470000,
0x4a49b400, 0x4a4c6800, 0x4a4f1c00, 0x4a51d000, 0x4a548400, 0x4a573800, 0x4a59ec00, 0x4a5ca000, 0x4a5f5400, 0x4a620800, 0x4a64bc00, 0x4a677000, 0x4a6a2400, 0x4a6cd800, 0x4a6f8c00, 0x4a724000,
0x4a74f400, 0x4a77a800, 0x4a7a5c00, 0x4a7d1000, 0x4a7fc400, 0x4a827800, 0x4a852c00, 0x4a87e000, 0x4a8a9400, 0x4a8d4800, 0x4a8ffc00, 0x4a92b000, 0x4a956400, 0x4a981800, 0x4a9acc00, 0x4a9d8000,
0x4aa03400, 0x4aa2e800, 0x4aa59c00, 0x4aa85000, 0x4aab0400, 0x4aadb800, 0x4ab06c00, 0x4ab32000, 0x4ab5d400, 0x4ab88800, 0x4abb3c00, 0x4abdf000, 0x4ac0a400, 0x4ac35800, 0x4ac60c00, 0x4ac8c000,
0x4acb7400, 0x4ace2800, 0x4ad0dc00, 0x4ad39000, 0x4ad64400, 0x4ad8f800, 0x4adbac00, 0x4ade6000, 0x4ae11400, 0x4ae3c800, 0x4ae67c00, 0x4ae93000, 0x4aebe400, 0x4aee9800, 0x4af14c00, 0x4af40000,
0x4af6cc00, 0x4af99800, 0x4afc6400, 0x4aff3000, 0x4b01fc00, 0x4b04c800, 0x4b079400, 0x4b0a6000, 0x4b0d2c00, 0x4b0ff800, 0x4b12c400, 0x4b159000, 0x4b185c00, 0x4b1b2800, 0x4b1df400, 0x4b20c000,
0x4b238c00, 0x4b265800, 0x4b292400, 0x4b2bf000, 0x4b2ebc00, 0x4b318800, 0x4b345400, 0x4b372000, 0x4b39ec00, 0x4b3cb800, 0x4b3f8400, 0x4b425000, 0x4b451c00, 0x4b47e800, 0x4b4ab400, 0x4b4d8000,
0x4b504c00, 0x4b531800, 0x4b55e400, 0x4b58b000, 0x4b5b7c00, 0x4b5e4800, 0x4b611400, 0x4b63e000, 0x4b66ac00, 0x4b697800, 0x4b6c4400, 0x4b6f1000, 0x4b71dc00, 0x4b74a800, 0x4b777400, 0x4b7a4000,
0x4b7d0c00, 0x4b7fd800, 0x4b82a400, 0x4b857000, 0x4b883c00, 0x4b8b0800, 0x4b8dd400, 0x4b90a000, 0x4b936c00, 0x4b963800, 0x4b990400, 0x4b9bd000, 0x4b9e9c00, 0x4ba16800, 0x4ba43400, 0x4ba70000,
0x4ba9cc00, 0x4bac9800, 0x4baf6400, 0x4bb23000, 0x4bb4fc00, 0x4bb7c700, 0x4bba9300, 0x4bbd5f00, 0x4bc02b00, 0x4bc2f700, 0x4bc5c300, 0x4bc88f00, 0x4bcb5b00, 0x4bce2700, 0x4bd0f300, 0x4bd3bf00,
0x4bd68b00, 0x4bd95700, 0x4bdc2300, 0x4bdeef00, 0x4be1bb00, 0x4be48700, 0x4be75300, 0x4bea1f00, 0x4beceb00, 0x4befb700, 0x4bf28300, 0x4bf54f00, 0x4bf81b00, 0x4bfae700, 0x4bfdb300, 0x4c007f00,
0x4c034b00, 0x4c061700, 0x4c08e300, 0x4c0baf00, 0x4c0e7b00, 0x4c114700, 0x4c141300, 0x4c16df00, 0x4c19ab00, 0x4c1c7700, 0x4c1f4300, 0x4c220f00, 0x4c24db00, 0x4c27a700, 0x4c2a7300, 0x4c2d3f00,
0x4c300b00, 0x4c32d700, 0x4c35a300, 0x4c386f00, 0x4c3b3b00, 0x4c3e0700, 0x4c40d300, 0x4c439f00, 0x4c466b00, 0x4c493700, 0x4c4c0300, 0x4c4ecf00, 0x4c519b00, 0x4c546700, 0x4c573300, 0x4c59ff00,
0x4c5d7700, 0x4c60ef00, 0x4c646700, 0x4c67df00, 0x4c6b5700, 0x4c6ecf00, 0x4c724700, 0x4c75bf00, 0x4c793700, 0x4c7caf00, 0x4c802700, 0x4c839f00, 0x4c871700, 0x4c8a8f00, 0x4c8e0700, 0x4c917f00,
0x4c94f700, 0x4c986f00, 0x4c9be700, 0x4c9f5f00, 0x4ca2d700, 0x4ca64f00, 0x4ca9c700, 0x4cad3f00, 0x4cb0b700, 0x4cb42f00, 0x4cb7a700, 0x4cbb1f00, 0x4cbe9700, 0x4cc20f00, 0x4cc58700, 0x4cc8ff00,
0x4ccc7700, 0x4ccfef00, 0x4cd36700, 0x4cd6df00, 0x4cda5700, 0x4cddcf00, 0x4ce14700, 0x4ce4bf00, 0x4ce83700, 0x4cebaf00, 0x4cef2700, 0x4cf29f00, 0x4cf61700, 0x4cf98f00, 0x4cfd0700, 0x4d007f00,
0x4d03f700, 0x4d076f00, 0x4d0ae700, 0x4d0e5f00, 0x4d11d700, 0x4d154f00, 0x4d18c700, 0x4d1c3f00, 0x4d1fb700, 0x4d232f00, 0x4d26a700, 0x4d2a1f00, 0x4d2d9700, 0x4d310f00, 0x4d348700, 0x4d37ff00,
0x4d3b7700, 0x4d3eef00, 0x4d426700, 0x4d45df00, 0x4d495700, 0x4d4ccf00, 0x4d504700, 0x4d53bf00, 0x4d573700, 0x4d5aaf00, 0x4d5e2700, 0x4d619f00, 0x4d651700, 0x4d688f00, 0x4d6c0700, 0x4d6f7f00,
0x4d72f700, 0x4d766f00, 0x4d79e700, 0x4d7d5f00, 0x4d80d700, 0x4d844f00, 0x4d87c700, 0x4d8b3f00, 0x4d8eb700, 0x4d922f00, 0x4d95a700, 0x4d991f00, 0x4d9c9700, 0x4da00f00, 0x4da38700, 0x4da6ff00,
0x4daa7700, 0x4dadef00, 0x4db16700, 0x4db4df00, 0x4db85700, 0x4dbbcf00, 0x4dbf4700, 0x4dc2bf00, 0x4dc63700, 0x4dc9af00, 0x4dcd2700, 0x4dd09f00, 0x4dd41700, 0x4dd78f00, 0x4ddb0700, 0x4dde7f00,
0x4de1f700, 0x4de56f00, 0x4de8e700, 0x4dec5f00, 0x4defd700, 0x4df34f00, 0x4df6c700, 0x4dfa3f00, 0x4dfdb700, 0x4e012f00, 0x4e04a700, 0x4e081f00, 0x4e0b9700, 0x4e0f0f00, 0x4e128700, 0x4e15ff00,
0x4e19ff00, 0x4e1dff00, 0x4e21ff00, 0x4e25ff00, 0x4e29ff00, 0x4e2dff00, 0x4e31ff00, 0x4e35ff00, 0x4e39ff00, 0x4e3dff00, 0x4e41ff00, 0x4e45ff00, 0x4e49ff00, 0x4e4dff00, 0x4e51ff00, 0x4e55ff00,
0x4e59ff00, 0x4e5dff00, 0x4e61ff00, 0x4e65ff00, 0x4e69ff00, 0x4e6dff00, 0x4e71ff00, 0x4e75ff00, 0x4e79ff00, 0x4e7dff00, 0x4e81ff00, 0x4e85ff00, 0x4e89ff00, 0x4e8dff00, 0x4e91ff00, 0x4e95ff00,
0x4e99ff00, 0x4e9dff00, 0x4ea1ff00, 0x4ea5ff00, 0x4ea9ff00, 0x4eadff00, 0x4eb1ff00, 0x4eb5ff00, 0x4eb9ff00, 0x4ebdff00, 0x4ec1ff00, 0x4ec5ff00, 0x4ec9ff00, 0x4ecdff00, 0x4ed1ff00, 0x4ed5ff00,
0x4ed9ff00, 0x4eddff00, 0x4ee1ff00, 0x4ee5ff00, 0x4ee9ff00, 0x4eedff00, 0x4ef1ff00, 0x4ef5ff00, 0x4ef9ff00, 0x4efdff00, 0x4f01ff00, 0x4f05ff00, 0x4f09ff00, 0x4f0dff00, 0x4f11ff00, 0x4f15ff00,
0x4f19ff00, 0x4f1dff00, 0x4f21ff00, 0x4f25ff00, 0x4f29ff00, 0x4f2dff00, 0x4f31ff00, 0x4f35ff00, 0x4f39ff00, 0x4f3dff00, 0x4f41ff00, 0x4f45ff00, 0x4f49ff00, 0x4f4dff00, 0x4f51ff00, 0x4f55ff00,
0x4f59ff00, 0x4f5dff00, 0x4f61ff00, 0x4f65ff00, 0x4f69ff00, 0x4f6dff00, 0x4f71ff00, 0x4f75ff00, 0x4f79ff00, 0x4f7dff00, 0x4f81ff00, 0x4f85ff00, 0x4f89ff00, 0x4f8dff00, 0x4f91ff00, 0x4f95ff00,
0x4f99ff00, 0x4f9dff00, 0x4fa1ff00, 0x4fa5ff00, 0x4fa9ff00, 0x4fadff00, 0x4fb1ff00, 0x4fb5ff00, 0x4fb9ff00, 0x4fbdff00, 0x4fc1ff00, 0x4fc5ff00, 0x4fc9ff00, 0x4fcdff00, 0x4fd1ff00, 0x4fd5ff00,
0x4fd9ff00, 0x4fddff00, 0x4fe1ff00, 0x4fe5ff00, 0x4fe9ff00, 0x4fedff00, 0x4ff1ff00, 0x4ff5ff00, 0x4ff9ff00, 0x4ffdff00, 0x5001ff00, 0x5005ff00, 0x5009ff00, 0x500dff00, 0x5011ff00, 0x5015ff00,
0x501a7700, 0x501eef00, 0x50236700, 0x5027df00, 0x502c5700, 0x5030cf00, 0x50354700, 0x5039bf00, 0x503e3700, 0x5042af00, 0x50472700, 0x504b9f00, 0x50501700, 0x50548f00, 0x50590700, 0x505d7f00,
0x5061f700, 0x50666f00, 0x506ae700, 0x506f5f00, 0x5073d700, 0x50785000, 0x507cc800, 0x50814000, 0x5085b800, 0x508a3000, 0x508ea800, 0x50932000, 0x50979800, 0x509c1000, 0x50a08800, 0x50a50000,
0x50a97800, 0x50adf000, 0x50b26800, 0x50b6e000, 0x50bb5800, 0x50bfd000, 0x50c44800, 0x50c8c000, 0x50cd3800, 0x50d1b000, 0x50d62800, 0x50daa000, 0x50df1800, 0x50e39000, 0x50e80800, 0x50ec8000,
0x50f0f800, 0x50f57000, 0x50f9e800, 0x50fe6000, 0x5102d800, 0x51075000, 0x510bc800, 0x51104000, 0x5114b800, 0x51193000, 0x511da800, 0x51222000, 0x51269800, 0x512b1000, 0x512f8800, 0x51340000,
0x51396800, 0x513ed000, 0x51443800, 0x5149a000, 0x514f0800, 0x51547000, 0x5159d800, 0x515f4000, 0x5164a800, 0x516a1000, 0x516f7800, 0x5174e000, 0x517a4800, 0x517fb000, 0x51851800, 0x518a8000,
0x518fe800, 0x51955000, 0x519ab800, 0x51a02000, 0x51a58800, 0x51aaf000, 0x51b05800, 0x51b5c000, 0x51bb2800, 0x51c09000, 0x51c5f800, 0x51cb6000, 0x51d0c800, 0x51d63000, 0x51db9800, 0x51e10000,
0x51e66800, 0x51ebd000, 0x51f13800, 0x51f6a000, 0x51fc0800, 0x52017000, 0x5206d800, 0x520c4000, 0x5211a800, 0x52171000, 0x521c7800, 0x5221e000, 0x52274800, 0x522cb000, 0x52321800, 0x52378000,
0x523ce800, 0x52425000, 0x5247b800, 0x524d2000, 0x52528800, 0x5257f000, 0x525d5800, 0x5262c000, 0x52682800, 0x526d9000, 0x5272f800, 0x52786000, 0x527dc800, 0x52833000, 0x52889800, 0x528e0000,
0x5293c000, 0x52998000, 0x529f4000, 0x52a50000, 0x52aac000, 0x52b08000, 0x52b64000, 0x52bc0000, 0x52c1bf00, 0x52c77f00, 0x52cd3f00, 0x52d2ff00, 0x52d8bf00, 0x52de7f00, 0x52e43f00, 0x52e9ff00,
0x52efbf00, 0x52f57f00, 0x52fb3f00, 0x5300ff00, 0x5306bf00, 0x530c7f00, 0x53123f00, 0x5317ff00, 0x531dbf00, 0x53237f00, 0x53293f00, 0x532eff00, 0x5334bf00, 0x533a7f00, 0x53403f00, 0x5345ff00,
0x534bbf00, 0x53517f00, 0x53573f00, 0x535cff00, 0x5362bf00, 0x53687f00, 0x536e3f00, 0x5373ff00, 0x5379bf00, 0x537f7f00, 0x53853f00, 0x538aff00, 0x5390bf00, 0x53967f00, 0x539c3f00, 0x53a1ff00,
0x53a7bf00, 0x53ad7f00, 0x53b33f00, 0x53b8ff00, 0x53bebf00, 0x53c47f00, 0x53ca3f00, 0x53cfff00, 0x53d5bf00, 0x53db7f00, 0x53e13f00, 0x53e6ff00, 0x53ecbf00, 0x53f27f00, 0x53f83f00, 0x53fdff00,
0x54055f00, 0x540cbf00, 0x54141f00, 0x541b7f00, 0x5422df00, 0x542a3f00, 0x54319f00, 0x5438ff00, 0x54405f00, 0x5447bf00, 0x544f1f00, 0x54567f00, 0x545ddf00, 0x54653f00, 0x546c9f00, 0x5473ff00,
0x547b5f00, 0x5482bf00, 0x548a1f00, 0x54917f00, 0x5498df00, 0x54a03f00, 0x54a79f00, 0x54aeff00, 0x54b65f00, 0x54bdbf00, 0x54c51f00, 0x54cc7f00, 0x54d3df00, 0x54db3f00, 0x54e29f00, 0x54e9ff00,
0x54f15f00, 0x54f8bf00, 0x55001f00, 0x55077f00, 0x550edf00, 0x55163f00, 0x551d9f00, 0x5524ff00, 0x552c5f00, 0x5533bf00, 0x553b1f00, 0x55427f00, 0x5549df00, 0x55513f00, 0x55589f00, 0x555fff00,
0x55675f00, 0x556ebf00, 0x55761f00, 0x557d7f00, 0x5584df00, 0x558c3f00, 0x55939f00, 0x559aff00, 0x55a25f00, 0x55a9bf00, 0x55b11f00, 0x55b87f00, 0x55bfdf00, 0x55c73f00, 0x55ce9f00, 0x55d5ff00,
0x55de9f00, 0x55e73f00, 0x55efdf00, 0x55f87f00, 0x56011f00, 0x5609bf00, 0x56125f00, 0x561aff00, 0x56239f00, 0x562c3f00, 0x5634df00, 0x563d7f00, 0x56461f00, 0x564ebf00, 0x56575f00, 0x565fff00,
0x56689f00, 0x56713f00, 0x5679df00, 0x56827f00, 0x568b1f00, 0x5693bf00, 0x569c5f00, 0x56a4ff00, 0x56ad9f00, 0x56b63f00, 0x56bedf00, 0x56c77f00, 0x56d01f00, 0x56d8bf00, 0x56e15f00, 0x56e9ff00,
0x56f29f00, 0x56fb3f00, 0x5703df00, 0x570c7f00, 0x57151f00, 0x571dbf00, 0x57265f00, 0x572eff00, 0x57379f00, 0x57403f00, 0x5748df00, 0x57517f00, 0x575a1f00, 0x5762bf00, 0x576b5f00, 0x5773ff00,
0x577c9f00, 0x57853f00, 0x578ddf00, 0x57967f00, 0x579f1f00, 0x57a7bf00, 0x57b05f00, 0x57b8ff00, 0x57c19f00, 0x57ca3f00, 0x57d2df00, 0x57db7f00, 0x57e41f00, 0x57ecbf00, 0x57f55f00, 0x57fdff00,
0x58087f00, 0x5812ff00, 0x581d7f00, 0x5827ff00, 0x58327f00, 0x583cff00, 0x58477f00, 0x5851ff00, 0x585c7f00, 0x5866ff00, 0x58717f00, 0x587bff00, 0x58867f00, 0x5890ff00, 0x589b7f00, 0x58a5ff00,
0x58b07f00, 0x58baff00, 0x58c57f00, 0x58cfff00, 0x58da7f00, 0x58e4ff00, 0x58ef7f00, 0x58f9ff00, 0x59047f00, 0x590eff00, 0x59197f00, 0x5923ff00, 0x592e7f00, 0x5938ff00, 0x59437f00, 0x594dff00,
0x59587f00, 0x5962ff00, 0x596d7f00, 0x5977ff00, 0x59827f00, 0x598cff00, 0x59977f00, 0x59a1ff00, 0x59ac7f00, 0x59b6ff00, 0x59c17f00, 0x59cbff00, 0x59d67f00, 0x59e0ff00, 0x59eb7f00, 0x59f5ff00,
0x5a007f00, 0x5a0aff00, 0x5a157f00, 0x5a1fff00, 0x5a2a7f00, 0x5a34ff00, 0x5a3f7f00, 0x5a49ff00, 0x5a547f00, 0x5a5eff00, 0x5a697f00, 0x5a73ff00, 0x5a7e7f00, 0x5a88ff00, 0x5a937f00, 0x5a9dff00,
0x5aaa0700, 0x5ab60f00, 0x5ac21700, 0x5ace1f00, 0x5ada2700, 0x5ae62f00, 0x5af23700, 0x5afe3f00, 0x5b0a4700, 0x5b164f00, 0x5b225700, 0x5b2e5f00, 0x5b3a6700, 0x5b466f00, 0x5b527700, 0x5b5e7f00,
0x5b6a8700, 0x5b768f00, 0x5b829700, 0x5b8e9f00, 0x5b9aa700, 0x5ba6af00, 0x5bb2b700, 0x5bbebf00, 0x5bcac700, 0x5bd6cf00, 0x5be2d700, 0x5beedf00, 0x5bfae700, 0x5c06ef00, 0x5c12f700, 0x5c1eff00,
0x5c2b0700, 0x5c370f00, 0x5c431700, 0x5c4f1f00, 0x5c5b2700, 0x5c672f00, 0x5c733700, 0x5c7f3f00, 0x5c8b4700, 0x5c974f00, 0x5ca35700, 0x5caf5f00, 0x5cbb6700, 0x5cc76f00, 0x5cd37700, 0x5cdf7f00,
0x5ceb8700, 0x5cf78f00, 0x5d039700, 0x5d0f9f00, 0x5d1ba700, 0x5d27af00, 0x5d33b700, 0x5d3fbf00, 0x5d4bc700, 0x5d57cf00, 0x5d63d700, 0x5d6fdf00, 0x5d7be700, 0x5d87ef00, 0x5d93f700, 0x5da00000,
0x5dac8000, 0x5db90000, 0x5dc58000, 0x5dd20000, 0x5dde8000, 0x5deb0000, 0x5df78000, 0x5e040000, 0x5e108000, 0x5e1d0000, 0x5e298000, 0x5e360000, 0x5e428000, 0x5e4f0000, 0x5e5b8000, 0x5e680000,
0x5e748000, 0x5e810000, 0x5e8d8000, 0x5e9a0000, 0x5ea68000, 0x5eb30000, 0x5ebf8000, 0x5ecc0000, 0x5ed88000, 0x5ee50000, 0x5ef18000, 0x5efe0000, 0x5f0a8000, 0x5f170000, 0x5f238000, 0x5f300000,
0x5f3c8000, 0x5f490000, 0x5f558000, 0x5f620000, 0x5f6e8000, 0x5f7b0000, 0x5f878000, 0x5f940000, 0x5fa08000, 0x5fad0000, 0x5fb98000, 0x5fc60000, 0x5fd28000, 0x5fdf0000, 0x5feb8000, 0x5ff80000,
0x60048000, 0x60110000, 0x601d8000, 0x602a0000, 0x60368000, 0x60430000, 0x604f8000, 0x605c0000, 0x60688000, 0x60750000, 0x60818000, 0x608e0000, 0x609a8000, 0x60a70000, 0x60b38000, 0x60c00000,
0x60cc8000, 0x60d90000, 0x60e58000, 0x60f20000, 0x60fe8000, 0x610b0000, 0x61178000, 0x61240000, 0x61308000, 0x613d0000, 0x61498000, 0x61560000, 0x61628000, 0x616f0000, 0x617b8000, 0x61880000,
0x61948000, 0x61a10000, 0x61ad8000, 0x61ba0000, 0x61c68000, 0x61d30000, 0x61df8000, 0x61ec0000, 0x61f88000, 0x62050000, 0x62118000, 0x621e0000, 0x622a8000, 0x62370000, 0x62438000, 0x62500000,
0x625c8000, 0x62690000, 0x62758000, 0x62820000, 0x628e8000, 0x629b0000, 0x62a78000, 0x62b40000, 0x62c08000, 0x62cd0000, 0x62d98000, 0x62e60000, 0x62f28000, 0x62ff0000, 0x630b8000, 0x63180000,
0x63248000, 0x63310000, 0x633d8000, 0x634a0000, 0x63568000, 0x63630000, 0x636f8000, 0x637c0000, 0x63888000, 0x63950000, 0x63a18000, 0x63ae0000, 0x63ba8000, 0x63c70000, 0x63d38000, 0x63e00000,
0x63ec8000, 0x63f90000, 0x64058000, 0x64120000, 0x641e8000, 0x642b0000, 0x64378000, 0x64440000, 0x64508000, 0x645d0000, 0x64698000, 0x64760000, 0x64828000, 0x648f0000, 0x649b8000, 0x64a80000,
0x64b48000, 0x64c10000, 0x64cd8000, 0x64da0000, 0x64e68000, 0x64f30000, 0x64ff8000, 0x650c0000, 0x65188000, 0x65250000, 0x65318000, 0x653e0000, 0x654a8000, 0x65570000, 0x65638000, 0x65700000,
0x657c8000, 0x65890000, 0x65958000, 0x65a20000, 0x65ae8000, 0x65bb0000, 0x65c78000, 0x65d40000, 0x65e08000, 0x65ed0000, 0x65f98000, 0x66060000, 0x66128000, 0x661f0000, 0x662b8000, 0x66380000,
0x66448000, 0x66510000, 0x665d8000, 0x666a0000, 0x66768000, 0x66830000, 0x668f8000, 0x669c0000, 0x66a88000, 0x66b50000, 0x66c18000, 0x66ce0000, 0x66da8000, 0x66e70000, 0x66f38000, 0x67000000,
0x670c8000, 0x67190000, 0x67258000, 0x67320000, 0x673e8000, 0x674b0000, 0x67578000, 0x67640000, 0x67708000, 0x677d0000, 0x67898000, 0x67960000, 0x67a28000, 0x67af0000, 0x67bb8000, 0x67c80000,
0x67d48000, 0x67e10000, 0x67ed8000, 0x67fa0000, 0x68068000, 0x68130000, 0x681f8000, 0x682c0000, 0x68388000, 0x68450000, 0x68518000, 0x685e0000, 0x686a8000, 0x68770000, 0x68838000, 0x68900000,
0x689c8000, 0x68a90000, 0x68b58000, 0x68c20000, 0x68ce8000, 0x68db0000, 0x68e78000, 0x68f40000, 0x69008000, 0x690d0000, 0x69198000, 0x69260000, 0x69328000, 0x693f0000, 0x694b8000, 0x69580000,
0x69648000, 0x69710000, 0x697d8000, 0x698a0000, 0x69968000, 0x69a30000, 0x69af8000, 0x69bc0000, 0x69c88000, 0x69d50000, 0x69e18000, 0x69ee0000, 0x69fa8000, 0x6a070000, 0x6a138000, 0x6a200000,
0x6a2c8000, 0x6a390000, 0x6a458000, 0x6a520000, 0x6a5e8000, 0x6a6b0000, 0x6a778000, 0x6a840000, 0x6a908000, 0x6a9d0000, 0x6aa98000, 0x6ab60000, 0x6ac28000, 0x6acf0000, 0x6adb8000, 0x6ae80000,
0x6af48000, 0x6b010000, 0x6b0d8000, 0x6b1a0000, 0x6b268000, 0x6b330000, 0x6b3f8000, 0x6b4c0000, 0x6b588000, 0x6b650000, 0x6b718000, 0x6b7e0000, 0x6b8a8000, 0x6b970000, 0x6ba38000, 0x6bb00000,
0x6bbc8000, 0x6bc90000, 0x6bd58000, 0x6be20000, 0x6bee8000, 0x6bfb0000, 0x6c078000, 0x6c140000, 0x6c208000, 0x6c2d0000, 0x6c398000, 0x6c460000, 0x6c528000, 0x6c5f0000, 0x6c6b8000, 0x6c780000,
0x6c848000, 0x6c910000, 0x6c9d8000, 0x6caa0000, 0x6cb68000, 0x6cc30000, 0x6ccf8000, 0x6cdc0000, 0x6ce88000, 0x6cf50000, 0x6d018000, 0x6d0e0000, 0x6d1a8000, 0x6d270000, 0x6d338000, 0x6d400000,
0x6d4c8000, 0x6d590000, 0x6d658000, 0x6d720000, 0x6d7e8000, 0x6d8b0000, 0x6d978000, 0x6da40000, 0x6db08000, 0x6dbd0000, 0x6dc98000, 0x6dd60000, 0x6de28000, 0x6def0000, 0x6dfb8000, 0x6e080000,
0x6e148000, 0x6e210000, 0x6e2d8000, 0x6e3a0000, 0x6e468000, 0x6e530000, 0x6e5f8000, 0x6e6c0000, 0x6e788000, 0x6e850000, 0x6e918000, 0x6e9e0000, 0x6eaa8000, 0x6eb70000, 0x6ec38000, 0x6ed00000,
0x6edc8000, 0x6ee90000, 0x6ef58000, 0x6f020000, 0x6f0e8000, 0x6f1b0000, 0x6f278000, 0x6f340000, 0x6f408000, 0x6f4d0000, 0x6f598000, 0x6f660000, 0x6f728000, 0x6f7f0000, 0x6f8b8000, 0x6f980000,
0x6fa48000, 0x6fb10000, 0x6fbd8000, 0x6fca0000, 0x6fd68000, 0x6fe30000, 0x6fef8000, 0x6ffc0000, 0x70088000, 0x70150000, 0x70218000, 0x702e0000, 0x703a8000, 0x70470000, 0x70538000, 0x70600000,
0x706c8000, 0x70790000, 0x70858000, 0x70920000, 0x709e8000, 0x70ab0000, 0x70b78000, 0x70c40000, 0x70d08000, 0x70dd0000, 0x70e98000, 0x70f60000, 0x71028000, 0x710f0000, 0x711b8000, 0x71280000,
0x71348000, 0x71410000, 0x714d8000, 0x715a0000, 0x71668000, 0x71730000, 0x717f8000, 0x718c0000, 0x71988000, 0x71a50000, 0x71b18000, 0x71be0000, 0x71ca8000, 0x71d70000, 0x71e38000, 0x71f00000,
0x71fc8000, 0x72090000, 0x72158000, 0x72220000, 0x722e8000, 0x723b0000, 0x72478000, 0x72540000, 0x72608000, 0x726d0000, 0x72798000, 0x72860000, 0x72928000, 0x729f0000, 0x72ab8000, 0x72b80000,
0x72c48000, 0x72d10000, 0x72dd8000, 0x72ea0000, 0x72f68000, 0x73030000, 0x730f8000, 0x731c0000, 0x73288000, 0x73350000, 0x73418000, 0x734e0000, 0x735a8000, 0x73670000, 0x73738000, 0x73800000,
0x738c8000, 0x73990000, 0x73a58000, 0x73b20000, 0x73be8000, 0x73cb0000, 0x73d78000, 0x73e40000, 0x73f08000, 0x73fd0000, 0x74098000, 0x74160000, 0x74228000, 0x742f0000, 0x743b8000, 0x74480000,
0x74548000, 0x74610000, 0x746d8000, 0x747a0000, 0x74868000, 0x74930000, 0x749f8000, 0x74ac0000, 0x74b88000, 0x74c50000, 0x74d18000, 0x74de0000, 0x74ea8000, 0x74f70000, 0x75038000, 0x75100000,
0x751c8000, 0x75290000, 0x75358000, 0x75420000, 0x754e8000, 0x755b0000, 0x75678000, 0x75740000, 0x75808000, 0x758d0000, 0x75998000, 0x75a60000, 0x75b28000, 0x75bf0000, 0x75cb8000, 0x75d80000,
0x75e48000, 0x75f10000, 0x75fd8000, 0x760a0000, 0x76168000, 0x76230000, 0x762f8000, 0x763c0000, 0x76488000, 0x76550000, 0x76618000, 0x766e0000, 0x767a8000, 0x76870000, 0x76938000, 0x76a00000,
0x76ac8000, 0x76b90000, 0x76c58000, 0x76d20000, 0x76de8000, 0x76eb0000, 0x76f78000, 0x77040000, 0x77108000, 0x771d0000, 0x77298000, 0x77360000, 0x77428000, 0x774f0000, 0x775b8000, 0x77680000,
0x77748000, 0x77810000, 0x778d8000, 0x779a0000, 0x77a68000, 0x77b30000, 0x77bf8000, 0x77cc0000, 0x77d88000, 0x77e50000, 0x77f18000, 0x77fe0000, 0x780a8000, 0x78170000, 0x78238000, 0x78300000,
0x783c8000, 0x78490000, 0x78558000, 0x78620000, 0x786e8000, 0x787b0000, 0x78878000, 0x78940000, 0x78a08000, 0x78ad0000, 0x78b98000, 0x78c60000, 0x78d28000, 0x78df0000, 0x78eb8000, 0x78f80000,
0x79048000, 0x79110000, 0x791d8000, 0x792a0000, 0x79368000, 0x79430000, 0x794f8000, 0x795c0000, 0x79688000, 0x79750000, 0x79818000, 0x798e0000, 0x799a8000, 0x79a70000, 0x79b38000, 0x79c00000,
0x79cc8000, 0x79d90000, 0x79e58000, 0x79f20000, 0x79fe8000, 0x7a0b0000, 0x7a178000, 0x7a240000, 0x7a308000, 0x7a3d0000, 0x7a498000, 0x7a560000, 0x7a628000, 0x7a6f0000, 0x7a7b8000, 0x7a880000,
0x7a948000, 0x7aa10000, 0x7aad8000, 0x7aba0000, 0x7ac68000, 0x7ad30000, 0x7adf8000, 0x7aec0000, 0x7af88000, 0x7b050000, 0x7b118000, 0x7b1e0000, 0x7b2a8000, 0x7b370000, 0x7b438000, 0x7b500000,
0x7b5c8000, 0x7b690000, 0x7b758000, 0x7b820000, 0x7b8e8000, 0x7b9b0000, 0x7ba78000, 0x7bb40000, 0x7bc08000, 0x7bcd0000, 0x7bd98000, 0x7be60000, 0x7bf28000, 0x7bff0000, 0x7c0b8000, 0x7c180000,
0x7c248000, 0x7c310000, 0x7c3d8000, 0x7c4a0000, 0x7c568000, 0x7c630000, 0x7c6f8000, 0x7c7c0000, 0x7c888000, 0x7c950000, 0x7ca18000, 0x7cae0000, 0x7cba8000, 0x7cc70000, 0x7cd38000, 0x7ce00000,
0x7cec8000, 0x7cf90000, 0x7d058000, 0x7d120000, 0x7d1e8000, 0x7d2b0000, 0x7d378000, 0x7d440000, 0x7d508000, 0x7d5d0000, 0x7d698000, 0x7d760000, 0x7d828000, 0x7d8f0000, 0x7d9b8000, 0x7da80000,
0x7db48000, 0x7dc10000, 0x7dcd8000, 0x7dda0000, 0x7de68000, 0x7df30000, 0x7dff8000, 0x7e0c0000, 0x7e188000, 0x7e250000, 0x7e318000, 0x7e3e0000, 0x7e4a8000, 0x7e570000, 0x7e638000, 0x7e700000,
0x7e7c8000, 0x7e890000, 0x7e958000, 0x7ea20000, 0x7eae8000, 0x7ebb0000, 0x7ec78000, 0x7ed40000, 0x7ee08000, 0x7eed0000, 0x7ef98000, 0x7f060000, 0x7f128000, 0x7f1f0000, 0x7f2b8000, 0x7f380000,
0x7f448000, 0x7f510000, 0x7f5d8000, 0x7f6a0000, 0x7f768000, 0x7f830000, 0x7f8f8000, 0x7f9c0000, 0x7fa88000, 0x7fb50000, 0x7fc18000, 0x7fce0000, 0x7fda8000, 0x7fe70000, 0x7ff38000, 0x80000000
};
static const uint8_t readaheadtab[] = {
0x03, 0x02, 0x01, 0x01, 0x1f, 0x1e, 0x1f, 0x11, 0x1f, 0x1e, 0x1f, 0x1d, 0x1f, 0x1e, 0x1f,
0x10, 0x1f, 0x1e, 0x1f, 0x1d, 0x1f, 0x1e, 0x1f, 0x1c, 0x1f, 0x1e, 0x1f, 0x1d, 0x1f, 0x1e,
0x1f, 0x0f, 0x1f, 0x1e, 0x1f, 0x1d, 0x1f, 0x1e, 0x1f, 0x1c, 0x1f, 0x1e, 0x1f, 0x1d, 0x1f,
0x1e, 0x1f, 0x1b, 0x1f, 0x1e, 0x1f, 0x1d, 0x1f, 0x1e, 0x1f, 0x1c, 0x1f, 0x1e, 0x1f, 0x1d,
0x1f, 0x1e, 0x0e, 0x19, 0x07, 0x1e, 0x1f, 0x1d, 0x1f, 0x1e, 0x1f, 0x1c, 0x1f, 0x1e, 0x1f,
0x1d, 0x1f, 0x1e, 0x1f, 0x1b, 0x1f, 0x1e, 0x1f, 0x1d, 0x1f, 0x1e, 0x1f, 0x1c, 0x1f, 0x1e,
0x1f, 0x1d, 0x1f, 0x1e, 0x1f, 0x1a, 0x1f, 0x1e, 0x1f, 0x1d, 0x1f, 0x1e, 0x1f, 0x1c, 0x1f,
0x1e, 0x1f, 0x1d, 0x1f, 0x1e, 0x1f, 0x1b, 0x1f, 0x1e, 0x1f, 0x1d, 0x1f, 0x1e, 0x1f, 0x1c,
0x1f, 0x1e, 0x1f, 0x1d, 0x1f, 0x0d, 0x18, 0x20, 0x06, 0x1e, 0x1f, 0x12, 0x1f, 0x1e, 0x1f,
0x1c, 0x1f, 0x1e, 0x1f, 0x1d, 0x1f, 0x1e, 0x1f, 0x1b, 0x1f, 0x1e, 0x1f, 0x1d, 0x1f, 0x1e,
0x1f, 0x1c, 0x1f, 0x1e, 0x1f, 0x1d, 0x1f, 0x1e, 0x1f, 0x1a, 0x08, 0x1e, 0x1f, 0x1d, 0x1f,
0x1e, 0x1f, 0x1c, 0x1f, 0x1e, 0x1f, 0x1d, 0x1f, 0x1e, 0x1f, 0x1b, 0x1f, 0x1e, 0x1f, 0x1d,
0x1f, 0x1e, 0x1f, 0x1c, 0x1f, 0x1e, 0x1f, 0x1d, 0x1f, 0x1e, 0x1f, 0x19, 0x1f, 0x13, 0x1f,
0x1d, 0x1f, 0x1e, 0x1f, 0x1c, 0x1f, 0x1e, 0x1f, 0x1d, 0x1f, 0x1e, 0x1f, 0x1b, 0x09, 0x1e,
0x1f, 0x1d, 0x1f, 0x1e, 0x1f, 0x1c, 0x1f, 0x1e, 0x1f, 0x1d, 0x1f, 0x1e, 0x1f, 0x1a, 0x14,
0x1e, 0x1f, 0x1d, 0x1f, 0x1e, 0x1f, 0x1c, 0x0a, 0x1e, 0x1f, 0x1d, 0x1f, 0x1e, 0x1f, 0x1b,
0x15, 0x1e, 0x1f, 0x1d, 0x0b, 0x1e, 0x1f, 0x1c, 0x16, 0x1e, 0x0c, 0x1d, 0x17, 0x1e, 0x1f,
0x20
};
//values between 0 and 1 multiplied by 2^23 to avoid floating point numbers.
static const int32_t gaintab[] = {
0x800000, 0x7ff144, 0x7fe28a, 0x7fd3d2, 0x7fc51b, 0x7fb666, 0x7fa7b3, 0x7f9901, 0x7f8a52, 0x7f7ba3, 0x7f6cf7, 0x7f5e4c, 0x7f4fa3, 0x7f40fc, 0x7f3256,
0x7f23b2, 0x7f1510, 0x7f066f, 0x7ef7d0, 0x7ee933, 0x7eda97, 0x7ecbfd, 0x7ebd65, 0x7eaece, 0x7ea039, 0x7e91a6, 0x7e8315, 0x7e7485, 0x7e65f6, 0x7e576a,
0x7e48df, 0x7e3a56, 0x7e2bce, 0x7e1d49, 0x7e0ec5, 0x7e0042, 0x7df1c1, 0x7de342, 0x7dd4c5, 0x7dc649, 0x7db7cf, 0x7da956, 0x7d9adf, 0x7d8c6a, 0x7d7df7,
0x7d6f85, 0x7d6115, 0x7d52a6, 0x7d443a, 0x7d35ce, 0x7d2765, 0x7d18fd, 0x7d0a97, 0x7cfc32, 0x7cedd0, 0x7cdf6e, 0x7cd10f, 0x7cc2b1, 0x7cb455, 0x7ca5fa,
0x7c97a1, 0x7c894a, 0x7c7af4, 0x7c6ca0, 0x7c5e4e, 0x7c4ffd, 0x7c41ae, 0x7c3361, 0x7c2515, 0x7c16cb, 0x7c0882, 0x7bfa3b, 0x7bebf6, 0x7bddb3, 0x7bcf71,
0x7bc131, 0x7bb2f2, 0x7ba4b5, 0x7b967a, 0x7b8840, 0x7b7a08, 0x7b6bd2, 0x7b5d9d, 0x7b4f6a, 0x7b4138, 0x7b3308, 0x7b24da, 0x7b16ad, 0x7b0882, 0x7afa59,
0x7aec31, 0x7ade0b, 0x7acfe7, 0x7ac1c4, 0x7ab3a3, 0x7aa583, 0x7a9765, 0x7a8949, 0x7a7b2e, 0x7a6d15, 0x7a5efd, 0x7a50e8, 0x7a42d3, 0x7a34c1, 0x7a26b0,
0x7a18a0, 0x7a0a93, 0x79fc87, 0x79ee7c, 0x79e073, 0x79d26c, 0x79c466, 0x79b662, 0x79a860, 0x799a5f, 0x798c60, 0x797e62, 0x797066, 0x79626c, 0x795473,
0x79467c, 0x793886, 0x792a92, 0x791ca0, 0x790eaf, 0x7900c0, 0x78f2d3, 0x78e4e7, 0x78d6fc, 0x78c914, 0x78bb2d, 0x78ad47, 0x789f63, 0x789181, 0x7883a0,
0x7875c1, 0x7867e3, 0x785a07, 0x784c2d, 0x783e54, 0x78307d, 0x7822a8, 0x7814d4, 0x780701, 0x77f931, 0x77eb61, 0x77dd94, 0x77cfc8, 0x77c1fd, 0x77b434,
0x77a66d, 0x7798a8, 0x778ae3, 0x777d21, 0x776f60, 0x7761a1, 0x7753e3, 0x774627, 0x77386c, 0x772ab3, 0x771cfc, 0x770f46, 0x770192, 0x76f3df, 0x76e62e,
0x76d87e, 0x76cad0, 0x76bd24, 0x76af79, 0x76a1d0, 0x769428, 0x768682, 0x7678de, 0x766b3b, 0x765d99, 0x764ffa, 0x76425b, 0x7634bf, 0x762723, 0x76198a,
0x760bf2, 0x75fe5c, 0x75f0c7, 0x75e333, 0x75d5a2, 0x75c811, 0x75ba83, 0x75acf6, 0x759f6a, 0x7591e0, 0x758458, 0x7576d1, 0x75694c, 0x755bc8, 0x754e46,
0x7540c6, 0x753347, 0x7525c9, 0x75184d, 0x750ad3, 0x74fd5a, 0x74efe3, 0x74e26d, 0x74d4f9, 0x74c786, 0x74ba15, 0x74aca6, 0x749f38, 0x7491cb, 0x748460,
0x7476f7, 0x74698f, 0x745c29, 0x744ec4, 0x744161, 0x7433ff, 0x74269f, 0x741941, 0x740be4, 0x73fe88, 0x73f12e, 0x73e3d6, 0x73d67f, 0x73c92a, 0x73bbd6,
0x73ae84, 0x73a133, 0x7393e4, 0x738696, 0x73794a, 0x736bff, 0x735eb6, 0x73516f, 0x734429, 0x7336e4, 0x7329a1, 0x731c60, 0x730f20, 0x7301e1, 0x72f4a5,
0x72e769, 0x72da2f, 0x72ccf7, 0x72bfc0, 0x72b28b, 0x72a557, 0x729825, 0x728af4, 0x727dc5, 0x727098, 0x72636c, 0x725641, 0x724918, 0x723bf0, 0x722eca,
0x7221a6, 0x721482, 0x720761, 0x71fa41, 0x71ed22, 0x71e005, 0x71d2ea, 0x71c5d0, 0x71b8b7, 0x71aba0, 0x719e8b, 0x719177, 0x718465, 0x717754, 0x716a44,
0x715d36, 0x71502a, 0x71431f, 0x713615, 0x71290e, 0x711c07, 0x710f02, 0x7101ff, 0x70f4fd, 0x70e7fc, 0x70dafd, 0x70ce00, 0x70c104, 0x70b40a, 0x70a711,
0x709a19, 0x708d23, 0x70802f, 0x70733c, 0x70664a, 0x70595a, 0x704c6c, 0x703f7f, 0x703293, 0x7025a9, 0x7018c0, 0x700bd9, 0x6ffef4, 0x6ff20f, 0x6fe52d,
0x6fd84c, 0x6fcb6c, 0x6fbe8e, 0x6fb1b1, 0x6fa4d6, 0x6f97fc, 0x6f8b24, 0x6f7e4d, 0x6f7178, 0x6f64a4, 0x6f57d2, 0x6f4b01, 0x6f3e31, 0x6f3163, 0x6f2497,
0x6f17cc, 0x6f0b02, 0x6efe3a, 0x6ef174, 0x6ee4af, 0x6ed7eb, 0x6ecb29, 0x6ebe68, 0x6eb1a9, 0x6ea4eb, 0x6e982f, 0x6e8b74, 0x6e7ebb, 0x6e7203, 0x6e654c,
0x6e5897, 0x6e4be4, 0x6e3f32, 0x6e3281, 0x6e25d2, 0x6e1924, 0x6e0c78, 0x6dffcd, 0x6df324, 0x6de67c, 0x6dd9d6, 0x6dcd31, 0x6dc08e, 0x6db3ec, 0x6da74b,
0x6d9aac, 0x6d8e0e, 0x6d8172, 0x6d74d7, 0x6d683e, 0x6d5ba6, 0x6d4f10, 0x6d427b, 0x6d35e7, 0x6d2955, 0x6d1cc5, 0x6d1036, 0x6d03a8, 0x6cf71c, 0x6cea91,
0x6cde07, 0x6cd17f, 0x6cc4f9, 0x6cb874, 0x6cabf0, 0x6c9f6e, 0x6c92ed, 0x6c866e, 0x6c79f0, 0x6c6d74, 0x6c60f9, 0x6c547f, 0x6c4807, 0x6c3b91, 0x6c2f1b,
0x6c22a8, 0x6c1635, 0x6c09c4, 0x6bfd55, 0x6bf0e7, 0x6be47a, 0x6bd80f, 0x6bcba5, 0x6bbf3d, 0x6bb2d6, 0x6ba670, 0x6b9a0c, 0x6b8daa, 0x6b8148, 0x6b74e9,
0x6b688a, 0x6b5c2d, 0x6b4fd2, 0x6b4378, 0x6b371f, 0x6b2ac8, 0x6b1e72, 0x6b121d, 0x6b05ca, 0x6af979, 0x6aed29, 0x6ae0da, 0x6ad48d, 0x6ac841, 0x6abbf6,
0x6aafad, 0x6aa365, 0x6a971f, 0x6a8ada, 0x6a7e97, 0x6a7255, 0x6a6614, 0x6a59d5, 0x6a4d97, 0x6a415b, 0x6a3520, 0x6a28e6, 0x6a1cae, 0x6a1078, 0x6a0442,
0x69f80e, 0x69ebdc, 0x69dfab, 0x69d37b, 0x69c74d, 0x69bb20, 0x69aef4, 0x69a2ca, 0x6996a1, 0x698a7a, 0x697e54, 0x697230, 0x69660c, 0x6959eb, 0x694dca,
0x6941ab, 0x69358e, 0x692972, 0x691d57, 0x69113e, 0x690526, 0x68f90f, 0x68ecfa, 0x68e0e6, 0x68d4d4, 0x68c8c3, 0x68bcb3, 0x68b0a5, 0x68a498, 0x68988d,
0x688c83, 0x68807a, 0x687473, 0x68686d, 0x685c68, 0x685065, 0x684463, 0x683863, 0x682c64, 0x682066, 0x68146a, 0x68086f, 0x67fc76, 0x67f07d, 0x67e487,
0x67d891, 0x67cc9d, 0x67c0ab, 0x67b4ba, 0x67a8ca, 0x679cdb, 0x6790ee, 0x678502, 0x677918, 0x676d2f, 0x676147, 0x675561, 0x67497c, 0x673d99, 0x6731b7,
0x6725d6, 0x6719f7, 0x670e19, 0x67023c, 0x66f661, 0x66ea87, 0x66deae, 0x66d2d7, 0x66c701, 0x66bb2d, 0x66af59, 0x66a388, 0x6697b7, 0x668be8, 0x66801a,
0x66744e, 0x666883, 0x665cba, 0x6650f1, 0x66452a, 0x663965, 0x662da1, 0x6621de, 0x66161c, 0x660a5c, 0x65fe9e, 0x65f2e0, 0x65e724, 0x65db69, 0x65cfb0,
0x65c3f8, 0x65b841, 0x65ac8c, 0x65a0d8, 0x659525, 0x658974, 0x657dc4, 0x657216, 0x656668, 0x655abc, 0x654f12, 0x654369, 0x6537c1, 0x652c1a, 0x652075,
0x6514d1, 0x65092f, 0x64fd8d, 0x64f1ee, 0x64e64f, 0x64dab2, 0x64cf16, 0x64c37c, 0x64b7e3, 0x64ac4b, 0x64a0b4, 0x64951f, 0x64898b, 0x647df9, 0x647268,
0x6466d8, 0x645b49, 0x644fbc, 0x644430, 0x6438a6, 0x642d1d, 0x642195, 0x64160e, 0x640a89, 0x63ff05, 0x63f383, 0x63e802, 0x63dc82, 0x63d103, 0x63c586,
0x63ba0a, 0x63ae8f, 0x63a316, 0x63979e, 0x638c28, 0x6380b2, 0x63753e, 0x6369cc, 0x635e5a, 0x6352ea, 0x63477b, 0x633c0e, 0x6330a2, 0x632537, 0x6319ce,
0x630e66, 0x6302ff, 0x62f799, 0x62ec35, 0x62e0d2, 0x62d571, 0x62ca10, 0x62beb1, 0x62b354, 0x62a7f7, 0x629c9c, 0x629142, 0x6285ea, 0x627a93, 0x626f3d,
0x6263e9, 0x625895, 0x624d43, 0x6241f3, 0x6236a4, 0x622b56, 0x622009, 0x6214bd, 0x620973, 0x61fe2b, 0x61f2e3, 0x61e79d, 0x61dc58, 0x61d114, 0x61c5d2,
0x61ba91, 0x61af51, 0x61a413, 0x6198d6, 0x618d9a, 0x61825f, 0x617726, 0x616bee, 0x6160b7, 0x615582, 0x614a4e, 0x613f1b, 0x6133ea, 0x6128b9, 0x611d8a,
0x61125d, 0x610730, 0x60fc05, 0x60f0dc, 0x60e5b3, 0x60da8c, 0x60cf66, 0x60c441, 0x60b91e, 0x60adfc, 0x60a2db, 0x6097bc, 0x608c9d, 0x608180, 0x607665,
0x606b4a, 0x606031, 0x605519, 0x604a03, 0x603eed, 0x6033d9, 0x6028c7, 0x601db5, 0x6012a5, 0x600796, 0x5ffc88, 0x5ff17c, 0x5fe671, 0x5fdb67, 0x5fd05e,
0x5fc557, 0x5fba51, 0x5faf4c, 0x5fa449, 0x5f9947, 0x5f8e46, 0x5f8346, 0x5f7848, 0x5f6d4a, 0x5f624e, 0x5f5754, 0x5f4c5a, 0x5f4162, 0x5f366c, 0x5f2b76,
0x5f2082, 0x5f158f, 0x5f0a9d, 0x5effac, 0x5ef4bd, 0x5ee9cf, 0x5edee2, 0x5ed3f7, 0x5ec90c, 0x5ebe23, 0x5eb33c, 0x5ea855, 0x5e9d70, 0x5e928c, 0x5e87a9,
0x5e7cc8, 0x5e71e8, 0x5e6709, 0x5e5c2b, 0x5e514f, 0x5e4673, 0x5e3b99, 0x5e30c1, 0x5e25e9, 0x5e1b13, 0x5e103e, 0x5e056a, 0x5dfa98, 0x5defc7, 0x5de4f7,
0x5dda28, 0x5dcf5a, 0x5dc48e, 0x5db9c3, 0x5daef9, 0x5da431, 0x5d996a, 0x5d8ea4, 0x5d83df, 0x5d791b, 0x5d6e59, 0x5d6398, 0x5d58d8, 0x5d4e19, 0x5d435c,
0x5d38a0, 0x5d2de5, 0x5d232b, 0x5d1873, 0x5d0dbc, 0x5d0306, 0x5cf851, 0x5ced9d, 0x5ce2eb, 0x5cd83a, 0x5ccd8a, 0x5cc2dc, 0x5cb82e, 0x5cad82, 0x5ca2d7,
0x5c982e, 0x5c8d85, 0x5c82de, 0x5c7838, 0x5c6d93, 0x5c62f0, 0x5c584e, 0x5c4dad, 0x5c430d, 0x5c386e, 0x5c2dd1, 0x5c2334, 0x5c1899, 0x5c0e00, 0x5c0367,
0x5bf8d0, 0x5bee3a, 0x5be3a5, 0x5bd911, 0x5bce7f, 0x5bc3ee, 0x5bb95e, 0x5baecf, 0x5ba441, 0x5b99b5, 0x5b8f2a, 0x5b84a0, 0x5b7a17, 0x5b6f90, 0x5b6509,
0x5b5a84, 0x5b5000, 0x5b457e, 0x5b3afc, 0x5b307c, 0x5b25fd, 0x5b1b7f, 0x5b1103, 0x5b0687, 0x5afc0d, 0x5af194, 0x5ae71c, 0x5adca6, 0x5ad230, 0x5ac7bc,
0x5abd49, 0x5ab2d7, 0x5aa867, 0x5a9df7, 0x5a9389, 0x5a891c, 0x5a7eb1, 0x5a7446, 0x5a69dd, 0x5a5f74, 0x5a550d, 0x5a4aa8, 0x5a4043, 0x5a35e0, 0x5a2b7e,
0x5a211d, 0x5a16bd, 0x5a0c5e, 0x5a0201, 0x59f7a5, 0x59ed4a, 0x59e2f0, 0x59d897, 0x59ce40, 0x59c3e9, 0x59b994, 0x59af40, 0x59a4ee, 0x599a9c, 0x59904c,
0x5985fd, 0x597baf, 0x597162, 0x596717, 0x595ccc, 0x595283, 0x59483b, 0x593df4, 0x5933ae, 0x59296a, 0x591f27, 0x5914e5, 0x590aa4, 0x590064, 0x58f625,
0x58ebe8, 0x58e1ac, 0x58d771, 0x58cd37, 0x58c2fe, 0x58b8c7, 0x58ae90, 0x58a45b, 0x589a27, 0x588ff5, 0x5885c3, 0x587b93, 0x587163, 0x586735, 0x585d08,
0x5852dc, 0x5848b2, 0x583e88, 0x583460, 0x582a39, 0x582013, 0x5815ee, 0x580bcb, 0x5801a9, 0x57f787, 0x57ed67, 0x57e348, 0x57d92b, 0x57cf0e, 0x57c4f3,
0x57bad8, 0x57b0bf, 0x57a6a7, 0x579c91, 0x57927b, 0x578866, 0x577e53, 0x577441, 0x576a30, 0x576020, 0x575612, 0x574c04, 0x5741f8, 0x5737ed, 0x572de3,
0x5723da, 0x5719d2, 0x570fcc, 0x5705c6, 0x56fbc2, 0x56f1bf, 0x56e7bd, 0x56ddbc, 0x56d3bc, 0x56c9be, 0x56bfc1, 0x56b5c4, 0x56abc9, 0x56a1cf, 0x5697d7,
0x568ddf, 0x5683e9, 0x5679f3, 0x566fff, 0x56660c, 0x565c1a, 0x56522a, 0x56483a, 0x563e4c, 0x56345e, 0x562a72, 0x562087, 0x56169d, 0x560cb5, 0x5602cd,
0x55f8e7, 0x55ef01, 0x55e51d, 0x55db3a, 0x55d158, 0x55c777, 0x55bd98, 0x55b3b9, 0x55a9dc, 0x55a000, 0x559625, 0x558c4b, 0x558272, 0x55789a, 0x556ec4,
0x5564ee, 0x555b1a, 0x555147, 0x554775, 0x553da4, 0x5533d4, 0x552a06, 0x552038, 0x55166c, 0x550ca1, 0x5502d7, 0x54f90e, 0x54ef46, 0x54e57f, 0x54dbba,
0x54d1f5, 0x54c832, 0x54be6f, 0x54b4ae, 0x54aaee, 0x54a130, 0x549772, 0x548db5, 0x5483fa, 0x547a3f, 0x547086, 0x5466ce, 0x545d17, 0x545361, 0x5449ac,
0x543ff9, 0x543646, 0x542c95, 0x5422e4, 0x541935, 0x540f87, 0x5405da, 0x53fc2e, 0x53f283, 0x53e8da, 0x53df31, 0x53d58a, 0x53cbe4, 0x53c23e, 0x53b89a,
0x53aef7, 0x53a555, 0x539bb5, 0x539215, 0x538877, 0x537ed9, 0x53753d, 0x536ba2, 0x536208, 0x53586f, 0x534ed7, 0x534540, 0x533baa, 0x533216, 0x532882,
0x531ef0, 0x53155e, 0x530bce, 0x53023f, 0x52f8b1, 0x52ef24, 0x52e599, 0x52dc0e, 0x52d284, 0x52c8fc, 0x52bf74, 0x52b5ee, 0x52ac69, 0x52a2e5, 0x529962,
0x528fe0, 0x52865f, 0x527cdf, 0x527361, 0x5269e3, 0x526067, 0x5256eb, 0x524d71, 0x5243f8, 0x523a80, 0x523109, 0x522793, 0x521e1e, 0x5214ab, 0x520b38,
0x5201c6, 0x51f856, 0x51eee7, 0x51e578, 0x51dc0b, 0x51d29f, 0x51c934, 0x51bfca, 0x51b661, 0x51acf9, 0x51a393, 0x519a2d, 0x5190c9, 0x518765, 0x517e03,
0x5174a1, 0x516b41, 0x5161e2, 0x515884, 0x514f27, 0x5145cb, 0x513c70, 0x513317, 0x5129be, 0x512066, 0x511710, 0x510dba, 0x510466, 0x50fb13, 0x50f1c1,
0x50e86f, 0x50df1f, 0x50d5d0, 0x50cc82, 0x50c336, 0x50b9ea, 0x50b09f, 0x50a755, 0x509e0d, 0x5094c5, 0x508b7f, 0x50823a, 0x5078f5, 0x506fb2, 0x506670,
0x505d2f, 0x5053ef, 0x504ab0, 0x504172, 0x503835, 0x502ef9, 0x5025be, 0x501c85, 0x50134c, 0x500a15, 0x5000de, 0x4ff7a9, 0x4fee74, 0x4fe541, 0x4fdc0f,
0x4fd2de, 0x4fc9ae, 0x4fc07e, 0x4fb750, 0x4fae23, 0x4fa4f8, 0x4f9bcd, 0x4f92a3, 0x4f897a, 0x4f8053, 0x4f772c, 0x4f6e06, 0x4f64e2, 0x4f5bbe, 0x4f529c,
0x4f497b, 0x4f405a, 0x4f373b, 0x4f2e1d, 0x4f2500, 0x4f1be4, 0x4f12c9, 0x4f09af, 0x4f0096, 0x4ef77e, 0x4eee67, 0x4ee551, 0x4edc3c, 0x4ed328, 0x4eca16,
0x4ec104, 0x4eb7f3, 0x4eaee4, 0x4ea5d5, 0x4e9cc8, 0x4e93bc, 0x4e8ab0, 0x4e81a6, 0x4e789c, 0x4e6f94, 0x4e668d, 0x4e5d87, 0x4e5482, 0x4e4b7e, 0x4e427a,
0x4e3978, 0x4e3077, 0x4e2777, 0x4e1e79, 0x4e157b, 0x4e0c7e, 0x4e0382, 0x4dfa87, 0x4df18d, 0x4de895, 0x4ddf9d, 0x4dd6a6, 0x4dcdb1, 0x4dc4bc, 0x4dbbc9,
0x4db2d6, 0x4da9e5, 0x4da0f4, 0x4d9805, 0x4d8f16, 0x4d8629, 0x4d7d3c, 0x4d7451, 0x4d6b67, 0x4d627e, 0x4d5995, 0x4d50ae, 0x4d47c8, 0x4d3ee3, 0x4d35ff,
0x4d2d1b, 0x4d2439, 0x4d1b58, 0x4d1278, 0x4d0999, 0x4d00bb, 0x4cf7de, 0x4cef02, 0x4ce627, 0x4cdd4d, 0x4cd474, 0x4ccb9c, 0x4cc2c5, 0x4cb9f0, 0x4cb11b,
0x4ca847, 0x4c9f74, 0x4c96a2, 0x4c8dd1, 0x4c8502, 0x4c7c33, 0x4c7365, 0x4c6a98, 0x4c61cd, 0x4c5902, 0x4c5038, 0x4c4770, 0x4c3ea8, 0x4c35e1, 0x4c2d1c,
0x4c2457, 0x4c1b93, 0x4c12d1, 0x4c0a0f, 0x4c014f, 0x4bf88f, 0x4befd0, 0x4be713, 0x4bde56, 0x4bd59b, 0x4bcce0, 0x4bc426, 0x4bbb6e, 0x4bb2b6, 0x4baa00,
0x4ba14a, 0x4b9896, 0x4b8fe2, 0x4b8730, 0x4b7e7e, 0x4b75cd, 0x4b6d1e, 0x4b646f, 0x4b5bc2, 0x4b5315, 0x4b4a6a, 0x4b41bf, 0x4b3916, 0x4b306d, 0x4b27c6,
0x4b1f1f, 0x4b1679, 0x4b0dd5, 0x4b0531, 0x4afc8f, 0x4af3ed, 0x4aeb4c, 0x4ae2ad, 0x4ada0e, 0x4ad171, 0x4ac8d4, 0x4ac038, 0x4ab79e, 0x4aaf04, 0x4aa66b,
0x4a9dd4, 0x4a953d, 0x4a8ca7, 0x4a8413, 0x4a7b7f, 0x4a72ec, 0x4a6a5a, 0x4a61ca, 0x4a593a, 0x4a50ab, 0x4a481d, 0x4a3f91, 0x4a3705, 0x4a2e7a, 0x4a25f0,
0x4a1d67, 0x4a14df, 0x4a0c58, 0x4a03d2, 0x49fb4d, 0x49f2c9, 0x49ea46, 0x49e1c4, 0x49d943, 0x49d0c3, 0x49c844, 0x49bfc6, 0x49b749, 0x49aecd, 0x49a652,
0x499dd7, 0x49955e, 0x498ce6, 0x49846f, 0x497bf8, 0x497383, 0x496b0f, 0x49629b, 0x495a29, 0x4951b8, 0x494947, 0x4940d8, 0x493869, 0x492ffc, 0x49278f,
0x491f23, 0x4916b9, 0x490e4f, 0x4905e6, 0x48fd7f, 0x48f518, 0x48ecb2, 0x48e44d, 0x48dbe9, 0x48d386, 0x48cb25, 0x48c2c4, 0x48ba64, 0x48b205, 0x48a9a6,
0x48a149, 0x4898ed, 0x489092, 0x488838, 0x487fdf, 0x487786, 0x486f2f, 0x4866d8, 0x485e83, 0x48562f, 0x484ddb, 0x484589, 0x483d37, 0x4834e6, 0x482c97,
0x482448, 0x481bfa, 0x4813ad, 0x480b62, 0x480317, 0x47facd, 0x47f284, 0x47ea3c, 0x47e1f5, 0x47d9ae, 0x47d169, 0x47c925, 0x47c0e2, 0x47b89f, 0x47b05e,
0x47a81e, 0x479fde, 0x4797a0, 0x478f62, 0x478725, 0x477eea, 0x4776af, 0x476e75, 0x47663c, 0x475e05, 0x4755ce, 0x474d98, 0x474563, 0x473d2f, 0x4734fb,
0x472cc9, 0x472498, 0x471c68, 0x471438, 0x470c0a, 0x4703dc, 0x46fbb0, 0x46f384, 0x46eb59, 0x46e330, 0x46db07, 0x46d2df, 0x46cab8, 0x46c292, 0x46ba6d,
0x46b249, 0x46aa26, 0x46a203, 0x4699e2, 0x4691c2, 0x4689a2, 0x468184, 0x467966, 0x46714a, 0x46692e, 0x466113, 0x4658f9, 0x4650e0, 0x4648c9, 0x4640b1,
0x46389b, 0x463086, 0x462872, 0x46205f, 0x46184c, 0x46103b, 0x46082a, 0x46001b, 0x45f80c, 0x45effe, 0x45e7f2, 0x45dfe6, 0x45d7db, 0x45cfd1, 0x45c7c8,
0x45bfbf, 0x45b7b8, 0x45afb2, 0x45a7ac, 0x459fa8, 0x4597a4, 0x458fa2, 0x4587a0, 0x457f9f, 0x45779f, 0x456fa0, 0x4567a2, 0x455fa5, 0x4557a9, 0x454fae,
0x4547b3, 0x453fba, 0x4537c1, 0x452fca, 0x4527d3, 0x451fdd, 0x4517e8, 0x450ff5, 0x450802, 0x45000f, 0x44f81e, 0x44f02e, 0x44e83f, 0x44e050, 0x44d863,
0x44d076, 0x44c88a, 0x44c09f, 0x44b8b6, 0x44b0cd, 0x44a8e4, 0x44a0fd, 0x449917, 0x449132, 0x44894d, 0x44816a, 0x447987, 0x4471a5, 0x4469c5, 0x4461e5,
0x445a06, 0x445228, 0x444a4b, 0x44426e, 0x443a93, 0x4432b8, 0x442adf, 0x442306, 0x441b2e, 0x441358, 0x440b82, 0x4403ad, 0x43fbd8, 0x43f405, 0x43ec33,
0x43e461, 0x43dc91, 0x43d4c1, 0x43ccf3, 0x43c525, 0x43bd58, 0x43b58c, 0x43adc1, 0x43a5f6, 0x439e2d, 0x439664, 0x438e9d, 0x4386d6, 0x437f10, 0x43774c,
0x436f88, 0x4367c5, 0x436002, 0x435841, 0x435081, 0x4348c1, 0x434102, 0x433945, 0x433188, 0x4329cc, 0x432211, 0x431a57, 0x43129d, 0x430ae5, 0x43032e,
0x42fb77, 0x42f3c1, 0x42ec0c, 0x42e458, 0x42dca5, 0x42d4f3, 0x42cd42, 0x42c591, 0x42bde2, 0x42b633, 0x42ae85, 0x42a6d9, 0x429f2d, 0x429781, 0x428fd7,
0x42882e, 0x428085, 0x4278de, 0x427137, 0x426991, 0x4261ec, 0x425a48, 0x4252a5, 0x424b03, 0x424361, 0x423bc1, 0x423421, 0x422c82, 0x4224e5, 0x421d48,
0x4215ab, 0x420e10, 0x420676, 0x41fedc, 0x41f744, 0x41efac, 0x41e815, 0x41e07f, 0x41d8ea, 0x41d155, 0x41c9c2, 0x41c22f, 0x41ba9e, 0x41b30d, 0x41ab7d,
0x41a3ee, 0x419c60, 0x4194d2, 0x418d46, 0x4185ba, 0x417e30, 0x4176a6, 0x416f1d, 0x416795, 0x41600d, 0x415887, 0x415102, 0x41497d, 0x4141f9, 0x413a76,
0x4132f4, 0x412b73, 0x4123f3, 0x411c73, 0x4114f5, 0x410d77, 0x4105fa, 0x40fe7e, 0x40f703, 0x40ef89, 0x40e80f, 0x40e097, 0x40d91f, 0x40d1a8, 0x40ca32,
0x40c2bd, 0x40bb49, 0x40b3d5, 0x40ac63, 0x40a4f1, 0x409d80, 0x409610, 0x408ea1, 0x408733, 0x407fc5, 0x407859, 0x4070ed, 0x406982, 0x406218, 0x405aaf,
0x405347, 0x404bdf, 0x404479, 0x403d13, 0x4035ae, 0x402e4a, 0x4026e7, 0x401f85, 0x401823, 0x4010c3, 0x400963, 0x400204, 0x3ffaa6, 0x3ff348, 0x3febec,
0x3fe490, 0x3fdd36, 0x3fd5dc, 0x3fce83, 0x3fc72b, 0x3fbfd3, 0x3fb87d, 0x3fb127, 0x3fa9d3, 0x3fa27f, 0x3f9b2c, 0x3f93d9, 0x3f8c88, 0x3f8537, 0x3f7de8,
0x3f7699, 0x3f6f4b, 0x3f67fd, 0x3f60b1, 0x3f5966, 0x3f521b, 0x3f4ad1, 0x3f4388, 0x3f3c40, 0x3f34f9, 0x3f2db2, 0x3f266c, 0x3f1f28, 0x3f17e4, 0x3f10a1,
0x3f095e, 0x3f021d, 0x3efadc, 0x3ef39c, 0x3eec5d, 0x3ee51f, 0x3edde2, 0x3ed6a6, 0x3ecf6a, 0x3ec82f, 0x3ec0f5, 0x3eb9bc, 0x3eb284, 0x3eab4c, 0x3ea416,
0x3e9ce0, 0x3e95ab, 0x3e8e77, 0x3e8743, 0x3e8011, 0x3e78df, 0x3e71ae, 0x3e6a7e, 0x3e634f, 0x3e5c21, 0x3e54f3, 0x3e4dc7, 0x3e469b, 0x3e3f70, 0x3e3845,
0x3e311c, 0x3e29f3, 0x3e22cc, 0x3e1ba5, 0x3e147f, 0x3e0d59, 0x3e0635, 0x3dff11, 0x3df7ef, 0x3df0cd, 0x3de9ab, 0x3de28b, 0x3ddb6b, 0x3dd44d, 0x3dcd2f,
0x3dc612, 0x3dbef6, 0x3db7da, 0x3db0c0, 0x3da9a6, 0x3da28d, 0x3d9b75, 0x3d945d, 0x3d8d47, 0x3d8631, 0x3d7f1c, 0x3d7808, 0x3d70f5, 0x3d69e2, 0x3d62d1,
0x3d5bc0, 0x3d54b0, 0x3d4da1, 0x3d4692, 0x3d3f85, 0x3d3878, 0x3d316c, 0x3d2a61, 0x3d2356, 0x3d1c4d, 0x3d1544, 0x3d0e3c, 0x3d0735, 0x3d002f, 0x3cf929,
0x3cf225, 0x3ceb21, 0x3ce41e, 0x3cdd1c, 0x3cd61a, 0x3ccf1a, 0x3cc81a, 0x3cc11b, 0x3cba1c, 0x3cb31f, 0x3cac22, 0x3ca527, 0x3c9e2c, 0x3c9731, 0x3c9038,
0x3c893f, 0x3c8248, 0x3c7b51, 0x3c745b, 0x3c6d65, 0x3c6671, 0x3c5f7d, 0x3c588a, 0x3c5198, 0x3c4aa6, 0x3c43b6, 0x3c3cc6, 0x3c35d7, 0x3c2ee9, 0x3c27fb,
0x3c210f, 0x3c1a23, 0x3c1338, 0x3c0c4e, 0x3c0564, 0x3bfe7c, 0x3bf794, 0x3bf0ad, 0x3be9c7, 0x3be2e1, 0x3bdbfd, 0x3bd519, 0x3bce36, 0x3bc753, 0x3bc072,
0x3bb991, 0x3bb2b1, 0x3babd2, 0x3ba4f4, 0x3b9e17, 0x3b973a, 0x3b905e, 0x3b8983, 0x3b82a8, 0x3b7bcf, 0x3b74f6, 0x3b6e1e, 0x3b6747, 0x3b6070, 0x3b599b,
0x3b52c6, 0x3b4bf2, 0x3b451f, 0x3b3e4c, 0x3b377b, 0x3b30aa, 0x3b29da, 0x3b230a, 0x3b1c3c, 0x3b156e, 0x3b0ea1, 0x3b07d5, 0x3b0109, 0x3afa3f, 0x3af375,
0x3aecac, 0x3ae5e3, 0x3adf1c, 0x3ad855, 0x3ad18f, 0x3acaca, 0x3ac406, 0x3abd42, 0x3ab67f, 0x3aafbd, 0x3aa8fc, 0x3aa23b, 0x3a9b7c, 0x3a94bd, 0x3a8dfe,
0x3a8741, 0x3a8084, 0x3a79c9, 0x3a730d, 0x3a6c53, 0x3a659a, 0x3a5ee1, 0x3a5829, 0x3a5172, 0x3a4abb, 0x3a4406, 0x3a3d51, 0x3a369d, 0x3a2fe9, 0x3a2937,
0x3a2285, 0x3a1bd4, 0x3a1524, 0x3a0e74, 0x3a07c5, 0x3a0118, 0x39fa6a, 0x39f3be, 0x39ed12, 0x39e667, 0x39dfbd, 0x39d914, 0x39d26b, 0x39cbc4, 0x39c51d,
0x39be76, 0x39b7d1, 0x39b12c, 0x39aa88, 0x39a3e5, 0x399d42, 0x3996a1, 0x399000, 0x398960, 0x3982c0, 0x397c22, 0x397584, 0x396ee7, 0x39684a, 0x3961af,
0x395b14, 0x39547a, 0x394de0, 0x394748, 0x3940b0, 0x393a19, 0x393383, 0x392ced, 0x392658, 0x391fc4, 0x391931, 0x39129f, 0x390c0d, 0x39057c, 0x38feec,
0x38f85c, 0x38f1ce, 0x38eb40, 0x38e4b2, 0x38de26, 0x38d79a, 0x38d10f, 0x38ca85, 0x38c3fc, 0x38bd73, 0x38b6eb, 0x38b064, 0x38a9de, 0x38a358, 0x389cd3,
0x38964f, 0x388fcb, 0x388949, 0x3882c7, 0x387c46, 0x3875c5, 0x386f45, 0x3868c7, 0x386248, 0x385bcb, 0x38554e, 0x384ed2, 0x384857, 0x3841dd, 0x383b63,
0x3834ea, 0x382e72, 0x3827fa, 0x382184, 0x381b0e, 0x381498, 0x380e24, 0x3807b0, 0x38013d, 0x37facb, 0x37f459, 0x37ede9, 0x37e778, 0x37e109, 0x37da9b,
0x37d42d, 0x37cdc0, 0x37c753, 0x37c0e8, 0x37ba7d, 0x37b413, 0x37ada9, 0x37a741, 0x37a0d9, 0x379a72, 0x37940b, 0x378da6, 0x378741, 0x3780dc, 0x377a79,
0x377416, 0x376db4, 0x376753, 0x3760f2, 0x375a93, 0x375433, 0x374dd5, 0x374777, 0x37411b, 0x373abe, 0x373463, 0x372e08, 0x3727ae, 0x372155, 0x371afd,
0x3714a5, 0x370e4e, 0x3707f8, 0x3701a2, 0x36fb4d, 0x36f4f9, 0x36eea6, 0x36e853, 0x36e201, 0x36dbb0, 0x36d55f, 0x36cf10, 0x36c8c1, 0x36c272, 0x36bc25,
0x36b5d8, 0x36af8c, 0x36a940, 0x36a2f6, 0x369cac, 0x369663, 0x36901a, 0x3689d2, 0x36838b, 0x367d45, 0x3676ff, 0x3670ba, 0x366a76, 0x366433, 0x365df0,
0x3657ae, 0x36516d, 0x364b2c, 0x3644ec, 0x363ead, 0x36386f, 0x363231, 0x362bf4, 0x3625b8, 0x361f7c, 0x361942, 0x361308, 0x360cce, 0x360695, 0x36005e,
0x35fa26
};
#define HDCD_PROCESS_STEREO_DEFAULT 1
#define HDCD_MAX_CHANNELS 2
/** convert to float from 4-bit (3.1) fixed-point
* the always-negative value is stored positive, so make it negative */
#define GAINTOFLOAT(g) (g) ? -(float)(g>>1) - ((g & 1) ? 0.5 : 0.0) : 0.0
/** apply gain, 11-bit (3.8) fixed point,
* always negative but stored positive. */
#define APPLY_GAIN(s,g) do{int64_t s64 = s; s64 *= gaintab[g]; s = (int32_t)(s64 >> 23); }while(0);
/** tone generator: sample_number, frequency, sample_rate, amplitude */
#define TONEGEN16(sn, f, sr, a) (int16_t)(sin((6.28318530718 * (sn) * (f)) /(sr)) * (a) * 0x7fff)
typedef struct hdcd_state {
uint64_t window;
unsigned char readahead;
/** arg is set when a packet prefix is found.
* control is the active control code, where
* bit 0-3: target_gain, 4-bit (3.1) fixed-point value
* bit 4 : peak_extend
* bit 5 : transient_filter
* bit 6,7: always zero */
uint8_t arg, control;
unsigned int sustain, sustain_reset; /**< code detect timer */
int running_gain; /**< 11-bit (3.8) fixed point, extended from target_gain */
/* counters */
int code_counterA; /**< 8-bit format packet */
int code_counterA_almost; /**< looks like an A code, but a bit expected to be 0 is 1 */
int code_counterB; /**< 16-bit format packet, 8-bit code, 8-bit XOR of code */
int code_counterB_checkfails; /**< looks like a B code, but doesn't pass the XOR check */
int code_counterC; /**< packet prefix was found, expect a code */
int code_counterC_unmatched; /**< told to look for a code, but didn't find one */
int count_peak_extend; /**< valid packets where peak_extend was enabled */
int count_transient_filter; /**< valid packets where filter was detected */
/** target_gain is a 4-bit (3.1) fixed-point value, always
* negative, but stored positive.
* The 16 possible values range from -7.5 to 0.0 dB in
* steps of 0.5, but no value below -6.0 dB should appear. */
int gain_counts[16];
int max_gain;
/** occurrences of code detect timer expiring without detecting
* a code. -1 for timer never set. */
int count_sustain_expired;
int rate; /**< sampling rate */
int _ana_snb; /**< used in the analyze mode tone generator */
} hdcd_state;
typedef enum {
HDCD_PE_NEVER = 0, /**< All valid packets have PE set to off */
HDCD_PE_INTERMITTENT = 1, /**< Some valid packets have PE set to on */
HDCD_PE_PERMANENT = 2, /**< All valid packets have PE set to on */
} hdcd_pe;
static const char * const pe_str[] = {
"never enabled",
"enabled intermittently",
"enabled permanently"
};
typedef enum {
HDCD_NONE = 0, /**< HDCD packets do not (yet) appear */
HDCD_NO_EFFECT = 1, /**< HDCD packets appear, but all control codes are NOP */
HDCD_EFFECTUAL = 2, /**< HDCD packets appear, and change the output in some way */
} hdcd_dv;
typedef enum {
HDCD_PVER_NONE = 0, /**< No packets (yet) discovered */
HDCD_PVER_A = 1, /**< Packets of type A (8-bit control) discovered */
HDCD_PVER_B = 2, /**< Packets of type B (8-bit control, 8-bit XOR) discovered */
HDCD_PVER_MIX = 3, /**< Packets of type A and B discovered, most likely an encoding error */
} hdcd_pf;
static const char * const pf_str[] = {
"?", "A", "B", "A+B"
};
typedef struct hdcd_detection_data {
hdcd_dv hdcd_detected;
hdcd_pf packet_type;
int total_packets; /**< valid packets */
int errors; /**< detectable errors */
hdcd_pe peak_extend;
int uses_transient_filter;
float max_gain_adjustment; /**< in dB, expected in the range -7.5 to 0.0 */
int cdt_expirations; /**< -1 for never set, 0 for set but never expired */
int _active_count; /**< used internally */
} hdcd_detection_data;
typedef enum {
HDCD_ANA_OFF = 0,
HDCD_ANA_LLE = 1,
HDCD_ANA_PE = 2,
HDCD_ANA_CDT = 3,
HDCD_ANA_TGM = 4,
HDCD_ANA_TOP = 5, /**< used in max value of AVOption */
} hdcd_ana_mode;
/** analyze mode descriptions: macro for AVOption definitions, array of const char for mapping mode to string */
#define HDCD_ANA_OFF_DESC "disabled"
#define HDCD_ANA_LLE_DESC "gain adjustment level at each sample"
#define HDCD_ANA_PE_DESC "samples where peak extend occurs"
#define HDCD_ANA_CDT_DESC "samples where the code detect timer is active"
#define HDCD_ANA_TGM_DESC "samples where the target gain does not match between channels"
static const char * const ana_mode_str[] = {
HDCD_ANA_OFF_DESC,
HDCD_ANA_LLE_DESC,
HDCD_ANA_PE_DESC,
HDCD_ANA_CDT_DESC,
HDCD_ANA_TGM_DESC,
};
typedef struct HDCDContext {
const AVClass *class;
hdcd_state state[HDCD_MAX_CHANNELS];
/* AVOption members */
/** use hdcd_*_stereo() functions to process both channels together.
* -af hdcd=process_stereo=0 for off
* -af hdcd=process_stereo=1 for on
* default is HDCD_PROCESS_STEREO_DEFAULT */
int process_stereo;
/** always extend peaks above -3dBFS even if PE isn't signaled
* -af hdcd=force_pe=0 for off
* -af hdcd=force_pe=1 for on
* default is off */
int force_pe;
/** analyze mode replaces the audio with a solid tone and adjusts
* the amplitude to signal some specific aspect of the decoding
* process. See docs or HDCD_ANA_* defines. */
int analyze_mode;
int cdt_ms; /**< code detect timer period in ms */
int disable_autoconvert; /**< disable any format conversion or resampling in the filter graph */
int bits_per_sample; /**< bits per sample 16, 20, or 24 */
/* end AVOption members */
/** config_input() and config_output() scan links for any resampling
* or format changes. If found, warnings are issued and bad_config
* is set. */
int bad_config;
AVFilterContext *fctx; /**< filter context for logging errors */
int sample_count; /**< used in error logging */
int val_target_gain; /**< last matching target_gain in both channels */
/* User information/stats */
hdcd_detection_data detect;
} HDCDContext;
#define OFFSET(x) offsetof(HDCDContext, x)
#define A AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
static const AVOption hdcd_options[] = {
{ "disable_autoconvert", "Disable any format conversion or resampling in the filter graph.",
OFFSET(disable_autoconvert), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, A },
{ "process_stereo", "Process stereo channels together. Only apply target_gain when both channels match.",
OFFSET(process_stereo), AV_OPT_TYPE_BOOL, { .i64 = HDCD_PROCESS_STEREO_DEFAULT }, 0, 1, A },
{ "cdt_ms", "Code detect timer period in ms.",
OFFSET(cdt_ms), AV_OPT_TYPE_INT, { .i64 = 2000 }, 100, 60000, A },
{ "force_pe", "Always extend peaks above -3dBFS even when PE is not signaled.",
OFFSET(force_pe), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, A },
{ "analyze_mode", "Replace audio with solid tone and signal some processing aspect in the amplitude.",
OFFSET(analyze_mode), AV_OPT_TYPE_INT, { .i64=HDCD_ANA_OFF }, 0, HDCD_ANA_TOP-1, A, "analyze_mode"},
{ "off", HDCD_ANA_OFF_DESC, 0, AV_OPT_TYPE_CONST, {.i64=HDCD_ANA_OFF}, 0, 0, A, "analyze_mode" },
{ "lle", HDCD_ANA_LLE_DESC, 0, AV_OPT_TYPE_CONST, {.i64=HDCD_ANA_LLE}, 0, 0, A, "analyze_mode" },
{ "pe", HDCD_ANA_PE_DESC, 0, AV_OPT_TYPE_CONST, {.i64=HDCD_ANA_PE}, 0, 0, A, "analyze_mode" },
{ "cdt", HDCD_ANA_CDT_DESC, 0, AV_OPT_TYPE_CONST, {.i64=HDCD_ANA_CDT}, 0, 0, A, "analyze_mode" },
{ "tgm", HDCD_ANA_TGM_DESC, 0, AV_OPT_TYPE_CONST, {.i64=HDCD_ANA_TGM}, 0, 0, A, "analyze_mode" },
{ "bits_per_sample", "Valid bits per sample (location of the true LSB).",
OFFSET(bits_per_sample), AV_OPT_TYPE_INT, { .i64=16 }, 16, 24, A, "bits_per_sample"},
{ "16", "16-bit (in s32 or s16)", 0, AV_OPT_TYPE_CONST, {.i64=16}, 0, 0, A, "bits_per_sample" },
{ "20", "20-bit (in s32)", 0, AV_OPT_TYPE_CONST, {.i64=20}, 0, 0, A, "bits_per_sample" },
{ "24", "24-bit (in s32)", 0, AV_OPT_TYPE_CONST, {.i64=24}, 0, 0, A, "bits_per_sample" },
{NULL}
};
AVFILTER_DEFINE_CLASS(hdcd);
static void hdcd_reset(hdcd_state *state, unsigned rate, unsigned cdt_ms)
{
int i;
uint64_t sustain_reset = (uint64_t)cdt_ms * rate / 1000;
state->window = 0;
state->readahead = 32;
state->arg = 0;
state->control = 0;
state->running_gain = 0;
state->sustain_reset = sustain_reset;
state->sustain = 0;
state->code_counterA = 0;
state->code_counterA_almost = 0;
state->code_counterB = 0;
state->code_counterB_checkfails = 0;
state->code_counterC = 0;
state->code_counterC_unmatched = 0;
state->count_peak_extend = 0;
state->count_transient_filter = 0;
for(i = 0; i < 16; i++) state->gain_counts[i] = 0;
state->max_gain = 0;
state->count_sustain_expired = -1;
state->rate = rate;
state->_ana_snb = 0;
}
static int hdcd_integrate(HDCDContext *ctx, hdcd_state *states, int channels, int *flag, const int32_t *samples, int count, int stride)
{
uint32_t bits[HDCD_MAX_CHANNELS];
int result = count;
int i, j, f;
*flag = 0;
memset(bits, 0, sizeof(bits));
if (stride < channels) stride = channels;
for (i = 0; i < channels; i++)
result = FFMIN(states[i].readahead, result);
for (j = result - 1; j >= 0; j--) {
for (i = 0; i < channels; i++)
bits[i] |= (*(samples++) & 1U) << j;
samples += stride - channels;
}
for (i = 0; i < channels; i++) {
states[i].window = (states[i].window << result) | bits[i];
states[i].readahead -= result;
if (states[i].readahead == 0) {
uint32_t wbits = (uint32_t)(states[i].window ^ states[i].window >> 5 ^ states[i].window >> 23);
if (states[i].arg) {
f = 0;
if ((wbits & 0x0fa00500) == 0x0fa00500) {
/* A: 8-bit code 0x7e0fa005[..] */
if ((wbits & 0xc8) == 0) {
/* [..pt gggg]
* 0x0fa005[..] -> 0b[00.. 0...], gain part doubled (shifted left 1) */
states[i].control = (wbits & 255) + (wbits & 7);
f = 1;
states[i].code_counterA++;
} else {
/* one of bits 3, 6, or 7 was not 0 */
states[i].code_counterA_almost++;
av_log(ctx->fctx, AV_LOG_VERBOSE,
"hdcd error: Control A almost: 0x%02"PRIx32" near %d\n",
wbits & 0xff, ctx->sample_count);
}
} else if ((wbits & 0xa0060000) == 0xa0060000) {
/* B: 8-bit code, 8-bit XOR check, 0x7e0fa006[....] */
if (((wbits ^ (~wbits >> 8 & 255)) & 0xffff00ff) == 0xa0060000) {
/* check: [..pt gggg ~(..pt gggg)]
* 0xa006[....] -> 0b[.... .... .... .... ] */
states[i].control = wbits >> 8 & 255;
f = 1;
states[i].code_counterB++;
} else {
/* XOR check failed */
states[i].code_counterB_checkfails++;
av_log(ctx->fctx, AV_LOG_VERBOSE,
"hdcd error: Control B check failed: 0x%04"PRIx32
" (0x%02"PRIx32" vs 0x%02"PRIx32") near %d\n",
wbits & 0xffff, (wbits & 0xff00) >> 8, ~wbits & 0xff, ctx->sample_count);
}
}
if (f) {
*flag |= (1<<i);
/* update counters */
if (states[i].control & 16) states[i].count_peak_extend++;
if (states[i].control & 32) states[i].count_transient_filter++;
states[i].gain_counts[states[i].control & 15]++;
states[i].max_gain = FFMAX(states[i].max_gain, (states[i].control & 15));
}
states[i].arg = 0;
}
if (wbits == 0x7e0fa005 || wbits == 0x7e0fa006) {
/* 0x7e0fa00[.]-> [0b0101 or 0b0110] */
states[i].readahead = (wbits & 3) * 8;
states[i].arg = 1;
states[i].code_counterC++;
} else {
if (wbits)
states[i].readahead = readaheadtab[wbits & 0xff];
else
states[i].readahead = 31; /* ffwd over digisilence */
}
}
}
return result;
}
static int hdcd_scan(HDCDContext *ctx, hdcd_state *states, int channels, const int32_t *samples, int max, int stride)
{
int result;
int i;
int cdt_active[HDCD_MAX_CHANNELS];
memset(cdt_active, 0, sizeof(cdt_active));
if (stride < channels) stride = channels;
/* code detect timers for each channel */
for(i = 0; i < channels; i++) {
if (states[i].sustain > 0) {
cdt_active[i] = 1;
if (states[i].sustain <= (unsigned)max) {
states[i].control = 0;
max = states[i].sustain;
}
states[i].sustain -= max;
}
}
result = 0;
while (result < max) {
int flag;
int consumed = hdcd_integrate(ctx, states, channels, &flag, samples, max - result, stride);
result += consumed;
if (flag) {
/* reset timer if code detected in a channel */
for(i = 0; i < channels; i++) {
if (flag & (1<<i)) {
states[i].sustain = states[i].sustain_reset;
/* if this is the first reset then change
* from never set, to never expired */
if (states[i].count_sustain_expired == -1)
states[i].count_sustain_expired = 0;
}
}
break;
}
samples += consumed * stride;
}
for(i = 0; i < channels; i++) {
/* code detect timer expired */
if (cdt_active[i] && states[i].sustain == 0)
states[i].count_sustain_expired++;
}
return result;
}
/** replace audio with solid tone, but save LSBs */
static void hdcd_analyze_prepare(hdcd_state *state, int32_t *samples, int count, int stride) {
int n, f = 300;
int so = state->rate / f;
for (n = 0; n < count * stride; n += stride) {
/* in analyze mode, the audio is replaced by a solid tone, and
* amplitude is changed to signal when the specified feature is
* used.
* bit 0: HDCD signal preserved
* bit 1: Original sample was above PE level */
int32_t save = (abs(samples[n]) - PEAK_EXT_LEVEL >= 0) ? 2 : 0; /* above PE level */
save |= samples[n] & 1; /* save LSB for HDCD packets */
samples[n] = TONEGEN16(state->_ana_snb, f, state->rate, 0.1);
samples[n] = (samples[n] | 3) ^ ((~save) & 3);
if (++state->_ana_snb > so) state->_ana_snb = 0;
}
}
/** encode a value in the given sample by adjusting the amplitude */
static int32_t hdcd_analyze_gen(int32_t sample, unsigned int v, unsigned int maxv)
{
static const int r = 18, m = 1024;
int64_t s64 = sample;
v = m + (v * r * m / maxv);
return (int32_t)(s64 * v / m);
}
/** behaves like hdcd_envelope(), but encodes processing information in
* a way that is audible (and visible in an audio editor) to aid analysis. */
static int hdcd_analyze(int32_t *samples, int count, int stride, int gain, int target_gain, int extend, int mode, int cdt_active, int tg_mismatch)
{
static const int maxg = 0xf << 7;
int i;
int32_t *samples_end = samples + stride * count;
for (i = 0; i < count; i++) {
samples[i * stride] *= 1 << 15;
if (mode == HDCD_ANA_PE) {
int pel = (samples[i * stride] >> 16) & 1;
int32_t sample = samples[i * stride];
samples[i * stride] = hdcd_analyze_gen(sample, !!(pel && extend), 1);
} else if (mode == HDCD_ANA_TGM && tg_mismatch > 0)
samples[i * stride] = hdcd_analyze_gen(samples[i * stride], 1, 1);
else if (mode == HDCD_ANA_CDT && cdt_active)
samples[i * stride] = hdcd_analyze_gen(samples[i * stride], 1, 1);
}
if (gain <= target_gain) {
int len = FFMIN(count, target_gain - gain);
/* attenuate slowly */
for (i = 0; i < len; i++) {
++gain;
if (mode == HDCD_ANA_LLE)
*samples = hdcd_analyze_gen(*samples, gain, maxg);
samples += stride;
}
count -= len;
} else {
int len = FFMIN(count, (gain - target_gain) >> 3);
/* amplify quickly */
for (i = 0; i < len; i++) {
gain -= 8;
if (mode == HDCD_ANA_LLE)
*samples = hdcd_analyze_gen(*samples, gain, maxg);
samples += stride;
}
if (gain - 8 < target_gain)
gain = target_gain;
count -= len;
}
/* hold a steady level */
if (gain == 0) {
if (count > 0)
samples += count * stride;
} else {
while (--count >= 0) {
if (mode == HDCD_ANA_LLE)
*samples = hdcd_analyze_gen(*samples, gain, maxg);
samples += stride;
}
}
av_assert0(samples == samples_end);
return gain;
}
/** apply HDCD decoding parameters to a series of samples */
static int hdcd_envelope(int32_t *samples, int count, int stride, int vbits, int gain, int target_gain, int extend)
{
static const int max_asample = sizeof(peaktab) / sizeof(peaktab[0]) - 1;
int32_t *samples_end = samples + stride * count;
int i;
int pe_level = PEAK_EXT_LEVEL, shft = 15;
if (vbits != 16) {
pe_level = (1 << (vbits - 1)) - (0x8000 - PEAK_EXT_LEVEL);
shft = 32 - vbits - 1;
}
av_assert0(PEAK_EXT_LEVEL + max_asample == 0x8000);
if (extend) {
for (i = 0; i < count; i++) {
int32_t sample = samples[i * stride];
int32_t asample = abs(sample) - pe_level;
if (asample >= 0) {
av_assert0(asample <= max_asample);
sample = sample >= 0 ? peaktab[asample] : -peaktab[asample];
} else
sample *= (1 << shft);
samples[i * stride] = sample;
}
} else {
for (i = 0; i < count; i++)
samples[i * stride] *= (1 << shft);
}
if (gain <= target_gain) {
int len = FFMIN(count, target_gain - gain);
/* attenuate slowly */
for (i = 0; i < len; i++) {
++gain;
APPLY_GAIN(*samples, gain);
samples += stride;
}
count -= len;
} else {
int len = FFMIN(count, (gain - target_gain) >> 3);
/* amplify quickly */
for (i = 0; i < len; i++) {
gain -= 8;
APPLY_GAIN(*samples, gain);
samples += stride;
}
if (gain - 8 < target_gain)
gain = target_gain;
count -= len;
}
/* hold a steady level */
if (gain == 0) {
if (count > 0)
samples += count * stride;
} else {
while (--count >= 0) {
APPLY_GAIN(*samples, gain);
samples += stride;
}
}
av_assert0(samples == samples_end);
return gain;
}
/** extract fields from control code */
static void hdcd_control(HDCDContext *ctx, hdcd_state *state, int *peak_extend, int *target_gain)
{
*peak_extend = (ctx->force_pe || state->control & 16);
*target_gain = (state->control & 15) << 7;
}
typedef enum {
HDCD_OK=0,
HDCD_TG_MISMATCH
} hdcd_control_result;
static hdcd_control_result hdcd_control_stereo(HDCDContext *ctx, int *peak_extend0, int *peak_extend1)
{
int target_gain[2];
hdcd_control(ctx, &ctx->state[0], peak_extend0, &target_gain[0]);
hdcd_control(ctx, &ctx->state[1], peak_extend1, &target_gain[1]);
if (target_gain[0] == target_gain[1])
ctx->val_target_gain = target_gain[0];
else {
av_log(ctx->fctx, AV_LOG_VERBOSE,
"hdcd error: Unmatched target_gain near %d: tg0: %0.1f, tg1: %0.1f, lvg: %0.1f\n",
ctx->sample_count,
GAINTOFLOAT(target_gain[0] >>7),
GAINTOFLOAT(target_gain[1] >>7),
GAINTOFLOAT(ctx->val_target_gain >>7) );
return HDCD_TG_MISMATCH;
}
return HDCD_OK;
}
static void hdcd_process(HDCDContext *ctx, hdcd_state *state, int32_t *samples, int count, int stride)
{
int32_t *samples_end = samples + count * stride;
int gain = state->running_gain;
int peak_extend, target_gain;
int lead = 0;
if (ctx->analyze_mode)
hdcd_analyze_prepare(state, samples, count, stride);
hdcd_control(ctx, state, &peak_extend, &target_gain);
while (count > lead) {
int envelope_run;
int run;
av_assert0(samples + lead * stride + stride * (count - lead) <= samples_end);
run = hdcd_scan(ctx, state, 1, samples + lead * stride, count - lead, 0) + lead;
envelope_run = run - 1;
av_assert0(samples + envelope_run * stride <= samples_end);
if (ctx->analyze_mode)
gain = hdcd_analyze(samples, envelope_run, stride, gain, target_gain, peak_extend, ctx->analyze_mode, state->sustain, -1);
else
gain = hdcd_envelope(samples, envelope_run, stride, ctx->bits_per_sample, gain, target_gain, peak_extend);
samples += envelope_run * stride;
count -= envelope_run;
lead = run - envelope_run;
hdcd_control(ctx, state, &peak_extend, &target_gain);
}
if (lead > 0) {
av_assert0(samples + lead * stride <= samples_end);
if (ctx->analyze_mode)
gain = hdcd_analyze(samples, lead, stride, gain, target_gain, peak_extend, ctx->analyze_mode, state->sustain, -1);
else
gain = hdcd_envelope(samples, lead, stride, ctx->bits_per_sample, gain, target_gain, peak_extend);
}
state->running_gain = gain;
}
static void hdcd_process_stereo(HDCDContext *ctx, int32_t *samples, int count)
{
const int stride = 2;
int32_t *samples_end = samples + count * stride;
int gain[2] = {ctx->state[0].running_gain, ctx->state[1].running_gain};
int peak_extend[2];
int lead = 0;
int ctlret;
if (ctx->analyze_mode) {
hdcd_analyze_prepare(&ctx->state[0], samples, count, stride);
hdcd_analyze_prepare(&ctx->state[1], samples + 1, count, stride);
}
ctlret = hdcd_control_stereo(ctx, &peak_extend[0], &peak_extend[1]);
while (count > lead) {
int envelope_run, run;
av_assert0(samples + lead * stride + stride * (count - lead) <= samples_end);
run = hdcd_scan(ctx, ctx->state, 2, samples + lead * stride, count - lead, 0) + lead;
envelope_run = run - 1;
av_assert0(samples + envelope_run * stride <= samples_end);
if (ctx->analyze_mode) {
gain[0] = hdcd_analyze(samples, envelope_run, stride, gain[0], ctx->val_target_gain, peak_extend[0],
ctx->analyze_mode,
ctx->state[0].sustain,
(ctlret == HDCD_TG_MISMATCH) );
gain[1] = hdcd_analyze(samples + 1, envelope_run, stride, gain[1], ctx->val_target_gain, peak_extend[1],
ctx->analyze_mode,
ctx->state[1].sustain,
(ctlret == HDCD_TG_MISMATCH) );
} else {
gain[0] = hdcd_envelope(samples, envelope_run, stride, ctx->bits_per_sample, gain[0], ctx->val_target_gain, peak_extend[0]);
gain[1] = hdcd_envelope(samples + 1, envelope_run, stride, ctx->bits_per_sample, gain[1], ctx->val_target_gain, peak_extend[1]);
}
samples += envelope_run * stride;
count -= envelope_run;
lead = run - envelope_run;
ctlret = hdcd_control_stereo(ctx, &peak_extend[0], &peak_extend[1]);
}
if (lead > 0) {
av_assert0(samples + lead * stride <= samples_end);
if (ctx->analyze_mode) {
gain[0] = hdcd_analyze(samples, lead, stride, gain[0], ctx->val_target_gain, peak_extend[0],
ctx->analyze_mode,
ctx->state[0].sustain,
(ctlret == HDCD_TG_MISMATCH) );
gain[1] = hdcd_analyze(samples + 1, lead, stride, gain[1], ctx->val_target_gain, peak_extend[1],
ctx->analyze_mode,
ctx->state[1].sustain,
(ctlret == HDCD_TG_MISMATCH) );
} else {
gain[0] = hdcd_envelope(samples, lead, stride, ctx->bits_per_sample, gain[0], ctx->val_target_gain, peak_extend[0]);
gain[1] = hdcd_envelope(samples + 1, lead, stride, ctx->bits_per_sample, gain[1], ctx->val_target_gain, peak_extend[1]);
}
}
ctx->state[0].running_gain = gain[0];
ctx->state[1].running_gain = gain[1];
}
static void hdcd_detect_reset(hdcd_detection_data *detect) {
detect->hdcd_detected = HDCD_NONE;
detect->packet_type = HDCD_PVER_NONE;
detect->total_packets = 0;
detect->errors = 0;
detect->peak_extend = HDCD_PE_NEVER;
detect->uses_transient_filter = 0;
detect->max_gain_adjustment = 0.0;
detect->cdt_expirations = -1;
detect->_active_count = 0;
}
static void hdcd_detect_start(hdcd_detection_data *detect) {
detect->errors = 0; /* re-sum every pass */
detect->total_packets = 0;
detect->_active_count = 0; /* will need to match channels at hdcd_detect_end() */
detect->cdt_expirations = -1;
}
static void hdcd_detect_onech(hdcd_state *state, hdcd_detection_data *detect) {
hdcd_pe pe = HDCD_PE_NEVER;
detect->uses_transient_filter |= !!(state->count_transient_filter);
detect->total_packets += state->code_counterA + state->code_counterB;
if (state->code_counterA) detect->packet_type |= HDCD_PVER_A;
if (state->code_counterB) detect->packet_type |= HDCD_PVER_B;
if (state->count_peak_extend) {
/* if every valid packet has used PE, call it permanent */
if (state->count_peak_extend == state->code_counterA + state->code_counterB)
pe = HDCD_PE_PERMANENT;
else
pe = HDCD_PE_INTERMITTENT;
if (detect->peak_extend != HDCD_PE_INTERMITTENT)
detect->peak_extend = pe;
}
detect->max_gain_adjustment = FFMIN(detect->max_gain_adjustment, GAINTOFLOAT(state->max_gain));
detect->errors += state->code_counterA_almost
+ state->code_counterB_checkfails
+ state->code_counterC_unmatched;
if (state->sustain) detect->_active_count++;
if (state->count_sustain_expired >= 0) {
if (detect->cdt_expirations == -1) detect->cdt_expirations = 0;
detect->cdt_expirations += state->count_sustain_expired;
}
}
static void hdcd_detect_end(hdcd_detection_data *detect, int channels) {
/* HDCD is detected if a valid packet is active in all
* channels at the same time. */
if (detect->_active_count == channels) {
if (detect->max_gain_adjustment || detect->peak_extend)
detect->hdcd_detected = HDCD_EFFECTUAL;
else
detect->hdcd_detected = HDCD_NO_EFFECT;
}
}
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
{
AVFilterContext *ctx = inlink->dst;
HDCDContext *s = ctx->priv;
AVFilterLink *outlink = ctx->outputs[0];
AVFrame *out;
const int16_t *in_data;
const int32_t *in_data32;
int32_t *out_data;
int n, c, result;
int a = 32 - s->bits_per_sample;
out = ff_get_audio_buffer(outlink, in->nb_samples);
if (!out) {
av_frame_free(&in);
return AVERROR(ENOMEM);
}
result = av_frame_copy_props(out, in);
if (result) {
av_frame_free(&out);
av_frame_free(&in);
return result;
}
out->format = outlink->format; // is this needed?
out_data = (int32_t*)out->data[0];
switch (inlink->format) {
case AV_SAMPLE_FMT_S16P:
for (n = 0; n < in->nb_samples; n++)
for (c = 0; c < in->channels; c++) {
in_data = (int16_t*)in->extended_data[c];
out_data[(n * in->channels) + c] = in_data[n];
}
break;
case AV_SAMPLE_FMT_S16:
in_data = (int16_t*)in->data[0];
for (n = 0; n < in->nb_samples * in->channels; n++)
out_data[n] = in_data[n];
break;
case AV_SAMPLE_FMT_S32P:
for (n = 0; n < in->nb_samples; n++)
for (c = 0; c < in->channels; c++) {
in_data32 = (int32_t*)in->extended_data[c];
out_data[(n * in->channels) + c] = in_data32[n] >> a;
}
break;
case AV_SAMPLE_FMT_S32:
in_data32 = (int32_t*)in->data[0];
for (n = 0; n < in->nb_samples * in->channels; n++)
out_data[n] = in_data32[n] >> a;
break;
}
if (s->process_stereo) {
hdcd_detect_start(&s->detect);
hdcd_process_stereo(s, out_data, in->nb_samples);
hdcd_detect_onech(&s->state[0], &s->detect);
hdcd_detect_onech(&s->state[1], &s->detect);
hdcd_detect_end(&s->detect, 2);
} else {
hdcd_detect_start(&s->detect);
for (c = 0; c < in->channels; c++) {
hdcd_process(s, &s->state[c], out_data + c, in->nb_samples, in->channels);
hdcd_detect_onech(&s->state[c], &s->detect);
}
hdcd_detect_end(&s->detect, in->channels);
}
s->sample_count += in->nb_samples * in->channels;
av_frame_free(&in);
return ff_filter_frame(outlink, out);
}
static int query_formats(AVFilterContext *ctx)
{
static const int sample_rates[] = {
44100, 48000,
88200, 96000,
176400, 192000,
-1
};
AVFilterFormats *in_formats;
AVFilterFormats *out_formats;
AVFilterChannelLayouts *layouts = NULL;
AVFilterLink *inlink = ctx->inputs[0];
AVFilterLink *outlink = ctx->outputs[0];
static const enum AVSampleFormat sample_fmts_in[] = {
AV_SAMPLE_FMT_S16,
AV_SAMPLE_FMT_S16P,
AV_SAMPLE_FMT_S32,
AV_SAMPLE_FMT_S32P,
AV_SAMPLE_FMT_NONE
};
static const enum AVSampleFormat sample_fmts_out[] = {
AV_SAMPLE_FMT_S32,
AV_SAMPLE_FMT_NONE
};
int ret;
ret = ff_add_channel_layout(&layouts, AV_CH_LAYOUT_MONO);
if (ret < 0)
return ret;
ret = ff_add_channel_layout(&layouts, AV_CH_LAYOUT_STEREO);
if (ret < 0)
return ret;
ret = ff_set_common_channel_layouts(ctx, layouts);
if (ret < 0)
return ret;
in_formats = ff_make_format_list(sample_fmts_in);
ret = ff_formats_ref(in_formats, &inlink->outcfg.formats);
if (ret < 0)
return ret;
out_formats = ff_make_format_list(sample_fmts_out);
ret = ff_formats_ref(out_formats, &outlink->incfg.formats);
if (ret < 0)
return ret;
return
ff_set_common_samplerates(ctx, ff_make_format_list(sample_rates) );
}
static av_cold void uninit(AVFilterContext *ctx)
{
HDCDContext *s = ctx->priv;
int i, j;
/* dump the state for each channel for AV_LOG_VERBOSE */
for (i = 0; i < HDCD_MAX_CHANNELS; i++) {
hdcd_state *state = &s->state[i];
av_log(ctx, AV_LOG_VERBOSE, "Channel %d: counter A: %d, B: %d, C: %d\n", i,
state->code_counterA, state->code_counterB, state->code_counterC);
av_log(ctx, AV_LOG_VERBOSE, "Channel %d: pe: %d, tf: %d, almost_A: %d, checkfail_B: %d, unmatched_C: %d, cdt_expired: %d\n", i,
state->count_peak_extend,
state->count_transient_filter,
state->code_counterA_almost,
state->code_counterB_checkfails,
state->code_counterC_unmatched,
state->count_sustain_expired);
for (j = 0; j <= state->max_gain; j++) {
av_log(ctx, AV_LOG_VERBOSE, "Channel %d: tg %0.1f: %d\n", i, GAINTOFLOAT(j), state->gain_counts[j]);
}
}
av_log(ctx, AV_LOG_VERBOSE, "Packets: type: %s, total: %d\n",
pf_str[s->detect.packet_type],
s->detect.total_packets);
/* log the HDCD decode information */
if (s->detect.hdcd_detected)
av_log(ctx, AV_LOG_INFO,
"HDCD detected: yes, peak_extend: %s, max_gain_adj: %0.1f dB, transient_filter: %s, detectable errors: %d%s%s\n",
pe_str[s->detect.peak_extend],
s->detect.max_gain_adjustment,
(s->detect.uses_transient_filter) ? "detected" : "not detected",
s->detect.errors, (s->detect.errors) ? " (try -v verbose)" : "",
(s->bad_config) ? " (bad_config)" : ""
);
else
av_log(ctx, AV_LOG_INFO, "HDCD detected: no%s\n",
(s->bad_config) ? " (bad_config)" : ""
);
}
static av_cold int init(AVFilterContext *ctx)
{
HDCDContext *s = ctx->priv;
s->sample_count = 0;
s->fctx = ctx;
s->bad_config = 0;
if (s->disable_autoconvert) {
av_log(ctx, AV_LOG_VERBOSE, "Disabling automatic format conversion.\n");
avfilter_graph_set_auto_convert(ctx->graph, AVFILTER_AUTO_CONVERT_NONE);
}
return 0;
}
static int config_input(AVFilterLink *inlink) {
AVFilterContext *ctx = inlink->dst;
HDCDContext *s = ctx->priv;
int c;
av_log(ctx, AV_LOG_VERBOSE, "Auto-convert: %s\n",
(ctx->graph->disable_auto_convert) ? "disabled" : "enabled");
if ((inlink->format == AV_SAMPLE_FMT_S16 ||
inlink->format == AV_SAMPLE_FMT_S16P) &&
s->bits_per_sample != 16) {
av_log(ctx, AV_LOG_WARNING, "bits_per_sample %d does not fit into sample format %s, falling back to 16\n",
s->bits_per_sample, av_get_sample_fmt_name(inlink->format) );
s->bits_per_sample = 16;
} else {
av_log(ctx, AV_LOG_VERBOSE, "Looking for %d-bit HDCD in sample format %s\n",
s->bits_per_sample, av_get_sample_fmt_name(inlink->format) );
}
if (s->bits_per_sample != 16)
av_log(ctx, AV_LOG_WARNING, "20 and 24-bit HDCD decoding is experimental\n");
if (inlink->sample_rate != 44100)
av_log(ctx, AV_LOG_WARNING, "HDCD decoding for sample rates other than 44100 is experimental\n");
hdcd_detect_reset(&s->detect);
for (c = 0; c < HDCD_MAX_CHANNELS; c++) {
hdcd_reset(&s->state[c], inlink->sample_rate, s->cdt_ms);
}
av_log(ctx, AV_LOG_VERBOSE, "CDT period: %dms (%u samples @44100Hz)\n",
s->cdt_ms, s->state[0].sustain_reset );
if (inlink->channels != 2 && s->process_stereo) {
av_log(ctx, AV_LOG_WARNING, "process_stereo disabled (channels = %d)\n", inlink->channels);
s->process_stereo = 0;
}
av_log(ctx, AV_LOG_VERBOSE, "Process mode: %s\n",
(s->process_stereo) ? "process stereo channels together" : "process each channel separately");
av_log(ctx, AV_LOG_VERBOSE, "Force PE: %s\n",
(s->force_pe) ? "on" : "off");
av_log(ctx, AV_LOG_VERBOSE, "Analyze mode: [%d] %s\n",
s->analyze_mode, ana_mode_str[s->analyze_mode] );
return 0;
}
static const AVFilterPad avfilter_af_hdcd_inputs[] = {
{
.name = "default",
.type = AVMEDIA_TYPE_AUDIO,
.filter_frame = filter_frame,
.config_props = config_input,
},
{ NULL }
};
static const AVFilterPad avfilter_af_hdcd_outputs[] = {
{
.name = "default",
.type = AVMEDIA_TYPE_AUDIO,
},
{ NULL }
};
AVFilter ff_af_hdcd = {
.name = "hdcd",
.description = NULL_IF_CONFIG_SMALL("Apply High Definition Compatible Digital (HDCD) decoding."),
.priv_size = sizeof(HDCDContext),
.priv_class = &hdcd_class,
.init = init,
.uninit = uninit,
.query_formats = query_formats,
.inputs = avfilter_af_hdcd_inputs,
.outputs = avfilter_af_hdcd_outputs,
};
|
607750.c | /*
* Copyright (C) 2006 Michael Brown <[email protected]>.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*
* You can also choose to distribute this program under the terms of
* the Unmodified Binary Distribution Licence (as given in the file
* COPYING.UBDL), provided that you have satisfied its requirements.
*/
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <byteswap.h>
#include <string.h>
#include <errno.h>
#include <config/general.h>
#include <ipxe/if_ether.h>
#include <ipxe/iobuf.h>
#include <ipxe/tables.h>
#include <ipxe/process.h>
#include <ipxe/init.h>
#include <ipxe/malloc.h>
#include <ipxe/device.h>
#include <ipxe/errortab.h>
#include <ipxe/profile.h>
#include <ipxe/fault.h>
#include <ipxe/vlan.h>
#include <ipxe/netdevice.h>
/** @file
*
* Network device management
*
*/
/** List of network devices */
struct list_head net_devices = LIST_HEAD_INIT ( net_devices );
/** List of open network devices, in reverse order of opening */
static struct list_head open_net_devices = LIST_HEAD_INIT ( open_net_devices );
/** Network device index */
static unsigned int netdev_index = 0;
/** Network polling profiler */
static struct profiler net_poll_profiler __profiler = { .name = "net.poll" };
/** Network receive profiler */
static struct profiler net_rx_profiler __profiler = { .name = "net.rx" };
/** Network transmit profiler */
static struct profiler net_tx_profiler __profiler = { .name = "net.tx" };
/** Default unknown link status code */
#define EUNKNOWN_LINK_STATUS __einfo_error ( EINFO_EUNKNOWN_LINK_STATUS )
#define EINFO_EUNKNOWN_LINK_STATUS \
__einfo_uniqify ( EINFO_EINPROGRESS, 0x01, "Unknown" )
/** Default not-yet-attempted-configuration status code */
#define EUNUSED_CONFIG __einfo_error ( EINFO_EUNUSED_CONFIG )
#define EINFO_EUNUSED_CONFIG \
__einfo_uniqify ( EINFO_EINPROGRESS, 0x02, "Unused" )
/** Default configuration-in-progress status code */
#define EINPROGRESS_CONFIG __einfo_error ( EINFO_EINPROGRESS_CONFIG )
#define EINFO_EINPROGRESS_CONFIG \
__einfo_uniqify ( EINFO_EINPROGRESS, 0x03, "Incomplete" )
/** Default link-down status code */
#define ENOTCONN_LINK_DOWN __einfo_error ( EINFO_ENOTCONN_LINK_DOWN )
#define EINFO_ENOTCONN_LINK_DOWN \
__einfo_uniqify ( EINFO_ENOTCONN, 0x01, "Down" )
/** Human-readable message for the default link statuses */
struct errortab netdev_errors[] __errortab = {
__einfo_errortab ( EINFO_EUNKNOWN_LINK_STATUS ),
__einfo_errortab ( EINFO_ENOTCONN_LINK_DOWN ),
__einfo_errortab ( EINFO_EUNUSED_CONFIG ),
__einfo_errortab ( EINFO_EINPROGRESS_CONFIG ),
};
/**
* Check whether or not network device has a link-layer address
*
* @v netdev Network device
* @ret has_ll_addr Network device has a link-layer address
*/
static int netdev_has_ll_addr ( struct net_device *netdev ) {
uint8_t *ll_addr = netdev->ll_addr;
size_t remaining = sizeof ( netdev->ll_addr );
while ( remaining-- ) {
if ( *(ll_addr++) != 0 )
return 1;
}
return 0;
}
/**
* Notify drivers of network device or link state change
*
* @v netdev Network device
*/
static void netdev_notify ( struct net_device *netdev ) {
struct net_driver *driver;
for_each_table_entry ( driver, NET_DRIVERS ) {
if ( driver->notify )
driver->notify ( netdev );
}
}
/**
* Freeze network device receive queue processing
*
* @v netdev Network device
*/
void netdev_rx_freeze ( struct net_device *netdev ) {
/* Mark receive queue processing as frozen */
netdev->state |= NETDEV_RX_FROZEN;
/* Notify drivers of change */
netdev_notify ( netdev );
}
/**
* Unfreeze network device receive queue processing
*
* @v netdev Network device
*/
void netdev_rx_unfreeze ( struct net_device *netdev ) {
/* Mark receive queue processing as not frozen */
netdev->state &= ~NETDEV_RX_FROZEN;
/* Notify drivers of change */
netdev_notify ( netdev );
}
/**
* Mark network device as having a specific link state
*
* @v netdev Network device
* @v rc Link status code
*/
void netdev_link_err ( struct net_device *netdev, int rc ) {
/* Stop link block timer */
stop_timer ( &netdev->link_block );
/* Record link state */
netdev->link_rc = rc;
if ( netdev->link_rc == 0 ) {
DBGC ( netdev, "NETDEV %s link is up\n", netdev->name );
} else {
DBGC ( netdev, "NETDEV %s link is down: %s\n",
netdev->name, strerror ( netdev->link_rc ) );
}
/* Notify drivers of link state change */
netdev_notify ( netdev );
}
/**
* Mark network device as having link down
*
* @v netdev Network device
*/
void netdev_link_down ( struct net_device *netdev ) {
/* Avoid clobbering a more detailed link status code, if one
* is already set.
*/
if ( ( netdev->link_rc == 0 ) ||
( netdev->link_rc == -EUNKNOWN_LINK_STATUS ) ) {
netdev_link_err ( netdev, -ENOTCONN_LINK_DOWN );
}
}
/**
* Mark network device link as being blocked
*
* @v netdev Network device
* @v timeout Timeout (in ticks)
*/
void netdev_link_block ( struct net_device *netdev, unsigned long timeout ) {
/* Start link block timer */
if ( ! netdev_link_blocked ( netdev ) ) {
DBGC ( netdev, "NETDEV %s link blocked for %ld ticks\n",
netdev->name, timeout );
}
start_timer_fixed ( &netdev->link_block, timeout );
}
/**
* Mark network device link as being unblocked
*
* @v netdev Network device
*/
void netdev_link_unblock ( struct net_device *netdev ) {
/* Stop link block timer */
if ( netdev_link_blocked ( netdev ) )
DBGC ( netdev, "NETDEV %s link unblocked\n", netdev->name );
stop_timer ( &netdev->link_block );
}
/**
* Handle network device link block timer expiry
*
* @v timer Link block timer
* @v fail Failure indicator
*/
static void netdev_link_block_expired ( struct retry_timer *timer,
int fail __unused ) {
struct net_device *netdev =
container_of ( timer, struct net_device, link_block );
/* Assume link is no longer blocked */
DBGC ( netdev, "NETDEV %s link block expired\n", netdev->name );
}
/**
* Record network device statistic
*
* @v stats Network device statistics
* @v rc Status code
*/
static void netdev_record_stat ( struct net_device_stats *stats, int rc ) {
struct net_device_error *error;
struct net_device_error *least_common_error;
unsigned int i;
/* If this is not an error, just update the good counter */
if ( rc == 0 ) {
stats->good++;
return;
}
/* Update the bad counter */
stats->bad++;
/* Locate the appropriate error record */
least_common_error = &stats->errors[0];
for ( i = 0 ; i < ( sizeof ( stats->errors ) /
sizeof ( stats->errors[0] ) ) ; i++ ) {
error = &stats->errors[i];
/* Update matching record, if found */
if ( error->rc == rc ) {
error->count++;
return;
}
if ( error->count < least_common_error->count )
least_common_error = error;
}
/* Overwrite the least common error record */
least_common_error->rc = rc;
least_common_error->count = 1;
}
/**
* Transmit raw packet via network device
*
* @v netdev Network device
* @v iobuf I/O buffer
* @ret rc Return status code
*
* Transmits the packet via the specified network device. This
* function takes ownership of the I/O buffer.
*/
int netdev_tx ( struct net_device *netdev, struct io_buffer *iobuf ) {
int rc;
DBGC2 ( netdev, "NETDEV %s transmitting %p (%p+%zx)\n",
netdev->name, iobuf, iobuf->data, iob_len ( iobuf ) );
profile_start ( &net_tx_profiler );
/* Enqueue packet */
list_add_tail ( &iobuf->list, &netdev->tx_queue );
/* Avoid calling transmit() on unopened network devices */
if ( ! netdev_is_open ( netdev ) ) {
rc = -ENETUNREACH;
goto err;
}
/* Discard packet (for test purposes) if applicable */
if ( ( rc = inject_fault ( NETDEV_DISCARD_RATE ) ) != 0 )
goto err;
/* Transmit packet */
if ( ( rc = netdev->op->transmit ( netdev, iobuf ) ) != 0 )
goto err;
profile_stop ( &net_tx_profiler );
return 0;
err:
netdev_tx_complete_err ( netdev, iobuf, rc );
return rc;
}
/**
* Defer transmitted packet
*
* @v netdev Network device
* @v iobuf I/O buffer
*
* Drivers may call netdev_tx_defer() if there is insufficient space
* in the transmit descriptor ring. Any packets deferred in this way
* will be automatically retransmitted as soon as space becomes
* available (i.e. as soon as the driver calls netdev_tx_complete()).
*
* The packet must currently be in the network device's TX queue.
*
* Drivers utilising netdev_tx_defer() must ensure that space in the
* transmit descriptor ring is freed up @b before calling
* netdev_tx_complete(). For example, if the ring is modelled using a
* producer counter and a consumer counter, then the consumer counter
* must be incremented before the call to netdev_tx_complete().
* Failure to do this will cause the retransmitted packet to be
* immediately redeferred (which will result in out-of-order
* transmissions and other nastiness).
*/
void netdev_tx_defer ( struct net_device *netdev, struct io_buffer *iobuf ) {
/* Catch data corruption as early as possible */
list_check_contains_entry ( iobuf, &netdev->tx_queue, list );
/* Remove from transmit queue */
list_del ( &iobuf->list );
/* Add to deferred transmit queue */
list_add_tail ( &iobuf->list, &netdev->tx_deferred );
/* Record "out of space" statistic */
netdev_tx_err ( netdev, NULL, -ENOBUFS );
}
/**
* Discard transmitted packet
*
* @v netdev Network device
* @v iobuf I/O buffer, or NULL
* @v rc Packet status code
*
* The packet is discarded and a TX error is recorded. This function
* takes ownership of the I/O buffer.
*/
void netdev_tx_err ( struct net_device *netdev,
struct io_buffer *iobuf, int rc ) {
/* Update statistics counter */
netdev_record_stat ( &netdev->tx_stats, rc );
if ( rc == 0 ) {
DBGC2 ( netdev, "NETDEV %s transmission %p complete\n",
netdev->name, iobuf );
} else {
DBGC ( netdev, "NETDEV %s transmission %p failed: %s\n",
netdev->name, iobuf, strerror ( rc ) );
}
/* Discard packet */
free_iob ( iobuf );
}
/**
* Complete network transmission
*
* @v netdev Network device
* @v iobuf I/O buffer
* @v rc Packet status code
*
* The packet must currently be in the network device's TX queue.
*/
void netdev_tx_complete_err ( struct net_device *netdev,
struct io_buffer *iobuf, int rc ) {
/* Catch data corruption as early as possible */
list_check_contains_entry ( iobuf, &netdev->tx_queue, list );
/* Dequeue and free I/O buffer */
list_del ( &iobuf->list );
netdev_tx_err ( netdev, iobuf, rc );
/* Handle pending transmit queue */
while ( ( iobuf = list_first_entry ( &netdev->tx_deferred,
struct io_buffer, list ) ) ) {
/* Remove from pending transmit queue */
list_del ( &iobuf->list );
/* When any transmit completion fails, cancel all
* pending transmissions.
*/
if ( rc != 0 ) {
netdev_tx_err ( netdev, iobuf, -ECANCELED );
continue;
}
/* Otherwise, attempt to transmit the first pending packet */
netdev_tx ( netdev, iobuf );
break;
}
}
/**
* Complete network transmission
*
* @v netdev Network device
* @v rc Packet status code
*
* Completes the oldest outstanding packet in the TX queue.
*/
void netdev_tx_complete_next_err ( struct net_device *netdev, int rc ) {
struct io_buffer *iobuf;
if ( ( iobuf = list_first_entry ( &netdev->tx_queue, struct io_buffer,
list ) ) != NULL ) {
netdev_tx_complete_err ( netdev, iobuf, rc );
}
}
/**
* Flush device's transmit queue
*
* @v netdev Network device
*/
static void netdev_tx_flush ( struct net_device *netdev ) {
/* Discard any packets in the TX queue. This will also cause
* any packets in the deferred TX queue to be discarded
* automatically.
*/
while ( ! list_empty ( &netdev->tx_queue ) ) {
netdev_tx_complete_next_err ( netdev, -ECANCELED );
}
assert ( list_empty ( &netdev->tx_queue ) );
assert ( list_empty ( &netdev->tx_deferred ) );
}
/**
* Add packet to receive queue
*
* @v netdev Network device
* @v iobuf I/O buffer, or NULL
*
* The packet is added to the network device's RX queue. This
* function takes ownership of the I/O buffer.
*/
void netdev_rx ( struct net_device *netdev, struct io_buffer *iobuf ) {
int rc;
DBGC2 ( netdev, "NETDEV %s received %p (%p+%zx)\n",
netdev->name, iobuf, iobuf->data, iob_len ( iobuf ) );
/* Discard packet (for test purposes) if applicable */
if ( ( rc = inject_fault ( NETDEV_DISCARD_RATE ) ) != 0 ) {
netdev_rx_err ( netdev, iobuf, rc );
return;
}
/* Enqueue packet */
list_add_tail ( &iobuf->list, &netdev->rx_queue );
/* Update statistics counter */
netdev_record_stat ( &netdev->rx_stats, 0 );
}
/**
* Discard received packet
*
* @v netdev Network device
* @v iobuf I/O buffer, or NULL
* @v rc Packet status code
*
* The packet is discarded and an RX error is recorded. This function
* takes ownership of the I/O buffer. @c iobuf may be NULL if, for
* example, the net device wishes to report an error due to being
* unable to allocate an I/O buffer.
*/
void netdev_rx_err ( struct net_device *netdev,
struct io_buffer *iobuf, int rc ) {
DBGC ( netdev, "NETDEV %s failed to receive %p: %s\n",
netdev->name, iobuf, strerror ( rc ) );
/* Discard packet */
free_iob ( iobuf );
/* Update statistics counter */
netdev_record_stat ( &netdev->rx_stats, rc );
}
/**
* Poll for completed and received packets on network device
*
* @v netdev Network device
*
* Polls the network device for completed transmissions and received
* packets. Any received packets will be added to the RX packet queue
* via netdev_rx().
*/
void netdev_poll ( struct net_device *netdev ) {
if ( netdev_is_open ( netdev ) )
netdev->op->poll ( netdev );
}
/**
* Remove packet from device's receive queue
*
* @v netdev Network device
* @ret iobuf I/O buffer, or NULL
*
* Removes the first packet from the device's RX queue and returns it.
* Ownership of the packet is transferred to the caller.
*/
struct io_buffer * netdev_rx_dequeue ( struct net_device *netdev ) {
struct io_buffer *iobuf;
iobuf = list_first_entry ( &netdev->rx_queue, struct io_buffer, list );
if ( ! iobuf )
return NULL;
list_del ( &iobuf->list );
return iobuf;
}
/**
* Flush device's receive queue
*
* @v netdev Network device
*/
static void netdev_rx_flush ( struct net_device *netdev ) {
struct io_buffer *iobuf;
/* Discard any packets in the RX queue */
while ( ( iobuf = netdev_rx_dequeue ( netdev ) ) ) {
netdev_rx_err ( netdev, iobuf, -ECANCELED );
}
}
/**
* Finish network device configuration
*
* @v config Network device configuration
* @v rc Reason for completion
*/
static void netdev_config_close ( struct net_device_configuration *config,
int rc ) {
struct net_device_configurator *configurator = config->configurator;
struct net_device *netdev = config->netdev;
/* Restart interface */
intf_restart ( &config->job, rc );
/* Record configuration result */
config->rc = rc;
if ( rc == 0 ) {
DBGC ( netdev, "NETDEV %s configured via %s\n",
netdev->name, configurator->name );
} else {
DBGC ( netdev, "NETDEV %s configuration via %s failed: %s\n",
netdev->name, configurator->name, strerror ( rc ) );
}
}
/** Network device configuration interface operations */
static struct interface_operation netdev_config_ops[] = {
INTF_OP ( intf_close, struct net_device_configuration *,
netdev_config_close ),
};
/** Network device configuration interface descriptor */
static struct interface_descriptor netdev_config_desc =
INTF_DESC ( struct net_device_configuration, job, netdev_config_ops );
/**
* Free network device
*
* @v refcnt Network device reference counter
*/
static void free_netdev ( struct refcnt *refcnt ) {
struct net_device *netdev =
container_of ( refcnt, struct net_device, refcnt );
stop_timer ( &netdev->link_block );
netdev_tx_flush ( netdev );
netdev_rx_flush ( netdev );
clear_settings ( netdev_settings ( netdev ) );
free ( netdev );
}
/**
* Allocate network device
*
* @v priv_len Length of private data area (net_device::priv)
* @ret netdev Network device, or NULL
*
* Allocates space for a network device and its private data area.
*/
struct net_device * alloc_netdev ( size_t priv_len ) {
struct net_device *netdev;
struct net_device_configurator *configurator;
struct net_device_configuration *config;
unsigned int num_configs;
size_t confs_len;
size_t total_len;
num_configs = table_num_entries ( NET_DEVICE_CONFIGURATORS );
confs_len = ( num_configs * sizeof ( netdev->configs[0] ) );
total_len = ( sizeof ( *netdev ) + confs_len + priv_len );
netdev = zalloc ( total_len );
if ( netdev ) {
ref_init ( &netdev->refcnt, free_netdev );
netdev->link_rc = -EUNKNOWN_LINK_STATUS;
timer_init ( &netdev->link_block, netdev_link_block_expired,
&netdev->refcnt );
INIT_LIST_HEAD ( &netdev->tx_queue );
INIT_LIST_HEAD ( &netdev->tx_deferred );
INIT_LIST_HEAD ( &netdev->rx_queue );
netdev_settings_init ( netdev );
config = netdev->configs;
for_each_table_entry ( configurator, NET_DEVICE_CONFIGURATORS ){
config->netdev = netdev;
config->configurator = configurator;
config->rc = -EUNUSED_CONFIG;
intf_init ( &config->job, &netdev_config_desc,
&netdev->refcnt );
config++;
}
netdev->priv = ( ( ( void * ) netdev ) + sizeof ( *netdev ) +
confs_len );
}
return netdev;
}
/**
* Register network device
*
* @v netdev Network device
* @ret rc Return status code
*
* Gives the network device a name and adds it to the list of network
* devices.
*/
int register_netdev ( struct net_device *netdev ) {
struct ll_protocol *ll_protocol = netdev->ll_protocol;
struct net_driver *driver;
struct net_device *duplicate;
uint32_t seed;
int rc;
/* Set initial link-layer address, if not already set */
if ( ! netdev_has_ll_addr ( netdev ) ) {
ll_protocol->init_addr ( netdev->hw_addr, netdev->ll_addr );
}
/* Set MTU, if not already set */
if ( ! netdev->mtu ) {
netdev->mtu = ( netdev->max_pkt_len -
ll_protocol->ll_header_len );
}
/* Reject network devices that are already available via a
* different hardware device.
*/
duplicate = find_netdev_by_ll_addr ( ll_protocol, netdev->ll_addr );
if ( duplicate && ( duplicate->dev != netdev->dev ) ) {
DBGC ( netdev, "NETDEV rejecting duplicate (phys %s) of %s "
"(phys %s)\n", netdev->dev->name, duplicate->name,
duplicate->dev->name );
rc = -EEXIST;
goto err_duplicate;
}
/* Reject named network devices that already exist */
if ( netdev->name[0] && ( duplicate = find_netdev ( netdev->name ) ) ) {
DBGC ( netdev, "NETDEV rejecting duplicate name %s\n",
duplicate->name );
rc = -EEXIST;
goto err_duplicate;
}
/* Record device index and create device name */
if ( netdev->name[0] == '\0' ) {
snprintf ( netdev->name, sizeof ( netdev->name ), "net%d",
netdev_index );
}
netdev->index = ++netdev_index;
/* Use least significant bits of the link-layer address to
* improve the randomness of the (non-cryptographic) random
* number generator.
*/
memcpy ( &seed, ( netdev->ll_addr + ll_protocol->ll_addr_len
- sizeof ( seed ) ), sizeof ( seed ) );
srand ( rand() ^ seed );
/* Add to device list */
netdev_get ( netdev );
list_add_tail ( &netdev->list, &net_devices );
DBGC ( netdev, "NETDEV %s registered (phys %s hwaddr %s)\n",
netdev->name, netdev->dev->name,
netdev_addr ( netdev ) );
/* Register per-netdev configuration settings */
if ( ( rc = register_settings ( netdev_settings ( netdev ),
NULL, netdev->name ) ) != 0 ) {
DBGC ( netdev, "NETDEV %s could not register settings: %s\n",
netdev->name, strerror ( rc ) );
goto err_register_settings;
}
/* Probe device */
for_each_table_entry ( driver, NET_DRIVERS ) {
if ( driver->probe && ( rc = driver->probe ( netdev ) ) != 0 ) {
DBGC ( netdev, "NETDEV %s could not add %s device: "
"%s\n", netdev->name, driver->name,
strerror ( rc ) );
goto err_probe;
}
}
return 0;
err_probe:
for_each_table_entry_continue_reverse ( driver, NET_DRIVERS ) {
if ( driver->remove )
driver->remove ( netdev );
}
clear_settings ( netdev_settings ( netdev ) );
unregister_settings ( netdev_settings ( netdev ) );
err_register_settings:
list_del ( &netdev->list );
netdev_put ( netdev );
err_duplicate:
return rc;
}
/**
* Open network device
*
* @v netdev Network device
* @ret rc Return status code
*/
int netdev_open ( struct net_device *netdev ) {
int rc;
/* Do nothing if device is already open */
if ( netdev->state & NETDEV_OPEN )
return 0;
DBGC ( netdev, "NETDEV %s opening\n", netdev->name );
/* Mark as opened */
netdev->state |= NETDEV_OPEN;
/* Open the device */
if ( ( rc = netdev->op->open ( netdev ) ) != 0 )
goto err;
/* Add to head of open devices list */
list_add ( &netdev->open_list, &open_net_devices );
/* Notify drivers of device state change */
netdev_notify ( netdev );
return 0;
err:
netdev->state &= ~NETDEV_OPEN;
return rc;
}
/**
* Close network device
*
* @v netdev Network device
*/
void netdev_close ( struct net_device *netdev ) {
unsigned int num_configs;
unsigned int i;
/* Do nothing if device is already closed */
if ( ! ( netdev->state & NETDEV_OPEN ) )
return;
DBGC ( netdev, "NETDEV %s closing\n", netdev->name );
/* Terminate any ongoing configurations. Use intf_close()
* rather than intf_restart() to allow the cancellation to be
* reported back to us if a configuration is actually in
* progress.
*/
num_configs = table_num_entries ( NET_DEVICE_CONFIGURATORS );
for ( i = 0 ; i < num_configs ; i++ )
intf_close ( &netdev->configs[i].job, -ECANCELED );
/* Remove from open devices list */
list_del ( &netdev->open_list );
/* Mark as closed */
netdev->state &= ~NETDEV_OPEN;
/* Notify drivers of device state change */
netdev_notify ( netdev );
/* Close the device */
netdev->op->close ( netdev );
/* Flush TX and RX queues */
netdev_tx_flush ( netdev );
netdev_rx_flush ( netdev );
}
/**
* Unregister network device
*
* @v netdev Network device
*
* Removes the network device from the list of network devices.
*/
void unregister_netdev ( struct net_device *netdev ) {
struct net_driver *driver;
/* Ensure device is closed */
netdev_close ( netdev );
/* Remove device */
for_each_table_entry_reverse ( driver, NET_DRIVERS ) {
if ( driver->remove )
driver->remove ( netdev );
}
/* Unregister per-netdev configuration settings */
clear_settings ( netdev_settings ( netdev ) );
unregister_settings ( netdev_settings ( netdev ) );
/* Remove from device list */
DBGC ( netdev, "NETDEV %s unregistered\n", netdev->name );
list_del ( &netdev->list );
netdev_put ( netdev );
/* Reset network device index if no devices remain */
if ( list_empty ( &net_devices ) )
netdev_index = 0;
}
/** Enable or disable interrupts
*
* @v netdev Network device
* @v enable Interrupts should be enabled
*/
void netdev_irq ( struct net_device *netdev, int enable ) {
/* Enable or disable device interrupts, if applicable */
if ( netdev_irq_supported ( netdev ) )
netdev->op->irq ( netdev, enable );
/* Record interrupt enabled state */
netdev->state &= ~NETDEV_IRQ_ENABLED;
if ( enable )
netdev->state |= NETDEV_IRQ_ENABLED;
}
/**
* Get network device by name
*
* @v name Network device name
* @ret netdev Network device, or NULL
*/
struct net_device * find_netdev ( const char *name ) {
struct net_device *netdev;
/* Allow "netX" shortcut */
if ( strcmp ( name, "netX" ) == 0 )
return last_opened_netdev();
/* Identify network device by name */
list_for_each_entry ( netdev, &net_devices, list ) {
if ( strcmp ( netdev->name, name ) == 0 )
return netdev;
}
return NULL;
}
/**
* Get network device by index
*
* @v index Network device index
* @ret netdev Network device, or NULL
*/
struct net_device * find_netdev_by_index ( unsigned int index ) {
struct net_device *netdev;
/* Identify network device by index */
list_for_each_entry ( netdev, &net_devices, list ) {
if ( netdev->index == index )
return netdev;
}
return NULL;
}
/**
* Get network device by PCI bus:dev.fn address
*
* @v bus_type Bus type
* @v location Bus location
* @ret netdev Network device, or NULL
*/
struct net_device * find_netdev_by_location ( unsigned int bus_type,
unsigned int location ) {
struct net_device *netdev;
list_for_each_entry ( netdev, &net_devices, list ) {
if ( ( netdev->dev->desc.bus_type == bus_type ) &&
( netdev->dev->desc.location == location ) )
return netdev;
}
return NULL;
}
/**
* Get network device by link-layer address
*
* @v ll_protocol Link-layer protocol
* @v ll_addr Link-layer address
* @ret netdev Network device, or NULL
*/
struct net_device * find_netdev_by_ll_addr ( struct ll_protocol *ll_protocol,
const void *ll_addr ) {
struct net_device *netdev;
list_for_each_entry ( netdev, &net_devices, list ) {
if ( ( netdev->ll_protocol == ll_protocol ) &&
( memcmp ( netdev->ll_addr, ll_addr,
ll_protocol->ll_addr_len ) == 0 ) )
return netdev;
}
return NULL;
}
/**
* Get most recently opened network device
*
* @ret netdev Most recently opened network device, or NULL
*/
struct net_device * last_opened_netdev ( void ) {
struct net_device *netdev;
netdev = list_first_entry ( &open_net_devices, struct net_device,
open_list );
if ( ! netdev )
return NULL;
assert ( netdev_is_open ( netdev ) );
return netdev;
}
/**
* Transmit network-layer packet
*
* @v iobuf I/O buffer
* @v netdev Network device
* @v net_protocol Network-layer protocol
* @v ll_dest Destination link-layer address
* @v ll_source Source link-layer address
* @ret rc Return status code
*
* Prepends link-layer headers to the I/O buffer and transmits the
* packet via the specified network device. This function takes
* ownership of the I/O buffer.
*/
int net_tx ( struct io_buffer *iobuf, struct net_device *netdev,
struct net_protocol *net_protocol, const void *ll_dest,
const void *ll_source ) {
struct ll_protocol *ll_protocol = netdev->ll_protocol;
int rc;
/* Add link-layer header */
if ( ( rc = ll_protocol->push ( netdev, iobuf, ll_dest, ll_source,
net_protocol->net_proto ) ) != 0 ) {
/* Record error for diagnosis */
netdev_tx_err ( netdev, iobuf, rc );
return rc;
}
/* Transmit packet */
return netdev_tx ( netdev, iobuf );
}
/**
* Process received network-layer packet
*
* @v iobuf I/O buffer
* @v netdev Network device
* @v net_proto Network-layer protocol, in network-byte order
* @v ll_dest Destination link-layer address
* @v ll_source Source link-layer address
* @v flags Packet flags
* @ret rc Return status code
*/
int net_rx ( struct io_buffer *iobuf, struct net_device *netdev,
uint16_t net_proto, const void *ll_dest, const void *ll_source,
unsigned int flags ) {
struct net_protocol *net_protocol;
/* Hand off to network-layer protocol, if any */
for_each_table_entry ( net_protocol, NET_PROTOCOLS ) {
if ( net_protocol->net_proto == net_proto )
return net_protocol->rx ( iobuf, netdev, ll_dest,
ll_source, flags );
}
DBGC ( netdev, "NETDEV %s unknown network protocol %04x\n",
netdev->name, ntohs ( net_proto ) );
free_iob ( iobuf );
return -ENOTSUP;
}
/**
* Poll the network stack
*
* This polls all interfaces for received packets, and processes
* packets from the RX queue.
*/
void net_poll ( void ) {
struct net_device *netdev;
struct io_buffer *iobuf;
struct ll_protocol *ll_protocol;
const void *ll_dest;
const void *ll_source;
uint16_t net_proto;
unsigned int flags;
int rc;
/* Poll and process each network device */
list_for_each_entry ( netdev, &net_devices, list ) {
/* Poll for new packets */
profile_start ( &net_poll_profiler );
netdev_poll ( netdev );
profile_stop ( &net_poll_profiler );
/* Leave received packets on the queue if receive
* queue processing is currently frozen. This will
* happen when the raw packets are to be manually
* dequeued using netdev_rx_dequeue(), rather than
* processed via the usual networking stack.
*/
if ( netdev_rx_frozen ( netdev ) )
continue;
/* Process all received packets */
while ( ( iobuf = netdev_rx_dequeue ( netdev ) ) ) {
DBGC2 ( netdev, "NETDEV %s processing %p (%p+%zx)\n",
netdev->name, iobuf, iobuf->data,
iob_len ( iobuf ) );
profile_start ( &net_rx_profiler );
/* Remove link-layer header */
ll_protocol = netdev->ll_protocol;
if ( ( rc = ll_protocol->pull ( netdev, iobuf,
&ll_dest, &ll_source,
&net_proto,
&flags ) ) != 0 ) {
free_iob ( iobuf );
continue;
}
/* Hand packet to network layer */
if ( ( rc = net_rx ( iob_disown ( iobuf ), netdev,
net_proto, ll_dest,
ll_source, flags ) ) != 0 ) {
/* Record error for diagnosis */
netdev_rx_err ( netdev, NULL, rc );
}
profile_stop ( &net_rx_profiler );
}
}
}
/**
* Single-step the network stack
*
* @v process Network stack process
*/
static void net_step ( struct process *process __unused ) {
net_poll();
}
/**
* Get the VLAN tag (when VLAN support is not present)
*
* @v netdev Network device
* @ret tag 0, indicating that device is not a VLAN device
*/
__weak unsigned int vlan_tag ( struct net_device *netdev __unused ) {
return 0;
}
/**
* Add VLAN tag-stripped packet to queue (when VLAN support is not present)
*
* @v netdev Network device
* @v tag VLAN tag, or zero
* @v iobuf I/O buffer
*/
__weak void vlan_netdev_rx ( struct net_device *netdev, unsigned int tag,
struct io_buffer *iobuf ) {
if ( tag == 0 ) {
netdev_rx ( netdev, iobuf );
} else {
netdev_rx_err ( netdev, iobuf, -ENODEV );
}
}
/**
* Discard received VLAN tag-stripped packet (when VLAN support is not present)
*
* @v netdev Network device
* @v tag VLAN tag, or zero
* @v iobuf I/O buffer, or NULL
* @v rc Packet status code
*/
__weak void vlan_netdev_rx_err ( struct net_device *netdev,
unsigned int tag __unused,
struct io_buffer *iobuf, int rc ) {
netdev_rx_err ( netdev, iobuf, rc );
}
/** Networking stack process */
PERMANENT_PROCESS ( net_process, net_step );
/**
* Discard some cached network device data
*
* @ret discarded Number of cached items discarded
*/
static unsigned int net_discard ( void ) {
struct net_device *netdev;
struct io_buffer *iobuf;
unsigned int discarded = 0;
/* Try to drop one deferred TX packet from each network device */
for_each_netdev ( netdev ) {
if ( ( iobuf = list_first_entry ( &netdev->tx_deferred,
struct io_buffer,
list ) ) != NULL ) {
/* Discard first deferred packet */
list_del ( &iobuf->list );
free_iob ( iobuf );
/* Report discard */
discarded++;
}
}
return discarded;
}
/** Network device cache discarder */
struct cache_discarder net_discarder __cache_discarder ( CACHE_NORMAL ) = {
.discard = net_discard,
};
/**
* Find network device configurator
*
* @v name Name
* @ret configurator Network device configurator, or NULL
*/
struct net_device_configurator * find_netdev_configurator ( const char *name ) {
struct net_device_configurator *configurator;
for_each_table_entry ( configurator, NET_DEVICE_CONFIGURATORS ) {
if ( strcmp ( configurator->name, name ) == 0 )
return configurator;
}
return NULL;
}
/**
* Start network device configuration
*
* @v netdev Network device
* @v configurator Network device configurator
* @ret rc Return status code
*/
int netdev_configure ( struct net_device *netdev,
struct net_device_configurator *configurator ) {
struct net_device_configuration *config =
netdev_configuration ( netdev, configurator );
int rc;
/* Check applicability of configurator */
if ( ! netdev_configurator_applies ( netdev, configurator ) ) {
DBGC ( netdev, "NETDEV %s does not support configuration via "
"%s\n", netdev->name, configurator->name );
return -ENOTSUP;
}
/* Terminate any ongoing configuration */
intf_restart ( &config->job, -ECANCELED );
/* Mark configuration as being in progress */
config->rc = -EINPROGRESS_CONFIG;
DBGC ( netdev, "NETDEV %s starting configuration via %s\n",
netdev->name, configurator->name );
/* Start configuration */
if ( ( rc = configurator->start ( &config->job, netdev ) ) != 0 ) {
DBGC ( netdev, "NETDEV %s could not start configuration via "
"%s: %s\n", netdev->name, configurator->name,
strerror ( rc ) );
config->rc = rc;
return rc;
}
return 0;
}
/**
* Start network device configuration via all supported configurators
*
* @v netdev Network device
* @ret rc Return status code
*/
int netdev_configure_all ( struct net_device *netdev ) {
struct net_device_configurator *configurator;
int rc;
/* Start configuration for each configurator */
for_each_table_entry ( configurator, NET_DEVICE_CONFIGURATORS ) {
/* Skip any inapplicable configurators */
if ( ! netdev_configurator_applies ( netdev, configurator ) )
continue;
/* Start configuration */
if ( ( rc = netdev_configure ( netdev, configurator ) ) != 0 )
return rc;
}
return 0;
}
/**
* Check if network device has a configuration with a specified status code
*
* @v netdev Network device
* @v rc Status code
* @ret has_rc Network device has a configuration with this status code
*/
static int netdev_has_configuration_rc ( struct net_device *netdev, int rc ) {
unsigned int num_configs;
unsigned int i;
num_configs = table_num_entries ( NET_DEVICE_CONFIGURATORS );
for ( i = 0 ; i < num_configs ; i++ ) {
if ( netdev->configs[i].rc == rc )
return 1;
}
return 0;
}
/**
* Check if network device configuration is in progress
*
* @v netdev Network device
* @ret is_in_progress Network device configuration is in progress
*/
int netdev_configuration_in_progress ( struct net_device *netdev ) {
return netdev_has_configuration_rc ( netdev, -EINPROGRESS_CONFIG );
}
/**
* Check if network device has at least one successful configuration
*
* @v netdev Network device
* @v configurator Configurator
* @ret rc Return status code
*/
int netdev_configuration_ok ( struct net_device *netdev ) {
return netdev_has_configuration_rc ( netdev, 0 );
}
|
620016.c | #include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include "tree.h"
//specification_begin
tree create_empty_tree(){
return NULL;
}
void destroy(tree t){
free(t);
}
tree build_tree(tree left, int val, tree right){
tree tmp = malloc(sizeof(node));
tmp->left = left;
tmp->val = val;
tmp->right = right;
return tmp;
}
bool tree_is_empty(tree t){
return t == NULL;
}
int get_root(tree t){
return t->val;
}
tree get_left(tree t){
return t->left;
}
tree get_right(tree t){
return t->right;
}
int remove_leftmost(tree *t){
if((*t)->left != NULL){
return remove_leftmost(&(*t)->left);
}else {
int tmp = (*t)->val;
tree a = (*t)->right;
free(*t);
*t = a;
return tmp;
}
}
tree delete_rightmost(tree t, int *new_root){
if(!tree_is_empty(t->right)){
tree tmp = build_tree(get_left(t),get_root(t), delete_rightmost(get_right(t), new_root));
destroy(t);
return tmp;
}else {
*new_root = get_root(t);
return get_left(t);
}
}
//specification_end
//function
void clear_tree_recursive(tree t){
if(t != NULL) {
clear_tree_recursive(t->left);
clear_tree_recursive(t->right);
free(t);
}
}
tree insert(tree t, int val){
if(tree_is_empty(t)){
return build_tree(create_empty_tree(), val, create_empty_tree());
} else if(val < get_root(t)) {
tree tmp = build_tree(insert(get_left(t), val), get_root(t), get_right(t));
return tmp;
} else if(val > get_root(t)){
tree tmp = build_tree(get_left(t), get_root(t),insert(get_right(t), val));
return tmp;
} else {
return t;
}
}
tree* find(tree *t, int val){
if(*t == NULL){
return NULL;
} else if(val < (*t)->val){
return find(&(*t)->left, val);
} else if(val > (*t)->val){
return find(&(*t)->left, val);
} else{
return t;
}
}
void remove_(tree *t){
if((*t)->left == NULL){
tree a = (*t)->right;
free(*t);
*t = a;
} else if((*t)->right == NULL){
tree a = (*t)->left;
free(*t);
*t = a;
} else{
int n = remove_leftmost(&(*t)->right);
(*t)->val = n;
}
}
tree remove_el(tree t, int val) {
if(tree_is_empty(t)){
return t;
} else if(val < get_root(t)){
tree tmp = build_tree(remove_el(get_left(t), val), get_root(t), get_right(t));
destroy(t);
return tmp;
}else if(val > get_root(t)){
tree tmp = build_tree(get_left(t), get_root(t), remove_el(get_right(t), val));
destroy(t);
return tmp;
}else{
if(tree_is_empty(get_right(t))){
tree tmp = get_left(t);
destroy(t);
return tmp;
} else if(tree_is_empty(get_left(t))){
tree tmp = get_right(t);
destroy(t);
return tmp;
}else {
int new_root;
tree new_left = delete_rightmost(get_left(t), &new_root);
tree tmp = build_tree(new_left, new_root, get_right(t));
destroy(t);
return tmp;
}
}
} |
460244.c | /* $NetBSD: lca.c,v 1.37 2002/05/16 01:01:32 thorpej Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Jason R. Thorpe.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
* Copyright (c) 1995, 1996 Carnegie-Mellon University.
* All rights reserved.
*
* Authors: Jeffrey Hsu and Chris G. Demetriou
*
* Permission to use, copy, modify and distribute this software and
* its documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
* FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or [email protected]
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie the
* rights to redistribute these changes.
*/
#include "opt_dec_axppci_33.h"
#include "opt_dec_alphabook1.h"
#include "opt_dec_eb66.h"
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(0, "$NetBSD: lca.c,v 1.37 2002/05/16 01:01:32 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
#include <sys/device.h>
#include <uvm/uvm_extern.h>
#include <machine/autoconf.h>
#include <machine/rpb.h>
#include <machine/sysarch.h>
#include <dev/isa/isareg.h>
#include <dev/isa/isavar.h>
#include <dev/pci/pcireg.h>
#include <dev/pci/pcivar.h>
#include <alpha/pci/lcareg.h>
#include <alpha/pci/lcavar.h>
#ifdef DEC_AXPPCI_33
#include <alpha/pci/pci_axppci_33.h>
#endif
#ifdef DEC_ALPHABOOK1
#include <alpha/pci/pci_alphabook1.h>
#endif
#ifdef DEC_EB66
#include <alpha/pci/pci_eb66.h>
#endif
int lcamatch __P((struct device *, struct cfdata *, void *));
void lcaattach __P((struct device *, struct device *, void *));
struct cfattach lca_ca = {
sizeof(struct lca_softc), lcamatch, lcaattach,
};
extern struct cfdriver lca_cd;
static int lcaprint __P((void *, const char *pnp));
int lca_bus_get_window __P((int, int,
struct alpha_bus_space_translation *));
/* There can be only one. */
int lcafound;
struct lca_config lca_configuration;
int
lcamatch(parent, match, aux)
struct device *parent;
struct cfdata *match;
void *aux;
{
struct mainbus_attach_args *ma = aux;
/* Make sure that we're looking for a LCA. */
if (strcmp(ma->ma_name, lca_cd.cd_name) != 0)
return (0);
if (lcafound)
return (0);
return (1);
}
/*
* Set up the chipset's function pointers.
*/
void
lca_init(lcp, mallocsafe)
struct lca_config *lcp;
int mallocsafe;
{
/*
* The LCA HAE register is WRITE-ONLY, so we can't tell where
* the second sparse window is actually mapped. Therefore,
* we have to guess where it is. This seems to be the normal
* address.
*/
lcp->lc_s_mem_w2_masked_base = 0x80000000;
if (!lcp->lc_initted) {
/* don't do these twice since they set up extents */
lca_bus_io_init(&lcp->lc_iot, lcp);
lca_bus_mem_init(&lcp->lc_memt, lcp);
/*
* We have 1 I/O window and 3 MEM windows.
*/
alpha_bus_window_count[ALPHA_BUS_TYPE_PCI_IO] = 1;
alpha_bus_window_count[ALPHA_BUS_TYPE_PCI_MEM] = 3;
alpha_bus_get_window = lca_bus_get_window;
}
lcp->lc_mallocsafe = mallocsafe;
lca_pci_init(&lcp->lc_pc, lcp);
alpha_pci_chipset = &lcp->lc_pc;
/*
* Refer to ``DECchip 21066 and DECchip 21068 Alpha AXP Microprocessors
* Hardware Reference Manual''.
* ...
*/
/*
* According to section 6.4.1, all bits of the IOC_HAE register are
* undefined after reset. Bits <31:27> are write-only. However, we
* cannot blindly set it to zero. The serial ROM code that initializes
* the PCI devices' address spaces, allocates sparse memory blocks in
* the range that must use the IOC_HAE register for address translation,
* and sets this register accordingly (see section 6.4.14).
*
* IOC_HAE left AS IS.
*/
/* According to section 6.4.2, all bits of the IOC_CONF register are
* undefined after reset. Bits <1:0> are write-only. Set them to
* 0x00 for PCI Type 0 configuration access.
*
* IOC_CONF set to ZERO.
*/
REGVAL64(LCA_IOC_CONF) = 0;
lcp->lc_initted = 1;
}
void
lcaattach(parent, self, aux)
struct device *parent, *self;
void *aux;
{
struct lca_softc *sc = (struct lca_softc *)self;
struct lca_config *lcp;
struct pcibus_attach_args pba;
/* note that we've attached the chipset; can't have 2 LCAs. */
/* Um, not sure about this. XXX JH */
lcafound = 1;
/*
* set up the chipset's info; done once at console init time
* (maybe), but we must do it twice to take care of things
* that need to use memory allocation.
*/
lcp = sc->sc_lcp = &lca_configuration;
lca_init(lcp, 1);
/* XXX print chipset information */
printf("\n");
lca_dma_init(lcp);
switch (cputype) {
#ifdef DEC_AXPPCI_33
case ST_DEC_AXPPCI_33:
pci_axppci_33_pickintr(lcp);
break;
#endif
#ifdef DEC_ALPHABOOK1
case ST_ALPHABOOK1:
pci_alphabook1_pickintr(lcp);
break;
#endif
#ifdef DEC_EB66
case ST_EB66:
pci_eb66_pickintr(lcp);
break;
#endif
default:
panic("lcaattach: shouldn't be here, really...");
}
pba.pba_busname = "pci";
pba.pba_iot = &lcp->lc_iot;
pba.pba_memt = &lcp->lc_memt;
pba.pba_dmat =
alphabus_dma_get_tag(&lcp->lc_dmat_direct, ALPHA_BUS_PCI);
pba.pba_pc = &lcp->lc_pc;
pba.pba_bus = 0;
pba.pba_bridgetag = NULL;
pba.pba_flags = PCI_FLAGS_IO_ENABLED | PCI_FLAGS_MEM_ENABLED |
PCI_FLAGS_MRL_OKAY | PCI_FLAGS_MRM_OKAY | PCI_FLAGS_MWI_OKAY;
config_found(self, &pba, lcaprint);
}
static int
lcaprint(aux, pnp)
void *aux;
const char *pnp;
{
register struct pcibus_attach_args *pba = aux;
/* only PCIs can attach to LCAes; easy. */
if (pnp)
printf("%s at %s", pba->pba_busname, pnp);
printf(" bus %d", pba->pba_bus);
return (UNCONF);
}
int
lca_bus_get_window(type, window, abst)
int type, window;
struct alpha_bus_space_translation *abst;
{
struct lca_config *lcp = &lca_configuration;
bus_space_tag_t st;
switch (type) {
case ALPHA_BUS_TYPE_PCI_IO:
st = &lcp->lc_iot;
break;
case ALPHA_BUS_TYPE_PCI_MEM:
st = &lcp->lc_memt;
break;
default:
panic("lca_bus_get_window");
}
return (alpha_bus_space_get_window(st, window, abst));
}
|
161991.c | #include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <pthread.h>
#include <errno.h>
#include "debug.h"
#include "box64context.h"
#include "dynarec.h"
#include "emu/x64emu_private.h"
#include "emu/x64run_private.h"
#include "x64run.h"
#include "x64emu.h"
#include "box64stack.h"
#include "callback.h"
#include "emu/x64run_private.h"
#include "x64trace.h"
#include "emu/x87emu_private.h"
#include "dynarec_native.h"
#include "arm64_printer.h"
#include "dynarec_arm64_private.h"
#include "dynarec_arm64_helper.h"
#include "dynarec_arm64_functions.h"
uintptr_t dynarec64_DD(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst, rex_t rex, int rep, int* ok, int* need_epilog)
{
(void)ip; (void)rep; (void)need_epilog;
uint8_t nextop = F8;
uint8_t ed;
int64_t fixedaddress;
int v1, v2;
int s0;
MAYUSE(s0);
MAYUSE(v2);
MAYUSE(v1);
switch(nextop) {
case 0xC0:
case 0xC1:
case 0xC2:
case 0xC3:
case 0xC4:
case 0xC5:
case 0xC6:
case 0xC7:
INST_NAME("FFREE STx");
MESSAGE(LOG_DUMP, "Need Optimization\n");
x87_purgecache(dyn, ninst, 0, x1, x2, x3);
MOV32w(x1, nextop&7);
CALL(fpu_do_free, -1);
break;
case 0xD0:
case 0xD1:
case 0xD2:
case 0xD3:
case 0xD4:
case 0xD5:
case 0xD6:
case 0xD7:
INST_NAME("FST ST0, STx");
v1 = x87_get_st(dyn, ninst, x1, x2, 0, X87_COMBINE(0, nextop&7));
v2 = x87_get_st(dyn, ninst, x1, x2, nextop&7, X87_COMBINE(0, nextop&7));
if(ST_IS_F(0)) {
FMOVS(v2, v1);
} else {
FMOVD(v2, v1);
}
break;
case 0xD8:
INST_NAME("FSTP ST0, ST0");
x87_do_pop(dyn, ninst, x3);
break;
case 0xD9:
case 0xDA:
case 0xDB:
case 0xDC:
case 0xDD:
case 0xDE:
case 0xDF:
INST_NAME("FSTP ST0, STx");
// copy the cache value for st0 to stx
x87_swapreg(dyn, ninst, x1, x2, 0, nextop&7);
x87_do_pop(dyn, ninst, x3);
break;
case 0xE0:
case 0xE1:
case 0xE2:
case 0xE3:
case 0xE4:
case 0xE5:
case 0xE6:
case 0xE7:
INST_NAME("FUCOM ST0, STx");
v1 = x87_get_st(dyn, ninst, x1, x2, 0, X87_COMBINE(0, nextop&7));
v2 = x87_get_st(dyn, ninst, x1, x2, nextop&7, X87_COMBINE(0, nextop&7));
if(ST_IS_F(0)) {
FCMPS(v1, v2);
} else {
FCMPD(v1, v2);
}
FCOM(x1, x2, x3);
break;
case 0xE8:
case 0xE9:
case 0xEA:
case 0xEB:
case 0xEC:
case 0xED:
case 0xEE:
case 0xEF:
INST_NAME("FUCOMP ST0, STx");
v1 = x87_get_st(dyn, ninst, x1, x2, 0, X87_COMBINE(0, nextop&7));
v2 = x87_get_st(dyn, ninst, x1, x2, nextop&7, X87_COMBINE(0, nextop&7));
if(ST_IS_F(0)) {
FCMPS(v1, v2);
} else {
FCMPD(v1, v2);
}
FCOM(x1, x2, x3);
x87_do_pop(dyn, ninst, x3);
break;
case 0xC8:
case 0xC9:
case 0xCA:
case 0xCB:
case 0xCC:
case 0xCD:
case 0xCE:
case 0xCF:
case 0xF0:
case 0xF1:
case 0xF2:
case 0xF3:
case 0xF4:
case 0xF5:
case 0xF6:
case 0xF7:
case 0xF8:
case 0xF9:
case 0xFA:
case 0xFB:
case 0xFC:
case 0xFD:
case 0xFE:
case 0xFF:
DEFAULT;
break;
default:
switch((nextop>>3)&7) {
case 0:
INST_NAME("FLD double");
v1 = x87_do_push(dyn, ninst, x3, NEON_CACHE_ST_D);
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 0xfff<<3, 7, rex, 0, 0);
VLDR64_U12(v1, ed, fixedaddress);
break;
case 1:
INST_NAME("FISTTP i64, ST0");
v1 = x87_do_push(dyn, ninst, x3, NEON_CACHE_ST_D);
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 0xfff<<3, 7, rex, 0, 0);
s0 = fpu_get_scratch(dyn);
#if 0
// those are ARM 8.5 opcode!
FRINT64ZD(s0, v1);
#else
FRINTRRD(s0, v1, 3); // not ideal, might averflow and not set 0x8000000000000000 correctly
#endif
FCVTZSxD(x2, s0);
STRx_U12(x2, ed, fixedaddress);
x87_do_pop(dyn, ninst, x3);
break;
case 2:
INST_NAME("FST double");
v1 = x87_get_st(dyn, ninst, x1, x2, 0, NEON_CACHE_ST_D);
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 0xfff<<3, 7, rex, 0, 0);
VSTR64_U12(v1, ed, fixedaddress);
break;
case 3:
INST_NAME("FSTP double");
v1 = x87_get_st(dyn, ninst, x1, x2, 0, NEON_CACHE_ST_D);
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 0xfff<<3, 7, rex, 0, 0);
VSTR64_U12(v1, ed, fixedaddress);
x87_do_pop(dyn, ninst, x3);
break;
case 4:
INST_NAME("FRSTOR m108byte");
MESSAGE(LOG_DUMP, "Need Optimization\n");
fpu_purgecache(dyn, ninst, 0, x1, x2, x3);
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 0, 0, rex, 0, 0);
if(ed!=x1) {MOVx_REG(x1, ed);}
CALL(arm_frstor, -1);
break;
case 6:
INST_NAME("FSAVE m108byte");
MESSAGE(LOG_DUMP, "Need Optimization\n");
fpu_purgecache(dyn, ninst, 0, x1, x2, x3);
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 0, 0, rex, 0, 0);
if(ed!=x1) {MOVx_REG(x1, ed);}
CALL(arm_fsave, -1);
break;
case 7:
INST_NAME("FNSTSW m2byte");
fpu_purgecache(dyn, ninst, 0, x1, x2, x3);
addr = geted(dyn, addr, ninst, nextop, &ed, x4, &fixedaddress, 0xfff<<1, 1, rex, 0, 0);
LDRw_U12(x2, xEmu, offsetof(x64emu_t, top));
LDRH_U12(x3, xEmu, offsetof(x64emu_t, sw));
if(dyn->n.x87stack) {
// update top
if(dyn->n.x87stack>0) {
SUBw_U12(x2, x2, dyn->n.x87stack);
} else {
ADDw_U12(x2, x2, -dyn->n.x87stack);
}
ANDw_mask(x2, x2, 0, 2);
}
BFIw(x3, x2, 11, 3); // inject TOP at bit 11 (3 bits)
STRH_U12(x3, ed, fixedaddress); // store whole sw flags
break;
default:
DEFAULT;
}
}
return addr;
}
|
348209.c | /**
* \file
* Static single assign form support for the JIT compiler.
*
* Author:
* Dietmar Maurer ([email protected])
*
* (C) 2003 Ximian, Inc.
* Copyright 2011 Xamarin, Inc (http://www.xamarin.com)
* Licensed under the MIT license. See LICENSE file in the project root for full license information.
*/
#include <config.h>
#include <string.h>
#include <mono/metadata/debug-helpers.h>
#include <mono/metadata/mempool.h>
#include <mono/metadata/mempool-internals.h>
#include <mono/utils/mono-compiler.h>
#ifndef DISABLE_JIT
#include "mini.h"
#include "mini-runtime.h"
#ifdef HAVE_ALLOCA_H
#include <alloca.h>
#endif
#define CREATE_PRUNED_SSA
//#define DEBUG_SSA 1
#define NEW_PHI(cfg,dest,val) do { \
MONO_INST_NEW ((cfg), (dest), OP_PHI); \
(dest)->inst_c0 = (val); \
} while (0)
typedef struct {
MonoBasicBlock *bb;
MonoInst *inst;
} MonoVarUsageInfo;
static void
unlink_target (MonoBasicBlock *bb, MonoBasicBlock *target)
{
int i;
for (i = 0; i < bb->out_count; i++) {
if (bb->out_bb [i] == target) {
bb->out_bb [i] = bb->out_bb [--bb->out_count];
break;
}
}
for (i = 0; i < target->in_count; i++) {
if (target->in_bb [i] == bb) {
target->in_bb [i] = target->in_bb [--target->in_count];
break;
}
}
}
static void
unlink_unused_bblocks (MonoCompile *cfg)
{
int i, j;
MonoBasicBlock *bb;
g_assert (cfg->comp_done & MONO_COMP_REACHABILITY);
if (G_UNLIKELY (cfg->verbose_level > 1))
printf ("\nUNLINK UNUSED BBLOCKS:\n");
for (bb = cfg->bb_entry; bb && bb->next_bb;) {
if (!(bb->next_bb->flags & BB_REACHABLE)) {
bb->next_bb = bb->next_bb->next_bb;
} else
bb = bb->next_bb;
}
for (i = 1; i < cfg->num_bblocks; i++) {
bb = cfg->bblocks [i];
if (!(bb->flags & BB_REACHABLE)) {
for (j = 0; j < bb->in_count; j++) {
unlink_target (bb->in_bb [j], bb);
}
for (j = 0; j < bb->out_count; j++) {
unlink_target (bb, bb->out_bb [j]);
}
if (G_UNLIKELY (cfg->verbose_level > 1))
printf ("\tUnlinked BB%d\n", bb->block_num);
}
}
}
/**
* remove_bb_from_phis:
*
* Remove BB from the PHI statements in TARGET.
*/
static void
remove_bb_from_phis (MonoCompile *cfg, MonoBasicBlock *bb, MonoBasicBlock *target)
{
MonoInst *ins;
int i, j;
for (i = 0; i < target->in_count; i++) {
if (target->in_bb [i] == bb) {
break;
}
}
g_assert (i < target->in_count);
for (ins = target->code; ins; ins = ins->next) {
if (MONO_IS_PHI (ins)) {
for (j = i; j < ins->inst_phi_args [0] - 1; ++j)
ins->inst_phi_args [j + 1] = ins->inst_phi_args [j + 2];
ins->inst_phi_args [0] --;
}
else
break;
}
}
static inline int
op_phi_to_move (int opcode)
{
switch (opcode) {
case OP_PHI:
return OP_MOVE;
case OP_FPHI:
return OP_FMOVE;
case OP_VPHI:
return OP_VMOVE;
case OP_XPHI:
return OP_XMOVE;
default:
g_assert_not_reached ();
}
return -1;
}
static inline void
record_use (MonoCompile *cfg, MonoInst *var, MonoBasicBlock *bb, MonoInst *ins)
{
MonoMethodVar *info;
MonoVarUsageInfo *ui = (MonoVarUsageInfo *)mono_mempool_alloc (cfg->mempool, sizeof (MonoVarUsageInfo));
info = MONO_VARINFO (cfg, var->inst_c0);
ui->bb = bb;
ui->inst = ins;
info->uses = g_list_prepend_mempool (cfg->mempool, info->uses, ui);
}
typedef struct {
MonoInst *var;
int idx;
} RenameInfo;
/**
* mono_ssa_rename_vars:
* Implement renaming of SSA variables. Also compute def-use information in parallel.
* \p stack_history points to an area of memory which can be used for storing changes
* made to the stack, so they can be reverted later.
*/
static void
mono_ssa_rename_vars (MonoCompile *cfg, int max_vars, MonoBasicBlock *bb, gboolean *originals_used, MonoInst **stack, guint32 *lvreg_stack, gboolean *lvreg_defined, RenameInfo *stack_history, int stack_history_size)
{
MonoInst *ins, *new_var;
int i, j, idx;
GSList *tmp;
int stack_history_len = 0;
if (cfg->verbose_level >= 4)
printf ("\nRENAME VARS BLOCK %d:\n", bb->block_num);
/* First pass: Create new vars */
for (ins = bb->code; ins; ins = ins->next) {
const char *spec = INS_INFO (ins->opcode);
int num_sregs;
int sregs [MONO_MAX_SRC_REGS];
#ifdef DEBUG_SSA
printf ("\tProcessing "); mono_print_ins (ins);
#endif
if (ins->opcode == OP_NOP)
continue;
/* SREGs */
num_sregs = mono_inst_get_src_registers (ins, sregs);
for (i = 0; i < num_sregs; ++i) {
if (spec [MONO_INST_SRC1 + i] != ' ') {
MonoInst *var = get_vreg_to_inst (cfg, sregs [i]);
if (var && !(var->flags & (MONO_INST_VOLATILE|MONO_INST_INDIRECT))) {
int idx = var->inst_c0;
if (stack [idx]) {
if (var->opcode != OP_ARG)
g_assert (stack [idx]);
sregs [i] = stack [idx]->dreg;
record_use (cfg, stack [idx], bb, ins);
}
else
record_use (cfg, var, bb, ins);
}
else if (G_UNLIKELY (!var && lvreg_stack [sregs [i]]))
sregs [i] = lvreg_stack [sregs [i]];
}
}
mono_inst_set_src_registers (ins, sregs);
if (MONO_IS_STORE_MEMBASE (ins)) {
MonoInst *var = get_vreg_to_inst (cfg, ins->dreg);
if (var && !(var->flags & (MONO_INST_VOLATILE|MONO_INST_INDIRECT))) {
int idx = var->inst_c0;
if (stack [idx]) {
if (var->opcode != OP_ARG)
g_assert (stack [idx]);
ins->dreg = stack [idx]->dreg;
record_use (cfg, stack [idx], bb, ins);
}
else
record_use (cfg, var, bb, ins);
}
else if (G_UNLIKELY (!var && lvreg_stack [ins->dreg]))
ins->dreg = lvreg_stack [ins->dreg];
}
/* DREG */
if ((spec [MONO_INST_DEST] != ' ') && !MONO_IS_STORE_MEMBASE (ins)) {
MonoInst *var = get_vreg_to_inst (cfg, ins->dreg);
MonoMethodVar *info;
if (var && !(var->flags & (MONO_INST_VOLATILE|MONO_INST_INDIRECT))) {
idx = var->inst_c0;
g_assert (idx < max_vars);
if (var->opcode == OP_ARG)
originals_used [idx] = TRUE;
if (stack_history_len + 128 > stack_history_size) {
stack_history_size += 1024;
RenameInfo *new_history = mono_mempool_alloc (cfg->mempool, sizeof (RenameInfo) * stack_history_size);
memcpy (new_history, stack_history, stack_history_len * sizeof (RenameInfo));
stack_history = new_history;
}
stack_history [stack_history_len].var = stack [idx];
stack_history [stack_history_len].idx = idx;
stack_history_len ++;
if (originals_used [idx]) {
new_var = mono_compile_create_var (cfg, var->inst_vtype, OP_LOCAL);
new_var->flags = var->flags;
MONO_VARINFO (cfg, new_var->inst_c0)->reg = idx;
if (cfg->verbose_level >= 4)
printf (" R%d -> R%d\n", var->dreg, new_var->dreg);
stack [idx] = new_var;
ins->dreg = new_var->dreg;
var = new_var;
}
else {
stack [idx] = var;
originals_used [idx] = TRUE;
}
info = MONO_VARINFO (cfg, var->inst_c0);
info->def = ins;
info->def_bb = bb;
}
else if (G_UNLIKELY (!var && lvreg_defined [ins->dreg] && (ins->dreg >= MONO_MAX_IREGS))) {
/* Perform renaming for local vregs */
lvreg_stack [ins->dreg] = vreg_is_ref (cfg, ins->dreg) ? mono_alloc_ireg_ref (cfg) : mono_alloc_preg (cfg);
ins->dreg = lvreg_stack [ins->dreg];
}
else
lvreg_defined [ins->dreg] = TRUE;
}
#ifdef DEBUG_SSA
printf ("\tAfter processing "); mono_print_ins (ins);
#endif
}
/* Rename PHI arguments in succeeding bblocks */
for (i = 0; i < bb->out_count; i++) {
MonoBasicBlock *n = bb->out_bb [i];
for (j = 0; j < n->in_count; j++)
if (n->in_bb [j] == bb)
break;
for (ins = n->code; ins; ins = ins->next) {
if (MONO_IS_PHI (ins)) {
idx = ins->inst_c0;
if (stack [idx])
new_var = stack [idx];
else
new_var = cfg->varinfo [idx];
#ifdef DEBUG_SSA
printf ("FOUND PHI %d (%d, %d)\n", idx, j, new_var->inst_c0);
#endif
ins->inst_phi_args [j + 1] = new_var->dreg;
record_use (cfg, new_var, n, ins);
if (G_UNLIKELY (cfg->verbose_level >= 4))
printf ("\tAdd PHI R%d <- R%d to BB%d\n", ins->dreg, new_var->dreg, n->block_num);
}
else
/* The phi nodes are at the beginning of the bblock */
break;
}
}
if (bb->dominated) {
for (tmp = bb->dominated; tmp; tmp = tmp->next) {
mono_ssa_rename_vars (cfg, max_vars, (MonoBasicBlock *)tmp->data, originals_used, stack, lvreg_stack, lvreg_defined, stack_history + stack_history_len, stack_history_size - stack_history_len);
}
}
/* Restore stack */
for (i = stack_history_len - 1; i >= 0; i--) {
stack [stack_history [i].idx] = stack_history [i].var;
}
cfg->comp_done |= MONO_COMP_SSA_DEF_USE;
}
void
mono_ssa_compute (MonoCompile *cfg)
{
int i, j, idx, bitsize;
MonoBitSet *set;
MonoMethodVar *vinfo = g_new0 (MonoMethodVar, cfg->num_varinfo);
MonoInst *ins, **stack;
guint8 *buf, *buf_start;
RenameInfo *stack_history;
int stack_history_size;
gboolean *originals;
guint32 *lvreg_stack;
gboolean *lvreg_defined;
g_assert (!(cfg->comp_done & MONO_COMP_SSA));
g_assert (!cfg->disable_ssa);
if (cfg->verbose_level >= 4)
printf ("\nCOMPUTE SSA %d (R%d-)\n\n", cfg->num_varinfo, cfg->next_vreg);
#ifdef CREATE_PRUNED_SSA
/* we need liveness for pruned SSA */
if (!(cfg->comp_done & MONO_COMP_LIVENESS))
mono_analyze_liveness (cfg);
#endif
mono_compile_dominator_info (cfg, MONO_COMP_DOM | MONO_COMP_IDOM | MONO_COMP_DFRONTIER);
bitsize = mono_bitset_alloc_size (cfg->num_bblocks, 0);
buf = buf_start = (guint8 *)g_malloc0 (mono_bitset_alloc_size (cfg->num_bblocks, 0) * cfg->num_varinfo);
for (i = 0; i < cfg->num_varinfo; ++i) {
vinfo [i].def_in = mono_bitset_mem_new (buf, cfg->num_bblocks, 0);
buf += bitsize;
vinfo [i].idx = i;
/* implicit reference at start */
if (cfg->varinfo [i]->opcode == OP_ARG)
mono_bitset_set_fast (vinfo [i].def_in, 0);
}
for (i = 0; i < cfg->num_bblocks; ++i) {
MONO_BB_FOR_EACH_INS (cfg->bblocks [i], ins) {
if (ins->opcode == OP_NOP)
continue;
if (!MONO_IS_STORE_MEMBASE (ins) && get_vreg_to_inst (cfg, ins->dreg)) {
mono_bitset_set_fast (vinfo [get_vreg_to_inst (cfg, ins->dreg)->inst_c0].def_in, i);
}
}
}
/* insert phi functions */
for (i = 0; i < cfg->num_varinfo; ++i) {
MonoInst *var = cfg->varinfo [i];
#if SIZEOF_REGISTER == 4
if (var->type == STACK_I8 && !COMPILE_LLVM (cfg))
continue;
#endif
if (var->flags & (MONO_INST_VOLATILE|MONO_INST_INDIRECT))
continue;
/* Most variables have only one definition */
if (mono_bitset_count (vinfo [i].def_in) <= 1)
continue;
set = mono_compile_iterated_dfrontier (cfg, vinfo [i].def_in);
if (cfg->verbose_level >= 4) {
if (mono_bitset_count (set) > 0) {
printf ("\tR%d needs PHI functions in ", var->dreg);
mono_blockset_print (cfg, set, "", -1);
}
}
mono_bitset_foreach_bit (set, idx, cfg->num_bblocks) {
MonoBasicBlock *bb = cfg->bblocks [idx];
/* fixme: create pruned SSA? we would need liveness information for that */
if (bb == cfg->bb_exit && !COMPILE_LLVM (cfg))
continue;
if ((cfg->comp_done & MONO_COMP_LIVENESS) && !mono_bitset_test_fast (bb->live_in_set, i)) {
//printf ("%d is not live in BB%d %s\n", i, bb->block_num, mono_method_full_name (cfg->method, TRUE));
continue;
}
NEW_PHI (cfg, ins, i);
switch (var->type) {
case STACK_I4:
case STACK_I8:
case STACK_PTR:
case STACK_MP:
case STACK_OBJ:
ins->opcode = OP_PHI;
break;
case STACK_R8:
ins->opcode = OP_FPHI;
break;
case STACK_VTYPE:
ins->opcode = MONO_CLASS_IS_SIMD (cfg, var->klass) ? OP_XPHI : OP_VPHI;
break;
}
if (var->inst_vtype->byref)
ins->klass = mono_defaults.int_class;
else
ins->klass = var->klass;
ins->inst_phi_args = (int *)mono_mempool_alloc0 (cfg->mempool, sizeof (int) * (cfg->bblocks [idx]->in_count + 1));
ins->inst_phi_args [0] = cfg->bblocks [idx]->in_count;
/* For debugging */
for (j = 0; j < cfg->bblocks [idx]->in_count; ++j)
ins->inst_phi_args [j + 1] = -1;
ins->dreg = cfg->varinfo [i]->dreg;
mono_bblock_insert_before_ins (bb, bb->code, ins);
#ifdef DEBUG_SSA
printf ("ADD PHI BB%d %s\n", cfg->bblocks [idx]->block_num, mono_method_full_name (cfg->method, TRUE));
#endif
}
}
/* free the stuff */
g_free (vinfo);
g_free (buf_start);
/* Renaming phase */
stack = (MonoInst **)alloca (sizeof (MonoInst *) * cfg->num_varinfo);
memset (stack, 0, sizeof (MonoInst *) * cfg->num_varinfo);
lvreg_stack = g_new0 (guint32, cfg->next_vreg);
lvreg_defined = g_new0 (gboolean, cfg->next_vreg);
stack_history_size = 10240;
stack_history = g_new (RenameInfo, stack_history_size);
originals = g_new0 (gboolean, cfg->num_varinfo);
mono_ssa_rename_vars (cfg, cfg->num_varinfo, cfg->bb_entry, originals, stack, lvreg_stack, lvreg_defined, stack_history, stack_history_size);
g_free (stack_history);
g_free (originals);
g_free (lvreg_stack);
g_free (lvreg_defined);
if (cfg->verbose_level >= 4)
printf ("\nEND COMPUTE SSA.\n\n");
cfg->comp_done |= MONO_COMP_SSA;
}
/*
* mono_ssa_remove_gsharedvt:
*
* Same as mono_ssa_remove, but only remove phi nodes for gsharedvt variables.
*/
void
mono_ssa_remove_gsharedvt (MonoCompile *cfg)
{
MonoInst *ins, *var, *move;
int i, j, first;
/*
* When compiling gsharedvt code, we need to get rid of the VPHI instructions,
* since they cannot be handled later in the llvm backend.
*/
g_assert (cfg->comp_done & MONO_COMP_SSA);
for (i = 0; i < cfg->num_bblocks; ++i) {
MonoBasicBlock *bb = cfg->bblocks [i];
if (cfg->verbose_level >= 4)
printf ("\nREMOVE SSA %d:\n", bb->block_num);
for (ins = bb->code; ins; ins = ins->next) {
if (!(MONO_IS_PHI (ins) && ins->opcode == OP_VPHI && mini_is_gsharedvt_variable_type (m_class_get_byval_arg (ins->klass))))
continue;
g_assert (ins->inst_phi_args [0] == bb->in_count);
var = get_vreg_to_inst (cfg, ins->dreg);
/* Check for PHI nodes where all the inputs are the same */
first = ins->inst_phi_args [1];
for (j = 1; j < bb->in_count; ++j)
if (first != ins->inst_phi_args [j + 1])
break;
if ((bb->in_count > 1) && (j == bb->in_count)) {
ins->opcode = op_phi_to_move (ins->opcode);
if (ins->opcode == OP_VMOVE)
g_assert (ins->klass);
ins->sreg1 = first;
} else {
for (j = 0; j < bb->in_count; j++) {
MonoBasicBlock *pred = bb->in_bb [j];
int sreg = ins->inst_phi_args [j + 1];
if (cfg->verbose_level >= 4)
printf ("\tADD R%d <- R%d in BB%d\n", var->dreg, sreg, pred->block_num);
if (var->dreg != sreg) {
MONO_INST_NEW (cfg, move, op_phi_to_move (ins->opcode));
if (move->opcode == OP_VMOVE) {
g_assert (ins->klass);
move->klass = ins->klass;
}
move->dreg = var->dreg;
move->sreg1 = sreg;
mono_add_ins_to_end (pred, move);
}
}
NULLIFY_INS (ins);
}
}
}
}
void
mono_ssa_remove (MonoCompile *cfg)
{
MonoInst *ins, *var, *move;
int bbindex, i, j, first;
g_assert (cfg->comp_done & MONO_COMP_SSA);
for (i = 0; i < cfg->num_bblocks; ++i) {
MonoBasicBlock *bb = cfg->bblocks [i];
if (cfg->verbose_level >= 4)
printf ("\nREMOVE SSA %d:\n", bb->block_num);
for (ins = bb->code; ins; ins = ins->next) {
if (MONO_IS_PHI (ins)) {
g_assert (ins->inst_phi_args [0] == bb->in_count);
var = get_vreg_to_inst (cfg, ins->dreg);
/* Check for PHI nodes where all the inputs are the same */
first = ins->inst_phi_args [1];
for (j = 1; j < bb->in_count; ++j)
if (first != ins->inst_phi_args [j + 1])
break;
if ((bb->in_count > 1) && (j == bb->in_count)) {
ins->opcode = op_phi_to_move (ins->opcode);
if (ins->opcode == OP_VMOVE)
g_assert (ins->klass);
ins->sreg1 = first;
} else {
for (j = 0; j < bb->in_count; j++) {
MonoBasicBlock *pred = bb->in_bb [j];
int sreg = ins->inst_phi_args [j + 1];
if (cfg->verbose_level >= 4)
printf ("\tADD R%d <- R%d in BB%d\n", var->dreg, sreg, pred->block_num);
if (var->dreg != sreg) {
MONO_INST_NEW (cfg, move, op_phi_to_move (ins->opcode));
if (move->opcode == OP_VMOVE) {
g_assert (ins->klass);
move->klass = ins->klass;
}
move->dreg = var->dreg;
move->sreg1 = sreg;
mono_add_ins_to_end (pred, move);
}
}
NULLIFY_INS (ins);
}
}
}
}
if (cfg->verbose_level >= 4) {
for (i = 0; i < cfg->num_bblocks; ++i) {
MonoBasicBlock *bb = cfg->bblocks [i];
mono_print_bb (bb, "AFTER REMOVE SSA:");
}
}
/*
* Removal of SSA form introduces many copies. To avoid this, we tyry to coalesce
* the variables if possible. Since the newly introduced SSA variables don't
* have overlapping live ranges (because we don't do agressive optimization), we
* can coalesce them into the original variable.
*/
for (bbindex = 0; bbindex < cfg->num_bblocks; ++bbindex) {
MonoBasicBlock *bb = cfg->bblocks [bbindex];
for (ins = bb->code; ins; ins = ins->next) {
const char *spec = INS_INFO (ins->opcode);
int num_sregs;
int sregs [MONO_MAX_SRC_REGS];
if (ins->opcode == OP_NOP)
continue;
if (spec [MONO_INST_DEST] != ' ') {
MonoInst *var = get_vreg_to_inst (cfg, ins->dreg);
if (var) {
MonoMethodVar *vmv = MONO_VARINFO (cfg, var->inst_c0);
/*
* The third condition avoids coalescing with variables eliminated
* during deadce.
*/
if ((vmv->reg != -1) && (vmv->idx != vmv->reg) && (MONO_VARINFO (cfg, vmv->reg)->reg != -1)) {
printf ("COALESCE: R%d -> R%d\n", ins->dreg, cfg->varinfo [vmv->reg]->dreg);
ins->dreg = cfg->varinfo [vmv->reg]->dreg;
}
}
}
num_sregs = mono_inst_get_src_registers (ins, sregs);
for (i = 0; i < num_sregs; ++i) {
MonoInst *var = get_vreg_to_inst (cfg, sregs [i]);
if (var) {
MonoMethodVar *vmv = MONO_VARINFO (cfg, var->inst_c0);
if ((vmv->reg != -1) && (vmv->idx != vmv->reg) && (MONO_VARINFO (cfg, vmv->reg)->reg != -1)) {
printf ("COALESCE: R%d -> R%d\n", sregs [i], cfg->varinfo [vmv->reg]->dreg);
sregs [i] = cfg->varinfo [vmv->reg]->dreg;
}
}
}
mono_inst_set_src_registers (ins, sregs);
}
}
for (i = 0; i < cfg->num_varinfo; ++i) {
MONO_VARINFO (cfg, i)->reg = -1;
}
if (cfg->comp_done & MONO_COMP_REACHABILITY)
unlink_unused_bblocks (cfg);
cfg->comp_done &= ~MONO_COMP_LIVENESS;
cfg->comp_done &= ~MONO_COMP_SSA;
}
static void
mono_ssa_create_def_use (MonoCompile *cfg)
{
MonoBasicBlock *bb;
MonoInst *ins;
int i;
g_assert (!(cfg->comp_done & MONO_COMP_SSA_DEF_USE));
for (bb = cfg->bb_entry; bb; bb = bb->next_bb) {
for (ins = bb->code; ins; ins = ins->next) {
const char *spec = INS_INFO (ins->opcode);
MonoMethodVar *info;
int num_sregs;
int sregs [MONO_MAX_SRC_REGS];
if (ins->opcode == OP_NOP)
continue;
/* SREGs */
num_sregs = mono_inst_get_src_registers (ins, sregs);
for (i = 0; i < num_sregs; ++i) {
MonoInst *var = get_vreg_to_inst (cfg, sregs [i]);
if (var && !(var->flags & (MONO_INST_VOLATILE|MONO_INST_INDIRECT)))
record_use (cfg, var, bb, ins);
}
if (MONO_IS_STORE_MEMBASE (ins)) {
MonoInst *var = get_vreg_to_inst (cfg, ins->dreg);
if (var && !(var->flags & (MONO_INST_VOLATILE|MONO_INST_INDIRECT)))
record_use (cfg, var, bb, ins);
}
if (MONO_IS_PHI (ins)) {
for (i = ins->inst_phi_args [0]; i > 0; i--) {
g_assert (ins->inst_phi_args [i] != -1);
record_use (cfg, get_vreg_to_inst (cfg, ins->inst_phi_args [i]), bb, ins);
}
}
/* DREG */
if ((spec [MONO_INST_DEST] != ' ') && !MONO_IS_STORE_MEMBASE (ins)) {
MonoInst *var = get_vreg_to_inst (cfg, ins->dreg);
if (var && !(var->flags & (MONO_INST_VOLATILE|MONO_INST_INDIRECT))) {
info = MONO_VARINFO (cfg, var->inst_c0);
info->def = ins;
info->def_bb = bb;
}
}
}
}
cfg->comp_done |= MONO_COMP_SSA_DEF_USE;
}
static void
mono_ssa_copyprop (MonoCompile *cfg)
{
int i, index;
GList *l;
g_assert ((cfg->comp_done & MONO_COMP_SSA_DEF_USE));
for (index = 0; index < cfg->num_varinfo; ++index) {
MonoInst *var = cfg->varinfo [index];
MonoMethodVar *info = MONO_VARINFO (cfg, index);
if (info->def && (MONO_IS_MOVE (info->def))) {
MonoInst *var2 = get_vreg_to_inst (cfg, info->def->sreg1);
if (var2 && !(var2->flags & (MONO_INST_VOLATILE|MONO_INST_INDIRECT)) && MONO_VARINFO (cfg, var2->inst_c0)->def && (!MONO_IS_PHI (MONO_VARINFO (cfg, var2->inst_c0)->def))) {
/* Rewrite all uses of var to be uses of var2 */
int dreg = var->dreg;
int sreg1 = var2->dreg;
l = info->uses;
while (l) {
MonoVarUsageInfo *u = (MonoVarUsageInfo*)l->data;
MonoInst *ins = u->inst;
GList *next = l->next;
int num_sregs;
int sregs [MONO_MAX_SRC_REGS];
num_sregs = mono_inst_get_src_registers (ins, sregs);
for (i = 0; i < num_sregs; ++i) {
if (sregs [i] == dreg)
break;
}
if (i < num_sregs) {
g_assert (sregs [i] == dreg);
sregs [i] = sreg1;
mono_inst_set_src_registers (ins, sregs);
} else if (MONO_IS_STORE_MEMBASE (ins) && ins->dreg == dreg) {
ins->dreg = sreg1;
} else if (MONO_IS_PHI (ins)) {
for (i = ins->inst_phi_args [0]; i > 0; i--) {
int sreg = ins->inst_phi_args [i];
if (sreg == var->dreg)
break;
}
g_assert (i > 0);
ins->inst_phi_args [i] = sreg1;
}
else
g_assert_not_reached ();
record_use (cfg, var2, u->bb, ins);
l = next;
}
info->uses = NULL;
}
}
}
if (cfg->verbose_level >= 4) {
MonoBasicBlock *bb;
for (bb = cfg->bb_entry; bb; bb = bb->next_bb)
mono_print_bb (bb, "AFTER SSA COPYPROP");
}
}
static int
evaluate_ins (MonoCompile *cfg, MonoInst *ins, MonoInst **res, MonoInst **carray)
{
MonoInst *args [MONO_MAX_SRC_REGS];
int rs [MONO_MAX_SRC_REGS];
MonoInst *c0;
gboolean const_args = TRUE;
const char *spec = INS_INFO (ins->opcode);
int num_sregs, i;
int sregs [MONO_MAX_SRC_REGS];
/* Short-circuit this */
if (ins->opcode == OP_ICONST) {
*res = ins;
return 1;
}
if (ins->opcode == OP_NOP)
return 2;
num_sregs = mono_inst_get_src_registers (ins, sregs);
for (i = 0; i < MONO_MAX_SRC_REGS; ++i)
args [i] = NULL;
for (i = 0; i < num_sregs; ++i) {
MonoInst *var = get_vreg_to_inst (cfg, sregs [i]);
rs [i] = 2;
args [i] = carray [sregs [i]];
if (args [i])
rs [i] = 1;
else if (var && !(var->flags & (MONO_INST_VOLATILE|MONO_INST_INDIRECT)))
rs [i] = MONO_VARINFO (cfg, var->inst_c0)->cpstate;
if (rs [i] != 1)
const_args = FALSE;
}
c0 = NULL;
if (num_sregs > 0 && const_args) {
g_assert (num_sregs <= 2);
if ((spec [MONO_INST_DEST] != ' ') && carray [ins->dreg]) {
// Cached value
*res = carray [ins->dreg];
return 1;
}
c0 = mono_constant_fold_ins (cfg, ins, args [0], args [1], FALSE);
if (c0) {
if (G_UNLIKELY (cfg->verbose_level > 1)) {
printf ("\t cfold -> ");
mono_print_ins (c0);
}
*res = c0;
return 1;
}
else
/* Can't cfold this ins */
return 2;
}
if (num_sregs == 0)
return 2;
for (i = 0; i < num_sregs; ++i) {
if (rs [i] == 2)
return 2;
}
return 0;
}
static inline void
change_varstate (MonoCompile *cfg, GList **cvars, MonoMethodVar *info, int state, MonoInst *c0, MonoInst **carray)
{
if (info->cpstate >= state)
return;
info->cpstate = state;
if (G_UNLIKELY (cfg->verbose_level > 1))
printf ("\tState of R%d set to %d\n", cfg->varinfo [info->idx]->dreg, info->cpstate);
if (state == 1)
g_assert (c0);
carray [cfg->varinfo [info->idx]->dreg] = c0;
if (!g_list_find (*cvars, info)) {
*cvars = g_list_prepend (*cvars, info);
}
}
static inline void
add_cprop_bb (MonoCompile *cfg, MonoBasicBlock *bb, GList **bblist)
{
if (G_UNLIKELY (cfg->verbose_level > 1))
printf ("\tAdd BB%d to worklist\n", bb->block_num);
if (!(bb->flags & BB_REACHABLE)) {
bb->flags |= BB_REACHABLE;
*bblist = g_list_prepend (*bblist, bb);
}
}
static void
visit_inst (MonoCompile *cfg, MonoBasicBlock *bb, MonoInst *ins, GList **cvars, GList **bblist, MonoInst **carray)
{
const char *spec = INS_INFO (ins->opcode);
if (ins->opcode == OP_NOP)
return;
if (cfg->verbose_level > 1)
mono_print_ins (ins);
/* FIXME: Support longs/floats */
/* FIXME: Work on vregs as well */
if (MONO_IS_PHI (ins)) {
MonoMethodVar *info = MONO_VARINFO (cfg, get_vreg_to_inst (cfg, ins->dreg)->inst_c0);
MonoInst *c0 = NULL;
int j;
for (j = 1; j <= ins->inst_phi_args [0]; j++) {
MonoInst *var = get_vreg_to_inst (cfg, ins->inst_phi_args [j]);
MonoMethodVar *mv = MONO_VARINFO (cfg, var->inst_c0);
MonoInst *src = mv->def;
if (mv->def_bb && !(mv->def_bb->flags & BB_REACHABLE))
continue;
if (!mv->def || !src || mv->cpstate == 2) {
change_varstate (cfg, cvars, info, 2, NULL, carray);
break;
}
if (mv->cpstate == 0)
continue;
g_assert (carray [var->dreg]);
if (!c0)
c0 = carray [var->dreg];
/* FIXME: */
if (c0->opcode != OP_ICONST) {
change_varstate (cfg, cvars, info, 2, NULL, carray);
break;
}
if (carray [var->dreg]->inst_c0 != c0->inst_c0) {
change_varstate (cfg, cvars, info, 2, NULL, carray);
break;
}
}
if (c0 && info->cpstate < 1) {
change_varstate (cfg, cvars, info, 1, c0, carray);
g_assert (c0->opcode == OP_ICONST);
}
}
else if (!MONO_IS_STORE_MEMBASE (ins) && ((spec [MONO_INST_SRC1] != ' ') || (spec [MONO_INST_SRC2] != ' ') || (spec [MONO_INST_DEST] != ' '))) {
MonoInst *var, *c0;
int state;
if (spec [MONO_INST_DEST] != ' ')
var = get_vreg_to_inst (cfg, ins->dreg);
else
var = NULL;
c0 = NULL;
state = evaluate_ins (cfg, ins, &c0, carray);
if (var && !(var->flags & (MONO_INST_VOLATILE|MONO_INST_INDIRECT))) {
MonoMethodVar *info = MONO_VARINFO (cfg, var->inst_c0);
if (info->cpstate < 2) {
if (state == 1)
change_varstate (cfg, cvars, info, 1, c0, carray);
else if (state == 2)
change_varstate (cfg, cvars, info, 2, NULL, carray);
}
}
else if (!var && (ins->dreg != -1)) {
/*
* We don't record def-use information for local vregs since it would be
* expensive. Instead, we depend on the fact that all uses of the vreg are in
* the same bblock, so they will be examined after the definition.
* FIXME: This isn't true if the ins is visited through an SSA edge.
*/
if (c0) {
carray [ins->dreg] = c0;
} else {
if (carray [ins->dreg]) {
/*
* The state of the vreg changed from constant to non-constant
* -> need to rescan the whole bblock.
*/
carray [ins->dreg] = NULL;
/* FIXME: Speed this up */
if (!g_list_find (*bblist, bb))
*bblist = g_list_prepend (*bblist, bb);
}
}
}
if (MONO_IS_JUMP_TABLE (ins)) {
int i;
MonoJumpInfoBBTable *table = (MonoJumpInfoBBTable *)MONO_JUMP_TABLE_FROM_INS (ins);
if (!ins->next || ins->next->opcode != OP_PADD) {
/* The PADD was optimized away */
/* FIXME: handle this as well */
for (i = 0; i < table->table_size; i++)
if (table->table [i])
add_cprop_bb (cfg, table->table [i], bblist);
return;
}
g_assert (ins->next->opcode == OP_PADD);
g_assert (ins->next->sreg1 == ins->dreg);
if (carray [ins->next->sreg2]) {
#if SIZEOF_REGISTER == 8
int idx = carray [ins->next->sreg2]->inst_c0 >> 3;
#else
int idx = carray [ins->next->sreg2]->inst_c0 >> 2;
#endif
if ((idx < 0) || (idx >= table->table_size))
/* Out-of-range, no branch is executed */
return;
else
if (table->table [idx])
add_cprop_bb (cfg, table->table [idx], bblist);
}
else {
for (i = 0; i < table->table_size; i++)
if (table->table [i])
add_cprop_bb (cfg, table->table [i], bblist);
}
}
if (ins->opcode == OP_SWITCH) {
int i;
MonoJumpInfoBBTable *table = (MonoJumpInfoBBTable *)ins->inst_p0;
for (i = 0; i < table->table_size; i++)
if (table->table [i])
add_cprop_bb (cfg, table->table [i], bblist);
}
/* Handle COMPARE+BRCOND pairs */
if (ins->next && MONO_IS_COND_BRANCH_OP (ins->next)) {
if (c0) {
g_assert (c0->opcode == OP_ICONST);
if (c0->inst_c0)
ins->next->flags |= MONO_INST_CFOLD_TAKEN;
else
ins->next->flags |= MONO_INST_CFOLD_NOT_TAKEN;
}
else {
ins->next->flags &= ~(MONO_INST_CFOLD_TAKEN | MONO_INST_CFOLD_NOT_TAKEN);
}
visit_inst (cfg, bb, ins->next, cvars, bblist, carray);
}
} else if (ins->opcode == OP_BR) {
add_cprop_bb (cfg, ins->inst_target_bb, bblist);
} else if (MONO_IS_COND_BRANCH_OP (ins)) {
if (ins->flags & MONO_INST_CFOLD_TAKEN) {
add_cprop_bb (cfg, ins->inst_true_bb, bblist);
} else if (ins->flags & MONO_INST_CFOLD_NOT_TAKEN) {
if (ins->inst_false_bb)
add_cprop_bb (cfg, ins->inst_false_bb, bblist);
} else {
add_cprop_bb (cfg, ins->inst_true_bb, bblist);
if (ins->inst_false_bb)
add_cprop_bb (cfg, ins->inst_false_bb, bblist);
}
}
}
/**
* fold_ins:
*
* Replace INS with its constant value, if it exists
*/
static void
fold_ins (MonoCompile *cfg, MonoBasicBlock *bb, MonoInst *ins, MonoInst **carray)
{
const char *spec = INS_INFO (ins->opcode);
int opcode2;
int num_sregs = mono_inst_get_num_src_registers (ins);
if ((ins->opcode != OP_NOP) && (ins->dreg != -1) && !MONO_IS_STORE_MEMBASE (ins)) {
if (carray [ins->dreg] && (spec [MONO_INST_DEST] == 'i') && (ins->dreg >= MONO_MAX_IREGS)) {
/* Perform constant folding */
/* FIXME: */
g_assert (carray [ins->dreg]->opcode == OP_ICONST);
ins->opcode = OP_ICONST;
ins->inst_c0 = carray [ins->dreg]->inst_c0;
MONO_INST_NULLIFY_SREGS (ins);
} else if (num_sregs == 2 && carray [ins->sreg2]) {
/* Perform op->op_imm conversion */
opcode2 = mono_op_to_op_imm (ins->opcode);
if (opcode2 != -1) {
ins->opcode = opcode2;
ins->inst_imm = carray [ins->sreg2]->inst_c0;
ins->sreg2 = -1;
if ((opcode2 == OP_VOIDCALL) || (opcode2 == OP_CALL) || (opcode2 == OP_LCALL) || (opcode2 == OP_FCALL))
((MonoCallInst*)ins)->fptr = (gpointer)ins->inst_imm;
}
} else {
/* FIXME: Handle 3 op insns */
}
if (MONO_IS_JUMP_TABLE (ins)) {
int i;
MonoJumpInfoBBTable *table = (MonoJumpInfoBBTable *)MONO_JUMP_TABLE_FROM_INS (ins);
if (!ins->next || ins->next->opcode != OP_PADD) {
/* The PADD was optimized away */
/* FIXME: handle this as well */
return;
}
g_assert (ins->next->opcode == OP_PADD);
g_assert (ins->next->sreg1 == ins->dreg);
g_assert (ins->next->next->opcode == OP_LOAD_MEMBASE);
if (carray [ins->next->sreg2]) {
/* Convert to a simple branch */
#if SIZEOF_REGISTER == 8
int idx = carray [ins->next->sreg2]->inst_c0 >> 3;
#else
int idx = carray [ins->next->sreg2]->inst_c0 >> 2;
#endif
if (!((idx >= 0) && (idx < table->table_size))) {
/* Out of range, eliminate the whole switch */
for (i = 0; i < table->table_size; ++i) {
remove_bb_from_phis (cfg, bb, table->table [i]);
mono_unlink_bblock (cfg, bb, table->table [i]);
}
NULLIFY_INS (ins);
NULLIFY_INS (ins->next);
NULLIFY_INS (ins->next->next);
if (ins->next->next->next)
NULLIFY_INS (ins->next->next->next);
return;
}
if (!ins->next->next->next || ins->next->next->next->opcode != OP_BR_REG) {
/* A one-way switch which got optimized away */
if (G_UNLIKELY (cfg->verbose_level > 1)) {
printf ("\tNo cfold on ");
mono_print_ins (ins);
}
return;
}
if (G_UNLIKELY (cfg->verbose_level > 1)) {
printf ("\tcfold on ");
mono_print_ins (ins);
}
/* Unlink target bblocks */
for (i = 0; i < table->table_size; ++i) {
if (table->table [i] != table->table [idx]) {
remove_bb_from_phis (cfg, bb, table->table [i]);
mono_unlink_bblock (cfg, bb, table->table [i]);
}
}
/* Change the OP_BR_REG to a simple branch */
ins->next->next->next->opcode = OP_BR;
ins->next->next->next->inst_target_bb = table->table [idx];
ins->next->next->next->sreg1 = -1;
/* Nullify the other instructions */
NULLIFY_INS (ins);
NULLIFY_INS (ins->next);
NULLIFY_INS (ins->next->next);
}
}
}
else if (MONO_IS_COND_BRANCH_OP (ins)) {
if (ins->flags & MONO_INST_CFOLD_TAKEN) {
remove_bb_from_phis (cfg, bb, ins->inst_false_bb);
mono_unlink_bblock (cfg, bb, ins->inst_false_bb);
ins->opcode = OP_BR;
ins->inst_target_bb = ins->inst_true_bb;
} else if (ins->flags & MONO_INST_CFOLD_NOT_TAKEN) {
remove_bb_from_phis (cfg, bb, ins->inst_true_bb);
mono_unlink_bblock (cfg, bb, ins->inst_true_bb);
ins->opcode = OP_BR;
ins->inst_target_bb = ins->inst_false_bb;
}
}
}
void
mono_ssa_cprop (MonoCompile *cfg)
{
MonoInst **carray;
MonoBasicBlock *bb;
GList *bblock_list, *cvars;
GList *tmp;
int i;
//printf ("SIMPLE OPTS BB%d %s\n", bb->block_num, mono_method_full_name (cfg->method, TRUE));
carray = g_new0 (MonoInst*, cfg->next_vreg);
if (!(cfg->comp_done & MONO_COMP_SSA_DEF_USE))
mono_ssa_create_def_use (cfg);
bblock_list = g_list_prepend (NULL, cfg->bb_entry);
cfg->bb_entry->flags |= BB_REACHABLE;
memset (carray, 0, sizeof (MonoInst *) * cfg->num_varinfo);
for (i = 0; i < cfg->num_varinfo; i++) {
MonoMethodVar *info = MONO_VARINFO (cfg, i);
if (!info->def)
info->cpstate = 2;
}
for (bb = cfg->bb_entry->next_bb; bb; bb = bb->next_bb) {
/*
* FIXME: This should be bb->flags & BB_FLAG_EXCEPTION_HANDLER, but
* that would still allow unreachable try's to be removed.
*/
if (bb->region)
add_cprop_bb (cfg, bb, &bblock_list);
}
cvars = NULL;
while (bblock_list) {
MonoInst *inst;
bb = (MonoBasicBlock *)bblock_list->data;
bblock_list = g_list_delete_link (bblock_list, bblock_list);
g_assert (bb->flags & BB_REACHABLE);
/*
* Some bblocks are linked to 2 others even through they fall through to the
* next bblock.
*/
if (!(bb->last_ins && MONO_IS_BRANCH_OP (bb->last_ins))) {
for (i = 0; i < bb->out_count; ++i)
add_cprop_bb (cfg, bb->out_bb [i], &bblock_list);
}
if (cfg->verbose_level > 1)
printf ("\nSSA CONSPROP BB%d:\n", bb->block_num);
for (inst = bb->code; inst; inst = inst->next) {
visit_inst (cfg, bb, inst, &cvars, &bblock_list, carray);
}
while (cvars) {
MonoMethodVar *info = (MonoMethodVar *)cvars->data;
cvars = g_list_delete_link (cvars, cvars);
for (tmp = info->uses; tmp; tmp = tmp->next) {
MonoVarUsageInfo *ui = (MonoVarUsageInfo *)tmp->data;
if (!(ui->bb->flags & BB_REACHABLE))
continue;
visit_inst (cfg, ui->bb, ui->inst, &cvars, &bblock_list, carray);
}
}
}
for (bb = cfg->bb_entry->next_bb; bb; bb = bb->next_bb) {
MonoInst *inst;
for (inst = bb->code; inst; inst = inst->next) {
fold_ins (cfg, bb, inst, carray);
}
}
g_free (carray);
cfg->comp_done |= MONO_COMP_REACHABILITY;
/* fixme: we should update usage infos during cprop, instead of computing it again */
cfg->comp_done &= ~MONO_COMP_SSA_DEF_USE;
for (i = 0; i < cfg->num_varinfo; i++) {
MonoMethodVar *info = MONO_VARINFO (cfg, i);
info->def = NULL;
info->uses = NULL;
}
}
static inline void
add_to_dce_worklist (MonoCompile *cfg, MonoMethodVar *var, MonoMethodVar *use, GList **wl)
{
GList *tmp;
*wl = g_list_prepend_mempool (cfg->mempool, *wl, use);
for (tmp = use->uses; tmp; tmp = tmp->next) {
MonoVarUsageInfo *ui = (MonoVarUsageInfo *)tmp->data;
if (ui->inst == var->def) {
/* from the mempool */
use->uses = g_list_remove_link (use->uses, tmp);
break;
}
}
}
void
mono_ssa_deadce (MonoCompile *cfg)
{
int i;
GList *work_list;
g_assert (cfg->comp_done & MONO_COMP_SSA);
//printf ("DEADCE %s\n", mono_method_full_name (cfg->method, TRUE));
if (!(cfg->comp_done & MONO_COMP_SSA_DEF_USE))
mono_ssa_create_def_use (cfg);
mono_ssa_copyprop (cfg);
work_list = NULL;
for (i = 0; i < cfg->num_varinfo; i++) {
MonoMethodVar *info = MONO_VARINFO (cfg, i);
work_list = g_list_prepend_mempool (cfg->mempool, work_list, info);
}
while (work_list) {
MonoMethodVar *info = (MonoMethodVar *)work_list->data;
work_list = g_list_remove_link (work_list, work_list);
/*
* The second part of the condition happens often when PHI nodes have their dreg
* as one of their arguments due to the fact that we use the original vars.
*/
if (info->def && (!info->uses || ((info->uses->next == NULL) && (((MonoVarUsageInfo*)info->uses->data)->inst == info->def)))) {
MonoInst *def = info->def;
/* Eliminating FMOVE could screw up the fp stack */
if (MONO_IS_MOVE (def) && (!MONO_ARCH_USE_FPSTACK || (def->opcode != OP_FMOVE))) {
MonoInst *src_var = get_vreg_to_inst (cfg, def->sreg1);
if (src_var && !(src_var->flags & (MONO_INST_VOLATILE|MONO_INST_INDIRECT)))
add_to_dce_worklist (cfg, info, MONO_VARINFO (cfg, src_var->inst_c0), &work_list);
NULLIFY_INS (def);
info->reg = -1;
} else if ((def->opcode == OP_ICONST) || (def->opcode == OP_I8CONST) || MONO_IS_ZERO (def)) {
NULLIFY_INS (def);
info->reg = -1;
} else if (MONO_IS_PHI (def)) {
int j;
for (j = def->inst_phi_args [0]; j > 0; j--) {
MonoMethodVar *u = MONO_VARINFO (cfg, get_vreg_to_inst (cfg, def->inst_phi_args [j])->inst_c0);
add_to_dce_worklist (cfg, info, u, &work_list);
}
NULLIFY_INS (def);
info->reg = -1;
}
else if (def->opcode == OP_NOP) {
}
//else
//mono_print_ins (def);
}
}
}
#if 0
void
mono_ssa_strength_reduction (MonoCompile *cfg)
{
MonoBasicBlock *bb;
int i;
g_assert (cfg->comp_done & MONO_COMP_SSA);
g_assert (cfg->comp_done & MONO_COMP_LOOPS);
g_assert (cfg->comp_done & MONO_COMP_SSA_DEF_USE);
for (bb = cfg->bb_entry->next_bb; bb; bb = bb->next_bb) {
GList *lp = bb->loop_blocks;
if (lp) {
MonoBasicBlock *h = (MonoBasicBlock *)lp->data;
/* we only consider loops with 2 in bblocks */
if (!h->in_count == 2)
continue;
for (i = 0; i < cfg->num_varinfo; i++) {
MonoMethodVar *info = MONO_VARINFO (cfg, i);
if (info->def && info->def->ssa_op == MONO_SSA_STORE &&
info->def->inst_i0->opcode == OP_LOCAL && g_list_find (lp, info->def_bb)) {
MonoInst *v = info->def->inst_i1;
printf ("FOUND %d in %s\n", info->idx, mono_method_full_name (cfg->method, TRUE));
}
}
}
}
}
#endif
void
mono_ssa_loop_invariant_code_motion (MonoCompile *cfg)
{
MonoBasicBlock *bb, *h, *idom;
MonoInst *ins, *n, *tins;
int i;
g_assert (cfg->comp_done & MONO_COMP_SSA);
if (!(cfg->comp_done & MONO_COMP_LOOPS) || !(cfg->comp_done & MONO_COMP_SSA_DEF_USE))
return;
for (bb = cfg->bb_entry->next_bb; bb; bb = bb->next_bb) {
GList *lp = bb->loop_blocks;
if (!lp)
continue;
h = (MonoBasicBlock *)lp->data;
if (bb != h)
continue;
MONO_BB_FOR_EACH_INS_SAFE (bb, n, ins) {
/*
* Try to move instructions out of loop headers into the preceeding bblock.
*/
if (ins->opcode == OP_LDLEN || ins->opcode == OP_STRLEN || ins->opcode == OP_CHECK_THIS || ins->opcode == OP_AOTCONST || ins->opcode == OP_GENERIC_CLASS_INIT) {
gboolean skip;
int sreg;
idom = h->idom;
/*
* h->nesting is needed to work around:
* http://llvm.org/bugs/show_bug.cgi?id=17868
*/
if (!(idom && idom->last_ins && idom->last_ins->opcode == OP_BR && idom->last_ins->inst_target_bb == h && h->nesting == 1)) {
continue;
}
/*
* Make sure there are no instructions with side effects before ins.
*/
skip = FALSE;
MONO_BB_FOR_EACH_INS (bb, tins) {
if (tins == ins)
break;
if (!MONO_INS_HAS_NO_SIDE_EFFECT (tins)) {
skip = TRUE;
break;
}
}
if (skip) {
/*
printf ("%s\n", mono_method_full_name (cfg->method, TRUE));
mono_print_ins (tins);
*/
continue;
}
/* Make sure we don't move the instruction before the def of its sreg */
if (ins->opcode == OP_LDLEN || ins->opcode == OP_STRLEN || ins->opcode == OP_CHECK_THIS)
sreg = ins->sreg1;
else
sreg = -1;
if (sreg != -1) {
MonoInst *tins, *var;
skip = FALSE;
for (tins = ins->prev; tins; tins = tins->prev) {
const char *spec = INS_INFO (tins->opcode);
if (tins->opcode == OP_MOVE && tins->dreg == sreg) {
sreg = tins->sreg1;
} if (spec [MONO_INST_DEST] != ' ' && tins->dreg == sreg) {
skip = TRUE;
break;
}
}
if (skip)
continue;
var = get_vreg_to_inst (cfg, sreg);
if (var && (var->flags & (MONO_INST_VOLATILE|MONO_INST_INDIRECT)))
continue;
ins->sreg1 = sreg;
}
if (cfg->verbose_level > 1) {
printf ("licm in BB%d on ", bb->block_num);
mono_print_ins (ins);
}
//{ static int count = 0; count ++; printf ("%d\n", count); }
MONO_REMOVE_INS (bb, ins);
mono_bblock_insert_before_ins (idom, idom->last_ins, ins);
if (ins->opcode == OP_LDLEN || ins->opcode == OP_STRLEN)
idom->needs_decompose = TRUE;
}
}
}
cfg->comp_done &= ~MONO_COMP_SSA_DEF_USE;
for (i = 0; i < cfg->num_varinfo; i++) {
MonoMethodVar *info = MONO_VARINFO (cfg, i);
info->def = NULL;
info->uses = NULL;
}
}
#else /* !DISABLE_JIT */
MONO_EMPTY_SOURCE_FILE (ssa);
#endif /* !DISABLE_JIT */
|
447502.c | /**********************************************************************/
/* ____ ____ */
/* / /\/ / */
/* /___/ \ / */
/* \ \ \/ */
/* \ \ Copyright (c) 2003-2020 Xilinx, Inc. */
/* / / All Right Reserved. */
/* /---/ /\ */
/* \ \ / \ */
/* \___\/\___\ */
/**********************************************************************/
#if defined(_WIN32)
#include "stdio.h"
#define IKI_DLLESPEC __declspec(dllimport)
#else
#define IKI_DLLESPEC
#endif
#include "iki.h"
#include <string.h>
#include <math.h>
#ifdef __GNUC__
#include <stdlib.h>
#else
#include <malloc.h>
#define alloca _alloca
#endif
/**********************************************************************/
/* ____ ____ */
/* / /\/ / */
/* /___/ \ / */
/* \ \ \/ */
/* \ \ Copyright (c) 2003-2020 Xilinx, Inc. */
/* / / All Right Reserved. */
/* /---/ /\ */
/* \ \ / \ */
/* \___\/\___\ */
/**********************************************************************/
#if defined(_WIN32)
#include "stdio.h"
#define IKI_DLLESPEC __declspec(dllimport)
#else
#define IKI_DLLESPEC
#endif
#include "iki.h"
#include <string.h>
#include <math.h>
#ifdef __GNUC__
#include <stdlib.h>
#else
#include <malloc.h>
#define alloca _alloca
#endif
typedef void (*funcp)(char *, char *);
extern int main(int, char**);
IKI_DLLESPEC extern void execute_25(char*, char *);
IKI_DLLESPEC extern void execute_26(char*, char *);
IKI_DLLESPEC extern void execute_27(char*, char *);
IKI_DLLESPEC extern void execute_23(char*, char *);
IKI_DLLESPEC extern void execute_24(char*, char *);
IKI_DLLESPEC extern void transaction_0(char*, char*, unsigned, unsigned, unsigned);
IKI_DLLESPEC extern void vhdl_transfunc_eventcallback(char*, char*, unsigned, unsigned, unsigned, char *);
funcp funcTab[7] = {(funcp)execute_25, (funcp)execute_26, (funcp)execute_27, (funcp)execute_23, (funcp)execute_24, (funcp)transaction_0, (funcp)vhdl_transfunc_eventcallback};
const int NumRelocateId= 7;
void relocate(char *dp)
{
iki_relocate(dp, "xsim.dir/tb_cnt_up_down_behav/xsim.reloc", (void **)funcTab, 7);
iki_vhdl_file_variable_register(dp + 3088);
iki_vhdl_file_variable_register(dp + 3144);
/*Populate the transaction function pointer field in the whole net structure */
}
void sensitize(char *dp)
{
iki_sensitize(dp, "xsim.dir/tb_cnt_up_down_behav/xsim.reloc");
}
void simulate(char *dp)
{
iki_schedule_processes_at_time_zero(dp, "xsim.dir/tb_cnt_up_down_behav/xsim.reloc");
// Initialize Verilog nets in mixed simulation, for the cases when the value at time 0 should be propagated from the mixed language Vhdl net
iki_execute_processes();
// Schedule resolution functions for the multiply driven Verilog nets that have strength
// Schedule transaction functions for the singly driven Verilog nets that have strength
}
#include "iki_bridge.h"
void relocate(char *);
void sensitize(char *);
void simulate(char *);
extern SYSTEMCLIB_IMP_DLLSPEC void local_register_implicit_channel(int, char*);
extern SYSTEMCLIB_IMP_DLLSPEC int xsim_argc_copy ;
extern SYSTEMCLIB_IMP_DLLSPEC char** xsim_argv_copy ;
int main(int argc, char **argv)
{
iki_heap_initialize("ms", "isimmm", 0, 2147483648) ;
iki_set_sv_type_file_path_name("xsim.dir/tb_cnt_up_down_behav/xsim.svtype");
iki_set_crvs_dump_file_path_name("xsim.dir/tb_cnt_up_down_behav/xsim.crvsdump");
void* design_handle = iki_create_design("xsim.dir/tb_cnt_up_down_behav/xsim.mem", (void *)relocate, (void *)sensitize, (void *)simulate, (void*)0, 0, isimBridge_getWdbWriter(), 0, argc, argv);
iki_set_rc_trial_count(100);
(void) design_handle;
return iki_simulate_design();
}
|
322518.c | #include "global.h"
char username[30];
boolean logged;
boolean searchUser (TabStr X, char word[30]) {
/* Kamus Lokal */
int i, n;
boolean found, temp;
/* Algoritma */
found = false;
i = 0;
while ( ( i<X.NbElmt ) && (!found) ) {
temp = true;
n = 0;
if ( X.TI[i].Length == strlen(word) ) {
while ( ( n < X.TI[i].Length ) && (temp) ) {
if ( X.TI[i].TabKata[n] != word[n] ) {
n = X.TI[i].Length + 1;
temp = false;
}
//printf("%c", word[n]);
n++;
}
} else {
temp = false;
}
if ( temp ) {
found = true;
}
i++;
}
return found;
}
void makeFileUser(char word[30]) {
FILE *file_save;
char file_dir[90];
char file_fdir[40];
int i;
char *board;
/* Algoritma */
file_dir[0] = '\0';
i = 0;
for ( i = 0; i <= 9; i++ ) {
file_dir[0] = '\0';
strcat(file_dir, "../saves/board");
switch (i) {
case 0: board = "0"; break;
case 1: board = "1"; break;
case 2: board = "2"; break;
case 3: board = "3"; break;
case 4: board = "4"; break;
case 5: board = "5"; break;
case 6: board = "6"; break;
case 7: board = "7"; break;
case 8: board = "8"; break;
case 9: board = "9"; break;
default: board = "0";
}
strcat(file_dir, board);
strcat(file_dir, "/highscore/");
strcat(file_dir, word);
strcat(file_dir, ".txt");
file_save = fopen(file_dir, "w+");
fprintf(file_save, ".");
fclose(file_save);
}
for ( i = 0; i <= 9; i++ ) {
file_dir[0] = '\0';
strcat(file_dir, "../saves/board");
switch (i) {
case 0: board = "0"; break;
case 1: board = "1"; break;
case 2: board = "2"; break;
case 3: board = "3"; break;
case 4: board = "4"; break;
case 5: board = "5"; break;
case 6: board = "6"; break;
case 7: board = "7"; break;
case 8: board = "8"; break;
case 9: board = "9"; break;
default: board = "0";
}
strcat(file_dir, board);
strcat(file_dir, "/words/");
strcat(file_dir, word);
strcat(file_dir, ".txt");
file_save = fopen(file_dir, "w+");
fprintf(file_save, ".");
fclose(file_save);
}
}
boolean registerUser(char word[30]) {
/* Kamus Lokal */
FILE *file_save;
TabStr X;
X.NbElmt = 0;
char file_dir[90];
int i, n;
boolean granted;
/* Algoritma */
file_dir[0] = '\0';
strcat(file_dir, "../saves/userlist.txt");
STARTKATA(file_dir,"r",1);
i = 0;
n = 0;
while (!EndKata) {
for ( i = 1; i <= CKata.Length; i++ ) {
X.TI[n].TabKata[i-1] = CKata.TabKata[i];
}
X.TI[n].Length = CKata.Length;
X.NbElmt += 1;
n++;
ADVKATA(1);
}
// Check if the username is available
if ( !searchUser(X, word) ) {
granted = true;
} else {
granted = false;
}
if ( granted ) {
for ( n=0; n < strlen(word); n++ ) {
X.TI[X.NbElmt].TabKata[n] = word[n];
}
X.TI[X.NbElmt].TabKata[n] = '\0';
X.TI[X.NbElmt].Length = strlen(word);
X.NbElmt = X.NbElmt + 1;
file_save = fopen(file_dir, "w+");
for ( i=0 ; i < X.NbElmt; i++ ) {
for ( n = 0; n < X.TI[i].Length; n++ ) {
fprintf(file_save, "%c", X.TI[i].TabKata[n]);
}
fprintf(file_save, "\n");
}
fprintf(file_save, ".");
fclose(file_save);
makeFileUser(word);
return true;
} else {
return false;
}
}
boolean loginUser(char word[30]) {
/* Kamus Lokal */
TabStr X;
X.NbElmt = 0;
char file_dir[90];
int i, n;
boolean granted;
/* Algoritma */
file_dir[0] = '\0';
strcat(file_dir, "../saves/userlist.txt");
STARTKATA(file_dir,"r",1);
i = 0;
n = 0;
while (!EndKata) {
for ( i = 1; i <= CKata.Length; i++ ) {
X.TI[n].TabKata[i-1] = CKata.TabKata[i];
}
X.TI[n].Length = CKata.Length;
X.NbElmt += 1;
//printf("%s", X.TI[n].TabKata);
n++;
ADVKATA(1);
}
// Check if the username is available
if ( searchUser(X, word) ) {
granted = true;
} else {
granted = false;
}
if ( granted ) {
username[0] = '\0';
strcat(username, word);
logged = true;
return true;
} else {
return false;
}
}
void logoutUser() {
logged = false;
username[0] = '\0';
}
boolean cekUser(char word[30]) {
/* Kamus Lokal */
FILE *file_save;
TabStr X;
X.NbElmt = 0;
char file_dir[90];
int i, n;
boolean granted;
/* Algoritma */
file_dir[0] = '\0';
strcat(file_dir, "../saves/userlist.txt");
STARTKATA(file_dir,"r",1);
i = 0;
n = 0;
while (!EndKata) {
for ( i = 1; i <= CKata.Length; i++ ) {
X.TI[n].TabKata[i-1] = CKata.TabKata[i];
}
X.TI[n].Length = CKata.Length;
X.NbElmt += 1;
n++;
ADVKATA(1);
}
// Check if the username is available
if ( !searchUser(X, word) ) {
granted = true;
} else {
granted = false;
}
return granted;
}
|
183184.c | /*
Copyright 2007, UCAR/Unidata
See COPYRIGHT file for copying and redistribution conditions.
This program (quickly, but not thoroughly) tests the large file
features. It turns off fill mode to quickly create an 8 gb file, and
write one value is written, nothing is read.
@author Ed Hartnett
*/
#include <config.h>
#include <nc_tests.h>
#include <netcdf.h>
#include <stdio.h>
#include <string.h>
/* Size, in bytes, of a double. */
#define DOUBLE_SIZE 8
/* This is one megabyte (2^20), in decimal. */
#define MEGABYTE 1048576
/* This is the magic number for classic format limits: 2 GiB - 4
bytes. */
#define MAX_CLASSIC_BYTES 2147483644
/* This is the magic number for 64-bit offset format limits: 4 GiB - 4
bytes. */
#define MAX_64OFFSET_BYTES 4294967292
/* Handy for constucting tests. */
#define QTR_CLASSIC_MAX (MAX_CLASSIC_BYTES/4)
/* We will create this file. */
#define FILE_NAME "tst_large3.nc"
int
main(int argc, char **argv)
{
char file_name[NC_MAX_NAME + 1];
printf("\n*** Testing really large files in netCDF-4/HDF5 format, quickly.\n");
printf("*** Testing create of simple, but large, file...");
{
#define DIM_NAME "Time_in_nanoseconds"
#define NUMDIMS 1
#define NUMVARS 4
int ncid, dimids[NUMDIMS], varid[NUMVARS];
size_t chunksize[NUMDIMS];
char var_name[NUMVARS][NC_MAX_NAME + 1] = {"England", "Scotland", "Ireland", "Wales"};
size_t index[NUMDIMS] = {QTR_CLASSIC_MAX-1};
int ndims, nvars, natts, unlimdimid;
nc_type xtype;
char name_in[NC_MAX_NAME + 1];
size_t len;
double pi = 3.1459, pi_in;
int i;
/* Create a netCDF netCDF-4/HDF5 format file, with 4 vars. */
sprintf(file_name, "%s/%s", TEMP_LARGE, FILE_NAME);
if (nc_create(file_name, NC_NETCDF4, &ncid)) ERR;
if (nc_set_fill(ncid, NC_NOFILL, NULL)) ERR;
if (nc_def_dim(ncid, DIM_NAME, QTR_CLASSIC_MAX, dimids)) ERR;
chunksize[0] = MEGABYTE/DOUBLE_SIZE;
for (i = 0; i < NUMVARS; i++)
{
if (nc_def_var(ncid, var_name[i], NC_DOUBLE, NUMDIMS,
dimids, &varid[i])) ERR;
if (nc_def_var_chunking(ncid, i, 0, chunksize)) ERR;
}
if (nc_enddef(ncid)) ERR;
for (i = 0; i < NUMVARS; i++)
if (nc_put_var1_double(ncid, i, index, &pi)) ERR;
if (nc_close(ncid)) ERR;
/* Reopen and check the file. */
if (nc_open(file_name, 0, &ncid)) ERR;
if (nc_inq(ncid, &ndims, &nvars, &natts, &unlimdimid)) ERR;
if (ndims != NUMDIMS || nvars != NUMVARS || natts != 0 || unlimdimid != -1) ERR;
if (nc_inq_dimids(ncid, &ndims, dimids, 1)) ERR;
if (ndims != 1 || dimids[0] != 0) ERR;
if (nc_inq_dim(ncid, 0, name_in, &len)) ERR;
if (strcmp(name_in, DIM_NAME) || len != QTR_CLASSIC_MAX) ERR;
for (i = 0; i < NUMVARS; i++)
{
if (nc_inq_var(ncid, i, name_in, &xtype, &ndims, dimids, &natts)) ERR;
if (strcmp(name_in, var_name[i]) || xtype != NC_DOUBLE || ndims != 1 ||
dimids[0] != 0 || natts != 0) ERR;
if (nc_get_var1_double(ncid, i, index, &pi_in)) ERR;
if (pi_in != pi) ERR;
}
if (nc_close(ncid)) ERR;
}
SUMMARIZE_ERR;
FINAL_RESULTS;
}
|
877796.c | /**
******************************************************************************
* @file stm8s_it.c
* @author MCD Application Team
* @version V2.3.0
* @date 16-June-2017
* @brief Main Interrupt Service Routines.
* This file provides template for all peripherals interrupt service
* routine.
******************************************************************************
* @attention
*
* <h2><center>© COPYRIGHT 2014 STMicroelectronics</center></h2>
*
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.st.com/software_license_agreement_liberty_v2
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "stm8s_it.h"
/** @addtogroup Template_Project
* @{
*/
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/
/* Public functions ----------------------------------------------------------*/
#ifdef _COSMIC_
/**
* @brief Dummy Interrupt routine
* @par Parameters:
* None
* @retval
* None
*/
INTERRUPT_HANDLER(NonHandledInterrupt, 25)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
#endif /*_COSMIC_*/
/**
* @brief TRAP Interrupt routine
* @param None
* @retval None
*/
INTERRUPT_HANDLER_TRAP(TRAP_IRQHandler)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief Top Level Interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(TLI_IRQHandler, 0)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief Auto Wake Up Interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(AWU_IRQHandler, 1)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief Clock Controller Interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(CLK_IRQHandler, 2)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief External Interrupt PORTA Interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(EXTI_PORTA_IRQHandler, 3)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief External Interrupt PORTB Interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(EXTI_PORTB_IRQHandler, 4)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief External Interrupt PORTC Interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(EXTI_PORTC_IRQHandler, 5)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief External Interrupt PORTD Interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(EXTI_PORTD_IRQHandler, 6)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief External Interrupt PORTE Interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(EXTI_PORTE_IRQHandler, 7)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
#if defined (STM8S903) || defined (STM8AF622x)
/**
* @brief External Interrupt PORTF Interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(EXTI_PORTF_IRQHandler, 8)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
#endif /* (STM8S903) || (STM8AF622x) */
#if defined (STM8S208) || defined (STM8AF52Ax)
/**
* @brief CAN RX Interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(CAN_RX_IRQHandler, 8)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief CAN TX Interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(CAN_TX_IRQHandler, 9)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
#endif /* (STM8S208) || (STM8AF52Ax) */
/**
* @brief SPI Interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(SPI_IRQHandler, 10)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief Timer1 Update/Overflow/Trigger/Break Interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(TIM1_UPD_OVF_TRG_BRK_IRQHandler, 11)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief Timer1 Capture/Compare Interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(TIM1_CAP_COM_IRQHandler, 12)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
#if defined (STM8S903) || defined (STM8AF622x)
/**
* @brief Timer5 Update/Overflow/Break/Trigger Interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(TIM5_UPD_OVF_BRK_TRG_IRQHandler, 13)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief Timer5 Capture/Compare Interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(TIM5_CAP_COM_IRQHandler, 14)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
#else /* (STM8S208) || (STM8S207) || (STM8S105) || (STM8S103) || (STM8AF62Ax) || (STM8AF52Ax) || (STM8AF626x) */
/**
* @brief Timer2 Update/Overflow/Break Interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(TIM2_UPD_OVF_BRK_IRQHandler, 13)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief Timer2 Capture/Compare Interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(TIM2_CAP_COM_IRQHandler, 14)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
#endif /* (STM8S903) || (STM8AF622x) */
#if defined (STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S105) || \
defined(STM8S005) || defined (STM8AF62Ax) || defined (STM8AF52Ax) || defined (STM8AF626x)
/**
* @brief Timer3 Update/Overflow/Break Interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(TIM3_UPD_OVF_BRK_IRQHandler, 15)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief Timer3 Capture/Compare Interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(TIM3_CAP_COM_IRQHandler, 16)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
#endif /* (STM8S208) || (STM8S207) || (STM8S105) || (STM8AF62Ax) || (STM8AF52Ax) || (STM8AF626x) */
#if defined (STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S103) || \
defined (STM8S003) || defined(STM8S001) || defined (STM8AF62Ax) || defined (STM8AF52Ax) || defined (STM8S903)
/**
* @brief UART1 TX Interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(UART1_TX_IRQHandler, 17)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief UART1 RX Interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(UART1_RX_IRQHandler, 18)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
#endif /* (STM8S208) || (STM8S207) || (STM8S103) || (STM8S001) || (STM8S903) || (STM8AF62Ax) || (STM8AF52Ax) */
#if defined(STM8AF622x)
/**
* @brief UART4 TX Interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(UART4_TX_IRQHandler, 17)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief UART4 RX Interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(UART4_RX_IRQHandler, 18)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
#endif /* (STM8AF622x) */
/**
* @brief I2C Interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(I2C_IRQHandler, 19)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
#if defined(STM8S105) || defined(STM8S005) || defined (STM8AF626x)
/**
* @brief UART2 TX interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(UART2_TX_IRQHandler, 20)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief UART2 RX interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(UART2_RX_IRQHandler, 21)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
#endif /* (STM8S105) || (STM8AF626x) */
#if defined(STM8S207) || defined(STM8S007) || defined(STM8S208) || defined (STM8AF52Ax) || defined (STM8AF62Ax)
/**
* @brief UART3 TX interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(UART3_TX_IRQHandler, 20)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @brief UART3 RX interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(UART3_RX_IRQHandler, 21)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
#endif /* (STM8S208) || (STM8S207) || (STM8AF52Ax) || (STM8AF62Ax) */
#if defined(STM8S207) || defined(STM8S007) || defined(STM8S208) || defined (STM8AF52Ax) || defined (STM8AF62Ax)
/**
* @brief ADC2 interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(ADC2_IRQHandler, 22)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
#else /* STM8S105 or STM8S103 or STM8S903 or STM8AF626x or STM8AF622x */
/**
* @brief ADC1 interrupt routine.
* @par Parameters:
* None
* @retval
* None
*/
INTERRUPT_HANDLER(ADC1_IRQHandler, 22)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
#endif /* (STM8S208) || (STM8S207) || (STM8AF52Ax) || (STM8AF62Ax) */
#if defined (STM8S903) || defined (STM8AF622x)
/**
* @brief Timer6 Update/Overflow/Trigger Interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(TIM6_UPD_OVF_TRG_IRQHandler, 23)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
#else /* STM8S208 or STM8S207 or STM8S105 or STM8S103 or STM8AF52Ax or STM8AF62Ax or STM8AF626x */
/**
* @brief Timer4 Update/Overflow Interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(TIM4_UPD_OVF_IRQHandler, 23)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
#endif /* (STM8S903) || (STM8AF622x)*/
/**
* @brief Eeprom EEC Interrupt routine.
* @param None
* @retval None
*/
INTERRUPT_HANDLER(EEPROM_EEC_IRQHandler, 24)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
}
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
743772.c | /*
* Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* File: wcmd.c
*
* Purpose: Handles the management command interface functions
*
* Author: Lyndon Chen
*
* Date: May 8, 2003
*
* Functions:
* s_vProbeChannel - Active scan channel
* s_MgrMakeProbeRequest - Make ProbeRequest packet
* CommandTimer - Timer function to handle command
* s_bCommandComplete - Command Complete function
* bScheduleCommand - Push Command and wait Command Scheduler to do
* vCommandTimer- Command call back functions
* vCommandTimerWait- Call back timer
* s_bClearBSSID_SCAN- Clear BSSID_SCAN cmd in CMD Queue
*
* Revision History:
*
*/
#include "ttype.h"
#include "tmacro.h"
#include "device.h"
#include "mac.h"
#include "card.h"
#include "80211hdr.h"
#include "wcmd.h"
#include "wmgr.h"
#include "power.h"
#include "wctl.h"
#include "baseband.h"
#include "control.h"
#include "rxtx.h"
#include "rf.h"
#include "rndis.h"
#include "channel.h"
#include "iowpa.h"
/*--------------------- Static Definitions -------------------------*/
/*--------------------- Static Classes ----------------------------*/
/*--------------------- Static Variables --------------------------*/
static int msglevel =MSG_LEVEL_INFO;
//static int msglevel =MSG_LEVEL_DEBUG;
/*--------------------- Static Functions --------------------------*/
static
void
s_vProbeChannel(
PSDevice pDevice
);
static
PSTxMgmtPacket
s_MgrMakeProbeRequest(
PSDevice pDevice,
PSMgmtObject pMgmt,
PBYTE pScanBSSID,
PWLAN_IE_SSID pSSID,
PWLAN_IE_SUPP_RATES pCurrRates,
PWLAN_IE_SUPP_RATES pCurrExtSuppRates
);
static
BOOL
s_bCommandComplete (
PSDevice pDevice
);
static BOOL s_bClearBSSID_SCAN(void *hDeviceContext);
/*--------------------- Export Variables --------------------------*/
/*--------------------- Export Functions --------------------------*/
/*
* Description:
* Stop AdHoc beacon during scan process
*
* Parameters:
* In:
* pDevice - Pointer to the adapter
* Out:
* none
*
* Return Value: none
*
*/
static
void
vAdHocBeaconStop(PSDevice pDevice)
{
PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
BOOL bStop;
/*
* temporarily stop Beacon packet for AdHoc Server
* if all of the following coditions are met:
* (1) STA is in AdHoc mode
* (2) VT3253 is programmed as automatic Beacon Transmitting
* (3) One of the following conditions is met
* (3.1) AdHoc channel is in B/G band and the
* current scan channel is in A band
* or
* (3.2) AdHoc channel is in A mode
*/
bStop = FALSE;
if ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) &&
(pMgmt->eCurrState >= WMAC_STATE_STARTED))
{
if ((pMgmt->uIBSSChannel <= CB_MAX_CHANNEL_24G) &&
(pMgmt->uScanChannel > CB_MAX_CHANNEL_24G))
{
bStop = TRUE;
}
if (pMgmt->uIBSSChannel > CB_MAX_CHANNEL_24G)
{
bStop = TRUE;
}
}
if (bStop)
{
//PMESG(("STOP_BEACON: IBSSChannel = %u, ScanChannel = %u\n",
// pMgmt->uIBSSChannel, pMgmt->uScanChannel));
MACvRegBitsOff(pDevice, MAC_REG_TCR, TCR_AUTOBCNTX);
}
} /* vAdHocBeaconStop */
/*
* Description:
* Restart AdHoc beacon after scan process complete
*
* Parameters:
* In:
* pDevice - Pointer to the adapter
* Out:
* none
*
* Return Value: none
*
*/
static
void
vAdHocBeaconRestart(PSDevice pDevice)
{
PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
/*
* Restart Beacon packet for AdHoc Server
* if all of the following coditions are met:
* (1) STA is in AdHoc mode
* (2) VT3253 is programmed as automatic Beacon Transmitting
*/
if ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) &&
(pMgmt->eCurrState >= WMAC_STATE_STARTED))
{
//PMESG(("RESTART_BEACON\n"));
MACvRegBitsOn(pDevice, MAC_REG_TCR, TCR_AUTOBCNTX);
}
}
/*+
*
* Routine Description:
* Prepare and send probe request management frames.
*
*
* Return Value:
* none.
*
-*/
static
void
s_vProbeChannel(
PSDevice pDevice
)
{
//1M, 2M, 5M, 11M, 18M, 24M, 36M, 54M
BYTE abyCurrSuppRatesG[] = {WLAN_EID_SUPP_RATES, 8, 0x02, 0x04, 0x0B, 0x16, 0x24, 0x30, 0x48, 0x6C};
BYTE abyCurrExtSuppRatesG[] = {WLAN_EID_EXTSUPP_RATES, 4, 0x0C, 0x12, 0x18, 0x60};
//6M, 9M, 12M, 48M
BYTE abyCurrSuppRatesA[] = {WLAN_EID_SUPP_RATES, 8, 0x0C, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C};
BYTE abyCurrSuppRatesB[] = {WLAN_EID_SUPP_RATES, 4, 0x02, 0x04, 0x0B, 0x16};
PBYTE pbyRate;
PSTxMgmtPacket pTxPacket;
PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
unsigned int ii;
if (pDevice->byBBType == BB_TYPE_11A) {
pbyRate = &abyCurrSuppRatesA[0];
} else if (pDevice->byBBType == BB_TYPE_11B) {
pbyRate = &abyCurrSuppRatesB[0];
} else {
pbyRate = &abyCurrSuppRatesG[0];
}
// build an assocreq frame and send it
pTxPacket = s_MgrMakeProbeRequest
(
pDevice,
pMgmt,
pMgmt->abyScanBSSID,
(PWLAN_IE_SSID)pMgmt->abyScanSSID,
(PWLAN_IE_SUPP_RATES)pbyRate,
(PWLAN_IE_SUPP_RATES)abyCurrExtSuppRatesG
);
if (pTxPacket != NULL ){
for (ii = 0; ii < 1 ; ii++) {
if (csMgmt_xmit(pDevice, pTxPacket) != CMD_STATUS_PENDING) {
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Probe request sending fail.. \n");
}
else {
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Probe request is sending.. \n");
}
}
}
}
/*+
*
* Routine Description:
* Constructs an probe request frame
*
*
* Return Value:
* A ptr to Tx frame or NULL on allocation failue
*
-*/
PSTxMgmtPacket
s_MgrMakeProbeRequest(
PSDevice pDevice,
PSMgmtObject pMgmt,
PBYTE pScanBSSID,
PWLAN_IE_SSID pSSID,
PWLAN_IE_SUPP_RATES pCurrRates,
PWLAN_IE_SUPP_RATES pCurrExtSuppRates
)
{
PSTxMgmtPacket pTxPacket = NULL;
WLAN_FR_PROBEREQ sFrame;
pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool;
memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_PROBEREQ_FR_MAXLEN);
pTxPacket->p80211Header = (PUWLAN_80211HDR)((PBYTE)pTxPacket + sizeof(STxMgmtPacket));
sFrame.pBuf = (PBYTE)pTxPacket->p80211Header;
sFrame.len = WLAN_PROBEREQ_FR_MAXLEN;
vMgrEncodeProbeRequest(&sFrame);
sFrame.pHdr->sA3.wFrameCtl = cpu_to_le16(
(
WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR) |
WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_PROBEREQ)
));
memcpy( sFrame.pHdr->sA3.abyAddr1, pScanBSSID, WLAN_ADDR_LEN);
memcpy( sFrame.pHdr->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN);
memcpy( sFrame.pHdr->sA3.abyAddr3, pScanBSSID, WLAN_BSSID_LEN);
// Copy the SSID, pSSID->len=0 indicate broadcast SSID
sFrame.pSSID = (PWLAN_IE_SSID)(sFrame.pBuf + sFrame.len);
sFrame.len += pSSID->len + WLAN_IEHDR_LEN;
memcpy(sFrame.pSSID, pSSID, pSSID->len + WLAN_IEHDR_LEN);
sFrame.pSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len);
sFrame.len += pCurrRates->len + WLAN_IEHDR_LEN;
memcpy(sFrame.pSuppRates, pCurrRates, pCurrRates->len + WLAN_IEHDR_LEN);
// Copy the extension rate set
if (pDevice->byBBType == BB_TYPE_11G) {
sFrame.pExtSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len);
sFrame.len += pCurrExtSuppRates->len + WLAN_IEHDR_LEN;
memcpy(sFrame.pExtSuppRates, pCurrExtSuppRates, pCurrExtSuppRates->len + WLAN_IEHDR_LEN);
}
pTxPacket->cbMPDULen = sFrame.len;
pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN;
return pTxPacket;
}
void vCommandTimerWait(void *hDeviceContext, unsigned int MSecond)
{
PSDevice pDevice = (PSDevice)hDeviceContext;
init_timer(&pDevice->sTimerCommand);
pDevice->sTimerCommand.data = (unsigned long)pDevice;
pDevice->sTimerCommand.function = (TimerFunction)vRunCommand;
// RUN_AT :1 msec ~= (HZ/1024)
pDevice->sTimerCommand.expires = (unsigned int)RUN_AT((MSecond * HZ) >> 10);
add_timer(&pDevice->sTimerCommand);
return;
}
void vRunCommand(void *hDeviceContext)
{
PSDevice pDevice = (PSDevice)hDeviceContext;
PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
PWLAN_IE_SSID pItemSSID;
PWLAN_IE_SSID pItemSSIDCurr;
CMD_STATUS Status;
unsigned int ii;
BYTE byMask[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80};
struct sk_buff *skb;
BYTE byData;
if (pDevice->dwDiagRefCount != 0)
return;
if (pDevice->bCmdRunning != TRUE)
return;
spin_lock_irq(&pDevice->lock);
switch ( pDevice->eCommandState ) {
case WLAN_CMD_SCAN_START:
pDevice->byReAssocCount = 0;
if (pDevice->bRadioOff == TRUE) {
s_bCommandComplete(pDevice);
spin_unlock_irq(&pDevice->lock);
return;
}
if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) {
s_bCommandComplete(pDevice);
spin_unlock_irq(&pDevice->lock);
return;
}
pItemSSID = (PWLAN_IE_SSID)pMgmt->abyScanSSID;
if (pMgmt->uScanChannel == 0 ) {
pMgmt->uScanChannel = pDevice->byMinChannel;
}
if (pMgmt->uScanChannel > pDevice->byMaxChannel) {
pMgmt->eScanState = WMAC_NO_SCANNING;
if (pDevice->byBBType != pDevice->byScanBBType) {
pDevice->byBBType = pDevice->byScanBBType;
CARDvSetBSSMode(pDevice);
}
if (pDevice->bUpdateBBVGA) {
BBvSetShortSlotTime(pDevice);
BBvSetVGAGainOffset(pDevice, pDevice->byBBVGACurrent);
BBvUpdatePreEDThreshold(pDevice, FALSE);
}
// Set channel back
vAdHocBeaconRestart(pDevice);
// Set channel back
CARDbSetMediaChannel(pDevice, pMgmt->uCurrChannel);
// Set Filter
if (pMgmt->bCurrBSSIDFilterOn) {
MACvRegBitsOn(pDevice, MAC_REG_RCR, RCR_BSSID);
pDevice->byRxMode |= RCR_BSSID;
}
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Scanning, set back to channel: [%d]\n", pMgmt->uCurrChannel);
pDevice->bStopDataPkt = FALSE;
s_bCommandComplete(pDevice);
spin_unlock_irq(&pDevice->lock);
return;
} else {
if (!ChannelValid(pDevice->byZoneType, pMgmt->uScanChannel)) {
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Invalid channel pMgmt->uScanChannel = %d \n",pMgmt->uScanChannel);
s_bCommandComplete(pDevice);
spin_unlock_irq(&pDevice->lock);
return;
}
if (pMgmt->uScanChannel == pDevice->byMinChannel) {
// pMgmt->eScanType = WMAC_SCAN_ACTIVE; //mike mark
pMgmt->abyScanBSSID[0] = 0xFF;
pMgmt->abyScanBSSID[1] = 0xFF;
pMgmt->abyScanBSSID[2] = 0xFF;
pMgmt->abyScanBSSID[3] = 0xFF;
pMgmt->abyScanBSSID[4] = 0xFF;
pMgmt->abyScanBSSID[5] = 0xFF;
pItemSSID->byElementID = WLAN_EID_SSID;
// clear bssid list
/* BSSvClearBSSList((void *) pDevice,
pDevice->bLinkPass); */
pMgmt->eScanState = WMAC_IS_SCANNING;
pDevice->byScanBBType = pDevice->byBBType; //lucas
pDevice->bStopDataPkt = TRUE;
// Turn off RCR_BSSID filter everytime
MACvRegBitsOff(pDevice, MAC_REG_RCR, RCR_BSSID);
pDevice->byRxMode &= ~RCR_BSSID;
}
//lucas
vAdHocBeaconStop(pDevice);
if ((pDevice->byBBType != BB_TYPE_11A) && (pMgmt->uScanChannel > CB_MAX_CHANNEL_24G)) {
pDevice->byBBType = BB_TYPE_11A;
CARDvSetBSSMode(pDevice);
}
else if ((pDevice->byBBType == BB_TYPE_11A) && (pMgmt->uScanChannel <= CB_MAX_CHANNEL_24G)) {
pDevice->byBBType = BB_TYPE_11G;
CARDvSetBSSMode(pDevice);
}
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Scanning.... channel: [%d]\n", pMgmt->uScanChannel);
// Set channel
CARDbSetMediaChannel(pDevice, pMgmt->uScanChannel);
// Set Baseband to be more sensitive.
if (pDevice->bUpdateBBVGA) {
BBvSetShortSlotTime(pDevice);
BBvSetVGAGainOffset(pDevice, pDevice->abyBBVGA[0]);
BBvUpdatePreEDThreshold(pDevice, TRUE);
}
pMgmt->uScanChannel++;
while (!ChannelValid(pDevice->byZoneType, pMgmt->uScanChannel) &&
pMgmt->uScanChannel <= pDevice->byMaxChannel ){
pMgmt->uScanChannel++;
}
if (pMgmt->uScanChannel > pDevice->byMaxChannel) {
// Set Baseband to be not sensitive and rescan
pDevice->eCommandState = WLAN_CMD_SCAN_END;
}
if ((pMgmt->b11hEnable == FALSE) ||
(pMgmt->uScanChannel < CB_MAX_CHANNEL_24G)) {
s_vProbeChannel(pDevice);
spin_unlock_irq(&pDevice->lock);
vCommandTimerWait((void *) pDevice, 100);
return;
} else {
spin_unlock_irq(&pDevice->lock);
vCommandTimerWait((void *) pDevice, WCMD_PASSIVE_SCAN_TIME);
return;
}
}
break;
case WLAN_CMD_SCAN_END:
// Set Baseband's sensitivity back.
if (pDevice->byBBType != pDevice->byScanBBType) {
pDevice->byBBType = pDevice->byScanBBType;
CARDvSetBSSMode(pDevice);
}
if (pDevice->bUpdateBBVGA) {
BBvSetShortSlotTime(pDevice);
BBvSetVGAGainOffset(pDevice, pDevice->byBBVGACurrent);
BBvUpdatePreEDThreshold(pDevice, FALSE);
}
// Set channel back
vAdHocBeaconRestart(pDevice);
// Set channel back
CARDbSetMediaChannel(pDevice, pMgmt->uCurrChannel);
// Set Filter
if (pMgmt->bCurrBSSIDFilterOn) {
MACvRegBitsOn(pDevice, MAC_REG_RCR, RCR_BSSID);
pDevice->byRxMode |= RCR_BSSID;
}
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Scanning, set back to channel: [%d]\n", pMgmt->uCurrChannel);
pMgmt->eScanState = WMAC_NO_SCANNING;
pDevice->bStopDataPkt = FALSE;
//2008-0409-07, <Add> by Einsn Liu
#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
if(pMgmt->eScanType == WMAC_SCAN_PASSIVE)
{
//send scan event to wpa_Supplicant
union iwreq_data wrqu;
PRINT_K("wireless_send_event--->SIOCGIWSCAN(scan done)\n");
memset(&wrqu, 0, sizeof(wrqu));
wireless_send_event(pDevice->dev, SIOCGIWSCAN, &wrqu, NULL);
}
#endif
s_bCommandComplete(pDevice);
break;
case WLAN_CMD_DISASSOCIATE_START :
pDevice->byReAssocCount = 0;
if ((pMgmt->eCurrMode == WMAC_MODE_ESS_STA) &&
(pMgmt->eCurrState != WMAC_STATE_ASSOC)) {
s_bCommandComplete(pDevice);
spin_unlock_irq(&pDevice->lock);
return;
} else {
#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
pDevice->bwextstep0 = FALSE;
pDevice->bwextstep1 = FALSE;
pDevice->bwextstep2 = FALSE;
pDevice->bwextstep3 = FALSE;
pDevice->bWPASuppWextEnabled = FALSE;
#endif
pDevice->fWPA_Authened = FALSE;
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Send Disassociation Packet..\n");
// reason = 8 : disassoc because sta has left
vMgrDisassocBeginSta((void *) pDevice,
pMgmt,
pMgmt->abyCurrBSSID,
(8),
&Status);
pDevice->bLinkPass = FALSE;
ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_SLOW);
// unlock command busy
pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID;
pItemSSID->len = 0;
memset(pItemSSID->abySSID, 0, WLAN_SSID_MAXLEN);
pMgmt->eCurrState = WMAC_STATE_IDLE;
pMgmt->sNodeDBTable[0].bActive = FALSE;
// pDevice->bBeaconBufReady = FALSE;
}
netif_stop_queue(pDevice->dev);
if (pDevice->bNeedRadioOFF == TRUE)
CARDbRadioPowerOff(pDevice);
s_bCommandComplete(pDevice);
break;
case WLAN_CMD_SSID_START:
pDevice->byReAssocCount = 0;
if (pDevice->bRadioOff == TRUE) {
s_bCommandComplete(pDevice);
spin_unlock_irq(&pDevice->lock);
return;
}
memcpy(pMgmt->abyAdHocSSID,pMgmt->abyDesireSSID,
((PWLAN_IE_SSID)pMgmt->abyDesireSSID)->len + WLAN_IEHDR_LEN);
pItemSSID = (PWLAN_IE_SSID)pMgmt->abyDesireSSID;
pItemSSIDCurr = (PWLAN_IE_SSID)pMgmt->abyCurrSSID;
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" cmd: desire ssid = %s\n", pItemSSID->abySSID);
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" cmd: curr ssid = %s\n", pItemSSIDCurr->abySSID);
if (pMgmt->eCurrState == WMAC_STATE_ASSOC) {
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" Cmd pMgmt->eCurrState == WMAC_STATE_ASSOC\n");
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pItemSSID->len =%d\n",pItemSSID->len);
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pItemSSIDCurr->len = %d\n",pItemSSIDCurr->len);
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" desire ssid = %s\n", pItemSSID->abySSID);
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" curr ssid = %s\n", pItemSSIDCurr->abySSID);
}
if ((pMgmt->eCurrState == WMAC_STATE_ASSOC) ||
((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA)&& (pMgmt->eCurrState == WMAC_STATE_JOINTED))) {
if (pItemSSID->len == pItemSSIDCurr->len) {
if (memcmp(pItemSSID->abySSID, pItemSSIDCurr->abySSID, pItemSSID->len) == 0) {
s_bCommandComplete(pDevice);
spin_unlock_irq(&pDevice->lock);
return;
}
}
netif_stop_queue(pDevice->dev);
pDevice->bLinkPass = FALSE;
ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_SLOW);
}
// set initial state
pMgmt->eCurrState = WMAC_STATE_IDLE;
pMgmt->eCurrMode = WMAC_MODE_STANDBY;
PSvDisablePowerSaving((void *) pDevice);
BSSvClearNodeDBTable(pDevice, 0);
vMgrJoinBSSBegin((void *) pDevice, &Status);
// if Infra mode
if ((pMgmt->eCurrMode == WMAC_MODE_ESS_STA) && (pMgmt->eCurrState == WMAC_STATE_JOINTED)) {
// Call mgr to begin the deauthentication
// reason = (3) beacuse sta has left ESS
if (pMgmt->eCurrState >= WMAC_STATE_AUTH) {
vMgrDeAuthenBeginSta((void *)pDevice,
pMgmt,
pMgmt->abyCurrBSSID,
(3),
&Status);
}
// Call mgr to begin the authentication
vMgrAuthenBeginSta((void *) pDevice, pMgmt, &Status);
if (Status == CMD_STATUS_SUCCESS) {
pDevice->byLinkWaitCount = 0;
pDevice->eCommandState = WLAN_AUTHENTICATE_WAIT;
vCommandTimerWait((void *) pDevice, AUTHENTICATE_TIMEOUT);
spin_unlock_irq(&pDevice->lock);
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" Set eCommandState = WLAN_AUTHENTICATE_WAIT\n");
return;
}
}
// if Adhoc mode
else if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) {
if (pMgmt->eCurrState == WMAC_STATE_JOINTED) {
if (netif_queue_stopped(pDevice->dev)){
netif_wake_queue(pDevice->dev);
}
pDevice->bLinkPass = TRUE;
ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_INTER);
pMgmt->sNodeDBTable[0].bActive = TRUE;
pMgmt->sNodeDBTable[0].uInActiveCount = 0;
}
else {
// start own IBSS
DBG_PRT(MSG_LEVEL_DEBUG,
KERN_INFO "CreateOwn IBSS by CurrMode = IBSS_STA\n");
vMgrCreateOwnIBSS((void *) pDevice, &Status);
if (Status != CMD_STATUS_SUCCESS){
DBG_PRT(MSG_LEVEL_DEBUG,
KERN_INFO "WLAN_CMD_IBSS_CREATE fail!\n");
};
BSSvAddMulticastNode(pDevice);
}
s_bClearBSSID_SCAN(pDevice);
}
// if SSID not found
else if (pMgmt->eCurrMode == WMAC_MODE_STANDBY) {
if (pMgmt->eConfigMode == WMAC_CONFIG_IBSS_STA ||
pMgmt->eConfigMode == WMAC_CONFIG_AUTO) {
// start own IBSS
DBG_PRT(MSG_LEVEL_DEBUG,
KERN_INFO "CreateOwn IBSS by CurrMode = STANDBY\n");
vMgrCreateOwnIBSS((void *) pDevice, &Status);
if (Status != CMD_STATUS_SUCCESS){
DBG_PRT(MSG_LEVEL_DEBUG,
KERN_INFO "WLAN_CMD_IBSS_CREATE fail!\n");
};
BSSvAddMulticastNode(pDevice);
s_bClearBSSID_SCAN(pDevice);
/*
pDevice->bLinkPass = TRUE;
ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_INTER);
if (netif_queue_stopped(pDevice->dev)){
netif_wake_queue(pDevice->dev);
}
s_bClearBSSID_SCAN(pDevice);
*/
}
else {
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disconnect SSID none\n");
#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
// if(pDevice->bWPASuppWextEnabled == TRUE)
{
union iwreq_data wrqu;
memset(&wrqu, 0, sizeof (wrqu));
wrqu.ap_addr.sa_family = ARPHRD_ETHER;
PRINT_K("wireless_send_event--->SIOCGIWAP(disassociated:vMgrJoinBSSBegin Fail !!)\n");
wireless_send_event(pDevice->dev, SIOCGIWAP, &wrqu, NULL);
}
#endif
}
}
s_bCommandComplete(pDevice);
break;
case WLAN_AUTHENTICATE_WAIT :
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCommandState == WLAN_AUTHENTICATE_WAIT\n");
if (pMgmt->eCurrState == WMAC_STATE_AUTH) {
pDevice->byLinkWaitCount = 0;
// Call mgr to begin the association
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCurrState == WMAC_STATE_AUTH\n");
vMgrAssocBeginSta((void *) pDevice, pMgmt, &Status);
if (Status == CMD_STATUS_SUCCESS) {
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCommandState = WLAN_ASSOCIATE_WAIT\n");
pDevice->byLinkWaitCount = 0;
pDevice->eCommandState = WLAN_ASSOCIATE_WAIT;
vCommandTimerWait((void *) pDevice, ASSOCIATE_TIMEOUT);
spin_unlock_irq(&pDevice->lock);
return;
}
}
else if(pMgmt->eCurrState < WMAC_STATE_AUTHPENDING) {
printk("WLAN_AUTHENTICATE_WAIT:Authen Fail???\n");
}
else if(pDevice->byLinkWaitCount <= 4){ //mike add:wait another 2 sec if authenticated_frame delay!
pDevice->byLinkWaitCount ++;
printk("WLAN_AUTHENTICATE_WAIT:wait %d times!!\n",pDevice->byLinkWaitCount);
spin_unlock_irq(&pDevice->lock);
vCommandTimerWait((void *) pDevice, AUTHENTICATE_TIMEOUT/2);
return;
}
pDevice->byLinkWaitCount = 0;
s_bCommandComplete(pDevice);
break;
case WLAN_ASSOCIATE_WAIT :
if (pMgmt->eCurrState == WMAC_STATE_ASSOC) {
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCurrState == WMAC_STATE_ASSOC\n");
if (pDevice->ePSMode != WMAC_POWER_CAM) {
PSvEnablePowerSaving((void *) pDevice,
pMgmt->wListenInterval);
}
/*
if (pMgmt->eAuthenMode >= WMAC_AUTH_WPA) {
KeybRemoveAllKey(pDevice, &(pDevice->sKey), pDevice->abyBSSID);
}
*/
pDevice->byLinkWaitCount = 0;
pDevice->byReAssocCount = 0;
pDevice->bLinkPass = TRUE;
ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_INTER);
s_bClearBSSID_SCAN(pDevice);
if (netif_queue_stopped(pDevice->dev)){
netif_wake_queue(pDevice->dev);
}
if(pDevice->IsTxDataTrigger != FALSE) { //TxDataTimer is not triggered at the first time
// printk("Re-initial TxDataTimer****\n");
del_timer(&pDevice->sTimerTxData);
init_timer(&pDevice->sTimerTxData);
pDevice->sTimerTxData.data = (unsigned long) pDevice;
pDevice->sTimerTxData.function = (TimerFunction)BSSvSecondTxData;
pDevice->sTimerTxData.expires = RUN_AT(10*HZ); //10s callback
pDevice->fTxDataInSleep = FALSE;
pDevice->nTxDataTimeCout = 0;
}
else {
// printk("mike:-->First time triger TimerTxData InSleep\n");
}
pDevice->IsTxDataTrigger = TRUE;
add_timer(&pDevice->sTimerTxData);
}
else if(pMgmt->eCurrState < WMAC_STATE_ASSOCPENDING) {
printk("WLAN_ASSOCIATE_WAIT:Association Fail???\n");
}
else if(pDevice->byLinkWaitCount <= 4){ //mike add:wait another 2 sec if associated_frame delay!
pDevice->byLinkWaitCount ++;
printk("WLAN_ASSOCIATE_WAIT:wait %d times!!\n",pDevice->byLinkWaitCount);
spin_unlock_irq(&pDevice->lock);
vCommandTimerWait((void *) pDevice, ASSOCIATE_TIMEOUT/2);
return;
}
pDevice->byLinkWaitCount = 0;
s_bCommandComplete(pDevice);
break;
case WLAN_CMD_AP_MODE_START :
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCommandState == WLAN_CMD_AP_MODE_START\n");
if (pMgmt->eConfigMode == WMAC_CONFIG_AP) {
del_timer(&pMgmt->sTimerSecondCallback);
pMgmt->eCurrState = WMAC_STATE_IDLE;
pMgmt->eCurrMode = WMAC_MODE_STANDBY;
pDevice->bLinkPass = FALSE;
ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_SLOW);
if (pDevice->bEnableHostWEP == TRUE)
BSSvClearNodeDBTable(pDevice, 1);
else
BSSvClearNodeDBTable(pDevice, 0);
pDevice->uAssocCount = 0;
pMgmt->eCurrState = WMAC_STATE_IDLE;
pDevice->bFixRate = FALSE;
vMgrCreateOwnIBSS((void *) pDevice, &Status);
if (Status != CMD_STATUS_SUCCESS) {
DBG_PRT(MSG_LEVEL_DEBUG,
KERN_INFO "vMgrCreateOwnIBSS fail!\n");
};
// alway turn off unicast bit
MACvRegBitsOff(pDevice, MAC_REG_RCR, RCR_UNICAST);
pDevice->byRxMode &= ~RCR_UNICAST;
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "wcmd: rx_mode = %x\n", pDevice->byRxMode );
BSSvAddMulticastNode(pDevice);
if (netif_queue_stopped(pDevice->dev)){
netif_wake_queue(pDevice->dev);
}
pDevice->bLinkPass = TRUE;
ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_INTER);
add_timer(&pMgmt->sTimerSecondCallback);
}
s_bCommandComplete(pDevice);
break;
case WLAN_CMD_TX_PSPACKET_START :
// DTIM Multicast tx
if (pMgmt->sNodeDBTable[0].bRxPSPoll) {
while ((skb = skb_dequeue(&pMgmt->sNodeDBTable[0].sTxPSQueue)) != NULL) {
if (skb_queue_empty(&pMgmt->sNodeDBTable[0].sTxPSQueue)) {
pMgmt->abyPSTxMap[0] &= ~byMask[0];
pDevice->bMoreData = FALSE;
}
else {
pDevice->bMoreData = TRUE;
}
if (nsDMA_tx_packet(pDevice, TYPE_AC0DMA, skb) != 0) {
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Multicast ps tx fail \n");
}
pMgmt->sNodeDBTable[0].wEnQueueCnt--;
}
};
// PS nodes tx
for (ii = 1; ii < (MAX_NODE_NUM + 1); ii++) {
if (pMgmt->sNodeDBTable[ii].bActive &&
pMgmt->sNodeDBTable[ii].bRxPSPoll) {
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Index=%d Enqueu Cnt= %d\n",
ii, pMgmt->sNodeDBTable[ii].wEnQueueCnt);
while ((skb = skb_dequeue(&pMgmt->sNodeDBTable[ii].sTxPSQueue)) != NULL) {
if (skb_queue_empty(&pMgmt->sNodeDBTable[ii].sTxPSQueue)) {
// clear tx map
pMgmt->abyPSTxMap[pMgmt->sNodeDBTable[ii].wAID >> 3] &=
~byMask[pMgmt->sNodeDBTable[ii].wAID & 7];
pDevice->bMoreData = FALSE;
}
else {
pDevice->bMoreData = TRUE;
}
if (nsDMA_tx_packet(pDevice, TYPE_AC0DMA, skb) != 0) {
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "sta ps tx fail \n");
}
pMgmt->sNodeDBTable[ii].wEnQueueCnt--;
// check if sta ps enable, wait next pspoll
// if sta ps disable, send all pending buffers.
if (pMgmt->sNodeDBTable[ii].bPSEnable)
break;
}
if (skb_queue_empty(&pMgmt->sNodeDBTable[ii].sTxPSQueue)) {
// clear tx map
pMgmt->abyPSTxMap[pMgmt->sNodeDBTable[ii].wAID >> 3] &=
~byMask[pMgmt->sNodeDBTable[ii].wAID & 7];
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Index=%d PS queue clear \n", ii);
}
pMgmt->sNodeDBTable[ii].bRxPSPoll = FALSE;
}
}
s_bCommandComplete(pDevice);
break;
case WLAN_CMD_RADIO_START:
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCommandState == WLAN_CMD_RADIO_START\n");
// if (pDevice->bRadioCmd == TRUE)
// CARDbRadioPowerOn(pDevice);
// else
// CARDbRadioPowerOff(pDevice);
//2008-09-09<Add> BY Mike:Hot Key for Radio On/Off
{
int ntStatus = STATUS_SUCCESS;
BYTE byTmp;
ntStatus = CONTROLnsRequestIn(pDevice,
MESSAGE_TYPE_READ,
MAC_REG_GPIOCTL1,
MESSAGE_REQUEST_MACREG,
1,
&byTmp);
if ( ntStatus != STATUS_SUCCESS ) {
s_bCommandComplete(pDevice);
spin_unlock_irq(&pDevice->lock);
return;
}
if ( (byTmp & GPIO3_DATA) == 0 ) {
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" WLAN_CMD_RADIO_START_OFF........................\n");
// Old commands are useless.
// empty command Q
pDevice->cbFreeCmdQueue = CMD_Q_SIZE;
pDevice->uCmdDequeueIdx = 0;
pDevice->uCmdEnqueueIdx = 0;
//0415pDevice->bCmdRunning = FALSE;
pDevice->bCmdClear = TRUE;
pDevice->bStopTx0Pkt = FALSE;
pDevice->bStopDataPkt = TRUE;
pDevice->byKeyIndex = 0;
pDevice->bTransmitKey = FALSE;
spin_unlock_irq(&pDevice->lock);
KeyvInitTable(pDevice,&pDevice->sKey);
spin_lock_irq(&pDevice->lock);
pMgmt->byCSSPK = KEY_CTL_NONE;
pMgmt->byCSSGK = KEY_CTL_NONE;
if (pDevice->bLinkPass == TRUE) {
// reason = 8 : disassoc because sta has left
vMgrDisassocBeginSta((void *) pDevice,
pMgmt,
pMgmt->abyCurrBSSID,
(8),
&Status);
pDevice->bLinkPass = FALSE;
// unlock command busy
pMgmt->eCurrState = WMAC_STATE_IDLE;
pMgmt->sNodeDBTable[0].bActive = FALSE;
#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
// if(pDevice->bWPASuppWextEnabled == TRUE)
{
union iwreq_data wrqu;
memset(&wrqu, 0, sizeof (wrqu));
wrqu.ap_addr.sa_family = ARPHRD_ETHER;
PRINT_K("wireless_send_event--->SIOCGIWAP(disassociated)\n");
wireless_send_event(pDevice->dev, SIOCGIWAP, &wrqu, NULL);
}
#endif
}
#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
pDevice->bwextstep0 = FALSE;
pDevice->bwextstep1 = FALSE;
pDevice->bwextstep2 = FALSE;
pDevice->bwextstep3 = FALSE;
pDevice->bWPASuppWextEnabled = FALSE;
#endif
//clear current SSID
pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID;
pItemSSID->len = 0;
memset(pItemSSID->abySSID, 0, WLAN_SSID_MAXLEN);
//clear dessire SSID
pItemSSID = (PWLAN_IE_SSID)pMgmt->abyDesireSSID;
pItemSSID->len = 0;
memset(pItemSSID->abySSID, 0, WLAN_SSID_MAXLEN);
netif_stop_queue(pDevice->dev);
CARDbRadioPowerOff(pDevice);
MACvRegBitsOn(pDevice,MAC_REG_GPIOCTL1,GPIO3_INTMD);
ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_OFF);
pDevice->bHWRadioOff = TRUE;
} else {
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" WLAN_CMD_RADIO_START_ON........................\n");
pDevice->bHWRadioOff = FALSE;
CARDbRadioPowerOn(pDevice);
MACvRegBitsOff(pDevice,MAC_REG_GPIOCTL1,GPIO3_INTMD);
ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_ON);
}
}
s_bCommandComplete(pDevice);
break;
case WLAN_CMD_CHANGE_BBSENSITIVITY_START:
pDevice->bStopDataPkt = TRUE;
pDevice->byBBVGACurrent = pDevice->byBBVGANew;
BBvSetVGAGainOffset(pDevice, pDevice->byBBVGACurrent);
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Change sensitivity pDevice->byBBVGACurrent = %x\n", pDevice->byBBVGACurrent);
pDevice->bStopDataPkt = FALSE;
s_bCommandComplete(pDevice);
break;
case WLAN_CMD_TBTT_WAKEUP_START:
PSbIsNextTBTTWakeUp(pDevice);
s_bCommandComplete(pDevice);
break;
case WLAN_CMD_BECON_SEND_START:
bMgrPrepareBeaconToSend(pDevice, pMgmt);
s_bCommandComplete(pDevice);
break;
case WLAN_CMD_SETPOWER_START:
RFbSetPower(pDevice, pDevice->wCurrentRate, pMgmt->uCurrChannel);
s_bCommandComplete(pDevice);
break;
case WLAN_CMD_CHANGE_ANTENNA_START:
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Change from Antenna%d to", (int)pDevice->dwRxAntennaSel);
if ( pDevice->dwRxAntennaSel == 0) {
pDevice->dwRxAntennaSel=1;
if (pDevice->bTxRxAntInv == TRUE)
BBvSetAntennaMode(pDevice, ANT_RXA);
else
BBvSetAntennaMode(pDevice, ANT_RXB);
} else {
pDevice->dwRxAntennaSel=0;
if (pDevice->bTxRxAntInv == TRUE)
BBvSetAntennaMode(pDevice, ANT_RXB);
else
BBvSetAntennaMode(pDevice, ANT_RXA);
}
s_bCommandComplete(pDevice);
break;
case WLAN_CMD_REMOVE_ALLKEY_START:
KeybRemoveAllKey(pDevice, &(pDevice->sKey), pDevice->abyBSSID);
s_bCommandComplete(pDevice);
break;
case WLAN_CMD_MAC_DISPOWERSAVING_START:
ControlvReadByte (pDevice, MESSAGE_REQUEST_MACREG, MAC_REG_PSCTL, &byData);
if ( (byData & PSCTL_PS) != 0 ) {
// disable power saving hw function
CONTROLnsRequestOut(pDevice,
MESSAGE_TYPE_DISABLE_PS,
0,
0,
0,
NULL
);
}
s_bCommandComplete(pDevice);
break;
case WLAN_CMD_11H_CHSW_START:
CARDbSetMediaChannel(pDevice, pDevice->byNewChannel);
pDevice->bChannelSwitch = FALSE;
pMgmt->uCurrChannel = pDevice->byNewChannel;
pDevice->bStopDataPkt = FALSE;
s_bCommandComplete(pDevice);
break;
default:
s_bCommandComplete(pDevice);
break;
} //switch
spin_unlock_irq(&pDevice->lock);
return;
}
static
BOOL
s_bCommandComplete (
PSDevice pDevice
)
{
PWLAN_IE_SSID pSSID;
BOOL bRadioCmd = FALSE;
//WORD wDeAuthenReason = 0;
BOOL bForceSCAN = TRUE;
PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
pDevice->eCommandState = WLAN_CMD_IDLE;
if (pDevice->cbFreeCmdQueue == CMD_Q_SIZE) {
//Command Queue Empty
pDevice->bCmdRunning = FALSE;
return TRUE;
}
else {
pDevice->eCommand = pDevice->eCmdQueue[pDevice->uCmdDequeueIdx].eCmd;
pSSID = (PWLAN_IE_SSID)pDevice->eCmdQueue[pDevice->uCmdDequeueIdx].abyCmdDesireSSID;
bRadioCmd = pDevice->eCmdQueue[pDevice->uCmdDequeueIdx].bRadioCmd;
bForceSCAN = pDevice->eCmdQueue[pDevice->uCmdDequeueIdx].bForceSCAN;
ADD_ONE_WITH_WRAP_AROUND(pDevice->uCmdDequeueIdx, CMD_Q_SIZE);
pDevice->cbFreeCmdQueue++;
pDevice->bCmdRunning = TRUE;
switch ( pDevice->eCommand ) {
case WLAN_CMD_BSSID_SCAN:
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCommandState= WLAN_CMD_BSSID_SCAN\n");
pDevice->eCommandState = WLAN_CMD_SCAN_START;
pMgmt->uScanChannel = 0;
if (pSSID->len != 0) {
memcpy(pMgmt->abyScanSSID, pSSID, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
} else {
memset(pMgmt->abyScanSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
}
/*
if ((bForceSCAN == FALSE) && (pDevice->bLinkPass == TRUE)) {
if ((pSSID->len == ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->len) &&
( !memcmp(pSSID->abySSID, ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->abySSID, pSSID->len))) {
pDevice->eCommandState = WLAN_CMD_IDLE;
}
}
*/
break;
case WLAN_CMD_SSID:
pDevice->eCommandState = WLAN_CMD_SSID_START;
if (pSSID->len > WLAN_SSID_MAXLEN)
pSSID->len = WLAN_SSID_MAXLEN;
if (pSSID->len != 0)
memcpy(pMgmt->abyDesireSSID, pSSID, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"eCommandState= WLAN_CMD_SSID_START\n");
break;
case WLAN_CMD_DISASSOCIATE:
pDevice->eCommandState = WLAN_CMD_DISASSOCIATE_START;
break;
case WLAN_CMD_RX_PSPOLL:
pDevice->eCommandState = WLAN_CMD_TX_PSPACKET_START;
break;
case WLAN_CMD_RUN_AP:
pDevice->eCommandState = WLAN_CMD_AP_MODE_START;
break;
case WLAN_CMD_RADIO:
pDevice->eCommandState = WLAN_CMD_RADIO_START;
pDevice->bRadioCmd = bRadioCmd;
break;
case WLAN_CMD_CHANGE_BBSENSITIVITY:
pDevice->eCommandState = WLAN_CMD_CHANGE_BBSENSITIVITY_START;
break;
case WLAN_CMD_TBTT_WAKEUP:
pDevice->eCommandState = WLAN_CMD_TBTT_WAKEUP_START;
break;
case WLAN_CMD_BECON_SEND:
pDevice->eCommandState = WLAN_CMD_BECON_SEND_START;
break;
case WLAN_CMD_SETPOWER:
pDevice->eCommandState = WLAN_CMD_SETPOWER_START;
break;
case WLAN_CMD_CHANGE_ANTENNA:
pDevice->eCommandState = WLAN_CMD_CHANGE_ANTENNA_START;
break;
case WLAN_CMD_REMOVE_ALLKEY:
pDevice->eCommandState = WLAN_CMD_REMOVE_ALLKEY_START;
break;
case WLAN_CMD_MAC_DISPOWERSAVING:
pDevice->eCommandState = WLAN_CMD_MAC_DISPOWERSAVING_START;
break;
case WLAN_CMD_11H_CHSW:
pDevice->eCommandState = WLAN_CMD_11H_CHSW_START;
break;
default:
break;
}
vCommandTimerWait((void *) pDevice, 0);
}
return TRUE;
}
BOOL bScheduleCommand(void *hDeviceContext,
CMD_CODE eCommand,
PBYTE pbyItem0)
{
PSDevice pDevice = (PSDevice)hDeviceContext;
if (pDevice->cbFreeCmdQueue == 0) {
return (FALSE);
}
pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].eCmd = eCommand;
pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].bForceSCAN = TRUE;
memset(pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].abyCmdDesireSSID, 0 , WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
if (pbyItem0 != NULL) {
switch (eCommand) {
case WLAN_CMD_BSSID_SCAN:
pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].bForceSCAN = FALSE;
memcpy(pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].abyCmdDesireSSID,
pbyItem0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
break;
case WLAN_CMD_SSID:
memcpy(pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].abyCmdDesireSSID,
pbyItem0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
break;
case WLAN_CMD_DISASSOCIATE:
pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].bNeedRadioOFF = *((int *)pbyItem0);
break;
/*
case WLAN_CMD_DEAUTH:
pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].wDeAuthenReason = *((PWORD)pbyItem0);
break;
*/
case WLAN_CMD_RADIO:
pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].bRadioCmd = *((int *)pbyItem0);
break;
default:
break;
}
}
ADD_ONE_WITH_WRAP_AROUND(pDevice->uCmdEnqueueIdx, CMD_Q_SIZE);
pDevice->cbFreeCmdQueue--;
if (pDevice->bCmdRunning == FALSE) {
s_bCommandComplete(pDevice);
}
else {
}
return (TRUE);
}
/*
* Description:
* Clear BSSID_SCAN cmd in CMD Queue
*
* Parameters:
* In:
* hDeviceContext - Pointer to the adapter
* eCommand - Command
* Out:
* none
*
* Return Value: TRUE if success; otherwise FALSE
*
*/
static BOOL s_bClearBSSID_SCAN(void *hDeviceContext)
{
PSDevice pDevice = (PSDevice)hDeviceContext;
unsigned int uCmdDequeueIdx = pDevice->uCmdDequeueIdx;
unsigned int ii;
if ((pDevice->cbFreeCmdQueue < CMD_Q_SIZE) && (uCmdDequeueIdx != pDevice->uCmdEnqueueIdx)) {
for (ii = 0; ii < (CMD_Q_SIZE - pDevice->cbFreeCmdQueue); ii ++) {
if (pDevice->eCmdQueue[uCmdDequeueIdx].eCmd == WLAN_CMD_BSSID_SCAN)
pDevice->eCmdQueue[uCmdDequeueIdx].eCmd = WLAN_CMD_IDLE;
ADD_ONE_WITH_WRAP_AROUND(uCmdDequeueIdx, CMD_Q_SIZE);
if (uCmdDequeueIdx == pDevice->uCmdEnqueueIdx)
break;
}
}
return TRUE;
}
//mike add:reset command timer
void vResetCommandTimer(void *hDeviceContext)
{
PSDevice pDevice = (PSDevice)hDeviceContext;
//delete timer
del_timer(&pDevice->sTimerCommand);
//init timer
init_timer(&pDevice->sTimerCommand);
pDevice->sTimerCommand.data = (unsigned long)pDevice;
pDevice->sTimerCommand.function = (TimerFunction)vRunCommand;
pDevice->sTimerCommand.expires = RUN_AT(HZ);
pDevice->cbFreeCmdQueue = CMD_Q_SIZE;
pDevice->uCmdDequeueIdx = 0;
pDevice->uCmdEnqueueIdx = 0;
pDevice->eCommandState = WLAN_CMD_IDLE;
pDevice->bCmdRunning = FALSE;
pDevice->bCmdClear = FALSE;
}
void BSSvSecondTxData(void *hDeviceContext)
{
PSDevice pDevice = (PSDevice)hDeviceContext;
PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
pDevice->nTxDataTimeCout++;
if(pDevice->nTxDataTimeCout<4) //don't tx data if timer less than 40s
{
// printk("mike:%s-->no data Tx not exceed the desired Time as %d\n",__FUNCTION__,
// (int)pDevice->nTxDataTimeCout);
pDevice->sTimerTxData.expires = RUN_AT(10*HZ); //10s callback
add_timer(&pDevice->sTimerTxData);
return;
}
spin_lock_irq(&pDevice->lock);
//is wap_supplicant running successful OR only open && sharekey mode!
if(((pDevice->bLinkPass ==TRUE)&&(pMgmt->eAuthenMode < WMAC_AUTH_WPA)) || //open && sharekey linking
(pDevice->fWPA_Authened == TRUE)) { //wpa linking
// printk("mike:%s-->InSleep Tx Data Procedure\n",__FUNCTION__);
pDevice->fTxDataInSleep = TRUE;
PSbSendNullPacket(pDevice); //send null packet
pDevice->fTxDataInSleep = FALSE;
}
spin_unlock_irq(&pDevice->lock);
pDevice->sTimerTxData.expires = RUN_AT(10*HZ); //10s callback
add_timer(&pDevice->sTimerTxData);
return;
}
|
764034.c | /*
*
* Copyright 2015, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "server_credentials.h"
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <php.h>
#include <php_ini.h>
#include <ext/standard/info.h>
#include <ext/spl/spl_exceptions.h>
#include "php_grpc.h"
#include <zend_exceptions.h>
#include <zend_hash.h>
#include <grpc/grpc.h>
#include <grpc/grpc_security.h>
zend_class_entry *grpc_ce_server_credentials;
#if PHP_MAJOR_VERSION >= 7
static zend_object_handlers server_credentials_ce_handlers;
#endif
/* Frees and destroys an instace of wrapped_grpc_server_credentials */
PHP_GRPC_FREE_WRAPPED_FUNC_START(wrapped_grpc_server_credentials)
if (p->wrapped != NULL) {
grpc_server_credentials_release(p->wrapped);
}
PHP_GRPC_FREE_WRAPPED_FUNC_END()
/* Initializes an instace of wrapped_grpc_server_credentials to be
* associated with an object of a class specified by class_type */
php_grpc_zend_object create_wrapped_grpc_server_credentials(
zend_class_entry *class_type TSRMLS_DC) {
PHP_GRPC_ALLOC_CLASS_OBJECT(wrapped_grpc_server_credentials);
zend_object_std_init(&intern->std, class_type TSRMLS_CC);
object_properties_init(&intern->std, class_type);
PHP_GRPC_FREE_CLASS_OBJECT(wrapped_grpc_server_credentials,
server_credentials_ce_handlers);
}
zval *grpc_php_wrap_server_credentials(grpc_server_credentials
*wrapped TSRMLS_DC) {
zval *server_credentials_object;
PHP_GRPC_MAKE_STD_ZVAL(server_credentials_object);
object_init_ex(server_credentials_object, grpc_ce_server_credentials);
wrapped_grpc_server_credentials *server_credentials =
Z_WRAPPED_GRPC_SERVER_CREDS_P(server_credentials_object);
server_credentials->wrapped = wrapped;
return server_credentials_object;
}
/**
* Create SSL credentials.
* @param string pem_root_certs PEM encoding of the server root certificates
* @param string pem_private_key PEM encoding of the client's private key
* @param string pem_cert_chain PEM encoding of the client's certificate chain
* @return Credentials The new SSL credentials object
*/
PHP_METHOD(ServerCredentials, createSsl) {
char *pem_root_certs = 0;
grpc_ssl_pem_key_cert_pair pem_key_cert_pair;
php_grpc_int root_certs_length = 0;
php_grpc_int private_key_length;
php_grpc_int cert_chain_length;
/* "s!ss" == 1 nullable string, 2 strings */
/* TODO: support multiple key cert pairs. */
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s!ss", &pem_root_certs,
&root_certs_length, &pem_key_cert_pair.private_key,
&private_key_length, &pem_key_cert_pair.cert_chain,
&cert_chain_length) == FAILURE) {
zend_throw_exception(spl_ce_InvalidArgumentException,
"createSsl expects 3 strings", 1 TSRMLS_CC);
return;
}
/* TODO: add a client_certificate_request field in ServerCredentials and pass
* it as the last parameter. */
grpc_server_credentials *creds = grpc_ssl_server_credentials_create_ex(
pem_root_certs, &pem_key_cert_pair, 1,
GRPC_SSL_DONT_REQUEST_CLIENT_CERTIFICATE, NULL);
zval *creds_object = grpc_php_wrap_server_credentials(creds TSRMLS_CC);
RETURN_DESTROY_ZVAL(creds_object);
}
ZEND_BEGIN_ARG_INFO_EX(arginfo_createSsl, 0, 0, 3)
ZEND_ARG_INFO(0, pem_root_certs)
ZEND_ARG_INFO(0, pem_private_key)
ZEND_ARG_INFO(0, pem_cert_chain)
ZEND_END_ARG_INFO()
static zend_function_entry server_credentials_methods[] = {
PHP_ME(ServerCredentials, createSsl, arginfo_createSsl,
ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
PHP_FE_END
};
void grpc_init_server_credentials(TSRMLS_D) {
zend_class_entry ce;
INIT_CLASS_ENTRY(ce, "Grpc\\ServerCredentials", server_credentials_methods);
ce.create_object = create_wrapped_grpc_server_credentials;
grpc_ce_server_credentials = zend_register_internal_class(&ce TSRMLS_CC);
PHP_GRPC_INIT_HANDLER(wrapped_grpc_server_credentials,
server_credentials_ce_handlers);
}
|
53216.c | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* get_number_of_items.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: slisandr <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/01/28 22:43:34 by slisandr #+# #+# */
/* Updated: 2020/01/28 22:43:38 by slisandr ### ########.fr */
/* */
/* ************************************************************************** */
#include "fillit.h"
#define ERROR_CODE -1
int get_number_of_items(unsigned int square_side)
{
return (square_side * square_side);
}
|
524266.c | /* protFeat.c was originally generated by the autoSql program, which also
* generated protFeat.h and protFeat.sql. This module links the database and
* the RAM representation of objects. */
#include "common.h"
#include "linefile.h"
#include "dystring.h"
#include "jksql.h"
#include "protFeat.h"
static char const rcsid[] = "$Id: protFeat.c,v 1.1 2007/03/29 08:04:07 kent Exp $";
void protFeatStaticLoad(char **row, struct protFeat *ret)
/* Load a row from protFeat table into ret. The contents of ret will
* be replaced at the next call to this function. */
{
ret->protein = row[0];
ret->start = sqlSigned(row[1]);
ret->end = sqlSigned(row[2]);
ret->feature = row[3];
ret->score = sqlDouble(row[4]);
}
struct protFeat *protFeatLoad(char **row)
/* Load a protFeat from row fetched with select * from protFeat
* from database. Dispose of this with protFeatFree(). */
{
struct protFeat *ret;
AllocVar(ret);
ret->protein = cloneString(row[0]);
ret->start = sqlSigned(row[1]);
ret->end = sqlSigned(row[2]);
ret->feature = cloneString(row[3]);
ret->score = sqlDouble(row[4]);
return ret;
}
struct protFeat *protFeatLoadAll(char *fileName)
/* Load all protFeat from a whitespace-separated file.
* Dispose of this with protFeatFreeList(). */
{
struct protFeat *list = NULL, *el;
struct lineFile *lf = lineFileOpen(fileName, TRUE);
char *row[5];
while (lineFileRow(lf, row))
{
el = protFeatLoad(row);
slAddHead(&list, el);
}
lineFileClose(&lf);
slReverse(&list);
return list;
}
struct protFeat *protFeatLoadAllByChar(char *fileName, char chopper)
/* Load all protFeat from a chopper separated file.
* Dispose of this with protFeatFreeList(). */
{
struct protFeat *list = NULL, *el;
struct lineFile *lf = lineFileOpen(fileName, TRUE);
char *row[5];
while (lineFileNextCharRow(lf, chopper, row, ArraySize(row)))
{
el = protFeatLoad(row);
slAddHead(&list, el);
}
lineFileClose(&lf);
slReverse(&list);
return list;
}
struct protFeat *protFeatCommaIn(char **pS, struct protFeat *ret)
/* Create a protFeat out of a comma separated string.
* This will fill in ret if non-null, otherwise will
* return a new protFeat */
{
char *s = *pS;
if (ret == NULL)
AllocVar(ret);
ret->protein = sqlStringComma(&s);
ret->start = sqlSignedComma(&s);
ret->end = sqlSignedComma(&s);
ret->feature = sqlStringComma(&s);
ret->score = sqlDoubleComma(&s);
*pS = s;
return ret;
}
void protFeatFree(struct protFeat **pEl)
/* Free a single dynamically allocated protFeat such as created
* with protFeatLoad(). */
{
struct protFeat *el;
if ((el = *pEl) == NULL) return;
freeMem(el->protein);
freeMem(el->feature);
freez(pEl);
}
void protFeatFreeList(struct protFeat **pList)
/* Free a list of dynamically allocated protFeat's */
{
struct protFeat *el, *next;
for (el = *pList; el != NULL; el = next)
{
next = el->next;
protFeatFree(&el);
}
*pList = NULL;
}
void protFeatOutput(struct protFeat *el, FILE *f, char sep, char lastSep)
/* Print out protFeat. Separate fields with sep. Follow last field with lastSep. */
{
if (sep == ',') fputc('"',f);
fprintf(f, "%s", el->protein);
if (sep == ',') fputc('"',f);
fputc(sep,f);
fprintf(f, "%d", el->start);
fputc(sep,f);
fprintf(f, "%d", el->end);
fputc(sep,f);
if (sep == ',') fputc('"',f);
fprintf(f, "%s", el->feature);
if (sep == ',') fputc('"',f);
fputc(sep,f);
fprintf(f, "%g", el->score);
fputc(lastSep,f);
}
/* -------------------------------- End autoSql Generated Code -------------------------------- */
|
503520.c | /*
* main.c
*
* Created on: Dec 28, 2018
* Author: Vijay Katoch
*/
#include <string.h>
#include "appweb/appweb.h"
#include "app_i.h"
#include "httpUtil_i.h"
#define HTTP_STR_METHOD_GET "GET"
#define HTTP_STR_METHOD_POST "POST"
#define HTTP_STR_METHOD_PUT "PUT"
/********************************* Code *******************************/
/*
Run the handler. This is called when all input data has been received.
*/
static void readyRequest(HttpQueue *q)
{
HttpConn *conn;
conn = q->conn;
httpSetHeaderString(conn, "Custom-Date", conn->http->currentDate);
httpSetStatus(conn, 200);
/*
Generate some dynamic data. If you generate a lot, this will buffer up to a configured maximum.
If that limit is exceeded, the packet will be sent downstream and the response headers will be created.
*/
httpWrite(q, "Hello World from PiTank\n");
/*
Call finalize when the response to the client is complete. Call httpFlushOutput if the response is
incomplete and you wish to immediately send any buffered output.
*/
httpFinalize(conn);
}
static void incomingRequest(HttpQueue *q, HttpPacket *packet)
{
if (q->conn->error)
{
return;
}
const char* const HTTP_REQ_METHOD = q->conn->rx->method;
if (q->conn->rx->length > 0)
{
if (strcmp(HTTP_REQ_METHOD, HTTP_STR_METHOD_POST) == 0)
{
if (packet->content)
{
/*printf("POST Data in packet is %s\n", mprGetBufStart(packet->content));*/
POST_DATA pData;
getPostFormData(mprGetBufStart(packet->content), &pData);
handlePOSTRequest(&pData);
}
}
else if (strcmp(HTTP_REQ_METHOD, HTTP_STR_METHOD_PUT) == 0)
{
if (packet->content)
{
/*printf("PUT Data in packet is %s\n", mprGetBufStart(packet->content));*/
}
}
}
}
/*
Module load initialization. This is called when the module is first loaded.
*/
int httpRequestHandlerInit(Http *http, MprModule *module)
{
HttpStage *stage;
if ((stage = httpCreateHandler("requestHandler", module)) == 0) {
return MPR_ERR_CANT_CREATE;
}
stage->ready = readyRequest;
stage->incoming = incomingRequest;
/*
* Application Init
*/
app_init();
return 0;
}
|
896158.c | /*
Copyright 2011-2021 Daniel S. Buckstein
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
animal3D SDK: Minimal 3D Animation Framework
By Daniel S. Buckstein
a3_DemoState_idle-input.c/.cpp
Demo state function implementations.
****************************************************
*** THIS IS ONE OF YOUR DEMO'S MAIN SOURCE FILES ***
*** Implement your demo logic pertaining to ***
*** HANDLING INPUT in this file. ***
****************************************************
*/
//-----------------------------------------------------------------------------
#include "../a3_DemoState.h"
#include "../_a3_demo_utilities/a3_DemoMacros.h"
//-----------------------------------------------------------------------------
// INPUT SUB-ROUTINES
//-----------------------------------------------------------------------------
// CALLBACKS
// ascii key callback
void a3demo_input_keyCharPress(a3_DemoState* demoState, a3i32 const asciiKey)
{
switch (asciiKey)
{
// change pipeline mode
//a3demoCtrlCasesLoop(demoState->demoMode, demoState_mode_max, '>', '<');
//a3demoCtrlCasesLoop(demoState->demoMode, demoState_mode_max, '.', ',');
// toggle grid
a3demoCtrlCaseToggle(demoState->displayGrid, 'g');
// toggle skybox
a3demoCtrlCaseToggle(demoState->displaySkybox, 'b');
// toggle hidden volumes
a3demoCtrlCaseToggle(demoState->displayHiddenVolumes, 'h');
// toggle world axes
a3demoCtrlCaseToggle(demoState->displayWorldAxes, 'x');
// toggle object axes
a3demoCtrlCaseToggle(demoState->displayObjectAxes, 'z');
// toggle tangent bases on vertices or other
a3demoCtrlCaseToggle(demoState->displayTangentBases, 'B');
// toggle wireframe overlay
a3demoCtrlCaseToggle(demoState->displayWireframe, 'F');
// update animation
a3demoCtrlCaseToggle(demoState->updateAnimation, 'm');
// toggle stencil test
a3demoCtrlCaseToggle(demoState->stencilTest, 'i');
// toggle stencil test
a3demoCtrlCaseToggle(demoState->skipIntermediatePasses, 'I');
}
// update current mode pointer
//demoState->demoModeCallbacksPtr = demoState->demoModeCallbacks + demoState->demoMode;
// callbacks for current mode
//if (demoState->demoModeCallbacksPtr->handleKeyPress)
// demoState->demoModeCallbacksPtr->handleKeyPress(demoState,
// demoState->demoModeCallbacksPtr->demoMode, asciiKey, 0);
//if (demoState->demoModeCallbacksPtr->handleKeyHold)
// demoState->demoModeCallbacksPtr->handleKeyHold(demoState,
// demoState->demoModeCallbacksPtr->demoMode, asciiKey, 0);
}
// ascii key hold callback
void a3demo_input_keyCharHold(a3_DemoState* demoState, a3i32 asciiKey)
{
// switch (asciiKey)
// {
//
// }
// callback for current mode
//if (demoState->demoModeCallbacksPtr->handleKeyHold)
// demoState->demoModeCallbacksPtr->handleKeyHold(demoState,
// demoState->demoModeCallbacksPtr->demoMode, asciiKey, 0);
}
//-----------------------------------------------------------------------------
// INPUT
void a3demo_input(a3_DemoState* demoState, a3f64 const dt)
{
// callback for current mode
//if (demoState->demoModeCallbacksPtr->handleInput)
// demoState->demoModeCallbacksPtr->handleInput(demoState,
// demoState->demoModeCallbacksPtr->demoMode, dt);
}
//-----------------------------------------------------------------------------
|
74550.c | /* src/interfaces/ecpg/preproc/output.c */
#include "postgres_fe.h"
#include "extern.h"
static void output_escaped_str(char *cmd, bool quoted);
void
output_line_number(void)
{
char *line = hashline_number();
fprintf(base_yyout, "%s", line);
free(line);
}
void
output_simple_statement(char *stmt)
{
output_escaped_str(stmt, false);
output_line_number();
free(stmt);
}
/*
* store the whenever action here
*/
struct when when_error,
when_nf,
when_warn;
static void
print_action(struct when *w)
{
switch (w->code)
{
case W_SQLPRINT:
fprintf(base_yyout, "sqlprint();");
break;
case W_GOTO:
fprintf(base_yyout, "goto %s;", w->command);
break;
case W_DO:
fprintf(base_yyout, "%s;", w->command);
break;
case W_STOP:
fprintf(base_yyout, "exit (1);");
break;
case W_BREAK:
fprintf(base_yyout, "break;");
break;
case W_CONTINUE:
fprintf(base_yyout, "continue;");
break;
default:
fprintf(base_yyout, "{/* %d not implemented yet */}", w->code);
break;
}
}
void
whenever_action(int mode)
{
if ((mode & 1) == 1 && when_nf.code != W_NOTHING)
{
output_line_number();
fprintf(base_yyout, "\nif (sqlca.sqlcode == ECPG_NOT_FOUND) ");
print_action(&when_nf);
}
if (when_warn.code != W_NOTHING)
{
output_line_number();
fprintf(base_yyout, "\nif (sqlca.sqlwarn[0] == 'W') ");
print_action(&when_warn);
}
if (when_error.code != W_NOTHING)
{
output_line_number();
fprintf(base_yyout, "\nif (sqlca.sqlcode < 0) ");
print_action(&when_error);
}
if ((mode & 2) == 2)
fputc('}', base_yyout);
output_line_number();
}
char *
hashline_number(void)
{
/* do not print line numbers if we are in debug mode */
if (input_filename
#ifdef YYDEBUG
&& !base_yydebug
#endif
)
{
/* "* 2" here is for escaping '\' and '"' below */
char *line = mm_alloc(strlen("\n#line %d \"%s\"\n") + sizeof(int) * CHAR_BIT * 10 / 3 + strlen(input_filename) * 2);
char *src,
*dest;
sprintf(line, "\n#line %d \"", base_yylineno);
src = input_filename;
dest = line + strlen(line);
while (*src)
{
if (*src == '\\' || *src == '"')
*dest++ = '\\';
*dest++ = *src++;
}
*dest = '\0';
strcat(dest, "\"\n");
return line;
}
return EMPTY;
}
static char *ecpg_statement_type_name[] = {
"ECPGst_normal",
"ECPGst_execute",
"ECPGst_exec_immediate",
"ECPGst_prepnormal"
};
void
output_statement(char *stmt, int whenever_mode, enum ECPG_statement_type st)
{
fprintf(base_yyout, "{ ECPGdo(__LINE__, %d, %d, %s, %d, ", compat, force_indicator, connection ? connection : "NULL", questionmarks);
if (st == ECPGst_execute || st == ECPGst_exec_immediate)
{
fprintf(base_yyout, "%s, %s, ", ecpg_statement_type_name[st], stmt);
}
else
{
if (st == ECPGst_prepnormal && auto_prepare)
fputs("ECPGst_prepnormal, \"", base_yyout);
else
fputs("ECPGst_normal, \"", base_yyout);
output_escaped_str(stmt, false);
fputs("\", ", base_yyout);
}
/* dump variables to C file */
dump_variables(argsinsert, 1);
fputs("ECPGt_EOIT, ", base_yyout);
dump_variables(argsresult, 1);
fputs("ECPGt_EORT);", base_yyout);
reset_variables();
whenever_action(whenever_mode | 2);
free(stmt);
if (connection != NULL)
free(connection);
connection = NULL;
}
void
output_prepare_statement(char *name, char *stmt)
{
fprintf(base_yyout, "{ ECPGprepare(__LINE__, %s, %d, ", connection ? connection : "NULL", questionmarks);
output_escaped_str(name, true);
fputs(", ", base_yyout);
output_escaped_str(stmt, true);
fputs(");", base_yyout);
whenever_action(2);
free(name);
if (connection != NULL)
free(connection);
connection = NULL;
}
void
output_deallocate_prepare_statement(char *name)
{
const char *con = connection ? connection : "NULL";
if (strcmp(name, "all") != 0)
{
fprintf(base_yyout, "{ ECPGdeallocate(__LINE__, %d, %s, ", compat, con);
output_escaped_str(name, true);
fputs(");", base_yyout);
}
else
fprintf(base_yyout, "{ ECPGdeallocate_all(__LINE__, %d, %s);", compat, con);
whenever_action(2);
free(name);
if (connection != NULL)
free(connection);
connection = NULL;
}
static void
output_escaped_str(char *str, bool quoted)
{
int i = 0;
int len = strlen(str);
if (quoted && str[0] == '"' && str[len - 1] == '"') /* do not escape quotes
* at beginning and end
* if quoted string */
{
i = 1;
len--;
fputs("\"", base_yyout);
}
/* output this char by char as we have to filter " and \n */
for (; i < len; i++)
{
if (str[i] == '"')
fputs("\\\"", base_yyout);
else if (str[i] == '\n')
fputs("\\\n", base_yyout);
else if (str[i] == '\\')
{
int j = i;
/*
* check whether this is a continuation line if it is, do not
* output anything because newlines are escaped anyway
*/
/* accept blanks after the '\' as some other compilers do too */
do
{
j++;
} while (str[j] == ' ' || str[j] == '\t');
if ((str[j] != '\n') && (str[j] != '\r' || str[j + 1] != '\n')) /* not followed by a
* newline */
fputs("\\\\", base_yyout);
}
else if (str[i] == '\r' && str[i + 1] == '\n')
{
fputs("\\\r\n", base_yyout);
i++;
}
else
fputc(str[i], base_yyout);
}
if (quoted && str[0] == '"' && str[len] == '"')
fputs("\"", base_yyout);
}
|
144384.c | /* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE122_Heap_Based_Buffer_Overflow__c_CWE193_wchar_t_memcpy_15.c
Label Definition File: CWE122_Heap_Based_Buffer_Overflow__c_CWE193.label.xml
Template File: sources-sink-15.tmpl.c
*/
/*
* @description
* CWE: 122 Heap Based Buffer Overflow
* BadSource: Allocate memory for a string, but do not allocate space for NULL terminator
* GoodSource: Allocate enough memory for a string and the NULL terminator
* Sink: memcpy
* BadSink : Copy string to data using memcpy()
* Flow Variant: 15 Control flow: switch(6)
*
* */
#include "std_testcase.h"
#ifndef _WIN32
#include <wchar.h>
#endif
/* MAINTENANCE NOTE: The length of this string should equal the 10 */
#define SRC_STRING L"AAAAAAAAAA"
#ifndef OMITBAD
void CWE122_Heap_Based_Buffer_Overflow__c_CWE193_wchar_t_memcpy_15_bad()
{
wchar_t * data;
data = NULL;
switch(6)
{
case 6:
/* FLAW: Did not leave space for a null terminator */
data = (wchar_t *)malloc(10*sizeof(wchar_t));
if (data == NULL) {exit(-1);}
break;
default:
/* INCIDENTAL: CWE 561 Dead Code, the code below will never run */
printLine("Benign, fixed string");
break;
}
{
wchar_t source[10+1] = SRC_STRING;
/* Copy length + 1 to include NUL terminator from source */
/* POTENTIAL FLAW: data may not have enough space to hold source */
memcpy(data, source, (wcslen(source) + 1) * sizeof(wchar_t));
printWLine(data);
free(data);
}
}
#endif /* OMITBAD */
#ifndef OMITGOOD
/* goodG2B1() - use goodsource and badsink by changing the switch to switch(5) */
static void goodG2B1()
{
wchar_t * data;
data = NULL;
switch(5)
{
case 6:
/* INCIDENTAL: CWE 561 Dead Code, the code below will never run */
printLine("Benign, fixed string");
break;
default:
/* FIX: Allocate space for a null terminator */
data = (wchar_t *)malloc((10+1)*sizeof(wchar_t));
if (data == NULL) {exit(-1);}
break;
}
{
wchar_t source[10+1] = SRC_STRING;
/* Copy length + 1 to include NUL terminator from source */
/* POTENTIAL FLAW: data may not have enough space to hold source */
memcpy(data, source, (wcslen(source) + 1) * sizeof(wchar_t));
printWLine(data);
free(data);
}
}
/* goodG2B2() - use goodsource and badsink by reversing the blocks in the switch */
static void goodG2B2()
{
wchar_t * data;
data = NULL;
switch(6)
{
case 6:
/* FIX: Allocate space for a null terminator */
data = (wchar_t *)malloc((10+1)*sizeof(wchar_t));
if (data == NULL) {exit(-1);}
break;
default:
/* INCIDENTAL: CWE 561 Dead Code, the code below will never run */
printLine("Benign, fixed string");
break;
}
{
wchar_t source[10+1] = SRC_STRING;
/* Copy length + 1 to include NUL terminator from source */
/* POTENTIAL FLAW: data may not have enough space to hold source */
memcpy(data, source, (wcslen(source) + 1) * sizeof(wchar_t));
printWLine(data);
free(data);
}
}
void CWE122_Heap_Based_Buffer_Overflow__c_CWE193_wchar_t_memcpy_15_good()
{
goodG2B1();
goodG2B2();
}
#endif /* OMITGOOD */
/* Below is the main(). It is only used when building this testcase on
* its own for testing or for building a binary to use in testing binary
* analysis tools. It is not used when compiling all the testcases as one
* application, which is how source code analysis tools are tested.
*/
#ifdef INCLUDEMAIN
int main(int argc, char * argv[])
{
/* seed randomness */
srand( (unsigned)time(NULL) );
#ifndef OMITGOOD
printLine("Calling good()...");
CWE122_Heap_Based_Buffer_Overflow__c_CWE193_wchar_t_memcpy_15_good();
printLine("Finished good()");
#endif /* OMITGOOD */
#ifndef OMITBAD
printLine("Calling bad()...");
CWE122_Heap_Based_Buffer_Overflow__c_CWE193_wchar_t_memcpy_15_bad();
printLine("Finished bad()");
#endif /* OMITBAD */
return 0;
}
#endif
|
445851.c | /* $XFree86: xc/programs/Xserver/hw/xfree86/vga256/drivers/s3v/s3v_misc.c,v 1.1.2.3 1997/05/28 13:12:53 dawes Exp $ */
/*
*
* Copyright 1995-1997 The XFree86 Project, Inc.
*
*/
/*
* Various functions used in the virge driver.
* Right now, this only contains the PCI probing function.
*
* Created 18/03/97 by Sebastien Marineau
* Revision:
* [0.1] 18/03/97: Added PCI probe function, taken from accel/s3_virge server.
* Not sure if the code used to adjust the PCI base address is
* still needed for the ViRGE chipsets.
*/
#include "X.h"
#include "input.h"
#include "screenint.h"
#include "compiler.h"
#include "xf86.h"
#include "xf86Priv.h"
#include "xf86_OSlib.h"
#include "xf86_HWlib.h"
#include "xf86_PCI.h"
#include "vga.h"
#include "vgaPCI.h"
#ifdef XFreeXDGA
#include "X.h"
#include "Xproto.h"
#include "scrnintstr.h"
#include "servermd.h"
#define _XF86DGA_SERVER_
#include "extensions/xf86dgastr.h"
#endif
#define XCONFIG_FLAGS_ONLY
#include "xf86_Config.h"
#include "regs3v.h"
#include "s3v_driver.h"
extern SymTabRec s3vChipTable[];
extern S3VPRIV s3vPriv;
/*
* s3vGetPCIInfo -- probe for PCI information
*/
S3PCIInformation *
s3vGetPCIInfo()
{
static S3PCIInformation info = {0, };
pciConfigPtr pcrp, *pcrpp;
Bool found = FALSE;
int i = 0;
pcrpp = xf86scanpci(vga256InfoRec.scrnIndex);
if (!pcrpp)
return NULL;
while ((pcrp = pcrpp[i])) {
if (pcrp->_vendor == PCI_S3_VENDOR_ID) {
found = TRUE;
switch (pcrp->_device) {
case PCI_ViRGE:
info.ChipType = S3_ViRGE;
break;
case PCI_ViRGE_VX:
info.ChipType = S3_ViRGE_VX;
break;
case PCI_ViRGE_DXGX:
info.ChipType = S3_ViRGE_DXGX;
break;
default:
info.ChipType = S3_UNKNOWN;
info.DevID = pcrp->_device;
break;
}
info.ChipRev = pcrp->_rev_id;
info.MemBase = pcrp->_base0 & 0xFF800000;
break;
}
i++;
}
/* for new mmio we have to ensure that the PCI base address is
* 64MB aligned and that there are no address collitions within 64MB.
* S3 868/968 only pretend to need 32MB and thus fool
* the BIOS PCI auto configuration :-( */
if (info.ChipType == S3_ViRGE) {
unsigned long base0;
char *probed;
char map_64m[64];
int j;
if (vga256InfoRec.MemBase == 0) {
base0 = info.MemBase;
probed = XCONFIG_PROBED;
}
else {
base0 = vga256InfoRec.MemBase;
probed = XCONFIG_GIVEN;
}
/* map allocated 64MB blocks */
for (j=0; j<64; j++) map_64m[j] = 0;
map_64m[63] = 1; /* don't use the last 64MB area */
for (j=0; (pcrp = pcrpp[j]); j++) {
if (i != j) {
map_64m[ (pcrp->_base0 >> 26) & 0x3f] = 1;
map_64m[((pcrp->_base0+0x3ffffff) >> 26) & 0x3f] = 1;
map_64m[ (pcrp->_base1 >> 26) & 0x3f] = 1;
map_64m[((pcrp->_base1+0x3ffffff) >> 26) & 0x3f] = 1;
map_64m[ (pcrp->_base2 >> 26) & 0x3f] = 1;
map_64m[((pcrp->_base2+0x3ffffff) >> 26) & 0x3f] = 1;
map_64m[ (pcrp->_base3 >> 26) & 0x3f] = 1;
map_64m[((pcrp->_base3+0x3ffffff) >> 26) & 0x3f] = 1;
map_64m[ (pcrp->_base4 >> 26) & 0x3f] = 1;
map_64m[((pcrp->_base4+0x3ffffff) >> 26) & 0x3f] = 1;
map_64m[ (pcrp->_base5 >> 26) & 0x3f] = 1;
map_64m[((pcrp->_base5+0x3ffffff) >> 26) & 0x3f] = 1;
}
}
/* check for 64MB alignment and free space */
if ((base0 & 0x3ffffff) ||
map_64m[(base0 >> 26) & 0x3f] ||
map_64m[((base0+0x3ffffff) >> 26) & 0x3f]) {
for (j=63; j>=16 && map_64m[j]; j--);
info.MemBase = ((unsigned long)j) << 26;
ErrorF("%s %s: S3V: PCI base address not correctly aligned or address conflict\n",
probed, vga256InfoRec.name);
ErrorF("\t\tbase address changed from 0x%08lx to 0x%08lx\n",
base0, info.MemBase);
xf86writepci(vga256InfoRec.scrnIndex, pcrpp[i]->_bus, pcrpp[i]->_cardnum,
pcrpp[i]->_func, PCI_MAP_REG_START, ~0L,
info.MemBase | PCI_MAP_MEMORY | PCI_MAP_MEMORY_TYPE_32BIT);
}
}
else {
if (vga256InfoRec.MemBase != 0) {
/* Should we allow the user to specify this??? */
/* Guess this should be reenabled for VLB */
}
else {
}
}
/* Free PCI information */
xf86cleanpci();
if (found && xf86Verbose) {
if (info.ChipType != S3_UNKNOWN) {
ErrorF("%s %s: S3V: %s rev %x, Linear FB @ 0x%08lx\n", XCONFIG_PROBED,
vga256InfoRec.name,xf86TokenToString(s3vChipTable, info.ChipType),
info.ChipRev, info.MemBase);
}
}
if (found)
return &info;
else
return NULL;
}
|
323690.c | /****************************************************************************
* libs/libc/unistd/lib_gettid.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <sys/types.h>
#include <unistd.h>
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: gettid
*
* Description:
* Get the thread ID of the currently executing thread.
*
* Input parameters:
* None
*
* Returned Value:
* On success, returns the thread ID of the calling process.
*
****************************************************************************/
pid_t gettid(void)
{
return getpid();
}
|
784572.c | #include "packets.h"
size_t pkt_len(struct packet * pckt)
{
return HEADER_LEN + pckt->payload.len;
}
|
851358.c | /*-------------------------------------------------------------------------
*
* paramassign.c
* Functions for assigning PARAM_EXEC slots during planning.
*
* This module is responsible for managing three planner data structures:
*
* root->glob->paramExecTypes: records actual assignments of PARAM_EXEC slots.
* The i'th list element holds the data type OID of the i'th parameter slot.
* (Elements can be InvalidOid if they represent slots that are needed for
* chgParam signaling, but will never hold a value at runtime.) This list is
* global to the whole plan since the executor has only one PARAM_EXEC array.
* Assignments are permanent for the plan: we never remove entries once added.
*
* root->plan_params: a list of PlannerParamItem nodes, recording Vars and
* PlaceHolderVars that the root's query level needs to supply to lower-level
* subqueries, along with the PARAM_EXEC number to use for each such value.
* Elements are added to this list while planning a subquery, and the list
* is reset to empty after completion of each subquery.
*
* root->curOuterParams: a list of NestLoopParam nodes, recording Vars and
* PlaceHolderVars that some outer level of nestloop needs to pass down to
* a lower-level plan node in its righthand side. Elements are added to this
* list as createplan.c creates lower Plan nodes that need such Params, and
* are removed when it creates a NestLoop Plan node that will supply those
* values.
*
* The latter two data structures are used to prevent creating multiple
* PARAM_EXEC slots (each requiring work to fill) when the same upper
* SubPlan or NestLoop supplies a value that is referenced in more than
* one place in its child plan nodes. However, when the same Var has to
* be supplied to different subplan trees by different SubPlan or NestLoop
* parent nodes, we don't recognize any commonality; a fresh plan_params or
* curOuterParams entry will be made (since the old one has been removed
* when we finished processing the earlier SubPlan or NestLoop) and a fresh
* PARAM_EXEC number will be assigned. At one time we tried to avoid
* allocating duplicate PARAM_EXEC numbers in such cases, but it's harder
* than it seems to avoid bugs due to overlapping Param lifetimes, so we
* don't risk that anymore. Minimizing the number of PARAM_EXEC slots
* doesn't really save much executor work anyway.
*
*
* Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* src/backend/optimizer/util/paramassign.c
*
*-------------------------------------------------------------------------
*/
#include "postgres.h"
#include "nodes/nodeFuncs.h"
#include "nodes/plannodes.h"
#include "optimizer/paramassign.h"
#include "optimizer/placeholder.h"
#include "rewrite/rewriteManip.h"
/*
* Select a PARAM_EXEC number to identify the given Var as a parameter for
* the current subquery. (It might already have one.)
* Record the need for the Var in the proper upper-level root->plan_params.
*/
static int
assign_param_for_var(PlannerInfo *root, Var *var)
{
ListCell *ppl;
PlannerParamItem *pitem;
Index levelsup;
/* Find the query level the Var belongs to */
for (levelsup = var->varlevelsup; levelsup > 0; levelsup--)
root = root->parent_root;
/* If there's already a matching PlannerParamItem there, just use it */
foreach(ppl, root->plan_params)
{
pitem = (PlannerParamItem *) lfirst(ppl);
if (IsA(pitem->item, Var))
{
Var *pvar = (Var *) pitem->item;
/*
* This comparison must match _equalVar(), except for ignoring
* varlevelsup. Note that _equalVar() ignores varnosyn,
* varattnosyn, and location, so this does too.
*/
if (pvar->varno == var->varno &&
pvar->varattno == var->varattno &&
pvar->vartype == var->vartype &&
pvar->vartypmod == var->vartypmod &&
pvar->varcollid == var->varcollid)
return pitem->paramId;
}
}
/* Nope, so make a new one */
var = copyObject(var);
var->varlevelsup = 0;
pitem = makeNode(PlannerParamItem);
pitem->item = (Node *) var;
pitem->paramId = list_length(root->glob->paramExecTypes);
root->glob->paramExecTypes = lappend_oid(root->glob->paramExecTypes,
var->vartype);
root->plan_params = lappend(root->plan_params, pitem);
return pitem->paramId;
}
/*
* Generate a Param node to replace the given Var,
* which is expected to have varlevelsup > 0 (ie, it is not local).
* Record the need for the Var in the proper upper-level root->plan_params.
*/
Param *
replace_outer_var(PlannerInfo *root, Var *var)
{
Param *retval;
int i;
Assert(var->varlevelsup > 0 && var->varlevelsup < root->query_level);
/* Find the Var in the appropriate plan_params, or add it if not present */
i = assign_param_for_var(root, var);
retval = makeNode(Param);
retval->paramkind = PARAM_EXEC;
retval->paramid = i;
retval->paramtype = var->vartype;
retval->paramtypmod = var->vartypmod;
retval->paramcollid = var->varcollid;
retval->location = var->location;
return retval;
}
/*
* Select a PARAM_EXEC number to identify the given PlaceHolderVar as a
* parameter for the current subquery. (It might already have one.)
* Record the need for the PHV in the proper upper-level root->plan_params.
*
* This is just like assign_param_for_var, except for PlaceHolderVars.
*/
static int
assign_param_for_placeholdervar(PlannerInfo *root, PlaceHolderVar *phv)
{
ListCell *ppl;
PlannerParamItem *pitem;
Index levelsup;
/* Find the query level the PHV belongs to */
for (levelsup = phv->phlevelsup; levelsup > 0; levelsup--)
root = root->parent_root;
/* If there's already a matching PlannerParamItem there, just use it */
foreach(ppl, root->plan_params)
{
pitem = (PlannerParamItem *) lfirst(ppl);
if (IsA(pitem->item, PlaceHolderVar))
{
PlaceHolderVar *pphv = (PlaceHolderVar *) pitem->item;
/* We assume comparing the PHIDs is sufficient */
if (pphv->phid == phv->phid)
return pitem->paramId;
}
}
/* Nope, so make a new one */
phv = copyObject(phv);
IncrementVarSublevelsUp((Node *) phv, -((int) phv->phlevelsup), 0);
Assert(phv->phlevelsup == 0);
pitem = makeNode(PlannerParamItem);
pitem->item = (Node *) phv;
pitem->paramId = list_length(root->glob->paramExecTypes);
root->glob->paramExecTypes = lappend_oid(root->glob->paramExecTypes,
exprType((Node *) phv->phexpr));
root->plan_params = lappend(root->plan_params, pitem);
return pitem->paramId;
}
/*
* Generate a Param node to replace the given PlaceHolderVar,
* which is expected to have phlevelsup > 0 (ie, it is not local).
* Record the need for the PHV in the proper upper-level root->plan_params.
*
* This is just like replace_outer_var, except for PlaceHolderVars.
*/
Param *
replace_outer_placeholdervar(PlannerInfo *root, PlaceHolderVar *phv)
{
Param *retval;
int i;
Assert(phv->phlevelsup > 0 && phv->phlevelsup < root->query_level);
/* Find the PHV in the appropriate plan_params, or add it if not present */
i = assign_param_for_placeholdervar(root, phv);
retval = makeNode(Param);
retval->paramkind = PARAM_EXEC;
retval->paramid = i;
retval->paramtype = exprType((Node *) phv->phexpr);
retval->paramtypmod = exprTypmod((Node *) phv->phexpr);
retval->paramcollid = exprCollation((Node *) phv->phexpr);
retval->location = -1;
return retval;
}
/*
* Generate a Param node to replace the given Aggref
* which is expected to have agglevelsup > 0 (ie, it is not local).
* Record the need for the Aggref in the proper upper-level root->plan_params.
*/
Param *
replace_outer_agg(PlannerInfo *root, Aggref *agg)
{
Param *retval;
PlannerParamItem *pitem;
Index levelsup;
Assert(agg->agglevelsup > 0 && agg->agglevelsup < root->query_level);
/* Find the query level the Aggref belongs to */
for (levelsup = agg->agglevelsup; levelsup > 0; levelsup--)
root = root->parent_root;
/*
* It does not seem worthwhile to try to de-duplicate references to outer
* aggs. Just make a new slot every time.
*/
agg = copyObject(agg);
IncrementVarSublevelsUp((Node *) agg, -((int) agg->agglevelsup), 0);
Assert(agg->agglevelsup == 0);
pitem = makeNode(PlannerParamItem);
pitem->item = (Node *) agg;
pitem->paramId = list_length(root->glob->paramExecTypes);
root->glob->paramExecTypes = lappend_oid(root->glob->paramExecTypes,
agg->aggtype);
root->plan_params = lappend(root->plan_params, pitem);
retval = makeNode(Param);
retval->paramkind = PARAM_EXEC;
retval->paramid = pitem->paramId;
retval->paramtype = agg->aggtype;
retval->paramtypmod = -1;
retval->paramcollid = agg->aggcollid;
retval->location = agg->location;
return retval;
}
/*
* Generate a Param node to replace the given GroupingFunc expression which is
* expected to have agglevelsup > 0 (ie, it is not local).
* Record the need for the GroupingFunc in the proper upper-level
* root->plan_params.
*/
Param *
replace_outer_grouping(PlannerInfo *root, GroupingFunc *grp)
{
Param *retval;
PlannerParamItem *pitem;
Index levelsup;
Oid ptype = exprType((Node *) grp);
Assert(grp->agglevelsup > 0 && grp->agglevelsup < root->query_level);
/* Find the query level the GroupingFunc belongs to */
for (levelsup = grp->agglevelsup; levelsup > 0; levelsup--)
root = root->parent_root;
/*
* It does not seem worthwhile to try to de-duplicate references to outer
* aggs. Just make a new slot every time.
*/
grp = copyObject(grp);
IncrementVarSublevelsUp((Node *) grp, -((int) grp->agglevelsup), 0);
Assert(grp->agglevelsup == 0);
pitem = makeNode(PlannerParamItem);
pitem->item = (Node *) grp;
pitem->paramId = list_length(root->glob->paramExecTypes);
root->glob->paramExecTypes = lappend_oid(root->glob->paramExecTypes,
ptype);
root->plan_params = lappend(root->plan_params, pitem);
retval = makeNode(Param);
retval->paramkind = PARAM_EXEC;
retval->paramid = pitem->paramId;
retval->paramtype = ptype;
retval->paramtypmod = -1;
retval->paramcollid = InvalidOid;
retval->location = grp->location;
return retval;
}
/*
* Generate a Param node to replace the given Var,
* which is expected to come from some upper NestLoop plan node.
* Record the need for the Var in root->curOuterParams.
*/
Param *
replace_nestloop_param_var(PlannerInfo *root, Var *var)
{
Param *param;
NestLoopParam *nlp;
ListCell *lc;
/* Is this Var already listed in root->curOuterParams? */
foreach(lc, root->curOuterParams)
{
nlp = (NestLoopParam *) lfirst(lc);
if (equal(var, nlp->paramval))
{
/* Yes, so just make a Param referencing this NLP's slot */
param = makeNode(Param);
param->paramkind = PARAM_EXEC;
param->paramid = nlp->paramno;
param->paramtype = var->vartype;
param->paramtypmod = var->vartypmod;
param->paramcollid = var->varcollid;
param->location = var->location;
return param;
}
}
/* No, so assign a PARAM_EXEC slot for a new NLP */
param = generate_new_exec_param(root,
var->vartype,
var->vartypmod,
var->varcollid);
param->location = var->location;
/* Add it to the list of required NLPs */
nlp = makeNode(NestLoopParam);
nlp->paramno = param->paramid;
nlp->paramval = copyObject(var);
root->curOuterParams = lappend(root->curOuterParams, nlp);
/* And return the replacement Param */
return param;
}
/*
* Generate a Param node to replace the given PlaceHolderVar,
* which is expected to come from some upper NestLoop plan node.
* Record the need for the PHV in root->curOuterParams.
*
* This is just like replace_nestloop_param_var, except for PlaceHolderVars.
*/
Param *
replace_nestloop_param_placeholdervar(PlannerInfo *root, PlaceHolderVar *phv)
{
Param *param;
NestLoopParam *nlp;
ListCell *lc;
/* Is this PHV already listed in root->curOuterParams? */
foreach(lc, root->curOuterParams)
{
nlp = (NestLoopParam *) lfirst(lc);
if (equal(phv, nlp->paramval))
{
/* Yes, so just make a Param referencing this NLP's slot */
param = makeNode(Param);
param->paramkind = PARAM_EXEC;
param->paramid = nlp->paramno;
param->paramtype = exprType((Node *) phv->phexpr);
param->paramtypmod = exprTypmod((Node *) phv->phexpr);
param->paramcollid = exprCollation((Node *) phv->phexpr);
param->location = -1;
return param;
}
}
/* No, so assign a PARAM_EXEC slot for a new NLP */
param = generate_new_exec_param(root,
exprType((Node *) phv->phexpr),
exprTypmod((Node *) phv->phexpr),
exprCollation((Node *) phv->phexpr));
/* Add it to the list of required NLPs */
nlp = makeNode(NestLoopParam);
nlp->paramno = param->paramid;
nlp->paramval = (Var *) copyObject(phv);
root->curOuterParams = lappend(root->curOuterParams, nlp);
/* And return the replacement Param */
return param;
}
/*
* process_subquery_nestloop_params
* Handle params of a parameterized subquery that need to be fed
* from an outer nestloop.
*
* Currently, that would be *all* params that a subquery in FROM has demanded
* from the current query level, since they must be LATERAL references.
*
* subplan_params is a list of PlannerParamItems that we intend to pass to
* a subquery-in-FROM. (This was constructed in root->plan_params while
* planning the subquery, but isn't there anymore when this is called.)
*
* The subplan's references to the outer variables are already represented
* as PARAM_EXEC Params, since that conversion was done by the routines above
* while planning the subquery. So we need not modify the subplan or the
* PlannerParamItems here. What we do need to do is add entries to
* root->curOuterParams to signal the parent nestloop plan node that it must
* provide these values. This differs from replace_nestloop_param_var in
* that the PARAM_EXEC slots to use have already been determined.
*
* Note that we also use root->curOuterRels as an implicit parameter for
* sanity checks.
*/
void
process_subquery_nestloop_params(PlannerInfo *root, List *subplan_params)
{
ListCell *lc;
foreach(lc, subplan_params)
{
PlannerParamItem *pitem = lfirst_node(PlannerParamItem, lc);
if (IsA(pitem->item, Var))
{
Var *var = (Var *) pitem->item;
NestLoopParam *nlp;
ListCell *lc;
/* If not from a nestloop outer rel, complain */
if (!bms_is_member(var->varno, root->curOuterRels))
elog(ERROR, "non-LATERAL parameter required by subquery");
/* Is this param already listed in root->curOuterParams? */
foreach(lc, root->curOuterParams)
{
nlp = (NestLoopParam *) lfirst(lc);
if (nlp->paramno == pitem->paramId)
{
Assert(equal(var, nlp->paramval));
/* Present, so nothing to do */
break;
}
}
if (lc == NULL)
{
/* No, so add it */
nlp = makeNode(NestLoopParam);
nlp->paramno = pitem->paramId;
nlp->paramval = copyObject(var);
root->curOuterParams = lappend(root->curOuterParams, nlp);
}
}
else if (IsA(pitem->item, PlaceHolderVar))
{
PlaceHolderVar *phv = (PlaceHolderVar *) pitem->item;
NestLoopParam *nlp;
ListCell *lc;
/* If not from a nestloop outer rel, complain */
if (!bms_is_subset(find_placeholder_info(root, phv, false)->ph_eval_at,
root->curOuterRels))
elog(ERROR, "non-LATERAL parameter required by subquery");
/* Is this param already listed in root->curOuterParams? */
foreach(lc, root->curOuterParams)
{
nlp = (NestLoopParam *) lfirst(lc);
if (nlp->paramno == pitem->paramId)
{
Assert(equal(phv, nlp->paramval));
/* Present, so nothing to do */
break;
}
}
if (lc == NULL)
{
/* No, so add it */
nlp = makeNode(NestLoopParam);
nlp->paramno = pitem->paramId;
nlp->paramval = (Var *) copyObject(phv);
root->curOuterParams = lappend(root->curOuterParams, nlp);
}
}
else
elog(ERROR, "unexpected type of subquery parameter");
}
}
/*
* Identify any NestLoopParams that should be supplied by a NestLoop plan
* node with the specified lefthand rels. Remove them from the active
* root->curOuterParams list and return them as the result list.
*/
List *
identify_current_nestloop_params(PlannerInfo *root, Relids leftrelids)
{
List *result;
ListCell *cell;
result = NIL;
foreach(cell, root->curOuterParams)
{
NestLoopParam *nlp = (NestLoopParam *) lfirst(cell);
/*
* We are looking for Vars and PHVs that can be supplied by the
* lefthand rels. The "bms_overlap" test is just an optimization to
* allow skipping find_placeholder_info() if the PHV couldn't match.
*/
if (IsA(nlp->paramval, Var) &&
bms_is_member(nlp->paramval->varno, leftrelids))
{
root->curOuterParams = foreach_delete_current(root->curOuterParams,
cell);
result = lappend(result, nlp);
}
else if (IsA(nlp->paramval, PlaceHolderVar) &&
bms_overlap(((PlaceHolderVar *) nlp->paramval)->phrels,
leftrelids) &&
bms_is_subset(find_placeholder_info(root,
(PlaceHolderVar *) nlp->paramval,
false)->ph_eval_at,
leftrelids))
{
root->curOuterParams = foreach_delete_current(root->curOuterParams,
cell);
result = lappend(result, nlp);
}
}
return result;
}
/*
* Generate a new Param node that will not conflict with any other.
*
* This is used to create Params representing subplan outputs or
* NestLoop parameters.
*
* We don't need to build a PlannerParamItem for such a Param, but we do
* need to make sure we record the type in paramExecTypes (otherwise,
* there won't be a slot allocated for it).
*/
Param *
generate_new_exec_param(PlannerInfo *root, Oid paramtype, int32 paramtypmod,
Oid paramcollation)
{
Param *retval;
retval = makeNode(Param);
retval->paramkind = PARAM_EXEC;
retval->paramid = list_length(root->glob->paramExecTypes);
root->glob->paramExecTypes = lappend_oid(root->glob->paramExecTypes,
paramtype);
retval->paramtype = paramtype;
retval->paramtypmod = paramtypmod;
retval->paramcollid = paramcollation;
retval->location = -1;
return retval;
}
/*
* Assign a (nonnegative) PARAM_EXEC ID for a special parameter (one that
* is not actually used to carry a value at runtime). Such parameters are
* used for special runtime signaling purposes, such as connecting a
* recursive union node to its worktable scan node or forcing plan
* re-evaluation within the EvalPlanQual mechanism. No actual Param node
* exists with this ID, however.
*/
int
assign_special_exec_param(PlannerInfo *root)
{
int paramId = list_length(root->glob->paramExecTypes);
root->glob->paramExecTypes = lappend_oid(root->glob->paramExecTypes,
InvalidOid);
return paramId;
}
|
264869.c | // dizi3.c 弟子
#include <ansi.h>
inherit NPC;
inherit F_MASTER;
void create()
{
set_name("青衣弟子", ({ "di zi", "di", "zi" }));
set("long", "這是三十多歲的壯漢,膀大腰圓,是島主從中原招募來的。\n");
set("gender", "男性");
set("age", 30);
set("shen_type",1);
set("attitude", "peaceful");
set("str", 20);
set("int", 20);
set("con", 20);
set("dex", 20);
set("qi", 500);
set("max_qi", 500);
set("jing", 200);
set("max_jing", 200);
set("neili", 300);
set("max_neili", 300);
set("jiali", 30);
set("combat_exp", 30000);
set("score", 10);
set_skill("force", 70);
set_skill("unarmed", 70);
set_skill("dodge", 70);
set_skill("parry", 70);
set_skill("hand", 70);
set_skill("staff", 50);
create_family("俠客島", 2, "弟子");
setup();
carry_object(__DIR__"obj/bcloth")->wear();
}
void init()
{
object ob= this_player();
::init();
if( interactive(ob) && !ob->is_fight() )
{
remove_call_out("greeting");
call_out("greeting", 1, ob);
}
}
void greeting(object ob)
{
object room;
room = find_object("/d/xiakedao/shimen");
if( !ob || environment(ob) != environment()
|| environment() != room)
return;
message_vision("
$N説道:洞內有二十四座石室,各位可請隨意來去。看得厭了,可到
洞外散心,一應飲食,石室內均有置備,各位隨意取用,不必客氣。", this_object());
message_vision("
二十四座石室大致是這樣分佈的:
基本掌法 基本鈎法 基本拳腳
| | |
基本暗器—一進—基本輕功 基本棒法—二進—基本槍法 基本刀法—三進—基本招架
| | |
基本劍法 基本腿法 基本刺法
基本斧法 基本錘法 基本指法
| | |
基本爪法—四進—基本杖法 基本內功—五進—基本陣法 太玄功—六進—基本鞭法
| | |
基本拳法 基本手法 基本棍法\n", this_object());
}
|
94016.c | //------------------------------------------------------------------------------
// GB_Asaxpy3B: hard-coded saxpy3 method for a semiring
//------------------------------------------------------------------------------
// SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2021, All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
//------------------------------------------------------------------------------
// If this file is in the Generated/ folder, do not edit it (auto-generated).
#include "GB_AxB_defs__min_div_uint8.h"
#ifndef GBCOMPACT
//------------------------------------------------------------------------------
// C=A*B, C<M>=A*B, C<!M>=A*B: saxpy method (Gustavson + Hash)
//------------------------------------------------------------------------------
#if ( !GB_DISABLE )
#include "GB_AxB_saxpy3_template.h"
GrB_Info GB (_Asaxpy3B_notM__min_div_uint8)
(
GrB_Matrix C, // C<!M>=A*B, C sparse or hypersparse
const GrB_Matrix M, const bool Mask_struct,
const bool M_packed_in_place,
const GrB_Matrix A, bool A_is_pattern,
const GrB_Matrix B, bool B_is_pattern,
GB_saxpy3task_struct *restrict SaxpyTasks,
const int ntasks, const int nfine, const int nthreads,
const int do_sort,
GB_Context Context
)
{
if (GB_IS_SPARSE (A) && GB_IS_SPARSE (B))
{
// both A and B are sparse
#define GB_META16
#define GB_NO_MASK 0
#define GB_MASK_COMP 1
#define GB_A_IS_SPARSE 1
#define GB_A_IS_HYPER 0
#define GB_A_IS_BITMAP 0
#define GB_A_IS_FULL 0
#define GB_B_IS_SPARSE 1
#define GB_B_IS_HYPER 0
#define GB_B_IS_BITMAP 0
#define GB_B_IS_FULL 0
#include "GB_meta16_definitions.h"
#include "GB_AxB_saxpy3_template.c"
}
else
{
// general case
#undef GB_META16
#define GB_NO_MASK 0
#define GB_MASK_COMP 1
#include "GB_meta16_definitions.h"
#include "GB_AxB_saxpy3_template.c"
}
return (GrB_SUCCESS) ;
}
#endif
#endif
|
415419.c |
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
Package, Release 3d, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions, and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions, and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the University nor the names of its contributors may
be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
=============================================================================*/
#include "platform.h"
#include "softfloat.h"
/*----------------------------------------------------------------------------
| Raises the exceptions specified by `flags'. Floating-point traps can be
| defined here if desired. It is currently not possible for such a trap
| to substitute a result value. If traps are not implemented, this routine
| should be simply `softfloat_exceptionFlags |= flags;'.
*----------------------------------------------------------------------------*/
void softfloat_raiseFlags( uint_fast8_t flags )
{
softfloat_exceptionFlags |= flags;
}
|
980061.c | /**
****************************************************************************************
*
* @file tips.c
*
* @brief Time Profile Server implementation.
*
* Copyright (C) RivieraWaves 2009-2016
*
*
****************************************************************************************
*/
/**
****************************************************************************************
* @addtogroup TIPS
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "rwip_config.h"
#if (BLE_TIP_SERVER)
#include "attm.h"
#include "tips.h"
#include "tips_task.h"
#include "prf_utils.h"
#include "ke_mem.h"
/*
* CTS, NDCS, RTUS ATTRIBUTES
****************************************************************************************
*/
/// Full CTS Database Description - Used to add attributes into the database
const struct attm_desc cts_att_db[CTS_IDX_NB] =
{
// Current Time Service Declaration
[CTS_IDX_SVC] = {ATT_DECL_PRIMARY_SERVICE, PERM(RD, ENABLE), 0, 0},
// Current Time Characteristic Declaration
[CTS_IDX_CURRENT_TIME_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0},
// Current Time Characteristic Value
[CTS_IDX_CURRENT_TIME_VAL] = {ATT_CHAR_CT_TIME, PERM(RD, ENABLE) | PERM(NTF, ENABLE), PERM(RI, ENABLE), CTS_CURRENT_TIME_VAL_LEN},
// Current Time Characteristic - Client Char. Configuration Descriptor
[CTS_IDX_CURRENT_TIME_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, PERM(RD, ENABLE) | PERM(WRITE_REQ, ENABLE), 0, 0},
// Local Time Information Characteristic Declaration
[CTS_IDX_LOCAL_TIME_INFO_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0},
// Local Time Information Characteristic Value
[CTS_IDX_LOCAL_TIME_INFO_VAL] = {ATT_CHAR_LOCAL_TIME_INFO, PERM(RD, ENABLE), PERM(RI, ENABLE), sizeof(struct tip_loc_time_info)},
// Reference Time Information Characteristic Declaration
[CTS_IDX_REF_TIME_INFO_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0},
// Reference Time Info Characteristic Value
[CTS_IDX_REF_TIME_INFO_VAL] = {ATT_CHAR_REFERENCE_TIME_INFO, PERM(RD, ENABLE), PERM(RI, ENABLE), sizeof(struct tip_ref_time_info)},
};
/// Full NDCS Database Description - Used to add attributes into the database
const struct attm_desc ndcs_att_db[NDCS_IDX_NB] =
{
// Next DST Change Service Declaration
[NDCS_IDX_SVC] = {ATT_DECL_PRIMARY_SERVICE, PERM(RD, ENABLE), 0, 0},
// Time with DST Characteristic Declaration
[NDCS_IDX_TIME_DST_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0},
// Time With DST Characteristic Value
[NDCS_IDX_TIME_DST_VAL] = {ATT_CHAR_TIME_WITH_DST, PERM(RD, ENABLE), PERM(RI, ENABLE), NDCS_TIME_DST_VAL_LEN},
};
/// Full RTUS Database Description - Used to add attributes into the database
const struct attm_desc rtus_att_db[RTUS_IDX_NB] =
{
// Reference Time Information Service Declaration
[RTUS_IDX_SVC] = {ATT_DECL_PRIMARY_SERVICE, PERM(RD, ENABLE), 0, 0},
// Time Update Control Point Characteristic Declaration
[RTUS_IDX_TIME_UPD_CTNL_PT_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0},
// Time Update Control Point Characteristic Value
[RTUS_IDX_TIME_UPD_CTNL_PT_VAL] = {ATT_CHAR_TIME_UPDATE_CNTL_POINT, PERM(WRITE_COMMAND, ENABLE), PERM(RI, ENABLE), sizeof(tip_time_upd_contr_pt)},
// Time Update State Characteristic Declaration
[RTUS_IDX_TIME_UPD_STATE_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0},
// Time Update State Characteristic Value
[RTUS_IDX_TIME_UPD_STATE_VAL] = {ATT_CHAR_TIME_UPDATE_STATE, PERM(RD, ENABLE), PERM(RI, ENABLE), sizeof(struct tip_time_upd_state)},
};
/**
****************************************************************************************
* @brief Initialization of the TIPS module.
* This function performs all the initializations of the Profile module.
* - Creation of database (if it's a service)
* - Allocation of profile required memory
* - Initialization of task descriptor to register application
* - Task State array
* - Number of tasks
* - Default task handler
*
* @param[out] env Collector or Service allocated environment data.
* @param[in|out] start_hdl Service start handle (0 - dynamically allocated), only applies for services.
* @param[in] app_task Application task number.
* @param[in] sec_lvl Security level (AUTH, EKS and MI field of @see enum attm_value_perm_mask)
* @param[in] param Configuration parameters of profile collector or service (32 bits aligned)
*
* @return status code to know if profile initialization succeed or not.
****************************************************************************************
*/
static uint8_t tips_init(struct prf_task_env* env, uint16_t* start_hdl, uint16_t app_task, uint8_t sec_lvl, struct tips_db_cfg* params)
{
// Service content flag
uint32_t cfg_flag= TIPS_CTS_CURRENT_TIME_MASK;
// DB Creation Status
uint8_t status = ATT_ERR_NO_ERROR;
// Total number of attributes
uint8_t tot_nb_att = CTS_IDX_NB;
// Allocate TIPS required environment variable
struct tips_env_tag* tips_env =
(struct tips_env_tag* ) ke_malloc(sizeof(struct tips_env_tag), KE_MEM_ATT_DB);
env->env = (prf_env_t*) tips_env;
//------------------ create the attribute database for the profile -------------------
// Check supported attributes
if (params->features & TIPS_NDCS_SUP)
{
tot_nb_att += NDCS_IDX_NB;
}
if (params->features & TIPS_NDCS_SUP)
{
tot_nb_att += RTUS_IDX_NB;
}
// Check that attribute list can be allocated.
status = attm_reserve_handle_range(start_hdl, tot_nb_att);
if (status == ATT_ERR_NO_ERROR)
{
//Set Configuration Flag Value
if (params->features & TIPS_CTS_LOC_TIME_INFO_SUP)
{
cfg_flag |= TIPS_CTS_LOC_TIME_INFO_MASK;
}
if (params->features & TIPS_CTS_REF_TIME_INFO_SUP)
{
cfg_flag |= TIPS_CTS_REF_TIME_INFO_MASK;
}
/*---------------------------------------------------*
* Current Time Service Creation
*---------------------------------------------------*/
status = attm_svc_create_db(start_hdl, ATT_SVC_CURRENT_TIME, (uint8_t *)&cfg_flag,
CTS_IDX_NB, &tips_env->cts_att_tbl[0], env->task, &cts_att_db[0],
(sec_lvl & (PERM_MASK_SVC_DIS | PERM_MASK_SVC_AUTH | PERM_MASK_SVC_EKS)) | PERM(SVC_MI, ENABLE));
// Update index
tips_env->cts_shdl = *start_hdl;
*start_hdl += CTS_IDX_NB;
//All attributes are mandatory for NDCS and RTUS
cfg_flag = 0xFF;
if ((status == ATT_ERR_NO_ERROR) && ((params->features & TIPS_NDCS_SUP)))
{
/*---------------------------------------------------*
* Next DST Change Service Creation
*---------------------------------------------------*/
status = attm_svc_create_db(start_hdl, ATT_SVC_NEXT_DST_CHANGE, (uint8_t *)&cfg_flag,
NDCS_IDX_NB, &tips_env->ndcs_att_tbl[0], env->task, &ndcs_att_db[0],
(sec_lvl & (PERM_MASK_SVC_DIS | PERM_MASK_SVC_AUTH | PERM_MASK_SVC_EKS)) | PERM(SVC_MI, ENABLE));
// Update index
tips_env->ndcs_shdl = *start_hdl;
*start_hdl += NDCS_IDX_NB;
}
/*---------------------------------------------------*
* Reference Time Update Service Creation
*---------------------------------------------------*/
if ((status == ATT_ERR_NO_ERROR) && ((params->features & TIPS_RTUS_SUP)))
{
status = attm_svc_create_db(start_hdl, ATT_SVC_REF_TIME_UPDATE, (uint8_t *)&cfg_flag,
RTUS_IDX_NB, &tips_env->rtus_att_tbl[0], env->task, &rtus_att_db[0],
(sec_lvl & (PERM_MASK_SVC_DIS | PERM_MASK_SVC_AUTH | PERM_MASK_SVC_EKS)) | PERM(SVC_MI, ENABLE));
// Update index
tips_env->rtus_shdl = *start_hdl;
*start_hdl += RTUS_IDX_NB;
}
// Initialize TIPS environment
tips_env->features = params->features;
tips_env->prf_env.app_task = app_task
| (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) : PERM(PRF_MI, DISABLE));
// Multi Instantiated task
tips_env->prf_env.prf_task = env->task | PERM(PRF_MI, ENABLE);
// initialize environment variable
env->id = TASK_ID_TIPS;
env->desc.idx_max = TIPS_IDX_MAX;
env->desc.state = tips_env->state;
env->desc.default_handler = &tips_default_handler;
for(uint8_t idx = 0; idx < BLE_CONNECTION_MAX ; idx++)
{
tips_env->env[idx] = NULL;
}
/* Put TIS in disabled state */
ke_state_set(env->task, TIPS_IDLE);
}
return (status);
}
/**
****************************************************************************************
* @brief Destruction of the TIPS module - due to a reset for instance.
* This function clean-up allocated memory (attribute database is destroyed by another
* procedure)
*
* @param[in|out] env Collector or Service allocated environment data.
****************************************************************************************
*/
static void tips_destroy(struct prf_task_env* env)
{
uint8_t idx;
struct tips_env_tag* tips_env = (struct tips_env_tag*) env->env;
// cleanup environment variable for each task instances
for(idx = 0; idx < BLE_CONNECTION_MAX ; idx++)
{
if(tips_env->env[idx] != NULL)
{
ke_free(tips_env->env[idx]);
}
}
// free profile environment variables
env->env = NULL;
ke_free(tips_env);
}
/**
****************************************************************************************
* @brief Handles Connection creation
*
* @param[in|out] env Collector or Service allocated environment data.
* @param[in] conidx Connection index
****************************************************************************************
*/
static void tips_create(struct prf_task_env* env, uint8_t conidx)
{
struct tips_env_tag* tips_env = (struct tips_env_tag*) env->env;
tips_env->env[conidx] = (struct tips_cnx_env*)
ke_malloc(sizeof(struct tips_cnx_env), KE_MEM_ATT_DB);
memset(tips_env->env[conidx], 0, sizeof(struct tips_cnx_env));
/* Put TIS in idle state */
ke_state_set(KE_BUILD_ID(env->task, conidx), TIPS_IDLE);
}
/**
****************************************************************************************
* @brief Handles Disconnection
*
* @param[in|out] env Collector or Service allocated environment data.
* @param[in] conidx Connection index
* @param[in] reason Detach reason
****************************************************************************************
*/
static void tips_cleanup(struct prf_task_env* env, uint8_t conidx, uint8_t reason)
{
struct tips_env_tag* tips_env = (struct tips_env_tag*) env->env;
// clean-up environment variable allocated for task instance
if(tips_env->env[conidx] != NULL)
{
ke_free(tips_env->env[conidx]);
tips_env->env[conidx] = NULL;
}
}
/*
* GLOBAL VARIABLE DEFINITIONS
****************************************************************************************
*/
/// TIPS Task interface required by profile manager
const struct prf_task_cbs tips_itf =
{
(prf_init_fnct) tips_init,
tips_destroy,
tips_create,
tips_cleanup,
};
/*
* EXPORTED FUNCTIONS DEFINITIONS
****************************************************************************************
*/
const struct prf_task_cbs* tips_prf_itf_get(void)
{
return &tips_itf;
}
uint8_t tips_pack_curr_time_value(uint8_t *p_pckd_time, const struct tip_curr_time* p_curr_time_val)
{
// Date-Time
prf_pack_date_time(p_pckd_time, &(p_curr_time_val->date_time));
//Day of Week
*(p_pckd_time + 7) = p_curr_time_val->day_of_week;
//Fraction 256
*(p_pckd_time + 8) = p_curr_time_val->fraction_256;
//Adjust Reason
*(p_pckd_time + 9) = p_curr_time_val->adjust_reason;
return 10;
}
uint8_t tips_pack_time_dst_value(uint8_t *p_pckd_time_dst, const struct tip_time_with_dst* p_time_dst_val)
{
// Date-Time
prf_pack_date_time(p_pckd_time_dst, &(p_time_dst_val->date_time));
// DST Offset
*(p_pckd_time_dst + 7) = p_time_dst_val->dst_offset;
return 8;
}
#endif //BLE_TIP_SERVER
/// @} TIPS
|
234421.c | /*
* Drip
*
* This code has been extracted from the Csound opcode "dripwater".
* It has been modified to work as a Soundpipe module.
*
* Original Author(s): Perry Cook
* Year: 2000
* Location: Opcodes/phisem.c
*
*/
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include "soundpipe.h"
#define WUTR_SOUND_DECAY 0.95
#define WUTR_SYSTEM_DECAY 0.996
#define WUTR_GAIN 1.0
#define WUTR_NUM_SOURCES 10.0
#define WUTR_CENTER_FREQ0 450.0
#define WUTR_CENTER_FREQ1 600.0
#define WUTR_CENTER_FREQ2 750.0
#define WUTR_RESON 0.9985
#define WUTR_FREQ_SWEEP 1.0001
#define MAX_SHAKE 2000
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
static int my_random(sp_data *sp, int max)
{
return (sp_rand(sp) % (max + 1));
}
static SPFLOAT noise_tick(sp_data *sp)
{
SPFLOAT temp;
temp = 1.0 * sp_rand(sp) - 1073741823.5;
return temp * (1.0 / 1073741823.0);
}
int sp_drip_create(sp_drip **p)
{
*p = malloc(sizeof(sp_drip));
return SP_OK;
}
int sp_drip_destroy(sp_drip **p)
{
free(*p);
return SP_OK;
}
int sp_drip_init(sp_data *sp, sp_drip *p, SPFLOAT dettack)
{
SPFLOAT temp;
p->dettack = dettack;
p->num_tubes = 10;
p->damp = 0.2;
p->shake_max = 0;
p->freq = 450.0;
p->freq1 = 600.0;
p->freq2 = 720.0;
p->amp = 0.3;
p->sndLevel = 0.0;
SPFLOAT tpidsr = 2.0 * M_PI / sp->sr;
p->kloop = (sp->sr * p->dettack);
p->outputs00 = 0.0;
p->outputs01 = 0.0;
p->outputs10 = 0.0;
p->outputs11 = 0.0;
p->outputs20 = 0.0;
p->outputs21 = 0.0;
p->totalEnergy = 0.0;
p->center_freqs0 = p->res_freq0 = WUTR_CENTER_FREQ0;
p->center_freqs1 = p->res_freq1 = WUTR_CENTER_FREQ1;
p->center_freqs2 = p->res_freq2 = WUTR_CENTER_FREQ2;
p->num_objectsSave = p->num_objects = WUTR_NUM_SOURCES;
p->soundDecay = WUTR_SOUND_DECAY;
p->systemDecay = WUTR_SYSTEM_DECAY;
temp = log(WUTR_NUM_SOURCES) * WUTR_GAIN / WUTR_NUM_SOURCES;
p->gains0 = p->gains1 = p->gains2 = temp;
p->coeffs01 = WUTR_RESON * WUTR_RESON;
p->coeffs00 = -WUTR_RESON * 2.0 *
cos(WUTR_CENTER_FREQ0 * tpidsr);
p->coeffs11 = WUTR_RESON * WUTR_RESON;
p->coeffs10 = -WUTR_RESON * 2.0 *
cos(WUTR_CENTER_FREQ1 * tpidsr);
p->coeffs21 = WUTR_RESON * WUTR_RESON;
p->coeffs20 = -WUTR_RESON * 2.0 *
cos(WUTR_CENTER_FREQ2 * tpidsr);
p->shakeEnergy = p->amp * 1.0 * MAX_SHAKE * 0.1;
p->shake_damp = 0.0;
if (p->shakeEnergy > MAX_SHAKE) p->shakeEnergy = MAX_SHAKE;
p->shake_maxSave = 0.0;
p->num_objects = 10;
p->finalZ0 = p->finalZ1 = p->finalZ2 = 0.0;
return SP_OK;
}
int sp_drip_compute(sp_data *sp, sp_drip *p, SPFLOAT *trig, SPFLOAT *out)
{
SPFLOAT data;
SPFLOAT lastOutput;
SPFLOAT tpidsr = 2.0 * M_PI / sp->sr;
if(*trig) {
sp_drip_init(sp, p, p->dettack);
}
if (p->num_tubes != 0.0 && p->num_tubes != p->num_objects) {
p->num_objects = p->num_tubes;
if (p->num_objects < 1.0) p->num_objects = 1.0;
}
if (p->freq != 0.0 && p->freq != p->res_freq0) {
p->res_freq0 = p->freq;
p->coeffs00 = -WUTR_RESON * 2.0 *
cos(p->res_freq0 * tpidsr);
}
if (p->damp != 0.0 && p->damp != p->shake_damp) {
p->shake_damp = p->damp;
p->systemDecay = WUTR_SYSTEM_DECAY + (p->shake_damp * 0.002);
}
if (p->shake_max != 0.0 && p->shake_max != p->shake_maxSave) {
p->shake_maxSave = p->shake_max;
p->shakeEnergy += p->shake_maxSave * MAX_SHAKE * 0.1;
if (p->shakeEnergy > MAX_SHAKE) p->shakeEnergy = MAX_SHAKE;
}
if (p->freq1 != 0.0 && p->freq1 != p->res_freq1) {
p->res_freq1 = p->freq1;
p->coeffs10 = -WUTR_RESON * 2.0 *
cos(p->res_freq1 * tpidsr);
}
if (p->freq2 != 0.0 && p->freq2 != p->res_freq2) {
p->res_freq2 = p->freq2;
p->coeffs20 = -WUTR_RESON * 2.0 *
cos(p->res_freq2 * tpidsr);
}
if ((--p->kloop) == 0) {
p->shakeEnergy = 0.0;
}
SPFLOAT shakeEnergy = p->shakeEnergy;
SPFLOAT systemDecay = p->systemDecay;
SPFLOAT sndLevel = p->sndLevel;
SPFLOAT num_objects = p->num_objects;
SPFLOAT soundDecay = p->soundDecay;
SPFLOAT inputs0, inputs1, inputs2;
shakeEnergy *= systemDecay; /* Exponential system decay */
sndLevel = shakeEnergy;
if (my_random(sp, 32767) < num_objects) {
int j;
j = my_random(sp, 3);
if (j == 0) {
p->center_freqs0 = p->res_freq1 *
(0.75 + (0.25 * noise_tick(sp)));
p->gains0 = fabs(noise_tick(sp));
} else if (j == 1) {
p->center_freqs1 = p->res_freq1 *
(1.0 + (0.25 * noise_tick(sp)));
p->gains1 = fabs(noise_tick(sp));
} else {
p->center_freqs2 = p->res_freq1 *
(1.25 + (0.25 * noise_tick(sp)));
p->gains2 = fabs(noise_tick(sp));
}
}
p->gains0 *= WUTR_RESON;
if (p->gains0 > 0.001) {
p->center_freqs0 *= WUTR_FREQ_SWEEP;
p->coeffs00 = -WUTR_RESON * 2.0 *
cos(p->center_freqs0 * tpidsr);
}
p->gains1 *= WUTR_RESON;
if (p->gains1 > 0.00) {
p->center_freqs1 *= WUTR_FREQ_SWEEP;
p->coeffs10 = -WUTR_RESON * 2.0 *
cos(p->center_freqs1 * tpidsr);
}
p->gains2 *= WUTR_RESON;
if (p->gains2 > 0.001) {
p->center_freqs2 *= WUTR_FREQ_SWEEP;
p->coeffs20 = -WUTR_RESON * 2.0 *
cos(p->center_freqs2 * tpidsr);
}
sndLevel *= soundDecay;
inputs0 = sndLevel;
inputs0 *= noise_tick(sp);
inputs1 = inputs0 * p->gains1;
inputs2 = inputs0 * p->gains2;
inputs0 *= p->gains0;
inputs0 -= p->outputs00*p->coeffs00;
inputs0 -= p->outputs01*p->coeffs01;
p->outputs01 = p->outputs00;
p->outputs00 = inputs0;
data = p->gains0*p->outputs00;
inputs1 -= p->outputs10*p->coeffs10;
inputs1 -= p->outputs11*p->coeffs11;
p->outputs11 = p->outputs10;
p->outputs10 = inputs1;
data += p->gains1*p->outputs10;
inputs2-= p->outputs20*p->coeffs20;
inputs2 -= p->outputs21*p->coeffs21;
p->outputs21 = p->outputs20;
p->outputs20 = inputs2;
data += p->gains2*p->outputs20;
p->finalZ2 = p->finalZ1;
p->finalZ1 = p->finalZ0;
p->finalZ0 = data * 4.0;
lastOutput = p->finalZ2 - p->finalZ0;
lastOutput *= 0.005;
*out = lastOutput;
p->shakeEnergy = shakeEnergy;
p->sndLevel = sndLevel;
return SP_OK;
}
|
826856.c | /*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/** \file
* \ingroup edtransform
*/
#include "MEM_guardedalloc.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "BLI_math.h"
#include "BLI_utildefines.h"
#include "BLT_translation.h"
#include "BKE_context.h"
#include "BKE_editmesh.h"
#include "BKE_global.h"
#include "BKE_report.h"
#include "BKE_scene.h"
#include "RNA_access.h"
#include "RNA_define.h"
#include "RNA_enum_types.h"
#include "WM_api.h"
#include "WM_message.h"
#include "WM_toolsystem.h"
#include "WM_types.h"
#include "UI_interface.h"
#include "UI_resources.h"
#include "ED_screen.h"
/* for USE_LOOPSLIDE_HACK only */
#include "ED_mesh.h"
#include "transform.h"
#include "transform_convert.h"
typedef struct TransformModeItem {
const char *idname;
int mode;
void (*opfunc)(wmOperatorType *);
} TransformModeItem;
static const float VecOne[3] = {1, 1, 1};
static const char OP_TRANSLATION[] = "TRANSFORM_OT_translate";
static const char OP_ROTATION[] = "TRANSFORM_OT_rotate";
static const char OP_TOSPHERE[] = "TRANSFORM_OT_tosphere";
static const char OP_RESIZE[] = "TRANSFORM_OT_resize";
static const char OP_SKIN_RESIZE[] = "TRANSFORM_OT_skin_resize";
static const char OP_SHEAR[] = "TRANSFORM_OT_shear";
static const char OP_BEND[] = "TRANSFORM_OT_bend";
static const char OP_SHRINK_FATTEN[] = "TRANSFORM_OT_shrink_fatten";
static const char OP_PUSH_PULL[] = "TRANSFORM_OT_push_pull";
static const char OP_TILT[] = "TRANSFORM_OT_tilt";
static const char OP_TRACKBALL[] = "TRANSFORM_OT_trackball";
static const char OP_MIRROR[] = "TRANSFORM_OT_mirror";
static const char OP_BONE_SIZE[] = "TRANSFORM_OT_bbone_resize";
static const char OP_EDGE_SLIDE[] = "TRANSFORM_OT_edge_slide";
static const char OP_VERT_SLIDE[] = "TRANSFORM_OT_vert_slide";
static const char OP_EDGE_CREASE[] = "TRANSFORM_OT_edge_crease";
static const char OP_EDGE_BWEIGHT[] = "TRANSFORM_OT_edge_bevelweight";
static const char OP_SEQ_SLIDE[] = "TRANSFORM_OT_seq_slide";
static const char OP_NORMAL_ROTATION[] = "TRANSFORM_OT_rotate_normal";
static void TRANSFORM_OT_translate(struct wmOperatorType *ot);
static void TRANSFORM_OT_rotate(struct wmOperatorType *ot);
static void TRANSFORM_OT_tosphere(struct wmOperatorType *ot);
static void TRANSFORM_OT_resize(struct wmOperatorType *ot);
static void TRANSFORM_OT_skin_resize(struct wmOperatorType *ot);
static void TRANSFORM_OT_shear(struct wmOperatorType *ot);
static void TRANSFORM_OT_bend(struct wmOperatorType *ot);
static void TRANSFORM_OT_shrink_fatten(struct wmOperatorType *ot);
static void TRANSFORM_OT_push_pull(struct wmOperatorType *ot);
static void TRANSFORM_OT_tilt(struct wmOperatorType *ot);
static void TRANSFORM_OT_trackball(struct wmOperatorType *ot);
static void TRANSFORM_OT_mirror(struct wmOperatorType *ot);
static void TRANSFORM_OT_bbone_resize(struct wmOperatorType *ot);
static void TRANSFORM_OT_edge_slide(struct wmOperatorType *ot);
static void TRANSFORM_OT_vert_slide(struct wmOperatorType *ot);
static void TRANSFORM_OT_edge_crease(struct wmOperatorType *ot);
static void TRANSFORM_OT_edge_bevelweight(struct wmOperatorType *ot);
static void TRANSFORM_OT_seq_slide(struct wmOperatorType *ot);
static void TRANSFORM_OT_rotate_normal(struct wmOperatorType *ot);
static TransformModeItem transform_modes[] = {
{OP_TRANSLATION, TFM_TRANSLATION, TRANSFORM_OT_translate},
{OP_ROTATION, TFM_ROTATION, TRANSFORM_OT_rotate},
{OP_TOSPHERE, TFM_TOSPHERE, TRANSFORM_OT_tosphere},
{OP_RESIZE, TFM_RESIZE, TRANSFORM_OT_resize},
{OP_SKIN_RESIZE, TFM_SKIN_RESIZE, TRANSFORM_OT_skin_resize},
{OP_SHEAR, TFM_SHEAR, TRANSFORM_OT_shear},
{OP_BEND, TFM_BEND, TRANSFORM_OT_bend},
{OP_SHRINK_FATTEN, TFM_SHRINKFATTEN, TRANSFORM_OT_shrink_fatten},
{OP_PUSH_PULL, TFM_PUSHPULL, TRANSFORM_OT_push_pull},
{OP_TILT, TFM_TILT, TRANSFORM_OT_tilt},
{OP_TRACKBALL, TFM_TRACKBALL, TRANSFORM_OT_trackball},
{OP_MIRROR, TFM_MIRROR, TRANSFORM_OT_mirror},
{OP_BONE_SIZE, TFM_BONESIZE, TRANSFORM_OT_bbone_resize},
{OP_EDGE_SLIDE, TFM_EDGE_SLIDE, TRANSFORM_OT_edge_slide},
{OP_VERT_SLIDE, TFM_VERT_SLIDE, TRANSFORM_OT_vert_slide},
{OP_EDGE_CREASE, TFM_CREASE, TRANSFORM_OT_edge_crease},
{OP_EDGE_BWEIGHT, TFM_BWEIGHT, TRANSFORM_OT_edge_bevelweight},
{OP_SEQ_SLIDE, TFM_SEQ_SLIDE, TRANSFORM_OT_seq_slide},
{OP_NORMAL_ROTATION, TFM_NORMAL_ROTATION, TRANSFORM_OT_rotate_normal},
{NULL, 0},
};
const EnumPropertyItem rna_enum_transform_mode_types[] = {
{TFM_INIT, "INIT", 0, "Init", ""},
{TFM_DUMMY, "DUMMY", 0, "Dummy", ""},
{TFM_TRANSLATION, "TRANSLATION", 0, "Translation", ""},
{TFM_ROTATION, "ROTATION", 0, "Rotation", ""},
{TFM_RESIZE, "RESIZE", 0, "Resize", ""},
{TFM_SKIN_RESIZE, "SKIN_RESIZE", 0, "Skin Resize", ""},
{TFM_TOSPHERE, "TOSPHERE", 0, "Tosphere", ""},
{TFM_SHEAR, "SHEAR", 0, "Shear", ""},
{TFM_BEND, "BEND", 0, "Bend", ""},
{TFM_SHRINKFATTEN, "SHRINKFATTEN", 0, "Shrinkfatten", ""},
{TFM_TILT, "TILT", 0, "Tilt", ""},
{TFM_TRACKBALL, "TRACKBALL", 0, "Trackball", ""},
{TFM_PUSHPULL, "PUSHPULL", 0, "Pushpull", ""},
{TFM_CREASE, "CREASE", 0, "Crease", ""},
{TFM_MIRROR, "MIRROR", 0, "Mirror", ""},
{TFM_BONESIZE, "BONE_SIZE", 0, "Bonesize", ""},
{TFM_BONE_ENVELOPE, "BONE_ENVELOPE", 0, "Bone Envelope", ""},
{TFM_BONE_ENVELOPE_DIST, "BONE_ENVELOPE_DIST", 0, "Bone Envelope Distance", ""},
{TFM_CURVE_SHRINKFATTEN, "CURVE_SHRINKFATTEN", 0, "Curve Shrinkfatten", ""},
{TFM_MASK_SHRINKFATTEN, "MASK_SHRINKFATTEN", 0, "Mask Shrinkfatten", ""},
{TFM_GPENCIL_SHRINKFATTEN, "GPENCIL_SHRINKFATTEN", 0, "GPencil Shrinkfatten", ""},
{TFM_BONE_ROLL, "BONE_ROLL", 0, "Bone Roll", ""},
{TFM_TIME_TRANSLATE, "TIME_TRANSLATE", 0, "Time Translate", ""},
{TFM_TIME_SLIDE, "TIME_SLIDE", 0, "Time Slide", ""},
{TFM_TIME_SCALE, "TIME_SCALE", 0, "Time Scale", ""},
{TFM_TIME_EXTEND, "TIME_EXTEND", 0, "Time Extend", ""},
{TFM_BAKE_TIME, "BAKE_TIME", 0, "Bake Time", ""},
{TFM_BWEIGHT, "BWEIGHT", 0, "Bweight", ""},
{TFM_ALIGN, "ALIGN", 0, "Align", ""},
{TFM_EDGE_SLIDE, "EDGESLIDE", 0, "Edge Slide", ""},
{TFM_SEQ_SLIDE, "SEQSLIDE", 0, "Sequence Slide", ""},
{TFM_GPENCIL_OPACITY, "GPENCIL_OPACITY", 0, "GPencil Opacity", ""},
{0, NULL, 0, NULL, NULL},
};
static int select_orientation_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
View3D *v3d = CTX_wm_view3d(C);
int orientation = RNA_enum_get(op->ptr, "orientation");
BKE_scene_orientation_slot_set_index(&scene->orientation_slots[SCE_ORIENT_DEFAULT], orientation);
WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, NULL);
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d);
struct wmMsgBus *mbus = CTX_wm_message_bus(C);
WM_msg_publish_rna_prop(mbus, &scene->id, scene, TransformOrientationSlot, type);
return OPERATOR_FINISHED;
}
static int select_orientation_invoke(bContext *C,
wmOperator *UNUSED(op),
const wmEvent *UNUSED(event))
{
uiPopupMenu *pup;
uiLayout *layout;
pup = UI_popup_menu_begin(C, IFACE_("Orientation"), ICON_NONE);
layout = UI_popup_menu_layout(pup);
uiItemsEnumO(layout, "TRANSFORM_OT_select_orientation", "orientation");
UI_popup_menu_end(C, pup);
return OPERATOR_INTERFACE;
}
static void TRANSFORM_OT_select_orientation(struct wmOperatorType *ot)
{
PropertyRNA *prop;
/* identifiers */
ot->name = "Select Orientation";
ot->description = "Select transformation orientation";
ot->idname = "TRANSFORM_OT_select_orientation";
ot->flag = OPTYPE_UNDO;
/* api callbacks */
ot->invoke = select_orientation_invoke;
ot->exec = select_orientation_exec;
ot->poll = ED_operator_view3d_active;
prop = RNA_def_property(ot->srna, "orientation", PROP_ENUM, PROP_NONE);
RNA_def_property_ui_text(prop, "Orientation", "Transformation orientation");
RNA_def_enum_funcs(prop, rna_TransformOrientation_itemf);
}
static int delete_orientation_exec(bContext *C, wmOperator *UNUSED(op))
{
Scene *scene = CTX_data_scene(C);
BIF_removeTransformOrientationIndex(C,
scene->orientation_slots[SCE_ORIENT_DEFAULT].index_custom);
WM_event_add_notifier(C, NC_SCENE | NA_EDITED, scene);
struct wmMsgBus *mbus = CTX_wm_message_bus(C);
WM_msg_publish_rna_prop(mbus, &scene->id, scene, Scene, transform_orientation_slots);
return OPERATOR_FINISHED;
}
static int delete_orientation_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
return delete_orientation_exec(C, op);
}
static bool delete_orientation_poll(bContext *C)
{
if (ED_operator_areaactive(C) == 0) {
return 0;
}
Scene *scene = CTX_data_scene(C);
return ((scene->orientation_slots[SCE_ORIENT_DEFAULT].type >= V3D_ORIENT_CUSTOM) &&
(scene->orientation_slots[SCE_ORIENT_DEFAULT].index_custom != -1));
}
static void TRANSFORM_OT_delete_orientation(struct wmOperatorType *ot)
{
/* identifiers */
ot->name = "Delete Orientation";
ot->description = "Delete transformation orientation";
ot->idname = "TRANSFORM_OT_delete_orientation";
ot->flag = OPTYPE_UNDO;
/* api callbacks */
ot->invoke = delete_orientation_invoke;
ot->exec = delete_orientation_exec;
ot->poll = delete_orientation_poll;
}
static int create_orientation_exec(bContext *C, wmOperator *op)
{
char name[MAX_NAME];
const bool use = RNA_boolean_get(op->ptr, "use");
const bool overwrite = RNA_boolean_get(op->ptr, "overwrite");
const bool use_view = RNA_boolean_get(op->ptr, "use_view");
View3D *v3d = CTX_wm_view3d(C);
Scene *scene = CTX_data_scene(C);
RNA_string_get(op->ptr, "name", name);
if (use && !v3d) {
BKE_report(op->reports,
RPT_ERROR,
"Create Orientation's 'use' parameter only valid in a 3DView context");
return OPERATOR_CANCELLED;
}
if (!BIF_createTransformOrientation(C, op->reports, name, use_view, use, overwrite)) {
BKE_report(op->reports, RPT_ERROR, "Unable to create orientation");
return OPERATOR_CANCELLED;
}
if (use) {
struct wmMsgBus *mbus = CTX_wm_message_bus(C);
WM_msg_publish_rna_prop(mbus, &scene->id, scene, Scene, transform_orientation_slots);
WM_event_add_notifier(C, NC_SCENE | NA_EDITED, scene);
}
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d);
return OPERATOR_FINISHED;
}
static void TRANSFORM_OT_create_orientation(struct wmOperatorType *ot)
{
/* identifiers */
ot->name = "Create Orientation";
ot->description = "Create transformation orientation from selection";
ot->idname = "TRANSFORM_OT_create_orientation";
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* api callbacks */
ot->exec = create_orientation_exec;
ot->poll = ED_operator_areaactive;
RNA_def_string(ot->srna, "name", NULL, MAX_NAME, "Name", "Name of the new custom orientation");
RNA_def_boolean(
ot->srna,
"use_view",
false,
"Use View",
"Use the current view instead of the active object to create the new orientation");
WM_operatortype_props_advanced_begin(ot);
RNA_def_boolean(
ot->srna, "use", false, "Use After Creation", "Select orientation after its creation");
RNA_def_boolean(ot->srna,
"overwrite",
false,
"Overwrite Previous",
"Overwrite previously created orientation with same name");
}
#ifdef USE_LOOPSLIDE_HACK
/**
* Special hack for MESH_OT_loopcut_slide so we get back to the selection mode
*/
static void transformops_loopsel_hack(bContext *C, wmOperator *op)
{
if (op->type->idname == OP_EDGE_SLIDE) {
if (op->opm && op->opm->opm && op->opm->opm->prev) {
wmOperator *op_prev = op->opm->opm->prev;
Scene *scene = CTX_data_scene(C);
bool mesh_select_mode[3];
PropertyRNA *prop = RNA_struct_find_property(op_prev->ptr, "mesh_select_mode_init");
if (prop && RNA_property_is_set(op_prev->ptr, prop)) {
ToolSettings *ts = scene->toolsettings;
short selectmode_orig;
RNA_property_boolean_get_array(op_prev->ptr, prop, mesh_select_mode);
selectmode_orig = ((mesh_select_mode[0] ? SCE_SELECT_VERTEX : 0) |
(mesh_select_mode[1] ? SCE_SELECT_EDGE : 0) |
(mesh_select_mode[2] ? SCE_SELECT_FACE : 0));
/* still switch if we were originally in face select mode */
if ((ts->selectmode != selectmode_orig) && (selectmode_orig != SCE_SELECT_FACE)) {
Object *obedit = CTX_data_edit_object(C);
BMEditMesh *em = BKE_editmesh_from_object(obedit);
em->selectmode = ts->selectmode = selectmode_orig;
EDBM_selectmode_set(em);
}
}
}
}
}
#else
/* prevent removal by cleanup */
# error "loopslide hack removed!"
#endif /* USE_LOOPSLIDE_HACK */
static void transformops_exit(bContext *C, wmOperator *op)
{
#ifdef USE_LOOPSLIDE_HACK
transformops_loopsel_hack(C, op);
#endif
saveTransform(C, op->customdata, op);
MEM_freeN(op->customdata);
op->customdata = NULL;
G.moving = 0;
}
static int transformops_data(bContext *C, wmOperator *op, const wmEvent *event)
{
int retval = 1;
if (op->customdata == NULL) {
TransInfo *t = MEM_callocN(sizeof(TransInfo), "TransInfo data2");
TransformModeItem *tmode;
int mode = -1;
for (tmode = transform_modes; tmode->idname; tmode++) {
if (op->type->idname == tmode->idname) {
mode = tmode->mode;
break;
}
}
if (mode == -1) {
mode = RNA_enum_get(op->ptr, "mode");
}
retval = initTransform(C, t, op, event, mode);
/* store data */
if (retval) {
G.moving = special_transform_moving(t);
op->customdata = t;
}
else {
MEM_freeN(t);
}
}
return retval; /* return 0 on error */
}
static int transform_modal(bContext *C, wmOperator *op, const wmEvent *event)
{
int exit_code;
TransInfo *t = op->customdata;
const enum TfmMode mode_prev = t->mode;
#if defined(WITH_INPUT_NDOF) && 0
/* Stable 2D mouse coords map to different 3D coords while the 3D mouse is active
* in other words, 2D deltas are no longer good enough!
* disable until individual 'transformers' behave better. */
if (event->type == NDOF_MOTION) {
return OPERATOR_PASS_THROUGH;
}
#endif
/* XXX insert keys are called here, and require context */
t->context = C;
exit_code = transformEvent(t, event);
t->context = NULL;
/* XXX, workaround: active needs to be calculated before transforming,
* since we're not reading from 'td->center' in this case. see: T40241 */
if (t->tsnap.target == SCE_SNAP_TARGET_ACTIVE) {
/* In camera view, tsnap callback is not set
* (see initSnappingMode() in transfrom_snap.c, and T40348). */
if (t->tsnap.targetSnap && ((t->tsnap.status & TARGET_INIT) == 0)) {
t->tsnap.targetSnap(t);
}
}
transformApply(C, t);
exit_code |= transformEnd(C, t);
if ((exit_code & OPERATOR_RUNNING_MODAL) == 0) {
transformops_exit(C, op);
exit_code &= ~OPERATOR_PASS_THROUGH; /* preventively remove passthrough */
}
else {
if (mode_prev != t->mode) {
/* WARNING: this is not normal to switch operator types
* normally it would not be supported but transform happens
* to share callbacks between different operators. */
wmOperatorType *ot_new = NULL;
TransformModeItem *item = transform_modes;
while (item->idname) {
if (item->mode == t->mode) {
ot_new = WM_operatortype_find(item->idname, false);
break;
}
item++;
}
BLI_assert(ot_new != NULL);
if (ot_new) {
WM_operator_type_set(op, ot_new);
}
/* end suspicious code */
}
}
return exit_code;
}
static void transform_cancel(bContext *C, wmOperator *op)
{
TransInfo *t = op->customdata;
t->state = TRANS_CANCEL;
transformEnd(C, t);
transformops_exit(C, op);
}
static int transform_exec(bContext *C, wmOperator *op)
{
TransInfo *t;
if (!transformops_data(C, op, NULL)) {
G.moving = 0;
return OPERATOR_CANCELLED;
}
t = op->customdata;
t->options |= CTX_AUTOCONFIRM;
transformApply(C, t);
transformEnd(C, t);
transformops_exit(C, op);
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
return OPERATOR_FINISHED;
}
static int transform_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
if (!transformops_data(C, op, event)) {
G.moving = 0;
return OPERATOR_CANCELLED;
}
/* When modal, allow 'value' to set initial offset. */
if ((event == NULL) && RNA_struct_property_is_set(op->ptr, "value")) {
return transform_exec(C, op);
}
/* add temp handler */
WM_event_add_modal_handler(C, op);
op->flag |= OP_IS_MODAL_GRAB_CURSOR; /* XXX maybe we want this with the gizmo only? */
/* Use when modal input has some transformation to begin with. */
TransInfo *t = op->customdata;
if (UNLIKELY(!is_zero_v4(t->values_modal_offset))) {
transformApply(C, t);
}
return OPERATOR_RUNNING_MODAL;
}
static bool transform_poll_property(const bContext *UNUSED(C),
wmOperator *op,
const PropertyRNA *prop)
{
const char *prop_id = RNA_property_identifier(prop);
/* Orientation/Constraints. */
{
/* Hide orientation axis if no constraints are set, since it wont be used. */
PropertyRNA *prop_con = RNA_struct_find_property(op->ptr, "orient_type");
if (!ELEM(prop_con, NULL, prop)) {
if (STRPREFIX(prop_id, "constraint")) {
/* Special case: show constraint axis if we don't have values,
* needed for mirror operator. */
if (STREQ(prop_id, "constraint_axis") &&
(RNA_struct_find_property(op->ptr, "value") == NULL)) {
return true;
}
return false;
}
}
}
/* Proportional Editing. */
{
PropertyRNA *prop_pet = RNA_struct_find_property(op->ptr, "use_proportional_edit");
if (prop_pet && (prop_pet != prop) && (RNA_property_boolean_get(op->ptr, prop_pet) == false)) {
if (STRPREFIX(prop_id, "proportional") || STRPREFIX(prop_id, "use_proportional")) {
return false;
}
}
}
return true;
}
void Transform_Properties(struct wmOperatorType *ot, int flags)
{
PropertyRNA *prop;
if (flags & P_ORIENT_AXIS) {
prop = RNA_def_property(ot->srna, "orient_axis", PROP_ENUM, PROP_NONE);
RNA_def_property_ui_text(prop, "Axis", "");
RNA_def_property_enum_default(prop, 2);
RNA_def_property_enum_items(prop, rna_enum_axis_xyz_items);
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}
if (flags & P_ORIENT_AXIS_ORTHO) {
prop = RNA_def_property(ot->srna, "orient_axis_ortho", PROP_ENUM, PROP_NONE);
RNA_def_property_ui_text(prop, "Axis Ortho", "");
RNA_def_property_enum_default(prop, 0);
RNA_def_property_enum_items(prop, rna_enum_axis_xyz_items);
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}
if (flags & P_ORIENT_MATRIX) {
prop = RNA_def_property(ot->srna, "orient_type", PROP_ENUM, PROP_NONE);
RNA_def_property_ui_text(prop, "Orientation", "Transformation orientation");
RNA_def_enum_funcs(prop, rna_TransformOrientation_itemf);
/* Set by 'orient_type' or gizmo which acts on non-standard orientation. */
prop = RNA_def_float_matrix(
ot->srna, "orient_matrix", 3, 3, NULL, 0.0f, 0.0f, "Matrix", "", 0.0f, 0.0f);
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
/* Only use 'orient_matrix' when 'orient_matrix_type == orient_type',
* this allows us to reuse the orientation set by a gizmo for eg, without disabling the ability
* to switch over to other orientations. */
prop = RNA_def_property(ot->srna, "orient_matrix_type", PROP_ENUM, PROP_NONE);
RNA_def_property_ui_text(prop, "Matrix Orientation", "");
RNA_def_enum_funcs(prop, rna_TransformOrientation_itemf);
RNA_def_property_flag(prop, PROP_HIDDEN);
}
if (flags & P_CONSTRAINT) {
RNA_def_boolean_vector(ot->srna, "constraint_axis", 3, NULL, "Constraint Axis", "");
}
if (flags & P_MIRROR) {
prop = RNA_def_boolean(ot->srna, "mirror", 0, "Mirror Editing", "");
if (flags & P_MIRROR_DUMMY) {
/* only used so macros can disable this option */
RNA_def_property_flag(prop, PROP_HIDDEN);
}
}
if (flags & P_PROPORTIONAL) {
RNA_def_boolean(ot->srna, "use_proportional_edit", 0, "Proportional Editing", "");
prop = RNA_def_enum(ot->srna,
"proportional_edit_falloff",
rna_enum_proportional_falloff_items,
0,
"Proportional Falloff",
"Falloff type for proportional editing mode");
/* Abusing id_curve :/ */
RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_CURVE);
RNA_def_float(ot->srna,
"proportional_size",
1,
T_PROP_SIZE_MIN,
T_PROP_SIZE_MAX,
"Proportional Size",
"",
0.001f,
100.0f);
RNA_def_boolean(ot->srna, "use_proportional_connected", 0, "Connected", "");
RNA_def_boolean(ot->srna, "use_proportional_projected", 0, "Projected (2D)", "");
}
if (flags & P_SNAP) {
prop = RNA_def_boolean(ot->srna, "snap", 0, "Use Snapping Options", "");
RNA_def_property_flag(prop, PROP_HIDDEN);
if (flags & P_GEO_SNAP) {
prop = RNA_def_enum(ot->srna, "snap_target", rna_enum_snap_target_items, 0, "Target", "");
RNA_def_property_flag(prop, PROP_HIDDEN);
prop = RNA_def_float_vector(
ot->srna, "snap_point", 3, NULL, -FLT_MAX, FLT_MAX, "Point", "", -FLT_MAX, FLT_MAX);
RNA_def_property_flag(prop, PROP_HIDDEN);
if (flags & P_ALIGN_SNAP) {
prop = RNA_def_boolean(ot->srna, "snap_align", 0, "Align with Point Normal", "");
RNA_def_property_flag(prop, PROP_HIDDEN);
prop = RNA_def_float_vector(
ot->srna, "snap_normal", 3, NULL, -FLT_MAX, FLT_MAX, "Normal", "", -FLT_MAX, FLT_MAX);
RNA_def_property_flag(prop, PROP_HIDDEN);
}
}
}
if (flags & P_GPENCIL_EDIT) {
prop = RNA_def_boolean(ot->srna,
"gpencil_strokes",
0,
"Edit Grease Pencil",
"Edit selected Grease Pencil strokes");
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
}
if (flags & P_CURSOR_EDIT) {
prop = RNA_def_boolean(ot->srna, "cursor_transform", 0, "Transform Cursor", "");
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
}
if ((flags & P_OPTIONS) && !(flags & P_NO_TEXSPACE)) {
prop = RNA_def_boolean(
ot->srna, "texture_space", 0, "Edit Texture Space", "Edit Object data texture space");
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
prop = RNA_def_boolean(
ot->srna, "remove_on_cancel", 0, "Remove on Cancel", "Remove elements on cancel");
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
}
if (flags & P_CORRECT_UV) {
RNA_def_boolean(
ot->srna, "correct_uv", true, "Correct UVs", "Correct UV coordinates when transforming");
}
if (flags & P_CENTER) {
/* For gizmos that define their own center. */
prop = RNA_def_property(ot->srna, "center_override", PROP_FLOAT, PROP_XYZ);
RNA_def_property_array(prop, 3);
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
RNA_def_property_ui_text(prop, "Center Override", "Force using this center value (when set)");
}
if ((flags & P_NO_DEFAULTS) == 0) {
prop = RNA_def_boolean(ot->srna,
"release_confirm",
0,
"Confirm on Release",
"Always confirm operation when releasing button");
RNA_def_property_flag(prop, PROP_HIDDEN);
prop = RNA_def_boolean(ot->srna, "use_accurate", 0, "Accurate", "Use accurate transformation");
RNA_def_property_flag(prop, PROP_HIDDEN);
}
if (flags & P_POST_TRANSFORM) {
prop = RNA_def_boolean(ot->srna,
"use_automerge_and_split",
0,
"Auto Merge & Split",
"Forces the use of Auto Merge & Split");
RNA_def_property_flag(prop, PROP_HIDDEN);
}
}
static void TRANSFORM_OT_translate(struct wmOperatorType *ot)
{
/* identifiers */
ot->name = "Move";
ot->description = "Move selected items";
ot->idname = OP_TRANSLATION;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
/* api callbacks */
ot->invoke = transform_invoke;
ot->exec = transform_exec;
ot->modal = transform_modal;
ot->cancel = transform_cancel;
ot->poll = ED_operator_screenactive;
ot->poll_property = transform_poll_property;
RNA_def_float_translation(
ot->srna, "value", 3, NULL, -FLT_MAX, FLT_MAX, "Move", "", -FLT_MAX, FLT_MAX);
WM_operatortype_props_advanced_begin(ot);
Transform_Properties(ot,
P_ORIENT_MATRIX | P_CONSTRAINT | P_PROPORTIONAL | P_MIRROR | P_ALIGN_SNAP |
P_OPTIONS | P_GPENCIL_EDIT | P_CURSOR_EDIT | P_POST_TRANSFORM);
}
static void TRANSFORM_OT_resize(struct wmOperatorType *ot)
{
/* identifiers */
ot->name = "Resize";
ot->description = "Scale (resize) selected items";
ot->idname = OP_RESIZE;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
/* api callbacks */
ot->invoke = transform_invoke;
ot->exec = transform_exec;
ot->modal = transform_modal;
ot->cancel = transform_cancel;
ot->poll = ED_operator_screenactive;
ot->poll_property = transform_poll_property;
RNA_def_float_vector(
ot->srna, "value", 3, VecOne, -FLT_MAX, FLT_MAX, "Scale", "", -FLT_MAX, FLT_MAX);
WM_operatortype_props_advanced_begin(ot);
Transform_Properties(ot,
P_ORIENT_MATRIX | P_CONSTRAINT | P_PROPORTIONAL | P_MIRROR | P_GEO_SNAP |
P_OPTIONS | P_GPENCIL_EDIT | P_CENTER);
}
static void TRANSFORM_OT_skin_resize(struct wmOperatorType *ot)
{
/* identifiers */
ot->name = "Skin Resize";
ot->description = "Scale selected vertices' skin radii";
ot->idname = OP_SKIN_RESIZE;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
/* api callbacks */
ot->invoke = transform_invoke;
ot->exec = transform_exec;
ot->modal = transform_modal;
ot->cancel = transform_cancel;
ot->poll = ED_operator_editmesh;
ot->poll_property = transform_poll_property;
RNA_def_float_vector(
ot->srna, "value", 3, VecOne, -FLT_MAX, FLT_MAX, "Scale", "", -FLT_MAX, FLT_MAX);
WM_operatortype_props_advanced_begin(ot);
Transform_Properties(ot,
P_ORIENT_MATRIX | P_CONSTRAINT | P_PROPORTIONAL | P_MIRROR | P_GEO_SNAP |
P_OPTIONS | P_NO_TEXSPACE);
}
static void TRANSFORM_OT_trackball(struct wmOperatorType *ot)
{
/* identifiers */
ot->name = "Trackball";
ot->description = "Trackball style rotation of selected items";
ot->idname = OP_TRACKBALL;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
/* api callbacks */
ot->invoke = transform_invoke;
ot->exec = transform_exec;
ot->modal = transform_modal;
ot->cancel = transform_cancel;
ot->poll = ED_operator_screenactive;
ot->poll_property = transform_poll_property;
/* Maybe we could use float_vector_xyz here too? */
RNA_def_float_rotation(
ot->srna, "value", 2, NULL, -FLT_MAX, FLT_MAX, "Angle", "", -FLT_MAX, FLT_MAX);
WM_operatortype_props_advanced_begin(ot);
Transform_Properties(ot, P_PROPORTIONAL | P_MIRROR | P_SNAP | P_GPENCIL_EDIT | P_CENTER);
}
/* Similar to #transform_shear_poll. */
static bool transform_rotate_poll(bContext *C)
{
if (!ED_operator_screenactive(C)) {
return false;
}
ScrArea *area = CTX_wm_area(C);
return area && !ELEM(area->spacetype, SPACE_ACTION);
}
static void TRANSFORM_OT_rotate(struct wmOperatorType *ot)
{
/* identifiers */
ot->name = "Rotate";
ot->description = "Rotate selected items";
ot->idname = OP_ROTATION;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
/* api callbacks */
ot->invoke = transform_invoke;
ot->exec = transform_exec;
ot->modal = transform_modal;
ot->cancel = transform_cancel;
ot->poll = transform_rotate_poll;
ot->poll_property = transform_poll_property;
RNA_def_float_rotation(
ot->srna, "value", 0, NULL, -FLT_MAX, FLT_MAX, "Angle", "", -M_PI * 2, M_PI * 2);
WM_operatortype_props_advanced_begin(ot);
Transform_Properties(ot,
P_ORIENT_AXIS | P_ORIENT_MATRIX | P_CONSTRAINT | P_PROPORTIONAL | P_MIRROR |
P_GEO_SNAP | P_GPENCIL_EDIT | P_CENTER);
}
static void TRANSFORM_OT_tilt(struct wmOperatorType *ot)
{
/* identifiers */
ot->name = "Tilt";
/* optional -
* "Tilt selected vertices"
* "Specify an extra axis rotation for selected vertices of 3D curve" */
ot->description = "Tilt selected control vertices of 3D curve";
ot->idname = OP_TILT;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
/* api callbacks */
ot->invoke = transform_invoke;
ot->exec = transform_exec;
ot->modal = transform_modal;
ot->cancel = transform_cancel;
ot->poll = ED_operator_editcurve_3d;
ot->poll_property = transform_poll_property;
RNA_def_float_rotation(
ot->srna, "value", 0, NULL, -FLT_MAX, FLT_MAX, "Angle", "", -M_PI * 2, M_PI * 2);
WM_operatortype_props_advanced_begin(ot);
Transform_Properties(ot, P_PROPORTIONAL | P_MIRROR | P_SNAP);
}
static void TRANSFORM_OT_bend(struct wmOperatorType *ot)
{
/* identifiers */
ot->name = "Bend";
ot->description = "Bend selected items between the 3D cursor and the mouse";
ot->idname = OP_BEND;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
/* api callbacks */
ot->invoke = transform_invoke;
// ot->exec = transform_exec; /* unsupported */
ot->modal = transform_modal;
ot->cancel = transform_cancel;
ot->poll = ED_operator_region_view3d_active;
ot->poll_property = transform_poll_property;
RNA_def_float_rotation(
ot->srna, "value", 1, NULL, -FLT_MAX, FLT_MAX, "Angle", "", -M_PI * 2, M_PI * 2);
WM_operatortype_props_advanced_begin(ot);
Transform_Properties(ot, P_PROPORTIONAL | P_MIRROR | P_SNAP | P_GPENCIL_EDIT | P_CENTER);
}
/* Similar to #transform_rotate_poll. */
static bool transform_shear_poll(bContext *C)
{
if (!ED_operator_screenactive(C)) {
return false;
}
ScrArea *area = CTX_wm_area(C);
return area && !ELEM(area->spacetype, SPACE_ACTION);
}
static void TRANSFORM_OT_shear(struct wmOperatorType *ot)
{
/* identifiers */
ot->name = "Shear";
ot->description = "Shear selected items along the horizontal screen axis";
ot->idname = OP_SHEAR;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
/* api callbacks */
ot->invoke = transform_invoke;
ot->exec = transform_exec;
ot->modal = transform_modal;
ot->cancel = transform_cancel;
ot->poll = transform_shear_poll;
ot->poll_property = transform_poll_property;
RNA_def_float(ot->srna, "value", 0, -FLT_MAX, FLT_MAX, "Offset", "", -FLT_MAX, FLT_MAX);
WM_operatortype_props_advanced_begin(ot);
Transform_Properties(ot,
P_ORIENT_AXIS | P_ORIENT_AXIS_ORTHO | P_ORIENT_MATRIX | P_PROPORTIONAL |
P_MIRROR | P_SNAP | P_GPENCIL_EDIT);
}
static void TRANSFORM_OT_push_pull(struct wmOperatorType *ot)
{
/* identifiers */
ot->name = "Push/Pull";
ot->description = "Push/Pull selected items";
ot->idname = OP_PUSH_PULL;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
/* api callbacks */
ot->invoke = transform_invoke;
ot->exec = transform_exec;
ot->modal = transform_modal;
ot->cancel = transform_cancel;
ot->poll = ED_operator_screenactive;
ot->poll_property = transform_poll_property;
RNA_def_float(ot->srna, "value", 0, -FLT_MAX, FLT_MAX, "Distance", "", -FLT_MAX, FLT_MAX);
WM_operatortype_props_advanced_begin(ot);
Transform_Properties(ot, P_PROPORTIONAL | P_MIRROR | P_SNAP | P_CENTER);
}
static void TRANSFORM_OT_shrink_fatten(struct wmOperatorType *ot)
{
/* identifiers */
ot->name = "Shrink/Fatten";
ot->description = "Shrink/fatten selected vertices along normals";
ot->idname = OP_SHRINK_FATTEN;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
/* api callbacks */
ot->invoke = transform_invoke;
ot->exec = transform_exec;
ot->modal = transform_modal;
ot->cancel = transform_cancel;
ot->poll = ED_operator_editmesh;
ot->poll_property = transform_poll_property;
RNA_def_float_distance(ot->srna, "value", 0, -FLT_MAX, FLT_MAX, "Offset", "", -FLT_MAX, FLT_MAX);
RNA_def_boolean(ot->srna,
"use_even_offset",
false,
"Offset Even",
"Scale the offset to give more even thickness");
WM_operatortype_props_advanced_begin(ot);
Transform_Properties(ot, P_PROPORTIONAL | P_MIRROR | P_SNAP);
}
static void TRANSFORM_OT_tosphere(struct wmOperatorType *ot)
{
/* identifiers */
ot->name = "To Sphere";
ot->description = "Move selected items outward in a spherical shape around geometric center";
ot->idname = OP_TOSPHERE;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
/* api callbacks */
ot->invoke = transform_invoke;
ot->exec = transform_exec;
ot->modal = transform_modal;
ot->cancel = transform_cancel;
ot->poll = ED_operator_screenactive;
ot->poll_property = transform_poll_property;
RNA_def_float_factor(ot->srna, "value", 0, 0, 1, "Factor", "", 0, 1);
WM_operatortype_props_advanced_begin(ot);
Transform_Properties(ot, P_PROPORTIONAL | P_MIRROR | P_SNAP | P_GPENCIL_EDIT | P_CENTER);
}
static void TRANSFORM_OT_mirror(struct wmOperatorType *ot)
{
/* identifiers */
ot->name = "Mirror";
ot->description = "Mirror selected items around one or more axes";
ot->idname = OP_MIRROR;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
/* api callbacks */
ot->invoke = transform_invoke;
ot->exec = transform_exec;
ot->modal = transform_modal;
ot->cancel = transform_cancel;
ot->poll = ED_operator_screenactive;
ot->poll_property = transform_poll_property;
Transform_Properties(
ot, P_ORIENT_MATRIX | P_CONSTRAINT | P_PROPORTIONAL | P_GPENCIL_EDIT | P_CENTER);
}
static void TRANSFORM_OT_bbone_resize(struct wmOperatorType *ot)
{
/* identifiers */
ot->name = "Scale B-Bone";
ot->description = "Scale selected bendy bones display size";
ot->idname = OP_BONE_SIZE;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
/* api callbacks */
ot->invoke = transform_invoke;
ot->exec = transform_exec;
ot->modal = transform_modal;
ot->cancel = transform_cancel;
ot->poll = ED_operator_object_active;
ot->poll_property = transform_poll_property;
RNA_def_float_translation(
ot->srna, "value", 3, VecOne, -FLT_MAX, FLT_MAX, "Display Size", "", -FLT_MAX, FLT_MAX);
WM_operatortype_props_advanced_begin(ot);
Transform_Properties(ot, P_ORIENT_MATRIX | P_CONSTRAINT | P_MIRROR);
}
static void TRANSFORM_OT_edge_slide(struct wmOperatorType *ot)
{
PropertyRNA *prop;
/* identifiers */
ot->name = "Edge Slide";
ot->description = "Slide an edge loop along a mesh";
ot->idname = OP_EDGE_SLIDE;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
/* api callbacks */
ot->invoke = transform_invoke;
ot->exec = transform_exec;
ot->modal = transform_modal;
ot->cancel = transform_cancel;
ot->poll = ED_operator_editmesh_region_view3d;
ot->poll_property = transform_poll_property;
RNA_def_float_factor(ot->srna, "value", 0, -10.0f, 10.0f, "Factor", "", -1.0f, 1.0f);
prop = RNA_def_boolean(ot->srna, "single_side", false, "Single Side", "");
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
RNA_def_boolean(ot->srna,
"use_even",
false,
"Even",
"Make the edge loop match the shape of the adjacent edge loop");
WM_operatortype_props_advanced_begin(ot);
RNA_def_boolean(ot->srna,
"flipped",
false,
"Flipped",
"When Even mode is active, flips between the two adjacent edge loops");
RNA_def_boolean(ot->srna, "use_clamp", true, "Clamp", "Clamp within the edge extents");
Transform_Properties(ot, P_MIRROR | P_SNAP | P_CORRECT_UV);
}
static void TRANSFORM_OT_vert_slide(struct wmOperatorType *ot)
{
/* identifiers */
ot->name = "Vertex Slide";
ot->description = "Slide a vertex along a mesh";
ot->idname = OP_VERT_SLIDE;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
/* api callbacks */
ot->invoke = transform_invoke;
ot->exec = transform_exec;
ot->modal = transform_modal;
ot->cancel = transform_cancel;
ot->poll = ED_operator_editmesh_region_view3d;
ot->poll_property = transform_poll_property;
RNA_def_float_factor(ot->srna, "value", 0, -10.0f, 10.0f, "Factor", "", -1.0f, 1.0f);
RNA_def_boolean(ot->srna,
"use_even",
false,
"Even",
"Make the edge loop match the shape of the adjacent edge loop");
WM_operatortype_props_advanced_begin(ot);
RNA_def_boolean(ot->srna,
"flipped",
false,
"Flipped",
"When Even mode is active, flips between the two adjacent edge loops");
RNA_def_boolean(ot->srna, "use_clamp", true, "Clamp", "Clamp within the edge extents");
Transform_Properties(ot, P_MIRROR | P_SNAP | P_CORRECT_UV);
}
static void TRANSFORM_OT_edge_crease(struct wmOperatorType *ot)
{
/* identifiers */
ot->name = "Edge Crease";
ot->description = "Change the crease of edges";
ot->idname = OP_EDGE_CREASE;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
/* api callbacks */
ot->invoke = transform_invoke;
ot->exec = transform_exec;
ot->modal = transform_modal;
ot->cancel = transform_cancel;
ot->poll = ED_operator_editmesh;
ot->poll_property = transform_poll_property;
RNA_def_float_factor(ot->srna, "value", 0, -1.0f, 1.0f, "Factor", "", -1.0f, 1.0f);
WM_operatortype_props_advanced_begin(ot);
Transform_Properties(ot, P_SNAP);
}
static void TRANSFORM_OT_edge_bevelweight(struct wmOperatorType *ot)
{
/* identifiers */
ot->name = "Edge Bevel Weight";
ot->description = "Change the bevel weight of edges";
ot->idname = OP_EDGE_BWEIGHT;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
/* api callbacks */
ot->invoke = transform_invoke;
ot->exec = transform_exec;
ot->modal = transform_modal;
ot->cancel = transform_cancel;
ot->poll = ED_operator_editmesh;
RNA_def_float_factor(ot->srna, "value", 0, -1.0f, 1.0f, "Factor", "", -1.0f, 1.0f);
WM_operatortype_props_advanced_begin(ot);
Transform_Properties(ot, P_SNAP);
}
static void TRANSFORM_OT_seq_slide(struct wmOperatorType *ot)
{
/* identifiers */
ot->name = "Sequence Slide";
ot->description = "Slide a sequence strip in time";
ot->idname = OP_SEQ_SLIDE;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
/* api callbacks */
ot->invoke = transform_invoke;
ot->exec = transform_exec;
ot->modal = transform_modal;
ot->cancel = transform_cancel;
ot->poll = ED_operator_sequencer_active;
/* properties */
PropertyRNA *prop;
prop = RNA_def_float_vector(
ot->srna, "value", 2, NULL, -FLT_MAX, FLT_MAX, "Offset", "", -FLT_MAX, FLT_MAX);
RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, 0);
WM_operatortype_props_advanced_begin(ot);
Transform_Properties(ot, P_SNAP);
}
static void TRANSFORM_OT_rotate_normal(struct wmOperatorType *ot)
{
/* identifiers */
ot->name = "Rotate Normals";
ot->description = "Rotate split normal of selected items";
ot->idname = OP_NORMAL_ROTATION;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
/* api callbacks */
ot->invoke = transform_invoke;
ot->exec = transform_exec;
ot->modal = transform_modal;
ot->cancel = transform_cancel;
ot->poll = ED_operator_editmesh;
RNA_def_float_rotation(
ot->srna, "value", 0, NULL, -FLT_MAX, FLT_MAX, "Angle", "", -M_PI * 2, M_PI * 2);
Transform_Properties(ot, P_ORIENT_AXIS | P_ORIENT_MATRIX | P_CONSTRAINT | P_MIRROR);
}
static void TRANSFORM_OT_transform(struct wmOperatorType *ot)
{
PropertyRNA *prop;
/* identifiers */
ot->name = "Transform";
ot->description = "Transform selected items by mode type";
ot->idname = "TRANSFORM_OT_transform";
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
/* api callbacks */
ot->invoke = transform_invoke;
ot->exec = transform_exec;
ot->modal = transform_modal;
ot->cancel = transform_cancel;
ot->poll = ED_operator_screenactive;
ot->poll_property = transform_poll_property;
prop = RNA_def_enum(
ot->srna, "mode", rna_enum_transform_mode_types, TFM_TRANSLATION, "Mode", "");
RNA_def_property_flag(prop, PROP_HIDDEN);
RNA_def_float_vector(
ot->srna, "value", 4, NULL, -FLT_MAX, FLT_MAX, "Values", "", -FLT_MAX, FLT_MAX);
WM_operatortype_props_advanced_begin(ot);
Transform_Properties(ot,
P_ORIENT_AXIS | P_ORIENT_MATRIX | P_CONSTRAINT | P_PROPORTIONAL | P_MIRROR |
P_ALIGN_SNAP | P_GPENCIL_EDIT | P_CENTER);
}
static int transform_from_gizmo_invoke(bContext *C,
wmOperator *UNUSED(op),
const wmEvent *UNUSED(event))
{
bToolRef *tref = WM_toolsystem_ref_from_context(C);
if (tref) {
ARegion *region = CTX_wm_region(C);
wmGizmoMap *gzmap = region->gizmo_map;
wmGizmoGroup *gzgroup = gzmap ? WM_gizmomap_group_find(gzmap, "VIEW3D_GGT_xform_gizmo") : NULL;
if (gzgroup != NULL) {
PointerRNA gzg_ptr;
WM_toolsystem_ref_properties_ensure_from_gizmo_group(tref, gzgroup->type, &gzg_ptr);
const int drag_action = RNA_enum_get(&gzg_ptr, "drag_action");
const char *op_id = NULL;
switch (drag_action) {
case V3D_GIZMO_SHOW_OBJECT_TRANSLATE:
op_id = "TRANSFORM_OT_translate";
break;
case V3D_GIZMO_SHOW_OBJECT_ROTATE:
op_id = "TRANSFORM_OT_rotate";
break;
case V3D_GIZMO_SHOW_OBJECT_SCALE:
op_id = "TRANSFORM_OT_resize";
break;
default:
break;
}
if (op_id) {
wmOperatorType *ot = WM_operatortype_find(op_id, true);
PointerRNA op_ptr;
WM_operator_properties_create_ptr(&op_ptr, ot);
RNA_boolean_set(&op_ptr, "release_confirm", true);
WM_operator_name_call_ptr(C, ot, WM_OP_INVOKE_DEFAULT, &op_ptr);
WM_operator_properties_free(&op_ptr);
return OPERATOR_FINISHED;
}
}
}
return OPERATOR_PASS_THROUGH;
}
/* Use with 'TRANSFORM_GGT_gizmo'. */
static void TRANSFORM_OT_from_gizmo(struct wmOperatorType *ot)
{
/* identifiers */
ot->name = "Transform from Gizmo";
ot->description = "Transform selected items by mode type";
ot->idname = "TRANSFORM_OT_from_gizmo";
ot->flag = 0;
/* api callbacks */
ot->invoke = transform_from_gizmo_invoke;
}
void transform_operatortypes(void)
{
TransformModeItem *tmode;
for (tmode = transform_modes; tmode->idname; tmode++) {
WM_operatortype_append(tmode->opfunc);
}
WM_operatortype_append(TRANSFORM_OT_transform);
WM_operatortype_append(TRANSFORM_OT_select_orientation);
WM_operatortype_append(TRANSFORM_OT_create_orientation);
WM_operatortype_append(TRANSFORM_OT_delete_orientation);
WM_operatortype_append(TRANSFORM_OT_from_gizmo);
}
void ED_keymap_transform(wmKeyConfig *keyconf)
{
wmKeyMap *modalmap = transform_modal_keymap(keyconf);
TransformModeItem *tmode;
for (tmode = transform_modes; tmode->idname; tmode++) {
WM_modalkeymap_assign(modalmap, tmode->idname);
}
WM_modalkeymap_assign(modalmap, "TRANSFORM_OT_transform");
}
|
213367.c | /*******************************************************************************
SYS CLK Static Functions for Clock System Service
Company:
Microchip Technology Inc.
File Name:
plib_clk.c
Summary:
SYS CLK static function implementations for the Clock System Service.
Description:
The Clock System Service provides a simple interface to manage the
oscillators on Microchip microcontrollers. This file defines the static
implementation for the Clock System Service.
Remarks:
Static functions incorporate all system clock configuration settings as
determined by the user via the Microchip Harmony Configurator GUI.
It provides static version of the routines, eliminating the need for an
object ID or object handle.
Static single-open interfaces also eliminate the need for the open handle.
*******************************************************************************/
/*******************************************************************************
* Copyright (C) 2019 Microchip Technology Inc. and its subsidiaries.
*
* Subject to your compliance with these terms, you may use Microchip software
* and any derivatives exclusively with Microchip products. It is your
* responsibility to comply with third party license terms applicable to your
* use of third party software (including open source software) that may
* accompany Microchip software.
*
* THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
* EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED
* WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
* INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
* WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS
* BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE
* FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN
* ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
* THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
*******************************************************************************/
// *****************************************************************************
// *****************************************************************************
// Section: Include Files
// *****************************************************************************
// *****************************************************************************
#include "device.h"
#include "plib_clk.h"
// *****************************************************************************
// *****************************************************************************
// Section: File Scope Functions
// *****************************************************************************
// *****************************************************************************
// *****************************************************************************
/* Function:
void CLK_Initialize( void )
Summary:
Initializes hardware and internal data structure of the System Clock.
Description:
This function initializes the hardware and internal data structure of System
Clock Service.
Remarks:
This is configuration values for the static version of the Clock System
Service module is determined by the user via the MHC GUI.
The objective is to eliminate the user's need to be knowledgeable in the
function of the 'configuration bits' to configure the system oscillators.
*/
void CLK_Initialize( void )
{
/* Default clock setting is used, hence no code is generated */
/* Code for fuse settings can be found in "initialization.c" */
/* Peripheral Module Disable Configuration */
PMD1 = 0x1101;
PMD2 = 0x3;
PMD3 = 0x1f001f;
PMD4 = 0x1f;
PMD5 = 0xfeffffff;
PMD6 = 0xfffffffd;
}
|
889014.c | #include "autopy-key-module.h"
#include "keypress.h"
#include "py-convenience.h"
#include "deadbeef_rand.h"
#include <assert.h>
#include <stdbool.h>
/* Syntax: toggle(key, down_or_up, [modifiers]) */
/* Arguments: |key| => character or integer describing the key or keycode,
|down_or_up| => Boolean describing whether to hold down or
release the key,
|modifiers| => integer (bitwise-OR of |MOD_*| constants) */
/* Description: Holds down the given key or keycode if |down_or_up| is True,
or releases it if not. Integer keycodes and modifiers should
be taken from module constants (e.g., |key.K_DELETE| or
|key.MOD_META|). If the given key is a character, it is
automatically converted to a keycode corresponding to the
current keyboard layout.
To hold down more than one modifier at a time, bitwise-OR them,
e.g.:
{% toggle('a', True, key.MOD_SHIFT | key.MOD_ALT) %} */
static PyObject *key_toggle(PyObject *self, PyObject *args);
/* Syntax: tap(key, [modifiers]) */
/* Arguments: |key| => character or integer,
|modifiers| => integer (bitise-OR of |MOD_*| constants) */
/* Description: Convenience wrapper around `toggle()` that holds down and then
releases the given key and modifiers. */
static PyObject *key_tap(PyObject *self, PyObject *args);
/* Syntax: type_string(string, wpm=0) */
/* Arguments: |string| => ASCII string,
|wpm| => double (Words per minute to type string,
or unlimited if 0) */
/* Description: Attempts to simulate typing a string at the given WPM, or as
fast as possible if the WPM is 0. */
static PyObject *key_type_string(PyObject *self, PyObject *args);
static PyMethodDef KeyMethods[] = {
{"toggle", key_toggle, METH_VARARGS,
"toggle(key, down_or_up, [modifiers]) -> None\n"
"Holds down given key if down_or_up is True, releases if not."},
{"tap", key_tap, METH_VARARGS,
"tap(key, [modifiers]) -> None\n"
"Holds down and then releases the given key."},
{"type_string", key_type_string, METH_VARARGS,
"type_string(string, wpm=0) -> None\n"
"Attempts to type a string at the given WPM, or as fast as possible if\n"
"wpm is 0."},
{NULL, NULL, 0, NULL} /* Sentinel */
};
#ifdef PYTHREE
static struct PyModuleDef keymodule = {
PyModuleDef_HEAD_INIT,
"key",
"autopy module for working with the keyboard",
-1,
KeyMethods
};
#endif
PyMODINIT_FUNC initkey(void)
{
PyObject *mod;
#ifdef PYTHREE
mod = PyModule_Create(&keymodule);
#else
mod = Py_InitModule3("key", KeyMethods,
"autopy module for working with the "
"keyboard");
#endif
if (mod == NULL) return NULL; /* Error */
/* Needed for type_string(). */
deadbeef_srand_time();
/* Add keycode constants for toggle() and tap(). */
if (PyModule_AddIntMacro(mod, MOD_NONE) < 0 ||
PyModule_AddIntMacro(mod, MOD_META) < 0 ||
PyModule_AddIntMacro(mod, MOD_ALT) < 0 ||
PyModule_AddIntMacro(mod, MOD_CONTROL) < 0 ||
PyModule_AddIntMacro(mod, MOD_SHIFT) < 0 ||
PyModule_AddIntMacro(mod, K_BACKSPACE) < 0 ||
PyModule_AddIntMacro(mod, K_DELETE) < 0 ||
PyModule_AddIntMacro(mod, K_RETURN) < 0 ||
PyModule_AddIntMacro(mod, K_ESCAPE) < 0 ||
PyModule_AddIntMacro(mod, K_UP) < 0 ||
PyModule_AddIntMacro(mod, K_DOWN) < 0 ||
PyModule_AddIntMacro(mod, K_RIGHT) < 0 ||
PyModule_AddIntMacro(mod, K_LEFT) < 0 ||
PyModule_AddIntMacro(mod, K_HOME) < 0 ||
PyModule_AddIntMacro(mod, K_END) < 0 ||
PyModule_AddIntMacro(mod, K_PAGEUP) < 0 ||
PyModule_AddIntMacro(mod, K_PAGEDOWN) < 0 ||
PyModule_AddIntMacro(mod, K_F1) < 0 ||
PyModule_AddIntMacro(mod, K_F2) < 0 ||
PyModule_AddIntMacro(mod, K_F3) < 0 ||
PyModule_AddIntMacro(mod, K_F4) < 0 ||
PyModule_AddIntMacro(mod, K_F5) < 0 ||
PyModule_AddIntMacro(mod, K_F6) < 0 ||
PyModule_AddIntMacro(mod, K_F7) < 0 ||
PyModule_AddIntMacro(mod, K_F8) < 0 ||
PyModule_AddIntMacro(mod, K_F9) < 0 ||
PyModule_AddIntMacro(mod, K_F10) < 0 ||
PyModule_AddIntMacro(mod, K_F11) < 0 ||
PyModule_AddIntMacro(mod, K_F12) < 0 ||
PyModule_AddIntMacro(mod, K_META) < 0 ||
PyModule_AddIntMacro(mod, K_ALT) < 0 ||
PyModule_AddIntMacro(mod, K_CONTROL) < 0 ||
PyModule_AddIntMacro(mod, K_SHIFT) < 0 ||
PyModule_AddIntMacro(mod, K_CAPSLOCK) < 0) {
PyErr_SetString(PyExc_ValueError, "Error adding keycode constants");
return NULL;
}
#ifdef PYTHREE
return mod;
#endif
}
#ifdef PYTHREE
PyMODINIT_FUNC PyInit_key(void) { return initkey(); }
#endif
/* Attempts to extract MMKeyCode from PyInt. Returns false and sets error if
* MMKeyCode could not be converted, or returns true if it could. */
static bool MMKeyCodeFromPyInt(PyObject *num, MMKeyCode *val);
/* Attempts to extract char from PyString. Returns false and sets error if
* MMKeyCode could not be converted, or returns true if it could. */
static bool charFromPyString(PyObject *str, char *val);
static PyObject *key_toggle(PyObject *self, PyObject *args)
{
PyObject *key;
PyObject *downBool;
MMKeyFlags flags = MOD_NONE;
if (!PyArg_ParseTuple(args, "OO!|K", &key, &PyBool_Type, &downBool, &flags)) {
return NULL;
}
if (PyNumber_Check(key)) { /* Check for key code */
MMKeyCode code;
if (!MMKeyCodeFromPyInt(key, &code)) return NULL;
toggleKeyCode(code, downBool == Py_True, flags);
} else if (PyUnicode_Check(key)) { /* Check for single-character string */
char c;
if (!charFromPyString(key, &c)) return NULL;
toggleKey(c, downBool == Py_True, flags);
} else {
return Py_SetArgConvertErr("integer<H> or char", 1, key);
}
Py_RETURN_NONE;
}
static PyObject *key_tap(PyObject *self, PyObject *args)
{
PyObject *key;
MMKeyFlags flags = MOD_NONE;
if (!PyArg_ParseTuple(args, "O|I", &key, &flags)) return NULL;
if (PyNumber_Check(key)) { /* Check for key code */
MMKeyCode code;
if (!MMKeyCodeFromPyInt(key, &code)) return NULL;
tapKeyCode(code, flags);
} else if (PyUnicode_Check(key)) { /* Check for single-character string */
char c;
if (!charFromPyString(key, &c)) return NULL;
tapKey(c, flags);
} else {
return Py_SetArgConvertErr("integer<H> or char", 1, key);
}
Py_RETURN_NONE;
}
static PyObject *key_type_string(PyObject *self, PyObject *args)
{
char *str = NULL;
double wpm = 0.0;
if (!PyArg_ParseTuple(args, "s|d", &str, &wpm)) return NULL;
if (wpm == 0.0) {
typeString(str);
} else {
typeStringDelayed(str, WPM_TO_CPM(wpm));
}
Py_RETURN_NONE;
}
/* -- Helper functions -- */
static bool MMKeyCodeFromPyInt(PyObject *num, MMKeyCode *val)
{
long ival;
assert(val != NULL);
if (!PyLong_Check(num) || PyFloat_Check(num)) {
Py_SetConvertErr("integer<H>", num);
return false;
}
ival = PyLong_AsLong(num);
if (ival == -1 && PyErr_Occurred()) {
Py_SetConvertErr("integer<H>", num);
return false;
}
*val = (MMKeyCode)ival;
return true;
}
#ifdef PYTHREE
static bool charFromPyString(PyObject *str, char *val)
{
assert(val != NULL);
if (PyUnicode_GetLength(str) != 1) {
Py_SetConvertErr("char", str);
return false;
} else {
*val = PyUnicode_AsUTF8(str)[0];
return true;
}
}
#else
static bool charFromPyString(PyObject *str, char *val)
{
assert(val != NULL);
if (PyString_Size(str) != 1) {
Py_SetConvertErr("char", str);
return false;
} else {
*val = PyString_AsString(str)[0];
return true;
}
}
#endif
|
372950.c | /* $OpenBSD: display.c,v 1.47 2015/04/03 22:10:29 bcallah Exp $ */
/* This file is in the public domain. */
/*
* The functions in this file handle redisplay. The
* redisplay system knows almost nothing about the editing
* process; the editing functions do, however, set some
* hints to eliminate a lot of the grinding. There is more
* that can be done; the "vtputc" interface is a real
* pig.
*/
#include <sys/queue.h>
#include <ctype.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <term.h>
#include "def.h"
#include "kbd.h"
/*
* A video structure always holds
* an array of characters whose length is equal to
* the longest line possible. v_text is allocated
* dynamically to fit the screen width.
*/
struct video {
short v_hash; /* Hash code, for compares. */
short v_flag; /* Flag word. */
short v_color; /* Color of the line. */
int v_cost; /* Cost of display. */
char *v_text; /* The actual characters. */
};
#define VFCHG 0x0001 /* Changed. */
#define VFHBAD 0x0002 /* Hash and cost are bad. */
#define VFEXT 0x0004 /* extended line (beond ncol) */
/*
* SCORE structures hold the optimal
* trace trajectory, and the cost of redisplay, when
* the dynamic programming redisplay code is used.
*/
struct score {
int s_itrace; /* "i" index for track back. */
int s_jtrace; /* "j" index for trace back. */
int s_cost; /* Display cost. */
};
void vtmove(int, int);
void vtputc(int);
void vtpute(int);
int vtputs(const char *);
void vteeol(void);
void updext(int, int);
void modeline(struct mgwin *, int);
void setscores(int, int);
void traceback(int, int, int, int);
void ucopy(struct video *, struct video *);
void uline(int, struct video *, struct video *);
void hash(struct video *);
int sgarbf = TRUE; /* TRUE if screen is garbage. */
int vtrow = HUGE; /* Virtual cursor row. */
int vtcol = HUGE; /* Virtual cursor column. */
int tthue = CNONE; /* Current color. */
int ttrow = HUGE; /* Physical cursor row. */
int ttcol = HUGE; /* Physical cursor column. */
int tttop = HUGE; /* Top of scroll region. */
int ttbot = HUGE; /* Bottom of scroll region. */
int lbound = 0; /* leftmost bound of the current */
/* line being displayed */
struct video **vscreen; /* Edge vector, virtual. */
struct video **pscreen; /* Edge vector, physical. */
struct video *video; /* Actual screen data. */
struct video blanks; /* Blank line image. */
/*
* This matrix is written as an array because
* we do funny things in the "setscores" routine, which
* is very compute intensive, to make the subscripts go away.
* It would be "SCORE score[NROW][NROW]" in old speak.
* Look at "setscores" to understand what is up.
*/
struct score *score; /* [NROW * NROW] */
static int linenos = TRUE;
static int colnos = FALSE;
/* Is macro recording enabled? */
extern int macrodef;
/* Is working directory global? */
extern int globalwd;
/*
* Since we don't have variables (we probably should) these are command
* processors for changing the values of mode flags.
*/
/* ARGSUSED */
int
linenotoggle(int f, int n)
{
if (f & FFARG)
linenos = n > 0;
else
linenos = !linenos;
sgarbf = TRUE;
return (TRUE);
}
/* ARGSUSED */
int
colnotoggle(int f, int n)
{
if (f & FFARG)
colnos = n > 0;
else
colnos = !colnos;
sgarbf = TRUE;
return (TRUE);
}
/*
* Reinit the display data structures, this is called when the terminal
* size changes.
*/
int
vtresize(int force, int newrow, int newcol)
{
int i;
int rowchanged, colchanged;
static int first_run = 1;
struct video *vp;
if (newrow < 1 || newcol < 1)
return (FALSE);
rowchanged = (newrow != nrow);
colchanged = (newcol != ncol);
#define TRYREALLOC(a, n) do { \
void *tmp; \
if ((tmp = realloc((a), (n))) == NULL) { \
panic("out of memory in display code"); \
} \
(a) = tmp; \
} while (0)
#define TRYREALLOCARRAY(a, n, m) do { \
void *tmp; \
if ((tmp = reallocarray((a), (n), (m))) == NULL) {\
panic("out of memory in display code"); \
} \
(a) = tmp; \
} while (0)
/* No update needed */
if (!first_run && !force && !rowchanged && !colchanged)
return (TRUE);
if (first_run)
memset(&blanks, 0, sizeof(blanks));
if (rowchanged || first_run) {
int vidstart;
/*
* This is not pretty.
*/
if (nrow == 0)
vidstart = 0;
else
vidstart = 2 * (nrow - 1);
/*
* We're shrinking, free some internal data.
*/
if (newrow < nrow) {
for (i = 2 * (newrow - 1); i < 2 * (nrow - 1); i++) {
free(video[i].v_text);
video[i].v_text = NULL;
}
}
TRYREALLOCARRAY(score, newrow, newrow * sizeof(struct score));
TRYREALLOCARRAY(vscreen, (newrow - 1), sizeof(struct video *));
TRYREALLOCARRAY(pscreen, (newrow - 1), sizeof(struct video *));
TRYREALLOCARRAY(video, (newrow - 1), 2 * sizeof(struct video));
/*
* Zero-out the entries we just allocated.
*/
for (i = vidstart; i < 2 * (newrow - 1); i++)
memset(&video[i], 0, sizeof(struct video));
/*
* Reinitialize vscreen and pscreen arrays completely.
*/
vp = &video[0];
for (i = 0; i < newrow - 1; ++i) {
vscreen[i] = vp;
++vp;
pscreen[i] = vp;
++vp;
}
}
if (rowchanged || colchanged || first_run) {
for (i = 0; i < 2 * (newrow - 1); i++)
TRYREALLOC(video[i].v_text, newcol);
TRYREALLOC(blanks.v_text, newcol);
}
nrow = newrow;
ncol = newcol;
if (ttrow > nrow)
ttrow = nrow;
if (ttcol > ncol)
ttcol = ncol;
first_run = 0;
return (TRUE);
}
#undef TRYREALLOC
#undef TRYREALLOCARRAY
/*
* Initialize the data structures used
* by the display code. The edge vectors used
* to access the screens are set up. The operating
* system's terminal I/O channel is set up. Fill the
* "blanks" array with ASCII blanks. The rest is done
* at compile time. The original window is marked
* as needing full update, and the physical screen
* is marked as garbage, so all the right stuff happens
* on the first call to redisplay.
*/
void
vtinit(void)
{
int i;
ttopen();
ttinit();
/*
* ttinit called ttresize(), which called vtresize(), so our data
* structures are setup correctly.
*/
blanks.v_color = CTEXT;
for (i = 0; i < ncol; ++i)
blanks.v_text[i] = ' ';
}
/*
* Tidy up the virtual display system
* in anticipation of a return back to the host
* operating system. Right now all we do is position
* the cursor to the last line, erase the line, and
* close the terminal channel.
*/
void
vttidy(void)
{
ttcolor(CTEXT);
ttnowindow(); /* No scroll window. */
ttmove(nrow - 1, 0); /* Echo line. */
tteeol();
tttidy();
ttflush();
ttclose();
}
/*
* Move the virtual cursor to an origin
* 0 spot on the virtual display screen. I could
* store the column as a character pointer to the spot
* on the line, which would make "vtputc" a little bit
* more efficient. No checking for errors.
*/
void
vtmove(int row, int col)
{
vtrow = row;
vtcol = col;
}
/*
* Write a character to the virtual display,
* dealing with long lines and the display of unprintable
* things like control characters. Also expand tabs every 8
* columns. This code only puts printing characters into
* the virtual display image. Special care must be taken when
* expanding tabs. On a screen whose width is not a multiple
* of 8, it is possible for the virtual cursor to hit the
* right margin before the next tab stop is reached. This
* makes the tab code loop if you are not careful.
* Three guesses how we found this.
*/
void
vtputc(int c)
{
struct video *vp;
c &= 0xff;
vp = vscreen[vtrow];
if (vtcol >= ncol)
vp->v_text[ncol - 1] = '$';
else if (c == '\t'
#ifdef NOTAB
&& !(curbp->b_flag & BFNOTAB)
#endif
) {
do {
vtputc(' ');
} while (vtcol < ncol && (vtcol & 0x07) != 0);
} else if (ISCTRL(c)) {
vtputc('^');
vtputc(CCHR(c));
} else if (isprint(c))
vp->v_text[vtcol++] = c;
else {
char bf[5];
snprintf(bf, sizeof(bf), "\\%o", c);
vtputs(bf);
}
}
/*
* Put a character to the virtual screen in an extended line. If we are not
* yet on left edge, don't print it yet. Check for overflow on the right
* margin.
*/
void
vtpute(int c)
{
struct video *vp;
c &= 0xff;
vp = vscreen[vtrow];
if (vtcol >= ncol)
vp->v_text[ncol - 1] = '$';
else if (c == '\t'
#ifdef NOTAB
&& !(curbp->b_flag & BFNOTAB)
#endif
) {
do {
vtpute(' ');
} while (((vtcol + lbound) & 0x07) != 0 && vtcol < ncol);
} else if (ISCTRL(c) != FALSE) {
vtpute('^');
vtpute(CCHR(c));
} else {
if (vtcol >= 0)
vp->v_text[vtcol] = c;
++vtcol;
}
}
/*
* Erase from the end of the software cursor to the end of the line on which
* the software cursor is located. The display routines will decide if a
* hardware erase to end of line command should be used to display this.
*/
void
vteeol(void)
{
struct video *vp;
vp = vscreen[vtrow];
while (vtcol < ncol)
vp->v_text[vtcol++] = ' ';
}
/*
* Make sure that the display is
* right. This is a three part process. First,
* scan through all of the windows looking for dirty
* ones. Check the framing, and refresh the screen.
* Second, make sure that "currow" and "curcol" are
* correct for the current window. Third, make the
* virtual and physical screens the same.
*/
void
update(int modelinecolor)
{
struct line *lp;
struct mgwin *wp;
struct video *vp1;
struct video *vp2;
int c, i, j;
int hflag;
int currow, curcol;
int offs, size;
if (charswaiting())
return;
if (sgarbf) { /* must update everything */
wp = wheadp;
while (wp != NULL) {
wp->w_rflag |= WFMODE | WFFULL;
wp = wp->w_wndp;
}
}
if (linenos || colnos) {
wp = wheadp;
while (wp != NULL) {
wp->w_rflag |= WFMODE;
wp = wp->w_wndp;
}
}
hflag = FALSE; /* Not hard. */
for (wp = wheadp; wp != NULL; wp = wp->w_wndp) {
/*
* Nothing to be done.
*/
if (wp->w_rflag == 0)
continue;
if ((wp->w_rflag & WFFRAME) == 0) {
lp = wp->w_linep;
for (i = 0; i < wp->w_ntrows; ++i) {
if (lp == wp->w_dotp)
goto out;
if (lp == wp->w_bufp->b_headp)
break;
lp = lforw(lp);
}
}
/*
* Put the middle-line in place.
*/
i = wp->w_frame;
if (i > 0) {
--i;
if (i >= wp->w_ntrows)
i = wp->w_ntrows - 1;
} else if (i < 0) {
i += wp->w_ntrows;
if (i < 0)
i = 0;
} else
i = wp->w_ntrows / 2; /* current center, no change */
/*
* Find the line.
*/
lp = wp->w_dotp;
while (i != 0 && lback(lp) != wp->w_bufp->b_headp) {
--i;
lp = lback(lp);
}
wp->w_linep = lp;
wp->w_rflag |= WFFULL; /* Force full. */
out:
lp = wp->w_linep; /* Try reduced update. */
i = wp->w_toprow;
if ((wp->w_rflag & ~WFMODE) == WFEDIT) {
while (lp != wp->w_dotp) {
++i;
lp = lforw(lp);
}
vscreen[i]->v_color = CTEXT;
vscreen[i]->v_flag |= (VFCHG | VFHBAD);
vtmove(i, 0);
for (j = 0; j < llength(lp); ++j)
vtputc(lgetc(lp, j));
vteeol();
} else if ((wp->w_rflag & (WFEDIT | WFFULL)) != 0) {
hflag = TRUE;
while (i < wp->w_toprow + wp->w_ntrows) {
vscreen[i]->v_color = CTEXT;
vscreen[i]->v_flag |= (VFCHG | VFHBAD);
vtmove(i, 0);
if (lp != wp->w_bufp->b_headp) {
for (j = 0; j < llength(lp); ++j)
vtputc(lgetc(lp, j));
lp = lforw(lp);
}
vteeol();
++i;
}
}
if ((wp->w_rflag & WFMODE) != 0)
modeline(wp, modelinecolor);
wp->w_rflag = 0;
wp->w_frame = 0;
}
lp = curwp->w_linep; /* Cursor location. */
currow = curwp->w_toprow;
while (lp != curwp->w_dotp) {
++currow;
lp = lforw(lp);
}
curcol = 0;
i = 0;
while (i < curwp->w_doto) {
c = lgetc(lp, i++);
if (c == '\t'
#ifdef NOTAB
&& !(curbp->b_flag & BFNOTAB)
#endif
) {
curcol |= 0x07;
curcol++;
} else if (ISCTRL(c) != FALSE)
curcol += 2;
else if (isprint(c))
curcol++;
else {
char bf[5];
snprintf(bf, sizeof(bf), "\\%o", c);
curcol += strlen(bf);
}
}
if (curcol >= ncol - 1) { /* extended line. */
/* flag we are extended and changed */
vscreen[currow]->v_flag |= VFEXT | VFCHG;
updext(currow, curcol); /* and output extended line */
} else
lbound = 0; /* not extended line */
/*
* Make sure no lines need to be de-extended because the cursor is no
* longer on them.
*/
wp = wheadp;
while (wp != NULL) {
lp = wp->w_linep;
i = wp->w_toprow;
while (i < wp->w_toprow + wp->w_ntrows) {
if (vscreen[i]->v_flag & VFEXT) {
/* always flag extended lines as changed */
vscreen[i]->v_flag |= VFCHG;
if ((wp != curwp) || (lp != wp->w_dotp) ||
(curcol < ncol - 1)) {
vtmove(i, 0);
for (j = 0; j < llength(lp); ++j)
vtputc(lgetc(lp, j));
vteeol();
/* this line no longer is extended */
vscreen[i]->v_flag &= ~VFEXT;
}
}
lp = lforw(lp);
++i;
}
/* if garbaged then fix up mode lines */
if (sgarbf != FALSE)
vscreen[i]->v_flag |= VFCHG;
/* and onward to the next window */
wp = wp->w_wndp;
}
if (sgarbf != FALSE) { /* Screen is garbage. */
sgarbf = FALSE; /* Erase-page clears. */
epresf = FALSE; /* The message area. */
tttop = HUGE; /* Forget where you set. */
ttbot = HUGE; /* scroll region. */
tthue = CNONE; /* Color unknown. */
ttmove(0, 0);
tteeop();
for (i = 0; i < nrow - 1; ++i) {
uline(i, vscreen[i], &blanks);
ucopy(vscreen[i], pscreen[i]);
}
ttmove(currow, curcol - lbound);
ttflush();
return;
}
if (hflag != FALSE) { /* Hard update? */
for (i = 0; i < nrow - 1; ++i) {/* Compute hash data. */
hash(vscreen[i]);
hash(pscreen[i]);
}
offs = 0; /* Get top match. */
while (offs != nrow - 1) {
vp1 = vscreen[offs];
vp2 = pscreen[offs];
if (vp1->v_color != vp2->v_color
|| vp1->v_hash != vp2->v_hash)
break;
uline(offs, vp1, vp2);
ucopy(vp1, vp2);
++offs;
}
if (offs == nrow - 1) { /* Might get it all. */
ttmove(currow, curcol - lbound);
ttflush();
return;
}
size = nrow - 1; /* Get bottom match. */
while (size != offs) {
vp1 = vscreen[size - 1];
vp2 = pscreen[size - 1];
if (vp1->v_color != vp2->v_color
|| vp1->v_hash != vp2->v_hash)
break;
uline(size - 1, vp1, vp2);
ucopy(vp1, vp2);
--size;
}
if ((size -= offs) == 0) /* Get screen size. */
panic("Illegal screen size in update");
setscores(offs, size); /* Do hard update. */
traceback(offs, size, size, size);
for (i = 0; i < size; ++i)
ucopy(vscreen[offs + i], pscreen[offs + i]);
ttmove(currow, curcol - lbound);
ttflush();
return;
}
for (i = 0; i < nrow - 1; ++i) { /* Easy update. */
vp1 = vscreen[i];
vp2 = pscreen[i];
if ((vp1->v_flag & VFCHG) != 0) {
uline(i, vp1, vp2);
ucopy(vp1, vp2);
}
}
ttmove(currow, curcol - lbound);
ttflush();
}
/*
* Update a saved copy of a line,
* kept in a video structure. The "vvp" is
* the one in the "vscreen". The "pvp" is the one
* in the "pscreen". This is called to make the
* virtual and physical screens the same when
* display has done an update.
*/
void
ucopy(struct video *vvp, struct video *pvp)
{
vvp->v_flag &= ~VFCHG; /* Changes done. */
pvp->v_flag = vvp->v_flag; /* Update model. */
pvp->v_hash = vvp->v_hash;
pvp->v_cost = vvp->v_cost;
pvp->v_color = vvp->v_color;
bcopy(vvp->v_text, pvp->v_text, ncol);
}
/*
* updext: update the extended line which the cursor is currently on at a
* column greater than the terminal width. The line will be scrolled right or
* left to let the user see where the cursor is.
*/
void
updext(int currow, int curcol)
{
struct line *lp; /* pointer to current line */
int j; /* index into line */
if (ncol < 2)
return;
/*
* calculate what column the left bound should be
* (force cursor into middle half of screen)
*/
lbound = curcol - (curcol % (ncol >> 1)) - (ncol >> 2);
/*
* scan through the line outputing characters to the virtual screen
* once we reach the left edge
*/
vtmove(currow, -lbound); /* start scanning offscreen */
lp = curwp->w_dotp; /* line to output */
for (j = 0; j < llength(lp); ++j) /* until the end-of-line */
vtpute(lgetc(lp, j));
vteeol(); /* truncate the virtual line */
vscreen[currow]->v_text[0] = '$'; /* and put a '$' in column 1 */
}
/*
* Update a single line. This routine only
* uses basic functionality (no insert and delete character,
* but erase to end of line). The "vvp" points at the video
* structure for the line on the virtual screen, and the "pvp"
* is the same for the physical screen. Avoid erase to end of
* line when updating CMODE color lines, because of the way that
* reverse video works on most terminals.
*/
void
uline(int row, struct video *vvp, struct video *pvp)
{
char *cp1;
char *cp2;
char *cp3;
char *cp4;
char *cp5;
int nbflag;
if (vvp->v_color != pvp->v_color) { /* Wrong color, do a */
ttmove(row, 0); /* full redraw. */
#ifdef STANDOUT_GLITCH
if (pvp->v_color != CTEXT && magic_cookie_glitch >= 0)
tteeol();
#endif
ttcolor(vvp->v_color);
#ifdef STANDOUT_GLITCH
cp1 = &vvp->v_text[magic_cookie_glitch > 0 ? magic_cookie_glitch : 0];
/*
* The odd code for magic_cookie_glitch==0 is to avoid
* putting the invisible glitch character on the next line.
* (Hazeltine executive 80 model 30)
*/
cp2 = &vvp->v_text[ncol - (magic_cookie_glitch >= 0 ?
(magic_cookie_glitch != 0 ? magic_cookie_glitch : 1) : 0)];
#else
cp1 = &vvp->v_text[0];
cp2 = &vvp->v_text[ncol];
#endif
while (cp1 != cp2) {
ttputc(*cp1++);
++ttcol;
}
ttcolor(CTEXT);
return;
}
cp1 = &vvp->v_text[0]; /* Compute left match. */
cp2 = &pvp->v_text[0];
while (cp1 != &vvp->v_text[ncol] && cp1[0] == cp2[0]) {
++cp1;
++cp2;
}
if (cp1 == &vvp->v_text[ncol]) /* All equal. */
return;
nbflag = FALSE;
cp3 = &vvp->v_text[ncol]; /* Compute right match. */
cp4 = &pvp->v_text[ncol];
while (cp3[-1] == cp4[-1]) {
--cp3;
--cp4;
if (cp3[0] != ' ') /* Note non-blanks in */
nbflag = TRUE; /* the right match. */
}
cp5 = cp3; /* Is erase good? */
if (nbflag == FALSE && vvp->v_color == CTEXT) {
while (cp5 != cp1 && cp5[-1] == ' ')
--cp5;
/* Alcyon hack */
if ((int) (cp3 - cp5) <= tceeol)
cp5 = cp3;
}
/* Alcyon hack */
ttmove(row, (int) (cp1 - &vvp->v_text[0]));
#ifdef STANDOUT_GLITCH
if (vvp->v_color != CTEXT && magic_cookie_glitch > 0) {
if (cp1 < &vvp->v_text[magic_cookie_glitch])
cp1 = &vvp->v_text[magic_cookie_glitch];
if (cp5 > &vvp->v_text[ncol - magic_cookie_glitch])
cp5 = &vvp->v_text[ncol - magic_cookie_glitch];
} else if (magic_cookie_glitch < 0)
#endif
ttcolor(vvp->v_color);
while (cp1 != cp5) {
ttputc(*cp1++);
++ttcol;
}
if (cp5 != cp3) /* Do erase. */
tteeol();
}
/*
* Redisplay the mode line for the window pointed to by the "wp".
* This is the only routine that has any idea of how the mode line is
* formatted. You can change the modeline format by hacking at this
* routine. Called by "update" any time there is a dirty window. Note
* that if STANDOUT_GLITCH is defined, first and last magic_cookie_glitch
* characters may never be seen.
*/
void
modeline(struct mgwin *wp, int modelinecolor)
{
int n, md;
struct buffer *bp;
char sl[21]; /* Overkill. Space for 2^64 in base 10. */
int len;
n = wp->w_toprow + wp->w_ntrows; /* Location. */
vscreen[n]->v_color = modelinecolor; /* Mode line color. */
vscreen[n]->v_flag |= (VFCHG | VFHBAD); /* Recompute, display. */
vtmove(n, 0); /* Seek to right line. */
bp = wp->w_bufp;
vtputc('-');
vtputc('-');
if ((bp->b_flag & BFREADONLY) != 0) {
vtputc('%');
if ((bp->b_flag & BFCHG) != 0)
vtputc('*');
else
vtputc('%');
} else if ((bp->b_flag & BFCHG) != 0) { /* "*" if changed. */
vtputc('*');
vtputc('*');
} else {
vtputc('-');
vtputc('-');
}
vtputc('-');
n = 5;
n += vtputs("Mg: ");
if (bp->b_bname[0] != '\0')
n += vtputs(&(bp->b_bname[0]));
while (n < 42) { /* Pad out with blanks. */
vtputc(' ');
++n;
}
vtputc('(');
++n;
for (md = 0; ; ) {
n += vtputs(bp->b_modes[md]->p_name);
if (++md > bp->b_nmodes)
break;
vtputc('-');
++n;
}
/* XXX These should eventually move to a real mode */
if (macrodef == TRUE)
n += vtputs("-def");
if (globalwd == TRUE)
n += vtputs("-gwd");
vtputc(')');
++n;
if (linenos && colnos)
len = snprintf(sl, sizeof(sl), "--L%d--C%d", wp->w_dotline,
getcolpos(wp));
else if (linenos)
len = snprintf(sl, sizeof(sl), "--L%d", wp->w_dotline);
else if (colnos)
len = snprintf(sl, sizeof(sl), "--C%d", getcolpos(wp));
if ((linenos || colnos) && len < sizeof(sl) && len != -1)
n += vtputs(sl);
while (n < ncol) { /* Pad out. */
vtputc('-');
++n;
}
}
/*
* Output a string to the mode line, report how long it was.
*/
int
vtputs(const char *s)
{
int n = 0;
while (*s != '\0') {
vtputc(*s++);
++n;
}
return (n);
}
/*
* Compute the hash code for the line pointed to by the "vp".
* Recompute it if necessary. Also set the approximate redisplay
* cost. The validity of the hash code is marked by a flag bit.
* The cost understand the advantages of erase to end of line.
* Tuned for the VAX by Bob McNamara; better than it used to be on
* just about any machine.
*/
void
hash(struct video *vp)
{
int i, n;
char *s;
if ((vp->v_flag & VFHBAD) != 0) { /* Hash bad. */
s = &vp->v_text[ncol - 1];
for (i = ncol; i != 0; --i, --s)
if (*s != ' ')
break;
n = ncol - i; /* Erase cheaper? */
if (n > tceeol)
n = tceeol;
vp->v_cost = i + n; /* Bytes + blanks. */
for (n = 0; i != 0; --i, --s)
n = (n << 5) + n + *s;
vp->v_hash = n; /* Hash code. */
vp->v_flag &= ~VFHBAD; /* Flag as all done. */
}
}
/*
* Compute the Insert-Delete
* cost matrix. The dynamic programming algorithm
* described by James Gosling is used. This code assumes
* that the line above the echo line is the last line involved
* in the scroll region. This is easy to arrange on the VT100
* because of the scrolling region. The "offs" is the origin 0
* offset of the first row in the virtual/physical screen that
* is being updated; the "size" is the length of the chunk of
* screen being updated. For a full screen update, use offs=0
* and size=nrow-1.
*
* Older versions of this code implemented the score matrix by
* a two dimensional array of SCORE nodes. This put all kinds of
* multiply instructions in the code! This version is written to
* use a linear array and pointers, and contains no multiplication
* at all. The code has been carefully looked at on the VAX, with
* only marginal checking on other machines for efficiency. In
* fact, this has been tuned twice! Bob McNamara tuned it even
* more for the VAX, which is a big issue for him because of
* the 66 line X displays.
*
* On some machines, replacing the "for (i=1; i<=size; ++i)" with
* i = 1; do { } while (++i <=size)" will make the code quite a
* bit better; but it looks ugly.
*/
void
setscores(int offs, int size)
{
struct score *sp;
struct score *sp1;
struct video **vp, **pp;
struct video **vbase, **pbase;
int tempcost;
int bestcost;
int j, i;
vbase = &vscreen[offs - 1]; /* By hand CSE's. */
pbase = &pscreen[offs - 1];
score[0].s_itrace = 0; /* [0, 0] */
score[0].s_jtrace = 0;
score[0].s_cost = 0;
sp = &score[1]; /* Row 0, inserts. */
tempcost = 0;
vp = &vbase[1];
for (j = 1; j <= size; ++j) {
sp->s_itrace = 0;
sp->s_jtrace = j - 1;
tempcost += tcinsl;
tempcost += (*vp)->v_cost;
sp->s_cost = tempcost;
++vp;
++sp;
}
sp = &score[nrow]; /* Column 0, deletes. */
tempcost = 0;
for (i = 1; i <= size; ++i) {
sp->s_itrace = i - 1;
sp->s_jtrace = 0;
tempcost += tcdell;
sp->s_cost = tempcost;
sp += nrow;
}
sp1 = &score[nrow + 1]; /* [1, 1]. */
pp = &pbase[1];
for (i = 1; i <= size; ++i) {
sp = sp1;
vp = &vbase[1];
for (j = 1; j <= size; ++j) {
sp->s_itrace = i - 1;
sp->s_jtrace = j;
bestcost = (sp - nrow)->s_cost;
if (j != size) /* Cd(A[i])=0 @ Dis. */
bestcost += tcdell;
tempcost = (sp - 1)->s_cost;
tempcost += (*vp)->v_cost;
if (i != size) /* Ci(B[j])=0 @ Dsj. */
tempcost += tcinsl;
if (tempcost < bestcost) {
sp->s_itrace = i;
sp->s_jtrace = j - 1;
bestcost = tempcost;
}
tempcost = (sp - nrow - 1)->s_cost;
if ((*pp)->v_color != (*vp)->v_color
|| (*pp)->v_hash != (*vp)->v_hash)
tempcost += (*vp)->v_cost;
if (tempcost < bestcost) {
sp->s_itrace = i - 1;
sp->s_jtrace = j - 1;
bestcost = tempcost;
}
sp->s_cost = bestcost;
++sp; /* Next column. */
++vp;
}
++pp;
sp1 += nrow; /* Next row. */
}
}
/*
* Trace back through the dynamic programming cost
* matrix, and update the screen using an optimal sequence
* of redraws, insert lines, and delete lines. The "offs" is
* the origin 0 offset of the chunk of the screen we are about to
* update. The "i" and "j" are always started in the lower right
* corner of the matrix, and imply the size of the screen.
* A full screen traceback is called with offs=0 and i=j=nrow-1.
* There is some do-it-yourself double subscripting here,
* which is acceptable because this routine is much less compute
* intensive then the code that builds the score matrix!
*/
void
traceback(int offs, int size, int i, int j)
{
int itrace, jtrace;
int k;
int ninsl, ndraw, ndell;
if (i == 0 && j == 0) /* End of update. */
return;
itrace = score[(nrow * i) + j].s_itrace;
jtrace = score[(nrow * i) + j].s_jtrace;
if (itrace == i) { /* [i, j-1] */
ninsl = 0; /* Collect inserts. */
if (i != size)
ninsl = 1;
ndraw = 1;
while (itrace != 0 || jtrace != 0) {
if (score[(nrow * itrace) + jtrace].s_itrace != itrace)
break;
jtrace = score[(nrow * itrace) + jtrace].s_jtrace;
if (i != size)
++ninsl;
++ndraw;
}
traceback(offs, size, itrace, jtrace);
if (ninsl != 0) {
ttcolor(CTEXT);
ttinsl(offs + j - ninsl, offs + size - 1, ninsl);
}
do { /* B[j], A[j] blank. */
k = offs + j - ndraw;
uline(k, vscreen[k], &blanks);
} while (--ndraw);
return;
}
if (jtrace == j) { /* [i-1, j] */
ndell = 0; /* Collect deletes. */
if (j != size)
ndell = 1;
while (itrace != 0 || jtrace != 0) {
if (score[(nrow * itrace) + jtrace].s_jtrace != jtrace)
break;
itrace = score[(nrow * itrace) + jtrace].s_itrace;
if (j != size)
++ndell;
}
if (ndell != 0) {
ttcolor(CTEXT);
ttdell(offs + i - ndell, offs + size - 1, ndell);
}
traceback(offs, size, itrace, jtrace);
return;
}
traceback(offs, size, itrace, jtrace);
k = offs + j - 1;
uline(k, vscreen[k], pscreen[offs + i - 1]);
}
|
947261.c | // SPDX-FileCopyrightText: Copyright (c) 2021 Electronics and Telecommunications Research Institute
//
// SPDX-License-Identifier: GPL-3.0-or-later
#include <sys/types.h>
#include <stdarg.h>
#include "atomic.h"
#include "syscall.h"
#include "utility.h"
#include "az_types.h"
static QWORD vcon_addr;
/**
* Copy memory
*/
int a_memcpy(void *destination, const void *source, int size)
{
int i = 0;
int remain_byte = 0;
for (i=0; i<(size / 8); i++)
((QWORD *) destination)[i] = ((QWORD *) source)[i];
remain_byte = i * 8;
for (i=0; i<(size % 8); i++) {
((char *) destination)[remain_byte] = ((char *) source)[remain_byte];
remain_byte++;
}
return size;
}
/**
* Return the length of string
*/
int a_strlen(const char *buffer)
{
int i = 0;
for (i=0;; i++)
if (buffer[i] == '\0')
break;
return i;
}
/**
* Convert Integer to String
*/
int _itoa(long value, char *buffer, int radix)
{
int ret = 0;
switch (radix) {
case 16:
ret = hextostring(value, buffer);
break;
case 10:
default:
ret = decimaltostring(value, buffer);
break;
}
return ret;
}
/*
* Convert integer to string
*/
void int_to_str(int n, char *str) {
int i = 0;
int n_temp = n;
if(n == 0) {
str[0] = '0';
str[1] = 0;
}
else {
while (n_temp != 0) {
n_temp /= 10;
i++;
}
str[i] = 0;
i--;
while (n != 0) {
str[i] = (char) (n % 10) + '0';
n /= 10;
i--;
}
}
}
/**
* Convert HEX to String
*/
int hextostring(QWORD value, char *buffer)
{
QWORD i = 0;
QWORD curr_value = 0;
if (value == 0) {
buffer[0] = '0';
buffer[1] = '\0';
return 1;
}
for (i=0; value>0; i++) {
curr_value = value % 16;
if (curr_value >= 10)
buffer[i] = 'A' + (curr_value - 10);
else
buffer[i] = '0' + curr_value;
value = value / 16;
}
buffer[i] = '\0';
reversestring(buffer);
return i;
}
/**
* Convert Decimal to String
*/
int decimaltostring(long value, char *buffer)
{
long i = 0;
if (value == 0) {
buffer[0] = '0';
buffer[1] = '\0';
return 1;
}
if (value < 0) {
i = 1;
buffer[0] = '-';
value = -value;
} else {
i = 0;
}
for (; value > 0; i++) {
buffer[i] = '0' + value % 10;
value = value / 10;
}
buffer[i] = '\0';
if (buffer[0] == '-')
reversestring(&(buffer[1]));
else
reversestring(buffer);
return i;
}
/**
* Reverse String
*/
void reversestring(char *buffer)
{
int length = 0;
int i = 0;
char temp = NULL;
length = a_strlen(buffer);
for (i=0; i<length / 2; i++) {
temp = buffer[i];
buffer[i] = buffer[length - 1 - i];
buffer[length - 1 - i] = temp;
}
}
/**
* vsprintf()
*/
int vsprintf(char *buffer, const char *parameter, va_list ap)
{
QWORD i = 0, k = 0;
int buffer_index = 0;
int format_length = 0, copy_length = 0;
char *copy_string = NULL;
QWORD q_value = 0;
int i_value = 0;
double d_value = 0;
format_length = a_strlen(parameter);
for (i=0; i<format_length; i++) {
if (parameter[i] == '%') {
i++;
switch (parameter[i]) {
// String
case 's':
copy_string = (char *) (va_arg(ap, char *));
copy_length = a_strlen(copy_string);
a_memcpy(buffer + buffer_index, copy_string, copy_length);
buffer_index += copy_length;
break;
// Char
case 'c':
buffer[buffer_index] = (char) (va_arg(ap, int));
buffer_index++;
break;
// Integer
case 'd':
case 'i':
i_value = (int) (va_arg(ap, int));
buffer_index += _itoa(i_value, buffer + buffer_index, 10);
break;
// Hexadecimal (4Byte)
case 'x':
case 'X':
q_value = (DWORD) (va_arg(ap, DWORD)) & 0xFFFFFFFF;
buffer_index += _itoa(q_value, buffer + buffer_index, 16);
break;
// Hexadecimal (8Byte)
case 'q':
case 'Q':
case 'p':
q_value = (QWORD) (va_arg(ap, QWORD));
buffer_index += _itoa(q_value, buffer + buffer_index, 16);
break;
// Floating
case 'f':
d_value = (double) (va_arg(ap, double));
d_value += 0.005;
buffer[buffer_index] = '0' + (QWORD) (d_value * 100) % 10;
buffer[buffer_index + 1] = '0' + (QWORD) (d_value * 10) % 10;
buffer[buffer_index + 2] = '.';
for (k=0; ; k++) {
if (((QWORD) d_value == 0) && (k != 0)) {
break;
}
buffer[buffer_index + 3 + k] = '0' + ((QWORD) d_value % 10);
d_value = d_value / 10;
}
buffer[buffer_index + 3 + k] = '\0';
reversestring(buffer + buffer_index);
buffer_index += 3 + k;
break;
default:
buffer[buffer_index] = parameter[i];
buffer_index++;
break;
}
}
else {
buffer[buffer_index] = parameter[i];
buffer_index++;
}
}
buffer[buffer_index] = '\0';
return buffer_index;
}
int print( const char *buffer, ...)
{
va_list ap;
int ret = 0;
char str[64];
va_start(ap, buffer);
ret = vsprintf(str, buffer, ap);
va_end(ap);
print_log(str);
return ret;
}
/**
* Print to screen
*/
int print_xy(int x, int y, const char *buffer, ...)
{
va_list ap;
int ret = 0;
char str[1024];
char *vscreen;
int i = 0;
if ((QWORD *)vcon_addr == NULL)
vcon_addr = get_vcon_addr();
#ifdef _qemu_
#define LEVEL (2)
#else
#define LEVEL (1)
#endif
va_start(ap, buffer);
ret = vsprintf(str, buffer, ap);
va_end(ap);
vscreen = (char *) (vcon_addr);
// vscreen = (char *) va(*((unsigned long *) (0x94000+0x0000000000000073)) + MEMORY_START);
vscreen += (y * 80 * LEVEL) + x*LEVEL;
for (i = 0; str[i] != 0; i++)
vscreen[i*LEVEL] = str[i];
return ret;
}
int kprintf(const char *fmp, ...)
{
return 0;
}
static size_t start_tsc;
static size_t freq;
int az_gettimeofday(struct az_timeval *tv, struct az_timezone *tz)
{
if (start_tsc == 0)
start_tsc = get_start_tsc();
if (freq == 0)
freq = get_freq();
if(tv) {
size_t diff = rdtsc() - start_tsc;
tv->tv_sec = diff/freq;
tv->tv_usec = ((diff - tv->tv_sec * freq) * 1000000ULL) / freq;
}
return 0;
}
/**
* @brief return cpu frequency
* @return CPU frequency
*/
int get_cpufreq(void)
{
if (freq == 0)
freq = get_freq();
return freq;
}
#if 0
/**
* Random
*/
#define RAND_MAX 0x7fff
static long holdrand = 1L;
void srand(unsigned int seed)
{
holdrand = (long) seed;
}
int rand()
{
return (((holdrand = holdrand * 214013L + 2531011L) >> 16) & RAND_MAX);
}
#endif
|
673285.c | /*
* Copyright: 2015-2020. Stealthy Labs LLC. All Rights Reserved.
* Original Date: 28th April 2015
* Modified Date: 16th October 2019
* Modified Software: libgps_mtk3339
*/
#include <gpsconfig.h>
#include <gpsutils.h>
#ifdef LIBGPS_MTK3339_HAVE_ERRNO_H
#include <errno.h>
#endif
volatile int gpsutils_loglevel = GPSUTILS_LOGLEVEL_INFO;
static time_t gpsutils_timegm(struct tm *_tm)
{
#ifdef LIBGPS_MTK3339_HAVE_TIMEGM
return timegm(_tm);
#else
#warning "Using mktime() instead of timegm() and it is non-reentrant"
char *old_tz = getenv("TZ");
setenv("TZ", "UTC", 1);
time_t val = mktime(_tm);
if (old_tz) {
setenv("TZ", old_tz, 1);
} else {
unsetenv("TZ");
}
return val;
#endif
}
int gpsutils_get_timeval(const struct tm *tm1, uint32_t millisecs, struct timeval *tv)
{
if (tm1 && tv) {
// the mktime/timegm functions may modify the tm structure so we copy it
struct tm tm2 = { 0 };
memcpy(&tm2, tm1, sizeof(struct tm));
tv->tv_sec = gpsutils_timegm(&tm2);
if (millisecs < 1000) {
tv->tv_usec = millisecs * 1000;
} else {
tv->tv_sec += millisecs / 1000;
tv->tv_usec = (millisecs % 1000) * 1000;
}
return 0;
}
return -1;
}
void gpsutils_timer_start(gpsutils_timer_t *tt)
{
if (tt) {
struct timeval tv = { 0 };
gettimeofday(&tv, NULL);
tt->start = ((double)tv.tv_sec + ((double)tv.tv_usec * 1e-6));
tt->stop = NAN;
tt->time_taken = NAN;
}
}
void gpsutils_timer_stop(gpsutils_timer_t *tt)
{
if (tt) {
struct timeval tv = { 0 };
gettimeofday(&tv, NULL);
tt->stop = ((double)tv.tv_sec + ((double)tv.tv_usec * 1e-6));
tt->time_taken = tt->stop - tt->start;
}
}
void gpsutils_hex_dump(const uint8_t *inp, size_t inlen, FILE *fp)
{
if (!inp || inlen == 0 || !fp)
return;
size_t rows = inlen / 16;
if ((inlen % 16) > 0)
rows++;
for (size_t i = 0; i < rows; ++i) {
fprintf(fp, "%08zX ", i * 16);
for (size_t j = 0; j < 16; ++j) {
if ((i * 16 + j) < inlen) {
uint8_t ch = inp[i * 16 + j];
fprintf(fp, "%02X ", ch);
} else {
fprintf(fp, " ");
}
}
fprintf(fp, " |");
for (size_t j = 0; j < 16; ++j) {
if ((i * 16 + j) < inlen) {
uint8_t ch = inp[i * 16 + j];
if (ch < 0x20 || ch > 0x7E || !isprint(ch)) {
ch = '.';
}
fprintf(fp, "%c", ch);
}
}
fprintf(fp, "|\n");
}
}
static const uint8_t gpsutils_hex_parse_lut[256] = {
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1,
-1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
};
uint8_t gpsutils_hex_parse(const char a)
{
return gpsutils_hex_parse_lut[(uint8_t)a];
}
void gpsutils_string_toupper(char *s)
{
if (s) {
size_t len = strlen(s);
for (size_t i = 0; i < len; ++i) {
s[i] = toupper(s[i]);
}
}
}
int gpsutils_checksum(const char *buf, ssize_t len)
{
if (buf) {
if (len <= 0)
len = strlen(buf);
int checksum = 0;
for (ssize_t i = 0; i < len; ++i) {
checksum ^= buf[i];
}
//GPSUTILS_DEBUG("checksum for msg: %s is %d(0x%02x)\n", buf, checksum, checksum);
return checksum;
} else {
return -1;
}
}
|
960527.c | /*
* QEMU buffered QEMUFile
*
* Copyright IBM, Corp. 2008
*
* Authors:
* Anthony Liguori <[email protected]>
*
* This work is licensed under the terms of the GNU GPL, version 2. See
* the COPYING file in the top-level directory.
*
*/
#include "qemu-common.h"
#include "hw/hw.h"
#include "qemu-timer.h"
#include "sysemu.h"
#include "qemu-char.h"
#include "buffered_file.h"
//#define DEBUG_BUFFERED_FILE
typedef struct QEMUFileBuffered
{
BufferedPutFunc *put_buffer;
BufferedPutReadyFunc *put_ready;
BufferedWaitForUnfreezeFunc *wait_for_unfreeze;
BufferedCloseFunc *close;
void *opaque;
QEMUFile *file;
int has_error;
int freeze_output;
size_t bytes_xfer;
size_t xfer_limit;
uint8_t *buffer;
size_t buffer_size;
size_t buffer_capacity;
QEMUTimer *timer;
} QEMUFileBuffered;
#ifdef DEBUG_BUFFERED_FILE
#define DPRINTF(fmt, ...) \
do { printf("buffered-file: " fmt, ## __VA_ARGS__); } while (0)
#else
#define DPRINTF(fmt, ...) \
do { } while (0)
#endif
static void buffered_append(QEMUFileBuffered *s,
const uint8_t *buf, size_t size)
{
if (size > (s->buffer_capacity - s->buffer_size)) {
void *tmp;
DPRINTF("increasing buffer capacity from %zu by %zu\n",
s->buffer_capacity, size + 1024);
s->buffer_capacity += size + 1024;
tmp = qemu_realloc(s->buffer, s->buffer_capacity);
if (tmp == NULL) {
fprintf(stderr, "qemu file buffer expansion failed\n");
exit(1);
}
s->buffer = tmp;
}
memcpy(s->buffer + s->buffer_size, buf, size);
s->buffer_size += size;
}
static void buffered_flush(QEMUFileBuffered *s)
{
size_t offset = 0;
if (s->has_error) {
DPRINTF("flush when error, bailing\n");
return;
}
DPRINTF("flushing %zu byte(s) of data\n", s->buffer_size);
while (offset < s->buffer_size) {
ssize_t ret;
ret = s->put_buffer(s->opaque, s->buffer + offset,
s->buffer_size - offset);
if (ret == -EAGAIN) {
DPRINTF("backend not ready, freezing\n");
s->freeze_output = 1;
break;
}
if (ret <= 0) {
DPRINTF("error flushing data, %zd\n", ret);
s->has_error = 1;
break;
} else {
DPRINTF("flushed %zd byte(s)\n", ret);
offset += ret;
}
}
DPRINTF("flushed %zu of %zu byte(s)\n", offset, s->buffer_size);
memmove(s->buffer, s->buffer + offset, s->buffer_size - offset);
s->buffer_size -= offset;
}
static int buffered_put_buffer(void *opaque, const uint8_t *buf, int64_t pos, int size)
{
QEMUFileBuffered *s = opaque;
int offset = 0;
ssize_t ret;
DPRINTF("putting %d bytes at %" PRId64 "\n", size, pos);
if (s->has_error) {
DPRINTF("flush when error, bailing\n");
return -EINVAL;
}
DPRINTF("unfreezing output\n");
s->freeze_output = 0;
buffered_flush(s);
while (!s->freeze_output && offset < size) {
if (s->bytes_xfer > s->xfer_limit) {
DPRINTF("transfer limit exceeded when putting\n");
break;
}
ret = s->put_buffer(s->opaque, buf + offset, size - offset);
if (ret == -EAGAIN) {
DPRINTF("backend not ready, freezing\n");
s->freeze_output = 1;
break;
}
if (ret <= 0) {
DPRINTF("error putting\n");
s->has_error = 1;
offset = -EINVAL;
break;
}
DPRINTF("put %zd byte(s)\n", ret);
offset += ret;
s->bytes_xfer += ret;
}
if (offset >= 0) {
DPRINTF("buffering %d bytes\n", size - offset);
buffered_append(s, buf + offset, size - offset);
offset = size;
}
if (pos == 0 && size == 0) {
DPRINTF("file is ready\n");
if (s->bytes_xfer <= s->xfer_limit) {
DPRINTF("notifying client\n");
s->put_ready(s->opaque);
}
}
return offset;
}
static int buffered_close(void *opaque)
{
QEMUFileBuffered *s = opaque;
int ret;
DPRINTF("closing\n");
while (!s->has_error && s->buffer_size) {
buffered_flush(s);
if (s->freeze_output)
s->wait_for_unfreeze(s);
}
ret = s->close(s->opaque);
qemu_del_timer(s->timer);
qemu_free_timer(s->timer);
qemu_free(s->buffer);
qemu_free(s);
return ret;
}
static int buffered_rate_limit(void *opaque)
{
QEMUFileBuffered *s = opaque;
if (s->has_error)
return 0;
if (s->freeze_output)
return 1;
if (s->bytes_xfer > s->xfer_limit)
return 1;
return 0;
}
static size_t buffered_set_rate_limit(void *opaque, size_t new_rate)
{
QEMUFileBuffered *s = opaque;
if (s->has_error)
goto out;
s->xfer_limit = new_rate / 10;
out:
return s->xfer_limit;
}
static size_t buffered_get_rate_limit(void *opaque)
{
QEMUFileBuffered *s = opaque;
return s->xfer_limit;
}
static void buffered_rate_tick(void *opaque)
{
QEMUFileBuffered *s = opaque;
if (s->has_error) {
buffered_close(s);
return;
}
qemu_mod_timer(s->timer, qemu_get_clock(rt_clock) + 100);
if (s->freeze_output)
return;
s->bytes_xfer = 0;
buffered_flush(s);
/* Add some checks around this */
s->put_ready(s->opaque);
}
QEMUFile *qemu_fopen_ops_buffered(void *opaque,
size_t bytes_per_sec,
BufferedPutFunc *put_buffer,
BufferedPutReadyFunc *put_ready,
BufferedWaitForUnfreezeFunc *wait_for_unfreeze,
BufferedCloseFunc *close)
{
QEMUFileBuffered *s;
s = qemu_mallocz(sizeof(*s));
s->opaque = opaque;
s->xfer_limit = bytes_per_sec / 10;
s->put_buffer = put_buffer;
s->put_ready = put_ready;
s->wait_for_unfreeze = wait_for_unfreeze;
s->close = close;
s->file = qemu_fopen_ops(s, buffered_put_buffer, NULL,
buffered_close, buffered_rate_limit,
buffered_set_rate_limit,
buffered_get_rate_limit);
s->timer = qemu_new_timer(rt_clock, buffered_rate_tick, s);
qemu_mod_timer(s->timer, qemu_get_clock(rt_clock) + 100);
return s->file;
}
|
414791.c | /*-
* BSD LICENSE
*
* Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Intel Corporation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <rte_string_fns.h>
#include "rte_cfgfile.h"
struct rte_cfgfile_section {
char name[CFG_NAME_LEN];
int num_entries;
struct rte_cfgfile_entry *entries[0];
};
struct rte_cfgfile {
int flags;
int num_sections;
struct rte_cfgfile_section *sections[0];
};
/** when we resize a file structure, how many extra entries
* for new sections do we add in */
#define CFG_ALLOC_SECTION_BATCH 8
/** when we resize a section structure, how many extra entries
* for new entries do we add in */
#define CFG_ALLOC_ENTRY_BATCH 16
static unsigned
_strip(char *str, unsigned len)
{
int newlen = len;
if (len == 0)
return 0;
if (isspace(str[len-1])) {
/* strip trailing whitespace */
while (newlen > 0 && isspace(str[newlen - 1]))
str[--newlen] = '\0';
}
if (isspace(str[0])) {
/* strip leading whitespace */
int i, start = 1;
while (isspace(str[start]) && start < newlen)
start++
; /* do nothing */
newlen -= start;
for (i = 0; i < newlen; i++)
str[i] = str[i+start];
str[i] = '\0';
}
return newlen;
}
struct rte_cfgfile *
rte_cfgfile_load(const char *filename, int flags)
{
int allocated_sections = CFG_ALLOC_SECTION_BATCH;
int allocated_entries = 0;
int curr_section = -1;
int curr_entry = -1;
char buffer[256];
int lineno = 0;
struct rte_cfgfile *cfg = NULL;
FILE *f = fopen(filename, "r");
if (f == NULL)
return NULL;
cfg = malloc(sizeof(*cfg) + sizeof(cfg->sections[0]) *
allocated_sections);
if (cfg == NULL)
goto error2;
memset(cfg->sections, 0, sizeof(cfg->sections[0]) * allocated_sections);
while (fgets(buffer, sizeof(buffer), f) != NULL) {
char *pos = NULL;
size_t len = strnlen(buffer, sizeof(buffer));
lineno++;
if ((len >= sizeof(buffer) - 1) && (buffer[len-1] != '\n')) {
printf("Error line %d - no \\n found on string. "
"Check if line too long\n", lineno);
goto error1;
}
pos = memchr(buffer, ';', sizeof(buffer));
if (pos != NULL) {
*pos = '\0';
len = pos - buffer;
}
len = _strip(buffer, len);
if (buffer[0] != '[' && memchr(buffer, '=', len) == NULL)
continue;
if (buffer[0] == '[') {
/* section heading line */
char *end = memchr(buffer, ']', len);
if (end == NULL) {
printf("Error line %d - no terminating '['"
"character found\n", lineno);
goto error1;
}
*end = '\0';
_strip(&buffer[1], end - &buffer[1]);
/* close off old section and add start new one */
if (curr_section >= 0)
cfg->sections[curr_section]->num_entries =
curr_entry + 1;
curr_section++;
/* resize overall struct if we don't have room for more
sections */
if (curr_section == allocated_sections) {
allocated_sections += CFG_ALLOC_SECTION_BATCH;
struct rte_cfgfile *n_cfg = realloc(cfg,
sizeof(*cfg) + sizeof(cfg->sections[0])
* allocated_sections);
if (n_cfg == NULL) {
printf("Error - no more memory\n");
goto error1;
}
cfg = n_cfg;
}
/* allocate space for new section */
allocated_entries = CFG_ALLOC_ENTRY_BATCH;
curr_entry = -1;
cfg->sections[curr_section] = malloc(
sizeof(*cfg->sections[0]) +
sizeof(cfg->sections[0]->entries[0]) *
allocated_entries);
if (cfg->sections[curr_section] == NULL) {
printf("Error - no more memory\n");
goto error1;
}
snprintf(cfg->sections[curr_section]->name,
sizeof(cfg->sections[0]->name),
"%s", &buffer[1]);
} else {
/* value line */
if (curr_section < 0) {
printf("Error line %d - value outside of"
"section\n", lineno);
goto error1;
}
struct rte_cfgfile_section *sect =
cfg->sections[curr_section];
char *split[2];
if (rte_strsplit(buffer, sizeof(buffer), split, 2, '=')
!= 2) {
printf("Error at line %d - cannot split "
"string\n", lineno);
goto error1;
}
curr_entry++;
if (curr_entry == allocated_entries) {
allocated_entries += CFG_ALLOC_ENTRY_BATCH;
struct rte_cfgfile_section *n_sect = realloc(
sect, sizeof(*sect) +
sizeof(sect->entries[0]) *
allocated_entries);
if (n_sect == NULL) {
printf("Error - no more memory\n");
goto error1;
}
sect = cfg->sections[curr_section] = n_sect;
}
sect->entries[curr_entry] = malloc(
sizeof(*sect->entries[0]));
if (sect->entries[curr_entry] == NULL) {
printf("Error - no more memory\n");
goto error1;
}
struct rte_cfgfile_entry *entry = sect->entries[
curr_entry];
snprintf(entry->name, sizeof(entry->name), "%s",
split[0]);
snprintf(entry->value, sizeof(entry->value), "%s",
split[1]);
_strip(entry->name, strnlen(entry->name,
sizeof(entry->name)));
_strip(entry->value, strnlen(entry->value,
sizeof(entry->value)));
}
}
fclose(f);
cfg->flags = flags;
cfg->sections[curr_section]->num_entries = curr_entry + 1;
cfg->num_sections = curr_section + 1;
return cfg;
error1:
rte_cfgfile_close(cfg);
error2:
fclose(f);
return NULL;
}
int rte_cfgfile_close(struct rte_cfgfile *cfg)
{
int i, j;
if (cfg == NULL)
return -1;
for (i = 0; i < cfg->num_sections; i++) {
if (cfg->sections[i] != NULL) {
if (cfg->sections[i]->num_entries) {
for (j = 0; j < cfg->sections[i]->num_entries;
j++) {
if (cfg->sections[i]->entries[j] !=
NULL)
free(cfg->sections[i]->
entries[j]);
}
}
free(cfg->sections[i]);
}
}
free(cfg);
return 0;
}
int
rte_cfgfile_num_sections(struct rte_cfgfile *cfg, const char *sectionname,
size_t length)
{
int i;
int num_sections = 0;
for (i = 0; i < cfg->num_sections; i++) {
if (strncmp(cfg->sections[i]->name, sectionname, length) == 0)
num_sections++;
}
return num_sections;
}
int
rte_cfgfile_sections(struct rte_cfgfile *cfg, char *sections[],
int max_sections)
{
int i;
for (i = 0; i < cfg->num_sections && i < max_sections; i++)
snprintf(sections[i], CFG_NAME_LEN, "%s",
cfg->sections[i]->name);
return i;
}
static const struct rte_cfgfile_section *
_get_section(struct rte_cfgfile *cfg, const char *sectionname)
{
int i;
for (i = 0; i < cfg->num_sections; i++) {
if (strncmp(cfg->sections[i]->name, sectionname,
sizeof(cfg->sections[0]->name)) == 0)
return cfg->sections[i];
}
return NULL;
}
int
rte_cfgfile_has_section(struct rte_cfgfile *cfg, const char *sectionname)
{
return (_get_section(cfg, sectionname) != NULL);
}
int
rte_cfgfile_section_num_entries(struct rte_cfgfile *cfg,
const char *sectionname)
{
const struct rte_cfgfile_section *s = _get_section(cfg, sectionname);
if (s == NULL)
return -1;
return s->num_entries;
}
int
rte_cfgfile_section_entries(struct rte_cfgfile *cfg, const char *sectionname,
struct rte_cfgfile_entry *entries, int max_entries)
{
int i;
const struct rte_cfgfile_section *sect = _get_section(cfg, sectionname);
if (sect == NULL)
return -1;
for (i = 0; i < max_entries && i < sect->num_entries; i++)
entries[i] = *sect->entries[i];
return i;
}
const char *
rte_cfgfile_get_entry(struct rte_cfgfile *cfg, const char *sectionname,
const char *entryname)
{
int i;
const struct rte_cfgfile_section *sect = _get_section(cfg, sectionname);
if (sect == NULL)
return NULL;
for (i = 0; i < sect->num_entries; i++)
if (strncmp(sect->entries[i]->name, entryname, CFG_NAME_LEN)
== 0)
return sect->entries[i]->value;
return NULL;
}
int
rte_cfgfile_has_entry(struct rte_cfgfile *cfg, const char *sectionname,
const char *entryname)
{
return (rte_cfgfile_get_entry(cfg, sectionname, entryname) != NULL);
}
|
24918.c | /*
* Automatically Generated from Mathematica.
* Thu 4 Nov 2021 16:56:24 GMT-04:00
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "p_left_toe_B_src.h"
#ifdef _MSC_VER
#define INLINE __forceinline /* use __forceinline (VC++ specific) */
#else
#define INLINE static __inline__ /* use standard inline */
#endif
/**
* Copied from Wolfram Mathematica C Definitions file mdefs.hpp
* Changed marcos to inline functions (Eric Cousineau)
*/
INLINE double Power(double x, double y) { return pow(x, y); }
INLINE double Sqrt(double x) { return sqrt(x); }
INLINE double Abs(double x) { return fabs(x); }
INLINE double Exp(double x) { return exp(x); }
INLINE double Log(double x) { return log(x); }
INLINE double Sin(double x) { return sin(x); }
INLINE double Cos(double x) { return cos(x); }
INLINE double Tan(double x) { return tan(x); }
INLINE double Csc(double x) { return 1.0/sin(x); }
INLINE double Sec(double x) { return 1.0/cos(x); }
INLINE double ArcSin(double x) { return asin(x); }
INLINE double ArcCos(double x) { return acos(x); }
/* update ArcTan function to use atan2 instead. */
INLINE double ArcTan(double x, double y) { return atan2(y,x); }
INLINE double Sinh(double x) { return sinh(x); }
INLINE double Cosh(double x) { return cosh(x); }
INLINE double Tanh(double x) { return tanh(x); }
#define E 2.71828182845904523536029
#define Pi 3.14159265358979323846264
#define Degree 0.01745329251994329576924
/*
* Sub functions
*/
static void output1(double *p_output1,const double *var1)
{
double _NotUsed;
NULL;
p_output1[0]=var1[0];
p_output1[1]=var1[1];
p_output1[2]=var1[2];
}
void p_left_toe_B_src(double *p_output1, const double *var1)
{
/* Call Subroutines */
output1(p_output1, var1);
}
|
869552.c | /* ncpos.f -- translated by f2c (version 19980913).
You must link the resulting object file with the libraries:
-lf2c -lm (in that order)
*/
#include "f2c.h"
/* $Procedure NCPOS ( NOT character position ) */
integer ncpos_(char *str, char *chars, integer *start, ftnlen str_len, ftnlen
chars_len)
{
/* System generated locals */
integer ret_val;
/* Builtin functions */
integer i_len(char *, ftnlen), i_indx(char *, char *, ftnlen, ftnlen);
/* Local variables */
integer b;
logical found;
integer lenstr;
/* $ Abstract */
/* Find the first occurrence in a string of a character NOT belonging */
/* to a collection of characters, starting at a specified location, */
/* searching forwards. */
/* $ Disclaimer */
/* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
/* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
/* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
/* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
/* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
/* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
/* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
/* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
/* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
/* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
/* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
/* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
/* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
/* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
/* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
/* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
/* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
/* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
/* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
/* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
/* $ Required_Reading */
/* SCANNING */
/* $ Keywords */
/* CHARACTER */
/* SEARCH */
/* UTILITY */
/* $ Declarations */
/* $ Brief_I/O */
/* VARIABLE I/O DESCRIPTION */
/* -------- --- -------------------------------------------------- */
/* STR I Any character string. */
/* CHARS I A collection of characters. */
/* START I Position to begin looking for one not in CHARS */
/* The function returns the index of the first character of STR */
/* at or following index START that is not in the collection CHARS. */
/* $ Detailed_Input */
/* STR is any character string. */
/* CHARS is a character string containing a collection of */
/* characters. Spaces in CHARS are significant. */
/* START is the position in STR to begin looking for */
/* characters not in CHARS. */
/* $ Detailed_Output */
/* The function returns the index of the first character of STR (at */
/* or following index START) that is not one of the characters in the */
/* string CHARS. If no such character is found, the function returns */
/* zero. */
/* $ Parameters */
/* None. */
/* $ Exceptions */
/* Error free. */
/* 1) If START is less than 1, the search begins at the first */
/* character of the string. */
/* 2) If START is greater than the length of the string, NCPOS */
/* returns zero. */
/* $ Files */
/* None. */
/* $ Particulars */
/* NCPOS is case sensitive. */
/* An entire family of related SPICELIB routines (POS, CPOS, NCPOS, */
/* POSR, CPOSR, NCPOSR) is described in the Required Reading. */
/* Those familiar with the True BASIC language should note that */
/* these functions are equivalent to the True BASIC intrinsic */
/* functions with the same names. */
/* $ Examples */
/* Let STRING = 'BOB, JOHN, TED, AND MARTIN ' */
/* 123456789012345678901234567890 */
/* Let CHAR = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' */
/* Normal (Sequential) Searching: */
/* ------------------------------ */
/* NCPOS( STRING, CHAR, 1 ) = 4 */
/* NCPOS( STRING, CHAR, 5 ) = 5 */
/* NCPOS( STRING, CHAR, 6 ) = 10 */
/* NCPOS( STRING, CHAR, 11 ) = 11 */
/* NCPOS( STRING, CHAR, 12 ) = 15 */
/* NCPOS( STRING, CHAR, 16 ) = 16 */
/* NCPOS( STRING, CHAR, 17 ) = 20 */
/* NCPOS( STRING, CHAR, 21 ) = 27 */
/* NCPOS( STRING, CHAR, 28 ) = 28 */
/* NCPOS( STRING, CHAR, 29 ) = 29 */
/* NCPOS( STRING, CHAR, 30 ) = 30 */
/* NCPOS( STRING, CHAR, 31 ) = 0 */
/* START out of bounds: */
/* -------------------- */
/* NCPOS( STRING, CHAR, -12 ) = 4 */
/* NCPOS( STRING, CHAR, 0 ) = 4 */
/* NCPOS( STRING, CHAR, 31 ) = 0 */
/* NCPOS( STRING, CHAR, 123 ) = 0 */
/* Order within CHARS: */
/* ------------------- */
/* NCPOS( STRING, 'JOHN', 7 ) = 10 */
/* NCPOS( STRING, 'OHJN', 7 ) = 10 */
/* $ Restrictions */
/* None. */
/* $ Literature_References */
/* None. */
/* $ Author_and_Institution */
/* J. Diaz del Rio (ODC Space) */
/* H.A. Neilan (JPL) */
/* B.V. Semenov (JPL) */
/* W.L. Taber (JPL) */
/* $ Version */
/* - SPICELIB Version 1.1.0, 04-JUL-2021 (JDR) */
/* Edited the header to comply with NAIF standard. */
/* - SPICELIB Version 1.0.3, 31-JAN-2008 (BVS) */
/* Removed non-standard end-of-declarations marker */
/* 'C%&END_DECLARATIONS' from comments. */
/* - SPICELIB Version 1.0.2, 10-MAR-1992 (WLT) */
/* Comment section for permuted index source lines was added */
/* following the header. */
/* - SPICELIB Version 1.0.1, 26-MAR-1991 (HAN) */
/* The Required Reading file POSITION was renamed to SCANNING. */
/* This header was updated to reflect the change. */
/* - SPICELIB Version 1.0.0, 31-JAN-1990 (WLT) */
/* -& */
/* $ Index_Entries */
/* forward search for position of unlisted character */
/* -& */
/* Local variables */
lenstr = i_len(str, str_len);
b = max(1,*start);
found = FALSE_;
ret_val = 0;
while(! found) {
if (b > lenstr) {
return ret_val;
} else if (i_indx(chars, str + (b - 1), chars_len, (ftnlen)1) == 0) {
ret_val = b;
return ret_val;
} else {
++b;
}
}
return ret_val;
} /* ncpos_ */
|
553968.c | /* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
/* lib/crypto/openssl/enc_provider/des3.c */
/*
* Copyright (C) 2009 by the Massachusetts Institute of Technology.
* All rights reserved.
*
* Export of this software from the United States of America may
* require a specific license from the United States Government.
* It is the responsibility of any person or organization contemplating
* export to obtain such a license before exporting.
*
* WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
* distribute this software and its documentation for any purpose and
* without fee is hereby granted, provided that the above copyright
* notice appear in all copies and that both that copyright notice and
* this permission notice appear in supporting documentation, and that
* the name of M.I.T. not be used in advertising or publicity pertaining
* to distribution of the software without specific, written prior
* permission. Furthermore if you modify this software you must label
* your software as modified software and not distribute it in such a
* fashion that it might be confused with the original M.I.T. software.
* M.I.T. makes no representations about the suitability of
* this software for any purpose. It is provided "as is" without express
* or implied warranty.
*/
/*
* Copyright (C) 1998 by the FundsXpress, INC.
*
* All rights reserved.
*
* Export of this software from the United States of America may require
* a specific license from the United States Government. It is the
* responsibility of any person or organization contemplating export to
* obtain such a license before exporting.
*
* WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
* distribute this software and its documentation for any purpose and
* without fee is hereby granted, provided that the above copyright
* notice appear in all copies and that both that copyright notice and
* this permission notice appear in supporting documentation, and that
* the name of FundsXpress. not be used in advertising or publicity pertaining
* to distribution of the software without specific, written prior
* permission. FundsXpress makes no representations about the suitability of
* this software for any purpose. It is provided "as is" without express
* or implied warranty.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#include "crypto_int.h"
#include <openssl/evp.h>
#define DES3_BLOCK_SIZE 8
#define DES3_KEY_SIZE 24
#define DES3_KEY_BYTES 21
static krb5_error_code
validate(krb5_key key, const krb5_data *ivec, const krb5_crypto_iov *data,
size_t num_data, krb5_boolean *empty)
{
size_t i, input_length;
for (i = 0, input_length = 0; i < num_data; i++) {
const krb5_crypto_iov *iov = &data[i];
if (ENCRYPT_IOV(iov))
input_length += iov->data.length;
}
if (key->keyblock.length != DES3_KEY_SIZE)
return(KRB5_BAD_KEYSIZE);
if ((input_length%DES3_BLOCK_SIZE) != 0)
return(KRB5_BAD_MSIZE);
if (ivec && (ivec->length != 8))
return(KRB5_BAD_MSIZE);
*empty = (input_length == 0);
return 0;
}
static krb5_error_code
k5_des3_encrypt(krb5_key key, const krb5_data *ivec, krb5_crypto_iov *data,
size_t num_data)
{
int ret, olen = DES3_BLOCK_SIZE;
unsigned char iblock[DES3_BLOCK_SIZE], oblock[DES3_BLOCK_SIZE];
struct iov_block_state input_pos, output_pos;
EVP_CIPHER_CTX ciph_ctx;
krb5_boolean empty;
ret = validate(key, ivec, data, num_data, &empty);
if (ret != 0 || empty)
return ret;
IOV_BLOCK_STATE_INIT(&input_pos);
IOV_BLOCK_STATE_INIT(&output_pos);
EVP_CIPHER_CTX_init(&ciph_ctx);
ret = EVP_EncryptInit_ex(&ciph_ctx, EVP_des_ede3_cbc(), NULL,
key->keyblock.contents,
(ivec) ? (unsigned char*)ivec->data : NULL);
if (!ret)
return KRB5_CRYPTO_INTERNAL;
EVP_CIPHER_CTX_set_padding(&ciph_ctx,0);
for (;;) {
if (!krb5int_c_iov_get_block(iblock, DES3_BLOCK_SIZE,
data, num_data, &input_pos))
break;
ret = EVP_EncryptUpdate(&ciph_ctx, oblock, &olen,
(unsigned char *)iblock, DES3_BLOCK_SIZE);
if (!ret)
break;
krb5int_c_iov_put_block(data, num_data,
oblock, DES3_BLOCK_SIZE, &output_pos);
}
if (ivec != NULL)
memcpy(ivec->data, oblock, DES3_BLOCK_SIZE);
EVP_CIPHER_CTX_cleanup(&ciph_ctx);
zap(iblock, sizeof(iblock));
zap(oblock, sizeof(oblock));
if (ret != 1)
return KRB5_CRYPTO_INTERNAL;
return 0;
}
static krb5_error_code
k5_des3_decrypt(krb5_key key, const krb5_data *ivec, krb5_crypto_iov *data,
size_t num_data)
{
int ret, olen = DES3_BLOCK_SIZE;
unsigned char iblock[DES3_BLOCK_SIZE], oblock[DES3_BLOCK_SIZE];
struct iov_block_state input_pos, output_pos;
EVP_CIPHER_CTX ciph_ctx;
krb5_boolean empty;
ret = validate(key, ivec, data, num_data, &empty);
if (ret != 0 || empty)
return ret;
IOV_BLOCK_STATE_INIT(&input_pos);
IOV_BLOCK_STATE_INIT(&output_pos);
EVP_CIPHER_CTX_init(&ciph_ctx);
ret = EVP_DecryptInit_ex(&ciph_ctx, EVP_des_ede3_cbc(), NULL,
key->keyblock.contents,
(ivec) ? (unsigned char*)ivec->data : NULL);
if (!ret)
return KRB5_CRYPTO_INTERNAL;
EVP_CIPHER_CTX_set_padding(&ciph_ctx,0);
for (;;) {
if (!krb5int_c_iov_get_block(iblock, DES3_BLOCK_SIZE,
data, num_data, &input_pos))
break;
ret = EVP_DecryptUpdate(&ciph_ctx, oblock, &olen,
(unsigned char *)iblock, DES3_BLOCK_SIZE);
if (!ret)
break;
krb5int_c_iov_put_block(data, num_data, oblock, DES3_BLOCK_SIZE,
&output_pos);
}
if (ivec != NULL)
memcpy(ivec->data, iblock, DES3_BLOCK_SIZE);
EVP_CIPHER_CTX_cleanup(&ciph_ctx);
zap(iblock, sizeof(iblock));
zap(oblock, sizeof(oblock));
if (ret != 1)
return KRB5_CRYPTO_INTERNAL;
return 0;
}
const struct krb5_enc_provider krb5int_enc_des3 = {
DES3_BLOCK_SIZE,
DES3_KEY_BYTES, DES3_KEY_SIZE,
k5_des3_encrypt,
k5_des3_decrypt,
NULL,
krb5int_des_init_state,
krb5int_default_free_state
};
|
391386.c | /*-
* Copyright (c) 2013, Joseph Koshy
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer
* in this position and unchanged.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/param.h>
#include <sys/queue.h>
#include <assert.h>
#include <errno.h>
#include <gelf.h>
#include <stdlib.h>
#include <string.h>
#include "libelftc.h"
#include "_libelftc.h"
ELFTC_VCSID("$Id: elftc_string_table.c 2869 2013-01-06 13:29:18Z jkoshy $");
#define ELFTC_STRING_TABLE_DEFAULT_SIZE (4*1024)
#define ELFTC_STRING_TABLE_EXPECTED_STRING_SIZE 16
#define ELFTC_STRING_TABLE_EXPECTED_CHAIN_LENGTH 8
#define ELFTC_STRING_TABLE_POOL_SIZE_INCREMENT (4*1024)
struct _Elftc_String_Table_Entry {
int ste_idx;
SLIST_ENTRY(_Elftc_String_Table_Entry) ste_next;
};
#define ELFTC_STRING_TABLE_COMPACTION_FLAG 0x1
#define ELFTC_STRING_TABLE_LENGTH(st) ((st)->st_len >> 1)
#define ELFTC_STRING_TABLE_CLEAR_COMPACTION_FLAG(st) do { \
(st)->st_len &= ~ELFTC_STRING_TABLE_COMPACTION_FLAG; \
} while (0)
#define ELFTC_STRING_TABLE_SET_COMPACTION_FLAG(st) do { \
(st)->st_len |= ELFTC_STRING_TABLE_COMPACTION_FLAG; \
} while (0)
#define ELFTC_STRING_TABLE_UPDATE_LENGTH(st, len) do { \
(st)->st_len = \
((st)->st_len & \
ELFTC_STRING_TABLE_COMPACTION_FLAG) | \
((len) << 1); \
} while (0)
struct _Elftc_String_Table {
unsigned int st_len; /* length and flags */
int st_nbuckets;
int st_string_pool_size;
char *st_string_pool;
SLIST_HEAD(_Elftc_String_Table_Bucket,
_Elftc_String_Table_Entry) st_buckets[];
};
static struct _Elftc_String_Table_Entry *
elftc_string_table_find_hash_entry(Elftc_String_Table *st, const char *string,
int *rhashindex)
{
struct _Elftc_String_Table_Entry *ste;
int hashindex;
char *s;
hashindex = libelftc_hash_string(string) % st->st_nbuckets;
if (rhashindex)
*rhashindex = hashindex;
SLIST_FOREACH(ste, &st->st_buckets[hashindex], ste_next) {
s = st->st_string_pool + abs(ste->ste_idx);
assert(s > st->st_string_pool &&
s < st->st_string_pool + st->st_string_pool_size);
if (strcmp(s, string) == 0)
return (ste);
}
return (NULL);
}
static int
elftc_string_table_add_to_pool(Elftc_String_Table *st, const char *string)
{
char *newpool;
int len, newsize, stlen;
len = strlen(string) + 1; /* length, including the trailing NUL */
stlen = ELFTC_STRING_TABLE_LENGTH(st);
/* Resize the pool, if needed. */
if (stlen + len >= st->st_string_pool_size) {
newsize = roundup(st->st_string_pool_size +
ELFTC_STRING_TABLE_POOL_SIZE_INCREMENT,
ELFTC_STRING_TABLE_POOL_SIZE_INCREMENT);
if ((newpool = realloc(st->st_string_pool, newsize)) ==
NULL)
return (0);
st->st_string_pool = newpool;
st->st_string_pool_size = newsize;
}
strcpy(st->st_string_pool + stlen, string);
ELFTC_STRING_TABLE_UPDATE_LENGTH(st, stlen + len);
return (stlen);
}
Elftc_String_Table *
elftc_string_table_create(int sizehint)
{
int n, nbuckets, tablesize;
struct _Elftc_String_Table *st;
if (sizehint < ELFTC_STRING_TABLE_DEFAULT_SIZE)
sizehint = ELFTC_STRING_TABLE_DEFAULT_SIZE;
nbuckets = sizehint / (ELFTC_STRING_TABLE_EXPECTED_CHAIN_LENGTH *
ELFTC_STRING_TABLE_EXPECTED_STRING_SIZE);
tablesize = sizeof(struct _Elftc_String_Table) +
nbuckets * sizeof(struct _Elftc_String_Table_Bucket);
if ((st = malloc(tablesize)) == NULL)
return (NULL);
if ((st->st_string_pool = malloc(sizehint)) == NULL) {
free(st);
return (NULL);
}
for (n = 0; n < nbuckets; n++)
SLIST_INIT(&st->st_buckets[n]);
st->st_len = 0;
st->st_nbuckets = nbuckets;
st->st_string_pool_size = sizehint;
*st->st_string_pool = '\0';
ELFTC_STRING_TABLE_UPDATE_LENGTH(st, 1);
return (st);
}
void
elftc_string_table_destroy(Elftc_String_Table *st)
{
int n;
struct _Elftc_String_Table_Entry *s, *t;
for (n = 0; n < st->st_nbuckets; n++)
SLIST_FOREACH_SAFE(s, &st->st_buckets[n], ste_next, t)
free(s);
free(st->st_string_pool);
free(st);
return;
}
Elftc_String_Table *
elftc_string_table_from_section(Elf_Scn *scn, int sizehint)
{
int len;
Elf_Data *d;
GElf_Shdr sh;
const char *s, *end;
Elftc_String_Table *st;
/* Verify the type of the section passed in. */
if (gelf_getshdr(scn, &sh) == NULL ||
sh.sh_type != SHT_STRTAB) {
errno = EINVAL;
return (NULL);
}
if ((d = elf_getdata(scn, NULL)) == NULL ||
d->d_size == 0) {
errno = EINVAL;
return (NULL);
}
if ((st = elftc_string_table_create(sizehint)) == NULL)
return (NULL);
s = d->d_buf;
/*
* Verify that the first byte of the data buffer is '\0'.
*/
if (*s != '\0') {
errno = EINVAL;
goto fail;
}
end = s + d->d_size;
/*
* Skip the first '\0' and insert the strings in the buffer,
* in order.
*/
for (s += 1; s < end; s += len) {
if (elftc_string_table_insert(st, s) == 0)
goto fail;
len = strlen(s) + 1; /* Include space for the trailing NUL. */
}
return (st);
fail:
if (st)
(void) elftc_string_table_destroy(st);
return (NULL);
}
const char *
elftc_string_table_image(Elftc_String_Table *st, size_t *size)
{
char *r, *s, *end;
struct _Elftc_String_Table_Entry *ste;
struct _Elftc_String_Table_Bucket *head;
int copied, hashindex, offset, length, newsize;
/*
* For the common case of a string table has not seen
* a string deletion, we can just export the current
* pool.
*/
if ((st->st_len & ELFTC_STRING_TABLE_COMPACTION_FLAG) == 0) {
if (size)
*size = ELFTC_STRING_TABLE_LENGTH(st);
return (st->st_string_pool);
}
/*
* Otherwise, compact the string table in-place.
*/
assert(*st->st_string_pool == '\0');
newsize = 1;
end = st->st_string_pool + ELFTC_STRING_TABLE_LENGTH(st);
for (r = s = st->st_string_pool + 1;
s < end;
s += length, r += copied) {
copied = 0;
length = strlen(s) + 1;
ste = elftc_string_table_find_hash_entry(st, s,
&hashindex);
head = &st->st_buckets[hashindex];
assert(ste != NULL);
/* Ignore deleted strings. */
if (ste->ste_idx < 0) {
SLIST_REMOVE(head, ste, _Elftc_String_Table_Entry,
ste_next);
free(ste);
continue;
}
/* Move 'live' strings up. */
offset = newsize;
newsize += length;
copied = length;
if (r == s) /* Nothing removed yet. */
continue;
memmove(r, s, copied);
/* Update the index for this entry. */
ste->ste_idx = offset;
}
ELFTC_STRING_TABLE_CLEAR_COMPACTION_FLAG(st);
ELFTC_STRING_TABLE_UPDATE_LENGTH(st, newsize);
if (size)
*size = newsize;
return (st->st_string_pool);
}
size_t
elftc_string_table_insert(Elftc_String_Table *st, const char *string)
{
int hashindex, idx;
struct _Elftc_String_Table_Entry *ste;
hashindex = 0;
ste = elftc_string_table_find_hash_entry(st, string, &hashindex);
assert(hashindex >= 0 && hashindex < st->st_nbuckets);
if (ste == NULL) {
if ((ste = malloc(sizeof(*ste))) == NULL)
return (0);
if ((ste->ste_idx = elftc_string_table_add_to_pool(st,
string)) == 0) {
free(ste);
return (0);
}
SLIST_INSERT_HEAD(&st->st_buckets[hashindex], ste, ste_next);
}
idx = ste->ste_idx;
if (idx < 0) /* Undelete. */
ste->ste_idx = idx = (- idx);
return (idx);
}
size_t
elftc_string_table_lookup(Elftc_String_Table *st, const char *string)
{
int hashindex, idx;
struct _Elftc_String_Table_Entry *ste;
ste = elftc_string_table_find_hash_entry(st, string, &hashindex);
assert(hashindex >= 0 && hashindex < st->st_nbuckets);
if (ste == NULL || (idx = ste->ste_idx) < 0)
return (0);
return (idx);
}
int
elftc_string_table_remove(Elftc_String_Table *st, const char *string)
{
int idx;
struct _Elftc_String_Table_Entry *ste;
ste = elftc_string_table_find_hash_entry(st, string, NULL);
if (ste == NULL || (idx = ste->ste_idx) < 0)
return (ELFTC_FAILURE);
assert(idx > 0 && idx < (int) ELFTC_STRING_TABLE_LENGTH(st));
ste->ste_idx = (- idx);
ELFTC_STRING_TABLE_SET_COMPACTION_FLAG(st);
return (ELFTC_SUCCESS);
}
const char *
elftc_string_table_to_string(Elftc_String_Table *st, size_t offset)
{
const char *s;
s = st->st_string_pool + offset;
/*
* Check for:
* - An offset value within pool bounds.
* - A non-NUL byte at the specified offset.
* - The end of the prior string at offset - 1.
*/
if (offset == 0 || offset >= ELFTC_STRING_TABLE_LENGTH(st) ||
*s == '\0' || *(s - 1) != '\0') {
errno = EINVAL;
return (NULL);
}
return (s);
}
|
690853.c | #include <stdio.h>
int main(void) {
int i, j;
int tensu[2][4][3] = {
{ { 91, 63, 78 }, {67, 72, 46}, {89, 34, 53}, {32, 54, 34} },
{ { 97, 67, 82 }, {73, 43, 46}, {97, 56, 21}, {85, 46, 35} }
};
int sum[4][3] = {0};
// 求两次考试的分数之和
for (i = 0; i < 4; i++) {
for (j = 0; j < 3; j++) {
for (int k = 0; k < 2; k++) {
sum[i][j] += tensu[k][i][j];
}
}
}
puts("第一次考试的分数: ");
for (i = 0; i < 4; i++) {
for (j = 0; j < 3; j++) {
printf("%4d", tensu[0][i][j]);
}
putchar('\n');
}
puts("第二次考试的分数: ");
for (i = 0; i < 4; i++) {
for (j = 0; j < 3; j++) {
printf("%4d", tensu[1][i][j]);
}
putchar('\n');
}
puts("总分: ");
for (i = 0; i < 4; i++) {
for (j = 0; j < 3; j++) {
printf("%4d", sum[i][j]);
}
putchar('\n');
}
return 0;
}
/*
第一次考试的分数:
91 63 78
67 72 46
89 34 53
32 54 34
第二次考试的分数:
97 67 82
73 43 46
97 56 21
85 46 35
总分:
188 130 160
140 115 92
186 90 74
117 100 69
*/ |
618757.c | // SPDX-License-Identifier: GPL-2.0+
/*
* Copyright (c) 2012, Google Inc.
*/
#include <common.h>
#include <fs.h>
#include <os.h>
int sandbox_fs_set_blk_dev(struct blk_desc *rbdd, disk_partition_t *info)
{
/*
* Only accept a NULL struct blk_desc for the sandbox, which is when
* hostfs interface is used
*/
return rbdd != NULL;
}
int sandbox_fs_read_at(const char *filename, loff_t pos, void *buffer,
loff_t maxsize, loff_t *actread)
{
loff_t size;
int fd, ret;
fd = os_open(filename, OS_O_RDONLY);
if (fd < 0)
return fd;
ret = os_lseek(fd, pos, OS_SEEK_SET);
if (ret == -1) {
os_close(fd);
return ret;
}
if (!maxsize) {
ret = os_get_filesize(filename, &size);
if (ret) {
os_close(fd);
return ret;
}
maxsize = size;
}
size = os_read(fd, buffer, maxsize);
os_close(fd);
if (size < 0) {
ret = -1;
} else {
ret = 0;
*actread = size;
}
return ret;
}
int sandbox_fs_write_at(const char *filename, loff_t pos, void *buffer,
loff_t towrite, loff_t *actwrite)
{
ssize_t size;
int fd, ret;
fd = os_open(filename, OS_O_RDWR | OS_O_CREAT);
if (fd < 0)
return fd;
ret = os_lseek(fd, pos, OS_SEEK_SET);
if (ret == -1) {
os_close(fd);
return ret;
}
size = os_write(fd, buffer, towrite);
os_close(fd);
if (size == -1) {
ret = -1;
} else {
ret = 0;
*actwrite = size;
}
return ret;
}
int sandbox_fs_ls(const char *dirname)
{
struct os_dirent_node *head, *node;
int ret;
ret = os_dirent_ls(dirname, &head);
if (ret)
goto out;
for (node = head; node; node = node->next) {
printf("%s %10lu %s\n", os_dirent_get_typename(node->type),
node->size, node->name);
}
out:
os_dirent_free(head);
return ret;
}
int sandbox_fs_exists(const char *filename)
{
loff_t size;
int ret;
ret = os_get_filesize(filename, &size);
return ret == 0;
}
int sandbox_fs_size(const char *filename, loff_t *size)
{
return os_get_filesize(filename, size);
}
void sandbox_fs_close(void)
{
}
int fs_read_sandbox(const char *filename, void *buf, loff_t offset, loff_t len,
loff_t *actread)
{
int ret;
ret = sandbox_fs_read_at(filename, offset, buf, len, actread);
if (ret)
printf("** Unable to read file %s **\n", filename);
return ret;
}
int fs_write_sandbox(const char *filename, void *buf, loff_t offset,
loff_t len, loff_t *actwrite)
{
int ret;
ret = sandbox_fs_write_at(filename, offset, buf, len, actwrite);
if (ret)
printf("** Unable to write file %s **\n", filename);
return ret;
}
|