text:
<?php

define("CONFIG_DEFAULT_SATURATION", "DEFAULT_SATURATION");
define("CONFIG_DEFAULT_NUMBER_OF_COLORS", "DEFAULT_NUMBER_OF_COLORS");
define("CONFIG_DATABASE_VERSION", "DATABASE_VERSION");
define("CONFIG_DISPLAY_THEME_PROBABILITY", "DISPLAY_THEME_PROBABILITY");
define("CONFIG_TWITTER_ACCOUNT", "TWITTER_ACCOUNT");
define("CONFIG_TWITCH_ACCOUNT", "TWITCH_ACCOUNT");
define("CONFIG_IRC_ADDRESS", "IRC_ADDRESS");
define("CONFIG_IRC_CHANNEL", "IRC_CHANNEL");
define("CONFIG_IRC_CHAT_IN_BROWSER", "IRC_CHAT_IN_BROWSER");
define("CONFIG_DISCORD_INVITE_URL", "DISCORD_INVITE_URL");
define("CONFIG_TWITCH_API_STREAM_UPDATE_FREQUENCY", "TWITCH_API_STREAM_UPDATE_FREQUENCY");
define("CONFIG_THEME_DAYS_MARK_AS_OLD", "THEME_DAYS_MARK_AS_OLD");
define("CONFIG_THEME_MIN_VOTES_TO_SCORE", "THEME_MIN_VOTES_TO_SCORE");
define("CONFIG_THEME_NUMBER_TO_MARK_TOP", "THEME_NUMBER_TO_MARK_TOP");
define("CONFIG_THEME_NUMBER_TO_MARK_KEEP", "THEME_NUMBER_TO_MARK_KEEP");
define("CONFIG_JAMS_CONSIDERED_RECENT", "JAMS_CONSIDERED_RECENT");
define("CONFIG_SATISFACTION_RATINGS_TO_SHOW_SCORE", "SATISFACTION_RATINGS_TO_SHOW_SCORE");
define("CONFIG_PEPPER", "PEPPER");
define("CONFIG_SESSION_PASSWORD_ITERATIONS", "SESSION_PASSWORD_ITERATIONS");
define("CONFIG_TWITCH_CLIENT_ID", "TWITCH_CLIENT_ID");
define("CONFIG_TWITCH_CLIENT_SECRET", "TWITCH_CLIENT_SECRET");
define("CONFIG_TWITCH_CHECK_STREAM_AFTER_JAM_END_MINUTES", "TWITCH_CHECK_STREAM_AFTER_JAM_END_MINUTES");
define("CONFIG_RULES", "RULES");
define("CONFIG_NOTIFICATION_URL", "NOTIFICATION_URL");
define("CONFIG_NOTIFICATION_IMAGE", "NOTIFICATION_IMAGE");
define("CONFIG_NOTIFICATION", "NOTIFICATION");
define("CONFIG_JAM_TIME", "JAM_TIME");
define("CONFIG_JAM_DAY", "JAM_DAY");
define("CONFIG_JAMNAME", "JAMNAME");
define("CONFIG_JAMDESC", "JAMDESC");
define("CONFIG_DEFAULT_BRIGHTNESS", "DEFAULT_BRIGHTNESS");
define("CONFIG_DEFAULT_HUE_MIN", "DEFAULT_HUE_MIN");
define("CONFIG_DEFAULT_HUE_MAX", "DEFAULT_HUE_MAX");
define("CONFIG_ADMIN_ACTIVITY_JAMS_SINCE_LAST_PARTICIPATION_WARNING", "ADMIN_ACTIVITY_JAMS_SINCE_LAST_PARTICIPATION_WARNING");
define("CONFIG_ADMIN_SUGGESTION_TOTAL_PARTICIPATION", "ADMIN_SUGGESTION_TOTAL_PARTICIPATION");
define("CONFIG_ADMIN_SUGGESTION_RECENT_PARTICIPATION", "ADMIN_SUGGESTION_RECENT_PARTICIPATION");
define("CONFIG_ADMIN_ACTIVITY_DAYS_SINCE_LAST_ADMIN_ACTION_WARNING", "ADMIN_ACTIVITY_DAYS_SINCE_LAST_ADMIN_ACTION_WARNING");
define("CONFIG_ADMIN_ACTIVITY_DAYS_SINCE_LAST_LOGIN_GOOD", "ADMIN_ACTIVITY_DAYS_SINCE_LAST_LOGIN_GOOD");
define("CONFIG_ADMIN_ACTIVITY_JAMS_SINCE_LAST_PARTICIPATION_GOOD", "ADMIN_ACTIVITY_JAMS_SINCE_LAST_PARTICIPATION_GOOD");
define("CONFIG_ADMIN_ACTIVITY_DAYS_SINCE_LAST_LOGIN_WARNING", "ADMIN_ACTIVITY_DAYS_SINCE_LAST_LOGIN_WARNING");
define("CONFIG_ADMIN_ACTIVITY_DAYS_SINCE_LAST_ADMIN_ACTION_GOOD", "ADMIN_ACTIVITY_DAYS_SINCE_LAST_ADMIN_ACTION_GOOD");
define("CONFIG_REDIRECT_TO_HTTPS", "REDIRECT_TO_HTTPS");
define("CONFIG_JAM_DURATION", "JAM_DURATION");
define("CONFIG_MINIMUM_PASSWORD_LENGTH", "MINIMUM_PASSWORD_LENGTH");
define("CONFIG_MAXIMUM_PASSWORD_LENGTH", "MAXIMUM_PASSWORD_LENGTH");
define("CONFIG_MINIMUM_PASSWORD_HASH_ITERATIONS", "MINIMUM_PASSWORD_HASH_ITERATIONS");
define("CONFIG_MAXIMUM_PASSWORD_HASH_ITERATIONS", "MAXIMUM_PASSWORD_HASH_ITERATIONS");
define("CONFIG_MINIMUM_USERNAME_LENGTH", "MINIMUM_USERNAME_LENGTH");
define("CONFIG_MAXIMUM_USERNAME_LENGTH", "MAXIMUM_USERNAME_LENGTH");
define("CONFIG_DAYS_TO_KEEP_LOGGED_IN", "DAYS_TO_KEEP_LOGGED_IN");
define("CONFIG_MAX_COLORS_FOR_JAM", "MAX_COLORS_FOR_JAM");
define("CONFIG_MAX_ASSET_FILE_SIZE_IN_BYTES", "MAX_ASSET_FILE_SIZE_IN_BYTES");
define("CONFIG_MINIMUM_DISPLAY_NAME_LENGTH", "MINIMUM_DISPLAY_NAME_LENGTH");
define("CONFIG_MAXIMUM_DISPLAY_NAME_LENGTH", "MAXIMUM_DISPLAY_NAME_LENGTH");
define("CONFIG_MAX_SCREENSHOT_FILE_SIZE_IN_BYTES", "MAX_SCREENSHOT_FILE_SIZE_IN_BYTES");
define("CONFIG_JAM_AUTO_SCHEDULER_MINUTES_BEFORE_JAM", "JAM_AUTO_SCHEDULER_MINUTES_BEFORE_JAM");
define("CONFIG_JAM_AUTO_SCHEDULER_ENABLED", "JAM_AUTO_SCHEDULER_ENABLED");
define("CONFIG_JAMS_TO_LOAD", "JAMS_TO_LOAD");
define("CONFIG_THEMES_PER_USER", "THEMES_PER_USER");
define("CONFIG_JAM_THEMES_CONSIDERED_RECENT", "JAM_THEMES_CONSIDERED_RECENT");
define("CONFIG_THEME_PHRASE_PLURAL", "THEME_PHRASE_PLURAL");
define("CONFIG_THEME_PHRASE_SINGULAR", "THEME_PHRASE_SINGULAR");
define("CONFIG_SITE_FOOTER", "SITE_FOOTER");
define("CONFIG_GAME_PHRASE_SINGULAR", "GAME_PHRASE_SINGULAR");
define("CONFIG_GAME_PHRASE_PLURAL", "GAME_PHRASE_PLURAL");
define("CONFIG_JAM_PHRASE_SINGULAR", "JAM_PHRASE_SINGULAR");
define("CONFIG_JAM_PHRASE_PLURAL", "JAM_PHRASE_PLURAL");
define("CONFIG_DEVELOPER_PHRASE_SINGULAR", "DEVELOPER_PHRASE_SINGULAR");
define("CONFIG_DEVELOPER_PHRASE_PLURAL", "DEVELOPER_PHRASE_PLURAL");
define("CONFIG_OVERRIDE_BRAND_LOGO", "OVERRIDE_BRAND_LOGO");
define("CONFIG_OVERRIDE_MAIN_LOGO", "OVERRIDE_MAIN_LOGO");
define("CONFIG_CAN_SUBMIT_TO_PAST_JAMS", "CAN_SUBMIT_TO_PAST_JAMS");
define("CONFIG_DEFAULT_GAME_ICON_URL", "DEFAULT_GAME_ICON_URL");
define("CONFIG_DEFAULT_PERMISSIONS", "DEFAULT_PERMISSIONS");

class ConfigModel{
	public $Key;
	public $Value;
	public $Category;
	public $Description;
	public $Disabled;
	public $Editable;
	public $Required;
	public $Type;
	public $Options = Array();
    public $AddedToDictionary;
    public $RequiredPermissionsRead;
    public $RequiredPermissionsWrite;
}

class SettingEnumOptionModel{
    public $Text;
    public $Value;
}

class ConfigData{
    public $ConfigModels;

    private $configDbInterface;

    function __construct(&$configDbInterface, MessageService &$messageService) {
        $this->configDbInterface = $configDbInterface;
        $this->ConfigModels = $this->LoadConfig();
        $this->VerifyConfig($messageService);
    }

//////////////////////// MODEL CONSTRUCTOR

    function LoadConfig(){
        AddActionLog("LoadConfig");
        StartTimer("LoadConfig");

        $data = $this->configDbInterface->SelectAll();

        $configModels = Array();
        while($configData = mysqli_fetch_array($data)) {
            $key = $configData[DB_COLUMN_CONFIG_KEY];
            $options = json_decode($configData[DB_COLUMN_CONFIG_OPTIONS], true);
            $editable = $configData[DB_COLUMN_CONFIG_EDITABLE];

            $configModel = new ConfigModel();
            $configModel->Key = $key;
            $configModel->Value = $configData[DB_COLUMN_CONFIG_VALUE];
            $configModel->Category = $configData[DB_COLUMN_CONFIG_CATEGORY];
            $configModel->Description = $configData[DB_COLUMN_CONFIG_DESCRIPTION];
            $configModel->Disabled = !$editable;
            $configModel->Editable = $editable;
            $configModel->Required = $configData[DB_COLUMN_CONFIG_REQUIRED];
            $configModel->Type = $configData[DB_COLUMN_CONFIG_TYPE];
            $configModel->AddedToDictionary = $configData[DB_COLUMN_CONFIG_ADDED_TO_DICTIONARY];
            $configModel->RequiredPermissionsRead = $configData[DB_COLUMN_CONFIG_REQUIRED_PERMISSION_READ];
            $configModel->RequiredPermissionsWrite = $configData[DB_COLUMN_CONFIG_REQUIRED_PERMISSION_WRITE];

            $configModel->Options = Array();
            foreach($options as $i => $option){
                $settingEnumOptionModel = new SettingEnumOptionModel();
                $settingEnumOptionModel->Text = $option["TEXT"];
                $settingEnumOptionModel->Value = $option["VALUE"];
                $configModel->Options[] = $settingEnumOptionModel;
            }

            $configModels[$key] = $configModel;
        }

        StopTimer("LoadConfig");
        return $configModels;
    }

//////////////////////// END MODEL CONSTRUCTOR

//////////////////////// DATABASE ACTIONS (select, insert, update)

    function VerifyConfig(MessageService &$messageService) {
        AddActionLog("VerifyConfig");
        StartTimer("VerifyConfig");

        if (!isset($this->ConfigModels[CONFIG_PEPPER]->Value) || strlen($this->ConfigModels[CONFIG_PEPPER]->Value) < 1) {
            $pepper = GenerateSalt();
            $this->UpdateConfig(CONFIG_PEPPER, $pepper, OVERRIDE_AUTOMATIC_NUM);

			$messageService->SendMessage(LogMessage::SystemLogMessage(
				"CONFIG_UPDATED",
				"Config value edited: ".CONFIG_PEPPER." = '$pepper'",
				OVERRIDE_AUTOMATIC)
			);
        }

        if (!isset($this->ConfigModels[CONFIG_SESSION_PASSWORD_ITERATIONS]->Value) || strlen($this->ConfigModels[CONFIG_SESSION_PASSWORD_ITERATIONS]->Value) < 1) {
            $sessionPasswordIterations = GenerateUserHashIterations($this);
            $this->UpdateConfig(CONFIG_SESSION_PASSWORD_ITERATIONS, $sessionPasswordIterations, OVERRIDE_AUTOMATIC_NUM);

			$messageService->SendMessage(LogMessage::SystemLogMessage(
				"CONFIG_UPDATED",
				"Config value edited: ".CONFIG_SESSION_PASSWORD_ITERATIONS." = '$sessionPasswordIterations'",
				OVERRIDE_AUTOMATIC)
			);
        }

        StopTimer("VerifyConfig");
    }

    // Saves config to database, does not authorize to ensure VerifyConfig() continues to work
    function UpdateConfig($key, $value, $userId) {
        AddActionLog("UpdateConfig");
        StartTimer("UpdateConfig");

        if($this->ConfigModels[$key]->Value != $value){
            $this->configDbInterface->Update($key, $value, $userId);
            $this->ConfigModels[$key]->Value = $value;
        }

        StopTimer("UpdateConfig");
    }

//////////////////////// END DATABASE ACTIONS

//////////////////////// PUBLIC DATA EXPORT

    function GetAllPublicData(){
        AddActionLog("ConfigData_GetAllPublicData");
        StartTimer("ConfigData_GetAllPublicData");

        $dataFromDatabase = MySQLDataToArray($this->configDbInterface->SelectPublicData());

        foreach($dataFromDatabase as $i => $row){
            $dataFromDatabase[$i][DB_COLUMN_CONFIG_LASTEDITED] = gmdate("Y-m-d H:i:s", time());
            $dataFromDatabase[$i][DB_COLUMN_CONFIG_LASTEDITEDBY] = OVERRIDE_MIGRATION;
        }

        foreach($dataFromDatabase as $i => $row){
            switch($row[DB_COLUMN_CONFIG_KEY]){
                case CONFIG_TWITTER_ACCOUNT: $dataFromDatabase[$i][DB_COLUMN_CONFIG_VALUE] = ""; break;
                case CONFIG_TWITCH_ACCOUNT: $dataFromDatabase[$i][DB_COLUMN_CONFIG_VALUE] = ""; break;
                case CONFIG_IRC_ADDRESS: $dataFromDatabase[$i][DB_COLUMN_CONFIG_VALUE] = ""; break;
                case CONFIG_IRC_CHANNEL: $dataFromDatabase[$i][DB_COLUMN_CONFIG_VALUE] = ""; break;
                case CONFIG_IRC_CHAT_IN_BROWSER: $dataFromDatabase[$i][DB_COLUMN_CONFIG_VALUE] = ""; break;
                case CONFIG_DISCORD_INVITE_URL: $dataFromDatabase[$i][DB_COLUMN_CONFIG_VALUE] = ""; break;
                case CONFIG_PEPPER: $dataFromDatabase[$i][DB_COLUMN_CONFIG_VALUE] = GenerateSalt(); break;
                case CONFIG_SESSION_PASSWORD_ITERATIONS: $dataFromDatabase[$i][DB_COLUMN_CONFIG_VALUE] = GenerateUserHashIterations($this); break;
                case CONFIG_TWITCH_CLIENT_ID: $dataFromDatabase[$i][DB_COLUMN_CONFIG_VALUE] = ""; break;
                case CONFIG_TWITCH_CLIENT_SECRET: $dataFromDatabase[$i][DB_COLUMN_CONFIG_VALUE] = ""; break;
            }
        }

        StopTimer("ConfigData_GetAllPublicData");
        return $dataFromDatabase;
    }

//////////////////////// END PUBLIC DATA EXPORT
}

?>


text:
/**
 * @file glob.h
 * @author Alexander Merritt, merritt.alex@gatech.edu
 * @desc Assembly interposer globals
 */

#ifndef INTERPOSER_ASSM_GLOB_INCLUDED
#define INTERPOSER_ASSM_GLOB_INCLUDED

#include <cuda/bypass.h>
#include <assembly.h>
#include <util/compiler.h>
#include "../../assembly/internals.h"

/* Things to know
 * - thread/vgpu association; if none exist, must put thread into some vgpu
 * - if vgpu is remote or local
 * - where the marshaling region is, for remote vgpus
 */

/* association between an application thread and vgpu in the assembly */
/* assume one assembly is used for now */
struct tinfo
{
    bool valid;
    /* application state */
    pthread_t tid;
    /* vgpu state */
    struct vgpu_mapping *vgpu;
    /* marshaling state (only if remote) */
    void *buffer;
};

struct tinfo *__lookup(pthread_t tid);

#define rpc(tinfo)          ((tinfo)->vgpu->rpc)
#define VGPU_IS_LOCAL(vgpu) ((vgpu)->fixation == VGPU_LOCAL)

#define PER_THREAD_MARSHAL_BUF_SZ   (1UL << 30)

extern struct assembly * assembly_find(asmid_t id);
extern struct assembly *assm;
extern struct tinfo tinfos[32];
extern pthread_mutex_t tinfo_lock;
extern asmid_t assm_id;
extern int num_tids;

/*
 * Preprocessor magic to reduce typing
 */

#define FUNC_SETUP \
    void *buf = NULL; \
    struct tinfo *tinfo; \
    tinfo = __lookup(pthread_self()); \
    BUG(!tinfo); \
    BUG(!assm)

#define FUNC_SETUP_CERR \
    FUNC_SETUP; \
    cudaError_t cerr = cudaSuccess

/* initialize the buf ptr once thread state has been looked up */
static inline void
init_buf(void **buf, struct tinfo *tinfo)
{
    *buf = tinfo->buffer;
    memset(*buf, 0, sizeof(struct cuda_packet));
}

// Device API
cudaError_t assm_cudaGetDevice(int*);
cudaError_t assm_cudaGetDeviceCount(int*);
cudaError_t assm_cudaGetDeviceProperties(struct cudaDeviceProp*, int);
cudaError_t assm_cudaSetDevice(int);
cudaError_t assm_cudaSetDeviceFlags(unsigned int);
cudaError_t assm_cudaSetValidDevices(int*, int);

// Execution API
cudaError_t assm_cudaConfigureCall(dim3, dim3, size_t, cudaStream_t);
cudaError_t assm_cudaLaunch(const void*);
cudaError_t assm_cudaSetupArgument(const void*, size_t, size_t);

// Hidden API
void ** assm__cudaRegisterFatBinary(void *cubin);
void assm__cudaRegisterFunction(void** fatCubinHandle, const char* hostFun,
		char* deviceFun, const char* deviceName, int thread_limit, uint3* tid,
		uint3* bid, dim3* bDim, dim3* gDim, int* wSize);
void assm__cudaRegisterVar(void **fatCubinHandle, char *hostVar, char
        *deviceAddress, const char *deviceName, int ext, int vsize,
        int constant, int global);
void assm__cudaUnregisterFatBinary(void** fatCubinHandle);

// Memory API
cudaError_t assm_cudaFree(void * devPtr);
cudaError_t assm_cudaFreeArray(struct cudaArray * array);
cudaError_t assm_cudaFreeHost(void *ptr);
cudaError_t assm_cudaHostAlloc(void **pHost, size_t size, unsigned int flags);
cudaError_t assm_cudaMalloc(void **devPtr, size_t size);
cudaError_t assm_cudaMallocArray(struct cudaArray **array,
        const struct cudaChannelFormatDesc *desc, size_t width, size_t height,
        unsigned int flags);
cudaError_t assm_cudaMallocPitch(
		void **devPtr, size_t *pitch, size_t width, size_t height);
cudaError_t assm_cudaMemcpy(void *dst, const void *src,
        size_t count, enum cudaMemcpyKind kind);
cudaError_t assm_cudaMemcpyAsync(void *dst, const void *src, size_t count,
		enum cudaMemcpyKind kind, cudaStream_t stream);
cudaError_t assm_cudaMemcpyFromSymbol(void *dst, const void *symbol, size_t count,
        size_t offset, enum cudaMemcpyKind kind);
cudaError_t assm_cudaMemcpyToArray( struct cudaArray *dst, size_t wOffset,
        size_t hOffset, const void *src, size_t count, enum cudaMemcpyKind kind);
cudaError_t assm_cudaMemcpyToSymbol(const void *symbol, const void *src,
        size_t count, size_t offset, enum cudaMemcpyKind kind);

// Stream API
cudaError_t assm_cudaStreamCreate(cudaStream_t *pStream);
cudaError_t assm_cudaStreamSynchronize(cudaStream_t stream);

// Thread API
cudaError_t assm_cudaThreadExit(void);
cudaError_t assm_cudaThreadSynchronize(void);

#endif

redpajama_set_name: RedPajamaGithub


text:
ACCEPTED

#### According to
Index Fungorum

#### Published in
null

#### Original name
Pertusaria griseola Vain.

### Remarks
null


text:
<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>DFT Benchmark</title>
    <script src="../../.tmp/benchmark/dft.bench.js"></script>
</head>
<body>
</body>
</html>


text:
<?php

namespace Ds\Component\Camunda\Model\Attribute;

/**
 * Trait Suspended
 *
 * @package Ds\Component\Camunda
 */
trait Suspended
{
    /**
     * @var boolean
     */
    private $suspended; # region accessors

    /**
     * Set suspended
     *
     * @param boolean $suspended
     * @return object
     */
    public function setSuspended(?bool $suspended)
    {
        $this->suspended = $suspended;

        return $this;
    }

    /**
     * Get suspended
     *
     * @return boolean
     */
    public function getSuspended(): ?bool
    {
        return $this->suspended;
    }

    # endregion
}


text:
const babel = require('rollup-plugin-babel')
const commonJs = require('rollup-plugin-commonjs')
const fs = require('fs')
const Promise = require('bluebird')
const replace = require('rollup-plugin-replace')
const resolve = require('rollup-plugin-node-resolve')
const rollup = require('rollup').rollup
const uglify = require('rollup-plugin-uglify')

Promise.promisifyAll(fs)

const build = ({ file, input, format, plugins }) => new Promise((resolve, reject) => {
  rollup({ input, plugins })
    .then(bundle => bundle.write({ file, format, name: 'Wilderness' })
    .then(resolve))
    .catch(reject)
})

Promise.resolve(console.log('Creating UMD development bundle ...'))
  .then(() => build({
    file: 'dist/wilderness.development.js',
    input: 'src/index.js',
    format: 'umd',
    plugins: [
      babel({
        exclude: 'node_modules/**',
        plugins: [ 'transform-object-rest-spread', 'external-helpers' ],
        presets: [[ 'es2015', { 'modules': false } ]]
      }),
      commonJs(),
      resolve({ module: true }),
      replace({
        '__DEV__': true,
        "process.env.NODE_ENV !== 'production'": true
      })
    ]
  }))
  .then(() => Promise.resolve(console.log('UMD development bundle complete')))
  .then(() => Promise.resolve(console.log('Creating UMD production bundle ...')))
  .then(() => build({
    file: 'dist/wilderness.production.js',
    input: 'src/index.js',
    format: 'umd',
    plugins: [
      babel({
        exclude: 'node_modules/**',
        plugins: [ 'transform-object-rest-spread' ],
        presets: [[ 'es2015', { 'modules': false } ]]
      }),
      commonJs(),
      resolve({ module: true }),
      replace({
        '__DEV__': false,
        "process.env.NODE_ENV !== 'production'": false
      }),
      uglify()
    ]
  }))
  .then(() => Promise.resolve(console.log('UMD production bundle complete')))
  .then(() => Promise.resolve(console.log('Creating example bundles ...')))
  .then(() => fs.readdirAsync('examples')
  .then(files => Promise.filter(files, f => fs.lstatAsync(`examples/${f}`).then(x => Promise.resolve(x.isDirectory()))))
  .then(directories => Promise.all(directories.map(dir => (
    build({
      file: `examples/${dir}/dist.js`,
      input: `examples/${dir}/src.js`,
      format: 'iife',
      plugins: [
        babel({
          exclude: 'node_modules/**',
          plugins: [ 'transform-object-rest-spread' ],
          presets: [[ 'es2015', { 'modules': false } ]]
        }),
        commonJs(),
        resolve({ module: true }),
        replace({
          '__DEV__': true,
          "process.env.NODE_ENV !== 'production'": true
        })
      ]
    })
  ))))
  .then(() => Promise.resolve(console.log('Example bundles complete')))
  .catch(e => console.error(e)))


text:
namespace app { namespace Fuse { namespace Animations { struct MasterBase__Fuse_Elements_CachingMode; } } }

namespace app {
namespace Fuse {
namespace Animations {

struct MixerHandle__Fuse_Elements_CachingMode;

struct MixerHandle__Fuse_Elements_CachingMode__uType : ::uClassType
{
    ::app::Fuse::Animations::IMixerHandle__Fuse_Elements_CachingMode __interface_0;
};

MixerHandle__Fuse_Elements_CachingMode__uType* MixerHandle__Fuse_Elements_CachingMode__typeof();

void MixerHandle__Fuse_Elements_CachingMode___ObjInit(MixerHandle__Fuse_Elements_CachingMode* __this, ::app::Fuse::Animations::MasterBase__Fuse_Elements_CachingMode* master, int mode, int priority);
bool MixerHandle__Fuse_Elements_CachingMode__get_HasValue(MixerHandle__Fuse_Elements_CachingMode* __this);
int MixerHandle__Fuse_Elements_CachingMode__get_MixOp(MixerHandle__Fuse_Elements_CachingMode* __this);
int MixerHandle__Fuse_Elements_CachingMode__get_Priority(MixerHandle__Fuse_Elements_CachingMode* __this);
int MixerHandle__Fuse_Elements_CachingMode__get_RestValue(MixerHandle__Fuse_Elements_CachingMode* __this);
MixerHandle__Fuse_Elements_CachingMode* MixerHandle__Fuse_Elements_CachingMode__New_1(::uStatic* __this, ::app::Fuse::Animations::MasterBase__Fuse_Elements_CachingMode* master, int mode, int priority);
void MixerHandle__Fuse_Elements_CachingMode__Set(MixerHandle__Fuse_Elements_CachingMode* __this, int value, float strength);
void MixerHandle__Fuse_Elements_CachingMode__set_MixOp(MixerHandle__Fuse_Elements_CachingMode* __this, int value);
void MixerHandle__Fuse_Elements_CachingMode__set_Priority(MixerHandle__Fuse_Elements_CachingMode* __this, int value);
void MixerHandle__Fuse_Elements_CachingMode__Unregister(MixerHandle__Fuse_Elements_CachingMode* __this);

struct MixerHandle__Fuse_Elements_CachingMode : ::uObject
{
    int Value;
    float Strength;
    bool _hasValue;
    ::uStrong< ::app::Fuse::Animations::MasterBase__Fuse_Elements_CachingMode*> Master;
    int _MixOp;
    int _Priority;

    void _ObjInit(::app::Fuse::Animations::MasterBase__Fuse_Elements_CachingMode* master, int mode, int priority) { MixerHandle__Fuse_Elements_CachingMode___ObjInit(this, master, mode, priority); }
    bool HasValue() { return MixerHandle__Fuse_Elements_CachingMode__get_HasValue(this); }
    int MixOp() { return MixerHandle__Fuse_Elements_CachingMode__get_MixOp(this); }
    int Priority() { return MixerHandle__Fuse_Elements_CachingMode__get_Priority(this); }
    int RestValue() { return MixerHandle__Fuse_Elements_CachingMode__get_RestValue(this); }
    void Set(int value, float strength) { MixerHandle__Fuse_Elements_CachingMode__Set(this, value, strength); }
    void MixOp(int value) { MixerHandle__Fuse_Elements_CachingMode__set_MixOp(this, value); }
    void Priority(int value) { MixerHandle__Fuse_Elements_CachingMode__set_Priority(this, value); }
    void Unregister() { MixerHandle__Fuse_Elements_CachingMode__Unregister(this); }
};

}}}

#endif


text:
namespace cc {

class CC_EXPORT SharedBitmapManager {
 public:
  SharedBitmapManager() {}

  virtual scoped_ptr<SharedBitmap> AllocateSharedBitmap(const gfx::Size&) = 0;
  virtual scoped_ptr<SharedBitmap> GetSharedBitmapFromId(
      const gfx::Size&,
      const SharedBitmapId&) = 0;
  virtual scoped_ptr<SharedBitmap> GetBitmapForSharedMemory(
      base::SharedMemory*) = 0;

 private:
  DISALLOW_COPY_AND_ASSIGN(SharedBitmapManager);
};

}  // namespace cc

#endif  // CC_RESOURCES_SHARED_BITMAP_MANAGER_H_


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 org.flowable.engine.impl.persistence;

import org.flowable.common.engine.api.delegate.event.FlowableEventDispatcher;
import org.flowable.common.engine.impl.context.Context;
import org.flowable.common.engine.impl.interceptor.CommandContext;
import org.flowable.common.engine.impl.interceptor.CommandExecutor;
import org.flowable.common.engine.impl.persistence.entity.ByteArrayEntityManager;
import org.flowable.common.engine.impl.runtime.Clock;
import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl;
import org.flowable.engine.impl.history.HistoryManager;
import org.flowable.engine.impl.persistence.entity.ActivityInstanceEntityManager;
import org.flowable.engine.impl.persistence.entity.AttachmentEntityManager;
import org.flowable.engine.impl.persistence.entity.CommentEntityManager;
import org.flowable.engine.impl.persistence.entity.DeploymentEntityManager;
import org.flowable.engine.impl.persistence.entity.ExecutionEntityManager;
import org.flowable.engine.impl.persistence.entity.HistoricActivityInstanceEntityManager;
import org.flowable.engine.impl.persistence.entity.HistoricDetailEntityManager;
import org.flowable.engine.impl.persistence.entity.HistoricProcessInstanceEntityManager;
import org.flowable.engine.impl.persistence.entity.ModelEntityManager;
import org.flowable.engine.impl.persistence.entity.ProcessDefinitionEntityManager;
import org.flowable.engine.impl.persistence.entity.ProcessDefinitionInfoEntityManager;
import org.flowable.engine.impl.persistence.entity.ResourceEntityManager;
import org.flowable.job.service.impl.asyncexecutor.AsyncExecutor;

/**
 * @author Tom Baeyens
 * @author Joram Barrez
 */
public abstract class AbstractManager {

    protected ProcessEngineConfigurationImpl processEngineConfiguration;

    public AbstractManager(ProcessEngineConfigurationImpl processEngineConfiguration) {
        this.processEngineConfiguration = processEngineConfiguration;
    }

    // Command scoped

    protected CommandContext getCommandContext() {
        return Context.getCommandContext();
    }

    protected <T> T getSession(Class<T> sessionClass) {
        return getCommandContext().getSession(sessionClass);
    }

    // Engine scoped

    protected ProcessEngineConfigurationImpl getProcessEngineConfiguration() {
        return processEngineConfiguration;
    }

    protected CommandExecutor getCommandExecutor() {
        return getProcessEngineConfiguration().getCommandExecutor();
    }

    protected Clock getClock() {
        return getProcessEngineConfiguration().getClock();
    }

    protected AsyncExecutor getAsyncExecutor() {
        return getProcessEngineConfiguration().getAsyncExecutor();
    }

    protected FlowableEventDispatcher getEventDispatcher() {
        return getProcessEngineConfiguration().getEventDispatcher();
    }

    protected HistoryManager getHistoryManager() {
        return getProcessEngineConfiguration().getHistoryManager();
    }

    protected DeploymentEntityManager getDeploymentEntityManager() {
        return getProcessEngineConfiguration().getDeploymentEntityManager();
    }

    protected ResourceEntityManager getResourceEntityManager() {
        return getProcessEngineConfiguration().getResourceEntityManager();
    }

    protected ByteArrayEntityManager getByteArrayEntityManager() {
        return getProcessEngineConfiguration().getByteArrayEntityManager();
    }

    protected ProcessDefinitionEntityManager getProcessDefinitionEntityManager() {
        return getProcessEngineConfiguration().getProcessDefinitionEntityManager();
    }

    protected ProcessDefinitionInfoEntityManager getProcessDefinitionInfoEntityManager() {
        return getProcessEngineConfiguration().getProcessDefinitionInfoEntityManager();
    }

    protected ModelEntityManager getModelEntityManager() {
        return getProcessEngineConfiguration().getModelEntityManager();
    }

    protected ExecutionEntityManager getExecutionEntityManager() {
        return getProcessEngineConfiguration().getExecutionEntityManager();
    }

    protected ActivityInstanceEntityManager getActivityInstanceEntityManager() {
        return getProcessEngineConfiguration().getActivityInstanceEntityManager();
    }

    protected HistoricProcessInstanceEntityManager getHistoricProcessInstanceEntityManager() {
        return getProcessEngineConfiguration().getHistoricProcessInstanceEntityManager();
    }

    protected HistoricDetailEntityManager getHistoricDetailEntityManager() {
        return getProcessEngineConfiguration().getHistoricDetailEntityManager();
    }

    protected HistoricActivityInstanceEntityManager getHistoricActivityInstanceEntityManager() {
        return getProcessEngineConfiguration().getHistoricActivityInstanceEntityManager();
    }

    protected AttachmentEntityManager getAttachmentEntityManager() {
        return getProcessEngineConfiguration().getAttachmentEntityManager();
    }

    protected CommentEntityManager getCommentEntityManager() {
        return getProcessEngineConfiguration().getCommentEntityManager();
    }
}


text:
using System;
using Neat.Infrastructure.Config;
using Neat.Infrastructure.Encryption;
using NUnit.Framework;

namespace Neat.Test.Integration.Infrastructure.Encryption
{
    [TestFixture]
    public class AesEncryptionProviderTestCase
    {
        private AesEncryptionProvider aesEncryptionProvider;

        [SetUp]
        public void Setup()
        {
            aesEncryptionProvider = new AesEncryptionProvider(new EncryptionContext(new MsXmlConfig()));
        }

        [Test]
        public void TestEncryptDecrypt()
        {
            var result1 = aesEncryptionProvider.Encrypt("Test");
            Console.WriteLine(result1);
            var result2 = aesEncryptionProvider.Decrypt(result1);
            Console.WriteLine(result2);

            Assert.AreEqual("Test", result2);
        }
    }
}


text:
Gets the contents of a file as a byte array.

## SYNTAX

```
Get-ByteContent [-Path] <String> [<CommonParameters>]
```

## DESCRIPTION
The Get-ByteContent function is used to get the contents of a file as a byte array.

## EXAMPLES

### EXAMPLE 1
```
Get-ByteContent -Path $path
```

## PARAMETERS

### -Path
Specifies the path to an item.

```yaml
Type: System.String
Parameter Sets: (All)
Aliases:

Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).

## INPUTS

### none
## OUTPUTS

### System.Byte[]
## NOTES

## RELATED LINKS


text:
    Definisce un semplice parametro di testo dove gli utenti possono immettere
    un valore stringa utilizzabile durante una compilazione come variabile
    d'ambiente o (per sostituzione di variabili) in altre parti della
    configurazione.


text:
WORK-IN-PROGRESS
A text editor for the M4 microcontroller using the mMicroSD add-on.


text:
package org.apache.hadoop.hbase.mapreduce;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
import org.apache.hadoop.hbase.util.Base64;
import org.apache.hadoop.hbase.util.Pair;
import org.apache.hadoop.mapreduce.Mapper;
import org.apache.hadoop.mapreduce.Counter;
import org.apache.hadoop.hbase.classification.InterfaceAudience;
import org.apache.hadoop.hbase.classification.InterfaceStability;
import org.apache.hadoop.conf.Configuration;

import java.io.IOException;

/**
 * Write table content out to map output files.
 */
@InterfaceAudience.Public
@InterfaceStability.Evolving
public class TsvImporterTextMapper
extends Mapper<LongWritable, Text, ImmutableBytesWritable, Text>
{

  /** Column seperator */
  private String separator;

  /** Should skip bad lines */
  private boolean skipBadLines;
  private Counter badLineCount;

  private ImportTsv.TsvParser parser;

  public boolean getSkipBadLines() {
    return skipBadLines;
  }

  public Counter getBadLineCount() {
    return badLineCount;
  }

  public void incrementBadLineCount(int count) {
    this.badLineCount.increment(count);
  }

  /**
   * Handles initializing this class with objects specific to it (i.e., the parser).
   * Common initialization that might be leveraged by a subsclass is done in
   * doSetup. Hence a subclass may choose to override this method
   * and call doSetup as well before handling it's own custom params.
   *
   * @param context
   */
  @Override
  protected void setup(Context context) {
    doSetup(context);

    Configuration conf = context.getConfiguration();

    parser = new ImportTsv.TsvParser(conf.get(ImportTsv.COLUMNS_CONF_KEY), separator);
    if (parser.getRowKeyColumnIndex() == -1) {
      throw new RuntimeException("No row key column specified");
    }
  }

  /**
   * Handles common parameter initialization that a subclass might want to leverage.
   * @param context
   */
  protected void doSetup(Context context) {
    Configuration conf = context.getConfiguration();

    // If a custom separator has been used,
    // decode it back from Base64 encoding.
    separator = conf.get(ImportTsv.SEPARATOR_CONF_KEY);
    if (separator == null) {
      separator = ImportTsv.DEFAULT_SEPARATOR;
    } else {
      separator = new String(Base64.decode(separator));
    }

    skipBadLines = context.getConfiguration().getBoolean(ImportTsv.SKIP_LINES_CONF_KEY, true);
    badLineCount = context.getCounter("ImportTsv", "Bad Lines");
  }

  /**
   * Convert a line of TSV text into an HBase table row.
   */
  @Override
  public void map(LongWritable offset, Text value, Context context) throws IOException {
    try {
      Pair<Integer,Integer> rowKeyOffests = parser.parseRowKey(value.getBytes(), value.getLength());
      ImmutableBytesWritable rowKey = new ImmutableBytesWritable(
          value.getBytes(), rowKeyOffests.getFirst(), rowKeyOffests.getSecond());
      context.write(rowKey, value);
    } catch (ImportTsv.TsvParser.BadTsvLineException badLine) {
      if (skipBadLines) {
        System.err.println("Bad line at offset: " + offset.get() + ":\n" + badLine.getMessage());
        incrementBadLineCount(1);
        return;
      }
      throw new IOException(badLine);
    } catch (IllegalArgumentException e) {
      if (skipBadLines) {
        System.err.println("Bad line at offset: " + offset.get() + ":\n" + e.getMessage());
        incrementBadLineCount(1);
        return;
      } else {
        throw new IOException(e);
      }
    } catch (InterruptedException e) {
      e.printStackTrace();
      Thread.currentThread().interrupt();
    }
  }
}


text:
package extruder.typesafe;

import com.typesafe.config.Config;
import com.typesafe.config.ConfigList;
import com.typesafe.config.ConfigMemorySize;
import com.typesafe.config.ConfigMergeable;
import com.typesafe.config.ConfigObject;
import com.typesafe.config.ConfigOrigin;
import com.typesafe.config.ConfigResolveOptions;
import com.typesafe.config.ConfigValue;

import java.time.Duration;
import java.time.Period;
import java.time.temporal.TemporalAmount;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;

public class BrokenConfig implements Config {
  private String errorMsg;

  public BrokenConfig(String errorMsg){
    this.errorMsg = errorMsg;
  }

  @Override
  public ConfigObject root() {
    return null;
  }

  @Override
  public ConfigOrigin origin() {
    return null;
  }

  @Override
  public Config withFallback(final ConfigMergeable other) {
    return null;
  }

  @Override
  public Config resolve() {
    return null;
  }

  @Override
  public Config resolve(final ConfigResolveOptions options) {
    return null;
  }

  @Override
  public boolean isResolved() {
    return false;
  }

  @Override
  public Config resolveWith(final Config source) {
    return null;
  }

  @Override
  public Config resolveWith(final Config source, final ConfigResolveOptions options) {
    return null;
  }

  @Override
  public void checkValid(final Config reference, final String... restrictToPaths) {

  }

  @Override
  public boolean hasPath(final String path) {
    return false;
  }

  @Override
  public boolean hasPathOrNull(final String path) {
    return false;
  }

  @Override
  public boolean isEmpty() {
    return false;
  }

  @Override
  public Set<Map.Entry<String, ConfigValue>> entrySet() {
    return null;
  }

  @Override
  public boolean getIsNull(final String path) {
    return false;
  }

  @Override
  public boolean getBoolean(final String path) {
    return false;
  }

  @Override
  public Number getNumber(final String path) {
    return null;
  }

  @Override
  public int getInt(final String path) {
    return 0;
  }

  @Override
  public long getLong(final String path) {
    return 0;
  }

  @Override
  public double getDouble(final String path) {
    return 0;
  }

  @Override
  public String getString(final String path) {
    throw new RuntimeException(errorMsg);
  }

  @Override
  public <T extends Enum<T>> T getEnum(final Class<T> enumClass, final String path) {
    return null;
  }

  @Override
  public ConfigObject getObject(final String path) {
    return null;
  }

  @Override
  public Config getConfig(final String path) {
    return null;
  }

  @Override
  public Object getAnyRef(final String path) {
    return null;
  }

  @Override
  public ConfigValue getValue(final String path) {
    return null;
  }

  @Override
  public Long getBytes(final String path) {
    return null;
  }

  @Override
  public ConfigMemorySize getMemorySize(final String path) {
    return null;
  }

  @Override
  public Long getMilliseconds(final String path) {
    return null;
  }

  @Override
  public Long getNanoseconds(final String path) {
    return null;
  }

  @Override
  public long getDuration(final String path, final TimeUnit unit) {
    return 0;
  }

  @Override
  public Duration getDuration(final String path) {
    return null;
  }

  @Override
  public Period getPeriod(String path) {
    return null;
  }

  @Override
  public TemporalAmount getTemporal(String path) {
    return null;
  }

  @Override
  public ConfigList getList(final String path) {
    return null;
  }

  @Override
  public List<Boolean> getBooleanList(final String path) {
    return null;
  }

  @Override
  public List<Number> getNumberList(final String path) {
    return null;
  }

  @Override
  public List<Integer> getIntList(final String path) {
    return null;
  }

  @Override
  public List<Long> getLongList(final String path) {
    return null;
  }

  @Override
  public List<Double> getDoubleList(final String path) {
    return null;
  }

  @Override
  public List<String> getStringList(final String path) {
    return null;
  }

  @Override
  public <T extends Enum<T>> List<T> getEnumList(final Class<T> enumClass, final String path) {
    return null;
  }

  @Override
  public List<? extends ConfigObject> getObjectList(final String path) {
    return null;
  }

  @Override
  public List<? extends Config> getConfigList(final String path) {
    return null;
  }

  @Override
  public List<? extends Object> getAnyRefList(final String path) {
    return null;
  }

  @Override
  public List<Long> getBytesList(final String path) {
    return null;
  }

  @Override
  public List<ConfigMemorySize> getMemorySizeList(final String path) {
    return null;
  }

  @Override
  public List<Long> getMillisecondsList(final String path) {
    return null;
  }

  @Override
  public List<Long> getNanosecondsList(final String path) {
    return null;
  }

  @Override
  public List<Long> getDurationList(final String path, final TimeUnit unit) {
    return null;
  }

  @Override
  public List<Duration> getDurationList(final String path) {
    return null;
  }

  @Override
  public Config withOnlyPath(final String path) {
    return null;
  }

  @Override
  public Config withoutPath(final String path) {
    return null;
  }

  @Override
  public Config atPath(final String path) {
    return null;
  }

  @Override
  public Config atKey(final String key) {
    return null;
  }

  @Override
  public Config withValue(final String path, final ConfigValue value) {
    return null;
  }
}


text:
/*	SCCS Id: @(#)light.c	3.4	1997/04/10	*/
/* Copyright (c) Dean Luick, 1994					*/
/* NetHack may be freely redistributed.  See license for details.	*/

#include "hack.h"
#include "lev.h"	/* for checking save modes */

/*
 * Mobile light sources.
 *
 * This implementation minimizes memory at the expense of extra
 * recalculations.
 *
 * Light sources are "things" that have a physical position and range.
 * They have a type, which gives us information about them.  Currently
 * they are only attached to objects and monsters.  Note well:  the
 * polymorphed-player handling assumes that both youmonst.m_id and
 * youmonst.mx will always remain 0.
 *
 * Light sources, like timers, either follow game play (RANGE_GLOBAL) or
 * stay on a level (RANGE_LEVEL).  Light sources are unique by their
 * (type, id) pair.  For light sources attached to objects, this id
 * is a pointer to the object.
 *
 * The major working function is do_light_sources(). It is called
 * when the vision system is recreating its "could see" array.  Here
 * we add a flag (TEMP_LIT) to the array for all locations that are lit
 * via a light source.  The bad part of this is that we have to
 * re-calculate the LOS of each light source every time the vision
 * system runs.  Even if the light sources and any topology (vision blocking
 * positions) have not changed.  The good part is that no extra memory
 * is used, plus we don't have to figure out how far the sources have moved,
 * or if the topology has changed.
 *
 * The structure of the save/restore mechanism is amazingly similar to
 * the timer save/restore.  This is because they both have the same
 * principals of having pointers into objects that must be recalculated
 * across saves and restores.
 */

#ifdef OVL3

/* flags */
#define LSF_SHOW	0x1		/* display the light source */
#define LSF_NEEDS_FIXUP	0x2		/* need oid fixup */

static light_source *light_base = 0;

STATIC_DCL void FDECL(write_ls, (int, light_source *));
STATIC_DCL int FDECL(maybe_write_ls, (int, int, BOOLEAN_P));

/* imported from vision.c, for small circles */
extern char circle_data[];
extern char circle_start[];

/* Create a new light source.  */
void
new_light_source(x, y, range, type, id)
    xchar x, y;
    int range, type;
    genericptr_t id;
{
    light_source *ls;

    if (range > MAX_RADIUS || range < 1) {
	impossible("new_light_source:  illegal range %d", range);
	return;
    }

    ls = (light_source *) alloc(sizeof(light_source));

    ls->next = light_base;
    ls->x = x;
    ls->y = y;
    ls->range = range;
    ls->type = type;
    ls->id = id;
    ls->flags = 0;
    light_base = ls;

    vision_full_recalc = 1;	/* make the source show up */
}

/*
 * Delete a light source. This assumes only one light source is attached
 * to an object at a time.
 */
void
del_light_source(type, id)
    int type;
    genericptr_t id;
{
    light_source *curr, *prev;
    genericptr_t tmp_id;

    /* need to be prepared for dealing a with light source which
       has only been partially restored during a level change
       (in particular: chameleon vs prot. from shape changers) */
    switch (type) {
    case LS_OBJECT:	tmp_id = (genericptr_t)(((struct obj *)id)->o_id);
			break;
    case LS_MONSTER:	tmp_id = (genericptr_t)(((struct monst *)id)->m_id);
			break;
    default:		tmp_id = 0;
			break;
    }

    for (prev = 0, curr = light_base; curr; prev = curr, curr = curr->next) {
	if (curr->type != type) continue;
	if (curr->id == ((curr->flags & LSF_NEEDS_FIXUP) ? tmp_id : id)) {
	    if (prev)
		prev->next = curr->next;
	    else
		light_base = curr->next;

	    free((genericptr_t)curr);
	    vision_full_recalc = 1;
	    return;
	}
    }
    impossible("del_light_source: not found type=%d, id=0x%lx", type, (long)id);
}

/* Mark locations that are temporarily lit via mobile light sources. */
void
do_light_sources(cs_rows)
    char **cs_rows;
{
    int x, y, min_x, max_x, max_y, offset;
    char *limits;
    short at_hero_range = 0;
    light_source *ls;
    char *row;

    for (ls = light_base; ls; ls = ls->next) {
	ls->flags &= ~LSF_SHOW;

	/*
	 * Check for moved light sources.  It may be possible to
	 * save some effort if an object has not moved, but not in
	 * the current setup -- we need to recalculate for every
	 * vision recalc.
	 */
	if (ls->type == LS_OBJECT) {
	    if (get_obj_location((struct obj *) ls->id, &ls->x, &ls->y, 0))
		ls->flags |= LSF_SHOW;
	} else if (ls->type == LS_MONSTER) {
	    if (get_mon_location((struct monst *) ls->id, &ls->x, &ls->y, 0))
		ls->flags |= LSF_SHOW;
	}

	/* minor optimization: don't bother with duplicate light sources */
	/* at hero */
	if (ls->x == u.ux && ls->y == u.uy) {
	    if (at_hero_range >= ls->range)
		ls->flags &= ~LSF_SHOW;
	    else
		at_hero_range = ls->range;
	}

	if (ls->flags & LSF_SHOW) {
	    /*
	     * Walk the points in the circle and see if they are
	     * visible from the center.  If so, mark'em.
	     *
	     * Kevin's tests indicated that doing this brute-force
	     * method is faster for radius <= 3 (or so).
	     */
	    limits = circle_ptr(ls->range);
	    if ((max_y = (ls->y + ls->range)) >= ROWNO) max_y = ROWNO-1;
	    if ((y = (ls->y - ls->range)) < 0) y = 0;
	    for (; y <= max_y; y++) {
		row = cs_rows[y];
		offset = limits[abs(y - ls->y)];
		if ((min_x = (ls->x - offset)) < 0) min_x = 0;
		if ((max_x = (ls->x + offset)) >= COLNO) max_x = COLNO-1;

		if (ls->x == u.ux && ls->y == u.uy) {
		    /*
		     * If the light source is located at the hero, then
		     * we can use the COULD_SEE bits already calcualted
		     * by the vision system.  More importantly than
		     * this optimization, is that it allows the vision
		     * system to correct problems with clear_path().
		     * The function clear_path() is a simple LOS
		     * path checker that doesn't go out of its way
		     * make things look "correct".  The vision system
		     * does this.
		     */
		    for (x = min_x; x <= max_x; x++)
			if (row[x] & COULD_SEE)
			    row[x] |= TEMP_LIT;
		} else {
		    for (x = min_x; x <= max_x; x++)
			if ((ls->x == x && ls->y == y)
				|| clear_path((int)ls->x, (int) ls->y, x, y))
			    row[x] |= TEMP_LIT;
		}
	    }
	}
    }
}

/* (mon->mx == 0) implies migrating */
#define mon_is_local(mon)	((mon)->mx > 0)

struct monst *
find_mid(nid, fmflags)
unsigned nid;
unsigned fmflags;
{
	struct monst *mtmp;

	if (!nid)
	    return &youmonst;
	if (fmflags & FM_FMON)
		for (mtmp = fmon; mtmp; mtmp = mtmp->nmon)
		    if (!DEADMONSTER(mtmp) && mtmp->m_id == nid) return mtmp;
	if (fmflags & FM_MIGRATE)
		for (mtmp = migrating_mons; mtmp; mtmp = mtmp->nmon)
	    	    if (mtmp->m_id == nid) return mtmp;
	if (fmflags & FM_MYDOGS)
		for (mtmp = mydogs; mtmp; mtmp = mtmp->nmon)
	    	    if (mtmp->m_id == nid) return mtmp;
	return (struct monst *) 0;
}

/* Save all light sources of the given range. */
void
save_light_sources(fd, mode, range)
    int fd, mode, range;
{
    int count, actual, is_global;
    light_source **prev, *curr;

    if (perform_bwrite(mode)) {
	count = maybe_write_ls(fd, range, FALSE);
	bwrite(fd, (genericptr_t) &count, sizeof count);
	actual = maybe_write_ls(fd, range, TRUE);
	if (actual != count)
	    panic("counted %d light sources, wrote %d! [range=%d]",
		  count, actual, range);
    }

    if (release_data(mode)) {
	for (prev = &light_base; (curr = *prev) != 0; ) {
	    if (!curr->id) {
		impossible("save_light_sources: no id! [range=%d]", range);
		is_global = 0;
	    } else
	    switch (curr->type) {
	    case LS_OBJECT:
		is_global = !obj_is_local((struct obj *)curr->id);
		break;
	    case LS_MONSTER:
		is_global = !mon_is_local((struct monst *)curr->id);
		break;
	    default:
		is_global = 0;
		impossible("save_light_sources: bad type (%d) [range=%d]",
			   curr->type, range);
		break;
	    }
	    /* if global and not doing local, or vice versa, remove it */
	    if (is_global ^ (range == RANGE_LEVEL)) {
		*prev = curr->next;
		free((genericptr_t)curr);
	    } else {
		prev = &(*prev)->next;
	    }
	}
    }
}

/*
 * Pull in the structures from disk, but don't recalculate the object
 * pointers.
 */
void
restore_light_sources(fd)
    int fd;
{
    int count;
    light_source *ls;

    /* restore elements */
    mread(fd, (genericptr_t) &count, sizeof count);

    while (count-- > 0) {
	ls = (light_source *) alloc(sizeof(light_source));
	mread(fd, (genericptr_t) ls, sizeof(light_source));
	ls->next = light_base;
	light_base = ls;
    }
}

/* Relink all lights that are so marked. */
void
relink_light_sources(ghostly)
    boolean ghostly;
{
    char which;
    unsigned nid;
    light_source *ls;

    for (ls = light_base; ls; ls = ls->next) {
	if (ls->flags & LSF_NEEDS_FIXUP) {
	    if (ls->type == LS_OBJECT || ls->type == LS_MONSTER) {
		if (ghostly) {
		    if (!lookup_id_mapping((unsigned)ls->id, &nid))
			impossible("relink_light_sources: no id mapping");
		} else
		    nid = (unsigned) ls->id;
		if (ls->type == LS_OBJECT) {
		    which = 'o';
		    ls->id = (genericptr_t) find_oid(nid);
		} else {
		    which = 'm';
		    ls->id = (genericptr_t) find_mid(nid, FM_EVERYWHERE);
		}
		if (!ls->id)
		    impossible("relink_light_sources: cant find %c_id %d",
			       which, nid);
	    } else
		impossible("relink_light_sources: bad type (%d)", ls->type);

	    ls->flags &= ~LSF_NEEDS_FIXUP;
	}
    }
}

/*
 * Part of the light source save routine.  Count up the number of light
 * sources that would be written.  If write_it is true, actually write
 * the light source out.
 */
STATIC_OVL int
maybe_write_ls(fd, range, write_it)
    int fd, range;
    boolean write_it;
{
    int count = 0, is_global;
    light_source *ls;

    for (ls = light_base; ls; ls = ls->next) {
	if (!ls->id) {
	    impossible("maybe_write_ls: no id! [range=%d]", range);
	    continue;
	}
	switch (ls->type) {
	case LS_OBJECT:
	    is_global = !obj_is_local((struct obj *)ls->id);
	    break;
	case LS_MONSTER:
	    is_global = !mon_is_local((struct monst *)ls->id);
	    break;
	default:
	    is_global = 0;
	    impossible("maybe_write_ls: bad type (%d) [range=%d]",
		       ls->type, range);
	    break;
	}
	/* if global and not doing local, or vice versa, count it */
	if (is_global ^ (range == RANGE_LEVEL)) {
	    count++;
	    if (write_it) write_ls(fd, ls);
	}
    }

    return count;
}

/* Write a light source structure to disk. */
STATIC_OVL void
write_ls(fd, ls)
    int fd;
    light_source *ls;
{
    genericptr_t arg_save;
    struct obj *otmp;
    struct monst *mtmp;

    if (ls->type == LS_OBJECT || ls->type == LS_MONSTER) {
	if (ls->flags & LSF_NEEDS_FIXUP)
	    bwrite(fd, (genericptr_t)ls, sizeof(light_source));
	else {
	    /* replace object pointer with id for write, then put back */
	    arg_save = ls->id;
	    if (ls->type == LS_OBJECT) {
		otmp = (struct obj *)ls->id;
		ls->id = (genericptr_t)otmp->o_id;
#ifdef NETHACK_DEBUG
		if (find_oid((unsigned)ls->id) != otmp)
		    panic("write_ls: can't find obj #%u!", (unsigned)ls->id);
#endif
	    } else { /* ls->type == LS_MONSTER */
		mtmp = (struct monst *)ls->id;
		ls->id = (genericptr_t)mtmp->m_id;
#ifdef NETHACK_DEBUG
		if (find_mid((unsigned)ls->id, FM_EVERYWHERE) != mtmp)
		    panic("write_ls: can't find mon #%u!", (unsigned)ls->id);
#endif
	    }
	    ls->flags |= LSF_NEEDS_FIXUP;
	    bwrite(fd, (genericptr_t)ls, sizeof(light_source));
	    ls->id = arg_save;
	    ls->flags &= ~LSF_NEEDS_FIXUP;
	}
    } else {
	impossible("write_ls: bad type (%d)", ls->type);
    }
}

/* Change light source's ID from src to dest. */
void
obj_move_light_source(src, dest)
    struct obj *src, *dest;
{
    light_source *ls;

    for (ls = light_base; ls; ls = ls->next)
	if (ls->type == LS_OBJECT && ls->id == (genericptr_t) src)
	    ls->id = (genericptr_t) dest;
    src->lamplit = 0;
    dest->lamplit = 1;
}

/* return true if there exist any light sources */
boolean
any_light_source()
{
    return light_base != (light_source *) 0;
}

/*
 * Snuff an object light source if at (x,y).  This currently works
 * only for burning light sources.
 */
void
snuff_light_source(x, y)
    int x, y;
{
    light_source *ls;
    struct obj *obj;

    for (ls = light_base; ls; ls = ls->next)
	/*
	Is this position check valid??? Can I assume that the positions
	will always be correct because the objects would have been
	updated with the last vision update?  [Is that recent enough???]
	*/
	if (ls->type == LS_OBJECT && ls->x == x && ls->y == y) {
	    obj = (struct obj *) ls->id;
	    if (obj_is_burning(obj)) {
		/* The only way to snuff Sunsword is to unwield it.  Darkness
		 * scrolls won't affect it.  (If we got here because it was
		 * dropped or thrown inside a monster, this won't matter anyway
		 * because it will go out when dropped.)
		 */
		if (artifact_light(obj)) continue;
		end_burn(obj, obj->otyp != MAGIC_LAMP);
		/*
		 * The current ls element has just been removed (and
		 * ls->next is now invalid).  Return assuming that there
		 * is only one light source attached to each object.
		 */
		return;
	    }
	}
}

/* Return TRUE if object sheds any light at all. */
boolean
obj_sheds_light(obj)
    struct obj *obj;
{
    /* so far, only burning objects shed light */
    return obj_is_burning(obj);
}

/* Return TRUE if sheds light AND will be snuffed by end_burn(). */
boolean
obj_is_burning(obj)
    struct obj *obj;
{
    return (obj->lamplit &&
		(obj->otyp == MAGIC_LAMP || ignitable(obj) || artifact_light(obj)));
}

/* copy the light source(s) attachted to src, and attach it/them to dest */
void
obj_split_light_source(src, dest)
    struct obj *src, *dest;
{
    light_source *ls, *new_ls;

    for (ls = light_base; ls; ls = ls->next)
	if (ls->type == LS_OBJECT && ls->id == (genericptr_t) src) {
	    /*
	     * Insert the new source at beginning of list.  This will
	     * never interfere us walking down the list - we are already
	     * past the insertion point.
	     */
	    new_ls = (light_source *) alloc(sizeof(light_source));
	    *new_ls = *ls;
	    if (Is_candle(src)) {
		/* split candles may emit less light than original group */
		ls->range = candle_light_range(src);
		new_ls->range = candle_light_range(dest);
		vision_full_recalc = 1;	/* in case range changed */
	    }
	    new_ls->id = (genericptr_t) dest;
	    new_ls->next = light_base;
	    light_base = new_ls;
	    dest->lamplit = 1;		/* now an active light source */
	}
}

/* light source `src' has been folded into light source `dest';
   used for merging lit candles and adding candle(s) to lit candelabrum */
void
obj_merge_light_sources(src, dest)
struct obj *src, *dest;
{
    light_source *ls;

    /* src == dest implies adding to candelabrum */
    if (src != dest) end_burn(src, TRUE);		/* extinguish candles */

    for (ls = light_base; ls; ls = ls->next)
	if (ls->type == LS_OBJECT && ls->id == (genericptr_t) dest) {
	    ls->range = candle_light_range(dest);
	    vision_full_recalc = 1;	/* in case range changed */
	    break;
	}
}

/* Candlelight is proportional to the number of candles;
   minimum range is 2 rather than 1 for playability. */
int
candle_light_range(obj)
struct obj *obj;
{
    int radius;

    if (obj->otyp == CANDELABRUM_OF_INVOCATION) {
	/*
	 *	The special candelabrum emits more light than the
	 *	corresponding number of candles would.
	 *	 1..3 candles, range 2 (minimum range);
	 *	 4..6 candles, range 3 (normal lamp range);
	 *	    7 candles, range 4 (bright).
	 */
	radius = (obj->spe < 4) ? 2 : (obj->spe < 7) ? 3 : 4;
    } else if (Is_candle(obj)) {
	/*
	 *	Range is incremented by powers of 7 so that it will take
	 *	wizard mode quantities of candles to get more light than
	 *	from a lamp, without imposing an arbitrary limit.
	 *	 1..6   candles, range 2;
	 *	 7..48  candles, range 3;
	 *	49..342 candles, range 4; &c.
	 */
	long n = obj->quan;

	radius = 1;	/* always incremented at least once */
	do {
	    radius++;
	    n /= 7L;
	} while (n > 0L);
    } else {
	/* we're only called for lit candelabrum or candles */
     /* impossible("candlelight for %d?", obj->otyp); */
	radius = 3;		/* lamp's value */
    }
    return radius;
}

#ifdef WIZARD
extern char *FDECL(fmt_ptr, (const genericptr, char *));  /* from alloc.c */

int
wiz_light_sources()
{
    winid win;
    char buf[BUFSZ], arg_address[20];
    light_source *ls;

    win = create_nhwindow(NHW_MENU);	/* corner text window */
    if (win == WIN_ERR) return 0;

    Sprintf(buf, "Mobile light sources: hero @ (%2d,%2d)", u.ux, u.uy);
    putstr(win, 0, buf);
    putstr(win, 0, "");

    if (light_base) {
	putstr(win, 0, "location range flags  type    id");
	putstr(win, 0, "-------- ----- ------ ----  -------");
	for (ls = light_base; ls; ls = ls->next) {
	    Sprintf(buf, "  %2d,%2d   %2d   0x%04x  %s  %s",
		ls->x, ls->y, ls->range, ls->flags,
		(ls->type == LS_OBJECT ? "obj" :
		 ls->type == LS_MONSTER ?
		    (mon_is_local((struct monst *)ls->id) ? "mon" :
		     ((struct monst *)ls->id == &youmonst) ? "you" :
		     "<m>") :		/* migrating monster */
		 "???"),
		fmt_ptr(ls->id, arg_address));
	    putstr(win, 0, buf);
	}
    } else
	putstr(win, 0, "<none>");

    display_nhwindow(win, FALSE);
    destroy_nhwindow(win);

    return 0;
}

#endif /* WIZARD */

#endif /* OVL3 */

/*light.c*/