text:
% should be paired with features.m
function w = getweights(model)

if(~isfield(model, 'feattype') || strcmp(model.feattype, 'type1'))
    w = getweights1(model);
elseif(strcmp(model.feattype, 'type2'))
    w = getweights2(model);
elseif(strcmp(model.feattype, 'type3'))
    w = getweights3(model);
elseif(strcmp(model.feattype, 'type5'))
    w = getweights5(model);
elseif(strcmp(model.feattype, 'type6'))
    w = getweights6(model);
elseif(strcmp(model.feattype, 'itm_v0'))
    w = getweights_itm0(model);
elseif(strcmp(model.feattype, 'itm_v1'))
    w = getweights_itm1(model);
elseif(strcmp(model.feattype, 'itm_v2'))
    w = getweights_itm2(model);
elseif(strcmp(model.feattype, 'itm_v3'))
    w = getweights_itm3(model);
end

end

function w = getweights_itm3(model)
featlen =   1 + ... % scene classification
            1 + ... % layout confidence : no bias required, selection problem
            2 * model.nobjs + ... % object confidence : (weight + bias) per type
            model.nobjs + 1 + ...  % object-wall inclusion + floor area prior
            ( (model.nobjs+1) * model.nscene ) + ... % semantic constext
            sum(model.itmfeatlen) + ... % intearction templates!
            2 + ... % object-object interaction : 2D bboverlap, 2D polyoverlap
            model.nobjs + ...         % projection-deformation cost
            1;              % floor distance

w = zeros(featlen, 1);
ibase = 1;
% scene classification
w(ibase) = model.w_os;
ibase = ibase + 1;
% layout confidence
w(ibase) = model.w_or;
ibase = ibase + 1;
% object confidence
w(ibase:ibase+2*model.nobjs-1) = model.w_oo;
ibase = ibase+2*model.nobjs;
% object-wall inclusion
w(ibase:ibase + (model.nobjs + 1) - 1) = model.w_ior;
ibase = ibase + model.nobjs + 1;
% semantic constext
w(ibase:ibase+model.nscene*(model.nobjs+1)-1) = model.w_iso;
ibase = ibase + model.nscene*(model.nobjs+1);
% intearction templates!
for i = 1:length(model.itmptns)
    w(ibase:ibase+model.itmfeatlen(i)-1) = getITMweights2(model.itmptns(i));
    ibase = ibase + model.itmfeatlen(i);
end
% object-object interaction
w(ibase:ibase+1) = model.w_ioo;
ibase = ibase + 2;
% projection-deformation cost
w(ibase:ibase+model.nobjs-1) = model.w_iod;
ibase = ibase + model.nobjs;
% floor distance
w(ibase) = model.w_iof;
ibase = ibase + 1;

assert(featlen == ibase - 1);

end

function w = getweights_itm2(model)
featlen =   1 + ... % scene classification
            1 + ... % layout confidence : no bias required, selection problem
            2 * model.nobjs + ... % object confidence : (weight + bias) per type
            model.nobjs + 1 + ...  % object-wall inclusion + floor area prior
            ( model.nobjs * model.nscene ) + ... % semantic constext
            sum(model.itmfeatlen) + ... % intearction templates!
            2 + ... % object-object interaction : 2D bboverlap, 2D polyoverlap
            model.nobjs + ...         % projection-deformation cost
            1;              % floor distance

w = zeros(featlen, 1);
ibase = 1;
% scene classification
w(ibase) = model.w_os;
ibase = ibase + 1;
% layout confidence
w(ibase) = model.w_or;
ibase = ibase + 1;
% object confidence
w(ibase:ibase+2*model.nobjs-1) = model.w_oo;
ibase = ibase+2*model.nobjs;
% object-wall inclusion
w(ibase:ibase + (model.nobjs + 1) - 1) = model.w_ior;
ibase = ibase + model.nobjs + 1;
% semantic constext
w(ibase:ibase+model.nscene*model.nobjs-1) = model.w_iso;
ibase = ibase + model.nscene*model.nobjs;
% intearction templates!
for i = 1:length(model.itmptns)
    w(ibase:ibase+model.itmfeatlen(i)-1) = getITMweights(model.itmptns(i));
    ibase = ibase + model.itmfeatlen(i);
end
% object-object interaction
w(ibase:ibase+1) = model.w_ioo;
ibase = ibase + 2;
% projection-deformation cost
w(ibase:ibase+model.nobjs-1) = model.w_iod;
ibase = ibase + model.nobjs;
% floor distance
w(ibase) = model.w_iof;
ibase = ibase + 1;

assert(featlen == ibase - 1);

end

function w = getweights_itm1(model)
featlen =   1 + ... % scene classification
            1 + ... % layout confidence : no bias required, selection problem
            2 * model.nobjs + ... % object confidence : (weight + bias) per type
            model.nobjs*( length(model.ow_edge) - 1 ) + ... % object-wall inclusion
            ( model.nobjs * model.nscene ) + ... % semantic constext
            sum(model.itmfeatlen) + ... % intearction templates!
            2 + ... % object-object interaction : 2D bboverlap, 2D polyoverlap
            model.nobjs + ...         % projection-deformation cost
            1;              % floor distance

w = zeros(featlen, 1);
ibase = 1;
% scene classification
w(ibase) = model.w_os;
ibase = ibase + 1;
% layout confidence
w(ibase) = model.w_or;
ibase = ibase + 1;
% object confidence
w(ibase:ibase+2*model.nobjs-1) = model.w_oo;
ibase = ibase+2*model.nobjs;
% object-wall inclusion
w(ibase:ibase+(model.nobjs*(length(model.ow_edge)-1))-1) = model.w_ior;
ibase = ibase + model.nobjs*(length(model.ow_edge)-1);
% semantic constext
w(ibase:ibase+model.nscene*model.nobjs-1) = model.w_iso;
ibase = ibase + model.nscene*model.nobjs;
% intearction templates!
for i = 1:length(model.itmptns)
    w(ibase:ibase+model.itmfeatlen(i)-1) = getITMweights(model.itmptns(i));
    ibase = ibase + model.itmfeatlen(i);
end
% object-object interaction
w(ibase:ibase+1) = model.w_ioo;
ibase = ibase + 2;
% projection-deformation cost
w(ibase:ibase+model.nobjs-1) = model.w_iod;
ibase = ibase + model.nobjs;
% floor distance
w(ibase) = model.w_iof;
ibase = ibase + 1;

assert(featlen == ibase - 1);

end

function w = getweights_itm0(model)
featlen =   1 + ... % scene classification
            1 + ... % layout confidence : no bias required, selection problem
            2 * model.nobjs + ... % object confidence : (weight + bias) per type
            ( length(model.ow_edge) - 1 ) + ... % object-wall inclusion
            ( model.nobjs * model.nscene ) + ... % semantic constext
            sum(model.itmfeatlen) + ... % intearction templates!
            2 + ... % object-object interaction : 2D bboverlap, 2D polyoverlap
            1 + ...         % projection-deformation cost
            1;              % floor distance

w = zeros(featlen, 1);
ibase = 1;
% scene classification
w(ibase) = model.w_os;
ibase = ibase + 1;
% layout confidence
w(ibase) = model.w_or;
ibase = ibase + 1;
% object confidence
w(ibase:ibase+2*model.nobjs-1) = model.w_oo;
ibase = ibase+2*model.nobjs;
% object-wall inclusion
w(ibase:ibase+length(model.ow_edge)-2) = model.w_ior;
ibase = ibase + length(model.ow_edge) - 1;
% semantic constext
w(ibase:ibase+model.nscene*model.nobjs-1) = model.w_iso;
ibase = ibase + model.nscene*model.nobjs;
% intearction templates!
for i = 1:length(model.itmptns)
    w(ibase:ibase+model.itmfeatlen(i)-1) = getITMweights(model.itmptns(i));
    ibase = ibase + model.itmfeatlen(i);
end
% object-object interaction
w(ibase:ibase+1) = model.w_ioo;
ibase = ibase + 2;
% projection-deformation cost
w(ibase) = model.w_iod;
ibase = ibase + 1;
% floor distance
w(ibase) = model.w_iof;
ibase = ibase + 1;

assert(featlen == ibase - 1);

end

function w = getweights6(model)
featlen =   1 + ... % scene classification
            1 + ... % layout confidence : no bias required, selection problem
            2 * model.nobjs + ... % object confidence : (weight + bias) per type
            model.nobjs * ( length(model.ow_edge) - 1 ) + ... % object-wall inclusion
            ( model.nobjs * model.nscene ) + ... % semantic constext
            0 + ... % intearction templates!
            2 + ... % object-object interaction : 2D bboverlap, 2D polyoverlap
            model.nobjs + ...         % projection-deformation cost
            1;              % floor distance

w = zeros(featlen, 1);
ibase = 1;
% scene classification
w(ibase) = model.w_os;
ibase = ibase + 1;
% layout confidence
w(ibase) = model.w_or;
ibase = ibase + 1;
% object confidence
w(ibase:ibase+2*model.nobjs-1) = model.w_oo;
ibase = ibase+2*model.nobjs;
% object-wall inclusion
w(ibase:ibase+(model.nobjs*(length(model.ow_edge)-1))-1) = model.w_ior;
ibase = ibase + model.nobjs*(length(model.ow_edge)-1);
% semantic constext
w(ibase:ibase+model.nscene*model.nobjs-1) = model.w_iso;
ibase = ibase + model.nscene*model.nobjs;
% intearction templates!

% object-object interaction
w(ibase:ibase+1) = model.w_ioo;
ibase = ibase + 2;
% projection-deformation cost
w(ibase:ibase+model.nobjs-1) = model.w_iod;
ibase = ibase + model.nobjs;
% floor distance
w(ibase) = model.w_iof;
ibase = ibase + 1;

assert(featlen == ibase - 1);

end

function w = getweights5(model)
featlen =   1 + ... % scene classification
            1 + ... % layout confidence : no bias required, selection problem
            2 * model.nobjs + ... % object confidence : (weight + bias) per type
            ( length(model.ow_edge) - 1 ) + ... % object-wall inclusion
            ( model.nobjs * model.nscene ) + ... % semantic constext
            0 + ... % intearction templates!
            2 + ... % object-object interaction : 2D bboverlap, 2D polyoverlap
            1 + ...         % projection-deformation cost
            1;              % floor distance

w = zeros(featlen, 1);
ibase = 1;
% scene classification
w(ibase) = model.w_os;
ibase = ibase + 1;
% layout confidence
w(ibase) = model.w_or;
ibase = ibase + 1;
% object confidence
w(ibase:ibase+2*model.nobjs-1) = model.w_oo;
ibase = ibase+2*model.nobjs;
% object-wall inclusion
w(ibase:ibase+length(model.ow_edge)-2) = model.w_ior;
ibase = ibase + length(model.ow_edge) - 1;
% semantic constext
w(ibase:ibase+model.nscene*model.nobjs-1) = model.w_iso;
ibase = ibase + model.nscene*model.nobjs;
% intearction templates!

% object-object interaction
w(ibase:ibase+1) = model.w_ioo;
ibase = ibase + 2;
% projection-deformation cost
w(ibase) = model.w_iod;
ibase = ibase + 1;
% floor distance
w(ibase) = model.w_iof;
ibase = ibase + 1;

assert(featlen == ibase - 1);

end

function w = getweights3(model)
featlen =   1 + ... % layout confidence : no bias required, selection problem
            2 + ... % object pairs : 2D bboverlap
            (length(model.ow_edge) - 1) + ... % object inclusion : 3D volume intersection
            1 + ...       % projection-deformation cost
            1 + ...       % floor distance
            2 * model.nobjs;      % object confidence : (weight + bias) per type

w = zeros(featlen, 1);
ibase = 1;
w(ibase) = model.w_or;
ibase = ibase + 1;
w(ibase:ibase+1) = model.w_ioo;
ibase = ibase + 2;
w(ibase:ibase+length(model.ow_edge)-2) = model.w_ior;
ibase = ibase + length(model.ow_edge) - 1;
w(ibase) = model.w_iod;
ibase = ibase + 1;
w(ibase) = model.w_iof;
ibase = ibase + 1;
w(ibase:ibase+2*model.nobjs-1) = model.w_oo;
ibase = ibase+2*model.nobjs;

assert(featlen == ibase - 1);

end

function w = getweights2(model)
featlen =   1 + ... % layout confidence : no bias required, selection problem
            2 + ... % object pairs : 1) 3D intersection 2) 2D bboverlap
            3 * (length(model.ow_edge) - 1) + ... % object inclusion : 3D volume intersection
            model.nobjs + ... % min distance to wall 3D
            model.nobjs + ... % min distance to wall 2D
            model.nobjs + ... % floor distance per object: sofa to floor
            2 * model.nobjs;      % object confidence : (weight + bias) per type

w = zeros(featlen, 1);
ibase = 1;
w(ibase) = model.w_or;
ibase = ibase + 1;

w(ibase:ibase+1) = model.w_ioo;
ibase = ibase + 2;

w(ibase:ibase+3 * (length(model.ow_edge) - 1)-1) = model.w_ior;
ibase = ibase + 3 * (length(model.ow_edge) - 1);

w(ibase:ibase+model.nobjs-1) = model.w_iow3;
ibase = ibase + model.nobjs;

w(ibase:ibase+model.nobjs-1) = model.w_iow2;
ibase = ibase + model.nobjs;

w(ibase:ibase+model.nobjs-1) = model.w_iof;
ibase = ibase + model.nobjs;

w(ibase:ibase+2*model.nobjs-1) = model.w_oo;
ibase = ibase+2*model.nobjs;

assert(featlen == ibase - 1);

end

function w = getweights1(model)
featlen =   1 + ... % layout confidence : no bias required, selection problem
            2 + ... % object pairs : 1) 3D intersection 2) 2D bboverlap
            5 + ... % object inclusion : 3D volume intersection
            model.nobjs + ... % min distance to wall 3D
            model.nobjs + ... % min distance to wall 2D
            model.nobjs + ... % floor distance per object: sofa to floor
            2 * model.nobjs;      % object confidence : (weight + bias) per type

w = zeros(featlen, 1);
ibase = 1;
w(ibase) = model.w_or;
ibase = ibase + 1;

w(ibase:ibase+1) = model.w_ioo;
ibase = ibase + 2;

w(ibase:ibase+4) = model.w_ior;
ibase = ibase + 5;

w(ibase:ibase+model.nobjs-1) = model.w_iow3;
ibase = ibase + model.nobjs;

w(ibase:ibase+model.nobjs-1) = model.w_iow2;
ibase = ibase + model.nobjs;

w(ibase:ibase+model.nobjs-1) = model.w_iof;
ibase = ibase + model.nobjs;

w(ibase:ibase+2*model.nobjs-1) = model.w_oo;
ibase = ibase+2*model.nobjs;

assert(featlen == ibase - 1);

end


text:
#include "includes.h"

#include "common.h"
#include "eap_server/eap.h"
#include "eapol_auth_sm.h"
#include "eapol_auth_sm_i.h"

static inline const char * port_type_txt(PortTypes pt)
{
	switch (pt) {
	case ForceUnauthorized: return "ForceUnauthorized";
	case ForceAuthorized: return "ForceAuthorized";
	case Auto: return "Auto";
	default: return "Unknown";
	}
}

static inline const char * port_state_txt(PortState ps)
{
	switch (ps) {
	case Unauthorized: return "Unauthorized";
	case Authorized: return "Authorized";
	default: return "Unknown";
	}
}

static inline const char * ctrl_dir_txt(ControlledDirection dir)
{
	switch (dir) {
	case Both: return "Both";
	case In: return "In";
	default: return "Unknown";
	}
}

static inline const char * auth_pae_state_txt(int s)
{
	switch (s) {
	case AUTH_PAE_INITIALIZE: return "INITIALIZE";
	case AUTH_PAE_DISCONNECTED: return "DISCONNECTED";
	case AUTH_PAE_CONNECTING: return "CONNECTING";
	case AUTH_PAE_AUTHENTICATING: return "AUTHENTICATING";
	case AUTH_PAE_AUTHENTICATED: return "AUTHENTICATED";
	case AUTH_PAE_ABORTING: return "ABORTING";
	case AUTH_PAE_HELD: return "HELD";
	case AUTH_PAE_FORCE_AUTH: return "FORCE_AUTH";
	case AUTH_PAE_FORCE_UNAUTH: return "FORCE_UNAUTH";
	case AUTH_PAE_RESTART: return "RESTART";
	default: return "Unknown";
	}
}

static inline const char * be_auth_state_txt(int s)
{
	switch (s) {
	case BE_AUTH_REQUEST: return "REQUEST";
	case BE_AUTH_RESPONSE: return "RESPONSE";
	case BE_AUTH_SUCCESS: return "SUCCESS";
	case BE_AUTH_FAIL: return "FAIL";
	case BE_AUTH_TIMEOUT: return "TIMEOUT";
	case BE_AUTH_IDLE: return "IDLE";
	case BE_AUTH_INITIALIZE: return "INITIALIZE";
	case BE_AUTH_IGNORE: return "IGNORE";
	default: return "Unknown";
	}
}

static inline const char * reauth_timer_state_txt(int s)
{
	switch (s) {
	case REAUTH_TIMER_INITIALIZE: return "INITIALIZE";
	case REAUTH_TIMER_REAUTHENTICATE: return "REAUTHENTICATE";
	default: return "Unknown";
	}
}

static inline const char * auth_key_tx_state_txt(int s)
{
	switch (s) {
	case AUTH_KEY_TX_NO_KEY_TRANSMIT: return "NO_KEY_TRANSMIT";
	case AUTH_KEY_TX_KEY_TRANSMIT: return "KEY_TRANSMIT";
	default: return "Unknown";
	}
}

static inline const char * key_rx_state_txt(int s)
{
	switch (s) {
	case KEY_RX_NO_KEY_RECEIVE: return "NO_KEY_RECEIVE";
	case KEY_RX_KEY_RECEIVE: return "KEY_RECEIVE";
	default: return "Unknown";
	}
}

static inline const char * ctrl_dir_state_txt(int s)
{
	switch (s) {
	case CTRL_DIR_FORCE_BOTH: return "FORCE_BOTH";
	case CTRL_DIR_IN_OR_BOTH: return "IN_OR_BOTH";
	default: return "Unknown";
	}
}

void eapol_auth_dump_state(FILE *f, const char *prefix,
			   struct eapol_state_machine *sm)
{
	fprintf(f, "%sEAPOL state machine:\n", prefix);
	fprintf(f, "%s  aWhile=%d quietWhile=%d reAuthWhen=%d\n", prefix,
		sm->aWhile, sm->quietWhile, sm->reAuthWhen);
#define _SB(b) ((b) ? "TRUE" : "FALSE")
	fprintf(f,
		"%s  authAbort=%s authFail=%s authPortStatus=%s authStart=%s\n"
		"%s  authTimeout=%s authSuccess=%s eapFail=%s eapolEap=%s\n"
		"%s  eapSuccess=%s eapTimeout=%s initialize=%s "
		"keyAvailable=%s\n"
		"%s  keyDone=%s keyRun=%s keyTxEnabled=%s portControl=%s\n"
		"%s  portEnabled=%s portValid=%s reAuthenticate=%s\n",
		prefix, _SB(sm->authAbort), _SB(sm->authFail),
		port_state_txt(sm->authPortStatus), _SB(sm->authStart),
		prefix, _SB(sm->authTimeout), _SB(sm->authSuccess),
		_SB(sm->eap_if->eapFail), _SB(sm->eapolEap),
		prefix, _SB(sm->eap_if->eapSuccess),
		_SB(sm->eap_if->eapTimeout),
		_SB(sm->initialize), _SB(sm->eap_if->eapKeyAvailable),
		prefix, _SB(sm->keyDone), _SB(sm->keyRun),
		_SB(sm->keyTxEnabled), port_type_txt(sm->portControl),
		prefix, _SB(sm->eap_if->portEnabled), _SB(sm->portValid),
		_SB(sm->reAuthenticate));

	fprintf(f, "%s  Authenticator PAE:\n"
		"%s    state=%s\n"
		"%s    eapolLogoff=%s eapolStart=%s eapRestart=%s\n"
		"%s    portMode=%s reAuthCount=%d\n"
		"%s    quietPeriod=%d reAuthMax=%d\n"
		"%s    authEntersConnecting=%d\n"
		"%s    authEapLogoffsWhileConnecting=%d\n"
		"%s    authEntersAuthenticating=%d\n"
		"%s    authAuthSuccessesWhileAuthenticating=%d\n"
		"%s    authAuthTimeoutsWhileAuthenticating=%d\n"
		"%s    authAuthFailWhileAuthenticating=%d\n"
		"%s    authAuthEapStartsWhileAuthenticating=%d\n"
		"%s    authAuthEapLogoffWhileAuthenticating=%d\n"
		"%s    authAuthReauthsWhileAuthenticated=%d\n"
		"%s    authAuthEapStartsWhileAuthenticated=%d\n"
		"%s    authAuthEapLogoffWhileAuthenticated=%d\n",
		prefix, prefix, auth_pae_state_txt(sm->auth_pae_state), prefix,
		_SB(sm->eapolLogoff), _SB(sm->eapolStart),
		_SB(sm->eap_if->eapRestart),
		prefix, port_type_txt(sm->portMode), sm->reAuthCount,
		prefix, sm->quietPeriod, sm->reAuthMax,
		prefix, sm->authEntersConnecting,
		prefix, sm->authEapLogoffsWhileConnecting,
		prefix, sm->authEntersAuthenticating,
		prefix, sm->authAuthSuccessesWhileAuthenticating,
		prefix, sm->authAuthTimeoutsWhileAuthenticating,
		prefix, sm->authAuthFailWhileAuthenticating,
		prefix, sm->authAuthEapStartsWhileAuthenticating,
		prefix, sm->authAuthEapLogoffWhileAuthenticating,
		prefix, sm->authAuthReauthsWhileAuthenticated,
		prefix, sm->authAuthEapStartsWhileAuthenticated,
		prefix, sm->authAuthEapLogoffWhileAuthenticated);

	fprintf(f, "%s  Backend Authentication:\n"
		"%s    state=%s\n"
		"%s    eapNoReq=%s eapReq=%s eapResp=%s\n"
		"%s    serverTimeout=%d\n"
		"%s    backendResponses=%d\n"
		"%s    backendAccessChallenges=%d\n"
		"%s    backendOtherRequestsToSupplicant=%d\n"
		"%s    backendAuthSuccesses=%d\n"
		"%s    backendAuthFails=%d\n",
		prefix, prefix,
		be_auth_state_txt(sm->be_auth_state),
		prefix, _SB(sm->eap_if->eapNoReq), _SB(sm->eap_if->eapReq),
		_SB(sm->eap_if->eapResp),
		prefix, sm->serverTimeout,
		prefix, sm->backendResponses,
		prefix, sm->backendAccessChallenges,
		prefix, sm->backendOtherRequestsToSupplicant,
		prefix, sm->backendAuthSuccesses,
		prefix, sm->backendAuthFails);

	fprintf(f, "%s  Reauthentication Timer:\n"
		"%s    state=%s\n"
		"%s    reAuthPeriod=%d reAuthEnabled=%s\n", prefix, prefix,
		reauth_timer_state_txt(sm->reauth_timer_state), prefix,
		sm->reAuthPeriod, _SB(sm->reAuthEnabled));

	fprintf(f, "%s  Authenticator Key Transmit:\n"
		"%s    state=%s\n", prefix, prefix,
		auth_key_tx_state_txt(sm->auth_key_tx_state));

	fprintf(f, "%s  Key Receive:\n"
		"%s    state=%s\n"
		"%s    rxKey=%s\n", prefix, prefix,
		key_rx_state_txt(sm->key_rx_state), prefix, _SB(sm->rxKey));

	fprintf(f, "%s  Controlled Directions:\n"
		"%s    state=%s\n"
		"%s    adminControlledDirections=%s "
		"operControlledDirections=%s\n"
		"%s    operEdge=%s\n", prefix, prefix,
		ctrl_dir_state_txt(sm->ctrl_dir_state),
		prefix, ctrl_dir_txt(sm->adminControlledDirections),
		ctrl_dir_txt(sm->operControlledDirections),
		prefix, _SB(sm->operEdge));
#undef _SB
}

redpajama_set_name: RedPajamaGithub


text:
001
017    package org.apache.commons.configuration.tree;
018
019    import java.util.Iterator;
020
021    /**
022     * <p>
023     * A specialized node implementation to be used in view configurations.
024     * </p>
025     * <p>
026     * Some configurations provide a logical view on the nodes of other
027     * configurations. These configurations construct their own hierarchy of nodes
028     * based on the node trees of their source configurations. This special node
029     * class can be used for this purpose. It allows child nodes and attributes to
030     * be added without changing their parent node. So a node can belong to a
031     * hierarchy of nodes of a source configuration, but be also contained in a view
032     * configuration.
033     * </p>
034     *
035     * @author <a
036     * href="http://commons.apache.org/configuration/team-list.html">Commons
037     * Configuration team</a>
038     * @version $Id: ViewNode.java 561230 2007-07-31 04:17:09Z rahul $
039     * @since 1.3
040     */
041    public class ViewNode extends DefaultConfigurationNode
042    {
043        /**
044         * Adds an attribute to this view node. The new attribute's parent node will
045         * be saved.
046         *
047         * @param attr the attribute node to be added
048         */
049        public void addAttribute(ConfigurationNode attr)
050        {
051            ConfigurationNode parent = null;
052
053            if (attr != null)
054            {
055                parent = attr.getParentNode();
056                super.addAttribute(attr);
057                attr.setParentNode(parent);
058            }
059            else
060            {
061                throw new IllegalArgumentException("Attribute node must not be null!");
062            }
063        }
064
065        /**
066         * Adds a child node to this view node. The new child's parent node will be
067         * saved.
068         *
069         * @param child the child node to be added
070         */
071        public void addChild(ConfigurationNode child)
072        {
073            ConfigurationNode parent = null;
074
075            if (child != null)
076            {
077                parent = child.getParentNode();
078                super.addChild(child);
079                child.setParentNode(parent);
080            }
081            else
082            {
083                throw new IllegalArgumentException("Child node must not be null!");
084            }
085        }
086
087        /**
088         * Adds all attribute nodes of the given source node to this view node.
089         *
090         * @param source the source node
091         */
092        public void appendAttributes(ConfigurationNode source)
093        {
094            if (source != null)
095            {
096                for (Iterator it = source.getAttributes().iterator(); it.hasNext();)
097                {
098                    addAttribute((ConfigurationNode) it.next());
099                }
100            }
101        }
102
103        /**
104         * Adds all child nodes of the given source node to this view node.
105         *
106         * @param source the source node
107         */
108        public void appendChildren(ConfigurationNode source)
109        {
110            if (source != null)
111            {
112                for (Iterator it = source.getChildren().iterator(); it.hasNext();)
113                {
114                    addChild((ConfigurationNode) it.next());
115                }
116            }
117        }
118    }


text:
using Takenet.Textc.Metadata;

namespace Takenet.Textc.Types
{
    [TokenType(ShortName = "Long")]
    public class LongTokenType : ValueTokenTypeBase<long>
    {
        public LongTokenType(string name, bool isContextual, bool isOptional, bool invertParsing)
            : base(name, isContextual, isOptional, invertParsing)
        {
        }
    }
}


text:
class AuthEngine::InstallGenerator < Rails::Generators::Base
  source_root File.expand_path('../templates', __FILE__)

  def copy_initializer_file
    copy_file "omniauth.rb", "config/initializers/omniauth.rb"
  end

end


text:
package org.appng.core.security;

import org.appng.api.auth.PasswordPolicy;
import org.junit.Assert;
import org.junit.Test;

public class DefaultPasswordPolicyTest {

	PasswordPolicy passwordPolicy = new DefaultPasswordPolicy();

	@Test
	public void testGenerate() {
		for (int i = 0; i < 1000; i++) {
			String password = passwordPolicy.generatePassword();
			assertValid(password);
		}
	}

	@Test
	public void testComplexRegex() {
		// use ASCII hex ranges
		String expression = "^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)" //
				+ "(?=.*[" // use positive lookahead
				+ "\\x21-\\x2f" // "!" to "/" (char code 33 - 47)
				+ "\\x3A-\\x40" // ":" to "@" (char code 58 - 64)
				+ "\\x5b-\\x60" // "[" to "`" (char code 91 - 96)
				+ "\\x7b-\\x7e" // "{" to "~" (char code 123 - 126)
				+ "])" // end lookahead
				+ "[\\x21-\\x7e]" // "!" to "~" (char code 33 - 126)
				+ "{8,}$"; // 8 or more
		PasswordPolicy policy = new DefaultPasswordPolicy(expression, "dummy");

		// only 1 of 4 character groups
		Assert.assertFalse(policy.isValidPassword("testtest".toCharArray()));
		Assert.assertFalse(policy.isValidPassword("TESTTEST".toCharArray()));
		Assert.assertFalse(policy.isValidPassword("12345678".toCharArray()));
		Assert.assertFalse(policy.isValidPassword("!!!!!!!!".toCharArray()));

		// only 2 of 4 character groups
		Assert.assertFalse(policy.isValidPassword("testTEST".toCharArray()));
		Assert.assertFalse(policy.isValidPassword("test1234".toCharArray()));
		Assert.assertFalse(policy.isValidPassword("test!!!!".toCharArray()));
		Assert.assertFalse(policy.isValidPassword("TEST1234".toCharArray()));
		Assert.assertFalse(policy.isValidPassword("TEST!!!!".toCharArray()));
		Assert.assertFalse(policy.isValidPassword("1234!!!!".toCharArray()));

		// only 3 of 4 character groups
		Assert.assertFalse(policy.isValidPassword("testTEST12".toCharArray()));
		Assert.assertFalse(policy.isValidPassword("testTEST!!".toCharArray()));
		Assert.assertFalse(policy.isValidPassword("test1234!!".toCharArray()));
		Assert.assertFalse(policy.isValidPassword("TEST1234!!".toCharArray()));

		// to short
		Assert.assertFalse(policy.isValidPassword("Test!12".toCharArray()));
		Assert.assertFalse(policy.isValidPassword("Test12!".toCharArray()));
		Assert.assertFalse(policy.isValidPassword("12Test!".toCharArray()));
		Assert.assertFalse(policy.isValidPassword("12!Test".toCharArray()));
		Assert.assertFalse(policy.isValidPassword("!Test12".toCharArray()));
		Assert.assertFalse(policy.isValidPassword("!12Test".toCharArray()));

		// OK
		Assert.assertTrue(policy.isValidPassword("teST12!!".toCharArray()));
		Assert.assertTrue(policy.isValidPassword("teST!!12".toCharArray()));
		Assert.assertTrue(policy.isValidPassword("TEst!!12".toCharArray()));
		Assert.assertTrue(policy.isValidPassword("TEst12!!".toCharArray()));
		Assert.assertTrue(policy.isValidPassword("12!!teST".toCharArray()));
		Assert.assertTrue(policy.isValidPassword("12!!TEst".toCharArray()));
		Assert.assertTrue(policy.isValidPassword("!!12teST".toCharArray()));
		Assert.assertTrue(policy.isValidPassword("!!12TEst".toCharArray()));

	}

	@Test
	public void test() {
		assertInvalid("abcde");
		assertInvalid("      ");
		assertInvalid("		");
		assertInvalid("Сардинские лакомства");
		assertInvalid("Сарди");
		assertInvalid("01234567890123456789012345678901234567890123456789012345678912345");

		assertValid("0123456789012345678901234567890123456789012345678901234567891234");
		assertValid("123456");
		assertValid("abcdef");
		assertValid("ABCDEF");
		assertValid("aBc4dE7");

		assertValid("Сардинскиелакомства");
		assertValid("²³'иел");
	}

	private void assertValid(String password) {
		Assert.assertTrue(password + " should be valid", passwordPolicy.isValidPassword(password.toCharArray()));
	}

	private void assertInvalid(String password) {
		Assert.assertFalse(password + " should be invalid", passwordPolicy.isValidPassword(password.toCharArray()));
	}
}


text:
package org.apache.flink.table.operations;

/**
 * Operation to describe a USE [catalogName.]dataBaseName statement.
 */
public class UseDatabaseOperation implements UseOperation {

	private final String catalogName;
	private final String databaseName;

	public UseDatabaseOperation(String catalogName, String databaseName) {
		this.catalogName = catalogName;
		this.databaseName = databaseName;
	}

	public String getCatalogName() {
		return catalogName;
	}

	public String getDatabaseName() {
		return databaseName;
	}

	@Override
	public String asSummaryString() {
		return String.format("USE %s.%s", catalogName, databaseName);
	}
}


text:
from MuseParse.classes.ObjectHierarchy.TreeClasses.BaseTree import Node
from MuseParse.classes.ObjectHierarchy.TreeClasses import NoteNode
from MuseParse.classes.ObjectHierarchy.ItemClasses.Note import Arpeggiate, NonArpeggiate, GraceNote, Tuplet

class VoiceNode(Node):

    def __init__(self):
        Node.__init__(self, rules=[NoteNode.NoteNode, NoteNode.Placeholder])
        self.note_total = 0
        self.note_types = []

    def addNoteDuration(self, duration):
        self.note_total += duration
        self.note_types.append(duration)

    def removeNoteDuration(self, duration):
        self.note_total -= duration
        self.note_types.remove(duration)

    def GetAllNoteTypes(self):
        """ method to collect all note values from each node

        :return: list of note values
        """
        return self.note_types

    def RunNoteChecks(self):
        children = self.GetChildrenIndexes()
        previous = None
        for child in range(len(children)):
            note = self.GetChild(children[child])
            item = note.GetItem()
            if item is not None and isinstance(note, NoteNode.NoteNode):
                # look for arpeggiates or non-arpeggiates, and update the note's childnodes
                # used where a note is part of a chord (usually the case in
                # arpeggiates)
                arpeg = item.Search(Arpeggiate)
                narpeg = item.Search(NonArpeggiate)
                if arpeg is not None or narpeg is not None:
                    note.UpdateArpeggiates()

                # now look for gracenotes
                result = item.Search(GraceNote)
                if result is not None and previous is None:
                    # if this is the first note in the bar, it must be the
                    # first gracenote
                    result.first = True

                if len(children) == child + 1:
                    # if we're at the last note...
                    if result is not None:
                        # same check as arpeggiates - handles the case where
                        # notes are part of a chord
                        note.CheckForGraceNotes()

                    # look for timemods
                    if hasattr(item, "timeMod"):
                        result = item.Search(Tuplet)
                        if result is None:
                            item.close_timemod = True
                        if previous is not None:
                            if hasattr(previous.GetItem(), "timeMod"):
                                item.timeMod.first = False
                            else:
                                item.timeMod.first = True
                        else:
                            item.timeMod.first = True
                    else:
                        item.close_timemod = False
                else:
                    # otherwise check the next item for gracenotes and time
                    # mods
                    next = self.GetChild(children[child + 1])
                    next_item = next.GetItem()
                    if next_item is not None and isinstance(
                            next,
                            NoteNode.NoteNode):
                        result = item.Search(GraceNote)
                        next_result = next_item.Search(GraceNote)
                        if result is not None:
                            if next_result is None:
                                note.CheckForGraceNotes()
                            else:
                                result.last = False
                                next_result.first = False
                        if hasattr(item, "timeMod"):
                            res = item.Search(Tuplet)

                            if not hasattr(
                                    next_item,
                                    "timeMod") and res is None:
                                item.close_timemod = True
                            else:
                                item.close_timemod = False

                            # not sure if checking next and previous is
                            # necessary?
                            if previous is not None and isinstance(
                                    previous,
                                    NoteNode.NoteNode):
                                if hasattr(previous.GetItem(), "timeMod"):
                                    item.timeMod.first = False
                                else:
                                    item.timeMod.first = True
                            else:
                                item.timeMod.first = True
            previous = note

    def toLily(self):
        '''
        Method which converts the object instance, its attributes and children to a string of lilypond code

        :return: str of lilypond code
        '''

        lilystring = ""
        children = self.GetChildrenIndexes()
        total = self.note_total
        counter = 0
        for child in range(len(children)):
            note = self.GetChild(children[child])
            item = note.GetItem()
            if item is not None:
                item.autoBeam = self.autoBeam
            if hasattr(note, "duration"):
                try:
                    counter += int(note.duration)
                except:
                    if note.duration == "\\longa":
                        counter += 0.25
                    if note.duration == "\\breve":
                        counter += 0.5
            if counter > total / 2:
                if hasattr(self, "mid_barline"):
                    lilystring += self.mid_barline.toLily()
                    self.__delattr__("mid_barline")
            if hasattr(self, "rest") and hasattr(self, "total"):
                lilystring += "R" + self.total
            else:
                lilystring += note.toLily() + " "
        return lilystring


text:
from concrete_examples import LSRRFwTriv, LSRRFwBroken
import z3
from z3 import is_true, is_false
import time
import mcnet.components as components
import random
import sys
"""Check time as increase in nodes"""
def ResetZ3 ():
    z3._main_ctx = None
    z3.main_ctx()
    z3.set_param('auto_config', False)
    z3.set_param('smt.mbqi', True)
    z3.set_param('model.compact', True)
    z3.set_param('smt.pull_nested_quantifiers', True)
    z3.set_param('smt.mbqi.max_iterations', 10000)
    z3.set_param('smt.random_seed', random.SystemRandom().randint(0, sys.maxint))
iters = 5
bad_in_row = 0
for sz in xrange(1, 1000):
    times = []
    all_bad = True
    for it in xrange(0, iters):
        bad = False
        ResetZ3()
        pobj = LSRRFwTriv(sz)
        start = time.time()
        ret = pobj.check.CheckIsolationProperty(pobj.e0, pobj.e1)
        stop = time.time()
        if z3.sat != ret.result:
            bad = True
        stop = time.time()
        if not bad:
            times.append(stop - start)
            all_bad = False
    print "%d %s %s"%(sz, ' '.join(map(str, times)), "bad" if all_bad else "good")
    if all_bad:
        bad_in_row += 1
    else:
        bad_in_row = 0
    assert bad_in_row <= 5, \
            "Too many failures"


text:
using System;
using System.Collections.Generic;
using System.Text;
using Windows.Storage;
using System.Threading.Tasks;

namespace Ao3TrackReader
{
    public partial class App
    {
        public static string OSArchitechture => null;

        public static string HardwareName
        {
            get
            {
                var eas = new Windows.Security.ExchangeActiveSyncProvisioning.EasClientDeviceInformation();
                var sku = eas.SystemSku;
                if (!string.IsNullOrWhiteSpace(sku)) return sku;
                return eas.SystemManufacturer + " " + eas.SystemProductName;
            }
        }

        public static T RunSynchronously<T>(Windows.Foundation.IAsyncOperation<T> iasync)
        {
            var task = iasync.AsTask();
            task.Wait();
            return task.Result;
        }

        public static void RunSynchronously(Windows.Foundation.IAsyncAction iasync)
        {
            var task = iasync.AsTask();
            task.Wait();
        }

        public static void TextFileSave(string filename, string text, bool append=false)
        {
            var localFolder = ApplicationData.Current.LocalFolder;
            var sampleFile = RunSynchronously(localFolder.CreateFileAsync(filename, append?CreationCollisionOption.OpenIfExists:CreationCollisionOption.ReplaceExisting));
            RunSynchronously(FileIO.WriteTextAsync(sampleFile, text));
        }
        public static async Task<string> TextFileLoadAsync(string filename)
        {
            var storageFolder = ApplicationData.Current.LocalFolder;
            var sampleFile = (await storageFolder.TryGetItemAsync(filename)) as StorageFile;
            if (sampleFile == null) return null;
            return await Windows.Storage.FileIO.ReadTextAsync(sampleFile);
        }
        public static void TextFileDelete(string filename)
        {
            var storageFolder = ApplicationData.Current.LocalFolder;
            var sampleFile = RunSynchronously(storageFolder.TryGetItemAsync(filename)) as StorageFile;
            if (sampleFile != null) RunSynchronously(sampleFile.DeleteAsync());
        }
    }
}


text:
package org.dhs.chrislee.gnupg;

import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;

public class GPGUtil {

	/**
	 * detect the OS, and based on the OS, try to find a copy of gpg
	 *
	 * @return String with the full path to the GPG binary.  null if not found.
	 */
	public static String findGPG() {
		String os = System.getProperty("os.name").toLowerCase();
		String locations[];
		if(os.indexOf("win") >= 0) {
			locations = new String[] { "c:/Program Files/GNU/GnuPG/gpg2.exe" };
		} else {
			locations = new String[] { "/usr/bin/gpg2", "/usr/local/bin/gpg2", "/opt/local/bin/gpg2", "/usr/bin/gpg", "/usr/local/bin/gpg", "/opt/local/bin/gpg" };
		}
		// iterate through the lists and, on the first hit, return the location of gpg
		for(int i=0; i<locations.length; i++) {
			File f = new File(locations[i]);
			if(f.exists()) {
				return locations[i];
			}
		}
		return null;
	}

	public static GPGKeyList getSecretKeyIds(String gpgLoc) {
		return getKeyIds(gpgLoc, "--list-secret-keys", "sec");
	}

	public static GPGKeyList getPublicKeyIds(String gpgLoc) {
		return getKeyIds(gpgLoc, "--list-keys", "pub");
	}

	protected static GPGKeyList getKeyIds(String gpgLoc, String argument, String secpub) {
		GPGKeyList keyList = new GPGKeyList();
		try {
			Process p = Runtime.getRuntime().exec(gpgLoc+" "+argument);
			InputStreamReader is = new InputStreamReader(p.getInputStream());
			BufferedReader br = new BufferedReader(is);
			String line;
			GPGKeyId keyId = null;
			while((line = br.readLine()) != null) {
				if(line.startsWith(secpub)) {
					keyId = new GPGKeyId(line);
					if(keyId.keyId == null)
						keyId.setKeyId(br.readLine().trim());
				} else if(line.startsWith("uid")) {
					if(line.contains("@")) {
						if(line.contains("[ expired]") || line.contains("[ revoked]")) {
							continue;
						} else {
							line = line.replaceAll("\\[ *(unknown|expired|revoked|ultimate|full|undef) *\\]", "");
						}
						String[] parts = line.split(" +", 2);
						keyId.addUid(parts[1]);
					}
				} else {
					if(keyId != null) {
						keyList.addKeyId(keyId);
						keyId = null;
					}
				}
			}
		} catch (IOException io) {
			return null;
		}
		return keyList;
	}

	public static void main(String[] args) {
		GPGKeyList secKeys = GPGUtil.getSecretKeyIds("/usr/local/bin/gpg2");
		GPGKeyList pubKeys = GPGUtil.getPublicKeyIds("/usr/local/bin/gpg2");
		System.out.println("Secret Keys");
		System.out.println(secKeys.toString());
		System.out.println("Public Keys");
		System.out.println(pubKeys.toString());
	}
}


text:
<?php

namespace Symfony\Tests\Bootstrapper;

use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
use Symfony\Bootstrapper\InitCommand;
use Symfony\Bundle\FrameworkBundle\Util\Filesystem;
use Symfony\Component\Console\Tester\CommandTester;
use Symfony\Component\HttpFoundation\Request;

class InitCommandTest extends \PHPUnit_Framework_TestCase
{
    /**
     * @dataProvider getFormat
     * @runInSeparateProcess
     */
    public function testExecution($format)
    {
        $tmpDir = sys_get_temp_dir().'/sf_hello';
        $filesystem = new Filesystem();
        $filesystem->remove($tmpDir);
        $filesystem->mkdirs($tmpDir);

        chdir($tmpDir);

        $tester = new CommandTester(new InitCommand());
        $tester->execute(array(
            '--name'     => 'Hello'.$format,
            '--app-path' => 'hello'.$format,
            '--web-path' => 'web',
            '--src-path' => 'src',
            '--format'   => $format,
        ));

        // autoload
        $content = file_get_contents($file = $tmpDir.'/src/autoload.php');
        $content = str_replace(
            "__DIR__.'/vendor",
            "'".__DIR__."/../../../../src/vendor",
            $content
        );
        file_put_contents($file, $content);

        // Kernel
        $class = 'Hello'.$format.'Kernel';
        $file = $tmpDir.'/hello'.$format.'/'.$class.'.php';
        $this->assertTrue(file_exists($file));

        $content = file_get_contents($file);
        $content = str_replace(
            "__DIR__.'/../src/vendor/Symfony/src/Symfony/Bundle'",
            "'".__DIR__."/../../../../src/vendor/Symfony/src/Symfony/Bundle'",
            $content
        );
        file_put_contents($file, $content);

        require_once $file;

        $kernel = new $class('dev', true);
        $response = $kernel->handle(Request::create('/'));

        $this->assertRegExp('/successfully/', $response->getContent());

        $filesystem->remove($tmpDir);
    }

    public function getFormat()
    {
        return array(
            array('xml'),
            array('yml'),
            array('php'),
        );
    }

    protected function prepareTemplate(\Text_Template $template)
    {
        $template->setFile(__DIR__.'/TestCaseMethod.tpl');
    }
}


text:
package pl.jozwik.runner

import pl.jozwik.gist.GistReader._

object GistsToFile {

  private val endMethodName = Seq('(', '[', '=', ':')
  private val defName: String = "def "
  private val closeSolutions = s"""
                  |)
                  |
                  """.stripMargin

  private val endFile =
    s"""
        |}
     """.stripMargin

  private def beginFile(packageName: String, objectName: String, signatureOfMethod: String) =
    s"""
        |package $packageName
        |
        |import annotation._
        |
        |object $objectName{
        |
        |  val solutions =  $signatureOfMethod (
     """.stripMargin

  def gistsToFile(packageName: String, objectName: String, signatureOfMethod: String, gists: Seq[Int], url: String = DEFAULT_URL): String = {
    val contentOfFiles = readFilesFromGist(gists, url)

    val content = new StringBuilder()
    val solutions = new StringBuilder()
    contentOfFiles.foreach(_ match {
      case Right((body, number)) => {
        val b = body.toString
        val methodName:Option[String] = extractMethodName(b)
        methodName match {
          case None =>
          case Some(name) =>
            val newMethodName = name + "_" + number
            val newBody = b.replaceFirst(name, newMethodName)
            if (!solutions.isEmpty) {
              solutions.append(",").append('\n')
            }
            solutions.append(newMethodName)
            content.append(newBody).append('\n').append('\n')
        }

      }
      case Left(e) =>
    })

    toScalaObject(packageName, objectName, signatureOfMethod, solutions, content)

  }

  private def toScalaObject(packageName: String, objectName: String, signatureOfMethod: String, solutions: StringBuilder, content: StringBuilder): String = {
    beginFile(packageName, objectName, signatureOfMethod) + solutions + closeSolutions + content + endFile
  }

  def extractMethodName(body: String): Option[String] = {

    val defIndex = body.indexOf(defName)
    if (defIndex == -1) {
      None
    } else {
      endMethodName.map(e => body.indexOf(e)).filter(p => p != -1) match {
        case Nil => None
        case l => {
          val min = l.min
          if (defIndex + defName.length < l.min) {
            val name = body.substring(defIndex + defName.length, min).trim
            Some(name)
          }
          else {
            None
          }
        }
      }
    }
  }
}


text:
#ifndef EXPORTLEVELPOPUP_H
#define EXPORTLEVELPOPUP_H

// TnzCore includes
#include "tpixel.h"

// TnzLib includes
#include "toonz/tframehandle.h"

// Tnz6 includes
#include "filebrowserpopup.h"
#include "exportlevelcommand.h"

// STD includes
#include <map>
#include <string>

// Qt includes
#include <QFrame>

//==================================================

//    Forward  declarations

class TPropertyGroup;
class TCamera;

namespace DVGui
{
class CheckBox;
class IntLineEdit;
class DoubleLineEdit;
class MeasuredDoubleLineEdit;
class ColorField;
}

class FileBrowser;

class QString;
class QLabel;
class QCheckBox;
class QPushButton;
class QComboBox;
class QGroupBox;
class QShowEvent;
class QHideEvent;

//==================================================

//*********************************************************************************
//    Export Level Popup  declaration
//*********************************************************************************

/*!
  \brief    The popup dealing with level exports in Toonz.
*/
class ExportLevelPopup : public FileBrowserPopup
{
	Q_OBJECT

public:
	ExportLevelPopup();
	~ExportLevelPopup();

	bool execute();

	TPropertyGroup *getFormatProperties(const std::string &ext);
	IoCmd::ExportLevelOptions getOptions(const std::string &ext);

protected:
	void showEvent(QShowEvent *se);
	void hideEvent(QHideEvent *he);

private:
	class ExportOptions;
	class Swatch;

private:
	// Widgets

	DVGui::CheckBox *m_retas;
	QComboBox *m_format;
	QPushButton *m_formatOptions;

	ExportOptions *m_exportOptions;
	Swatch *m_swatch;

	// Others

	std::map<std::string,
			 TPropertyGroup *> m_formatProperties;

	TFrameHandle m_levelFrameIndexHandle; //!< Autonomous current level's frame \a index handle.

private slots:

	void onOptionsClicked();
	void onRetas(int);
	void initFolder();
	void updateOnSelection();
	void onformatChanged(const QString &);
	void checkAlpha();
	void updatePreview();
};

//-----------------------------------------------------------------------------

class ExportLevelPopup::ExportOptions : public QFrame
{
	Q_OBJECT

public:
	ExportOptions(QWidget *parent = 0);

	IoCmd::ExportLevelOptions getOptions() const;

	void updateOnSelection();

signals:

	void optionsChanged();

protected:
	void showEvent(QShowEvent *se);

	void updateCameraDefault();
	void updateDpi();

private:
	friend class ExportLevelPopup;

	QWidget *m_pliOptions;

	DVGui::ColorField *m_bgColorField;
	QCheckBox *m_noAntialias;

	DVGui::MeasuredDoubleLineEdit *m_widthFld;
	DVGui::MeasuredDoubleLineEdit *m_heightFld;

	DVGui::IntLineEdit *m_hResFld;
	DVGui::IntLineEdit *m_vResFld;

	DVGui::MeasuredDoubleLineEdit *m_resScale;

	QLabel *m_dpiLabel;

	QComboBox *m_thicknessTransformMode;

	DVGui::MeasuredDoubleLineEdit *m_fromThicknessScale,
		*m_fromThicknessDisplacement,
		*m_toThicknessScale,
		*m_toThicknessDisplacement;

private slots:

	void updateXRes();
	void updateYRes();
	void scaleRes();

	void onThicknessTransformModeChanged();
};

#endif // EXPORTLEVELPOPUP_H


text:
export JAVA_HOME="{{ openjdk_java_home }}"
export PATH=$JAVA_HOME/bin:$PATH


text:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WebMap
{

	[System.AttributeUsage(System.AttributeTargets.Class |
											 System.AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Property)
  ]
    public class ClientSideAttribute : System.Attribute
    {
    }
}


text:
#pragma once
#include "library/type_context.h"
namespace lean {
expr wf_rec(environment & env, options const & opts,
            metavar_context & mctx, local_context const & lctx,
            expr const & eqns);
void initialize_wf_rec();
void finalize_wf_rec();
}


text:
package br.com.caelum.vraptor.serialization.xstream;

import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

import java.io.ByteArrayOutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;

import javax.enterprise.inject.Instance;
import javax.servlet.http.HttpServletResponse;

import org.junit.Before;

import br.com.caelum.vraptor.core.DefaultReflectionProvider;
import br.com.caelum.vraptor.environment.Environment;
import br.com.caelum.vraptor.interceptor.DefaultTypeNameExtractor;
import br.com.caelum.vraptor.serialization.Serializee;
import br.com.caelum.vraptor.util.test.MockInstanceImpl;

import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.converters.Converter;
import com.thoughtworks.xstream.converters.SingleValueConverter;

/**
 * testing the same cases as {@link XStreamXMLSerializationTest}
 * but using an arbitrary {@link XStream} implementation, not the {@link VRaptorXStream}.
 * @author lucascs
 *
 */
public class XStreamSerializerTest extends XStreamXMLSerializationTest {

	@Override
	@Before
	public void setup() throws Exception {
		stream = new ByteArrayOutputStream();
		environment = mock(Environment.class);

		HttpServletResponse response = mock(HttpServletResponse.class);
		when(response.getWriter()).thenReturn(new PrintWriter(stream));

		List<Converter> converters = new ArrayList<>();
		converters.add(new CalendarConverter());

		final DefaultTypeNameExtractor extractor = new DefaultTypeNameExtractor();

		Instance<Converter> convertersInst = new MockInstanceImpl<>(converters);
		Instance<SingleValueConverter> singleValueConverters = new MockInstanceImpl<>();
		XStreamConverters xStreamConverters = new XStreamConverters(convertersInst, singleValueConverters);
		serialization = new XStreamXMLSerialization(response, new XStreamBuilderImpl(xStreamConverters, extractor,
				new Serializee(new DefaultReflectionProvider()), new DefaultReflectionProvider()), environment);
	}
}


text:
package com.armandgray.shared.api;

import java.io.IOException;

import javax.inject.Inject;

import androidx.annotation.NonNull;
import okhttp3.HttpUrl;
import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;

/**
 * Created by armandgray on 7/13/18
 */
@NetworkManager.NetworkScope
class NetworkInterceptor implements Interceptor {

    @SuppressWarnings("SpellCheckingInspection")
    private static final String JSON_ONLY_QUERY_PARAM = "nojsoncallback";
    private static final String JSON_ONLY_TRUE = "1";
    private static final String API_KEY_QUERY_PARAM = "api_key";
    private static final String API_KEY = "1508443e49213ff84d566777dc211f2a";
    private static final String FORMAT_QUERY_PARAM = "format";
    private static final String JSON = "json";
    private static final String SAFE_SEARCH_QUERY_PARAM = "safe_search";
    private static final String RESTRICTED = "3";

    @Inject
    NetworkInterceptor() {
    }

    @Override
    public Response intercept(@NonNull Chain chain) throws IOException {
        Request request = chain.request();
        HttpUrl url = request.url().newBuilder()
                .addQueryParameter(JSON_ONLY_QUERY_PARAM, JSON_ONLY_TRUE)
                .addQueryParameter(API_KEY_QUERY_PARAM, API_KEY)
                .addQueryParameter(FORMAT_QUERY_PARAM, JSON)
                .addQueryParameter(SAFE_SEARCH_QUERY_PARAM, RESTRICTED) // Flickr is Scary (this doesn't work! eek!!!)
                .build();

        return chain.proceed(request.newBuilder().url(url).build());
    }
}


text:
    <jf-panel jf-panel-heading="Package Info"
              ng-if="jfBower.bowerData.bowerPkgInfo">

                {{jfBower.DICTIONARY[key]}}:
                {{value}}

    </jf-panel>
    <jf-panel jf-panel-heading="Dependencies"
              ng-if="jfBower.bowerData.bowerDependencies">
        <jf-grid grid-options="jfBower.gridDependenciesOptions"
                no-pagination="true"></jf-grid>
    </jf-panel>
    <jf-panel jf-panel-heading="Main Files"
              ng-if="jfBower.bowerData.mainFiles.length">

{{mainFile}}

    </jf-panel>
    <jf-panel jf-panel-heading="Ignored Files"
              ng-if="jfBower.bowerData.ignoredFiles.length">

                {{ignoredFile}}

    </jf-panel>


text:
'use strict';

var _get = require('babel-runtime/helpers/get')['default'];

var _inherits = require('babel-runtime/helpers/inherits')['default'];

var _createClass = require('babel-runtime/helpers/create-class')['default'];

var _classCallCheck = require('babel-runtime/helpers/class-call-check')['default'];

var _interopRequireDefault = require('babel-runtime/helpers/interop-require-default')['default'];

Object.defineProperty(exports, '__esModule', {
  value: true
});

var _events = require('events');

var _util = require('util');

var _util2 = _interopRequireDefault(_util);

var Debug = (function (_EventEmitter) {
  _inherits(Debug, _EventEmitter);

  /*
    @options    Which debug details should be sent.
                data    - dump of packet data
                payload - details of decoded payload
  */

  function Debug(options) {
    _classCallCheck(this, Debug);

    _get(Object.getPrototypeOf(Debug.prototype), 'constructor', this).call(this);

    this.options = options;
    this.options = this.options || {};
    this.options.data = this.options.data || false;
    this.options.payload = this.options.payload || false;
    this.options.packet = this.options.packet || false;
    this.options.token = this.options.token || false;
    this.indent = '  ';
  }

  _createClass(Debug, [{
    key: 'packet',
    value: function packet(direction, _packet) {
      if (this.haveListeners() && this.options.packet) {
        this.log('');
        this.log(direction);
        this.log(_packet.headerToString(this.indent));
      }
    }
  }, {
    key: 'data',
    value: function data(packet) {
      if (this.haveListeners() && this.options.data) {
        this.log(packet.dataToString(this.indent));
      }
    }
  }, {
    key: 'payload',
    value: function payload(generatePayloadText) {
      if (this.haveListeners() && this.options.payload) {
        this.log(generatePayloadText());
      }
    }
  }, {
    key: 'token',
    value: function token(_token) {
      if (this.haveListeners() && this.options.token) {
        this.log(_util2['default'].inspect(_token, false, 5, true));
      }
    }
  }, {
    key: 'haveListeners',
    value: function haveListeners() {
      return this.listeners('debug').length > 0;
    }
  }, {
    key: 'log',
    value: function log(text) {
      this.emit('debug', text);
    }
  }]);

  return Debug;
})(_events.EventEmitter);

exports['default'] = Debug;
module.exports = exports['default'];


text:
/***
 Full-screen Text Terminal Manipulation.

 In the underlying curses C library, the following functions:

     getstr()   (and wgetstr(), mvgetstr(), and mvwgetstr())
     inchstr()  (and winchstr(), mvinchstr(), and mvwinchstr())
     instr()    (and winstr(), mvinstr(), and mvwinstr())

 are subject to buffer overflow attack. This is because you pass in the
 buffer to be filled in, which has to be of finite length. But in this
 Lua module, a buffer is assigned automatically and the function returns
 the string, so there is no security issue. You may still use the alternate
 functions:

     s = stdscr:getnstr()
     s = stdscr:inchnstr()
     s = stdscr:innstr()

 which take an extra "size of buffer" argument, in order to impose a maximum
 length on the string the user may type in.

 Some of the C functions beginning with "no" do not exist in Lua. You should
 use `curses.nl(false)` and `curses.nl(true)` instead of `nonl()` and `nl()`,
 and likewise `curses.echo(false)` and `curses.echo(true)` instead of
 `noecho()` and `echo()` .

 In this Lua module the `stdscr:getch()` function always returns an integer.
 In C, a single character is an integer, but in Lua (and Perl) a single
 character is a short string. The Perl Curses function `getch()` returns a
 char if it was a char, and a number if it was a constant; to get this
 behaviour in Lua you have to convert explicitly, e.g.:

     if c < 256 then c = string.char(c) end

 Some Lua functions take a different set of parameters than their C
 counterparts; for example, you should use `str = stdscr.getstr()` and
 `y, x = stdscr.getyx()` instead of `getstr(str)` and `getyx(y, x)`, and
 likewise for `getbegyx` and `getmaxyx` and `getparyx` and `pair_content`.
 The Perl Curses module now uses the C-compatible parameters, so be aware of
 this difference when translating code from Perl into Lua, as well as from C
 into Lua.

 Many curses functions have variants starting with the prefixes `w-`, `mv-`,
 and/or `wmv-`. These variants differ only in the explicit addition of a
 window, or by the addition of two coordinates that are used to move the
 cursor first. For example, in C `addch()` has three other variants:
 `waddch()`, `mvaddch()` and `mvwaddch()`.  The Lua equivalents,
 respectively being `stdscr:addch()`, `somewindow:addch()`,
 `stdscr:mvaddch()` and `somewindow:mvaddch()`, with the window argument
 passed implicitly with Lua's `:` syntax sugar.

@module curses
*/

#include <config.h>

#include "_helpers.c"
#include "strlcpy.c"

#if HAVE_CURSES

#include "curses/chstr.c"
#include "curses/window.c"

static const char *STDSCR_REGISTRY	= "curses:stdscr";
static const char *RIPOFF_TABLE		= "curses:ripoffline";

/***
Create a new line drawing buffer instance.
@function new_chstr
@int len number of element to allocate
@treturn chstr a new char buffer object
@see curses.chstr
*/
static int
Pnew_chstr(lua_State *L)
{
	int len = checkint(L, 1);
	chstr* ncs = chstr_new(L, len);  /* defined in curses/chstr.c */
	memset(ncs->str, ' ', len*sizeof(chtype));
	return 1;
}

#define CCR(n, v)				\
	lua_pushstring(L, n);			\
	lua_pushinteger(L, v);			\
	lua_settable(L, lua_upvalueindex(1))

#define CC(s)	   CCR(#s, s)
#define CF(i)	   CCR(LCURSES_STR(LCURSES_SPLICE(KEY_F, i)), KEY_F(i))

/*
** these values may be fixed only after initialization, so this is
** called from Pinitscr, after the curses driver is initialized
**
** curses table is kept at upvalue position 1, in case the global
** name is changed by the user or even in the registration phase by
** the developer
**
** some of these values are not constant so need to register
** them directly instead of using a table
*/

static void
register_curses_constants(lua_State *L)
{
	/* colors */
	CC(COLOR_BLACK);	CC(COLOR_RED);		CC(COLOR_GREEN);
	CC(COLOR_YELLOW);	CC(COLOR_BLUE);		CC(COLOR_MAGENTA);
	CC(COLOR_CYAN);		CC(COLOR_WHITE);

	/* alternate character set */
	CC(ACS_BLOCK);		CC(ACS_BOARD);

	CC(ACS_BTEE);		CC(ACS_TTEE);
	CC(ACS_LTEE);		CC(ACS_RTEE);
	CC(ACS_LLCORNER);	CC(ACS_LRCORNER);
	CC(ACS_URCORNER);	CC(ACS_ULCORNER);

	CC(ACS_LARROW);		CC(ACS_RARROW);
	CC(ACS_UARROW);		CC(ACS_DARROW);

	CC(ACS_HLINE);		CC(ACS_VLINE);

	CC(ACS_BULLET);		CC(ACS_CKBOARD);	CC(ACS_LANTERN);
	CC(ACS_DEGREE);		CC(ACS_DIAMOND);

	CC(ACS_PLMINUS);	CC(ACS_PLUS);
	CC(ACS_S1);		CC(ACS_S9);

	/* attributes */
	CC(A_NORMAL);		CC(A_STANDOUT);		CC(A_UNDERLINE);
	CC(A_REVERSE);		CC(A_BLINK);		CC(A_DIM);
	CC(A_BOLD);		CC(A_PROTECT);		CC(A_INVIS);
	CC(A_ALTCHARSET);	CC(A_CHARTEXT);
	CC(A_ATTRIBUTES);
#ifdef A_COLOR
	CC(A_COLOR);
#endif

	/* key functions */
	CC(KEY_BREAK);		CC(KEY_DOWN);		CC(KEY_UP);
	CC(KEY_LEFT);		CC(KEY_RIGHT);		CC(KEY_HOME);
	CC(KEY_BACKSPACE);

	CC(KEY_DL);		CC(KEY_IL);		CC(KEY_DC);
	CC(KEY_IC);		CC(KEY_EIC);		CC(KEY_CLEAR);
	CC(KEY_EOS);		CC(KEY_EOL);		CC(KEY_SF);
	CC(KEY_SR);		CC(KEY_NPAGE);		CC(KEY_PPAGE);
	CC(KEY_STAB);		CC(KEY_CTAB);		CC(KEY_CATAB);
	CC(KEY_ENTER);		CC(KEY_SRESET);		CC(KEY_RESET);
	CC(KEY_PRINT);		CC(KEY_LL);		CC(KEY_A1);
	CC(KEY_A3);		CC(KEY_B2);		CC(KEY_C1);
	CC(KEY_C3);		CC(KEY_BTAB);		CC(KEY_BEG);
	CC(KEY_CANCEL);		CC(KEY_CLOSE);		CC(KEY_COMMAND);
	CC(KEY_COPY);		CC(KEY_CREATE);		CC(KEY_END);
	CC(KEY_EXIT);		CC(KEY_FIND);		CC(KEY_HELP);
	CC(KEY_MARK);		CC(KEY_MESSAGE); /* ncurses extension: CC(KEY_MOUSE); */
	CC(KEY_MOVE);		CC(KEY_NEXT);		CC(KEY_OPEN);
	CC(KEY_OPTIONS);	CC(KEY_PREVIOUS);	CC(KEY_REDO);
	CC(KEY_REFERENCE);	CC(KEY_REFRESH);	CC(KEY_REPLACE);
	CC(KEY_RESIZE);		CC(KEY_RESTART);	CC(KEY_RESUME);
	CC(KEY_SAVE);		CC(KEY_SBEG);		CC(KEY_SCANCEL);
	CC(KEY_SCOMMAND);	CC(KEY_SCOPY);		CC(KEY_SCREATE);
	CC(KEY_SDC);		CC(KEY_SDL);		CC(KEY_SELECT);
	CC(KEY_SEND);		CC(KEY_SEOL);		CC(KEY_SEXIT);
	CC(KEY_SFIND);		CC(KEY_SHELP);		CC(KEY_SHOME);
	CC(KEY_SIC);		CC(KEY_SLEFT);		CC(KEY_SMESSAGE);
	CC(KEY_SMOVE);		CC(KEY_SNEXT);		CC(KEY_SOPTIONS);
	CC(KEY_SPREVIOUS);	CC(KEY_SPRINT);		CC(KEY_SREDO);
	CC(KEY_SREPLACE);	CC(KEY_SRIGHT);		CC(KEY_SRSUME);
	CC(KEY_SSAVE);		CC(KEY_SSUSPEND);	CC(KEY_SUNDO);
	CC(KEY_SUSPEND);	CC(KEY_UNDO);

	/* KEY_Fx  0 <= x <= 63 */
	CC(KEY_F0);
	CF(1);  CF(2);  CF(3);  CF(4);  CF(5);  CF(6);  CF(7);  CF(8);
	CF(9);  CF(10); CF(11); CF(12); CF(13); CF(14); CF(15); CF(16);
	CF(17); CF(18); CF(19); CF(20); CF(21); CF(22); CF(23); CF(24);
	CF(25); CF(26); CF(27); CF(28); CF(29); CF(30); CF(31); CF(32);
	CF(33); CF(34); CF(35); CF(36); CF(37); CF(38); CF(39); CF(40);
	CF(41); CF(42); CF(43); CF(44); CF(45); CF(46); CF(47); CF(48);
	CF(49); CF(50); CF(51); CF(52); CF(53); CF(54); CF(55); CF(56);
	CF(57); CF(58); CF(59); CF(60); CF(61); CF(62); CF(63);
}

/*
** make sure screen is restored (and cleared) at exit
** (for the situations where program is aborted without a
** proper cleanup)
*/

static void
cleanup(void)
{
	if (!isendwin())
	{
		wclear(stdscr);
		wrefresh(stdscr);
		endwin();
	}
}

/***
Initialise screen.
@function initscr
@treturn window main screen
@see initscr(3x)
*/
static int
Pinitscr(lua_State *L)
{
	WINDOW *w;

	/* initialize curses */
	w = initscr();

	/* no longer used, so clean it up */
	lua_pushstring(L, RIPOFF_TABLE);
	lua_pushnil(L);
	lua_settable(L, LUA_REGISTRYINDEX);

	/* failed to initialize */
	if (w == NULL)
		return 0;

	/* return stdscr - main window */
	lc_newwin(L, w);

	/* save main window on registry */
	lua_pushstring(L, STDSCR_REGISTRY);
	lua_pushvalue(L, -2);
	lua_rawset(L, LUA_REGISTRYINDEX);

	/* setup curses constants - curses.xxx numbers */
	register_curses_constants(L);

	/* install cleanup handler to help in debugging and screen trashing */
	atexit(cleanup);

	return 1;
}

/***
Clean up terminal prior to exiting or escaping curses.
@function endwin
@treturn bool `true`, if successful
@see endwin(3x)
*/
static int
Pendwin(lua_State *L)
{
	return pushokresult(endwin());
}

/***
Has @{endwin} been called more recently than @{curses.window:refresh}?
@function isendwin
@treturn bool whether @{endwin} has been called
@see isendwin(3x)
*/
static int
Pisendwin(lua_State *L)
{
	return pushboolresult(isendwin());
}

/***
Retern the main screen window.
@function stdscr
@treturn window main screen
@see initscr
@see stdscr(3x)
*/
static int
Pstdscr(lua_State *L)
{
	lua_pushstring(L, STDSCR_REGISTRY);
	lua_rawget(L, LUA_REGISTRYINDEX);
	return 1;
}

/***
Number of columns in the main screen window.
@function cols
@treturn int number of columns in the main screen
@see lines
@see stdscr
@see COLS(3x)
*/
static int
Pcols(lua_State *L)
{
	return pushintresult(COLS);
}

/***
Number of lines in the main screen window.
@function lines
@treturn int number of lines in the main screen
@see cols
@see stdscr
@see LINES(3x)
*/
static int
Plines(lua_State *L)
{
	return pushintresult(LINES);
}

/***
Initialise color output facility.
@function start_color
@treturn bool `true`, if successful
@see can_change_color(3x)
@see has_colors
*/
static int
Pstart_color(lua_State *L)
{
	return pushokresult(start_color());
}

/***
Does the terminal have color capability?
@function has_colors
@treturn bool `true`, if the terminal supports colors
@see can_change_color(3x)
@see start_color
@usage
if curses.has_colors () then
  curses.start_color ()
end
*/
static int
Phas_colors(lua_State *L)
{
	return pushboolresult(has_colors());
}

/***
Reserve `-1` to represent terminal default colors.
@function use_default_colors
@treturn bool `true`, if successful
@see use_default_colors(3x)
@fixme ncurses only?
*/
static int
Puse_default_colors(lua_State *L)
{
	return pushokresult(use_default_colors());
}

/***
Associate a color pair id with a specific foreground and background color.
@function init_pair
@int pair color pair id to act on
@int f foreground color to assign
@int b background color to assign
@treturn bool `true`, if successful
@see init_pair(3x)
@see pair_content
*/
static int
Pinit_pair(lua_State *L)
{
	short pair = checkint(L, 1);
	short f = checkint(L, 2);
	short b = checkint(L, 3);
	return pushokresult(init_pair(pair, f, b));
}

/***
Return the foreground and background colors associated with a color pair id.
@function pair_content
@int pair color pair id to act on
@treturn int foreground color of *pair*
@treturn int background color of *pair*
@see can_change_color(3x)
@see init_pair
*/
static int
Ppair_content(lua_State *L)
{
	short pair = checkint(L, 1);
	short f;
	short b;
	int ret = pair_content(pair, &f, &b);

	if (ret == ERR)
		return 0;

	lua_pushinteger(L, f);
	lua_pushinteger(L, b);
	return 2;
}

/***
How many colors are available for this terminal?
@function colors
@treturn int total number of available colors
@see can_change_color(3x)
@see color_pairs
*/
static int
Pcolors(lua_State *L)
{
	return pushintresult(COLORS);
}

/***
How may distinct color pairs are supported by this terminal?
@function color_pairs
@treturn int total number of available color pairs
@see can_change_color(3x)
@see colors
*/
static int
Pcolor_pairs(lua_State *L)
{
	return pushintresult(COLOR_PAIRS);
}

/***
Return the attributes for the given color pair id.
@function color_pair
@int pair color pair id to act on
@treturn int attributes for color pair *pair*
@see can_change_color(3x)
*/
static int
Pcolor_pair(lua_State *L)
{
	int n = checkint(L, 1);
	return pushintresult(COLOR_PAIR(n));
}

/***
Fetch the output speed of the terminal.
@function baudrate
@treturn int output speed of the terminal in bits-per-second
@see baudrate(3x)
*/
static int
Pbaudrate(lua_State *L)
{
	return pushintresult(baudrate());
}

/***
Fetch the terminal's current erase character.
@function erasechar
@treturn int current erase character
@see erasechar(3x)
*/
static int
Perasechar(lua_State *L)
{
	return pushintresult(erasechar());
}

/***
Fetch the character insert and delete capability of the terminal.
@function has_ic
@treturn bool `true`, if the terminal has insert and delete character
  operations
@see has_ic(3x)
*/
static int
Phas_ic(lua_State *L)
{
	return pushboolresult(has_ic());
}

/***
Fetch the line insert and delete capability of the terminal.
@function has_il
@treturn bool `true`, if the terminal has insert and delete line operations
@see has_il(3x)
*/
static int
Phas_il(lua_State *L)
{
	return pushboolresult(has_il());
}

/***
Fetch the terminal's current kill character.
@function killchar
@treturn int current line kill character
@see killchar(3x)
*/
static int
Pkillchar(lua_State *L)
{
	return pushintresult(killchar());
}

/***
Bitwise OR of all (or selected) video attributes supported by the terminal.
@function termattrs
@int[opt] a terminal attribute bits
@treturn[1] bool `true`, if the terminal supports attribute *a*
@treturn[2] int bitarray of supported terminal attributes
@see termattrs(3x)
*/
static int
Ptermattrs(lua_State *L)
{
	if (lua_gettop(L) > 0)
	{
		int a = checkint(L, 1);
		return pushboolresult(termattrs() & a);
	}
	return pushintresult(termattrs());
}

/***
Fetch the name of the terminal.
@function termname
@treturn string terminal name
@see termname(3x)
*/
static int
Ptermname(lua_State *L)
{
	return pushstringresult(termname());
}

/***
Fetch the verbose name of the terminal.
@function longname
@treturn string verbose description of the current terminal
@see longname(3x)
*/
static int
Plongname(lua_State *L)
{
	return pushstringresult(longname());
}

/* there is no easy way to implement this... */

static lua_State *rip_L = NULL;

static int
ripoffline_cb(WINDOW* w, int cols)
{
	static int line = 0;
	int top = lua_gettop(rip_L);

	/* better be safe */
	if (!lua_checkstack(rip_L, 5))
		return 0;

	/* get the table from the registry */
	lua_pushstring(rip_L, RIPOFF_TABLE);
	lua_gettable(rip_L, LUA_REGISTRYINDEX);

	/* get user callback function */
	if (lua_isnil(rip_L, -1)) {
		lua_pop(rip_L, 1);
		return 0;
	}

	lua_rawgeti(rip_L, -1, ++line);	/* function to be called */
	lc_newwin(rip_L, w);		/* create window object */
	lua_pushinteger(rip_L, cols);   /* push number of columns */

	lua_pcall(rip_L, 2,  0, 0);	/* call the lua function */

	lua_settop(rip_L, top);
	return 1;
}

/***
Reduce the available size of the main screen.
@function ripoffline
@bool top_line
@func callback
@treturn bool `true`, if successful
@see ripoffline(3x)
*/
static int
Pripoffline(lua_State *L)
{
	static int rip = 0;
	int top_line = lua_toboolean(L, 1);

#if LCURSES_POSIX_COMPLIANT
	if (!lua_isfunction(L, 2))
	{
		lua_pushliteral(L, "invalid callback passed as second parameter");
		lua_error(L);
	}

	/* need to save the lua state somewhere... */
	rip_L = L;

	/* get the table where we are going to save the callbacks */
	lua_pushstring(L, RIPOFF_TABLE);
	lua_gettable(L, LUA_REGISTRYINDEX);

	if (lua_isnil(L, -1))
	{
		lua_pop(L, 1);
		lua_newtable(L);

		lua_pushstring(L, RIPOFF_TABLE);
		lua_pushvalue(L, -2);
		lua_settable(L, LUA_REGISTRYINDEX);
	}

	/* save function callback in registry table */
	lua_pushvalue(L, 2);
	lua_rawseti(L, -2, ++rip);

	/* and tell curses we are going to take the line */
	return pushokresult(ripoffline(top_line ? 1 : -1, ripoffline_cb));
#else
	return binding_notimplemented(L, "ripoffline", "curses");
#endif
}

/***
Change the visibility of the cursor.
@function curs_set
@int vis one of `0` (invisible), `1` (visible) or `2` (very visible)
@treturn[1] int previous cursor state
@return[2] nil if *vis* is not supported
@see curs_set(3x)
*/
static int
Pcurs_set(lua_State *L)
{
	int vis = checkint(L, 1);
	int state = curs_set(vis);
	if (state == ERR)
		return 0;

	return pushintresult(state);
}

/***
Sleep for a few milliseconds.
@function napms
@int ms time to wait in milliseconds
@treturn bool `true`, if successful
@see napms(3x)
@see delay_output
*/
static int
Pnapms(lua_State *L)
{
	int ms = checkint(L, 1);
	return pushokresult(napms(ms));
}

/***
Change the terminal size.
@function resizeterm
@int nlines number of lines
@int ncols number of columns
@treturn bool `true`, if successful
@raise unimplemented
@fixme ncurses only?
*/
static int
Presizeterm(lua_State *L)
{
	int nlines  = checkint(L, 1);
	int ncols   = checkint(L, 2);
#if HAVE_RESIZETERM
	return pushokresult(resizeterm (nlines, ncols));
#else
	return binding_notimplemented(L, "resizeterm", "curses");
#endif
}

/***
Send the terminal audible bell.
@function beep
@treturn bool `true`, if successful
@see beep(3x)
@see flash
*/
static int
Pbeep(lua_State *L)
{
	return pushokresult(beep());
}

/***
Send the terminal visible bell.
@function flash
@treturn bool `true`, if successful
@see flash(3x)
@see beep
*/
static int
Pflash(lua_State *L)
{
	return pushokresult(flash());
}

/***
Create a new window.
@function newwin
@int nlines number of window lines
@int ncols number of window columns
@int begin_y top line of window
@int begin_x leftmost column of window
@treturn window a new window object
@see newwin(3x)
@see curses.window
*/
static int
Pnewwin(lua_State *L)
{
	int nlines  = checkint(L, 1);
	int ncols   = checkint(L, 2);
	int begin_y = checkint(L, 3);
	int begin_x = checkint(L, 4);

	lc_newwin(L, newwin(nlines, ncols, begin_y, begin_x));
	return 1;
}

/***
Refresh the visible terminal screen.
@function doupdate
@treturn bool `true`, if successful
@see doupdate(3x)
@see curses.window:refresh
*/
static int
Pdoupdate(lua_State *L)
{
	return pushokresult(doupdate());
}

/***
Initialise the soft label keys area.
This must be called before @{initscr}.
@function slk_init
@int fmt
@treturn bool `true`, if successful
@see slk_init(3x)
*/
static int
Pslk_init(lua_State *L)
{
	int fmt = checkint(L, 1);
#if LCURSES_POSIX_COMPLIANT
	return pushokresult(slk_init(fmt));
#else
	return binding_notimplemented(L, "slk_init", "curses");
#endif
}

/***
Set the label for a soft label key.
@function slk_set
@int labnum
@string label
@int fmt
@treturn bool `true`, if successful
@see slk_set(3x)
*/
static int
Pslk_set(lua_State *L)
{
	int labnum = checkint(L, 1);
	const char* label = luaL_checkstring(L, 2);
	int fmt = checkint(L, 3);
#if LCURSES_POSIX_COMPLIANT
	return pushokresult(slk_set(labnum, label, fmt));
#else
	return binding_notimplemented(L, "slk_set", "curses");
#endif
}

/***
Refresh the soft label key area.
@function slk_refresh
@treturn bool `true`, if successful
@see slk_refresh(3x)
@see curses.window:refresh
*/
static int
Pslk_refresh(lua_State *L)
{
#if LCURSES_POSIX_COMPLIANT
	return pushokresult(slk_refresh());
#else
	return binding_notimplemented(L, "slk_refresh", "curses");
#endif
}

/***
Copy the soft label key area backing screen to the virtual screen.
@function slk_noutrefresh
@treturn bool `true`, if successful
@see slk_noutrefresh(3x)
@see curses.window:refresh
*/
static int
Pslk_noutrefresh(lua_State *L)
{
#if LCURSES_POSIX_COMPLIANT
	return pushokresult(slk_noutrefresh());
#else
	return binding_notimplemented(L, "slk_noutrefresh", "curses");
#endif
}

/***
Fetch the label for a soft label key.
@function slk_label
@int labnum
@treturn string current label for *labnum*
@see slk_label(3x)
*/
static int
Pslk_label(lua_State *L)
{
	int labnum = checkint(L, 1);
#if LCURSES_POSIX_COMPLIANT
	return pushstringresult(slk_label(labnum));
#else
	return binding_notimplemented(L, "slk_label", "curses");
#endif
}

/***
Clears the soft labels from the screen.
@function slk_clear
@treturn bool `true`, if successful
@see slk_clear(3x)
@see slk_restore
*/
static int
Pslk_clear(lua_State *L)
{
#if LCURSES_POSIX_COMPLIANT
	return pushokresult(slk_clear());
#else
	return binding_notimplemented(L, "slk_clear", "curses");
#endif
}

/***
Restores the soft labels to the screen.
@function slk_restore
@treturn bool `true`, if successful
@see slk_restore(3x)
@see slk_clear
*/
static int
Pslk_restore(lua_State *L)
{
#if LCURSES_POSIX_COMPLIANT
	return pushokresult(slk_restore());
#else
	return binding_notimplemented(L, "slk_restore", "curses");
#endif
}

/***
Mark the soft label key area for refresh.
@function slk_touch
@treturn bool `true`, if successful
@see slk_touch(3x)
*/
static int
Pslk_touch(lua_State *L)
{
#if LCURSES_POSIX_COMPLIANT
	return pushokresult(slk_touch());
#else
	return binding_notimplemented(L, "slk_touch", "curses");
#endif
}

/***
Enable an attribute for soft labels.
@function slk_attron
@int attrs
@treturn bool `true`, if successful
@see slk_attron(3x)
*/
static int
Pslk_attron(lua_State *L)
{
	chtype attrs = checkch(L, 1);
#if LCURSES_POSIX_COMPLIANT
	return pushokresult(slk_attron(attrs));
#else
	return binding_notimplemented(L, "slk_attron", "curses");
#endif
}

/***
Disable an attribute for soft labels.
@function slk_attroff
@int attrs
@treturn bool `true`, if successful
@see slk_attroff(3x)
*/
static int
Pslk_attroff(lua_State *L)
{
	chtype attrs = checkch(L, 1);
#if LCURSES_POSIX_COMPLIANT
	return pushokresult(slk_attroff(attrs));
#else
	return binding_notimplemented(L, "slk_attroff", "curses");
#endif
}

/***
Set the attributes for soft labels.
@function slk_attrset
@int attrs
@treturn bool `true`, if successful
@see slk_attrset(3x)
*/
static int
Pslk_attrset(lua_State *L)
{
	chtype attrs = checkch(L, 1);
#if LCURSES_POSIX_COMPLIANT
	return pushokresult(slk_attrset(attrs));
#else
	return binding_notimplemented(L, "slk_attrset", "curses");
#endif
}

/***
Put the terminal into cbreak mode.
@function cbreak
@bool[opt] on
@treturn bool `true`, if successful
@see cbreak(3x)
@see nocbreak(3x)
*/
static int
Pcbreak(lua_State *L)
{
	if (lua_isnoneornil(L, 1) || lua_toboolean(L, 1))
		return pushokresult(cbreak());
	return pushokresult(nocbreak());
}

/***
Whether characters are echoed to the terminal as they are typed.
@function echo
@bool[opt] on
@treturn bool `true`, if successful
@see echo(3x)
@see noecho(3x)
*/
static int
Pecho(lua_State *L)
{
	if (lua_isnoneornil(L, 1) || lua_toboolean(L, 1))
		return pushokresult(echo());
	return pushokresult(noecho());
}

/***
Put the terminal into raw mode.
@function raw
@bool[opt] on
@treturn bool `true`, if successful
@see noraw(3x)
@see raw(3x)
*/
static int
Praw(lua_State *L)
{
	if (lua_isnoneornil(L, 1) || lua_toboolean(L, 1))
		return pushokresult(raw());
	return pushokresult(noraw());
}

/***
Put the terminal into halfdelay mode.
@function halfdelay
@int tenths delay in tenths of a second
@treturn bool `true`, if successful
@see halfdelay(3x)
*/
static int
Phalfdelay(lua_State *L)
{
	int tenths = checkint(L, 1);
	return pushokresult(halfdelay(tenths));
}

/***
Whether to translate a return key to newline on input.
@function nl
@bool[opt] on
@treturn bool `true`, if successful
@see nl(3x)
@see nonl(3x)
*/
static int
Pnl(lua_State *L)
{
	if (lua_isnoneornil(L, 1) || lua_toboolean(L, 1))
		return pushokresult(nl());
	return pushokresult(nonl());
}

/***
Return a printable representation of a character, ignoring attributes.
@function unctrl
@int c character to act on
@treturn string printable representation of *c*
@see unctrl(3x)
@see keyname
*/
static int
Punctrl(lua_State *L)
{
	chtype c = checkch(L, 1);
	return pushstringresult(unctrl(c));
}

/***
Return a printable representation of a key.
@function keyname
@int c a key
@treturn string key name of *c*
@see keyname(3x)
@see unctrl
*/
static int
Pkeyname(lua_State *L)
{
	int c = checkint(L, 1);
	return pushstringresult(keyname(c));
}

/***
Insert padding characters to force a short delay.
@function delay_output
@int ms delay time in milliseconds
@treturn bool `true`, if successful
@see napms
@fixme ncurses only?
*/
static int
Pdelay_output(lua_State *L)
{
	int ms = checkint(L, 1);
	return pushokresult(delay_output(ms));
}

/***
Throw away any typeahead in the keyboard input buffer.
@function flushinp
@treturn bool `true`, if successful
@see flushinp(3x)
@see ungetch
*/
static int
Pflushinp(lua_State *L)
{
	return pushboolresult(flushinp());
}

/***
Return a character to the keyboard input buffer.
@function ungetch
@int c
@treturn bool `true`, if successful
@see ungetch(3x)
@see flushinp
*/
static int
Pungetch(lua_State *L)
{
	int c = checkint(L, 1);
	return pushokresult(ungetch(c));
}

/***
Create a new pad.
@function newpad
@int nlines
@int ncols
@treturn bool `true`, if successful
@see newpad(3x)
*/
static int
Pnewpad(lua_State *L)
{
	int nlines = checkint(L, 1);
	int ncols = checkint(L, 2);
	lc_newwin(L, newpad(nlines, ncols));
	return 1;
}

static char ti_capname[32];

/***
Fetch terminfo boolean capability.
@function tigetflag
@string capname
@treturn bool content of terminal boolean capability
@see tigetflag(3x)
@see terminfo(5)
*/
static int
Ptigetflag (lua_State *L)
{
	int r;

	strlcpy (ti_capname, luaL_checkstring (L, 1), sizeof (ti_capname));
	r = tigetflag (ti_capname);
	if (-1 == r)
		return luaL_error (L, "`%s' is not a boolean capability", ti_capname);
	return pushboolresult (r);
}

/***
Fetch terminfo numeric capability.
@function tigetnum
@string capname
@treturn int content of terminal numeric capability
@see tigetnum(3x)
@see terminfo(5)
*/
static int
Ptigetnum (lua_State *L)
{
	int res;

	strlcpy (ti_capname, luaL_checkstring (L, 1), sizeof (ti_capname));
	res = tigetnum (ti_capname);
	if (-2 == res)
		return luaL_error (L, "`%s' is not a numeric capability", ti_capname);
	else if (-1 == res)
		lua_pushnil (L);
	else
		lua_pushinteger(L, res);
	return 1;
}

/***
Fetch terminfo string capability.
@function tigetstr
@string capname
@treturn string content of terminal string capability
@see tigetstr(3x)
@see terminfo(5)
*/
static int
Ptigetstr (lua_State *L)
{
	const char *res;

	strlcpy (ti_capname, luaL_checkstring (L, 1), sizeof (ti_capname));
	res = tigetstr (ti_capname);
	if ((char *) -1 == res)
		return luaL_error (L, "`%s' is not a string capability", ti_capname);
	else if (NULL == res)
		lua_pushnil (L);
	else
		lua_pushstring(L, res);
	return 1;
}
#endif

static const luaL_Reg curseslib[] =
{
#if HAVE_CURSES
	LCURSES_FUNC( Pbaudrate		),
	LCURSES_FUNC( Pbeep		),
	LCURSES_FUNC( Pcbreak		),
	LCURSES_FUNC( Pcolor_pair	),
	LCURSES_FUNC( Pcolor_pairs	),
	LCURSES_FUNC( Pcolors		),
	LCURSES_FUNC( Pcols		),
	LCURSES_FUNC( Pcurs_set		),
	LCURSES_FUNC( Pdelay_output	),
	LCURSES_FUNC( Pdoupdate		),
	LCURSES_FUNC( Pecho		),
	LCURSES_FUNC( Pendwin		),
	LCURSES_FUNC( Perasechar	),
	LCURSES_FUNC( Pflash		),
	LCURSES_FUNC( Pflushinp		),
	LCURSES_FUNC( Phalfdelay	),
	LCURSES_FUNC( Phas_colors	),
	LCURSES_FUNC( Phas_ic		),
	LCURSES_FUNC( Phas_il		),
	LCURSES_FUNC( Pinit_pair	),
	LCURSES_FUNC( Pisendwin		),
	LCURSES_FUNC( Pkeyname		),
	LCURSES_FUNC( Pkillchar		),
	LCURSES_FUNC( Plines		),
	LCURSES_FUNC( Plongname		),
	LCURSES_FUNC( Pnapms		),
	LCURSES_FUNC( Pnew_chstr	),
	LCURSES_FUNC( Pnewpad		),
	LCURSES_FUNC( Pnewwin		),
	LCURSES_FUNC( Pnl		),
	LCURSES_FUNC( Ppair_content	),
	LCURSES_FUNC( Praw		),
	LCURSES_FUNC( Presizeterm	),
	LCURSES_FUNC( Pripoffline	),
	LCURSES_FUNC( Pslk_attroff	),
	LCURSES_FUNC( Pslk_attron	),
	LCURSES_FUNC( Pslk_attrset	),
	LCURSES_FUNC( Pslk_clear	),
	LCURSES_FUNC( Pslk_init		),
	LCURSES_FUNC( Pslk_label	),
	LCURSES_FUNC( Pslk_noutrefresh	),
	LCURSES_FUNC( Pslk_refresh	),
	LCURSES_FUNC( Pslk_restore	),
	LCURSES_FUNC( Pslk_set		),
	LCURSES_FUNC( Pslk_touch	),
	LCURSES_FUNC( Pstart_color	),
	LCURSES_FUNC( Pstdscr		),
	LCURSES_FUNC( Ptermattrs	),
	LCURSES_FUNC( Ptermname		),
	LCURSES_FUNC( Ptigetflag	),
	LCURSES_FUNC( Ptigetnum		),
	LCURSES_FUNC( Ptigetstr		),
	LCURSES_FUNC( Punctrl		),
	LCURSES_FUNC( Pungetch		),
	LCURSES_FUNC( Puse_default_colors),
#endif
	{NULL, NULL}
};

/***
Constants.
@section constants
*/

/***
Curses constants.
Any constants not available in the underlying system will be `nil` valued,
see @{curses.lua}. Many of the `KEY_` constants cannot be generated by
modern keyboards and are mostly for historical compatibility with ancient
terminal hardware keyboards.

Note that almost all of these constants remain undefined (`nil`) until
after @{curses.initscr} has returned successfully.
@table curses
@int ACS_BLOCK alternate character set solid block
@int ACS_BOARD alternate character set board of squares
@int ACS_BTEE alternate character set bottom-tee
@int ACS_BULLET alternate character set bullet
@int ACS_CKBOARD alternate character set stipple
@int ACS_DARROW alternate character set down arrow
@int ACS_DEGREE alternate character set degrees mark
@int ACS_DIAMOND alternate character set diamond
@int ACS_HLINE alternate character set horizontal line
@int ACS_LANTERN alternate character set lantern
@int ACS_LARROW alternate character set left arrow
@int ACS_LLCORNER alternate character set lower left corner
@int ACS_LRCORNER alternate character set lower right corner
@int ACS_LTEE alternate character set left tee
@int ACS_PLMINUS alternate character set plus/minus
@int ACS_PLUS alternate character set plus
@int ACS_RARROW alternate character set right arrow
@int ACS_RTEE alternate character set right tee
@int ACS_S1 alternate character set scan-line 1
@int ACS_S9 alternate character set scan-line 9
@int ACS_TTEE alternate character set top tee
@int ACS_UARROW alternate character set up arrow
@int ACS_ULCORNER alternate character set upper left corner
@int ACS_URCORNER alternate character set upper right corner
@int ACS_VLINE alternate character set vertical line
@int A_ALTCHARSET alternatate character set attribute
@int A_ATTRIBUTES attributed character attributes bitmask
@int A_BLINK blinking attribute
@int A_BOLD bold attribute
@int A_CHARTEXT attributed character text bitmask
@int A_COLOR attributed character color-pair bitmask
@int A_DIM half-bright attribute
@int A_INVIS invisible attribute
@int A_NORMAL normal attribute (all attributes off)
@int A_PROTECT protected attribute
@int A_REVERSE reverse video attribute
@int A_STANDOUT standout attribute
@int A_UNDERLINE underline attribute
@int COLOR_BLACK black color attribute
@int COLOR_BLUE blue color attribute
@int COLOR_CYAN cyan color attribute
@int COLOR_GREEN green color attribute
@int COLOR_MAGENTA magenta color attribute
@int COLOR_RED red color attribute
@int COLOR_WHITE white color attribute
@int COLOR_YELLOW yellow color attribute
@int KEY_A1 upper-left of keypad key
@int KEY_A3 upper-right of keypad key
@int KEY_B2 center of keypad key
@int KEY_BACKSPACE backspace key
@int KEY_BEG beginning key
@int KEY_BREAK break key
@int KEY_BTAB backtab key
@int KEY_C1 bottom-left of keypad key
@int KEY_C3 bottom-right of keypad key
@int KEY_CANCEL cancel key
@int KEY_CATAB clear all tabs key
@int KEY_CLEAR clear screen key
@int KEY_CLOSE close key
@int KEY_COMMAND command key
@int KEY_COPY copy key
@int KEY_CREATE create key
@int KEY_CTAB clear tab key
@int KEY_DC delete character key
@int KEY_DL delete line key
@int KEY_DOWN down arrow key
@int KEY_EIC exit insert char mode key
@int KEY_END end key
@int KEY_ENTER enter key
@int KEY_EOL clear to end of line key
@int KEY_EOS clear to end of screen key
@int KEY_EXIT exit key
@int KEY_F0 f0 key
@int KEY_F1 f1 key
@int KEY_F2 f2 key
@int KEY_F3 f3 key
@int KEY_F4 f4 key
@int KEY_F5 f5 key
@int KEY_F6 f6 key
@int KEY_F7 f7 key
@int KEY_F8 f8 key
@int KEY_F9 f9 key
@int KEY_F10 f10 key
@int KEY_F11 f11 key
@int KEY_F12 f12 key
@int KEY_F13 f13 key
@int KEY_F14 f14 key
@int KEY_F15 f15 key
@int KEY_F16 f16 key
@int KEY_F17 f17 key
@int KEY_F18 f18 key
@int KEY_F19 f19 key
@int KEY_F20 f20 key
@int KEY_F21 f21 key
@int KEY_F22 f22 key
@int KEY_F23 f23 key
@int KEY_F24 f24 key
@int KEY_F25 f25 key
@int KEY_F26 f26 key
@int KEY_F27 f27 key
@int KEY_F28 f28 key
@int KEY_F29 f29 key
@int KEY_F30 f30 key
@int KEY_F31 f31 key
@int KEY_F32 f32 key
@int KEY_F33 f33 key
@int KEY_F34 f34 key
@int KEY_F35 f35 key
@int KEY_F36 f36 key
@int KEY_F37 f37 key
@int KEY_F38 f38 key
@int KEY_F39 f39 key
@int KEY_F40 f40 key
@int KEY_F41 f41 key
@int KEY_F42 f42 key
@int KEY_F43 f43 key
@int KEY_F44 f44 key
@int KEY_F45 f45 key
@int KEY_F46 f46 key
@int KEY_F47 f47 key
@int KEY_F48 f48 key
@int KEY_F49 f49 key
@int KEY_F50 f50 key
@int KEY_F51 f51 key
@int KEY_F52 f52 key
@int KEY_F53 f53 key
@int KEY_F54 f54 key
@int KEY_F55 f55 key
@int KEY_F56 f56 key
@int KEY_F57 f57 key
@int KEY_F58 f58 key
@int KEY_F59 f59 key
@int KEY_F60 f60 key
@int KEY_F61 f61 key
@int KEY_F62 f62 key
@int KEY_F63 f63 key
@int KEY_FIND find key
@int KEY_HELP help key
@int KEY_HOME home key
@int KEY_IC enter insert char mode key
@int KEY_IL insert line key
@int KEY_LEFT cursor left key
@int KEY_LL home down or bottom key
@int KEY_MARK mark key
@int KEY_MESSAGE message key
@int KEY_MOUSE mouse event available virtual key
@int KEY_MOVE move key
@int KEY_NEXT next object key
@int KEY_NPAGE next page key
@int KEY_OPEN open key
@int KEY_OPTIONS options key
@int KEY_PPAGE previous page key
@int KEY_PREVIOUS prewious object key
@int KEY_PRINT print key
@int KEY_REDO redo key
@int KEY_REFERENCE reference key
@int KEY_REFRESH refresh key
@int KEY_REPLACE replace key
@int KEY_RESET hard reset key
@int KEY_RESIZE resize event virtual key
@int KEY_RESTART restart key
@int KEY_RESUME resume key
@int KEY_RIGHT cursor right key
@int KEY_SAVE save key
@int KEY_SBEG shift beginning key
@int KEY_SCANCEL shift cancel key
@int KEY_SCOMMAND shift command key
@int KEY_SCOPY shift copy key
@int KEY_SCREATE shift create key
@int KEY_SDC shift delete character key
@int KEY_SDL shift delete line key
@int KEY_SELECT select key
@int KEY_SEND send key
@int KEY_SEOL shift clear to end of line key
@int KEY_SEXIT shift exit key
@int KEY_SF scroll one line forward key
@int KEY_SFIND shift find key
@int KEY_SHELP shift help key
@int KEY_SHOME shift home key
@int KEY_SIC shift enter insert mode key
@int KEY_SLEFT shift cursor left key
@int KEY_SMESSAGE shift message key
@int KEY_SMOVE shift move key
@int KEY_SNEXT shift next object key
@int KEY_SOPTIONS shift options key
@int KEY_SPREVIOUS shift previous object key
@int KEY_SPRINT shift print key
@int KEY_SR scroll one line backward key
@int KEY_SREDO shift redo key
@int KEY_SREPLACE shift replace key
@int KEY_SRESET soft reset key
@int KEY_SRIGHT shift cursor right key
@int KEY_SRSUME shift resume key
@int KEY_SSAVE shift save key
@int KEY_SSUSPEND shift suspend key
@int KEY_STAB shift tab key
@int KEY_SUNDO shift undo key
@int KEY_SUSPEND suspend key
@int KEY_UNDO undo key
@int KEY_UP cursor up key
@usage
  -- Print curses constants supported on this host.
  for name, value in pairs (require "curses") do
    if type (value) == "number" then
      print (name, value)
     end
  end
*/

LUALIB_API int
luaopen_curses_c(lua_State *L)
{
	luaopen_curses_window(L);
	luaopen_curses_chstr(L);

	luaL_register(L, "curses", curseslib);
	lua_pushliteral(L, "lcurses for " LUA_VERSION " / " PACKAGE_STRING);
	lua_setfield(L, -2, "version");

#if HAVE_CURSES
	lua_pushstring(L, "initscr");
	lua_pushvalue(L, -2);
	lua_pushcclosure(L, Pinitscr, 1);
	lua_settable(L, -3);
#endif

	return 1;
}


text:
<?php
if ($_POST["text_area_test"]) {
  echo '
Success
';
  echo '
YOU TYPED: ' . $_POST["text_area_test"] . '
';
} else {
  echo '
Failure
';
  echo '
Failed to receive any text from text area
';
}
?>


text:
package com.example.EECS_581.ecc_android_app;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.content.Intent;
import org.json.JSONObject;

import android.widget.CompoundButton;
import android.widget.TextView;
import android.view.View;
import android.text.Html;
import android.widget.CheckBox;

public class CompanyDetail extends Activity {

    View view;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Intent i = getIntent();
        String st = i.getStringExtra("Company_JSON_Object");
        System.out.println("Got intent with data: " + st);

        setContentView(R.layout.activity_company_detail);

        updateCompanyInfo(st);

    }

    public void updateCompanyInfo(String st) {
        try {
            JSONObject j = new JSONObject(st);
            final String companyName = (String) j.get("company_name");
            setTitle(companyName);

            TextView displayCompanyName = (TextView) findViewById(R.id.companyDetailName);
            displayCompanyName.append(companyName);

            TextView displayCompanyECCTable = (TextView) findViewById(R.id.companyDetailECCTable);
            String ECC_table = (String) j.get("ecc_table");
            displayCompanyECCTable.append(ECC_table);

            TextView displayCompanyOverview = (TextView) findViewById(R.id.companyDetailOverview);
            String overview = (String) j.get("overview");
            displayCompanyOverview.append(Html.fromHtml(overview));

            TextView displayCompanyWebsite = (TextView) findViewById(R.id.companyDetailWebsite);
            String website = (String) j.get("website");
            displayCompanyWebsite.append(website);

            TextView displayCompanyMajors = (TextView) findViewById(R.id.companyDetailMajors);
            String majors = (String) j.get("majors");
            displayCompanyMajors.append(majors);

            TextView displayCompanyPositionTypes = (TextView) findViewById(R.id.companyDetailPositionTypes);
            String position_types = (String) j.get("position_types");
            displayCompanyPositionTypes.append(position_types);

            TextView displayCompanyDegreeLevels = (TextView) findViewById(R.id.companyDetailDegreeLevels);
            String degree_levels = (String) j.get("degree_levels");
            displayCompanyDegreeLevels.append(degree_levels);

            CheckBox visitedBox = (CheckBox) findViewById (R.id.companyDetailVisited);
            Boolean visited = (Boolean) j.get("visited");
            visitedBox.setChecked(visited);
            visitedBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
                @Override
                public void onCheckedChanged(CompoundButton buttonView,boolean isChecked) {
                    System.out.println("visited check is now: " + isChecked);
                    CompanyList.setVisited(companyName, isChecked);
                }
            });

            CheckBox favoritedBox = (CheckBox) findViewById (R.id.companyDetailFavorite);
            Boolean favorited = (Boolean) j.get("favorited");
            favoritedBox.setChecked(favorited);
            favoritedBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
                @Override
                public void onCheckedChanged(CompoundButton buttonView,boolean isChecked) {
                    System.out.println("favorite check is now: " + isChecked);
                    CompanyList.setFavorited(companyName, isChecked);
                }
            });

        } catch (Exception e) {
            System.out.println(e.getMessage());
        }
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_company_detail, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }
}


text:
<?php

declare(strict_types=1);

namespace Zhiyi\Plus\Models;

use Illuminate\Database\Eloquent\Model;

/**
 * Zhiyi\Plus\Models\BlackList.
 *
 * @property int $user_id main user
 * @property int $target_id blacked user id
 * @property \Illuminate\Support\Carbon|null $created_at
 * @property \Illuminate\Support\Carbon|null $updated_at
 * @property-read \Zhiyi\Plus\Models\User|null $user
 * @method static \Illuminate\Database\Eloquent\Builder|BlackList newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|BlackList newQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|BlackList query()
 * @method static \Illuminate\Database\Eloquent\Builder|BlackList whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|BlackList whereTargetId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|BlackList whereUpdatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|BlackList whereUserId($value)
 * @mixin \Eloquent
 */
class BlackList extends Model
{
    public function user()
    {
        return $this->hasOne(User::class, 'id', 'target_id');
    }
}