text:
//#define LOG_NDEBUG 0
#include <utils/Log.h>
#include <utils/RefBase.h>
#include <binder/Parcel.h>

#include <display/IMultiDisplayCallbackRegistrar.h>

namespace android {
namespace intel {

enum {
    MDS_SERVER_REGISTER_CALLBACK = IBinder::FIRST_CALL_TRANSACTION,
    MDS_SERVER_UNREGISTER_CALLBACK,
};

class BpMultiDisplayCallbackRegistrar:public BpInterface<IMultiDisplayCallbackRegistrar> {
public:
    BpMultiDisplayCallbackRegistrar(const sp<IBinder>& impl)
        : BpInterface<IMultiDisplayCallbackRegistrar>(impl)
    {
    }

    virtual status_t registerCallback(const sp<IMultiDisplayCallback>& cbk) {
        Parcel data, reply;
        data.writeInterfaceToken(IMultiDisplayCallbackRegistrar::getInterfaceDescriptor());
        data.writeStrongBinder(cbk->asBinder());
        status_t result = remote()->transact(
                MDS_SERVER_REGISTER_CALLBACK, data, &reply);
        if (result != NO_ERROR) {
            return result;
        }
        result = reply.readInt32();
        return result;
    }

    virtual status_t unregisterCallback(const sp<IMultiDisplayCallback>& cbk) {
        Parcel data, reply;
        data.writeInterfaceToken(IMultiDisplayCallbackRegistrar::getInterfaceDescriptor());
        data.writeStrongBinder(cbk->asBinder());
        status_t result = remote()->transact(
                MDS_SERVER_UNREGISTER_CALLBACK, data, &reply);
        if (result != NO_ERROR) {
            return result;
        }
        result = reply.readInt32();
        return result;
    }
};

IMPLEMENT_META_INTERFACE(MultiDisplayCallbackRegistrar,"com.intel.MultiDisplayCallbackRegistrar");

status_t BnMultiDisplayCallbackRegistrar::onTransact(
    uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
    switch (code) {
        case MDS_SERVER_REGISTER_CALLBACK: {
            CHECK_INTERFACE(IMultiDisplayCallbackRegistrar, data, reply);
            sp<IBinder> cbk = data.readStrongBinder();
            status_t ret = registerCallback(
                    interface_cast<IMultiDisplayCallback>(cbk));
            reply->writeInt32(ret);
            return NO_ERROR;
        } break;
        case MDS_SERVER_UNREGISTER_CALLBACK: {
            CHECK_INTERFACE(IMultiDisplayCallbackRegistrar, data, reply);
            sp<IBinder> cbk = data.readStrongBinder();
            status_t ret = unregisterCallback(
                    interface_cast<IMultiDisplayCallback>(cbk));
            reply->writeInt32(ret);
            return NO_ERROR;
        } break;
        default:
            return BBinder::onTransact(code, data, reply, flags);
    } // switch
}

}; // namespace intel
}; // namespace android


text:
using UnityEngine;
using System.Collections;

public class WanderAvoidUnit : MonoBehaviour {

    private SteeringBasics steeringBasics;
    private Wander2 wander;
    private CollisionAvoidance colAvoid;

    private NearSensor colAvoidSensor;

    // Use this for initialization
    void Start()
    {
        steeringBasics = GetComponent<SteeringBasics>();
        wander = GetComponent<Wander2>();
        colAvoid = GetComponent<CollisionAvoidance>();

        colAvoidSensor = transform.Find("ColAvoidSensor").GetComponent<NearSensor>();
    }

    // Update is called once per frame
    void Update()
    {
        Vector3 accel = colAvoid.getSteering(colAvoidSensor.targets);

        if (accel.magnitude < 0.005f)
        {
            accel = wander.getSteering();
        }

        steeringBasics.steer(accel);
        steeringBasics.lookWhereYoureGoing();
    }
}

redpajama_set_name: RedPajamaGithub


text:
<?php

declare(strict_types=1);

namespace Application\Migrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
 * Add cloud role for all admin users
 */
final class Version20210223100000 extends AbstractMigration
{
    public function getDescription(): string
    {
        return 'Add cloud role for all admin users';
    }

    public function up(Schema $schema): void
    {
        $this->addSql('ALTER TABLE event_user_assignment ADD allowed_to_read TINYINT(1) NOT NULL');
        $rows = $this->connection->fetchAllAssociative(
            'SELECT * FROM user',
            []
        );

        foreach ($rows as $row) {
            $roles = unserialize($row['roles']);
            if (in_array('ROLE_ADMIN', $roles)) {
                $roles[] = 'ROLE_CLOUD';
                $this->addSql(
                    'UPDATE user SET roles = ? WHERE uid = ?',
                    [serialize($roles), $row['uid']]
                );
            }
        }
    }

    public function down(Schema $schema): void
    {
        $this->addSql(
            'ALTER TABLE event_user_assignment DROP allowed_to_read'
        );
        $rows = $this->connection->fetchAllAssociative(
            'SELECT * FROM user',
            []
        );

        foreach ($rows as $row) {
            $roles = unserialize($row['roles']);
            if (($key = array_search('ROLE_CLOUD', $roles)) !== false) {
                unset($roles[$key]);
                $this->addSql(
                    'UPDATE user SET roles = ? WHERE uid = ?',
                    [serialize($roles), $row['uid']]
                );
            }
        }

    }
}


text:
using System;

namespace PubNub.Async.Configuration
{
	public interface IRegisterService
	{
		void Register<TService>(Func<IPubNubClient, TService> resolver);
	}
}


text:
package gemlite.sample.order.logic;

import gemlite.core.annotations.logic.RemoteService;
import gemlite.core.api.index.IndexEntrySet;
import gemlite.core.api.logic.AbstractRemoteService;
import gemlite.core.api.logic.LogicServices;
import gemlite.sample.order.domain.Customer;
import gemlite.sample.order.domain.CustomerDBKey;

import java.util.List;
import java.util.Set;

@RemoteService(name = "TestCheckpoint")
public class TestCheckpoint extends AbstractRemoteService<List<Customer>>
{

  public List<Customer> doExecute(Object userArgs, Set<Object> filters)
  {
    CustomerDBKey k = new CustomerDBKey();
    IndexEntrySet set = LogicServices.getIndexData("d");
    f1();
    f2("dsd");
    LogicServices.getService("TestCheckpoint2");

    Tool1 tool = new Tool1();
    tool.f11();
    tool.f21("dd");
    return null;
  }

  private void f1()
  {
    TestCheckpoint2 cc = (TestCheckpoint2) LogicServices.getService("TestCheckpoint2");
    cc.doExecute(null, null);
  }

  private void f2(String n)
  {

    f3();
  }

  private void f3()
  {

  }

  private void f3(int k)
  {

  }
}


text:
from cnab240.tipos import LoteBase

class LoteCobranca(LoteBase):
    HeaderCls = LoteCobranca.banco.registros.HeaderLoteCobranca
    TrailerCls = LoteCobranca.banco.registros.TrailerLoteCobranca


text:
package com.cloud.network.ovs.dao;

import java.util.List;

import org.springframework.stereotype.Component;

import com.cloud.utils.db.GenericDaoBase;
import com.cloud.utils.db.SearchBuilder;
import com.cloud.utils.db.SearchCriteria;
import com.cloud.utils.db.SearchCriteria.Op;

@Component
public class OvsTunnelInterfaceDaoImpl extends GenericDaoBase<OvsTunnelInterfaceVO, Long> implements OvsTunnelInterfaceDao {

    protected final SearchBuilder<OvsTunnelInterfaceVO> hostAndLabelSearch;
    protected final SearchBuilder<OvsTunnelInterfaceVO> labelSearch;

    public OvsTunnelInterfaceDaoImpl() {
        hostAndLabelSearch = createSearchBuilder();
        hostAndLabelSearch.and("host_id", hostAndLabelSearch.entity().getHostId(), Op.EQ);
        hostAndLabelSearch.and("label", hostAndLabelSearch.entity().getLabel(), Op.EQ);
        hostAndLabelSearch.done();

        labelSearch = createSearchBuilder();
        labelSearch.and("label", labelSearch.entity().getLabel(), Op.EQ);
        labelSearch.done();

    }

    @Override
    public OvsTunnelInterfaceVO getByHostAndLabel(long hostId, String label) {
        SearchCriteria<OvsTunnelInterfaceVO> sc = hostAndLabelSearch.create();
        sc.setParameters("host_id", hostId);
        sc.setParameters("label", label);
        return findOneBy(sc);
    }

    @Override
    public List<OvsTunnelInterfaceVO> listByLabel(String label) {
        SearchCriteria<OvsTunnelInterfaceVO> sc = labelSearch.create();
        sc.setParameters("label", label);
        return listBy(sc);
    }

}


text:
/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package net.grinder.console.communication;

import java.util.EventListener;

import net.grinder.messages.console.AgentAddress;

/**
 * Listener which is invoked when log is arrived from agent controller.
 *
 * @author JunHo Yoon
 * @since 3.0
 */
public interface LogArrivedListener extends EventListener {
	/**
	 * callback method which will be called when log is arrived from a agent.
	 * @param testId test id
	 * @param agentAddress agent address
	 * @param logs compressed log byte array
	 */
	public void logArrived(String testId, AgentAddress agentAddress, byte[] logs);
}


text:
<?php

namespace Yandex\Market\Content\Models;

use Yandex\Common\Model;

class Option extends Model
{
    protected $valueId = null;

    protected $valueText = null;

    protected $count = null;

    protected $popularity = null;

    protected $tag = null;

    protected $code = null;

    protected $unit = null;

    protected $unitName = null;

    /**
     * Retrieve the valueId property
     *
     * @return int|null
     */
    public function getValueId()
    {
        return $this->valueId;
    }

    /**
     * Retrieve the valueText property
     *
     * @return string|null
     */
    public function getValueText()
    {
        return $this->valueText;
    }

    /**
     * Retrieve the count property
     *
     * @return int|null
     */
    public function getCount()
    {
        return $this->count;
    }

    /**
     * Retrieve the popularity property
     *
     * @return float|null
     */
    public function getPopularity()
    {
        return $this->popularity;
    }

    /**
     * Retrieve the tag property
     *
     * @return string|null
     */
    public function getTag()
    {
        return $this->tag;
    }

    /**
     * Retrieve the code property
     *
     * @return string|null
     */
    public function getCode()
    {
        return $this->code;
    }

    /**
     * Retrieve the unit property
     *
     * @return string|null
     */
    public function getUnit()
    {
        return $this->unit;
    }

    /**
     * Retrieve the unitName property
     *
     * @return string|null
     */
    public function getUnitName()
    {
        return $this->unitName;
    }
}


text:
package org.springframework.boot.actuate.autoconfigure.integrationtest;

import java.util.ArrayList;
import java.util.List;

import org.springframework.boot.actuate.autoconfigure.audit.AuditEventsEndpointAutoConfiguration;
import org.springframework.boot.actuate.autoconfigure.beans.BeansEndpointAutoConfiguration;
import org.springframework.boot.actuate.autoconfigure.condition.AutoConfigurationReportEndpointAutoConfiguration;
import org.springframework.boot.actuate.autoconfigure.context.ShutdownEndpointAutoConfiguration;
import org.springframework.boot.actuate.autoconfigure.context.properties.ConfigurationPropertiesReportEndpointAutoConfiguration;
import org.springframework.boot.actuate.autoconfigure.env.EnvironmentEndpointAutoConfiguration;
import org.springframework.boot.actuate.autoconfigure.health.HealthEndpointAutoConfiguration;
import org.springframework.boot.actuate.autoconfigure.info.InfoEndpointAutoConfiguration;
import org.springframework.boot.actuate.autoconfigure.management.ThreadDumpEndpointAutoConfiguration;
import org.springframework.boot.actuate.autoconfigure.trace.TraceEndpointAutoConfiguration;
import org.springframework.boot.actuate.autoconfigure.web.servlet.RequestMappingEndpointAutoConfiguration;

/**
 * A list of all endpoint auto-configuration classes for use in tests.
 */
final class EndpointAutoConfigurationClasses {

	static final Class<?>[] ALL;

	static {
		List<Class<?>> all = new ArrayList<>();
		all.add(AuditEventsEndpointAutoConfiguration.class);
		all.add(BeansEndpointAutoConfiguration.class);
		all.add(AutoConfigurationReportEndpointAutoConfiguration.class);
		all.add(ConfigurationPropertiesReportEndpointAutoConfiguration.class);
		all.add(ShutdownEndpointAutoConfiguration.class);
		all.add(EnvironmentEndpointAutoConfiguration.class);
		all.add(HealthEndpointAutoConfiguration.class);
		all.add(InfoEndpointAutoConfiguration.class);
		all.add(ThreadDumpEndpointAutoConfiguration.class);
		all.add(TraceEndpointAutoConfiguration.class);
		all.add(RequestMappingEndpointAutoConfiguration.class);
		ALL = all.toArray(new Class<?>[] {});
	}

	private EndpointAutoConfigurationClasses() {
	}

}


text:
package org.efidroid.efidroidmanager.services;

import android.app.Activity;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.NotificationCompat;

import org.efidroid.efidroidmanager.R;
import org.efidroid.efidroidmanager.activities.MainActivity;
import org.efidroid.efidroidmanager.activities.NotificationReceiverActivity;
import org.efidroid.efidroidmanager.types.ProgressReceiver;
import org.efidroid.efidroidmanager.types.ProgressServiceTask;

public class GenericProgressIntentService extends IntentServiceEx {
    // start argument
    public static final String ARG_BUNDLE = "argument_bundle";
    public static final String ARG_HANDLER = "argument_handler";

    // button_actions
    private static final String BUTTON_ACTION_STOP = "button_stop";

    // message actions
    public static final String MESSAGE_ACTION_NOTIFICATION_SHOW = "message_action_notification_show";
    public static final String MESSAGE_ACTION_NOTIFICATION_HIDE = "message_action_notification_hide";

    // status
    private boolean mShowNotifications = false;
    private ProgressServiceTask mHandler = null;

    public GenericProgressIntentService() {
        super("GenericProgressIntentService");
    }

    @Override
    protected void onHandleIntent(Intent intent) {
        mShowNotifications = false;

        Bundle extras = intent.getBundleExtra(ARG_BUNDLE);
        Class<ProgressServiceTask> handlerClass = (Class<ProgressServiceTask>) intent.getSerializableExtra(ARG_HANDLER);
        try {
            mHandler = handlerClass.getDeclaredConstructor(GenericProgressIntentService.class).newInstance(this);
            mHandler.onProcess(extras);

        } catch (Exception e) {
            e.printStackTrace();
        }

        if (mShowNotifications) {
            // remove progress notification
            cancelNotification();

            // show result if user didn't cancel(the activity will be opened anyway in that case)
            if (!shouldStop()) {
                showResultNotification();
            }
        }

        mHandler = null;
    }

    protected void showProgressNotification() {
        Intent intent;
        PendingIntent pIntent;

        // get notification manager
        NotificationManager notifyManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);

        // build notification
        NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this)
                .setSmallIcon(R.mipmap.ic_launcher)
                .setContentTitle(getBaseContext().getResources().getString(R.string.app_name))
                .setOngoing(true)
                .setContentText(mHandler.getNotificationProgressTitle());

        // create button intent
        intent = new Intent(this, NotificationReceiverActivity.class);
        intent.putExtra(NotificationReceiverActivity.ARG_NOTIFICATION_ID, NotificationReceiverActivity.NOTIFICATION_ID_OP_UPDATE_SERVICE);
        intent.putExtra(NotificationReceiverActivity.ARG_SERVICE_CLASS, getClass());
        intent.setAction(BUTTON_ACTION_STOP);
        pIntent = PendingIntent.getActivity(this, (int) System.currentTimeMillis(), intent, 0);
        mBuilder.addAction(R.drawable.ic_action_delete, getString(R.string.stop), pIntent);

        // create content intent
        intent = new Intent(this, MainActivity.class);
        intent.setAction(Intent.ACTION_MAIN);
        intent.addCategory(Intent.CATEGORY_LAUNCHER);
        pIntent = PendingIntent.getActivity(this, (int) System.currentTimeMillis(), intent, 0);
        mBuilder.setContentIntent(pIntent);

        // show notification
        notifyManager.notify(NotificationReceiverActivity.NOTIFICATION_ID_OP_UPDATE_SERVICE, mBuilder.build());
    }

    protected void showResultNotification() {
        Intent intent;
        PendingIntent pIntent;

        // get notification manager
        NotificationManager notifyManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);

        // build notification
        NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this)
                .setSmallIcon(R.mipmap.ic_launcher)
                .setContentTitle(getBaseContext().getResources().getString(R.string.app_name))
                .setAutoCancel(true)
                .setContentText(mHandler.getNotificationResultTitle());

        // create content intent
        intent = new Intent(this, MainActivity.class);
        intent.setAction(Intent.ACTION_MAIN);
        intent.addCategory(Intent.CATEGORY_LAUNCHER);
        pIntent = PendingIntent.getActivity(this, (int) System.currentTimeMillis(), intent, 0);
        mBuilder.setContentIntent(pIntent);

        notifyManager.notify(NotificationReceiverActivity.NOTIFICATION_ID_OP_UPDATE_SERVICE, mBuilder.build());
    }

    private void cancelNotification() {
        // get notification manager
        NotificationManager notifyManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);

        notifyManager.cancel(NotificationReceiverActivity.NOTIFICATION_ID_OP_UPDATE_SERVICE);
    }

    public int publishProgress(int percent, String text) {
        Intent intent = new Intent();
        intent.setAction(ProgressReceiver.ACTION_OPUPDATE_PROGRESS);
        intent.putExtra(ProgressReceiver.ARG_OPUPDATE_PROGRESS, percent);
        intent.putExtra(ProgressReceiver.ARG_OPUPDATE_TEXT, text);
        sendBroadcast(intent);

        return percent;
    }

    public void publishFinish(boolean success) {
        Intent intent = new Intent();
        intent.setAction(ProgressReceiver.ACTION_OPUPDATE_FINISH);
        intent.putExtra(ProgressReceiver.ARG_OPUPDATE_SUCCESS, success);
        sendBroadcast(intent);
    }

    @Override
    protected void onHandleMessage(Intent intent) {
        if (mHandler == null) {
            super.onHandleMessage(intent);
            return;
        }

        switch (intent.getAction()) {
            case MESSAGE_ACTION_NOTIFICATION_SHOW:
                if (!mShowNotifications) {
                    showProgressNotification();
                    mShowNotifications = true;
                }
                break;

            case MESSAGE_ACTION_NOTIFICATION_HIDE:
                if (mShowNotifications) {
                    cancelNotification();
                    mShowNotifications = false;
                }
                break;

            default:
                super.onHandleMessage(intent);
        }
    }

    @Override
    protected void earlyStop() {
        publishProgress(0, getString(R.string.aborted));
        publishFinish(false);
    }

    public static void handleNotificationIntent(Activity activity, Class<?> clazz) {
        switch (activity.getIntent().getAction()) {
            case BUTTON_ACTION_STOP:
                stopCurrentTask(activity, clazz);
                break;
        }
    }

    public static void showNotification(Context context, Class<?> clazz, boolean show) {
        Intent intent = new Intent();
        intent.setAction(show ? MESSAGE_ACTION_NOTIFICATION_SHOW : MESSAGE_ACTION_NOTIFICATION_HIDE);
        sendMessage(context, clazz, intent);
    }
}


text:
package com.acl.ax.datasource.test;

import static org.junit.Assert.*;

import java.util.List;

import org.junit.*;

import com.acl.ax.datasource.cmdutil.*;
import com.acl.ax.datasource.core.*;

/*
 * This class focus on parse the XML file to get Infa metadata
 * and convert to ACL table format
 */
public class XMLParseTest {

	final String configFileName = "testdata/apg.properties";
	final String unicodeXMLFile = "testdata/unicodeTable.xml";
	final String shortcutSourceXMLFile = "testdata/shortcutSource.xml";
	final String shortcutTargetXMLFile= "testdata/shortcutTarget.xml";
	final String shortcutMappingXMLFile= "testdata/shortcutMapping.xml";
	final String doubleShortcutXMLFile= "testdata/shortcutMappingWithTarget.xml";
	final String asciiXMLFile= "testdata/asciiInv.xml";
	final String workletXMLFile= "testdata/worklet.xml";
	final String reusableMixFile ="testdata/reusableMix.xml";

	private ACLProjectGenerator apg;
	@Before
	public void setUp() throws Exception {
		CommandLineConfigDataService config = new CommandLineConfigDataService(configFileName);
		config.loadConfigData();
		ConfigDataServiceFactory.setConfigDataService(config);
		apg = new ACLProjectGenerator();
	}

	@Test
	public void testUnicodeTable()
	{
		List<AclTableFormat> tbls = apg.getAclFileFromXMLMetadata(unicodeXMLFile, FormatStyle.ACLStyle);
		assertTrue(tbls.size() == 1);
		AclTableFormat tbl = tbls.get(0);
		checkChineseTable(tbl,new String ("\u4E2D\u6587\u8868_original_1"));
	}

	@Test
	public void testShortcutSource()
	{
		List<AclTableFormat> tbls = apg.getAclFileFromXMLMetadata(shortcutSourceXMLFile, FormatStyle.ACLStyle);
		assertEquals(tbls.size() , 1);
		AclTableFormat tbl = tbls.get(0);
		checkChineseTable(tbl,new String ("\u4E2D\u6587\u8868_original"));
	}
	@Test
	public void testShortcutTarget()
	{
		List<AclTableFormat> tbls = apg.getAclFileFromXMLMetadata(shortcutTargetXMLFile, FormatStyle.ACLStyle);
		assertEquals(tbls.size() , 1);
		AclTableFormat tbl = tbls.get(0);
		checkChineseTable(tbl,new String ("\u4E2D\u6587\u8868_link_to_zw"));

	}
	@Test
	public void testShortcutMapping()
	{
		List<AclTableFormat> tbls = apg.getAclFileFromXMLMetadata(shortcutMappingXMLFile, FormatStyle.ACLStyle);
		assertEquals(tbls.size() , 1);
		AclTableFormat tbl = tbls.get(0);
		checkChineseTable(tbl,new String ("\u4E2D\u6587\u8868_original_1"));
	}

	@Test
	public void testSCMappingWithSCTarget()
	{
		List<AclTableFormat> tbls = apg.getAclFileFromXMLMetadata(doubleShortcutXMLFile, FormatStyle.ACLStyle);
		assertEquals(tbls.size() , 1);
		AclTableFormat tbl = tbls.get(0);
		checkChineseTable(tbl,new String ("\u4E2D\u6587\u8868_link_to_zw"));
	}

	@Test
	public void testWorkletTarget()
	{
		List<AclTableFormat> tbls = apg.getAclFileFromXMLMetadata(workletXMLFile, FormatStyle.ACLStyle);
		assertTrue(tbls.size() == 1);
		AclTableFormat tbl = tbls.get(0);
		checkChineseTable(tbl,new String ("\u4E2D\u6587\u8868_link_to_zw"));
	}

	@Test
	public void testAsciiTarget()
	{
		List<AclTableFormat> tbls = apg.getAclFileFromXMLMetadata(asciiXMLFile, FormatStyle.ACLStyle);
		assertTrue(tbls.size() == 1);
		AclTableFormat tbl = tbls.get(0);
		assertFalse(tbl.isUnicode());
		assertEquals(15,tbl.fields.size());
		assertEquals("LOCATION",tbl.fields.get(2).name);
		assertEquals("ASCII",tbl.fields.get(2).getDataType());
	}

	//test the reusable session with mixed ascii & unicode target
	@Test
	public void testReusableMix()
	{
		List<AclTableFormat> tbls = apg.getAclFileFromXMLMetadata(reusableMixFile, FormatStyle.ACLStyle);
		assertTrue(tbls.size() == 2);

		AclTableFormat tbl1 = tbls.get(0);
		AclTableFormat tbl2 = tbls.get(1);
		if (tbl1.getTableName().equals("INVENTORY1"))
		{
			assertFalse(tbl1.isUnicode());
			assertEquals(15,tbl1.fields.size());
			assertEquals("LOCATION",tbl1.fields.get(2).name);
			assertEquals("ASCII",tbl1.fields.get(2).getDataType());
			checkChineseTable(tbl2,new String ("\u4E2D\u6587\u8868_link_to_zw"));

		}
		else
		{
			assertFalse(tbl2.isUnicode());
			assertEquals(15,tbl2.fields.size());
			assertEquals("LOCATION",tbl2.fields.get(2).name);
			assertEquals("ASCII",tbl2.fields.get(2).getDataType());
			checkChineseTable(tbl1,new String ("\u4E2D\u6587\u8868_link_to_zw"));
		}
	}

	private void checkChineseTable(AclTableFormat tbl, final String expTblName)
	{
		assertTrue(tbl.isUnicode());
		assertEquals(2,tbl.fields.size());
		assertEquals(tbl.getTableName(),expTblName);
		assertEquals(tbl.fields.get(0).name,(new String("\u4E2D\u6587\u5217_1")));
		assertEquals(tbl.fields.get(0).getDataType(),"UNICODE");
		assertEquals(tbl.fields.get(1).name,(new String("\u4E2D\u6587\u5217_2")));
		assertEquals(tbl.fields.get(1).getDataType(),"UNICODE");

	}
}


text:
<?php
defined('C5_EXECUTE') or die("Access Denied.");

$u = new User();
Config::getOrDefine('SITE_LOCALE', 'en_US');

if ($u->getUserDefaultLanguage() != '') {
	define('ACTIVE_LOCALE', $u->getUserDefaultLanguage());
} else if (defined('LOCALE')) {
	define('ACTIVE_LOCALE', LOCALE);
} else {
	define('ACTIVE_LOCALE', SITE_LOCALE);
}

if (strpos(ACTIVE_LOCALE, '_') > -1) {
	$loc = explode('_', ACTIVE_LOCALE);
	if (is_array($loc) && count($loc) == 2) {
		define('LANGUAGE', $loc[0]);
	}
}

define('DIRNAME_LANGUAGES_SITE_INTERFACE', 'site');

if (!defined('DIR_LANGUAGES_SITE_INTERFACE')) {
	define('DIR_LANGUAGES_SITE_INTERFACE', DIR_LANGUAGES . '/' . DIRNAME_LANGUAGES_SITE_INTERFACE);
}

if (!defined('REL_DIR_LANGUAGES_SITE_INTERFACE')) {
	define('REL_DIR_LANGUAGES_SITE_INTERFACE', DIR_REL . '/' . DIRNAME_LANGUAGES . '/' . DIRNAME_LANGUAGES_SITE_INTERFACE);
}

if (!defined("LANGUAGE")) {
	define("LANGUAGE", ACTIVE_LOCALE);
}

if (!defined('ENABLE_TRANSLATE_LOCALE_EN_US')) {
	define('ENABLE_TRANSLATE_LOCALE_EN_US', false);
}

// initialize localization immediately following defining locale
Localization::init();

if (defined('DATE_APP_GENERIC_MDYT_FULL')) {
	define('CUSTOM_DATE_APP_GENERIC_MDYT_FULL', DATE_APP_GENERIC_MDYT_FULL);
} else {
	/** @deprecated Use Loader::helper('date')->formatDateTime($date, true, false) instead */
	define('DATE_APP_GENERIC_MDYT_FULL', t('F d, Y \a\t g:i A'));
}

if (defined('DATE_APP_GENERIC_MDYT_FULL_SECONDS')) {
	define('CUSTOM_DATE_APP_GENERIC_MDYT_FULL_SECONDS', DATE_APP_GENERIC_MDYT_FULL_SECONDS);
} else {
	/** @deprecated Use Loader::helper('date')->formatDateTime($date, true, true) instead */
	define('DATE_APP_GENERIC_MDYT_FULL_SECONDS', t('F d, Y \a\t g:i:s A'));
}

if (defined('DATE_APP_GENERIC_MDYT')) {
	define('CUSTOM_DATE_APP_GENERIC_MDYT', DATE_APP_GENERIC_MDYT);
} else {
	/** @deprecated Use Loader::helper('date')->formatDateTime($date, false, false) instead */
	define('DATE_APP_GENERIC_MDYT', t('n/j/Y \a\t g:i A'));
}

if (defined('DATE_APP_GENERIC_MDY')) {
	define('CUSTOM_DATE_APP_GENERIC_MDY', DATE_APP_GENERIC_MDY);
} else {
	/** @deprecated Use Loader::helper('date')->formatDate($date, false) instead */
	define('DATE_APP_GENERIC_MDY', t('n/j/Y'));
}

if (defined('DATE_APP_GENERIC_MDY_FULL')) {
	define('CUSTOM_DATE_APP_GENERIC_MDY_FULL', DATE_APP_GENERIC_MDY_FULL);
} else {
	/** @deprecated Use Loader::helper('date')->formatDate($date, true) instead */
	define('DATE_APP_GENERIC_MDY_FULL', t('F j, Y'));
}

if (defined('DATE_APP_GENERIC_T')) {
	define('CUSTOM_DATE_APP_GENERIC_T', DATE_APP_GENERIC_T);
} else {
	/** @deprecated Use Loader::helper('date')->formatTime($date, false) instead */
	define('DATE_APP_GENERIC_T', t('g:i A'));
}

if (defined('DATE_APP_GENERIC_TS')) {
	define('CUSTOM_DATE_APP_GENERIC_TS', DATE_APP_GENERIC_TS);
} else {
	/** @deprecated Use Loader::helper('date')->formatTime($date, true) instead */
	define('DATE_APP_GENERIC_TS', t('g:i:s A'));
}

if (defined('DATE_APP_FILENAME')) {
	define('CUSTOM_DATE_APP_FILENAME', DATE_APP_FILENAME);
} else {
	/** @deprecated Use Loader::helper('date')->formatSpecial('FILENAME', $date) instead */
	define('DATE_APP_FILENAME', t('d-m-Y_H:i_')); // used when dates are used to start filenames
}

if (defined('DATE_APP_FILE_PROPERTIES')) {
	define('CUSTOM_DATE_APP_FILE_PROPERTIES', DATE_APP_FILE_PROPERTIES);
} else {
	/** @deprecated Use Loader::helper('date')->formatSpecial('FILE_PROPERTIES', $date) instead */
	define('DATE_APP_FILE_PROPERTIES', DATE_APP_GENERIC_MDYT_FULL);
}
if (defined('DATE_APP_FILE_VERSIONS')) {
	define('CUSTOM_DATE_APP_FILE_VERSIONS', DATE_APP_FILE_VERSIONS);
} else {
	/** @deprecated Use Loader::helper('date')->formatSpecial('FILE_VERSIONS', $date) instead */
	define('DATE_APP_FILE_VERSIONS', DATE_APP_GENERIC_MDYT_FULL);
}
if (defined('DATE_APP_FILE_DOWNLOAD')) {
	define('CUSTOM_DATE_APP_FILE_DOWNLOAD', DATE_APP_FILE_DOWNLOAD);
} else {
	/** @deprecated Use Loader::helper('date')->formatSpecial('FILE_DOWNLOAD', $date) instead */
	define('DATE_APP_FILE_DOWNLOAD', DATE_APP_GENERIC_MDYT_FULL);
}

if (defined('DATE_APP_PAGE_VERSIONS')) {
	define('CUSTOM_DATE_APP_PAGE_VERSIONS', DATE_APP_PAGE_VERSIONS);
} else {
	/** @deprecated Use Loader::helper('date')->formatSpecial('PAGE_VERSIONS', $date) instead */
	define('DATE_APP_PAGE_VERSIONS', DATE_APP_GENERIC_MDYT);
}
if (defined('DATE_APP_DASHBOARD_SEARCH_RESULTS_USERS')) {
	define('CUSTOM_DATE_APP_DASHBOARD_SEARCH_RESULTS_USERS', DATE_APP_DASHBOARD_SEARCH_RESULTS_USERS);
} else {
	/** @deprecated Use Loader::helper('date')->formatSpecial('DASHBOARD_SEARCH_RESULTS_USERS', $date) instead */
	define('DATE_APP_DASHBOARD_SEARCH_RESULTS_USERS', DATE_APP_GENERIC_MDYT);
}

if (defined('DATE_APP_DASHBOARD_SEARCH_RESULTS_FILES')) {
	define('CUSTOM_DATE_APP_DASHBOARD_SEARCH_RESULTS_FILES', DATE_APP_DASHBOARD_SEARCH_RESULTS_FILES);
} else {
	/** @deprecated Use Loader::helper('date')->formatSpecial('DASHBOARD_SEARCH_RESULTS_FILES', $date) instead */
	define('DATE_APP_DASHBOARD_SEARCH_RESULTS_FILES', DATE_APP_GENERIC_MDYT);
}

if (defined('DATE_APP_DASHBOARD_SEARCH_RESULTS_PAGES')) {
	define('CUSTOM_DATE_APP_DASHBOARD_SEARCH_RESULTS_PAGES', DATE_APP_DASHBOARD_SEARCH_RESULTS_PAGES);
} else {
	/** @deprecated Use Loader::helper('date')->formatSpecial('DASHBOARD_SEARCH_RESULTS_PAGES', $date) instead */
	define('DATE_APP_DASHBOARD_SEARCH_RESULTS_PAGES', DATE_APP_GENERIC_MDYT);
}

if (defined('DATE_APP_DATE_ATTRIBUTE_TYPE_MDY')) {
	define('CUSTOM_DATE_APP_DATE_ATTRIBUTE_TYPE_MDY', DATE_APP_DATE_ATTRIBUTE_TYPE_MDY);
} else {
	/** @deprecated Use Loader::helper('date')->formatSpecial('DATE_ATTRIBUTE_TYPE_MDY', $date) instead */
	define('DATE_APP_DATE_ATTRIBUTE_TYPE_MDY', DATE_APP_GENERIC_MDY);
}
if (defined('DATE_APP_DATE_ATTRIBUTE_TYPE_T')) {
	define('CUSTOM_DATE_APP_DATE_ATTRIBUTE_TYPE_T', DATE_APP_DATE_ATTRIBUTE_TYPE_T);
} else {
	/** @deprecated Use Loader::helper('date')->formatSpecial('DATE_ATTRIBUTE_TYPE_T', $date) instead */
	define('DATE_APP_DATE_ATTRIBUTE_TYPE_T', DATE_APP_GENERIC_TS);
}
if (defined('DATE_APP_DATE_PICKER')) {
	define('CUSTOM_DATE_APP_DATE_PICKER', DATE_APP_DATE_PICKER);
} else {
	/** @deprecated Use Loader::helper('date')->getJQueryUIDatePickerFormat() instead */
	define('DATE_APP_DATE_PICKER', t(/*i18n http://api.jqueryui.com/datepicker/#utility-formatDate */'m/d/yy'));
}

if (!defined('DATE_APP_SURVEY_RESULTS')) {
	// NO DEFINE HERE, JUST PLACING HERE TO MAKE A NOTE OF IT
}

if (!defined('DATE_FORM_HELPER_FORMAT_HOUR')) {
	define('DATE_FORM_HELPER_FORMAT_HOUR', tc(/*i18n: can be 12 or 24 */'Time format', '12'));
}
/** @deprecated */
define('BLOCK_NOT_AVAILABLE_TEXT', t('This block is no longer available.'));
/** @deprecated */
define('GUEST_GROUP_NAME', tc('GroupName', 'Guest'));
/** @deprecated */
define('REGISTERED_GROUP_NAME', tc('GroupName', 'Registered Users'));
/** @deprecated */
define('ADMIN_GROUP_NAME', tc('GroupName', 'Administrators'));


text:
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <errno.h>
#include <fcntl.h>

#include "ruby.h"

#ifndef RSTRING_PTR
#define RSTRING_PTR(str) (RSTRING(str)->ptr)
#endif
#ifndef RSTRING_LEN
#define RSTRING_LEN(str) (RSTRING(str)->len)
#endif

#ifdef HAVE_FASTCGI_FCGIAPP_H
#include <fastcgi/fcgiapp.h>
#else
#include "fcgiapp.h"
#endif

static VALUE cFCGI;
static VALUE eFCGIError;
static VALUE cFCGIStream;
static VALUE eFCGIStreamError;
static VALUE eFCGIStreamUnsupportedVersionError;
static VALUE eFCGIStreamProtocolError;
static VALUE eFCGIStreamParamsError;
static VALUE eFCGIStreamCallSeqError;

typedef struct fcgi_data {
  FCGX_Request *req;
  VALUE in;
  VALUE out;
  VALUE err;
  VALUE env;
} fcgi_data;

static void fcgi_mark(fcgi_data *data)
{
/*  rb_gc_mark(data->req); */
  rb_gc_mark(data->in);
  rb_gc_mark(data->out);
  rb_gc_mark(data->err);
  rb_gc_mark(data->env);
}

static void fcgi_free_req(fcgi_data *data)
{
  free(data->req);
  free(data);
}

static VALUE fcgi_s_accept(VALUE self)
{
  int status;
  FCGX_Request *req;
  fd_set readfds;

  req = ALLOC(FCGX_Request);

  status = FCGX_InitRequest(req,0,0);
  if (status != 0) {
    rb_raise(eFCGIError, "FCGX_Init() failed");
    return Qnil;
  }

  FD_ZERO(&readfds);
  FD_SET(req->listen_sock, &readfds);
  if (rb_thread_select(req->listen_sock+1, &readfds, NULL, NULL, NULL) < 1) {
    return Qnil;
  }

  status = FCGX_Accept_r(req);
  if (status >= 0) {
    fcgi_data *data;
    char      **env;
    VALUE     obj,key, value;
    char      *pkey,*pvalue;
    int       flags, fd;

    /* Unset NONBLOCKING */
    fd = ((FCGX_Request*) req)->ipcFd;
    flags = fcntl(fd, F_GETFL);

    if (flags & O_NONBLOCK) {
       fcntl(fd, F_SETFL, flags & ~O_NONBLOCK);
    }

    obj = Data_Make_Struct(self, fcgi_data, fcgi_mark, fcgi_free_req, data);
    data->req = req;
    data->in  = Data_Wrap_Struct(cFCGIStream, 0, 0, req->in);
    data->out = Data_Wrap_Struct(cFCGIStream, 0, 0, req->out);
    data->err = Data_Wrap_Struct(cFCGIStream, 0, 0, req->err);
    data->env = rb_hash_new();
    env = req->envp;
    for (; *env; env++) {
      int size = 0;
      pkey = *env;
      pvalue = pkey;
      while( *(pvalue++) != '=') size++;
      key   = rb_str_new(pkey, size);
      value = rb_str_new2(pvalue);
      OBJ_TAINT(key);
      OBJ_TAINT(value);
      rb_hash_aset(data->env, key, value);
    }

    return obj;
  } else {
    return Qnil;
  }
}

static VALUE fcgi_s_each(VALUE self)
{
  VALUE fcgi;

  while ((fcgi = fcgi_s_accept(self)) != Qnil) {
    rb_yield(fcgi);
  }
  return Qnil;
}

static VALUE fcgi_s_iscgi(VALUE self)
{
  if (FCGX_IsCGI()) {
    return Qtrue;
  } else {
    return Qfalse;
  }
}

static VALUE fcgi_in(VALUE self)
{
  fcgi_data *data;

  Data_Get_Struct(self, fcgi_data, data);
  return data->in;
}

static VALUE fcgi_out(VALUE self)
{
  fcgi_data *data;

  Data_Get_Struct(self, fcgi_data, data);
  return data->out;
}

static VALUE fcgi_err(VALUE self)
{
  fcgi_data *data;

  Data_Get_Struct(self, fcgi_data, data);
  return data->err;
}

static VALUE fcgi_env(VALUE self)
{
  fcgi_data *data;

  Data_Get_Struct(self, fcgi_data, data);
  return data->env;
}

static VALUE fcgi_finish(VALUE self)
{
  fcgi_data *data;

  Data_Get_Struct(self, fcgi_data, data);

  FCGX_Finish_r(data->req);

  return Qtrue;
}

#define CHECK_STREAM_ERROR(stream) {\
  int err = FCGX_GetError(stream);\
	extern int errno; \
  if (err) {\
    if (err > 0) {\
			errno = err;\
      rb_sys_fail(NULL);\
    }\
    else {\
      switch (err) {\
      case FCGX_UNSUPPORTED_VERSION:\
        rb_raise(eFCGIStreamUnsupportedVersionError, "unsupported version");\
        break;\
      case FCGX_PROTOCOL_ERROR:\
        rb_raise(eFCGIStreamProtocolError, "protocol error");\
        break;\
      case FCGX_PARAMS_ERROR:\
        rb_raise(eFCGIStreamProtocolError, "parameter error");\
        break;\
      case FCGX_CALL_SEQ_ERROR:\
        rb_raise(eFCGIStreamCallSeqError, "preconditions are not met");\
        break;\
      default:\
        rb_raise(eFCGIStreamError, "unknown error");\
        break;\
      }\
    }\
  }\
}

static VALUE fcgi_stream_putc(VALUE self, VALUE ch)
{
  FCGX_Stream *stream;
  int c;

  rb_secure(4);
  Data_Get_Struct(self, FCGX_Stream, stream);
  if ((c = FCGX_PutChar(NUM2INT(ch), stream)) == EOF)
    CHECK_STREAM_ERROR(stream);
  return INT2NUM(c);
}

static VALUE fcgi_stream_write(VALUE self, VALUE str)
{
  FCGX_Stream *stream;
  int len;

  rb_secure(4);
  Data_Get_Struct(self, FCGX_Stream, stream);
  str = rb_obj_as_string(str);
  len = FCGX_PutStr(RSTRING_PTR(str), RSTRING_LEN(str), stream);
  if (len == EOF) CHECK_STREAM_ERROR(stream);
  return INT2NUM(len);
}

static VALUE fcgi_stream_print(int argc, VALUE *argv, VALUE out)
{
  int i;
  VALUE line;

  /* if no argument given, print `$_' */
  if (argc == 0) {
    argc = 1;
    line = rb_lastline_get();
    argv = &line;
  }
  for (i=0; i<argc; i++) {
    if (!NIL_P(rb_output_fs) && i>0) {
      fcgi_stream_write(out, rb_output_fs);
    }
    switch (TYPE(argv[i])) {
    case T_NIL:
      fcgi_stream_write(out, rb_str_new2("nil"));
      break;
    default:
      fcgi_stream_write(out, argv[i]);
      break;
    }
  }
  if (!NIL_P(rb_output_rs)) {
    fcgi_stream_write(out, rb_output_rs);
  }

  return Qnil;
}

static VALUE fcgi_stream_printf(int argc, VALUE *argv, VALUE out)
{
  fcgi_stream_write(out, rb_f_sprintf(argc, argv));
  return Qnil;
}

static VALUE fcgi_stream_puts _((int, VALUE*, VALUE));

static VALUE fcgi_stream_puts_ary(VALUE ary, VALUE out)
{
  VALUE tmp;
  int i;

  for (i=0; i<RARRAY_LEN(ary); i++) {
    tmp = RARRAY_PTR(ary)[i];
    if (rb_inspecting_p(tmp)) {
      tmp = rb_str_new2("[...]");
    }
    fcgi_stream_puts(1, &tmp, out);
  }
  return Qnil;
}

static VALUE fcgi_stream_puts(int argc, VALUE *argv, VALUE out)
{
  int i;
  VALUE line;

  /* if no argument given, print newline. */
  if (argc == 0) {
    fcgi_stream_write(out, rb_default_rs);
    return Qnil;
  }
  for (i=0; i<argc; i++) {
    switch (TYPE(argv[i])) {
    case T_NIL:
      line = rb_str_new2("nil");
      break;
    case T_ARRAY:
      rb_protect_inspect(fcgi_stream_puts_ary, argv[i], out);
      continue;
    default:
      line = argv[i];
      break;
    }
    line = rb_obj_as_string(line);
    fcgi_stream_write(out, line);
    if (RSTRING_PTR(line)[RSTRING_LEN(line)-1] != '\n') {
      fcgi_stream_write(out, rb_default_rs);
    }
  }

  return Qnil;
}

static VALUE fcgi_stream_addstr(VALUE out, VALUE str)
{
  fcgi_stream_write(out, str);
  return out;
}

static VALUE fcgi_stream_flush(VALUE self)
{
  FCGX_Stream *stream;

  Data_Get_Struct(self, FCGX_Stream, stream);
  if (FCGX_FFlush(stream) == EOF)
    CHECK_STREAM_ERROR(stream);
  return Qnil;
}

static VALUE fcgi_stream_getc(VALUE self)
{
  FCGX_Stream *stream;
  int c;

  Data_Get_Struct(self, FCGX_Stream, stream);
  if ((c = FCGX_GetChar(stream)) == EOF) {
    CHECK_STREAM_ERROR(stream);
    return Qnil;
  }
  else {
    return INT2NUM(c);
  }
}

static VALUE fcgi_stream_ungetc(VALUE self, VALUE ch)
{
  FCGX_Stream *stream;
  int c;

  if (rb_safe_level() >= 4 && !OBJ_TAINTED(self)) {
    rb_raise(rb_eSecurityError, "Insecure: operation on untainted IO");
  }
  Data_Get_Struct(self, FCGX_Stream, stream);
  c = FCGX_UnGetChar(NUM2INT(ch), stream);
  CHECK_STREAM_ERROR(stream);
  return INT2NUM(c);
}

static VALUE fcgi_stream_gets(VALUE self) {
  FCGX_Stream *stream;
  char buff[BUFSIZ];
  VALUE str = rb_str_new(0,0);
  OBJ_TAINT(str);

  if (rb_safe_level() >= 4 && !OBJ_TAINTED(self)) {
    rb_raise(rb_eSecurityError, "Insecure: operation on untainted IO");
  }

  Data_Get_Struct(self, FCGX_Stream, stream);

  for (;;) {
    if (FCGX_GetLine(buff, BUFSIZ, stream) == NULL) {
      CHECK_STREAM_ERROR(stream);
      break;
    }
    rb_str_cat(str, buff, strlen(buff));
    if (strchr(buff, '\n')) break;
  }
  if (RSTRING_LEN(str) > 0)
    return str;
  else
    return Qnil;
}

static VALUE fcgi_stream_read(int argc, VALUE *argv, VALUE self)
{
  VALUE num,str;
  FCGX_Stream *stream;
  char *buff;
  int n;

  if (rb_safe_level() >= 4 && !OBJ_TAINTED(self)) {
    rb_raise(rb_eSecurityError, "Insecure: operation on untainted IO");
  }

  Data_Get_Struct(self, FCGX_Stream, stream);

  if (argc==0) {
    buff = ALLOC_N(char, 16384);
    n = FCGX_GetStr(buff, 16384, stream);
    CHECK_STREAM_ERROR(stream);
    if (n == 0) {
      free(buff);
      return  Qnil;
    }
    str = rb_str_new(buff, n);
    OBJ_TAINT(str);

    while(!FCGX_HasSeenEOF(stream)) {
      n = FCGX_GetStr(buff, 16384, stream);
      CHECK_STREAM_ERROR(stream);
      if (n > 0) {
        rb_str_cat(str, buff, n);
      } else {
        free(buff);
        return Qnil;
      }
    }
    free(buff);
    return str;
  }

  num = argv[0];
  n = NUM2INT(num);

  buff = ALLOC_N(char, n);
  n = FCGX_GetStr(buff, n, stream);
  CHECK_STREAM_ERROR(stream);
  if (n > 0) {
    str = rb_str_new(buff, n);
    OBJ_TAINT(str);
    free(buff);
    return str;
  }
  else {
    free(buff);
    return Qnil;
  }
}

static VALUE fcgi_stream_eof(VALUE self)
{
  FCGX_Stream *stream;

  if (rb_safe_level() >= 4 && !OBJ_TAINTED(self)) {
    rb_raise(rb_eSecurityError, "Insecure: operation on untainted IO");
  }
  Data_Get_Struct(self, FCGX_Stream, stream);
  return FCGX_HasSeenEOF(stream) ? Qtrue : Qfalse;
}

static VALUE fcgi_stream_close(VALUE self)
{
  FCGX_Stream *stream;

  if (rb_safe_level() >= 4 && !OBJ_TAINTED(self)) {
    rb_raise(rb_eSecurityError, "Insecure: can't close");
  }
  Data_Get_Struct(self, FCGX_Stream, stream);
  if (FCGX_FClose(stream) == EOF)
    CHECK_STREAM_ERROR(stream);
  return Qnil;
}

static VALUE fcgi_stream_closed(VALUE self)
{
  FCGX_Stream *stream;

  Data_Get_Struct(self, FCGX_Stream, stream);
  return stream->isClosed ? Qtrue : Qfalse;
}

static VALUE fcgi_stream_binmode(VALUE self)
{
  if (rb_safe_level() >= 4 && !OBJ_TAINTED(self)) {
    rb_raise(rb_eSecurityError, "Insecure: operation on untainted IO");
  }
  return self;
}

static VALUE fcgi_stream_isatty(VALUE self)
{
  if (rb_safe_level() >= 4 && !OBJ_TAINTED(self)) {
    rb_raise(rb_eSecurityError, "Insecure: operation on untainted IO");
  }
  return Qfalse;
}

static VALUE fcgi_stream_sync(VALUE self)
{
  if (rb_safe_level() >= 4 && !OBJ_TAINTED(self)) {
    rb_raise(rb_eSecurityError, "Insecure: operation on untainted IO");
  }
  return Qfalse;
}

static VALUE fcgi_stream_setsync(VALUE self,VALUE sync)
{
  if (rb_safe_level() >= 4 && !OBJ_TAINTED(self)) {
    rb_raise(rb_eSecurityError, "Insecure: operation on untainted IO");
  }
  return Qfalse;
}

void Init_fcgi() {

  FCGX_Init();

  cFCGI = rb_define_class("FCGI", rb_cObject);
  eFCGIError =rb_define_class_under(cFCGI, "Error", rb_eStandardError);
  rb_define_singleton_method(cFCGI, "accept", fcgi_s_accept, 0);
  rb_define_singleton_method(cFCGI, "each", fcgi_s_each, 0);
  rb_define_singleton_method(cFCGI, "each_request", fcgi_s_each, 0);
  rb_define_singleton_method(cFCGI, "is_cgi?", fcgi_s_iscgi, 0);
  rb_define_method(cFCGI, "in",  fcgi_in, 0);
  rb_define_method(cFCGI, "out", fcgi_out, 0);
  rb_define_method(cFCGI, "err", fcgi_err, 0);
  rb_define_method(cFCGI, "env", fcgi_env, 0);
  rb_define_method(cFCGI, "finish", fcgi_finish, 0);

  cFCGIStream = rb_define_class_under(cFCGI, "Stream", rb_cObject);
  eFCGIStreamError =rb_define_class_under(cFCGIStream, "Error", rb_eStandardError);
  eFCGIStreamUnsupportedVersionError =
    rb_define_class_under(cFCGIStream, "UnsupportedVersionError",
                          eFCGIStreamError);
  eFCGIStreamProtocolError = rb_define_class_under(cFCGIStream, "ProtocolError",
                                                   eFCGIStreamError);
  eFCGIStreamParamsError = rb_define_class_under(cFCGIStream, "ParamsError",
                                                 eFCGIStreamError);
  eFCGIStreamCallSeqError = rb_define_class_under(cFCGIStream, "CallSeqError",
                                                  eFCGIStreamError);
  rb_undef_method(CLASS_OF(cFCGIStream), "new");
  rb_define_method(cFCGIStream, "putc", fcgi_stream_putc, 1);
  rb_define_method(cFCGIStream, "write", fcgi_stream_write, 1);
  rb_define_method(cFCGIStream, "print", fcgi_stream_print, -1);
  rb_define_method(cFCGIStream, "printf", fcgi_stream_printf, -1);
  rb_define_method(cFCGIStream, "puts", fcgi_stream_puts, -1);
  rb_define_method(cFCGIStream, "<<", fcgi_stream_addstr, 1);
  rb_define_method(cFCGIStream, "flush", fcgi_stream_flush, 0);
  rb_define_method(cFCGIStream, "getc", fcgi_stream_getc, 0);
  rb_define_method(cFCGIStream, "ungetc", fcgi_stream_ungetc, 1);
  rb_define_method(cFCGIStream, "gets", fcgi_stream_gets, 0);
  rb_define_method(cFCGIStream, "read", fcgi_stream_read, -1);
  rb_define_method(cFCGIStream, "eof", fcgi_stream_eof, 0);
  rb_define_method(cFCGIStream, "eof?", fcgi_stream_eof, 0);
  rb_define_method(cFCGIStream, "close", fcgi_stream_close, 0);
  rb_define_method(cFCGIStream, "closed?", fcgi_stream_closed, 0);
  rb_define_method(cFCGIStream, "binmode", fcgi_stream_binmode, 0);
  rb_define_method(cFCGIStream, "isatty", fcgi_stream_isatty, 0);
  rb_define_method(cFCGIStream, "tty?", fcgi_stream_isatty, 0);
  rb_define_method(cFCGIStream, "sync", fcgi_stream_sync, 0);
  rb_define_method(cFCGIStream, "sync=", fcgi_stream_setsync, 1);
}