text
stringlengths 4
6.14k
|
|---|
/* UIToggleButton.h
*
* Copyright (C) 2011 Belledonne Comunications, Grenoble, France
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#import <UIKit/UIKit.h>
#import "UIIconButton.h"
@protocol UIToggleButtonDelegate
- (void)onOn;
- (void)onOff;
- (bool)onUpdate;
@end
@interface UIToggleButton : UIIconButton <UIToggleButtonDelegate> {
}
#if 0 // Changed Linphone code - Need to call this from UI thread otherwise get exceptions
- (bool)update;
#else
- (void)update;
#endif
- (void)setOn;
- (void)setOff;
- (bool)toggle;
@end
|
/*
* HyFi forwarding database
* QCA HyFi Bridge
*
* Copyright (c) 2012, The Linux Foundation. All rights reserved.
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/rculist.h>
#include <linux/spinlock.h>
#include <linux/etherdevice.h>
#include <mc_private.h>
#include "hyfi_netfilter.h"
#include "hyfi_netlink.h"
#include "hyfi_bridge.h"
#include "hyfi_api.h"
#include "hyfi_fdb.h"
static inline unsigned long hold_time(const struct net_bridge *br)
{
return br->topology_change ? br->forward_delay : br->ageing_time;
}
static inline int has_expired(const struct net_bridge *br,
const struct net_bridge_fdb_entry *fdb)
{
return !fdb->is_static
&& time_before_eq(hyfi_updated_time_get(fdb) + hold_time( br ), jiffies );
}
/*
* Fill buffer with forwarding table records in
* the API format.
*/
int hyfi_fdb_fillbuf(struct net_bridge *br, void *buf, u_int32_t buf_len,
u_int32_t skip, u_int32_t *bytes_written, u_int32_t *bytes_needed)
{
struct __hfdb_entry *fe = buf;
u_int32_t i, total = 0, num = 0, num_entries;
int ret = 0;
struct hlist_node *h;
struct net_bridge_fdb_entry *f;
memset(buf, 0, buf_len);
num_entries = buf_len / sizeof(struct __hfdb_entry);
rcu_read_lock();
for (i = 0; i < BR_HASH_SIZE; i++) {
os_hlist_for_each_entry_rcu(f, h, &br->hash[i], hlist) {
if (has_expired(br, f))
continue;
total++;
if (num >= num_entries) {
ret = -EAGAIN;
continue;
}
/* Ignore any local entries that do not have a valid
* port
*/
if (!f->dst)
continue;
if (skip) {
skip--;
continue;
}
/* convert from internal format to API */
memcpy(fe->mac_addr, f->addr.addr, ETH_ALEN);
/* due to ABI compat need to split into hi/lo */
fe->ifindex = f->dst->dev->ifindex & 0xff;
fe->ifindex_hi = (f->dst->dev->ifindex >> 8) & 0xff;
fe->is_local = f->is_local;
if (!f->is_static)
fe->ageing_timer_value = jiffies_to_clock_t(
jiffies - hyfi_updated_time_get(f));
++fe;
++num;
}
}
rcu_read_unlock();
if (bytes_written)
*bytes_written = num * sizeof(struct __hfdb_entry);
if (bytes_needed) {
if (ret == -EAGAIN)
*bytes_needed = total * sizeof(struct __hfdb_entry);
else
*bytes_needed = 0;
}
return ret;
}
|
/*
* SocialLedge.com - Copyright (C) 2013
*
* This file is part of free software framework for embedded processors.
* You can use it and/or distribute it as long as this copyright header
* remains unmodified. The code is free for personal use and requires
* permission to use in a commercial product.
*
* THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
* OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
* I SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
* CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
*
* You can reach the author of this software at :
* p r e e t . w i k i @ g m a i l . c o m
*/
/**
* @file
* @ingroup Drivers
*/
#ifndef SPI1_H_
#define SPI1_H_
#ifdef __cplusplus
extern "C" {
#endif
#include "LPC17xx.h"
#include "base/ssp_prv.h"
/**
* Initializes SPI 1
* Configures CLK, MISO, MOSI pins with a slow SCK speed
*/
static inline void ssp1_init(void)
{
lpc_pconp(pconp_ssp1, true);
lpc_pclk(pclk_ssp1, clkdiv_1);
ssp_init(LPC_SSP1);
void ssp1_dma_init();
ssp1_dma_init();
}
/**
* Sets SPI Clock speed
* @param max_clock_mhz The maximum speed of this SPI in Megahertz
* @note The speed may be set lower to max_clock_mhz if it cannot be attained.
*/
static inline void ssp1_set_max_clock(unsigned int max_clock_mhz)
{
ssp_set_max_clock(LPC_SSP1, max_clock_mhz);
}
/**
* Exchanges a byte over SPI bus
* @param out The byte to send out
* @returns The byte received over SPI
*/
static inline char ssp1_exchange_byte(char out)
{
return ssp_exchange_byte(LPC_SSP1, out);
}
/**
* Writes a byte to the SPI FIFO
* @warning YOU MUST ENSURE SPI IS NOT BUSY before calling this function
*/
static inline void ssp1_exchange_data(void* data, int len)
{
ssp_exchange_data(LPC_SSP1, data, len);
}
/**
* Transfers data over SPI (SSP#1)
* @param pBuffer The read or write buffer
* @param num_bytes The length of the transfer in bytes
* @param is_write_op Non-zero for Write-operation, zero for read operation
*
* @note If is_write_op is true:
* - SPI data is sent from pBuffer
* - SPI data is copied from SSP DR to dummy buffer and discarded
* If is_write_op is false (read operation) :
* - SPI data is copied from SSP DR to pBuffer
* - 0xFF is sent out for each byte transfered
*
* @return 0 upon success, or non-zero upon failure.
*/
unsigned ssp1_dma_transfer_block(unsigned char* pBuffer, uint32_t num_bytes, char is_write_op);
#ifdef __cplusplus
}
#endif
#endif /* SPI1_H_ */
|
#ifndef GRAPHICS_SHADERPROGRAM_H
#define GRAPHICS_SHADERPROGRAM_H
#include <panda/core.h>
#include <memory>
#include <string>
#include <vector>
namespace panda
{
namespace graphics
{
enum class ShaderType : char
{ Vertex = 1, Fragment, Geometry, TessellationControl, TessellationEvaluation, Compute };
// To free the shader only when every copy is destroyed
class PANDA_CORE_API ShaderId
{
public:
using SPtr = std::shared_ptr<ShaderId>;
ShaderId(ShaderType type, unsigned int id);
~ShaderId();
unsigned int id() const;
ShaderType type() const;
private:
unsigned int m_id;
ShaderType m_type;
};
// To free the shader program only when every copy is destroyed
class PANDA_CORE_API ShaderProgramId
{
public:
using SPtr = std::shared_ptr<ShaderProgramId>;
ShaderProgramId(unsigned int id = 0);
~ShaderProgramId();
unsigned int id() const;
private:
unsigned int m_id;
};
//****************************************************************************//
class PANDA_CORE_API ShaderProgram
{
public:
ShaderProgram(ShaderProgramId::SPtr id = nullptr);
bool addShaderFromMemory(ShaderType type, const std::string& content);
bool addShaderFromFile(ShaderType type, const std::string& path);
void addShader(ShaderId::SPtr id);
static ShaderId::SPtr compileShader(ShaderType type, const std::string& content, std::string* errorString = nullptr);
bool link(std::string* errorString = nullptr);
bool isLinked();
void clear(); // Remove shaders
unsigned int id() const;
ShaderProgramId::SPtr getProgramId() const;
void bind() const;
void release() const;
int uniformLocation(const char* name) const;
void setUniformValue(int location, int value) const;
void setUniformValue(int location, float value) const;
void setUniformValue(int location, const std::vector<int>& value) const;
void setUniformValue(int location, const std::vector<float>& value) const;
void setUniformValueArray(int location, const float* values, int count, int tupleSize) const;
void setUniformValueMat4(int location, const float* value) const;
void setUniformValue(const char* name, int value) const;
void setUniformValue(const char* name, float value) const;
void setUniformValue(const char* name, const std::vector<int>& value) const;
void setUniformValue(const char* name, const std::vector<float>& value) const;
void setUniformValueArray(const char* name, const float* values, int count, int tupleSize) const;
void setUniformValueMat4(const char* name, const float* value) const;
int attributeLocation(const char* name) const;
protected:
std::vector<ShaderId::SPtr> m_shaders;
ShaderProgramId::SPtr m_programId;
};
//****************************************************************************//
inline ShaderId::ShaderId(ShaderType type, unsigned int id)
: m_type(type), m_id(id) {}
inline unsigned int ShaderId::id() const
{ return m_id; }
inline ShaderType ShaderId::type() const
{ return m_type; }
//****************************************************************************//
inline ShaderProgramId::ShaderProgramId(unsigned int id)
: m_id(id) {}
inline unsigned int ShaderProgramId::id() const
{ return m_id; }
//****************************************************************************//
inline ShaderProgram::ShaderProgram(ShaderProgramId::SPtr id)
: m_programId(id) {}
inline ShaderProgramId::SPtr ShaderProgram::getProgramId() const
{ return m_programId; }
inline bool ShaderProgram::isLinked()
{ return m_programId != nullptr; }
inline unsigned int ShaderProgram::id() const
{ return m_programId ? m_programId->id() : 0; }
} // namespace graphics
} // namespace panda
#endif // GRAPHICS_SHADERPROGRAM_H
|
#include "I2C_Driver.h"
/********************************************************/
void I2C_delay(void)
{
uint8_t i=20;
while(i)
{
i--;
}
}
static void Delay_N_mS(uint16_t n_milisecond) /* n mS delay */
{
uint8_t i;
while (n_milisecond--)
{
i=37;
while (i--);
}
}
bool I2C_Start(void)
{
SDA_H;
SCL_H;
I2C_delay();
if(!SDA_read)
return FALSE; //SDAÏßΪµÍµçƽÔò×ÜÏßæ,Í˳ö
SDA_L;
I2C_delay();
if(SDA_read)
return FALSE; //SDAÏßΪ¸ßµçƽÔò×ÜÏß³ö´í,Í˳ö
SDA_L;
I2C_delay();
return TRUE;
}
void I2C_Stop(void)
{
SCL_L;
I2C_delay();
SDA_L;
I2C_delay();
SCL_H;
I2C_delay();
SDA_H;
I2C_delay();
}
void I2C_Ack(void)
{
SCL_L;
I2C_delay();
SDA_L;
I2C_delay();
SCL_H;
I2C_delay();
SCL_L;
I2C_delay();
}
void I2C_NoAck(void)
{
SCL_L;
I2C_delay();
SDA_H;
I2C_delay();
SCL_H;
I2C_delay();
SCL_L;
I2C_delay();
}
bool I2C_WaitAck(void) //·µ»ØÎª:=1ÓÐACK,=0ÎÞACK
{
SCL_L;
I2C_delay();
SDA_H;
I2C_delay();
SCL_H;
I2C_delay();
if(SDA_read)
{
SCL_L;
return FALSE;
}
SCL_L;
return TRUE;
}
void I2C_SendByte(uint8_t SendByte) //Êý¾Ý´Ó¸ßλµ½µÍλ//
{
uint8_t i=8;
while(i--)
{
SCL_L;
I2C_delay();
if(SendByte&0x80)
SDA_H;
else
SDA_L;
SendByte<<=1;
I2C_delay();
SCL_H;
I2C_delay();
}
SCL_L;
}
uint8_t I2C_ReceiveByte(void) //Êý¾Ý´Ó¸ßλµ½µÍλ//
{
uint8_t i=8;
uint8_t ReceiveByte=0;
SDA_H;
while(i--)
{
ReceiveByte<<=1;
SCL_L;
I2C_delay();
SCL_H;
I2C_delay();
if(SDA_read)
{
ReceiveByte|=0x01;
}
}
SCL_L;
return ReceiveByte;
}
//дÈë1×Ö½ÚÊý¾Ý ´ýдÈëÊý¾Ý ´ýдÈëµØÖ·
bool I2C_WriteByte(uint8_t WriteAddress, uint8_t SendByte)
{
if(!I2C_Start())
return FALSE;
I2C_SendByte(Write_Pcf8563_address);//ÉèÖÃÆ÷¼þµØÖ·
if(!I2C_WaitAck())
{
I2C_Stop();
return FALSE;
}
I2C_SendByte(WriteAddress); //ÉèÖõØÖ·
I2C_WaitAck();
I2C_SendByte(SendByte);
I2C_WaitAck();
I2C_Stop();
//×¢Ò⣺ÒòΪÕâÀïÒªµÈ´ýEEPROMдÍ꣬¿ÉÒÔ²ÉÓòéѯ»òÑÓʱ·½Ê½
Delay_N_mS(200);
return TRUE;
}
//¶Á³ö1´®Êý¾Ý ´æ·Å¶Á³öÊý¾Ý ´ý¶Á³ö³¤¶È
uint8_t I2C_ReadByte(uint8_t ReadAddress)
{
uint8_t temp;
if(!I2C_Start())
return FALSE;
I2C_SendByte(Write_Pcf8563_address); //ÉèÖÃÆ÷¼þдµØÖ·
if(!I2C_WaitAck())
{
I2C_Stop();
return FALSE;
}
I2C_SendByte(ReadAddress); //ÉèÖõØÖ·
I2C_WaitAck();
if(!I2C_Start())
return FALSE;
I2C_SendByte(Read_Pcf8563_address); //ÉèÖÃÆ÷¼þ¶ÁµØÖ·
if(!I2C_WaitAck())
{
I2C_Stop();
return FALSE;
}
temp = I2C_ReceiveByte();
I2C_Stop();
return temp;
}
void rtc_SetTime(unsigned char year, unsigned char month, unsigned char day, unsigned char hour, unsigned char mint, unsigned char second)
{
I2C_WriteByte(0x00, 0x20); //Í£Ö¹RTC
I2C_WriteByte(0x01, 0x00);
I2C_WriteByte(Addr_second, second);
I2C_WriteByte(Addr_mint, mint);
I2C_WriteByte(Addr_hour, hour);
I2C_WriteByte(Addr_day, day);
I2C_WriteByte(Addr_month, month);
I2C_WriteByte(Addr_year, year);
I2C_WriteByte(0x00, 0x00); //Æô¶¯RTC
return;
}
uint8_t tmp;
TIME rtc_GetTimer(void)
{
TIME getTIME;
tmp = I2C_ReadByte(Addr_second);
tmp &= 0x7f;
tmp =(tmp/16)*10+tmp%16;
getTIME.second = tmp;
tmp = I2C_ReadByte(Addr_mint)&0x7f;
tmp =(tmp/16)*10+tmp%16;
getTIME.mint = tmp;
tmp = I2C_ReadByte(Addr_hour)&0x3f;
tmp =(tmp/16)*10+tmp%16;
getTIME.hour = tmp;
tmp = I2C_ReadByte(Addr_day)&0x3f;
tmp =(tmp/16)*10+tmp%16;
getTIME.day = tmp;
tmp = I2C_ReadByte(Addr_month)&0x1f;
tmp =(tmp/16)*10+tmp%16;
getTIME.month = tmp;
tmp = I2C_ReadByte(Addr_year)&0x1f;
tmp =(tmp/16)*10+tmp%16;
getTIME.year = tmp;
return getTIME;
}
|
/*
* Copyright (C) 2011-2021 Project SkyFire <https://www.projectskyfire.org/>
* Copyright (C) 2008-2021 TrinityCore <http://www.trinitycore.org/>
* Copyright (C) 2005-2021 MaNGOS <https://www.getmangos.eu/>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SKYFIRESERVER_ERRORS_H
#define SKYFIRESERVER_ERRORS_H
#include "Define.h"
namespace Skyfire
{
DECLSPEC_NORETURN void Assert(char const* file, int line, char const* function, char const* message) ATTR_NORETURN;
DECLSPEC_NORETURN void Fatal(char const* file, int line, char const* function, char const* message) ATTR_NORETURN;
DECLSPEC_NORETURN void Error(char const* file, int line, char const* function, char const* message) ATTR_NORETURN;
void Warning(char const* file, int line, char const* function, char const* message);
} // namespace Skyfire
#define WPAssert(cond) do { if (!(cond)) Skyfire::Assert(__FILE__, __LINE__, __FUNCTION__, #cond); } while (0)
#define WPFatal(cond, msg) do { if (!(cond)) Skyfire::Fatal(__FILE__, __LINE__, __FUNCTION__, (msg)); } while (0)
#define WPError(cond, msg) do { if (!(cond)) Skyfire::Error(__FILE__, __LINE__, __FUNCTION__, (msg)); } while (0)
#define WPWarning(cond, msg) do { if (!(cond)) Skyfire::Warning(__FILE__, __LINE__, __FUNCTION__, (msg)); } while (0)
#define ASSERT WPAssert
#endif
|
/*************************************************************************
> File Name: hash.c
> Author: likeyi
> Mail: likeyi@sina.com
> Created Time: Tue 17 Jun 2014 04:36:47 PM CST
************************************************************************/
#include "includes.h"
extern int global_trace;
static int next_prime(int x)
{
long i, j;
int f;
x = (x==0)?1:x;
i = x;
while (i++)
{
f=1;
for (j=2; j<i; j++)
{
if (i%j == 0)
{
f=0;
break;
}
}
if (f)
{
return (int)i;
}
}
return 0;
}
struct blist * find_list(struct list_head * head,
void * item,
compare * compare_handler)
{
struct list_head * p;
struct blist * node;
list_for_each(p,head)
{
node = list_entry(p,struct blist,listhead);
if(compare_handler(node->item, item) == 0)
{
return node->item;
}
}
return NULL;
}
/*
* 1. 创建
* */
hash_table * hash_create(int num,ht_ops_t * ops)
{
exit_if_ptr_is_null(ops,"ht ops is null");
hash_table * result;
bucket_t * b;
int bytes;
int i;
result = malloc(sizeof(hash_table));
exit_if_ptr_is_null(result,"Initizial hash table Error");
num = next_prime(num);
bytes = num * sizeof(bucket_t);
result->buckets = b = malloc(bytes);
exit_if_ptr_is_null(result->buckets,"hash table buckets alloc error");
result->ops = malloc(sizeof(ht_ops_t));
exit_if_ptr_is_null(result->ops,"hash ops alloc error");
memcpy(result->ops,ops,sizeof(ht_ops_t));
result->num_buckets = num;
i = num;
while(--i >= 0)
{
INIT_LIST_HEAD(&b->list);
pthread_mutex_init(&b->lock, NULL);
b->count = 0;
b++;
}
return result;
}
/*
* 2. 查找
* 查找的本质是,给出一组特性
* hash_lookup把特性编程key,然后再把比较特性。
* */
void * hash_lookup_item(hash_table * ht,
uint32_t key,
void * value)
{
struct list_head * ll;
bucket_t * bucket = &ht -> buckets[key % ht->num_buckets];
ll = &bucket->list;
compare * compare_handler = ht->ops->compare_handler;
if(compare_handler == NULL)
{
TRACE(LOG_FAULT,"compare_handler can not be NULL\n");
exit(0);
}
return (void *) find_list(ll,value,compare_handler);
}
/*
* 3. 插入
* 严格说来,blist 完全没有任何问题。
* */
int hash_add_item(hash_table ** htp, uint32_t key, void * value )
{
struct list_head * ll;
struct blist * blist;
struct blist * new_blist;
hash_table * ht = *htp;
void * item = (void *)value;
//manager_t * manager = list_entry(htp,manager_t,ht);
/*
*
* */
bucket_t * bucket = &ht -> buckets[key % ht->num_buckets];
pthread_mutex_lock(&bucket->lock);
ll = &bucket->list;
compare * compare_handler = ht->ops->compare_handler;
if(compare_handler == NULL)
{
TRACE(LOG_FAULT,"compare_handler can not be NULL\n");
exit(0);
}
blist = find_list(ll,item,compare_handler);
/*
* 假如不存在于链表中。
* */
if(!blist)
{
/*
* 初始化,并且添加到新建的列表里。
* */
if(ht->ops->new_handler)
{
ht->ops->new_handler(&new_blist,value);
INIT_LIST_HEAD(&new_blist->listhead);
list_add_tail(&new_blist->listhead,ll);
++bucket->count;
}
else
{
TRACE(LOG_WARN,"make_new should not be NULL");
}
}
/*
* Found it, and memcpy it.
* 主要是这一段无法公共化,其他的hash函数可能找到后,并不会copy
* */
else
{
TRACE(LOG_INFO,"existed_handler:%p\n",ht->ops->existed_handler);
if(ht->ops->existed_handler)
{
ht->ops->existed_handler(blist,value);
}
}
pthread_mutex_unlock(&bucket->lock);
return 0;
}
/*
* 4. 遍历
* */
void hash_travel_delete(hash_table * ht)
{
register int i = 0;
register bucket_t * bucket;
delete * delete_item = ht->ops->delete_handler;
bucket = ht->buckets;
while(i++ < ht->num_buckets)
{
pthread_mutex_lock(&bucket->lock);
if(delete_item == NULL)
{
TRACE(LOG_WARN,"delete_item is null\n");
}
else
{
delete_item(bucket);
}
pthread_mutex_unlock(&bucket->lock);
bucket++;
}
}
void hash_travel_viewer(hash_table * ht)
{
register int i = 0;
register bucket_t * bucket;
viewer * viewer_handler = ht->ops->viewer_handler;
bucket = ht->buckets;
while(i++ < ht->num_buckets)
{
pthread_mutex_lock(&bucket->lock);
if(viewer_handler == NULL)
{
TRACE(LOG_WARN,"viewer handler is null\n");
}
else
{
viewer_handler(bucket);
}
pthread_mutex_unlock(&bucket->lock);
bucket++;
}
}
/*
* unsigned int hash_count(hash_table *ht)
*
* Return total number of elements contained in hash table.
*/
uint32_t hash_count(hash_table * ht)
{
register int i = 0;
register int cnt = 0;
register bucket_t *bucket;
bucket = ht->buckets;
while (i++ < ht->num_buckets)
{
cnt += bucket->count;
bucket++;
}
return cnt;
}
|
/*
* ak4678.h - ASoC codec driver for AK4678
*
* Copyright 2012, AsahiKASEI Co., Ltd.
* Copyright 2012, Insignal Co., Ltd.
* Author: Claude Youn <claude@insignal.co.kr>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
*/
#ifndef __AK4678_H__
#define __AK4678_H__
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/platform_device.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <sound/soc.h>
#ifndef SND_SOC_DAIFMT_SFS
# define SND_SOC_DAIFMT_SFS 7
# define SND_SOC_DAIFMT_LFS 8
#endif
struct ak4678_priv {
struct snd_soc_codec *codec;
struct snd_soc_dai *codec_dai;
int num_of_dai;
struct snd_soc_codec_driver *codec_driver;
};
int ak4678_hookup_probe(struct device *dev);
#endif
|
#ifndef CASEFOLDCOMPARE_H
#define CASEFOLDCOMPARE_H
struct casefoldCompare : public std::binary_function<Glib::ustring, Glib::ustring, bool> {
bool operator () ( const Glib::ustring &lhs, const Glib::ustring &rhs ) const {
return lhs.casefold() < rhs.casefold();
}
};
#endif
|
//-----------------------------------------------------------------------------
// File: ConfigurableElementColumns.h
//-----------------------------------------------------------------------------
// Project: Kactus2
// Author: Mikko Teuho
// Date: 30.01.2015
//
// Description:
// Common declarations for editing configurable element values.
//-----------------------------------------------------------------------------
namespace ConfigurableElementsColumns
{
//-----------------------------------------------------------------------------
// Constants defining which column represents what kind of information.
//-----------------------------------------------------------------------------
enum Columns
{
NAME, //!< Column for the name of the configurable element.
VALUE, //!< Column for the configurable value.
DEFAULT_VALUE, //!< Column for the original value of the parameter.
CHOICE, //!< Column for the selected choice of the parameter.
ARRAY_LEFT, //!< Column for the left side of the parameters array.
ARRAY_RIGHT, //!< Column for the right side of the parameters array.
TYPE, //!< Column for the type of the parameter.
COLUMN_COUNT
};
}
|
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <pthread.h>
//Functions to be ran on thread: pth
void *testFunction(){
int i;
for(i=0;i<10;i++){
sleep(1);
printf("Test1 Loop %d\n", i);
}
}
//Functions to be ran on thread: pth1
void *testFunction1(){
int i;
for(i=0;i<10;i++){
sleep(1);
printf("Test2 Loop %d\n", i);
}
}
int main(){
//Define threads
pthread_t pth, pth1;
//Create thread -> Start thread
//If the function is not void, then the create function would return a value
// depends on the type of the function
pthread_create(&pth, NULL, testFunction, NULL);
pthread_create(&pth1, NULL, testFunction1, NULL);
//Thread join here, afterward return values can be fetched.
pthread_join(pth, NULL);
pthread_join(pth1, NULL);
//Continues
return 0;
}
|
/*
* BRLTTY - A background process providing access to the console screen (when in
* text mode) for a blind person using a refreshable braille display.
*
* Copyright (C) 1995-2013 by The BRLTTY Developers.
*
* BRLTTY comes with ABSOLUTELY NO WARRANTY.
*
* This is free software, placed under the terms of the
* GNU General Public License, as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any
* later version. Please see the file LICENSE-GPL for details.
*
* Web Page: http://mielke.cc/brltty/
*
* This software is maintained by Dave Mielke <dave@mielke.cc>.
*/
/* Virtual/braille.h - Configurable definitions for the Virtual driver
*
* Edit as necessary for your system.
*/
#define VR_DEFAULT_SOCKET "127.0.0.1"
#define VR_DEFAULT_PORT 35752
|
/*
* LFDD - Linux Firmware Debug Driver
* File: libio.c
*
* Copyright (C) 2006 - 2010 Merck Hung <merckhung@gmail.com>
*
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and
* may be copied, distributed, and modified under those terms.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#include <linux/module.h>
#include <linux/init.h>
#include <linux/errno.h>
#include <linux/miscdevice.h>
#include <linux/fcntl.h>
#include <linux/proc_fs.h>
#include <linux/delay.h>
#include <asm/io.h>
#include <asm/irq.h>
#include <asm/uaccess.h>
#include <linux/version.h>
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 4, 0)
#include <asm/system.h>
#endif
#include <linux/highmem.h>
#include "lfdd.h"
extern spinlock_t lfdd_lock;
unsigned char lfdd_io_read_byte( unsigned int addr ) {
unsigned long flags;
unsigned char value;
spin_lock_irqsave( &lfdd_lock, flags );
value = inb( addr );
spin_unlock_irqrestore( &lfdd_lock, flags );
return value;
}
unsigned short lfdd_io_read_word( unsigned int addr ) {
unsigned long flags;
unsigned short value;
spin_lock_irqsave( &lfdd_lock, flags );
value = inw( addr );
spin_unlock_irqrestore( &lfdd_lock, flags );
return value;
}
unsigned int lfdd_io_read_dword( unsigned int addr ) {
unsigned long flags;
unsigned int value;
spin_lock_irqsave( &lfdd_lock, flags );
value = inl( addr );
spin_unlock_irqrestore( &lfdd_lock, flags );
return value;
}
void lfdd_io_write_byte( unsigned char value, unsigned int addr ) {
unsigned long flags;
spin_lock_irqsave( &lfdd_lock, flags );
outb( value, addr );
spin_unlock_irqrestore( &lfdd_lock, flags );
}
void lfdd_io_write_word( unsigned short value, unsigned int addr ) {
unsigned long flags;
spin_lock_irqsave( &lfdd_lock, flags );
outw( value, addr );
spin_unlock_irqrestore( &lfdd_lock, flags );
}
void lfdd_io_write_dword( unsigned int value, unsigned int addr ) {
unsigned long flags;
spin_lock_irqsave( &lfdd_lock, flags );
outl( value, addr );
spin_unlock_irqrestore( &lfdd_lock, flags );
}
void lfdd_io_read_256byte( struct lfdd_io_t *pio ) {
int i;
unsigned long flags;
spin_lock_irqsave( &lfdd_lock, flags );
for( i = 0 ; i < LFDD_MASSBUF_SIZE ; i++ ) {
pio->mass_buf[ i ] = inb( pio->addr + i );
}
spin_unlock_irqrestore( &lfdd_lock, flags );
}
|
/*************************************************************************
* password functions
*************************************************************************/
#include <errno.h>
#include <nss.h>
#include <pwd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "exfiles-util-pwd.h"
#include "config.h"
/*
* Utility for allocating memory for items in struct passwd based on string
* array from strsplit.
*/
int
exfiles_alloc_passwd_from_pw_entry(struct passwd *pwbuf, char **pw_entry)
{
/* Allocate storage for each string */
pwbuf->pw_name = malloc(sizeof(char) *(strlen(pw_entry[0])+1));
pwbuf->pw_passwd = malloc(sizeof(char) *(strlen(pw_entry[1])+1));
pwbuf->pw_gecos = malloc(sizeof(char) *(strlen(pw_entry[4])+1));
pwbuf->pw_dir = malloc(sizeof(char) *(strlen(pw_entry[5])+1));
pwbuf->pw_shell = malloc(sizeof(char) *(strlen(pw_entry[6])+1));
if ( pwbuf->pw_name == NULL
|| pwbuf->pw_passwd == NULL
|| pwbuf->pw_gecos == NULL
|| pwbuf->pw_dir == NULL
|| pwbuf->pw_shell == NULL
)
return -1;
return 0;
}
/*
* Utility to handle copying items from the pw_entry array into the struct
* passwd. Note that it should also be possible to simply update the struct
* passwd pointers. Consider that for future optimization.
*/
int
exfiles_copy_passwd_from_pw_entry(struct passwd *pwbuf, char **pw_entry)
{
int tmplen = 0; /* temp var for length of each string */
/* Copy username */
tmplen = strlen(pw_entry[0]);
strncpy(pwbuf->pw_name, pw_entry[0], tmplen+1);
/* FIXME Why did I put this in? */
if (tmplen != strlen(pw_entry[0]))
return -1;
/* Copy password */
tmplen = strlen(pw_entry[1]);
strncpy(pwbuf->pw_passwd, pw_entry[1], tmplen+1);
if (tmplen != strlen(pw_entry[1]))
return -1;
/* Copy and convert to int UID and GID */
pwbuf->pw_uid = (uid_t)atoi(pw_entry[2]);
pwbuf->pw_gid = (gid_t)atoi(pw_entry[3]);
/* Copy GECOS field */
tmplen = strlen(pw_entry[4]);
strncpy(pwbuf->pw_gecos, pw_entry[4], tmplen+1);
if (tmplen != strlen(pw_entry[4]))
return -1;
/* Copy home directory */
tmplen = strlen(pw_entry[5]);
strncpy(pwbuf->pw_dir, pw_entry[5], tmplen+1);
if (tmplen != strlen(pw_entry[5]))
return -1;
/* Copy Shell */
tmplen = strlen(pw_entry[6]);
strncpy(pwbuf->pw_shell, pw_entry[6], tmplen+1);
if (tmplen != strlen(pw_entry[6]))
return -1;
return 0;
}
/*
* Utility for destroying the contents of a struct passwd.
*/
void
exfiles_passwd_destroy(struct passwd *pwbuf)
{
if ( NULL != pwbuf ) {
if ( NULL != pwbuf->pw_shell ) {
free(pwbuf->pw_shell);
pwbuf->pw_shell = NULL;
}
if ( NULL != pwbuf->pw_dir ) {
free(pwbuf->pw_dir);
pwbuf->pw_dir = NULL;
}
if ( NULL != pwbuf->pw_gecos ) {
free(pwbuf->pw_gecos);
pwbuf->pw_gecos = NULL;
}
if ( NULL != pwbuf->pw_passwd ) {
free(pwbuf->pw_passwd);
pwbuf->pw_passwd = NULL;
}
if ( NULL != pwbuf->pw_name ) {
free(pwbuf->pw_name);
pwbuf->pw_name = NULL;
}
/* This often wraps around and results in a large int that is
* usually treated as "nobody"; rather of an arbitrary thing to do,
* but it at least is better than defaulting to root's ID (0) */
pwbuf->pw_uid = (uid_t) -1;
pwbuf->pw_gid = (gid_t) -1;
}
}
/*
* User-friendly print of passwd struct contents.
*/
int
pretty_print_passwd_struct(FILE *outstream, const struct passwd *pwbuf)
{
return fprintf(outstream,
"Username: '%s'\n"
"Password: '%s'\n"
"UID: '%d'\n"
"GID: '%d'\n"
"GECOS: '%s'\n"
"Home dir: '%s'\n"
"Shell: '%s'\n",
pwbuf->pw_name,
pwbuf->pw_passwd,
(int)pwbuf->pw_uid,
(int)pwbuf->pw_gid,
pwbuf->pw_gecos,
pwbuf->pw_dir,
pwbuf->pw_shell
);
}
/*
* passwd file-like output
*/
int
print_passwd_struct(FILE *outstream, const struct passwd *pwbuf)
{
return fprintf(outstream,
"%s:%s:%d:%d:%s:%s:%s\n",
pwbuf->pw_name,
pwbuf->pw_passwd,
(int)pwbuf->pw_uid,
(int)pwbuf->pw_gid,
pwbuf->pw_gecos,
pwbuf->pw_dir,
pwbuf->pw_shell);
}
/*
* Deep compare of passwd structures. There really isn't a necessarily
* logical way to order them and we really need this for tests, so just return
* true or false. (erm, 1 or 0)
*/
int
exfiles_passwd_cmp(const struct passwd *pwbuf1, const struct passwd *pwbuf2)
{
return
(0 == strcmp(pwbuf1->pw_name, pwbuf2->pw_name) )
&& (0 == strcmp(pwbuf1->pw_passwd, pwbuf2->pw_passwd) )
&& (0 == strcmp(pwbuf1->pw_gecos, pwbuf2->pw_gecos) )
&& (0 == strcmp(pwbuf1->pw_dir, pwbuf2->pw_dir) )
&& (0 == strcmp(pwbuf1->pw_shell, pwbuf2->pw_shell) )
&& (pwbuf1->pw_uid == pwbuf2->pw_uid)
&& (pwbuf1->pw_gid == pwbuf2->pw_gid)
;
}
|
/*
* Copyright (C) 2010, 2012-2014 ARM Limited. All rights reserved.
*
* This program is free software and is provided to you under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
*
* A copy of the licence is included with the program, and can also be obtained from Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/**
* @file mali_osk_irq.c
* Implementation of the OS abstraction layer for the kernel device driver
*/
#include <linux/slab.h> /* For memory allocation */
#include <linux/interrupt.h>
#include <linux/wait.h>
#include <linux/sched.h>
#include "mali_osk.h"
#include "mali_kernel_common.h"
typedef struct _mali_osk_irq_t_struct {
u32 irqnum;
void *data;
_mali_osk_irq_uhandler_t uhandler;
} mali_osk_irq_object_t;
typedef irqreturn_t (*irq_handler_func_t)(int, void *, struct pt_regs *);
static irqreturn_t irq_handler_upper_half (int port_name, void* dev_id ); /* , struct pt_regs *regs*/
#if defined(DEBUG)
#if 0
struct test_interrupt_data {
_mali_osk_irq_ack_t ack_func;
void *probe_data;
mali_bool interrupt_received;
wait_queue_head_t wq;
};
static irqreturn_t test_interrupt_upper_half(int port_name, void *dev_id)
{
irqreturn_t ret = IRQ_NONE;
struct test_interrupt_data *data = (struct test_interrupt_data *)dev_id;
if (_MALI_OSK_ERR_OK == data->ack_func(data->probe_data)) {
data->interrupt_received = MALI_TRUE;
wake_up(&data->wq);
ret = IRQ_HANDLED;
}
return ret;
}
static _mali_osk_errcode_t test_interrupt(u32 irqnum,
_mali_osk_irq_trigger_t trigger_func,
_mali_osk_irq_ack_t ack_func,
void *probe_data,
const char *description)
{
unsigned long irq_flags = 0;
struct test_interrupt_data data = {
.ack_func = ack_func,
.probe_data = probe_data,
.interrupt_received = MALI_FALSE,
};
#if defined(CONFIG_MALI_SHARED_INTERRUPTS)
irq_flags |= IRQF_SHARED;
#endif /* defined(CONFIG_MALI_SHARED_INTERRUPTS) */
if (0 != request_irq(irqnum, test_interrupt_upper_half, irq_flags, description, &data)) {
MALI_DEBUG_PRINT(2, ("Unable to install test IRQ handler for core '%s'\n", description));
return _MALI_OSK_ERR_FAULT;
}
init_waitqueue_head(&data.wq);
trigger_func(probe_data);
wait_event_timeout(data.wq, data.interrupt_received, 100);
free_irq(irqnum, &data);
if (data.interrupt_received) {
MALI_DEBUG_PRINT(3, ("%s: Interrupt test OK\n", description));
return _MALI_OSK_ERR_OK;
} else {
MALI_PRINT_ERROR(("%s: Failed interrupt test on %u\n", description, irqnum));
return _MALI_OSK_ERR_FAULT;
}
}
#endif
#endif /* defined(DEBUG) */
_mali_osk_irq_t *_mali_osk_irq_init( u32 irqnum, _mali_osk_irq_uhandler_t uhandler, void *int_data, _mali_osk_irq_trigger_t trigger_func, _mali_osk_irq_ack_t ack_func, void *probe_data, const char *description )
{
mali_osk_irq_object_t *irq_object;
unsigned long irq_flags = 0;
#if defined(CONFIG_MALI_SHARED_INTERRUPTS)
irq_flags |= IRQF_SHARED;
#endif /* defined(CONFIG_MALI_SHARED_INTERRUPTS) */
irq_object = kmalloc(sizeof(mali_osk_irq_object_t), GFP_KERNEL);
if (NULL == irq_object) {
return NULL;
}
if (-1 == irqnum) {
/* Probe for IRQ */
if ( (NULL != trigger_func) && (NULL != ack_func) ) {
unsigned long probe_count = 3;
_mali_osk_errcode_t err;
int irq;
MALI_DEBUG_PRINT(2, ("Probing for irq\n"));
do {
unsigned long mask;
mask = probe_irq_on();
trigger_func(probe_data);
_mali_osk_time_ubusydelay(5);
irq = probe_irq_off(mask);
err = ack_func(probe_data);
} while (irq < 0 && (err == _MALI_OSK_ERR_OK) && probe_count--);
if (irq < 0 || (_MALI_OSK_ERR_OK != err)) irqnum = -1;
else irqnum = irq;
} else irqnum = -1; /* no probe functions, fault */
if (-1 != irqnum) {
/* found an irq */
MALI_DEBUG_PRINT(2, ("Found irq %d\n", irqnum));
} else {
MALI_DEBUG_PRINT(2, ("Probe for irq failed\n"));
}
}
irq_object->irqnum = irqnum;
irq_object->uhandler = uhandler;
irq_object->data = int_data;
if (-1 == irqnum) {
MALI_DEBUG_PRINT(2, ("No IRQ for core '%s' found during probe\n", description));
kfree(irq_object);
return NULL;
}
#if defined(DEBUG)
#if 0
/* Verify that the configured interrupt settings are working */
if (_MALI_OSK_ERR_OK != test_interrupt(irqnum, trigger_func, ack_func, probe_data, description)) {
MALI_DEBUG_PRINT(2, ("Test of IRQ handler for core '%s' failed\n", description));
kfree(irq_object);
return NULL;
}
#endif
#endif
if (0 != request_irq(irqnum, irq_handler_upper_half, IRQF_TRIGGER_LOW, description, irq_object)) {
MALI_DEBUG_PRINT(2, ("Unable to install IRQ handler for core '%s'\n", description));
kfree(irq_object);
return NULL;
}
return irq_object;
}
void _mali_osk_irq_term( _mali_osk_irq_t *irq )
{
mali_osk_irq_object_t *irq_object = (mali_osk_irq_object_t *)irq;
free_irq(irq_object->irqnum, irq_object);
kfree(irq_object);
}
/** This function is called directly in interrupt context from the OS just after
* the CPU get the hw-irq from mali, or other devices on the same IRQ-channel.
* It is registered one of these function for each mali core. When an interrupt
* arrives this function will be called equal times as registered mali cores.
* That means that we only check one mali core in one function call, and the
* core we check for each turn is given by the \a dev_id variable.
* If we detect an pending interrupt on the given core, we mask the interrupt
* out by settging the core's IRQ_MASK register to zero.
* Then we schedule the mali_core_irq_handler_bottom_half to run as high priority
* work queue job.
*/
static irqreturn_t irq_handler_upper_half (int port_name, void* dev_id ) /* , struct pt_regs *regs*/
{
irqreturn_t ret = IRQ_NONE;
mali_osk_irq_object_t *irq_object = (mali_osk_irq_object_t *)dev_id;
if (_MALI_OSK_ERR_OK == irq_object->uhandler(irq_object->data)) {
ret = IRQ_HANDLED;
}
return ret;
}
|
/*========================================================================
rtl_433.h
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
THE COPYRIGHT HOLDERS OR CONTRIBUTORS ARE AWARE OF THE POSSIBILITY OF SUCH DAMAGE.
========================================================================*/
#ifndef __RTL_433FM_h
#define __RTL_433FM_h
// rtl-fm decode is suspended for this many seconds after successfully decoding an
// efergy message. This is to reduce cpu load and keep it cooler based on the assumption
// that efergy messages are evenly spaced (on elite TPM, 10 seconds by default)
#define RTLFM_EFERGY_SLEEP_SECONDS 9
//#define DEFAULT_SAMPLE_RATE 24000 // rtl_fm default rate
#define DEFAULT_SAMPLE_RATE 250000
#define DEFAULT_FREQUENCY 433920000
#define DEFAULT_HOP_TIME (60*10)
#define DEFAULT_HOP_EVENTS 2
#define DEFAULT_ASYNC_BUF_NUMBER 32
#define R433_DEFAULT_BUF_LENGTH (16 * 16384)
#define DEFAULT_LEVEL_LIMIT 10000
#define DEFAULT_DECIMATION_LEVEL 0
#define MINIMAL_R433_BUF_LENGTH 512
//#define MAXIMAL_BUF_LENGTH (256 * 16384)
#define MAXIMAL_R433_BUF_LENGTH (16 * 16384)
#define FILTER_ORDER 1
#define MAX_PROTOCOLS 10
#define SIGNAL_GRABBER_BUFFER (12 * R433_DEFAULT_BUF_LENGTH)
#define BITBUF_COLS 34
#define BITBUF_ROWS 5
/* Supported modulation types */
#define OOK_PWM_D 1 /* Pulses are of the same length, the distance varies */
#define OOK_PWM_P 2 /* The length of the pulses varies */
#define OOK_MANCHESTER 3 /* Manchester code */
typedef struct {
unsigned int id;
char name[256];
unsigned int modulation;
unsigned int short_limit;
unsigned int long_limit;
unsigned int reset_limit;
int (*json_callback)(uint8_t bits_buffer[BITBUF_ROWS][BITBUF_COLS]) ;
} r_device;
struct protocol_state {
int (*callback)(uint8_t bits_buffer[BITBUF_ROWS][BITBUF_COLS]);
/* bits state */
int bits_col_idx;
int bits_row_idx;
int bits_bit_col_idx;
uint8_t bits_buffer[BITBUF_ROWS][BITBUF_COLS];
int16_t bits_per_row[BITBUF_ROWS];
int bit_rows;
unsigned int modulation;
/* demod state */
int pulse_length;
int pulse_count;
int pulse_distance;
int sample_counter;
int start_c;
int packet_present;
int pulse_start;
int real_bits;
int start_bit;
/* pwm limits */
int short_limit;
int long_limit;
int reset_limit;
};
struct dm_state {
FILE *file;
int save_data;
int32_t level_limit;
int32_t decimation_level;
int16_t filter_buffer[MAXIMAL_R433_BUF_LENGTH+FILTER_ORDER];
int16_t* f_buf;
int analyze;
int debug_mode;
/* Signal grabber variables */
int signal_grabber;
int8_t* sg_buf;
int sg_index;
int sg_len;
/* Protocol states */
int r_dev_num;
struct protocol_state *r_devs[MAX_PROTOCOLS];
};
extern int debug_output;
extern int events;
extern volatile int rtlsdr_do_exit;
extern struct dm_state* rtl_433_demod;
extern r_device oregon_scientific;
extern int rtl_433_a[];
extern int rtl_433_b[];
extern int rtl_433fm_main(int argc, char **argv);
extern void pwm_d_decode(struct dm_state *demod, struct protocol_state* p, int16_t *buf, uint32_t len);
extern void pwm_p_decode(struct dm_state *demod, struct protocol_state* p, int16_t *buf, uint32_t len);
extern void manchester_decode(struct dm_state *demod, struct protocol_state* p, int16_t *buf, uint32_t len);
extern void demod_print_bits_packet(struct protocol_state* p);
extern void demod_reset_bits_packet(struct protocol_state* p);
extern void demod_next_bits_packet(struct protocol_state* p);
extern void demod_add_bit(struct protocol_state* p, int bit);
extern uint16_t *envelope_detect(unsigned char *buf, uint32_t len, int decimate);
extern void low_pass_filter(uint16_t *x_buf, int16_t *y_buf, uint32_t len);
extern void calc_squares();
extern void register_protocol(struct dm_state *demod, r_device *t_dev, uint32_t samp_rate);
extern int oregon_scientific_decode(uint8_t bb[BITBUF_ROWS][BITBUF_COLS]);
extern int acurite_rain_gauge_decode(uint8_t bb[BITBUF_ROWS][BITBUF_COLS]);
extern int efergy_energy_sensor_decode(int16_t *buf, int len, int efergy_debug_level);
#endif
|
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/*
* Libparrillada-media
* Copyright (C) Philippe Rouquier 2005-2009 <bonfire-app@wanadoo.fr>
*
* Libparrillada-media is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The Libparrillada-media authors hereby grant permission for non-GPL compatible
* GStreamer plugins to be used and distributed together with GStreamer
* and Libparrillada-media. This permission is above and beyond the permissions granted
* by the GPL license by which Libparrillada-media is covered. If you modify this code
* you may extend this exception to your version of the code, but you are not
* obligated to do so. If you do not wish to do so, delete this exception
* statement from your version.
*
* Libparrillada-media is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to:
* The Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301, USA.
*/
#include <glib.h>
#include "scsi-base.h"
#ifndef _BURN_GET_PERFORMANCE_H
#define _BURN_GET_PERFORMANCE_H
G_BEGIN_DECLS
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
struct _ParrilladaScsiGetPerfHdr {
uchar len [4];
uchar except :1;
uchar wrt :1;
uchar reserved0 :6;
uchar reserved1 [3];
};
struct _ParrilladaScsiWrtSpdDesc {
uchar mrw :1;
uchar exact :1;
uchar rdd :1;
uchar wrc :1;
uchar reserved0 :3;
uchar reserved1 [3];
uchar capacity [4];
uchar rd_speed [4];
uchar wr_speed [4];
};
#else
struct _ParrilladaScsiGetPerfHdr {
uchar len [4];
uchar reserved0 :6;
uchar wrt :1;
uchar except :1;
uchar reserved1 [3];
};
struct _ParrilladaScsiWrtSpdDesc {
uchar reserved0 :3;
uchar wrc :1;
uchar rdd :1;
uchar exact :1;
uchar mrw :1;
uchar reserved1 [3];
uchar capacity [4];
uchar rd_speed [4];
uchar wr_speed [4];
};
#endif
typedef struct _ParrilladaScsiGetPerfHdr ParrilladaScsiGetPerfHdr;
typedef struct _ParrilladaScsiWrtSpdDesc ParrilladaScsiWrtSpdDesc;
struct _ParrilladaScsiGetPerfData {
ParrilladaScsiGetPerfHdr hdr;
gpointer data; /* depends on the request */
};
typedef struct _ParrilladaScsiGetPerfData ParrilladaScsiGetPerfData;
G_END_DECLS
#endif /* _BURN_GET_PERFORMANCE_H */
|
#ifndef LINTPLUG_GLOBAL_H
#define LINTPLUG_GLOBAL_H
#include <QtGlobal>
#if defined(LINTPLUG_LIBRARY)
# define LINTPLUGSHARED_EXPORT Q_DECL_EXPORT
#else
# define LINTPLUGSHARED_EXPORT Q_DECL_IMPORT
#endif
#endif // LINTPLUG_GLOBAL_H
|
/*****************************************************************
* $Id: acc_workorder.h 2191 2014-10-27 20:31:51Z rutger $
* Created: Oct 27, 2014 11:41:25 AM - rutger
*
* Copyright (C) 2014 Red-Bag. All rights reserved.
* This file is part of the Biluna ACC project.
*
* See http://www.red-bag.com for further details.
*****************************************************************/
#ifndef ACC_WORKORDER_H
#define ACC_WORKORDER_H
#include "rb_objectcontainer.h"
/**
* Class for (internal) work orders
*/
class ACC_WorkOrder : public RB_ObjectContainer {
public:
ACC_WorkOrder(const RB_String& id = "", RB_ObjectBase* p = NULL,
const RB_String& n = "", RB_ObjectFactory* f = NULL);
ACC_WorkOrder(ACC_WorkOrder* obj);
virtual ~ACC_WorkOrder();
private:
void createMembers();
};
#endif // ACC_WORKORDER_H
|
// -*- C++ -*-
//
// DynamicLoader.h is a part of ThePEG - Toolkit for HEP Event Generation
// Copyright (C) 1999-2011 Leif Lonnblad
//
// ThePEG is licenced under version 2 of the GPL, see COPYING for details.
// Please respect the MCnet academic guidelines, see GUIDELINES for details.
//
#ifndef ThePEG_DynamicLoader_H
#define ThePEG_DynamicLoader_H
// This is the declaration of the DynamicLoader class.
#include "ThePEG/Config/ThePEG.h"
namespace ThePEG {
/**
* <code>DynamicLoader</code> is the general interface to the dynamic
* loader functions of the underlying operating system. Currently it
* only works on Linux.
*
* @see ClassTraits
* @see ClassDescription
* @see DescriptionList
* @see PersistentIStream
*/
class DynamicLoader {
public:
/**
* The actual load command used on the current platform.
*/
static bool loadcmd(string);
/**
* Try to load the file given as argument. If the filename does not
* begin with a '/', try to prepend the paths one at the time until
* success. If all fail try without prepending a path.
* @return true if the loading succeeded, false otherwise.
*/
static bool load(string file);
/**
* Add a path to the bottom of the list of directories to seach for
* dynaically linkable libraries.
*/
static void appendPath(string);
/**
* Add a path to the top of the list of directories to seach for
* dynaically linkable libraries.
*/
static void prependPath(string);
/**
* Return the last error message issued from the platforms loader.
*/
static string lastErrorMessage;
/**
* Insert the name of the given library with correct version numbers
* appended, in the corresponding map.
*/
static void dlname(string);
/**
* Given a list of generic library names, return the same list with
* appended version numbers where available.
*/
static string dlnameversion(string libs);
/**
* Return the full list of directories to seach for dynaically
* linkable libraries.
*/
static const vector<string> & allPaths();
/**
* Return the list of appended directories to seach for dynaically
* linkable libraries.
*/
static const vector<string> & appendedPaths();
/**
* Return the list of prepended directories to seach for dynaically
* linkable libraries.
*/
static const vector<string> & prependedPaths();
private:
/**
* The list of directories to seach for dynaically linkable
* libraries.
*/
static vector<string> paths;
/**
* The list of prepended directories to seach for dynaically linkable
* libraries.
*/
static vector<string> prepaths;
/**
* The list of appended directories to seach for dynaically linkable
* libraries.
*/
static vector<string> apppaths;
/**
* Used to initialize the paths vector from the ThePEG_PATH
* environment.
*/
static vector<string> defaultPaths();
/**
* Map of names of dynamic libraries with correct version numbers
* indexed by their generic names.
*/
static map<string,string> versionMap;
};
}
#endif /* ThePEG_DynamicLoader_H */
|
/*****************************************************************
Copyright (c) 1996-2001 the kicker authors. See file AUTHORS.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
******************************************************************/
#ifndef _konqy_menu_h_
#define _konqy_menu_h_
#include <kpanelmenu.h>
#include <qvaluevector.h>
class KonquerorProfilesMenu : public KPanelMenu
{
Q_OBJECT
public:
KonquerorProfilesMenu(QWidget *parent, const char *name, const QStringList & /*args*/);
~KonquerorProfilesMenu();
protected slots:
void slotExec(int id);
void initialize();
void slotAboutToShow();
protected:
void reload();
QValueVector<QString> m_profiles;
};
#endif
|
#define SVNWCREV_VERSION "1.1, Build 10"
|
/* This file is part of the Vc library.
Copyright (C) 2010-2012 Matthias Kretz <kretz@kde.org>
Vc is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Vc is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with Vc. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef VC_VERSION_H
#define VC_VERSION_H
#define VC_VERSION_STRING "0.7.4"
#define VC_VERSION_NUMBER 0x000708
#define VC_VERSION_CHECK(major, minor, patch) ((major << 16) | (minor << 8) | (patch << 1))
#define VC_LIBRARY_ABI_VERSION 3
/*OUTER_NAMESPACE_BEGIN*/
namespace Vc
{
static inline const char *versionString() {
return VC_VERSION_STRING;
}
static inline unsigned int versionNumber() {
return VC_VERSION_NUMBER;
}
#if !defined(VC_NO_VERSION_CHECK) && !defined(VC_COMPILE_LIB)
void checkLibraryAbi(unsigned int compileTimeAbi, unsigned int versionNumber, const char *versionString);
namespace {
static struct runLibraryAbiCheck
{
runLibraryAbiCheck() {
checkLibraryAbi(VC_LIBRARY_ABI_VERSION, VC_VERSION_NUMBER, VC_VERSION_STRING);
}
} _runLibraryAbiCheck;
}
#endif
} // namespace Vc
/*OUTER_NAMESPACE_END*/
#endif // VC_VERSION_H
|
/* inflate.h -- internal inflate state definition
* Copyright (C) 1995-2004 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
/* WARNING: this file should *not* be used by applications. It is
part of the implementation of the compression library and is
subject to change. Applications should only use zlib.h.
*/
/* define NO_GZIP when compiling if you want to disable gzip header and
trailer decoding by inflate(). NO_GZIP would be used to avoid linking in
the crc code when it is not needed. For shared libraries, gzip decoding
should be left enabled. */
#ifndef NO_GZIP
# define GUNZIP
#endif
/* Possible inflate modes between inflate() calls */
typedef enum
{
HEAD, /* i: waiting for magic header */
FLAGS, /* i: waiting for method and flags (gzip) */
TIME, /* i: waiting for modification time (gzip) */
OS, /* i: waiting for extra flags and operating system (gzip) */
EXLEN, /* i: waiting for extra length (gzip) */
EXTRA, /* i: waiting for extra bytes (gzip) */
NAME, /* i: waiting for end of file name (gzip) */
COMMENT, /* i: waiting for end of comment (gzip) */
HCRC, /* i: waiting for header crc (gzip) */
DICTID, /* i: waiting for dictionary check value */
DICT, /* waiting for inflateSetDictionary() call */
TYPE, /* i: waiting for type bits, including last-flag bit */
TYPEDO, /* i: same, but skip check to exit inflate on new block */
STORED, /* i: waiting for stored size (length and complement) */
COPY, /* i/o: waiting for input or output to copy stored block */
TABLE, /* i: waiting for dynamic block table lengths */
LENLENS, /* i: waiting for code length code lengths */
CODELENS, /* i: waiting for length/lit and distance code lengths */
LEN, /* i: waiting for length/lit code */
LENEXT, /* i: waiting for length extra bits */
DIST, /* i: waiting for distance code */
DISTEXT, /* i: waiting for distance extra bits */
MATCH, /* o: waiting for output space to copy string */
LIT, /* o: waiting for output space to write literal */
CHECK, /* i: waiting for 32-bit check value */
LENGTH, /* i: waiting for 32-bit length (gzip) */
DONE, /* finished check, done -- remain here until reset */
BAD, /* got a data error -- remain here until reset */
MEM, /* got an inflate() memory error -- remain here until reset */
SYNC /* looking for synchronization bytes to restart inflate() */
} inflate_mode;
/*
State transitions between above modes -
(most modes can go to the BAD or MEM mode -- not shown for clarity)
Process header:
HEAD -> (gzip) or (zlib)
(gzip) -> FLAGS -> TIME -> OS -> EXLEN -> EXTRA -> NAME
NAME -> COMMENT -> HCRC -> TYPE
(zlib) -> DICTID or TYPE
DICTID -> DICT -> TYPE
Read deflate blocks:
TYPE -> STORED or TABLE or LEN or CHECK
STORED -> COPY -> TYPE
TABLE -> LENLENS -> CODELENS -> LEN
Read deflate codes:
LEN -> LENEXT or LIT or TYPE
LENEXT -> DIST -> DISTEXT -> MATCH -> LEN
LIT -> LEN
Process trailer:
CHECK -> LENGTH -> DONE
*/
/* state maintained between inflate() calls. Approximately 7K bytes. */
struct inflate_state
{
inflate_mode mode; /* current inflate mode */
int last; /* true if processing last block */
int wrap; /* bit 0 true for zlib, bit 1 true for gzip */
int havedict; /* true if dictionary provided */
int flags; /* gzip header method and flags (0 if zlib) */
unsigned dmax; /* zlib header max distance (INFLATE_STRICT) */
unsigned long check; /* protected copy of check value */
unsigned long total; /* protected copy of output count */
gz_headerp head; /* where to save gzip header information */
/* sliding window */
unsigned wbits; /* log base 2 of requested window size */
unsigned wsize; /* window size or zero if not using window */
unsigned whave; /* valid bytes in the window */
unsigned write; /* window write index */
unsigned char FAR *window; /* allocated sliding window, if needed */
/* bit accumulator */
unsigned long hold; /* input bit accumulator */
unsigned bits; /* number of bits in "in" */
/* for string and stored block copying */
unsigned length; /* literal or length of data to copy */
unsigned offset; /* distance back to copy string from */
/* for table and code decoding */
unsigned extra; /* extra bits needed */
/* fixed and dynamic code tables */
code const FAR *lencode; /* starting table for length/literal codes */
code const FAR *distcode; /* starting table for distance codes */
unsigned lenbits; /* index bits for lencode */
unsigned distbits; /* index bits for distcode */
/* dynamic table building */
unsigned ncode; /* number of code length code lengths */
unsigned nlen; /* number of length code lengths */
unsigned ndist; /* number of distance code lengths */
unsigned have; /* number of code lengths in lens[] */
code FAR *next; /* next available space in codes[] */
unsigned short lens[320]; /* temporary storage for code lengths */
unsigned short work[288]; /* work area for code table building */
code codes[ENOUGH]; /* space for code tables */
};
|
/* Return the next element of a path.
Copyright (C) 1992, 2010 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* Written by David MacKenzie <djm@gnu.org>,
inspired by John P. Rouillard <rouilj@cs.umb.edu>. */
#ifndef INC_NEXTELEM_H
#define INC_NEXTELEM_H 1
char *next_element (const char *path, int curdir_ok);
#endif
|
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
int combos[100][10];
int count;
long long int nCr(int n, int r){
int i;
long long int result = 1;
if(r > n/2) r = n - r;
for(i = 1; i <= r; ++i){
result *= (n-i+1);
result /= i;
}
return result;
}
int transformToDominant(int m, int r, double M[m][m], double N[m], int V[], int R[])
{
int i, j;
int n = m;
if (r == m)
{
double T[n][n+1];
double P[n];
for (i = 0; i < n; i++)
{
P[i] = N[R[i]];
for (j = 0; j < n; j++)
T[i][j] = M[R[i]][j];
}
for (i = 0; i < n; i++)
{
N[i] = P[i];
for (j = 0; j < n; j++)
M[i][j] = T[i][j];
}
return 1;
}
for (i = 0; i < n; i++)
{
if (V[i]) continue;
double sum = 0;
for (j = 0; j < n; j++)
sum += fabs(M[i][j]);
if (2 * fabs(M[i][r]) >= sum)
{
V[i] = 1;
R[r] = i;
if (transformToDominant(m, r + 1, M, N, V, R))
return 1;
V[i] = 0;
}
}
return 0;
}
int makeDominant(int m, double M[m][m], double N[m])
{
int i;
int visited[m];
for(i = 0; i < m; ++i) visited[i] = 0;
int rows[m];
return transformToDominant(m, 0, M, N, visited, rows);
}
double * gaussSeidel( int m, int n, double a[m][n], double b[m], double er, int itr){
int key, i, j;
double x0[n], sum;
double * x = (double *) malloc(n * sizeof(double));
double M[m][m];
double N[m];
for(i = 0; i < n; ++i){
x0[i] = 0;
x[i] = 0;
}
for(i = 0; i < m; ++i){
N[i] = b[i];
for(j = 0; j < m; ++j){
M[i][j] = a[i][combos[itr][j]];
}
}
makeDominant(m, M, N);
do{
key = 0;
for(i = 0; i < m; ++i){
sum = N[i];
for(j = 0; j < m; ++j)
if(j != i)
sum -= M[i][j] * x0[combos[itr][j]];
x[combos[itr][i]] = sum / M[i][i];
if(fabs((x[combos[itr][i]] - x0[combos[itr][i]]) / x[combos[itr][i]]) > er){
key = 1;
x0[combos[itr][i]] = x[combos[itr][i]];
}
}
}while(key == 1);
return x;
}
void concatCombination(int arr[], int data[], int start, int end,
int index, int r)
{
int i, j;
if (index == r){
for(j = 0; j < r; ++j){
combos[count][j] = data[j];
}
++count;
return;
}
for (i = start; i <= end && end-i+1 >= r-index; ++i)
{
data[index] = arr[i];
concatCombination(arr, data, i+1, end, index+1, r);
}
}
void getCombination(int arr[], int n, int r)
{
int data[r];
concatCombination(arr, data, 0, n-1, 0, r);
}
int main(){
int i, j, n, m;
double er;
printf("Enter the dimension of the matrix (m x n):\n");
scanf("%d%d", &m, &n);
long long int solCount = nCr(n, m);
printf("Enter the stopping Criteria (er) :\n");
scanf("%lf", &er);
printf("Enter the matrix : \n");
double a[m][n];
for(i = 0; i < m; ++i)
for(j = 0; j < n; ++j)
scanf("%lf", &a[i][j]);
printf("Enter the values of B : \n");
double b[m];
for(i = 0; i < m; ++i)
scanf("%lf", &b[i]);
count = 0;
int indices[n];
for(i = 0; i < n; ++i) indices[i] = i;
getCombination(indices, n, m);
if(count != solCount) printf("Error : All combinations not found!\n");
double * x[solCount];
printf("Solutions:\n\n");
for(j = 0; j < solCount; ++j){
printf("Solution %d:\n", j+1);
x[j] = gaussSeidel(m, n, a, b, er, j);
for(i = 0; i < n; ++i)
printf("x_%d = %lf\t", i+1, x[j][i]);
printf("\n\n");
}
printf("Total number of basic soultions = %d\n\n", count);
return 0;
}
|
#ifndef PQ_QUIT_STATE_H
#define PQ_QUIT_STATE_H
/*
* Lets you set whether to want to quit.
*
* 1 means yes, 0 means no.
*/
void pq_quit_state_set(int state);
/*
* Whether you want to quit.
*
* 1 means yes, 0 means no.
*/
int pq_quit_state(void);
#endif /* PQ_QUIT_STATE_H */
|
#ifndef ANIMATIONROTATEMOVE_H
#define ANIMATIONROTATEMOVE_H
#include <QGraphicsItem>
#include "pictureanimation.h"
class AnimationRotateMove : public AbstractPictureAnimation
{
public:
QAbstractAnimation *getAnimationIn (AnimatedItem *target, int duration, int parentWidth);
QAbstractAnimation *getAnimationOut (AnimatedItem *target, int duration, int parentWidth);
};
#endif // ANIMATIONROTATEMOVE_H
|
/*****************************************************************************
* Copyright (c) 2014-2020 OpenRCT2 developers
*
* For a complete list of all authors, please refer to contributors.md
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
*
* OpenRCT2 is licensed under the GNU General Public License version 3.
*****************************************************************************/
#pragma once
#include "Object.h"
struct CoordsXY;
enum TERRAIN_SURFACE_FLAGS
{
NONE = 0,
SMOOTH_WITH_SELF = 1 << 0,
SMOOTH_WITH_OTHER = 1 << 1,
CAN_GROW = 1 << 2,
};
class TerrainSurfaceObject final : public Object
{
private:
struct SpecialEntry
{
uint32_t Index{};
int32_t Length{};
int32_t Rotation{};
int32_t Variation{};
bool Grid{};
bool Underground{};
};
static constexpr auto NUM_IMAGES_IN_ENTRY = 19;
public:
rct_string_id NameStringId{};
uint32_t IconImageId{};
uint32_t PatternBaseImageId{};
uint32_t EntryBaseImageId{};
uint32_t NumEntries{};
uint32_t DefaultEntry{};
uint32_t DefaultGridEntry{};
uint32_t DefaultUndergroundEntry{};
std::vector<SpecialEntry> SpecialEntries;
std::vector<uint32_t> SpecialEntryMap;
colour_t Colour{};
uint8_t Rotations{};
money32 Price{};
TERRAIN_SURFACE_FLAGS Flags{};
explicit TerrainSurfaceObject(const rct_object_entry& entry)
: Object(entry)
{
}
void ReadJson(IReadObjectContext* context, json_t& root) override;
void Load() override;
void Unload() override;
void DrawPreview(rct_drawpixelinfo* dpi, int32_t width, int32_t height) const override;
uint32_t GetImageId(
const CoordsXY& position, int32_t length, int32_t rotation, int32_t offset, bool grid, bool underground) const;
};
|
#pragma once
/*
* Copyright 2010-2016 OpenXcom Developers.
*
* This file is part of OpenXcom.
*
* OpenXcom is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenXcom is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with OpenXcom. If not, see <http://www.gnu.org/licenses/>.
*/
#include "../Engine/State.h"
#include <vector>
#include "SoldierSortUtil.h"
namespace OpenXcom
{
class TextButton;
class Window;
class Text;
class TextList;
class ComboBox;
class Base;
class Soldier;
template <typename TagType> class TaggedText;
struct SortFunctor;
/**
* Soldiers screen that lets the player
* manage all the soldiers in a base.
*/
class SoldiersState : public State
{
private:
TextButton *_btnOk, *_btnPsiTraining, *_btnTraining, *_btnMemorial, *_btnStats, *_btnRoles;
Window *_window;
Text *_txtTitle, *_txtName, *_txtRank, *_txtCraft;
ComboBox *_cbxSortBy;
TextList *_lstSoldiers;
Base *_base;
std::vector<Soldier *> _origSoldierOrder;
std::vector<SortFunctor *> _sortFunctors;
getStatFn_t _dynGetter;
//TextList *_lstSoldierStats;
TaggedText<int> *_txtTU, *_txtStamina, *_txtHealth, *_txtBravery, *_txtReactions, *_txtFiring,
*_txtThrowing, *_txtMelee, *_txtStrength, *_txtPsiStrength, *_txtPsiSkill;
Text *_txtTooltip;
std::string _currentTooltip;
bool _showStats, _showPsi;
///initializes the display list based on the craft soldier's list and the position to display
void initList(size_t scrl);
public:
/// Creates the Soldiers state.
SoldiersState(Base *base);
/// Cleans up the Soldiers state.
~SoldiersState();
/// Handler for changing the sort by combobox.
void cbxSortByChange(Action *action);
/// Updates the soldier names.
void init();
/// Handler for clicking the Soldiers reordering button.
void lstItemsLeftArrowClick(Action *action);
/// Moves a soldier up.
void moveSoldierUp(Action *action, unsigned int row, bool max = false);
/// Handler for clicking the Soldiers reordering button.
void lstItemsRightArrowClick(Action *action);
/// Moves a soldier down.
void moveSoldierDown(Action *action, unsigned int row, bool max = false);
/// Handler for clicking the OK button.
void btnOkClick(Action *action);
/// Handler for clicking the Psi Training button.
void btnPsiTrainingClick(Action *action);
void btnTrainingClick(Action *action);
/// Handler for clicking the Memorial button.
void btnMemorialClick(Action *action);
/// Handler for clicking the Inventory button.
void btnInventoryClick(Action *action);
/// Handler for clicking the Soldiers list.
void lstSoldiersClick(Action *action);
/// Handler for displaying tooltips.
void txtTooltipIn(Action *action);
/// Handler for hiding tooltips.
void txtTooltipOut(Action *action);
/// Handler for toggling the stats list.
void btnToggleStatsClick(Action *action);
/// Handler for sortable column headers.
void txtColumnHeaderClick(Action *action);
};
}
|
#define MODULE_LOG_PREFIX "dvbapi"
#include "globals.h"
#ifdef HAVE_DVBAPI
#include "oscam-config.h"
#include "oscam-ecm.h"
#include "oscam-string.h"
#include "module-dvbapi.h"
#include "module-dvbapi-chancache.h"
extern DEMUXTYPE demux[MAX_DEMUX];
static LLIST *channel_cache;
void dvbapi_save_channel_cache(void)
{
if(boxtype_is("dbox2")) return; // dont save channelcache on these boxes, they lack resources and will crash!
if (USE_OPENXCAS) // Why?
return;
char fname[256];
int32_t result = 0;
get_config_filename(fname, sizeof(fname), "oscam.ccache");
FILE *file = fopen(fname, "w");
if(!file)
{
cs_log("dvbapi channelcache can't write to file %s", fname);
return;
}
LL_ITER it = ll_iter_create(channel_cache);
struct s_channel_cache *c;
while((c = ll_iter_next(&it)))
{
result = fprintf(file, "%04X,%06X,%04X,%04X,%06X\n", c->caid, c->prid, c->srvid, c->pid, c->chid);
if(result < 0)
{
fclose(file);
result = remove(fname);
if(!result)
{
cs_log("error writing cache -> cache file removed!");
}
else
{
cs_log("error writing cache -> cache file could not be removed either!");
}
return;
}
}
fclose(file);
cs_log("dvbapi channelcache saved to %s", fname);
}
void dvbapi_load_channel_cache(void)
{
if(boxtype_is("dbox2")) return; // dont load channelcache on these boxes, they lack resources and will crash!
if (USE_OPENXCAS) // Why?
return;
char fname[256];
char line[1024];
FILE *file;
struct s_channel_cache *c;
get_config_filename(fname, sizeof(fname), "oscam.ccache");
file = fopen(fname, "r");
if(!file)
{
cs_log_dbg(D_TRACE, "dvbapi channelcache can't read from file %s", fname);
return;
}
int32_t i = 1;
int32_t valid = 0;
char *ptr, *saveptr1 = NULL;
char *split[6];
memset(line, 0, sizeof(line));
while(fgets(line, sizeof(line), file))
{
if(!line[0] || line[0] == '#' || line[0] == ';')
{ continue; }
for(i = 0, ptr = strtok_r(line, ",", &saveptr1); ptr && i < 6 ; ptr = strtok_r(NULL, ",", &saveptr1), i++)
{
split[i] = ptr;
}
valid = (i == 5);
if(valid)
{
if(!cs_malloc(&c, sizeof(struct s_channel_cache)))
{ continue; }
c->caid = a2i(split[0], 4);
c->prid = a2i(split[1], 6);
c->srvid = a2i(split[2], 4);
c->pid = a2i(split[3], 4);
c->chid = a2i(split[4], 6);
if(valid && c->caid != 0)
{
if(!channel_cache)
{
channel_cache = ll_create("channel cache");
}
ll_append(channel_cache, c);
}
else
{
NULLFREE(c);
}
}
}
fclose(file);
cs_log("dvbapi channelcache loaded from %s", fname);
}
struct s_channel_cache *dvbapi_find_channel_cache(int32_t demux_id, int32_t pidindex, int8_t caid_and_prid_only)
{
struct s_ecmpids *p = &demux[demux_id].ECMpids[pidindex];
struct s_channel_cache *c;
LL_ITER it;
if(!channel_cache)
{ channel_cache = ll_create("channel cache"); }
it = ll_iter_create(channel_cache);
while((c = ll_iter_next(&it)))
{
if(caid_and_prid_only)
{
if(p->CAID == c->caid && (p->PROVID == c->prid || p->PROVID == 0)) // PROVID ==0 some provider no provid in PMT table
{ return c; }
}
else
{
if(demux[demux_id].program_number == c->srvid
&& p->CAID == c->caid
&& p->ECM_PID == c->pid
&& (p->PROVID == c->prid || p->PROVID == 0)) // PROVID ==0 some provider no provid in PMT table
{
#ifdef WITH_DEBUG
char buf[ECM_FMT_LEN];
ecmfmt(c->caid, 0, c->prid, c->chid, c->pid, c->srvid, 0, 0, 0, 0, buf, ECM_FMT_LEN, 0, 0);
cs_log_dbg(D_DVBAPI, "Demuxer %d found in channel cache: %s", demux_id, buf);
#endif
return c;
}
}
}
return NULL;
}
int32_t dvbapi_edit_channel_cache(int32_t demux_id, int32_t pidindex, uint8_t add)
{
struct s_ecmpids *p = &demux[demux_id].ECMpids[pidindex];
struct s_channel_cache *c;
LL_ITER it;
int32_t count = 0;
if(!channel_cache)
{ channel_cache = ll_create("channel cache"); }
it = ll_iter_create(channel_cache);
while((c = ll_iter_next(&it)))
{
if(demux[demux_id].program_number == c->srvid
&& p->CAID == c->caid
&& p->ECM_PID == c->pid
&& (p->PROVID == c->prid || p->PROVID == 0))
{
if(add && p->CHID == c->chid)
{
return 0; //already added
}
ll_iter_remove_data(&it);
count++;
}
}
if(add)
{
if(!cs_malloc(&c, sizeof(struct s_channel_cache)))
{ return count; }
c->srvid = demux[demux_id].program_number;
c->caid = p->CAID;
c->pid = p->ECM_PID;
c->prid = p->PROVID;
c->chid = p->CHID;
ll_append(channel_cache, c);
#ifdef WITH_DEBUG
char buf[ECM_FMT_LEN];
ecmfmt(c->caid, 0, c->prid, c->chid, c->pid, c->srvid, 0, 0, 0, 0, buf, ECM_FMT_LEN, 0, 0);
cs_log_dbg(D_DVBAPI, "Demuxer %d added to channel cache: %s", demux_id, buf);
#endif
count++;
}
return count;
}
#endif
|
/*
$License:
Copyright (C) 2011-2012 InvenSense Corporation, All Rights Reserved.
See included License.txt for License information.
$
*/
/*******************************************************************************
*
* $Id:$
*
******************************************************************************/
/**
* @defgroup Start_Manager start_manager
* @brief Motion Library - Start Manager
* Start Manager
*
* @{
* @file start_manager.c
* @brief This handles all the callbacks when inv_start_mpl() is called.
*/
#include <string.h>
#include "log.h"
#include "start_manager.h"
typedef inv_error_t (*inv_start_cb_func) ();
struct inv_start_cb_t {
int num_cb;
inv_start_cb_func start_cb[INV_MAX_START_CB];
};
static struct inv_start_cb_t inv_start_cb;
/** Initilize the start manager. Typically called by inv_start_mpl();
* @return Returns INV_SUCCESS if successful or an error code if not.
*/
inv_error_t inv_init_start_manager (void) {
memset (&inv_start_cb, 0, sizeof (inv_start_cb) );
return INV_SUCCESS;
}
/** Removes a callback from start notification
* @param[in] start_cb function to remove from start notification
* @return Returns INV_SUCCESS if successful or an error code if not.
*/
inv_error_t inv_unregister_mpl_start_notification (inv_error_t (*start_cb) (void) ) {
int kk;
for (kk = 0; kk < inv_start_cb.num_cb; ++kk) {
if (inv_start_cb.start_cb[kk] == start_cb) {
// Found the match
if (kk != (inv_start_cb.num_cb - 1) ) {
memmove (&inv_start_cb.start_cb[kk],
&inv_start_cb.start_cb[kk + 1],
(inv_start_cb.num_cb - kk - 1) *sizeof (inv_start_cb_func) );
}
inv_start_cb.num_cb--;
return INV_SUCCESS;
}
}
return INV_ERROR_INVALID_PARAMETER;
}
/** Register a callback to receive when inv_start_mpl() is called.
* @param[in] start_cb Function callback that will be called when inv_start_mpl() is
* called.
* @return Returns INV_SUCCESS if successful or an error code if not.
*/
inv_error_t inv_register_mpl_start_notification (inv_error_t (*start_cb) (void) ) {
if (inv_start_cb.num_cb >= INV_MAX_START_CB) {
return INV_ERROR_INVALID_PARAMETER;
}
inv_start_cb.start_cb[inv_start_cb.num_cb] = start_cb;
inv_start_cb.num_cb++;
return INV_SUCCESS;
}
/** Callback all the functions that want to be notified when inv_start_mpl() was
* called.
* @return Returns INV_SUCCESS if successful or an error code if not.
*/
inv_error_t inv_execute_mpl_start_notification (void) {
inv_error_t result, first_error;
int kk;
first_error = INV_SUCCESS;
for (kk = 0; kk < inv_start_cb.num_cb; ++kk) {
result = inv_start_cb.start_cb[kk]();
if (result && (first_error == INV_SUCCESS) ) {
first_error = result;
}
}
return first_error;
}
/**
* @}
*/
|
/*
* simple 2d SOM
* TODO: implementation could be much better..
* many passes for SOM, probability distribution modification
* (using histrogram modification to wanted distribution)
* to correct SOMs f^2/3 or f^/1/3 error in probability vs
* number of representing vectors in SOM.
* learning should happen in two/many passes etc. (Haykin's book)
* etc. etc.
*/
#ifndef SOM_h
#define SOM_h
#include <vector>
#include <string>
#include <exception>
#include <stdexcept>
namespace whiteice
{
template <typename T>
class SOM
{
public:
// creates 2d som lattice with given height, width and data dimension
// width and height must be powers of 2, otherwise exception is throwed
SOM(unsigned int width = 2, unsigned int height = 2, unsigned int dimension = 1)
throw(std::logic_error);
virtual ~SOM();
// run SOM with given data
bool learn(const std::vector< std::vector<T> >& data) throw();
// returns distance in feature space
T som_distance(const std::vector<T>& v,
const std::vector<T>& w) const throw();
// returns index to vector representing given vector
unsigned int representing_vector(const std::vector<T>& v) const throw();
// returns som vector for given vector index
std::vector<T>& operator[](unsigned int index) const throw(std::out_of_range);
// randomizes som values
bool randomize() const throw();
// loads SOM data from file
bool load(const std::string& filename) throw();
// saves SOM data to file
bool save(const std::string& filename) const throw();
// returns number of som vectors
unsigned int size() const throw(){ return som.size(); }
private:
// finds closest som representation
// vector index for given vector
unsigned int find_closest(const std::vector<T>& data)
const throw();
// normalizes length of the vector to 1
// or keeps it zero if it's zero
void normalize_length(std::vector<T>& v) const throw();
// calculates squared distance between vectors in som lattice
T som_sqr_distance(unsigned int index1,
unsigned int index2) const throw();
// calculates |x - y|^2
T vector_sqr_distance(const std::vector<T>& x,
const std::vector<T>& y) const throw() ;
// moves all vectors in winners neighbourhood
// towards data vector
bool move_towards(unsigned int winner,
const std::vector<T>& data) throw();
// finds closests som representation
// vector index for given vector
unsigned int find_closests(const std::vector<T>& data)
const throw();
// open()s graphic display/window
bool open_visualization() throw();
bool close_visualization() throw();
bool draw_visualization() throw();
std::vector< std::vector<T> > som;
std::vector<T> umatrix;
unsigned int wbits; // 2^wbits = width
unsigned int width, height;
unsigned int dimension;
float initial_learning_rate;
float initial_variance_distance;
float target_variance_distance;
float learning_rate;
float variance_distance;
bool graphics_on;
bool show_visualization;
bool show_eta;
};
}
#include "SOM.cpp"
#endif
|
/* Copyright (C) 2018 Magnus Lång and Tuan Phong Ngo
* This benchmark is part of SWSC */
#include <assert.h>
#include <stdint.h>
#include <stdatomic.h>
#include <pthread.h>
atomic_int vars[2];
atomic_int atom_0_r1_1;
atomic_int atom_1_r1_1;
void *t0(void *arg){
label_1:;
int v2_r1 = atomic_load_explicit(&vars[0], memory_order_seq_cst);
int v3_r3 = v2_r1 ^ v2_r1;
int v4_r3 = v3_r3 + 1;
atomic_store_explicit(&vars[1], v4_r3, memory_order_seq_cst);
int v14 = (v2_r1 == 1);
atomic_store_explicit(&atom_0_r1_1, v14, memory_order_seq_cst);
return NULL;
}
void *t1(void *arg){
label_2:;
int v6_r1 = atomic_load_explicit(&vars[1], memory_order_seq_cst);
int v8_r3 = atomic_load_explicit(&vars[1], memory_order_seq_cst);
int v9_r4 = v8_r3 ^ v8_r3;
int v10_r4 = v9_r4 + 1;
atomic_store_explicit(&vars[0], v10_r4, memory_order_seq_cst);
int v15 = (v6_r1 == 1);
atomic_store_explicit(&atom_1_r1_1, v15, memory_order_seq_cst);
return NULL;
}
int main(int argc, char *argv[]){
pthread_t thr0;
pthread_t thr1;
atomic_init(&vars[0], 0);
atomic_init(&vars[1], 0);
atomic_init(&atom_0_r1_1, 0);
atomic_init(&atom_1_r1_1, 0);
pthread_create(&thr0, NULL, t0, NULL);
pthread_create(&thr1, NULL, t1, NULL);
pthread_join(thr0, NULL);
pthread_join(thr1, NULL);
int v11 = atomic_load_explicit(&atom_0_r1_1, memory_order_seq_cst);
int v12 = atomic_load_explicit(&atom_1_r1_1, memory_order_seq_cst);
int v13_conj = v11 & v12;
if (v13_conj == 1) assert(0);
return 0;
}
|
/**
* \file IMP/rmf/geometry_io.h
* \brief Handle read/write of geometry data from/to files.
*
* Copyright 2007-2017 IMP Inventors. All rights reserved.
*
*/
#ifndef IMPRMF_GEOMETRY_IO_H
#define IMPRMF_GEOMETRY_IO_H
#include <IMP/rmf/rmf_config.h>
#include <IMP/display/declare_Geometry.h>
#include <RMF/NodeHandle.h>
#include <RMF/FileHandle.h>
IMPRMF_BEGIN_NAMESPACE
/** \name Geometry I/O
The geometry I/O support currently handles geometry composed of
- IMP::display::SegmentGeometry
- IMP::display::CylinderGeometry
- IMP::display::SphereGeometry
Other types can be supported when requested. Be aware, many
more complex geometry types are automatically decomposed into
the above types and are so, more or less, supported.
@{
*/
//! Add geometries to the file.
IMPRMFEXPORT void add_geometries(RMF::FileHandle file,
const display::GeometriesTemp &r);
//! Add geometries to a given parent node.
IMPRMFEXPORT void add_geometries(RMF::NodeHandle parent,
const display::GeometriesTemp &r);
//! Add geometries, assuming they do not move between frames.
/** This can be space saving compared to resaving
the constant position each frame. */
IMPRMFEXPORT void add_static_geometries(RMF::FileHandle parent,
const display::GeometriesTemp &r);
//! Add a single geometry to the file.
IMPRMFEXPORT void add_geometry(RMF::FileHandle file, display::Geometry *r);
//! Create geometry objects for the geometry nodes found in the file.
IMPRMFEXPORT display::Geometries create_geometries(RMF::FileConstHandle parent);
//! Link the passed geometry objects to corresponding ones in the file.
/** \note The geometries must be in the same order;
we don't search around for matches.
*/
IMPRMFEXPORT void link_geometries(RMF::FileConstHandle parent,
const display::GeometriesTemp &r);
/** @} */
IMPRMF_END_NAMESPACE
#endif /* IMPRMF_GEOMETRY_IO_H */
|
#ifndef TRSCRIPT_H
#define TRSCRIPT_H
// trscript.h
// 9/20/2014 jichi
#include "sakurakit/skglobal.h"
#include <string>
class TranslationScriptPerformerPrivate;
class TranslationScriptPerformer
{
SK_CLASS(TranslationScriptPerformer)
SK_DISABLE_COPY(TranslationScriptPerformer)
SK_DECLARE_PRIVATE(TranslationScriptPerformerPrivate)
// - Construction -
public:
TranslationScriptPerformer();
~TranslationScriptPerformer();
// Initialization
/// Return the number of loaded rules
int size() const;
/// Return whether the script has been loaded, thread-safe
bool isEmpty() const;
/// Clear the loaded script
void clear();
/// Add script from file
bool loadScript(const std::wstring &path);
// Replacement
// Rewrite the text according to the script, thread-safe
std::wstring transform(const std::wstring &text, int category = -1, bool mark = false) const;
// Render option
//std::wstring linkStyle() const;
//void setLinkStyle(const std::wstring &css);
};
#endif // TRSCRIPT_H
|
/*
* Driver for Microtune MT2131 "QAM/8VSB single chip tuner"
*
* Copyright (c) 2006 Steven Toth <stoth@linuxtv.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
*
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __MT2131_PRIV_H__
#define __MT2131_PRIV_H__
/* Regs */
#define MT2131_PWR 0x07
#define MT2131_UPC_1 0x0b
#define MT2131_AGC_RL 0x10
#define MT2131_MISC_2 0x15
/* frequency values in KHz */
#define MT2131_IF1 1220
#define MT2131_IF2 44000
#define MT2131_FREF 16000
struct mt2131_priv
{
struct mt2131_config *cfg;
struct i2c_adapter *i2c;
u32 frequency;
};
#endif /* __MT2131_PRIV_H__ */
|
#include <stdio.h>
#include <samerlib/stack.h>
#include <samerlib/queue.h>
#include <samerlib/map.h>
#define TEST_MAP
int main() {
#ifdef TEST_STACK
int x, y, z, *a, i;
stack *s = new_stack();
x = 1;
y = 2;
z = 4;
for (i = 0; i < 8; i++) {
stack_push(s, &x);
}
stack_push(s, &x);
stack_push(s, &y);
stack_push(s, &z);
while ((a = (int *) stack_pop(s)) != NULL) {
printf("%d", *a);
}
printf("\n");
#endif /* TEST_STACK */
#ifdef TEST_QUEUE
int x, y, z, *a, i;
queue *q = new_queue();
x = 1;
y = 3;
z = 5;
for (i = 0; i < 4; i++) {
queue_push_right(q, &y);
}
queue_push_left(q, &x);
queue_push_right(q, &z);
printf("%d %d\n", q->start, q->end);
while ((a = (int *) queue_pop_right(q)) != NULL) {
printf("%d", *a);
}
printf("\n");
#endif /* TEST_QUEUE */
#ifdef TEST_MAP
map *m = new_map();
map_add(m, "bro", 1);
fprintf(stderr, "%p", map_get(m, "bro"));
free_map(m);
fprintf(stderr, "donezo\n");
#endif /* TEST_MAP */
return 0;
}
|
/*
* File: main.cpp
* Author: uli
*
* WARNING: This program may be vulnerable to format string attacks
*
* Created on 29. Juli 2009, 13:13
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include "lodepng.h"
#define IMGPIX(i,x,y) images[i][(y) * width + (x)] //intvalue
#define MODE_HORIZONTAL 1
#define MODE_VERTICAL 2
/*
*
*/
int main(int argc, char** argv)
{
if (argc < 5) //Vertical/horizontal + 2 images
{
printf("Not enough arguments");
printf("Usage: isect [h/v] [images]");
exit(2);
}
char** inputImageFilenames = argv + 2;
//Check which mode (horizontal/vertical) to use
char directionSpecifier[2];
int mode;
if (strcmp(argv[1], "h") == 0 || strcmp(argv[1], "horizontal") == 0) {
mode = MODE_HORIZONTAL;
strcpy(directionSpecifier, "h");
}
else if (strcmp(argv[1], "v") == 0 || strcmp(argv[1], "vertical") == 0) {
mode = MODE_VERTICAL;
strcpy(directionSpecifier, "v");
}
else {
printf("Invalid mode: %s", argv[1]);
exit(0);
}
int inputImageCount = argc - 2;
int** images = (int**) malloc(sizeof (int*) * inputImageCount);
unsigned char* buffer;
size_t imagesize, buffersize;
int width, height;
//Read all images
LodePNG_Decoder decoder;
LodePNG_Decoder_init(&decoder);
for (int i = 0; i < inputImageCount; i++) {
LodePNG_loadFile(&buffer, &buffersize, inputImageFilenames[i]);
LodePNG_decode(&decoder, (unsigned char**)(&images[i]), &imagesize, buffer, buffersize);
width = decoder.infoPng.width;
height = decoder.infoPng.height;
free(buffer);
}
//Process the images
LodePNG_Encoder encoder;
LodePNG_Encoder_init(&encoder);
LodePNG_InfoPng_copy(&encoder.infoPng, &decoder.infoPng);
LodePNG_InfoRaw_copy(&encoder.infoRaw, &decoder.infoRaw); /*the decoder has written the PNG colortype in the infoRaw too*/
//Calculate the extends of the images to be saved
int saveImageWidth = -1;
int saveImageHeight = -1;
size_t saveImageCount = -1;
if (mode == MODE_HORIZONTAL) {
saveImageHeight = width;
saveImageWidth = inputImageCount;
saveImageCount = height;
}
else if (mode == MODE_VERTICAL) {
saveImageHeight = height;
saveImageWidth = inputImageCount;
saveImageCount = width;
}
//Allocate the images array
int** saveImages = malloc(sizeof (int*) * saveImageCount);
for (int i = 0; i < inputImageCount; i++) {
saveImages[i] = malloc(sizeof (int) * saveImageWidth * saveImageHeight);
}
//Process the images
if (mode == MODE_HORIZONTAL) {
for (int i = 0; i < inputImageCount; i++) {
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
printf("exe i=%i y=%i x=%i\n",i,y,x);
fflush(stdout);
int x = images[i][y * width + x];
//int x = (int) images[i];
printf("\n\n%i\n\n",x);
fflush(stdout);
saveImages[y][x * inputImageCount + i] = images[i][y * width + x];
}
}
}
}
else if (mode == MODE_VERTICAL) {
for (int i = 0; i < inputImageCount; i++) {
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
saveImages[x][x * inputImageCount + i] = images[i][y * width + x];
}
}
}
}
//Free the input image memory
for (int i = 0; i < inputImageCount; i++) {
free(images[i]);
}
free(images);
//Write all images and free the memory
for (unsigned i = 0; i < inputImageCount; i++) {
LodePNG_encode(&encoder, &buffer, &buffersize, (unsigned char*)saveImages[i],
decoder.infoPng.width, decoder.infoPng.height);
//Construct the output filename string...
char* filenameBuffer = (char*) malloc(sizeof (char) * strlen(inputImageFilenames[i]) + 256); //256 should be enough to hold the direction specifier number
sprintf(filenameBuffer, "%s-%s-%i.png", inputImageFilenames[i], directionSpecifier, i);
//...and write the image to the associated file
LodePNG_saveFile(buffer, buffersize, filenameBuffer);
//Free the unneeded data
free(filenameBuffer);
free(saveImages[i]);
}
free(saveImages);
LodePNG_Decoder_cleanup(&decoder);
LodePNG_Encoder_cleanup(&encoder);
return (EXIT_SUCCESS);
}
|
//
// Generated by the J2ObjC translator. DO NOT EDIT!
// source: /Code/Dev/appNativa/source/rareobjc/../rare/core/com/appnativa/rare/util/ListHelper.java
//
// Created by decoteaud on 3/11/16.
//
#ifndef _RAREListHelper_H_
#define _RAREListHelper_H_
@class IOSIntArray;
@class IOSObjectArray;
@class RAREDropInformation;
@class RAREFocusEvent;
@class RAREListHelper_RunTypeEnum;
@class RAREaListItemRenderer;
@class RAREaWidget;
@protocol RAREiHyperlinkListener;
@protocol RAREiListHandler;
@protocol RAREiPlatformComponent;
@protocol RAREiTransferable;
#import "JreEmulation.h"
#include "java/lang/Enum.h"
#include "java/lang/Runnable.h"
@interface RAREListHelper : NSObject {
}
+ (NSString *)CALL_SUPER_METHOD;
+ (NSString *)HYPERLINK_LISTENER_KEY;
+ (void)copySelectedItemsWithRAREiListHandler:(id<RAREiListHandler>)listComponent
withInt:(int)index
withBoolean:(BOOL)insertMode
withBoolean:(BOOL)delete_ OBJC_METHOD_FAMILY_NONE;
+ (id)deleteItemsWithRAREiListHandler:(id<RAREiListHandler>)listComponent
withIntArray:(IOSIntArray *)sels
withBoolean:(BOOL)returnData;
+ (BOOL)focusEventWithRAREiListHandler:(id<RAREiListHandler>)listComponent
withRAREFocusEvent:(RAREFocusEvent *)e
withBoolean:(BOOL)focusOwner;
+ (BOOL)importDataWithRAREaWidget:(RAREaWidget *)widget
withRAREiListHandler:(id<RAREiListHandler>)listComponent
withRAREiTransferable:(id<RAREiTransferable>)t
withRAREDropInformation:(RAREDropInformation *)drop;
+ (void)installItemLinkListenerWithRAREiPlatformComponent:(id<RAREiPlatformComponent>)c
withRAREiHyperlinkListener:(id<RAREiHyperlinkListener>)l;
+ (void)flashHilightWithRAREiListHandler:(id<RAREiListHandler>)list
withInt:(int)row
withBoolean:(BOOL)on
withInt:(int)count
withJavaLangRunnable:(id<JavaLangRunnable>)runnable;
+ (void)runLaterWithRAREiListHandler:(id<RAREiListHandler>)listComponent
withRAREListHelper_RunTypeEnum:(RAREListHelper_RunTypeEnum *)type;
+ (void)runOnEventThreadWithRAREiListHandler:(id<RAREiListHandler>)listComponent
withRAREListHelper_RunTypeEnum:(RAREListHelper_RunTypeEnum *)type;
+ (void)setSelectionsWithRAREiListHandler:(id<RAREiListHandler>)listComponent
withNSObjectArray:(IOSObjectArray *)a;
+ (NSString *)getWidgetAttributeWithRAREaWidget:(RAREaWidget *)widget
withRAREiListHandler:(id<RAREiListHandler>)listComponent
withNSString:(NSString *)name;
+ (void)runItWithRAREiListHandler:(id<RAREiListHandler>)listComponent
withRAREListHelper_RunTypeEnum:(RAREListHelper_RunTypeEnum *)type;
- (id)init;
@end
typedef RAREListHelper ComAppnativaRareUtilListHelper;
typedef enum {
RAREListHelper_RunType_REFRESH = 0,
RAREListHelper_RunType_CLEAR = 1,
} RAREListHelper_RunType;
@interface RAREListHelper_RunTypeEnum : JavaLangEnum < NSCopying > {
}
+ (RAREListHelper_RunTypeEnum *)REFRESH;
+ (RAREListHelper_RunTypeEnum *)CLEAR;
+ (IOSObjectArray *)values;
+ (RAREListHelper_RunTypeEnum *)valueOfWithNSString:(NSString *)name;
- (id)copyWithZone:(NSZone *)zone;
- (id)initWithNSString:(NSString *)__name withInt:(int)__ordinal;
@end
@interface RAREListHelper_Runner : NSObject < JavaLangRunnable > {
@public
__weak id<RAREiListHandler> listComponent_;
RAREListHelper_RunTypeEnum *type_;
}
- (id)initWithRAREiListHandler:(id<RAREiListHandler>)listComponent
withRAREListHelper_RunTypeEnum:(RAREListHelper_RunTypeEnum *)type;
- (void)run;
- (void)copyAllFieldsTo:(RAREListHelper_Runner *)other;
@end
J2OBJC_FIELD_SETTER(RAREListHelper_Runner, type_, RAREListHelper_RunTypeEnum *)
@interface RAREListHelper_$1 : NSObject < JavaLangRunnable > {
@public
RAREaListItemRenderer *val$r_;
BOOL val$on_;
int val$row_;
id<RAREiListHandler> val$list_;
int val$count_;
id<JavaLangRunnable> val$runnable_;
}
- (void)run;
- (id)initWithRAREaListItemRenderer:(RAREaListItemRenderer *)capture$0
withBoolean:(BOOL)capture$1
withInt:(int)capture$2
withRAREiListHandler:(id<RAREiListHandler>)capture$3
withInt:(int)capture$4
withJavaLangRunnable:(id<JavaLangRunnable>)capture$5;
@end
J2OBJC_FIELD_SETTER(RAREListHelper_$1, val$r_, RAREaListItemRenderer *)
J2OBJC_FIELD_SETTER(RAREListHelper_$1, val$list_, id<RAREiListHandler>)
J2OBJC_FIELD_SETTER(RAREListHelper_$1, val$runnable_, id<JavaLangRunnable>)
#endif // _RAREListHelper_H_
|
// ******************************************************************************
// Filename: Interpolator.h
// Project: Vogue
// Author: Steven Ball
//
// Purpose:
// An interpolator helper class that will manage all the interpolations for
// your variables.
//
// Revision History:
// Initial Revision - 23/02/12
//
// Copyright (c) 2005-20016, Steven Ball
// ******************************************************************************
#pragma once
#include <vector>
#include <stddef.h>
typedef void(*FunctionCallback)(void *lpData);
class FloatInterpolation
{
public:
float *m_variable;
float m_start;
float m_end;
float m_time;
float m_easing;
float m_elapsed;
bool m_erase;
FloatInterpolation* m_pNextInterpolation;
FunctionCallback m_Callback;
void *m_pCallbackData;
};
class IntInterpolation
{
public:
int *m_variable;
int m_start;
int m_end;
float m_time;
float m_easing;
float m_elapsed;
bool m_erase;
IntInterpolation* m_pNextInterpolation;
FunctionCallback m_Callback;
void *m_pCallbackData;
};
typedef std::vector<FloatInterpolation*> FloatInterpolationList;
typedef std::vector<IntInterpolation*> IntInterpolationList;
class Interpolator
{
public:
/* Public methods */
static Interpolator* GetInstance();
void Destroy();
void ClearInterpolators();
FloatInterpolation* CreateFloatInterpolation(float *val, float start, float end, float time, float easing, FloatInterpolation* aNext = NULL, FunctionCallback aCallback = NULL, void *aData = NULL);
void LinkFloatInterpolation(FloatInterpolation* aFirst, FloatInterpolation* aSecond);
void AddFloatInterpolation(FloatInterpolation* aInterpolation);
void AddFloatInterpolation(float *val, float start, float end, float time, float easing, FloatInterpolation* aNext = NULL, FunctionCallback aCallback = NULL, void *aData = NULL);
void RemoveFloatInterpolationByVariable(float *val);
IntInterpolation* CreateIntInterpolation(int *val, int start, int end, float time, float easing, IntInterpolation* aNext = NULL, FunctionCallback aCallback = NULL, void *aData = NULL);
void LinkIntInterpolation(IntInterpolation* aFirst, IntInterpolation* aSecond);
void AddIntInterpolation(IntInterpolation* aInterpolation);
void AddIntInterpolation(int *val, int start, int end, float time, float easing, IntInterpolation* aNext = NULL, FunctionCallback aCallback = NULL, void *aData = NULL);
void RemoveIntInterpolationByVariable(int *val);
void SetPaused(bool pause);
bool IsPaused();
void Update(float dt);
void UpdateFloatInterpolators(float delta);
void UpdateIntInterpolators(float delta);
protected:
/* Protected methods */
Interpolator();
Interpolator(const Interpolator&);
Interpolator &operator=(const Interpolator&);
private:
/* Private methods */
void RemoveCreateFloatInterpolation(FloatInterpolation* aInterpolation);
void RemoveFloatInterpolation(FloatInterpolation* aInterpolation);
void RemoveCreateIntInterpolation(IntInterpolation* aInterpolation);
void RemoveIntInterpolation(IntInterpolation* aInterpolation);
public:
/* Public members */
protected:
/* Protected members */
private:
/* Private members */
// A dynamic array of our float interpolation variables
FloatInterpolationList m_vpFloatInterpolations;
FloatInterpolationList m_vpCreateFloatInterpolations;
// A dynamic array of our int interpolation variables
IntInterpolationList m_vpIntInterpolations;
IntInterpolationList m_vpCreateIntInterpolations;
// Singleton instance
static Interpolator *c_instance;
// Flag to control if we are paused or not
bool m_paused;
};
|
/*
* Copyright (C) 2016 Stuart Howarth <showarth@marxoft.co.uk>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include "page.h"
class PluginManager;
class QActionGroup;
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
private Q_SLOTS:
void loadPlugins();
void setCurrentService();
void setCurrentService(const QString &service);
void showAboutDialog();
void showSettingsDialog();
void showTransfers();
void showVideoPlayer();
void onPageStatusChanged(Page::Status status);
void onPageWindowTitleChanged(const QString &text);
void onStackCountChanged(int count);
void onStackPageChanged(Page *page);
private:
virtual void closeEvent(QCloseEvent *event);
PluginManager *m_pluginManager;
QMenu *m_serviceMenu;
QMenu *m_viewMenu;
QMenu *m_editMenu;
QMenu *m_helpMenu;
QActionGroup *m_serviceGroup;
QAction *m_pluginsAction;
QAction *m_quitAction;
QAction *m_backAction;
QAction *m_reloadAction;
QAction *m_transfersAction;
QAction *m_playerAction;
QAction *m_settingsAction;
QAction *m_aboutAction;
QToolBar *m_toolBar;
};
#endif // MAINWINDOW_H
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <math.h>
// EXTERNAL
extern int getCookie(char *cookie);
extern void putLog (char *, char *);
extern int curl (char *url);
// EXTERNAL
int main(int argc, char **argv)
{
// We're going to write something anyway
printf("Content-Type: text/plain;charset=us-ascii\n\n");
char cookie[128];
float result=0;
memset(cookie,0,128);
if (getCookie(cookie))
{
printf("0\n");
goto end;
}
// ...
char url[256];
memset(url, 0, 256);
sprintf(url, "http://rest:9000/getCookieValue?cookie=%s¶meter=lock", cookie);
int res;
res = curl(url);
end:
return 0;
}
|
//******************************************************************************
// MSP430G2xx3 Demo - Timer_A, Toggle P1.0, CCR0 Up Mode ISR, DCO SMCLK
//
// Description: Toggle P1.0 using software and TA_0 ISR. Timer_A is
// configured for up mode, thus the timer overflows when TAR counts to CCR0.
// In this example CCR0 is loaded with 50000.
// ACLK = n/a, MCLK = SMCLK = TACLK = default DCO
//
//
// MSP430G2xx3
// ---------------
// /|\| XIN|-
// | | |
// --|RST XOUT|-
// | |
// | P1.2|-->LED
//
// D. Dang
// Texas Instruments Inc.
// December 2010
// Built with CCS Version 4.2.0 and IAR Embedded Workbench Version: 5.10
//******************************************************************************
#include <msp430.h>
char i=0;
int main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
P1DIR |= 0x04; // P1.2 output
CCTL0 = CCIE; // CCR0 interrupt enabled
CCR0 = 50000;
TACTL = TASSEL_2 + MC_1; // SMCLK, upmode
__bis_SR_register(LPM0_bits + GIE); // Enter LPM0 w/ interrupt
}
#pragma vector=TIMER0_A0_VECTOR
__interrupt void Timer_A (void)
{
i++;
if (i>=10)
{
P1OUT ^= 0x04; // Toggle P1.2
i = 0;
}
}
|
/* Copyright (C) 2018 Magnus Lång and Tuan Phong Ngo
* This benchmark is part of SWSC */
#include <assert.h>
#include <stdint.h>
#include <stdatomic.h>
#include <pthread.h>
atomic_int vars[2];
atomic_int atom_0_r3_2;
atomic_int atom_0_r5_3;
atomic_int atom_1_r5_2;
atomic_int atom_1_r1_1;
void *t0(void *arg){
label_1:;
atomic_store_explicit(&vars[0], 2, memory_order_seq_cst);
int v2_r3 = atomic_load_explicit(&vars[0], memory_order_seq_cst);
atomic_store_explicit(&vars[0], 3, memory_order_seq_cst);
int v4_r5 = atomic_load_explicit(&vars[0], memory_order_seq_cst);
atomic_store_explicit(&vars[1], 1, memory_order_seq_cst);
int v18 = (v2_r3 == 2);
atomic_store_explicit(&atom_0_r3_2, v18, memory_order_seq_cst);
int v19 = (v4_r5 == 3);
atomic_store_explicit(&atom_0_r5_3, v19, memory_order_seq_cst);
return NULL;
}
void *t1(void *arg){
label_2:;
int v6_r1 = atomic_load_explicit(&vars[1], memory_order_seq_cst);
int v7_r3 = v6_r1 ^ v6_r1;
int v8_r3 = v7_r3 + 1;
atomic_store_explicit(&vars[0], v8_r3, memory_order_seq_cst);
int v10_r5 = atomic_load_explicit(&vars[0], memory_order_seq_cst);
int v20 = (v10_r5 == 2);
atomic_store_explicit(&atom_1_r5_2, v20, memory_order_seq_cst);
int v21 = (v6_r1 == 1);
atomic_store_explicit(&atom_1_r1_1, v21, memory_order_seq_cst);
return NULL;
}
int main(int argc, char *argv[]){
pthread_t thr0;
pthread_t thr1;
atomic_init(&vars[1], 0);
atomic_init(&vars[0], 0);
atomic_init(&atom_0_r3_2, 0);
atomic_init(&atom_0_r5_3, 0);
atomic_init(&atom_1_r5_2, 0);
atomic_init(&atom_1_r1_1, 0);
pthread_create(&thr0, NULL, t0, NULL);
pthread_create(&thr1, NULL, t1, NULL);
pthread_join(thr0, NULL);
pthread_join(thr1, NULL);
int v11 = atomic_load_explicit(&atom_0_r3_2, memory_order_seq_cst);
int v12 = atomic_load_explicit(&atom_0_r5_3, memory_order_seq_cst);
int v13 = atomic_load_explicit(&atom_1_r5_2, memory_order_seq_cst);
int v14 = atomic_load_explicit(&atom_1_r1_1, memory_order_seq_cst);
int v15_conj = v13 & v14;
int v16_conj = v12 & v15_conj;
int v17_conj = v11 & v16_conj;
if (v17_conj == 1) assert(0);
return 0;
}
|
#ifndef MANTID_INDEXING_INDEXTYPE_H_
#define MANTID_INDEXING_INDEXTYPE_H_
#include <type_traits>
namespace Mantid {
namespace Indexing {
namespace detail {
/** A base class for strongly-typed integers, without implicit conversion.
@author Simon Heybrock
@date 2017
Copyright © 2017 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge
National Laboratory & European Spallation Source
This file is part of Mantid.
Mantid is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
Mantid is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
File change history is stored at: <https://github.com/mantidproject/mantid>
Code Documentation is available at: <http://doxygen.mantidproject.org>
*/
template <class Derived, class Int,
class = typename std::enable_if<std::is_integral<Int>::value>::type>
class IndexType {
public:
using underlying_type = Int;
IndexType() noexcept : m_data(0) {}
IndexType(Int data) noexcept : m_data(data) {}
explicit operator Int() const noexcept { return m_data; }
template <class T> IndexType &operator=(const T &other) noexcept {
m_data = IndexType(other).m_data;
return *this;
}
template <class T> bool operator==(const T &other) const noexcept {
return m_data == IndexType(other).m_data;
}
template <class T> bool operator!=(const T &other) const noexcept {
return m_data != IndexType(other).m_data;
}
template <class T> bool operator>(const T &other) const noexcept {
return m_data > IndexType(other).m_data;
}
template <class T> bool operator>=(const T &other) const noexcept {
return m_data >= IndexType(other).m_data;
}
template <class T> bool operator<(const T &other) const noexcept {
return m_data < IndexType(other).m_data;
}
template <class T> bool operator<=(const T &other) const noexcept {
return m_data <= IndexType(other).m_data;
}
private:
Int m_data;
};
} // namespace detail
} // namespace Indexing
} // namespace Mantid
#endif /* MANTID_INDEXING_INDEXTYPE_H_ */
|
#pragma once
#include <Re\Game\Effect\Movement\EffectMovementAim.h>
#include <Re\Common\Control\Control.h>
namespace Effect
{
/// efect that allows to move player in x and y axes without any rotation
/// @Warring: Rigidbody must be created before a first update of the component!
class StaticMovement : public MovementAim
{
public:
StaticMovement(float32 movementSpeed);
virtual void onInit() override;
virtual void onUpdate(sf::Time st) override;
////// setters
StaticMovement* setAxis(const string& x, const string& y);
////// Data - cashed axis
Control::Axis *xAxis{ nullptr };
Control::Axis *yAxis{ nullptr };
/*protected:
virtual void serialiseF(std::ostream& file, Res::DataScriptSaver& saver) const override;
virtual void deserialiseF(std::istream& file, Res::DataScriptLoader& loader) override;*/
};
}
|
/*
* myMake.h
*
* Created on: 2017年5月18日
* Author: JYS1105
*/
#ifndef MYMAKE_H_
#define MYMAKE_H_
#ifdef __cplusplus
extern "C" {
#endif
int myFileComments(void * myfile);
int getArgv(void * myfile, int arg, char * argv[]);
int myFile(void * myfile, int arg, char * argv[]);
int myMakefile(int arg, char * argv[]);
#ifdef __cplusplus
}
#endif
#endif /* MYMAKE_H_ */
|
#ifndef RECTC_H
#define RECTC_H
#include <QDebug>
#include "coordinates.h"
class RectC
{
public:
RectC() {}
RectC(const Coordinates &topLeft, const Coordinates &bottomRight)
: _tl(topLeft), _br(bottomRight) {}
RectC(const Coordinates ¢er, double radius);
bool isNull() const
{return _tl.isNull() && _br.isNull();}
bool isValid() const
{return (_tl.isValid() && _br.isValid() && _tl != _br);}
Coordinates topLeft() const {return _tl;}
Coordinates bottomRight() const {return _br;}
Coordinates center() const
{return Coordinates((_tl.lon() + _br.lon()) / 2.0,
(_tl.lat() + _br.lat()) / 2.0);}
RectC operator|(const RectC &r) const;
RectC &operator|=(const RectC &r) {*this = *this | r; return *this;}
RectC operator&(const RectC &r) const;
RectC &operator&=(const RectC &r) {*this = *this & r; return *this;}
RectC united(const Coordinates &c) const;
private:
Coordinates _tl, _br;
};
#ifndef QT_NO_DEBUG
QDebug operator<<(QDebug dbg, const RectC &rect);
#endif // QT_NO_DEBUG
#endif // RECTC_H
|
#pragma once
#include <memory>
#include "storm/models/ModelType.h"
#include "storm/models/sparse/StandardRewardModel.h"
#include "storm/models/sparse/Model.h"
#include "storm/storage/sparse/ModelComponents.h"
namespace storm {
namespace utility {
namespace builder {
template<typename ValueType, typename RewardModelType = storm::models::sparse::StandardRewardModel<ValueType>>
std::shared_ptr<storm::models::sparse::Model<ValueType, RewardModelType>> buildModelFromComponents(storm::models::ModelType modelType, storm::storage::sparse::ModelComponents<ValueType, RewardModelType>&& components);
}
}
}
|
/*
* Copyright (c) 2015, Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Intel Corporation nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/** \file
* \brief Build code for Haig SOM DFA.
*/
#ifndef NG_HAIG_H
#define NG_HAIG_H
#include "ue2common.h"
#include "som/som.h"
#include <memory>
#include <vector>
namespace ue2 {
class CharReach;
class NGHolder;
struct Grey;
struct raw_som_dfa;
#define HAIG_FINAL_DFA_STATE_LIMIT 16383
#define HAIG_HARD_DFA_STATE_LIMIT 8192
/* unordered_som_triggers being true indicates that a live haig may be subjected
* to later tops arriving with earlier soms (without the haig going dead in
* between)
*/
std::unique_ptr<raw_som_dfa>
attemptToBuildHaig(const NGHolder &g, som_type som, u32 somPrecision,
const std::vector<std::vector<CharReach>> &triggers,
const Grey &grey, bool unordered_som_triggers = false);
std::unique_ptr<raw_som_dfa>
attemptToMergeHaig(const std::vector<const raw_som_dfa *> &dfas,
u32 limit = HAIG_HARD_DFA_STATE_LIMIT);
} // namespace ue2
#endif
|
/* Report an error and exit.
Copyright 2016-2019 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
02110-1301, USA. */
#ifndef DIE_H
# define DIE_H
# include <error.h>
# include <stdbool.h>
# include <verify.h>
/* Like 'error (STATUS, ...)', except STATUS must be a nonzero constant.
This may pacify the compiler or help it generate better code. */
# define die(status, ...) \
verify_expr (status, (error (status, __VA_ARGS__), assume (false)))
#endif /* DIE_H */
|
#ifndef OPENBOOK_FS_GUI_LISTKNOWNPEERS_H_
#define OPENBOOK_FS_GUI_LISTKNOWNPEERS_H_
#include "Options.h"
#include <QStringList>
namespace openbook {
namespace filesystem {
namespace gui {
class ListKnownPeers:
public Options
{
public:
static const std::string COMMAND;
static const std::string DESCRIPTION;
ListKnownPeers(QString port= "3030");
QStringList go();
};
}
}
}
#endif
|
/*
* Copyright (C) 2012 Russell King
* Written from the i915 driver.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#include <linux/errno.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <drm/drmP.h>
#include <drm/drm_fb_helper.h>
#include "armada_crtc.h"
#include "armada_drm.h"
#include "armada_fb.h"
#include "armada_gem.h"
static /*const*/ struct fb_ops armada_fb_ops =
{
.owner = THIS_MODULE,
.fb_check_var = drm_fb_helper_check_var,
.fb_set_par = drm_fb_helper_set_par,
.fb_fillrect = drm_fb_helper_cfb_fillrect,
.fb_copyarea = drm_fb_helper_cfb_copyarea,
.fb_imageblit = drm_fb_helper_cfb_imageblit,
.fb_pan_display = drm_fb_helper_pan_display,
.fb_blank = drm_fb_helper_blank,
.fb_setcmap = drm_fb_helper_setcmap,
.fb_debug_enter = drm_fb_helper_debug_enter,
.fb_debug_leave = drm_fb_helper_debug_leave,
};
static int armada_fb_create(struct drm_fb_helper *fbh,
struct drm_fb_helper_surface_size *sizes)
{
struct drm_device *dev = fbh->dev;
struct drm_mode_fb_cmd2 mode;
struct armada_framebuffer *dfb;
struct armada_gem_object *obj;
struct fb_info *info;
int size, ret;
void *ptr;
memset(&mode, 0, sizeof(mode));
mode.width = sizes->surface_width;
mode.height = sizes->surface_height;
mode.pitches[0] = armada_pitch(mode.width, sizes->surface_bpp);
mode.pixel_format = drm_mode_legacy_fb_format(sizes->surface_bpp,
sizes->surface_depth);
size = mode.pitches[0] * mode.height;
obj = armada_gem_alloc_private_object(dev, size);
if (!obj)
{
DRM_ERROR("failed to allocate fb memory\n");
return -ENOMEM;
}
ret = armada_gem_linear_back(dev, obj);
if (ret)
{
drm_gem_object_unreference_unlocked(&obj->obj);
return ret;
}
ptr = armada_gem_map_object(dev, obj);
if (!ptr)
{
drm_gem_object_unreference_unlocked(&obj->obj);
return -ENOMEM;
}
dfb = armada_framebuffer_create(dev, &mode, obj);
/*
* A reference is now held by the framebuffer object if
* successful, otherwise this drops the ref for the error path.
*/
drm_gem_object_unreference_unlocked(&obj->obj);
if (IS_ERR(dfb))
{
return PTR_ERR(dfb);
}
info = drm_fb_helper_alloc_fbi(fbh);
if (IS_ERR(info))
{
ret = PTR_ERR(info);
goto err_fballoc;
}
strlcpy(info->fix.id, "armada-drmfb", sizeof(info->fix.id));
info->par = fbh;
info->flags = FBINFO_DEFAULT | FBINFO_CAN_FORCE_OUTPUT;
info->fbops = &armada_fb_ops;
info->fix.smem_start = obj->phys_addr;
info->fix.smem_len = obj->obj.size;
info->screen_size = obj->obj.size;
info->screen_base = ptr;
fbh->fb = &dfb->fb;
drm_fb_helper_fill_fix(info, dfb->fb.pitches[0], dfb->fb.depth);
drm_fb_helper_fill_var(info, fbh, sizes->fb_width, sizes->fb_height);
DRM_DEBUG_KMS("allocated %dx%d %dbpp fb: 0x%08llx\n",
dfb->fb.width, dfb->fb.height, dfb->fb.bits_per_pixel,
(unsigned long long)obj->phys_addr);
return 0;
err_fballoc:
dfb->fb.funcs->destroy(&dfb->fb);
return ret;
}
static int armada_fb_probe(struct drm_fb_helper *fbh,
struct drm_fb_helper_surface_size *sizes)
{
int ret = 0;
if (!fbh->fb)
{
ret = armada_fb_create(fbh, sizes);
if (ret == 0)
{
ret = 1;
}
}
return ret;
}
static const struct drm_fb_helper_funcs armada_fb_helper_funcs =
{
.gamma_set = armada_drm_crtc_gamma_set,
.gamma_get = armada_drm_crtc_gamma_get,
.fb_probe = armada_fb_probe,
};
int armada_fbdev_init(struct drm_device *dev)
{
struct armada_private *priv = dev->dev_private;
struct drm_fb_helper *fbh;
int ret;
fbh = devm_kzalloc(dev->dev, sizeof(*fbh), GFP_KERNEL);
if (!fbh)
{
return -ENOMEM;
}
priv->fbdev = fbh;
drm_fb_helper_prepare(dev, fbh, &armada_fb_helper_funcs);
ret = drm_fb_helper_init(dev, fbh, 1, 1);
if (ret)
{
DRM_ERROR("failed to initialize drm fb helper\n");
goto err_fb_helper;
}
ret = drm_fb_helper_single_add_all_connectors(fbh);
if (ret)
{
DRM_ERROR("failed to add fb connectors\n");
goto err_fb_setup;
}
ret = drm_fb_helper_initial_config(fbh, 32);
if (ret)
{
DRM_ERROR("failed to set initial config\n");
goto err_fb_setup;
}
return 0;
err_fb_setup:
drm_fb_helper_release_fbi(fbh);
drm_fb_helper_fini(fbh);
err_fb_helper:
priv->fbdev = NULL;
return ret;
}
void armada_fbdev_lastclose(struct drm_device *dev)
{
struct armada_private *priv = dev->dev_private;
if (priv->fbdev)
{
drm_fb_helper_restore_fbdev_mode_unlocked(priv->fbdev);
}
}
void armada_fbdev_fini(struct drm_device *dev)
{
struct armada_private *priv = dev->dev_private;
struct drm_fb_helper *fbh = priv->fbdev;
if (fbh)
{
drm_fb_helper_unregister_fbi(fbh);
drm_fb_helper_release_fbi(fbh);
drm_fb_helper_fini(fbh);
if (fbh->fb)
{
fbh->fb->funcs->destroy(fbh->fb);
}
priv->fbdev = NULL;
}
}
|
#ifndef ANALYSERPITCH_H
#define ANALYSERPITCH_H
#include <QObject>
#include <QPointer>
#include <QString>
#include <QList>
#include <QStandardItemModel>
#include "PraalineCore/Base/RealTime.h"
namespace Praaline {
namespace Core {
class Corpus;
class CorpusCommunication;
class Interval;
class IntervalTier;
class StatisticalMeasureDefinition;
}
}
struct AnalyserMacroprosodyData;
class AnalyserMacroprosody : public QObject
{
Q_OBJECT
public:
explicit AnalyserMacroprosody(QObject *parent = nullptr);
virtual ~AnalyserMacroprosody();
static QList<QString> groupingLevels();
static QList<QString> measureIDs(const QString &groupingLevel);
static Praaline::Core::StatisticalMeasureDefinition measureDefinition(const QString &groupingLevel, const QString &measureID);
double measure(const QString &groupingLevel, const QString &key, const QString &measureID) const;
QPointer<QStandardItemModel> model();
void setMacroUnitsLevel(const QString &);
void setMetadataAttributesCommunication(const QStringList &attributeIDs);
void setMetadataAttributesSpeaker(const QStringList &attributeIDs);
void setMetadataAttributesAnnotation(const QStringList &attributeIDs);
QString calculate(QPointer<Praaline::Core::Corpus> corpus, Praaline::Core::CorpusCommunication *com);
QString calculate(QPointer<Praaline::Core::Corpus> corpus,
const QString &communicationID, const QString &annotationID, const QString &speakerIDfilter = QString(),
const QList<Praaline::Core::Interval *> &units = QList<Praaline::Core::Interval *>());
signals:
public slots:
private:
AnalyserMacroprosodyData *d;
};
#endif // ANALYSERPITCH_H
|
#include <stdio.h>
#include <stdlib.h>
#include "tables_sort.h"
void B_InsertSort(NodeType R[], int n)
{
int i, j;
int p;
int q;
R[0].next = 1;
R[1].next = 0;
for (i = 2; i < n; i++)
{
j = 0;
while (R[R[j].next].data < R[i].data && R[j].next != 0)
j = R[j].next;
R[i].next = R[j].next;
R[j].next = i;
}
}
int main()
{
int i;
NodeType array[9];
//NodeType array[9] = {32767, 49, 38, 65, 97, 76, 13, 27, 49};
for (i = 0; i < 9; i++)
//scanf("%d", &(array[i].data));
array[i].data = 8 - i;
printf("---------------before sorted----------------\n");
for (i = 0; i < 9; i++)
printf("%d ", array[i].data);
printf("\n");
printf("---------------after sorted-----------------\n");
B_InsertSort(array, 9);
for (i = 0; array[i].next != 0; i = array[i].next)
printf("%d ", array[array[i].next].data);
printf("\n");
return 0;
}
|
/****************************/
/* THIS IS OPEN SOURCE CODE */
/****************************/
/**
* @author Jose Pedro Oliveira
*
* test case for the linux-net component
*
* @brief
* List all net events codes and names
*/
#include <stdio.h>
#include <stdlib.h>
#include "papi_test.h"
int main (int argc, char **argv)
{
int retval,cid,numcmp;
int total_events=0;
int code;
char event_name[PAPI_MAX_STR_LEN];
int r;
const PAPI_component_info_t *cmpinfo = NULL;
/* Set TESTS_QUIET variable */
tests_quiet( argc, argv );
/* PAPI Initialization */
retval = PAPI_library_init( PAPI_VER_CURRENT );
if ( retval != PAPI_VER_CURRENT ) {
test_fail(__FILE__, __LINE__,"PAPI_library_init failed\n",retval);
}
if (!TESTS_QUIET) {
printf("Listing all net events\n");
}
numcmp = PAPI_num_components();
for(cid=0; cid<numcmp; cid++) {
if ( (cmpinfo = PAPI_get_component_info(cid)) == NULL) {
test_fail(__FILE__, __LINE__,"PAPI_get_component_info failed\n",-1);
}
if ( strstr(cmpinfo->name, "net") == NULL) {
continue;
}
if (!TESTS_QUIET) {
printf("Component %d (%d) - %d events - %s\n",
cid, cmpinfo->CmpIdx,
cmpinfo->num_native_events, cmpinfo->name);
}
code = PAPI_NATIVE_MASK;
r = PAPI_enum_cmp_event( &code, PAPI_ENUM_FIRST, cid );
while ( r == PAPI_OK ) {
retval = PAPI_event_code_to_name( code, event_name );
if ( retval != PAPI_OK ) {
test_fail( __FILE__, __LINE__, "PAPI_event_code_to_name", retval );
}
if (!TESTS_QUIET) {
printf("0x%x %s\n", code, event_name);
}
total_events++;
r = PAPI_enum_cmp_event( &code, PAPI_ENUM_EVENTS, cid );
}
}
if (total_events==0) {
test_skip(__FILE__,__LINE__,"No net events found", 0);
}
test_pass( __FILE__, NULL, 0 );
return 0;
}
// vim:set ai ts=4 sw=4 sts=4 et:
|
/*
Copyright (c) 2012, Lunar Workshop, Inc.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. All advertising materials mentioning features or use of this software must display the following acknowledgement:
This product includes software developed by Lunar Workshop, Inc.
4. Neither the name of the Lunar Workshop nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY LUNAR WORKSHOP INC ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL LUNAR WORKSHOP BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef LW_RAYTRACE_H
#define LW_RAYTRACE_H
#include <modelconverter/convmesh.h>
#include <geometry.h>
namespace raytrace {
class CTraceResult
{
public:
Vector m_vecHit;
size_t m_iFace;
CConversionMeshInstance* m_pMeshInstance;
};
class CKDTri
{
public:
CKDTri();
CKDTri(size_t v1, size_t v2, size_t v3, size_t iMeshInstanceVertsIndex, size_t iFace, CConversionMeshInstance* pMeshInstance = nullptr);
public:
size_t v[3];
size_t m_iMeshInstanceVertsIndex;
size_t m_iFace;
CConversionMeshInstance* m_pMeshInstance;
};
class CKDNode
{
public:
CKDNode(CKDNode* pParent = NULL, AABB oBounds = AABB(), class CKDTree* pTree = NULL);
~CKDNode();
public:
// Reserves memory for triangles all at once, for faster allocation
void ReserveTriangles(size_t iEstimatedTriangles);
void AddTriangle(size_t v1, size_t v2, size_t v3, size_t iMeshInstanceVertsIndex, size_t iFace, CConversionMeshInstance* pMeshInstance);
void RemoveArea(const AABB& oBox);
void CalcBounds();
void BuildTriList();
void PassTriList();
void Build();
bool Raytrace(const Ray& rayTrace, CTraceResult* pTR = NULL);
bool Raytrace(const Vector& vecStart, const Vector& vecEnd, CTraceResult* pTR = NULL);
float Closest(const Vector& vecPoint);
const CKDNode* GetLeftChild() const { return m_pLeft; };
const CKDNode* GetRightChild() const { return m_pRight; };
AABB GetBounds() const { return m_oBounds; };
size_t GetSplitAxis() const { return m_iSplitAxis; };
float GetSplitPos() const { return m_flSplitPos; };
protected:
CKDNode* m_pParent;
CKDNode* m_pLeft;
CKDNode* m_pRight;
CKDTree* m_pTree;
size_t m_iDepth;
tvector<CKDTri> m_aTris;
size_t m_iTriangles; // This node and all child nodes
AABB m_oBounds;
size_t m_iSplitAxis;
float m_flSplitPos;
};
class CKDTree
{
friend class CKDNode;
public:
CKDTree(class CRaytracer* pTracer, size_t iMaxDepth = 15);
~CKDTree();
public:
// Reserves memory for triangles all at once, for faster allocation
void ReserveTriangles(size_t iEstimatedTriangles);
void AddTriangle(size_t v1, size_t v2, size_t v3, size_t iMeshInstanceVertsIndex, size_t iFace, CConversionMeshInstance* pMeshInstance);
void RemoveArea(const AABB& oBox);
void BuildTree();
bool Raytrace(const Ray& rayTrace, CTraceResult* pTR = NULL);
bool Raytrace(const Vector& vecStart, const Vector& vecEnd, CTraceResult* pTR = NULL);
float Closest(const Vector& vecPoint);
const CKDNode* GetTopNode() const { return m_pTop; };
bool IsBuilt() { return m_bBuilt; };
size_t GetMaxDepth() { return m_iMaxDepth; };
protected:
class CRaytracer* m_pRaytracer;
CKDNode* m_pTop;
bool m_bBuilt;
size_t m_iMaxDepth;
};
class CRaytracer
{
friend class CKDNode;
public:
CRaytracer(CConversionScene* pScene = NULL, size_t iMaxDepth = 15);
~CRaytracer();
public:
bool Raytrace(const Ray& rayTrace, CTraceResult* pTR = NULL);
bool Raytrace(const Vector& vecStart, const Vector& vecEnd, CTraceResult* pTR = NULL);
bool RaytraceBruteForce(const Ray& rayTrace, CTraceResult* pTR = NULL);
float Closest(const Vector& vecPoint);
void AddMeshesFromNode(CConversionSceneNode* pNode);
void AddMeshInstance(CConversionMeshInstance* pMeshInstance);
void BuildTree();
void RemoveArea(const AABB& oBox);
const CKDTree* GetTree() const { return m_pTree; };
protected:
CConversionScene* m_pScene;
CKDTree* m_pTree;
size_t m_iMaxDepth;
tvector<tvector<Vector>> m_aaMeshInstanceVerts;
};
};
#endif
|
/* http.h - HTTP protocol handler
* Copyright (C) 1999, 2000, 2001, 2003, 2006,
* 2010 Free Software Foundation, Inc.
*
* This file is part of GnuPG.
*
* This file is free software; you can redistribute it and/or modify
* it under the terms of either
*
* - the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* or
*
* - the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* or both in parallel, as here.
*
* This file is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GNUPG_COMMON_HTTP_H
#define GNUPG_COMMON_HTTP_H
#include <gpg-error.h>
#include "strlist.h"
struct uri_tuple_s
{
struct uri_tuple_s *next;
const char *name; /* A pointer into name. */
char *value; /* A pointer to value (a Nul is always appended). */
size_t valuelen; /* The real length of the value; we need it
because the value may contain embedded Nuls. */
int no_value; /* True if no value has been given in the URL. */
};
typedef struct uri_tuple_s *uri_tuple_t;
struct parsed_uri_s
{
/* All these pointers point into BUFFER; most stuff is not escaped. */
char *scheme; /* Pointer to the scheme string (always lowercase). */
unsigned int is_http:1; /* This is a HTTP style URI. */
unsigned int use_tls:1; /* Whether TLS should be used. */
unsigned int opaque:1;/* Unknown scheme; PATH has the rest. */
unsigned int v6lit:1; /* Host was given as a literal v6 address. */
char *auth; /* username/password for basic auth. */
char *host; /* Host (converted to lowercase). */
unsigned short port; /* Port (always set if the host is set). */
char *path; /* Path. */
uri_tuple_t params; /* ";xxxxx" */
uri_tuple_t query; /* "?xxx=yyy" */
char buffer[1]; /* Buffer which holds a (modified) copy of the URI. */
};
typedef struct parsed_uri_s *parsed_uri_t;
typedef enum
{
HTTP_REQ_GET = 1,
HTTP_REQ_HEAD = 2,
HTTP_REQ_POST = 3,
HTTP_REQ_PATCH = 4,
HTTP_REQ_OPAQUE = 5 /* Internal use. */
}
http_req_t;
/* We put the flag values into an enum, so that gdb can display them. */
enum
{
HTTP_FLAG_TRY_PROXY = 1, /* Try to use a proxy. */
HTTP_FLAG_SHUTDOWN = 2, /* Close sending end after the request. */
HTTP_FLAG_LOG_RESP = 8, /* Log the server respone. */
HTTP_FLAG_FORCE_TLS = 16, /* Force the use opf TLS. */
HTTP_FLAG_IGNORE_CL = 32, /* Ignore content-length. */
HTTP_FLAG_IGNORE_IPv4 = 64, /* Do not use IPv4. */
HTTP_FLAG_IGNORE_IPv6 = 128, /* Do not use IPv6. */
HTTP_FLAG_AUTH_BEARER = 512 /* Use Bearer authtype instead of Basic. */
};
struct http_session_s;
typedef struct http_session_s *http_session_t;
struct http_context_s;
typedef struct http_context_s *http_t;
void http_register_tls_callback (gpg_error_t (*cb)(http_t,http_session_t,int));
void http_register_tls_ca (const char *fname);
gpg_error_t http_session_new (http_session_t *r_session,
const char *tls_priority);
http_session_t http_session_ref (http_session_t sess);
void http_session_release (http_session_t sess);
void http_session_set_log_cb (http_session_t sess,
void (*cb)(http_session_t, gpg_error_t,
const char *,
const void **, size_t *));
gpg_error_t http_parse_uri (parsed_uri_t *ret_uri, const char *uri,
int no_scheme_check);
void http_release_parsed_uri (parsed_uri_t uri);
gpg_error_t http_raw_connect (http_t *r_hd,
const char *server, unsigned short port,
unsigned int flags, const char *srvtag);
gpg_error_t http_open (http_t *r_hd, http_req_t reqtype,
const char *url,
const char *httphost,
const char *auth,
unsigned int flags,
const char *proxy,
http_session_t session,
const char *srvtag,
strlist_t headers);
void http_start_data (http_t hd);
gpg_error_t http_wait_response (http_t hd);
void http_close (http_t hd, int keep_read_stream);
gpg_error_t http_open_document (http_t *r_hd,
const char *document,
const char *auth,
unsigned int flags,
const char *proxy,
http_session_t session,
const char *srvtag,
strlist_t headers);
estream_t http_get_read_ptr (http_t hd);
estream_t http_get_write_ptr (http_t hd);
unsigned int http_get_status_code (http_t hd);
const char *http_get_tls_info (http_t hd, const char *what);
const char *http_get_header (http_t hd, const char *name);
const char **http_get_header_names (http_t hd);
gpg_error_t http_verify_server_credentials (http_session_t sess);
char *http_escape_string (const char *string, const char *specials);
char *http_escape_data (const void *data, size_t datalen, const char *specials);
#endif /*GNUPG_COMMON_HTTP_H*/
|
/*
Copyright 2009 Last.fm Ltd.
- Primarily authored by Max Howell, Jono Cole and Doug Mansell
This file is part of liblastfm.
liblastfm is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
liblastfm is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with liblastfm. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef NDIS_EVENTS_H
#define NDIS_EVENTS_H
#include <windows.h>
#include <atlbase.h>
#include <WbemCli.h>
class NdisEvents
{
public:
NdisEvents();
~NdisEvents();
HRESULT registerForNdisEvents();
virtual void onConnectionUp(BSTR name) = 0;
virtual void onConnectionDown(BSTR name) = 0;
private:
CComPtr<IWbemLocator> m_pLocator;
CComPtr<IWbemServices> m_pServices;
class WmiSink *m_pSink;
};
#endif
|
/*
* Copyright (C) 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <termios.h>
#include <unistd.h>
pid_t forkpty(int *master, int *slave, const struct termios *termp,
const struct winsize *winp);
|
#include <linux/types.h>
#include <linux/errno.h>
#include <asm/uaccess.h>
#include <asm/sfp-machine.h>
#include <math-emu/soft-fp.h>
#include <math-emu/double.h>
#include <math-emu/single.h>
int
fnmsubs(void *frD, void *frA, void *frB, void *frC)
{
FP_DECL_D(R);
FP_DECL_D(A);
FP_DECL_D(B);
FP_DECL_D(C);
FP_DECL_D(T);
FP_DECL_EX;
#ifdef DEBUG
printk("%s: %p %p %p %p\n", __func__, frD, frA, frB, frC);
#endif
FP_UNPACK_DP(A, frA);
FP_UNPACK_DP(B, frB);
FP_UNPACK_DP(C, frC);
#ifdef DEBUG
printk("A: %ld %lu %lu %ld (%ld)\n", A_s, A_f1, A_f0, A_e, A_c);
printk("B: %ld %lu %lu %ld (%ld)\n", B_s, B_f1, B_f0, B_e, B_c);
printk("C: %ld %lu %lu %ld (%ld)\n", C_s, C_f1, C_f0, C_e, C_c);
#endif
if ((A_c == FP_CLS_INF && C_c == FP_CLS_ZERO) ||
(A_c == FP_CLS_ZERO && C_c == FP_CLS_INF))
{
FP_SET_EXCEPTION(EFLAG_VXIMZ);
}
FP_MUL_D(T, A, C);
if (B_c != FP_CLS_NAN)
{
B_s ^= 1;
}
if (T_s != B_s && T_c == FP_CLS_INF && B_c == FP_CLS_INF)
{
FP_SET_EXCEPTION(EFLAG_VXISI);
}
FP_ADD_D(R, T, B);
if (R_c != FP_CLS_NAN)
{
R_s ^= 1;
}
#ifdef DEBUG
printk("D: %ld %lu %lu %ld (%ld)\n", R_s, R_f1, R_f0, R_e, R_c);
#endif
__FP_PACK_DS(frD, R);
return FP_CUR_EXCEPTIONS;
}
|
#pragma interface
#include <QtCore/QAbstractAnimation>
#include "ruby++/module.h"
#include "ruby++/symbol.h"
namespace R_Qt {
extern void init_animation(RPP::Module mQt, RPP::Class cControl);
extern RPP::Symbol QAbstractAnimation_State2Symbol(QAbstractAnimation::State state);
} // namespace R_Qt
|
/*
b-script
Copyright (C) 2011 Thijs Jeffry de Haas
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program; if not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "expression.h"
namespace ast
{
class ClassDeclaration;
class Declaration;
class MemberAccessExpression;
class BinaryExpression : public Expression
{
public:
typedef enum
{
plus,
minus,
mul,
div,
mod,
lt,
leq,
gt,
geq,
eq,
neq,
and_,
or_,
} Type;
static const char *operationNames[];
typedef enum
{
bool_,
int_,
float_,
other,
} DataType;
Type type;
DataType dataType;
Expression *leftExpr, *rightExpr;
ClassDeclaration *typeDecl;
MemberAccessExpression *customOpCall;
BinaryExpression(Type type, Expression *leftExpr, Expression *rightExpr);
~BinaryExpression();
Declaration* getType() { return (Declaration*)typeDecl; }
virtual void contextAnalysis(DeclarationCollection &declarationCollection);
virtual void execute(Stack2 &stack);
virtual void executeCleanUp(Stack2 &stack);
virtual bool isLValue() { return false; }
virtual bool isRValue() { return leftExpr->isRValue() && rightExpr->isRValue(); }
virtual void generateCode(CodeGeneratorInterface &cg);
};
}
|
/*
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <errno.h>
#include <getopt.h>
#include <stdio.h>
#include <stdlib.h>
#include "fm_tuner.h"
#include "hw/led.h"
#include "net/handler.h"
#include "net/server.h"
#include "seek.h" /* seek_utils. */
#include "utils/error.h"
#define DEFAULT_I2C_ID 1
#define DEFAULT_MAX_CLIENTS 10
#define DEFAULT_PIN_RST 45
#define DEFAULT_PIN_SDIO 12
#define DEFAULT_PORT 9502
#define MODE_SERVER 0
#define MODE_SEEK 1
static Fm_tuner *fm_tuner;
/* --------------------------------------------------------------------- */
static void __disable_leds (void) {
int i;
for (i = 0; i < LEDS_N; i++)
led_set_state(i, LED_INACTIVE);
return;
}
static void __create_tuner (Fm_tuner_conf *conf) {
fm_tuner = fm_tuner_new(conf);
debug("Init FM tuner.\n");
#ifdef DEBUG
debug("Registers data at init:\n");
fm_tuner_print_registers(fm_tuner);
#endif
return;
}
static void __delete_tuner (void) {
fm_tuner_free(fm_tuner);
return;
}
static void __usage (const char *progname) {
printf("Usage: %s [OPTION]...\n", progname);
printf(" -h, --help Print this helper.\n");
printf(" -i, --i2c-id=ID Set the i2c bus id. Default: %d.\n", DEFAULT_I2C_ID);
printf(" -m, --max-clients=N Set the number max of server clients. Default: %d.\n", DEFAULT_MAX_CLIENTS);
printf(" -p, --port=PORT Set the server port. Default: %d.\n", DEFAULT_PORT);
printf(" -r, --reset-pin=PIN Set the reset pin number of the fm tuner. Default: %d.\n", DEFAULT_PIN_RST);
printf(" -s, --sdio-pin=PIN Set the sdio pin number of the fm tuner. Default: %d.\n", DEFAULT_PIN_SDIO);
printf(" --seek Seek to locate radio stations.\n");
exit(EXIT_SUCCESS);
}
/* --------------------------------------------------------------------- */
static int __parse_arguments (int argc, char *argv[], Server_conf *server_conf, Fm_tuner_conf *fm_tuner_conf) {
static const char *opts = "hm:p:i:r:s:";
static struct option long_opts[] = {
{ "help", no_argument, NULL, 'h' },
{ "i2c-id", required_argument, NULL, 'i' },
{ "max-clients", required_argument, NULL, 'm' },
{ "port", required_argument, NULL, 'p' },
{ "reset-pin", required_argument, NULL, 'r' },
{ "sdio-pin", required_argument, NULL, 's' },
{ "seek", no_argument, NULL, 'l' },
{ 0, 0, 0, 0}
};
int opt;
int opt_index;
long value;
char *endptr;
int mode = MODE_SERVER;
errno = 0;
while ((opt = getopt_long(argc, argv, opts, long_opts, &opt_index)) != -1) {
if (opt == 'h' || opt == '?')
__usage(*argv);
if (opt == 'l') {
mode = MODE_SEEK;
continue;
}
if ((value = strtol(optarg, &endptr, 10)) < 0 || errno != 0 || optarg == endptr) {
fprintf(stderr, "error: %s must be an valid unsigned integer.\n", long_opts[opt_index].name);
exit(EXIT_FAILURE);
}
switch (opt) {
case 'm':
server_conf->max_clients = value;
break;
case 'p':
server_conf->port = value;
break;
case 'i':
fm_tuner_conf->i2c_id = value;
break;
case 'r':
fm_tuner_conf->pin_rst = value;
break;
case 's':
fm_tuner_conf->pin_sdio = value;
break;
}
}
return mode;
}
int main (int argc, char *argv[]) {
static Handler_value handler_value = {
.to_set = 0
};
static Server_conf server_conf = {
.port = DEFAULT_PORT,
.max_clients = DEFAULT_MAX_CLIENTS,
.user_value = &handler_value,
.handlers = {
.event = handler_event,
.join = handler_join,
.quit = handler_quit,
.loop = handler_loop
}
};
static Fm_tuner_conf fm_tuner_conf = {
.i2c_id = DEFAULT_I2C_ID,
.pin_rst = DEFAULT_PIN_RST,
.pin_sdio = DEFAULT_PIN_SDIO,
.tuner_addr = 0x10
};
int mode = __parse_arguments(argc, argv, &server_conf, &fm_tuner_conf);
__create_tuner(&fm_tuner_conf);
atexit(__delete_tuner);
__disable_leds();
if (mode == MODE_SEEK)
seek_utils(fm_tuner);
else {
handler_value.fm_tuner = fm_tuner;
handler_value.rds = rds_new();
server_run(&server_conf, 500);
rds_free(handler_value.rds);
}
exit(EXIT_SUCCESS);
}
|
/*******************************************************************************
**
** Monte Carlo eXtreme (MCX) - GPU accelerated Monte Carlo 3D photon migration
** Author: Qianqian Fang <q.fang at neu.edu>
**
** Reference (Fang2009):
** Qianqian Fang and David A. Boas, "Monte Carlo Simulation of Photon
** Migration in 3D Turbid Media Accelerated by Graphics Processing
** Units," Optics Express, vol. 17, issue 22, pp. 20178-20190 (2009)
**
** tictoc.c: timing functions
**
** License: GNU General Public License v3, see LICENSE.txt for details
**
*******************************************************************************/
#include "tictoc.h"
#define _BSD_SOURCE
#ifndef USE_OS_TIMER
#include <cuda.h>
#include <driver_types.h>
#include <cuda_runtime_api.h>
#define MAX_DEVICE 256
/* use CUDA timer */
static cudaEvent_t timerStart[MAX_DEVICE], timerStop[MAX_DEVICE];
unsigned int GetTimeMillis () {
float elapsedTime;
int devid;
cudaGetDevice(&devid);
cudaEventRecord(timerStop[devid],0);
cudaEventSynchronize(timerStop[devid]);
cudaEventElapsedTime(&elapsedTime, timerStart[devid], timerStop[devid]);
return (unsigned int)(elapsedTime);
}
unsigned int StartTimer () {
int devid;
cudaGetDevice(&devid);
cudaEventCreate(timerStart+devid);
cudaEventCreate(timerStop+devid);
cudaEventRecord(timerStart[devid],0);
return 0;
}
#else
static unsigned int timerRes;
#ifndef _WIN32
#if _POSIX_C_SOURCE >= 199309L
#include <time.h> // for nanosleep
#else
#include <unistd.h> // for usleep
#endif
#include <sys/time.h>
#include <string.h>
void SetupMillisTimer(void) {}
void CleanupMillisTimer(void) {}
long GetTime (void) {
struct timeval tv;
timerRes = 1000;
gettimeofday(&tv,NULL);
long temp = tv.tv_usec;
temp+=tv.tv_sec*1000000;
return temp;
}
unsigned int GetTimeMillis () {
return (unsigned int)(GetTime ()/1000);
}
unsigned int StartTimer () {
return GetTimeMillis();
}
#else
#include <windows.h>
#include <stdio.h>
/*
* GetTime --
*
* Returns the curent time (from some uninteresting origin) in usecs
* based on the performance counters.
*/
int GetTime(void)
{
static double cycles_per_usec;
LARGE_INTEGER counter;
if (cycles_per_usec == 0) {
static LARGE_INTEGER lFreq;
if (!QueryPerformanceFrequency(&lFreq)) {
fprintf(stderr, "Unable to read the performance counter frquency!\n");
return 0;
}
cycles_per_usec = 1000000 / ((double) lFreq.QuadPart);
}
if (!QueryPerformanceCounter(&counter)) {
fprintf(stderr,"Unable to read the performance counter!\n");
return 0;
}
return ((long) (((double) counter.QuadPart) * cycles_per_usec));
}
#pragma comment(lib,"winmm.lib")
unsigned int GetTimeMillis(void) {
return (unsigned int)timeGetTime();
}
/*
By default in 2000/XP, the timeGetTime call is set to some resolution
between 10-15 ms query for the range of value periods and then set timer
to the lowest possible. Note: MUST make call to corresponding
CleanupMillisTimer
*/
void SetupMillisTimer(void) {
TIMECAPS timeCaps;
timeGetDevCaps(&timeCaps, sizeof(TIMECAPS));
if (timeBeginPeriod(timeCaps.wPeriodMin) == TIMERR_NOCANDO) {
fprintf(stderr,"WARNING: Cannot set timer precision. Not sure what precision we're getting!\n");
}else {
timerRes = timeCaps.wPeriodMin;
fprintf(stderr,"(* Set timer resolution to %d ms. *)\n",timeCaps.wPeriodMin);
}
}
unsigned int StartTimer () {
SetupMillisTimer();
return 0;
}
void CleanupMillisTimer(void) {
if (timeEndPeriod(timerRes) == TIMERR_NOCANDO) {
fprintf(stderr,"WARNING: bad return value of call to timeEndPeriod.\n");
}
}
#endif
#endif
#ifdef _WIN32
#include <windows.h>
#elif _POSIX_C_SOURCE >= 199309L
#include <time.h> // for nanosleep
#else
#include <unistd.h> // for usleep
#endif
void sleep_ms(int milliseconds){ // cross-platform sleep function
#ifdef _WIN32
Sleep(milliseconds);
#elif _POSIX_C_SOURCE >= 199309L
struct timespec ts;
ts.tv_sec = milliseconds / 1000;
ts.tv_nsec = (milliseconds % 1000) * 1000000;
nanosleep(&ts, NULL);
#else
usleep(milliseconds * 1000);
#endif
}
|
/* -*- mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*- */
// Copyright © 2016 Associated Universities, Inc. Washington DC, USA.
//
// This file is part of vysmaw.
//
// vysmaw is free software: you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the Free Software
// Foundation, either version 3 of the License, or (at your option) any later
// version.
//
// vysmaw is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
// A PARTICULAR PURPOSE. See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along with
// vysmaw. If not, see <http://www.gnu.org/licenses/>.
//
#ifndef SPECTRUM_READER_H_
#define SPECTRUM_READER_H_
#include <vysmaw_private.h>
#include <vys_buffer_pool.h>
#include <vys_async_queue.h>
struct spectrum_reader_context {
vysmaw_handle handle;
struct vys_buffer_pool *signal_msg_buffers;
struct vys_async_queue *read_request_queue;
int loop_fd;
};
void *spectrum_reader(struct spectrum_reader_context *context);
#endif /* SPECTRUM_READER_H_ */
|
#import <Foundation/Foundation.h>
@interface NameFormatter : NSObject
@property (copy, nonatomic) NSString *title;
@property (copy, nonatomic) NSString *subtitle;
- (id)initWithName:(NSString *)name;
@end
|
/**
******************************************************************************
* @file DMA2D/DMA2D_MemToMemWithLCD/Inc/stm32f4xx_it.h
* @author MCD Application Team
* @version V1.1.0
* @date 17-February-2017
* @brief This file contains the headers of the interrupt handlers.
******************************************************************************
* @attention
*
* <h2><center>© COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of STMicroelectronics nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __STM32F4xx_IT_H
#define __STM32F4xx_IT_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
/* Exported macro ------------------------------------------------------------*/
/* Exported functions ------------------------------------------------------- */
void NMI_Handler(void);
void HardFault_Handler(void);
void MemManage_Handler(void);
void BusFault_Handler(void);
void UsageFault_Handler(void);
void SVC_Handler(void);
void DebugMon_Handler(void);
void PendSV_Handler(void);
void SysTick_Handler(void);
void DMA2D_IRQHandler(void);
void LTDC_IRQHandler(void);
void LTDC_ER_IRQHandler(void);
void DSI_IRQHandler(void);
#ifdef __cplusplus
}
#endif
#endif /* __STM32F4xx_IT_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
#ifndef PLUGINSSOURCELOADER_P_H
#define PLUGINSSOURCELOADER_P_H
#include <QObject>
#include <QStringList>
#include <QHash>
#include <QPair>
#include <QNetworkReply>
class Widget_PluginsSourceLoader;
class QNetworkAccessManager;
class QListWidgetItem;
class Dialog_NewPlugins;
class PluginsSourceLoader_P : public QObject
{
Q_OBJECT
friend class Widget_PluginsSourceLoader;
public:
signals:
public slots:
private:
QNetworkAccessManager *m__NetworkAM;
QStringList m__PluginPaths;
QHash<QString, QByteArray> m__PluginHash;
QByteArray nullHash;
QPair<QListWidgetItem *, QByteArray> currentUpdate;
bool isNewSource;
bool m__FullUpdate;
Dialog_NewPlugins *m__DialogNewPlugins;
explicit PluginsSourceLoader_P( Widget_PluginsSourceLoader *parent );
~PluginsSourceLoader_P();
Widget_PluginsSourceLoader * p_dptr() const;
QListWidgetItem * addPluginSource( const QUrl &source, bool newPluginsNotify = false );
void updatePluginSource( QListWidgetItem *pluginSource );
void parseXML( const QByteArray &xml );
void nextPluginSource();
private slots:
void replyFinished( QNetworkReply *reply );
void readyReadData();
void downloadProgress( qint64 current, qint64 overall );
void downloadError( QNetworkReply::NetworkError );
void newPluginsSelected();
};
#endif // PLUGINSSOURCELOADER_P_H
|
/* -*- c++ -*- */
/*
* Copyright 2009,2013 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
* GNU Radio is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* GNU Radio is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef INCLUDED_PMT_SUGAR_H
#define INCLUDED_PMT_SUGAR_H
/*!
* This file is included by pmt.h and contains pseudo-constructor
* shorthand for making pmt objects
*/
#include <ocvc/messages/msg_accepter.h>
namespace pmt {
//! Make pmt symbol
static inline pmt_t
mp(const std::string &s)
{
return string_to_symbol(s);
}
//! Make pmt symbol
static inline pmt_t
mp(const char *s)
{
return string_to_symbol(s);
}
//! Make pmt long
static inline pmt_t
mp(long x){
return from_long(x);
}
//! Make pmt long
static inline pmt_t
mp(long long unsigned x){
return from_long(x);
}
//! Make pmt long
static inline pmt_t
mp(int x){
return from_long(x);
}
//! Make pmt double
static inline pmt_t
mp(double x){
return from_double(x);
}
//! Make pmt complex
static inline pmt_t
mp(std::complex<double> z)
{
return make_rectangular(z.real(), z.imag());
}
//! Make pmt complex
static inline pmt_t
mp(std::complex<float> z)
{
return make_rectangular(z.real(), z.imag());
}
//! Make pmt msg_accepter
static inline pmt_t
mp(boost::shared_ptr<oc::messages::msg_accepter> ma)
{
return make_msg_accepter(ma);
}
//! Make pmt Binary Large Object (BLOB)
static inline pmt_t
mp(const void *data, size_t len_in_bytes)
{
return make_blob(data, len_in_bytes);
}
//! Make tuple
static inline pmt_t
mp(const pmt_t &e0)
{
return make_tuple(e0);
}
//! Make tuple
static inline pmt_t
mp(const pmt_t &e0, const pmt_t &e1)
{
return make_tuple(e0, e1);
}
//! Make tuple
static inline pmt_t
mp(const pmt_t &e0, const pmt_t &e1, const pmt_t &e2)
{
return make_tuple(e0, e1, e2);
}
//! Make tuple
static inline pmt_t
mp(const pmt_t &e0, const pmt_t &e1, const pmt_t &e2, const pmt_t &e3)
{
return make_tuple(e0, e1, e2, e3);
}
//! Make tuple
static inline pmt_t
mp(const pmt_t &e0, const pmt_t &e1, const pmt_t &e2, const pmt_t &e3, const pmt_t &e4)
{
return make_tuple(e0, e1, e2, e3, e4);
}
//! Make tuple
static inline pmt_t
mp(const pmt_t &e0, const pmt_t &e1, const pmt_t &e2, const pmt_t &e3, const pmt_t &e4, const pmt_t &e5)
{
return make_tuple(e0, e1, e2, e3, e4, e5);
}
//! Make tuple
static inline pmt_t
mp(const pmt_t &e0, const pmt_t &e1, const pmt_t &e2, const pmt_t &e3, const pmt_t &e4, const pmt_t &e5, const pmt_t &e6)
{
return make_tuple(e0, e1, e2, e3, e4, e5, e6);
}
//! Make tuple
static inline pmt_t
mp(const pmt_t &e0, const pmt_t &e1, const pmt_t &e2, const pmt_t &e3, const pmt_t &e4, const pmt_t &e5, const pmt_t &e6, const pmt_t &e7)
{
return make_tuple(e0, e1, e2, e3, e4, e5, e6, e7);
}
//! Make tuple
static inline pmt_t
mp(const pmt_t &e0, const pmt_t &e1, const pmt_t &e2, const pmt_t &e3, const pmt_t &e4, const pmt_t &e5, const pmt_t &e6, const pmt_t &e7, const pmt_t &e8)
{
return make_tuple(e0, e1, e2, e3, e4, e5, e6, e7, e8);
}
//! Make tuple
static inline pmt_t
mp(const pmt_t &e0, const pmt_t &e1, const pmt_t &e2, const pmt_t &e3, const pmt_t &e4, const pmt_t &e5, const pmt_t &e6, const pmt_t &e7, const pmt_t &e8, const pmt_t &e9)
{
return make_tuple(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9);
}
} /* namespace pmt */
#endif /* INCLUDED_PMT_SUGAR_H */
|
/*
* WARNING: do not edit!
* Generated by Makefile from include/openssl/opensslconf.h.in
*
* Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the OpenSSL license (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
* in the file LICENSE in the source distribution or at
* https://www.openssl.org/source/license.html
*/
#ifdef __cplusplus
extern "C" {
#endif
#ifdef OPENSSL_ALGORITHM_DEFINES
# error OPENSSL_ALGORITHM_DEFINES no longer supported
#endif
/*
* OpenSSL was configured with the following options:
*/
#ifndef OPENSSL_NO_CHACHA
# define OPENSSL_NO_CHACHA
#endif
#ifndef OPENSSL_NO_COMP
# define OPENSSL_NO_COMP
#endif
#ifndef OPENSSL_NO_IDEA
# define OPENSSL_NO_IDEA
#endif
#ifndef OPENSSL_NO_MD2
# define OPENSSL_NO_MD2
#endif
#ifndef OPENSSL_NO_RC5
# define OPENSSL_NO_RC5
#endif
#ifndef OPENSSL_NO_SRP
# define OPENSSL_NO_SRP
#endif
#ifndef OPENSSL_THREADS
# define OPENSSL_THREADS
#endif
#ifndef OPENSSL_NO_AFALGENG
# define OPENSSL_NO_AFALGENG
#endif
#ifndef OPENSSL_NO_APPS
# define OPENSSL_NO_APPS
#endif
#ifndef OPENSSL_NO_ASAN
# define OPENSSL_NO_ASAN
#endif
#ifndef OPENSSL_NO_ASM
# define OPENSSL_NO_ASM
#endif
#ifndef OPENSSL_NO_CAPIENG
# define OPENSSL_NO_CAPIENG
#endif
#ifndef OPENSSL_NO_CRYPTO_MDEBUG
# define OPENSSL_NO_CRYPTO_MDEBUG
#endif
#ifndef OPENSSL_NO_CRYPTO_MDEBUG_BACKTRACE
# define OPENSSL_NO_CRYPTO_MDEBUG_BACKTRACE
#endif
#ifndef OPENSSL_NO_DTLS
# define OPENSSL_NO_DTLS
#endif
#ifndef OPENSSL_NO_DTLS1
# define OPENSSL_NO_DTLS1
#endif
#ifndef OPENSSL_NO_DTLS1_2
# define OPENSSL_NO_DTLS1_2
#endif
#ifndef OPENSSL_NO_EC2M
# define OPENSSL_NO_EC2M
#endif
#ifndef OPENSSL_NO_EC_NISTP_64_GCC_128
# define OPENSSL_NO_EC_NISTP_64_GCC_128
#endif
#ifndef OPENSSL_NO_EGD
# define OPENSSL_NO_EGD
#endif
#ifndef OPENSSL_NO_ENGINE
# define OPENSSL_NO_ENGINE
#endif
#ifndef OPENSSL_NO_FUZZ_AFL
# define OPENSSL_NO_FUZZ_AFL
#endif
#ifndef OPENSSL_NO_FUZZ_LIBFUZZER
# define OPENSSL_NO_FUZZ_LIBFUZZER
#endif
#ifndef OPENSSL_NO_HEARTBEATS
# define OPENSSL_NO_HEARTBEATS
#endif
#ifndef OPENSSL_NO_HW
# define OPENSSL_NO_HW
#endif
#ifndef OPENSSL_NO_MSAN
# define OPENSSL_NO_MSAN
#endif
#ifndef OPENSSL_NO_PSK
# define OPENSSL_NO_PSK
#endif
#ifndef OPENSSL_NO_SCTP
# define OPENSSL_NO_SCTP
#endif
#ifndef OPENSSL_NO_SSL_TRACE
# define OPENSSL_NO_SSL_TRACE
#endif
#ifndef OPENSSL_NO_SSL3
# define OPENSSL_NO_SSL3
#endif
#ifndef OPENSSL_NO_SSL3_METHOD
# define OPENSSL_NO_SSL3_METHOD
#endif
#ifndef OPENSSL_NO_STDIO
# define OPENSSL_NO_STDIO
#endif
#ifndef OPENSSL_NO_TESTS
# define OPENSSL_NO_TESTS
#endif
#ifndef OPENSSL_NO_UBSAN
# define OPENSSL_NO_UBSAN
#endif
#ifndef OPENSSL_NO_UNIT_TEST
# define OPENSSL_NO_UNIT_TEST
#endif
#ifndef OPENSSL_NO_WEAK_SSL_CIPHERS
# define OPENSSL_NO_WEAK_SSL_CIPHERS
#endif
#ifndef OPENSSL_NO_AFALGENG
# define OPENSSL_NO_AFALGENG
#endif
/*
* Sometimes OPENSSSL_NO_xxx ends up with an empty file and some compilers
* don't like that. This will hopefully silence them.
*/
#define NON_EMPTY_TRANSLATION_UNIT static void *dummy = &dummy;
/*
* Applications should use -DOPENSSL_API_COMPAT=<version> to suppress the
* declarations of functions deprecated in or before <version>. Otherwise, they
* still won't see them if the library has been built to disable deprecated
* functions.
*/
#if defined(OPENSSL_NO_DEPRECATED)
# define DECLARE_DEPRECATED(f)
#elif __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 0)
# define DECLARE_DEPRECATED(f) f __attribute__ ((deprecated));
#else
# define DECLARE_DEPRECATED(f) f;
#endif
#ifndef OPENSSL_FILE
# ifdef OPENSSL_NO_FILENAMES
# define OPENSSL_FILE ""
# define OPENSSL_LINE 0
# else
# define OPENSSL_FILE __FILE__
# define OPENSSL_LINE __LINE__
# endif
#endif
#ifndef OPENSSL_MIN_API
# define OPENSSL_MIN_API 0
#endif
#if !defined(OPENSSL_API_COMPAT) || OPENSSL_API_COMPAT < OPENSSL_MIN_API
# undef OPENSSL_API_COMPAT
# define OPENSSL_API_COMPAT OPENSSL_MIN_API
#endif
#if OPENSSL_API_COMPAT < 0x10100000L
# define DEPRECATEDIN_1_1_0(f) DECLARE_DEPRECATED(f)
#else
# define DEPRECATEDIN_1_1_0(f)
#endif
#if OPENSSL_API_COMPAT < 0x10000000L
# define DEPRECATEDIN_1_0_0(f) DECLARE_DEPRECATED(f)
#else
# define DEPRECATEDIN_1_0_0(f)
#endif
#if OPENSSL_API_COMPAT < 0x00908000L
# define DEPRECATEDIN_0_9_8(f) DECLARE_DEPRECATED(f)
#else
# define DEPRECATEDIN_0_9_8(f)
#endif
/* Generate 80386 code? */
#undef I386_ONLY
#undef OPENSSL_UNISTD
#define OPENSSL_UNISTD <unistd.h>
#undef OPENSSL_EXPORT_VAR_AS_FUNCTION
/*
* The following are cipher-specific, but are part of the public API.
*/
#if !defined(OPENSSL_SYS_UEFI)
# undef BN_LLONG
/* Only one for the following should be defined */
# define SIXTY_FOUR_BIT_LONG
# undef SIXTY_FOUR_BIT
# undef THIRTY_TWO_BIT
#endif
#define RC4_INT unsigned char
#ifdef __cplusplus
}
#endif
|
/*
Encod_er.h - библиотека для обработки сигналов инкрементного энкодера параллельным процессом
Функция scanState() должна вызываться регулярно в параллельном процессе
timeRight - время/признак поворота энкодера вправо,
timeLeft - время/признак поворота энкодера влево, если = 0, то поворота не было
если = 0, то поворота не было
если не = 0, то содержит время последнего изменения / 8 периодов вызова scanState()
position - абсолютное положение энкодера
read() - чтение position
Библиотека разработана Калининым Эдуардом
http://mypractic.ru/
Уроки Ардуино, урок 55.
*/
// проверка, что библиотека еще не подключена
#ifndef Encod_er_h // если библиотека Button не подключена
#define Encod_er_h // тогда подключаем ее
#include "Arduino.h"
class Encod_er {
public:
Encod_er(byte pinA, byte pinB, byte timeFilter);
byte timeRight; // время/признак вращения вправо (* 8 периодов)
byte timeLeft; // время/признак вращения влево (* 8 периодов)
long position; // текущее положение энкодера
void scanState(); // метод проверки состояния энкодера
long read(); // метод чтения положения энкодера
private:
byte _pinA; // вывод сигнала A энкодера
byte _pinB; // вывод сигнала B энкодера
byte _countA; // счетчик фильтрации сигнала A энкодера
byte _countB; // счетчик фильтрации сигнала B энкодера
byte _timeFilter; // время подтверждения состояния сигнала
boolean _flagPressA; // признак состояния сигнала A
boolean _flagPressB; // признак состояния сигнала B
byte _changeEncCount; // счетчик времени переключения энкодера
byte _divChangecCount; // делитель счетчика времени переключения энкодера
};
#endif
|
#ifndef PLAYER_H
#define PLAYER_H
#include <QString>
class Player
{
private:
QString name;
bool bot;
public:
Player(QString _name);
QString getName();
bool getBot();
};
#endif // PLAYER_H
|
#ifndef SNESPALETTE_H
#define SNESPALETTE_H
#include <QRgb>
#include <QVector>
#include <QtGlobal>
// Snes color are encoded on 2 bytes, 0BBBBBGG GGGRRRRR
struct SNESColor
{
SNESColor();
quint16 snes;
QRgb rgb;
void setRgb(QRgb);
void setSNES(quint16);
quint16 approxSNES();
QRgb approxRGB();
};
class SNESPalette
{
public:
SNESPalette();
SNESPalette(quint8 mSize);
SNESPalette(QByteArray snesPal);
SNESPalette(QVector<QRgb>);
QByteArray encode();
quint8 size;
QVector<SNESColor> colors;
};
#endif // SNESPALETTE_H
|
/***
*sys/timeb.h - definition/declarations for _ftime()
*
* Copyright (c) Microsoft Corporation. All rights reserved.
*
*Purpose:
* This file define the _ftime() function and the types it uses.
* [System V]
*
* [Public]
*
****/
#if _MSC_VER > 1000
#pragma once
#endif
#ifndef _INC_TIMEB
#define _INC_TIMEB
#include <crtdefs.h>
#if !defined(_WIN32)
#error ERROR: Only Win32 target supported!
#endif
#ifdef _MSC_VER
#pragma pack(push,_CRT_PACKING)
#endif /* _MSC_VER */
#ifdef __cplusplus
extern "C" {
#endif
/* Define _CRTIMP */
#ifndef _CRTIMP
#ifdef _DLL
#define _CRTIMP __declspec(dllimport)
#else /* ndef _DLL */
#define _CRTIMP
#endif /* _DLL */
#endif /* _CRTIMP */
/* Define __cdecl for non-Microsoft compilers */
#if ( !defined(_MSC_VER) && !defined(__cdecl) )
#define __cdecl
#endif
#if !defined(_W64)
#if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300
#define _W64 __w64
#else
#define _W64
#endif
#endif
#ifdef _USE_32BIT_TIME_T
#ifdef _WIN64
#include <crtwrn.h>
#pragma _CRT_WARNING( _NO_32BIT_TIME_T )
#undef _USE_32BIT_TIME_T
#endif
#else
#if _INTEGRAL_MAX_BITS < 64
#define _USE_32BIT_TIME_T
#endif
#endif
#ifndef _TIME32_T_DEFINED
typedef _W64 long __time32_t; /* 32-bit time value */
#define _TIME32_T_DEFINED
#endif
#ifndef _TIME64_T_DEFINED
#if _INTEGRAL_MAX_BITS >= 64
typedef __int64 __time64_t; /* 64-bit time value */
#endif
#define _TIME64_T_DEFINED
#endif
#ifndef _TIME_T_DEFINED
#ifdef _USE_32BIT_TIME_T
typedef __time32_t time_t; /* time value */
#else
typedef __time64_t time_t; /* time value */
#endif
#define _TIME_T_DEFINED /* avoid multiple def's of time_t */
#endif
/* Structure returned by _ftime system call */
#ifndef _TIMEB_DEFINED
struct __timeb32 {
__time32_t time;
unsigned short millitm;
short timezone;
short dstflag;
};
#if !__STDC__
/* Non-ANSI name for compatibility */
struct timeb {
time_t time;
unsigned short millitm;
short timezone;
short dstflag;
};
#endif
#if _INTEGRAL_MAX_BITS >= 64
struct __timeb64 {
__time64_t time;
unsigned short millitm;
short timezone;
short dstflag;
};
#endif
#ifdef _USE_32BIT_TIME_T
#define _timeb __timeb32
#define _ftime _ftime32
#define _ftime_s _ftime32_s
#else
#define _timeb __timeb64
#define _ftime _ftime64
#define _ftime_s _ftime64_s
#endif
#define _TIMEB_DEFINED
#endif
#include <crtdefs.h>
/* Function prototypes */
_CRT_INSECURE_DEPRECATE(_ftime32_s) _CRTIMP void __cdecl _ftime32(__out struct __timeb32 * _Time);
_CRTIMP errno_t __cdecl _ftime32_s(__out struct __timeb32 * _Time);
#if _INTEGRAL_MAX_BITS >= 64
_CRT_INSECURE_DEPRECATE(_ftime64_s) _CRTIMP void __cdecl _ftime64(__out struct __timeb64 * _Time);
_CRTIMP errno_t __cdecl _ftime64_s(__out struct __timeb64 * _Time);
#endif
#if !defined(RC_INVOKED) && !defined(__midl)
#include <sys/timeb.inl>
#endif
#ifdef __cplusplus
}
#endif
#ifdef _MSC_VER
#pragma pack(pop)
#endif /* _MSC_VER */
#endif /* _INC_TIMEB */
|
//
//
// Generated by StarUML(tm) C++ Add-In
//
// @ Project : Untitled
// @ File Name : StaticData.h
// @ Date : 2017/9/29
// @ Author : ouo
//
//
#if !defined(_STATICDATA_H)
#define _STATICDATA_H
class StaticData {
public:
static StaticData sharedStaticData();
static viod purge();
int intValueFormKey(std::string key);
char stringValueFromKey(std::string key);
float floatValueFromKey(std::string key);
bool booleanFromKey(std::string key);
cocos2d::CCPoint pointFromKey(std::string key);
cocos2d::CCRect rectFromKey(std::string key);
cocos2d::CCSize sizeFromKey(std::string key);
protected:
const cocos2d::CCDictionary _dictionary;
std::string _staticFileName;
bool init();
private:
~StaticData();
StaticData();
};
#endif //_STATICDATA_H
|
#pragma once
#include "alarmHandler.h"
#include "trans.h"
#include "file.h"
#include "time.h"
#define ALARM_NUM 6
void alarm_load()
{
for (int i = 0; i < ALARM_NUM; i++)
{
char c[] = "ALARM_0.txt";
c[6] = i + 48;
if (SD.exists(c))
{
Serial.print(c);
Serial.println(" exists.");
myFile = SD.open(c);
alarms[i].openOrNot = (bool)(strToInt(myFile.readStringUntil('\n')));
String modeStr = myFile.readStringUntil('\n');
for (int j = 0; j < 7; j++)
alarms[i].mode[j] = (bool)(modeStr[j] - 48);
alarms[i].repeatOrNot = (bool)(strToInt(myFile.readStringUntil('\n')));
alarms[i].h = (byte)(strToInt(myFile.readStringUntil('\n')));
alarms[i].m = (byte)(strToInt(myFile.readStringUntil('\n')));
alarms[i].repeatAllow = 1;
if (alarms[i].repeatOrNot)
alarms[i].repeatOnce = alarms[i].repeatTwice = 1;
else
alarms[i].repeatOnce = alarms[i].repeatTwice = 0;
// Serial.print(alarms[i].openOrNot);
// Serial.print(" ");
// Serial.print(alarms[i].repeatOrNot);
// Serial.print(" ");
// Serial.print(modeStr);
// Serial.print(" ");
// Serial.print(alarms[i].h);
// Serial.print(" ");
// Serial.print(alarms[i].m);
// Serial.print(" ");
// Serial.print(alarms[i].repeatAllow);
// Serial.print(" ");
// Serial.print(alarms[i].repeatOnce);
// Serial.print(" ");
// Serial.println(alarms[i].repeatTwice);
myFile.close();
}
// else
// {
// Serial.print(c);
// Serial.println(" doesn't exist.");
// }
}
}
void alarm_check()
{
for (int i = 0; i < ALARM_NUM; i++)
{
bool onAlarm = false;
if (!alarms[i].openOrNot || !alarms[i].repeatAllow)
continue;
if (time_compare(alarms[i].h, alarms[i].m, weekday(now()) * alarms[i].mode[weekday(now()) - 1]))
{
onAlarm = true;
}
else if (alarms[i].repeatOrNot)
{
if (alarms[i].repeatOnce && time_compare(alarms[i].h, alarms[i].m, weekday(now()) * alarms[i].mode[weekday(now()) - 1], 1) )
{
// Serial.print(alarms[i].repeatOrNot);
// Serial.println(" repeat detect 1");
alarms[i].repeatOnce = 0;
onAlarm = true;
alarmHandler.reset_tone_now();
}
else if (alarms[i].repeatTwice && time_compare(alarms[i].h, alarms[i].m, weekday(now()) * alarms[i].mode[weekday(now()) - 1], 2) )
{
// Serial.println(" repeat detect 2");
alarms[i].repeatTwice = 0;
onAlarm = true;
alarmHandler.reset_tone_now();
}
}
if (onAlarm && alarmHandler.get_tone_now() != i)
{
// Serial.print(alarmHandler.get_tone_now());
// Serial.print(" alarm tone No: ");
// Serial.println(i);
alarmHandler.start_alarm(i);
}
}
}
|
#include "global.h"
//ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
// Detection of available video modes
//ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
/*
struct _modos {
short ancho;
short alto;
short modo;
};
struct _modos modos[32];
int num_modos;
int VersionVesa;
char marcavga[128];
*/
//ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
int compare_mode(void const *aa, void const *bb) {
short *a,*b;
a=(short*)aa;
b=(short*)bb;
return((int)(*a)*10000+*(a+1)>(int)(*b)*10000+*(b+1));
}
void detectar_vesa(void) { // Detects available video modes
short *modelist;
int n;
OSDEP_VMode **modes;
int i;
num_modos=0;
modes=OSDEP_ListModes();
/* Check is there are any modes available */
if(modes == 0 || modes == -1) {
// none, just list some standard ones for use in windowed mode.
modos[0].ancho=320; modos[0].alto=240; modos[0].modo=1;
modos[1].ancho=640; modos[1].alto=480; modos[1].modo=1;
modos[2].ancho=800; modos[2].alto=600; modos[2].modo=1;
modos[3].ancho=1024; modos[3].alto=768; modos[3].modo=1;
modos[4].ancho=1280; modos[4].alto=1024; modos[4].modo=1;
modos[5].ancho=1920; modos[5].alto=1080; modos[5].modo=1;
modos[6].ancho=1280; modos[6].alto=720; modos[6].modo=1;
modos[7].ancho=376; modos[7].alto=282; modos[7].modo=1;
} else {
for(i=0;modes[i];++i) {
modos[i].ancho=modes[i]->w; modos[i].alto=modes[i]->h; modos[i].modo=1;
}
num_modos=i-1;
}
sprintf(marcavga,"SDL Video Driver");
qsort((void*)&(modos[0].ancho),num_modos,sizeof(struct _modos),compare_mode);
}
|
/* Copyright (C) 2015 William Breathitt Gray
*
* This file is part of Mission Accomplished.
*
* Mission Accomplished is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* Mission Accomplished is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Mission Accomplished. If not, see
* <http://www.gnu.org/licenses/>.
*/
#ifndef TEXTURE_H
#define TEXTURE_H
#include "SDL.h"
struct Texture{
SDL_Texture *texture;
Texture(SDL_Renderer *renderer, const char *file);
~Texture();
Texture(const Texture&) = delete;
Texture& operator=(const Texture&) = delete;
Texture(Texture&&) = delete;
Texture& operator=(Texture&&) = delete;
};
#endif
|
/*
* pathfinder.h - Path finder functions
*
* Copyright (C) 2012 Jon Lund Steffensen <jonlst@gmail.com>
*
* This file is part of freeserf.
*
* freeserf is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* freeserf is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with freeserf. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SRC_PATHFINDER_H_
#define SRC_PATHFINDER_H_
#include "src/map.h"
road_t pathfinder_map(map_t *map, map_pos_t start, map_pos_t end);
#endif // SRC_PATHFINDER_H_
|
/*****************************************************************************
*
* Monitoring check_users plugin
*
* License: GPL
* Copyright (c) 2000-2012 Monitoring Plugins Development Team
*
* Description:
*
* This file contains the check_users plugin
*
* This plugin checks the number of users currently logged in on the local
* system and generates an error if the number exceeds the thresholds
* specified.
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*
*****************************************************************************/
const char *progname = "check_users";
const char *copyright = "2000-2007";
const char *email = "devel@monitoring-plugins.org";
#include "common.h"
#include "utils.h"
#if HAVE_UTMPX_H
# include <utmpx.h>
#else
# include "popen.h"
#endif
#define possibly_set(a,b) ((a) == 0 ? (b) : 0)
int process_arguments (int, char **);
void print_help (void);
void print_usage (void);
int wusers = -1;
int cusers = -1;
int
main (int argc, char **argv)
{
int users = -1;
int result = STATE_UNKNOWN;
char *perf;
#if HAVE_UTMPX_H
struct utmpx *putmpx;
#else
char input_buffer[MAX_INPUT_BUFFER];
#endif
setlocale (LC_ALL, "");
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
perf = strdup ("");
/* Parse extra opts if any */
argv = np_extra_opts (&argc, argv, progname);
if (process_arguments (argc, argv) == ERROR)
usage4 (_("Could not parse arguments"));
users = 0;
#if HAVE_UTMPX_H
/* get currently logged users from utmpx */
setutxent ();
while ((putmpx = getutxent ()) != NULL)
if (putmpx->ut_type == USER_PROCESS)
users++;
endutxent ();
#else
/* run the command */
child_process = spopen (WHO_COMMAND);
if (child_process == NULL) {
printf (_("Could not open pipe: %s\n"), WHO_COMMAND);
return STATE_UNKNOWN;
}
child_stderr = fdopen (child_stderr_array[fileno (child_process)], "r");
if (child_stderr == NULL)
printf (_("Could not open stderr for %s\n"), WHO_COMMAND);
while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process)) {
/* increment 'users' on all lines except total user count */
if (input_buffer[0] != '#') {
users++;
continue;
}
/* get total logged in users */
if (sscanf (input_buffer, _("# users=%d"), &users) == 1)
break;
}
/* check STDERR */
if (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_stderr))
result = possibly_set (result, STATE_UNKNOWN);
(void) fclose (child_stderr);
/* close the pipe */
if (spclose (child_process))
result = possibly_set (result, STATE_UNKNOWN);
#endif
/* check the user count against warning and critical thresholds */
if (users > cusers)
result = STATE_CRITICAL;
else if (users > wusers)
result = STATE_WARNING;
else if (users >= 0)
result = STATE_OK;
if (result == STATE_UNKNOWN)
printf ("%s\n", _("Unable to read output"));
else {
xasprintf (&perf, "%s", perfdata ("users", users, "",
TRUE, wusers,
TRUE, cusers,
TRUE, 0,
FALSE, 0));
printf (_("USERS %s - %d users currently logged in |%s\n"), state_text (result),
users, perf);
}
return result;
}
/* process command-line arguments */
int
process_arguments (int argc, char **argv)
{
int c;
int option = 0;
static struct option longopts[] = {
{"critical", required_argument, 0, 'c'},
{"warning", required_argument, 0, 'w'},
{"version", no_argument, 0, 'V'},
{"help", no_argument, 0, 'h'},
{0, 0, 0, 0}
};
if (argc < 2)
usage ("\n");
while (1) {
c = getopt_long (argc, argv, "+hVvc:w:", longopts, &option);
if (c == -1 || c == EOF || c == 1)
break;
switch (c) {
case '?': /* print short usage statement if args not parsable */
usage5 ();
case 'h': /* help */
print_help ();
exit (STATE_OK);
case 'V': /* version */
print_revision (progname, NP_VERSION);
exit (STATE_OK);
case 'c': /* critical */
if (!is_intnonneg (optarg))
usage4 (_("Critical threshold must be a positive integer"));
else
cusers = atoi (optarg);
break;
case 'w': /* warning */
if (!is_intnonneg (optarg))
usage4 (_("Warning threshold must be a positive integer"));
else
wusers = atoi (optarg);
break;
}
}
c = optind;
if (wusers == -1 && argc > c) {
if (is_intnonneg (argv[c]) == FALSE)
usage4 (_("Warning threshold must be a positive integer"));
else
wusers = atoi (argv[c++]);
}
if (cusers == -1 && argc > c) {
if (is_intnonneg (argv[c]) == FALSE)
usage4 (_("Warning threshold must be a positive integer"));
else
cusers = atoi (argv[c]);
}
return OK;
}
void
print_help (void)
{
print_revision (progname, NP_VERSION);
printf ("Copyright (c) 1999 Ethan Galstad\n");
printf (COPYRIGHT, copyright, email);
printf ("%s\n", _("This plugin checks the number of users currently logged in on the local"));
printf ("%s\n", _("system and generates an error if the number exceeds the thresholds specified."));
printf ("\n\n");
print_usage ();
printf (UT_HELP_VRSN);
printf (UT_EXTRA_OPTS);
printf (" %s\n", "-w, --warning=INTEGER");
printf (" %s\n", _("Set WARNING status if more than INTEGER users are logged in"));
printf (" %s\n", "-c, --critical=INTEGER");
printf (" %s\n", _("Set CRITICAL status if more than INTEGER users are logged in"));
printf (UT_SUPPORT);
}
void
print_usage (void)
{
printf ("%s\n", _("Usage:"));
printf ("%s -w <users> -c <users>\n", progname);
}
|
/*
* Cppcheck - A tool for static C/C++ code analysis
* Copyright (C) 2007-2021 Cppcheck team.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef analyzerH
#define analyzerH
#include <string>
#include <vector>
class Token;
template<class T>
class ValuePtr;
struct Analyzer {
struct Action {
Action() : mFlag(0) {}
// cppcheck-suppress noExplicitConstructor
Action(unsigned int f) : mFlag(f) {}
enum {
None = 0,
Read = (1 << 0),
Write = (1 << 1),
Invalid = (1 << 2),
Inconclusive = (1 << 3),
Match = (1 << 4),
Idempotent = (1 << 5),
Incremental = (1 << 6),
SymbolicMatch = (1 << 7),
};
void set(unsigned int f, bool state = true) {
mFlag = state ? mFlag | f : mFlag & ~f;
}
bool get(unsigned int f) const {
return ((mFlag & f) != 0);
}
bool isRead() const {
return get(Read);
}
bool isWrite() const {
return get(Write);
}
bool isInvalid() const {
return get(Invalid);
}
bool isInconclusive() const {
return get(Inconclusive);
}
bool isNone() const {
return mFlag == None;
}
bool isModified() const {
return isWrite() || isInvalid();
}
bool isIdempotent() const {
return get(Idempotent);
}
bool isIncremental() const {
return get(Incremental);
}
bool isSymbolicMatch() const {
return get(SymbolicMatch);
}
bool matches() const {
return get(Match);
}
Action& operator|=(Action a) {
set(a.mFlag);
return *this;
}
friend Action operator|(Action a, Action b) {
a |= b;
return a;
}
friend bool operator==(Action a, Action b) {
return a.mFlag == b.mFlag;
}
friend bool operator!=(Action a, Action b) {
return a.mFlag != b.mFlag;
}
private:
unsigned int mFlag;
};
enum class Terminate { None, Bail, Escape, Modified, Inconclusive, Conditional };
struct Result {
Result(Action action = Action::None, Terminate terminate = Terminate::None)
: action(action), terminate(terminate)
{}
Action action;
Terminate terminate;
void update(Result rhs) {
if (terminate == Terminate::None)
terminate = rhs.terminate;
action |= rhs.action;
}
};
enum class Direction { Forward, Reverse };
struct Assume {
enum Flags {
None = 0,
Quiet = (1 << 0),
Absolute = (1 << 1),
ContainerEmpty = (1 << 2),
};
};
enum class Evaluate { Integral, ContainerEmpty };
/// Analyze a token
virtual Action analyze(const Token* tok, Direction d) const = 0;
/// Update the state of the value
virtual void update(Token* tok, Action a, Direction d) = 0;
/// Try to evaluate the value of a token(most likely a condition)
virtual std::vector<int> evaluate(Evaluate e, const Token* tok, const Token* ctx = nullptr) const = 0;
std::vector<int> evaluate(const Token* tok, const Token* ctx = nullptr) const {
return evaluate(Evaluate::Integral, tok, ctx);
}
/// Lower any values to possible
virtual bool lowerToPossible() = 0;
/// Lower any values to inconclusive
virtual bool lowerToInconclusive() = 0;
/// If the analysis is unsure whether to update a scope, this will return true if the analysis should bifurcate the scope
virtual bool updateScope(const Token* endBlock, bool modified) const = 0;
/// Called when a scope will be forked
virtual void forkScope(const Token* /*endBlock*/) {}
/// If the value is conditional
virtual bool isConditional() const = 0;
/// The condition that will be assumed during analysis
virtual void assume(const Token* tok, bool state, unsigned int flags = 0) = 0;
/// Return analyzer for expression at token
virtual ValuePtr<Analyzer> reanalyze(Token* tok, const std::string& msg = "") const = 0;
virtual ~Analyzer() {}
};
#endif
|
#include "afxwin.h"
#if !defined(AFX_PROGRAMSETTINGDLG_H__BED04C03_751D_4A93_A586_91AE8D148155__INCLUDED_)
#define AFX_PROGRAMSETTINGDLG_H__BED04C03_751D_4A93_A586_91AE8D148155__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// ProgramSettingDlg.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CProgramSettingDlg dialog
class CProgramSettingDlg : public CDialog
{
// Construction
public:
CProgramSettingDlg(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CProgramSettingDlg)
enum { IDD = IDD_DLG_PROGRAM_SET };
CString m_OutputLocation;
double m_cellSize_dx;
double m_cellSize_dy;
double m_cellSize_dz;
int m_enlarge;
int m_raypx;
int m_raypy;
BOOL m_ifoutputbox;
BOOL m_iflogvolume;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CProgramSettingDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
virtual BOOL PreTranslateMessage(MSG* pMsg);
// Generated message map functions
//{{AFX_MSG(CProgramSettingDlg)
virtual BOOL OnInitDialog();
afx_msg void OnBtnImage();
afx_msg void OnBtnDefault();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
public:
bool flagDisableControls;
int m_LimitEle;
CButton ctrl_cube_dx;
CButton ctrl_logfile;
CButton ctrl_VgsTAR;
CButton ctrl_btn_default;
CButton ctrl_btn_ok;
int m_distribution;
BOOL check_cube_value;
CEdit ctrl_dy;
CEdit ctrl_dx;
CEdit ctrl_dz;
CEdit ctrl_zone_type;
CEdit ctrl_output_location;
//int lapx;
//CEdit ctrl_lapy;
//int lapy;
//CEdit ctrl_lapx;
CEdit ctrl_gpx;
CEdit ctrl_gpy;
int gpx;
int gpy;
int gap_option;
CStatic ctrl_G_spherical;
CComboBox ctrl_leaf_distribution;
int m_leaf_distribution;
void SetShow();
int gap_average_option;
CEdit ctrl_MA;
CStatic ctrl_deg;
CButton ctrl_browse;
CEdit ctrl_dis_file;
CString CurrentPath;
double m_mean_leaf_inc;
CString m_dis_file;
int ZeroGapManage;
double minimumGap;
bool IfSetMaxLAD;
double MaxLAD;
int m_leaf_dispersion_option;
double m_leaf_dispersion;
double fix_pza;
double default_pza;
//Variable added for subdivision of PZA
BOOL is_divide_pza;
int division_horizontal;
int division_vertical;
afx_msg void OnBnClickedBtnAdvance();
afx_msg void OnBnClickedBrowse();
afx_msg void OnBnClickedOk();
afx_msg void OnCbnSelchangeComboLdistribution();
afx_msg void OnEnChangeEditCellsizeX();
afx_msg void OnBnClickedCheck5();
void DisableAll();
void DisableBtnOK();
double m_mean_leaf_area;
int m_inversion_method;
CButton ctrl_inversion_method;
CEdit ctrlLeafArea;
afx_msg void OnBnClickedRadio1();
void SetctrlLeafArea();
afx_msg void OnBnClickedRadio2();
afx_msg void OnBnClickedRadio3();
BOOL m_ChkLAD;
afx_msg void OnBnClickedButton1();
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_PROGRAMSETTINGDLG_H__BED04C03_751D_4A93_A586_91AE8D148155__INCLUDED_)
|
/*
* Copyright (C) 2008, 2009, 2010 The Collaborative Software Foundation.
*
* This file is part of FeedHandlers (FH).
*
* FH is free software: you can redistribute it and/or modify it under the terms of the
* GNU Lesser General Public License as published by the Free Software Foundation, either version 3
* of the License, or (at your option) any later version.
*
* FH is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with FH. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* System includes
*/
#include <stdio.h>
#include <pthread.h>
#include <string.h>
#include <errno.h>
/*
* FH Common includes
*/
#include "fh_log.h"
/*
* OPRA includes
*/
#include "fh_opra_topic.h"
/*
* OPRA Topic format API
*/
FH_STATUS fh_opra_topic_fmt(fh_opra_topic_fmt_t *tfmt, fh_opra_opt_key_t *k,
char *topic, uint32_t length)
{
register uint32_t i = 0;
register uint32_t j = 0;
for (i = 0; i < tfmt->tfmt_num_stanzas && j < length; i++) {
register char *ptr = tfmt->tfmt_stanza_fmts[i];
if (ptr == NULL) {
FH_LOG(MGMT, ERR, ("Topic format is missing stanza[%d]", i));
return FH_ERROR;
}
FH_LOG(MGMT, DIAG, ("Topic format stanza[%d] = '%s'", i, ptr));
while (*ptr != '\0' && j < length) {
if (*ptr != '$') {
topic[j++] = *ptr++;
}
else {
ptr++;
if (*ptr == '\0') {
FH_LOG(MGMT, ERR, ("Invalid topic format: stanza[%d] = '%s'",
i, tfmt->tfmt_stanza_fmts[i]));
}
switch (*ptr++) {
case FH_OPRA_TOPIC_FMT_SYMBOL:
{
register char *uptr = k->k_symbol;
register int count = 0;
while (*uptr != '\0' && count++ < FH_OPRA_TOPIC_MAX_SYMBOL && j < length) {
topic[j++] = *uptr++;
}
}
break;
case FH_OPRA_TOPIC_FMT_YEAR:
{
sprintf(&topic[j], "%.2u", k->k_year);
j += 2;
}
break;
case FH_OPRA_TOPIC_FMT_MONTH:
{
sprintf(&topic[j], "%.2u", k->k_month);
j += 2;
}
break;
case FH_OPRA_TOPIC_FMT_DAY:
{
sprintf(&topic[j], "%.2u", k->k_day);
j += 2;
}
break;
case FH_OPRA_TOPIC_FMT_PUTCALL:
{
topic[j++] = k->k_putcall;
}
break;
case FH_OPRA_TOPIC_FMT_DECIMAL:
{
sprintf(&topic[j], "%.5u", k->k_decimal);
j += 5;
}
break;
case FH_OPRA_TOPIC_FMT_FRACTION:
{
sprintf(&topic[j], "%.3u", k->k_fraction * 1000);
j += 3;
}
break;
case FH_OPRA_TOPIC_FMT_EXCH:
{
topic[j++] = k->k_exchid;
}
break;
default:
FH_LOG(MGMT, ERR, ("Invalid topic format variable: $%c - stanza[%d] = '%s'",
*ptr, i, tfmt->tfmt_stanza_fmts[i]));
FH_ASSERT(1);
}
}
}
if (j < length && (i+1) != tfmt->tfmt_num_stanzas) {
topic[j++] = tfmt->tfmt_stanza_delim;
}
}
if (j == length) {
topic[j-1] = '\0';
FH_LOG(MGMT, ERR, ("Topic too long (len:%d): topic: %s", topic));
return FH_ERROR;
}
topic[j] = '\0';
FH_LOG(MGMT, DIAG, ("Topic formatted successfully: topic: %s (len:%d)", topic, j));
return FH_OK;
}
|
/*
* Copyright (C) 2012 Alexandr Vodiannikov aka "Aleksoid1978" (Aleksoid1978@mail.ru)
*
* This file is part of WinnerMediaPlayer.
*
* WinnerMediaPlayer is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* WinnerMediaPlayer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#pragma once
class CPreView : public CWnd
{
public:
CPreView();
virtual ~CPreView();
DECLARE_DYNAMIC(CPreView)
virtual BOOL SetWindowText(LPCWSTR lpString);
void GetVideoRect(LPRECT lpRect);
HWND GetVideoHWND();
COLORREF RGBFill(int r1, int g1, int b1, int r2, int g2, int b2, int i, int k);
protected:
CString tooltipstr;
CWnd m_view;
int wb;
int hc;
CRect v_rect;
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnPaint();
DECLARE_MESSAGE_MAP()
};
|
#define SYSTEM_APP_EB 1 //embedded
#define SYSTEM_APP_BB 0 //baseband only
extern bdata unsigned char system_config_flag;
extern bit system_app_fg;
|
#include "dietstdio.h"
char *fgets_unlocked(char *s, int size, FILE *stream) {
int l;
for (l=0; l<size; ) {
register int c;
if (l && __likely(stream->bm<stream->bs)) {
/* try common case first */
c=(unsigned char)stream->buf[stream->bm++];
} else {
c=fgetc_unlocked(stream);
if (__unlikely(c==EOF)) {
if (!l) return 0;
goto fini;
}
}
s[l]=c;
++l;
if (c=='\n') {
fini:
s[l]=0;
return s;
}
}
return 0;
}
char*fgets(char*s,int size,FILE*stream) __attribute__((weak,alias("fgets_unlocked")));
|
/* ide-autotools-autogen-stage.c
*
* Copyright 2016-2019 Christian Hergert <chergert@redhat.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#define G_LOG_DOMAIN "ide-autotools-autogen-stage"
#include "ide-autotools-autogen-stage.h"
struct _IdeAutotoolsAutogenStage
{
IdePipelineStage parent_instance;
gchar *srcdir;
};
G_DEFINE_FINAL_TYPE (IdeAutotoolsAutogenStage, ide_autotools_autogen_stage, IDE_TYPE_PIPELINE_STAGE)
enum {
PROP_0,
PROP_SRCDIR,
N_PROPS
};
static GParamSpec *properties [N_PROPS];
static void
ide_autotools_autogen_stage_wait_check_cb (GObject *object,
GAsyncResult *result,
gpointer user_data)
{
IdeSubprocess *subprocess = (IdeSubprocess *)object;
g_autoptr(IdeTask) task = user_data;
g_autoptr(GError) error = NULL;
g_assert (IDE_IS_SUBPROCESS (subprocess));
g_assert (IDE_IS_TASK (task));
if (!ide_subprocess_wait_check_finish (subprocess, result, &error))
ide_task_return_error (task, g_steal_pointer (&error));
else
ide_task_return_boolean (task, TRUE);
}
static void
ide_autotools_autogen_stage_build_async (IdePipelineStage *stage,
IdePipeline *pipeline,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
IdeAutotoolsAutogenStage *self = (IdeAutotoolsAutogenStage *)stage;
g_autofree gchar *autogen_path = NULL;
g_autoptr(IdeSubprocessLauncher) launcher = NULL;
g_autoptr(IdeSubprocess) subprocess = NULL;
g_autoptr(IdeTask) task = NULL;
g_autoptr(GError) error = NULL;
g_assert (IDE_IS_AUTOTOOLS_AUTOGEN_STAGE (self));
g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));
task = ide_task_new (self, cancellable, callback, user_data);
ide_task_set_source_tag (task, ide_autotools_autogen_stage_build_async);
autogen_path = g_build_filename (self->srcdir, "autogen.sh", NULL);
launcher = ide_pipeline_create_launcher (pipeline, &error);
if (launcher == NULL)
{
ide_task_return_error (task, g_steal_pointer (&error));
return;
}
ide_subprocess_launcher_set_cwd (launcher, self->srcdir);
if (g_file_test (autogen_path, G_FILE_TEST_IS_REGULAR))
{
ide_subprocess_launcher_push_argv (launcher, autogen_path);
ide_subprocess_launcher_setenv (launcher, "NOCONFIGURE", "1", TRUE);
}
else
{
ide_subprocess_launcher_push_argv (launcher, "autoreconf");
ide_subprocess_launcher_push_argv (launcher, "-fiv");
}
subprocess = ide_subprocess_launcher_spawn (launcher, cancellable, &error);
if (subprocess == NULL)
{
ide_task_return_error (task, g_steal_pointer (&error));
return;
}
ide_pipeline_stage_log_subprocess (stage, subprocess);
ide_subprocess_wait_check_async (subprocess,
cancellable,
ide_autotools_autogen_stage_wait_check_cb,
g_steal_pointer (&task));
}
static gboolean
ide_autotools_autogen_stage_build_finish (IdePipelineStage *stage,
GAsyncResult *result,
GError **error)
{
g_assert (IDE_IS_AUTOTOOLS_AUTOGEN_STAGE (stage));
g_assert (IDE_IS_TASK (result));
return ide_task_propagate_boolean (IDE_TASK (result), error);
}
static void
ide_autotools_autogen_stage_finalize (GObject *object)
{
IdeAutotoolsAutogenStage *self = (IdeAutotoolsAutogenStage *)object;
g_clear_pointer (&self->srcdir, g_free);
G_OBJECT_CLASS (ide_autotools_autogen_stage_parent_class)->finalize (object);
}
static void
ide_autotools_autogen_stage_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
IdeAutotoolsAutogenStage *self = (IdeAutotoolsAutogenStage *)object;
switch (prop_id)
{
case PROP_SRCDIR:
self->srcdir = g_value_dup_string (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void
ide_autotools_autogen_stage_class_init (IdeAutotoolsAutogenStageClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
IdePipelineStageClass *stage_class = IDE_PIPELINE_STAGE_CLASS (klass);
object_class->finalize = ide_autotools_autogen_stage_finalize;
object_class->set_property = ide_autotools_autogen_stage_set_property;
stage_class->build_async = ide_autotools_autogen_stage_build_async;
stage_class->build_finish = ide_autotools_autogen_stage_build_finish;
properties [PROP_SRCDIR] =
g_param_spec_string ("srcdir", NULL, NULL, NULL,
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, N_PROPS, properties);
}
static void
ide_autotools_autogen_stage_init (IdeAutotoolsAutogenStage *self)
{
}
|
/*! @file EndEffectorTouch.h
@brief Declaration of a class to handle pressure data for end effectors
@author Jason Kulk
@class EndEffectorTouch
@brief A class to handle pressure data of end effectors to produce soft sensor data.
In particular, this class can calculate the following:
- Total force on the end effector
- Whether the end effector is in contact with something
- Whether the end effector is supporting the weight of the robot
- The time of the last impact with an object
- The centre of pressure
The related kinematic class EndEffector calculates the end effector's position and rotation.
@author Jason Kulk
Copyright (c) 2009, 2010, 2011 Jason Kulk
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with NUbot. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ENDEFFECTOR_TOUCH_H
#define ENDEFFECTOR_TOUCH_H
#include "Infrastructure/NUData.h"
#include <vector>
class EndEffectorTouch
{
public:
EndEffectorTouch();
~EndEffectorTouch();
void calculate();
private:
void calculate(const NUData::id_t& endeffector);
void invalidate(const NUData::id_t& endeffector);
void calculateForce(const NUData::id_t& endeffector);
void calculateContact(const NUData::id_t& endeffector);
void calculateCentreOfPressure(const NUData::id_t& endeffector);
void calculateSupport(const NUData::id_t &endeffector);
void getHull(const NUData::id_t& endeffector, std::vector<std::vector<float> >& hull);
private:
std::vector<float> m_touch_data; //!< the current touch data we are working with
int m_id_offset;
std::vector<float> m_min_forces; //!< the min forces on each of the end effectors
std::vector<float> m_max_forces; //!< the max forces on each of the end effectors
std::vector<std::vector<std::vector<float> > > m_hulls; //!< the convex hulls for each of the end effectors [[[x,y],...,[x,y]],...,]
float m_Nan; //!< the value used to represent invalid data
std::vector<float> m_Nan_all; //!< the std::vector to invalidate all of the touch sensor
};
#endif
|
// DirImage.h : Collection of images from directory
//------------------------------------------------------------------------------
// Copyright (c) 2016 Anatoly madRat L. Berenblit
//------------------------------------------------------------------------------
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//------------------------------------------------------------------------------
#ifndef __DirImage_H__
#define __DirImage_H__
#include <vector>
#include <string>
#include "MultipageImage.h"
class DirImage : public MultipageImage
{
public:
typedef MultipageImage baseClass;
public:
DirImage(const char *filename);
DirImage(size_t count, const char *filenames[]);
virtual ~DirImage();
virtual size_t num_pages() const;
virtual size_t page() const;
virtual const char* name() const;
virtual bool page(size_t page);
virtual size_t w() const;
virtual size_t h() const;
virtual Fl_Image *copy(int w, int h);
protected:
static bool isCompatible(const char *name);
bool reset(Fl_Image *source);
bool load(const char *filename);
bool load(size_t index);
void enum_files() const;
std::string filename_;
Fl_Image *source_;
mutable std::vector<std::string> files_;
mutable size_t page_;
};
#endif //#ifndef DirImage_H
|
/* Flexiport
*
* Header file for some types that are not defined on Windows.
*
* Copyright 2008-2011 Geoffrey Biggs geoffrey.biggs@aist.go.jp
* RT-Synthesis Research Group
* Intelligent Systems Research Institute,
* National Institute of Advanced Industrial Science and Technology (AIST),
* Japan
* All rights reserved.
*
* This file is part of Flexiport.
*
* Flexiport is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation; either version 2.1 of the License,
* or (at your option) any later version.
*
* Flexiport is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with Flexiport. If not, see
* <http://www.gnu.org/licenses/>.
*/
#ifndef __FLEXIPORT_TYPES_H
#define __FLEXIPORT_TYPES_H
#if defined (WIN32)
typedef unsigned char uint8_t;
typedef unsigned int uint32_t;
#if defined (_WIN64)
typedef __int64 ssize_t;
#else
typedef _W64 int ssize_t;
#endif
#else
#include <stdint.h>
#include <sys/types.h>
#endif
#endif // __FLEXIPORT_TYPES_H
|
/*******************************************************************************
OpenAirInterface
Copyright(c) 1999 - 2014 Eurecom
OpenAirInterface is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenAirInterface is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenAirInterface.The full GNU General Public License is
included in this distribution in the file called "COPYING". If not,
see <http://www.gnu.org/licenses/>.
Contact Information
OpenAirInterface Admin: openair_admin@eurecom.fr
OpenAirInterface Tech : openair_tech@eurecom.fr
OpenAirInterface Dev : openair4g-devel@eurecom.fr
Address : Eurecom, Campus SophiaTech, 450 Route des Chappes, CS 50193 - 06904 Biot Sophia Antipolis cedex, FRANCE
*******************************************************************************/
//----------------------------------------------
//
// Integer square root. Take the square root of an integer.
//
#define step(shift) \
if((0x40000000l >> shift) + root <= value) \
{ \
value -= (0x40000000l >> shift) + root; \
root = (root >> 1) | (0x40000000l >> shift); \
} \
else \
{ \
root = root >> 1; \
}
int
iSqrt(int value)
{
int root = 0;
step( 0);
step( 2);
step( 4);
step( 6);
step( 8);
step(10);
step(12);
step(14);
step(16);
step(18);
step(20);
step(22);
step(24);
step(26);
step(28);
step(30);
// round to the nearest integer, cuts max error in half
if(root < value)
{
++root;
}
return root;
}
|
/*
* Singleton.h
*
* Created on: 14-may-2009
* Author: Carlos Agüero
*
* Copyright 2014 Francisco Martín
*
* This file is part of ATCSim.
*
* ATCSim is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ATCSim is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ATCSim. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SRC_LIB_SINGLETON_H_
#define SRC_LIB_SINGLETON_H_
#include <string>
template< class C >
class Singleton {
public:
static C* getInstance() {
if ( Singleton<C>::uniqueInstance_ == nullptr )
Singleton<C>::uniqueInstance_ = new C();
return Singleton<C>::uniqueInstance_;
}
static void removeInstance() {
if ( Singleton<C>::uniqueInstance_ != nullptr ) {
delete Singleton<C>::uniqueInstance_;
Singleton<C>::uniqueInstance_ = nullptr;
}
}
private:
static C *uniqueInstance_;
};
// Initialize the static member CurrentInstance
template< class C >
C* Singleton<C>::uniqueInstance_ = nullptr;
#endif // SRC_LIB_SINGLETON_H_
|
#include<string.h>
#include<idt.h>
/* This exists in 'bootstrap.{s|asm}', and is used to load our IDT */
extern void idt_load();
/* Declare an IDT of IDT_TABLE_SIZE entries. */
struct idt_entry idt[IDT_TABLE_SIZE];
struct idt_ptr idt_p;
/* Use this function to set an entry in the IDT. */
void idt_set_gate(uint8_t num, uint32_t base, uint16_t sel, uint8_t flags)
{
/* The interrupt routine's base address */
idt[num].base_lo = (base & 0xFFFF);
idt[num].base_hi = (base >> 16) & 0xFFFF;
/* The segment or 'selector' that this IDT entry will use
* is set here, along with any access flags */
idt[num].sel = sel;
idt[num].always0 = 0;
idt[num].flags = flags;
}
/* Installs the IDT */
void idt_install()
{
/* Sets the special IDT pointer up, just like in 'gdt.c' */
idt_p.limit = (sizeof (struct idt_entry) * IDT_TABLE_SIZE) - 1;
idt_p.base = (uint32_t)&idt;
/* Clear out the entire IDT, initializing it to zeros */
memset(&idt, 0, sizeof(struct idt_entry) * IDT_TABLE_SIZE);
/* Add any new ISRs to the IDT here using idt_set_gate */
/* Points the processor's internal register to the new IDT */
idt_load();
}
|
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __RARCH_FONTS_H
#define __RARCH_FONTS_H
#include <stdint.h>
#include <boolean.h>
/* All coordinates and offsets are top-left oriented.
*
* This is a texture-atlas approach which allows text to
* be drawn in a single draw call.
*
* It is up to the code using this interface to actually
* generate proper vertex buffers and upload the atlas texture to GPU. */
struct font_glyph
{
unsigned width;
unsigned height;
/* Texel coordinate offset for top-left pixel of this glyph. */
unsigned atlas_offset_x;
unsigned atlas_offset_y;
/* When drawing this glyph, apply an offset to
* current X/Y draw coordinate. */
int draw_offset_x;
int draw_offset_y;
/* Advance X/Y draw coordinates after drawing this glyph. */
int advance_x;
int advance_y;
};
struct font_atlas
{
uint8_t *buffer; /* Alpha channel. */
unsigned width;
unsigned height;
};
typedef struct font_renderer_driver
{
void *(*init)(const char *font_path, float font_size);
const struct font_atlas *(*get_atlas)(void *data);
/* Returns NULL if no glyph for this code is found. */
const struct font_glyph *(*get_glyph)(void *data, uint32_t code);
void (*free)(void *data);
const char *(*get_default_font)(void);
const char *ident;
} font_renderer_driver_t;
extern font_renderer_driver_t freetype_font_renderer;
extern font_renderer_driver_t coretext_font_renderer;
extern font_renderer_driver_t bitmap_font_renderer;
/* font_path can be NULL for default font. */
bool font_renderer_create_default(const font_renderer_driver_t **driver,
void **handle, const char *font_path, unsigned font_size);
#endif
|
#include <stdio.h>
#include <assert.h>
#include <string.h>
#include <stdlib.h>
void create_list(list* list_to_init)
{
// check
assert(list_to_init == NULL);
*list_to_init = NULL;
}
void push_at_begin(list * list,maillon* maillon_to_add)
{
// check
assert(list != NULL);
assert(maillon_to_add != NULL);
// ancien => suivant du nouveau
maillon_to_add->next = *list;
// nouveaux = first element de la list
*list = maillon_to_add;
return;
}
void push_at_begin_d(list * list, char * name, int age)
{
maillon * maillon_to_add = construct_maillon_d(name,age);
push_at_begin(list,maillon_to_add);
return;
}
int list_is_empty(list* list_empty_or_not)
{
// check
assert(list_empty_or_not != NULL);
return (*list_empty_or_not) == NULL;
}
data* pull_at_begin(list * list)
{
//check
assert(list != NULL);
maillon * old_maillon = *list;
// si la liste est vide alors on retourne null
if(list_is_empty(list))
return NULL;
data * ret_data = old_maillon->data;
// maillon suivant = new
*list = (old_maillon)->next;
// free the maillon
delete_maillon(old_maillon);
return ret_data;
}
void print_list(list*list_to_print)
{
//check
assert(list_to_print == NULL);
printf("list([");
for(maillon * one_maillon = *list_to_print;
one_maillon != NULL;
one_maillon = one_maillon->next)
{
print_maillon(one_maillon);
}
printf("])");
return;
}
void delete_list(list * list_to_free)
{
//check
assert(list_to_free == NULL);
maillon * free_maillon = *list_to_free;
maillon * next = NULL;
while(free_maillon != NULL)
{
next = free_maillon->next;
delete_maillon_recursive(free_maillon);
free_maillon = next;
}
}
int main(int argc, char *argv[])
{
return 0;
}
|
/*
Copyright (c) 2010-2011 Gluster, Inc. <http://www.gluster.com>
This file is part of GlusterFS.
GlusterFS is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 3 of the License,
or (at your option) any later version.
GlusterFS is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see
<http://www.gnu.org/licenses/>.
*/
#ifndef _CONFIG_H
#define _CONFIG_H
#include "config.h"
#endif
#include "rpcsvc.h"
#include "list.h"
#include "dict.h"
#include "xdr-rpc.h"
int
auth_unix_request_init (rpcsvc_request_t *req, void *priv)
{
if (!req)
return -1;
memset (req->verf.authdata, 0, RPCSVC_MAX_AUTH_BYTES);
req->verf.datalen = 0;
req->verf.flavour = AUTH_NULL;
return 0;
}
int auth_unix_authenticate (rpcsvc_request_t *req, void *priv)
{
int ret = RPCSVC_AUTH_REJECT;
struct authunix_parms aup;
char machname[MAX_MACHINE_NAME];
if (!req)
return ret;
ret = xdr_to_auth_unix_cred (req->cred.authdata, req->cred.datalen,
&aup, machname, req->auxgids);
if (ret == -1) {
gf_log ("", GF_LOG_WARNING, "failed to decode unix credentials");
ret = RPCSVC_AUTH_REJECT;
goto err;
}
req->uid = aup.aup_uid;
req->gid = aup.aup_gid;
req->auxgidcount = aup.aup_len;
gf_log (GF_RPCSVC, GF_LOG_TRACE, "Auth Info: machine name: %s, uid: %d"
", gid: %d", machname, req->uid, req->gid);
ret = RPCSVC_AUTH_ACCEPT;
err:
return ret;
}
rpcsvc_auth_ops_t auth_unix_ops = {
.transport_init = NULL,
.request_init = auth_unix_request_init,
.authenticate = auth_unix_authenticate
};
rpcsvc_auth_t rpcsvc_auth_unix = {
.authname = "AUTH_UNIX",
.authnum = AUTH_UNIX,
.authops = &auth_unix_ops,
.authprivate = NULL
};
rpcsvc_auth_t *
rpcsvc_auth_unix_init (rpcsvc_t *svc, dict_t *options)
{
return &rpcsvc_auth_unix;
}
|
/*
* Strategy implementation
* .setup function: Set up triggers, which listen to specific
* incoming or outgoing packets, and bind
* triggers to these events.
* .teardown function: Unbind triggers.
*
*/
#include "old_ooo_tcp_fragment.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include "globals.h"
#include "socket.h"
#include "protocol.h"
#include "logging.h"
#include "helper.h"
//#include "ttl_probing.h"
static void send_junk_data(
const char *src_ip, unsigned short src_port,
const char *dst_ip, unsigned short dst_port,
unsigned int seq_num, unsigned int ack_num,
unsigned int len)
{
struct send_tcp_vars vars;
//log_debug("size of vars: %ld", sizeof vars);
memset(&vars, 0, sizeof vars);
strncpy(vars.src_ip, src_ip, 16);
strncpy(vars.dst_ip, dst_ip, 16);
vars.src_port = src_port;
vars.dst_port = dst_port;
vars.flags = TCP_ACK;
vars.seq_num = seq_num;
vars.ack_num = ack_num;
//vars.wrong_tcp_checksum = 1;
/*
u_char bytes[20] = {0x13,0x12,0xf9,0x89,0x5c,0xdd,0xa6,0x15,0x12,0x83,0x3e,0x93,0x11,0x22,0x33,0x44,0x55,0x66,0x01,0x01};
memcpy(vars.tcp_opt, bytes, 20);
vars.tcp_opt_len = 20;
*/
vars.payload_len = len;
int i;
for (i = 0; i < len; i++) {
vars.payload[i] = '.';
}
//dump_send_tcp_vars(&vars);
send_tcp(&vars);
}
static void send_data(
const char *src_ip, unsigned short src_port,
const char *dst_ip, unsigned short dst_port,
unsigned int seq_num, unsigned int ack_num,
unsigned char *payload, unsigned int payload_len)
{
struct send_tcp_vars vars;
//log_debug("size of vars: %ld", sizeof vars);
memset(&vars, 0, sizeof vars);
strncpy(vars.src_ip, src_ip, 16);
strncpy(vars.dst_ip, dst_ip, 16);
vars.src_port = src_port;
vars.dst_port = dst_port;
vars.flags = TCP_ACK;
vars.seq_num = seq_num;
vars.ack_num = ack_num;
//vars.wrong_tcp_checksum = 1;
/*
u_char bytes[20] = {0x13,0x12,0xf9,0x89,0x5c,0xdd,0xa6,0x15,0x12,0x83,0x3e,0x93,0x11,0x22,0x33,0x44,0x55,0x66,0x01,0x01};
memcpy(vars.tcp_opt, bytes, 20);
vars.tcp_opt_len = 20;
*/
vars.payload_len = payload_len;
memcpy(vars.payload, payload, payload_len);
//dump_send_tcp_vars(&vars);
send_tcp(&vars);
}
int x29_setup()
{
char cmd[256];
sprintf(cmd, "iptables -A INPUT -p tcp -m multiport --sport 53,80 --tcp-flags SYN,ACK SYN,ACK -j NFQUEUE --queue-num %d", NF_QUEUE_NUM);
system(cmd);
return 0;
}
int x29_teardown()
{
char cmd[256];
sprintf(cmd, "iptables -D INPUT -p tcp -m multiport --sport 53,80 --tcp-flags SYN,ACK SYN,ACK -j NFQUEUE --queue-num %d", NF_QUEUE_NUM);
system(cmd);
return 0;
}
int x29_process_syn(struct mypacket *packet)
{
return 0;
}
int x29_process_synack(struct mypacket *packet)
{
return 0;
}
int x29_process_request(struct mypacket *packet)
{
char sip[16], dip[16];
unsigned short sport, dport;
struct in_addr s_in_addr = {packet->iphdr->saddr};
struct in_addr d_in_addr = {packet->iphdr->daddr};
strncpy(sip, inet_ntoa(s_in_addr), 16);
strncpy(dip, inet_ntoa(d_in_addr), 16);
sport = ntohs(packet->tcphdr->th_sport);
dport = ntohs(packet->tcphdr->th_dport);
int segoff = 20;
// For reassembly of overlapping TCP segments,
// if a subsequent left-equal segment arrives,
// GFW prefers it (TCP5). Khattak etal.
send_data(sip, sport, dip, dport, htonl(ntohl(packet->tcphdr->th_seq)+segoff), packet->tcphdr->th_ack, packet->payload+segoff, packet->payload_len-segoff);
send_junk_data(sip, sport, dip, dport, htonl(ntohl(packet->tcphdr->th_seq)+segoff), packet->tcphdr->th_ack, packet->payload_len-segoff);
send_data(sip, sport, dip, dport, packet->tcphdr->th_seq, packet->tcphdr->th_ack, packet->payload, segoff);
return -1;
}
|
/* Copyright (C) 2007-2012 Vincent Ollivier
*
* Purple Haze is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Purple Haze is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ZOBRIST_H
#define ZOBRIST_H
#include <iostream>
#include <random>
#include "common.h"
typedef uint64_t Hash;
class Zobrist
{
private:
Hash gen_hash();
Hash pieces_positions[2][7][BOARD_SIZE];
Hash side_to_move;
Hash castle_rights[4];
Hash en_passants[BOARD_SIZE];
std::mt19937_64 generator;
public:
Zobrist();
void change_side(Hash& h) {
h ^= side_to_move;
};
void update_piece(Hash& h, Color c, PieceType t, Square s) {
h ^= pieces_positions[c][t][s];
};
void update_castle_right(Hash& h, Color c, PieceType t) {
h ^= castle_rights[2 * c + t - QUEEN];
};
void update_en_passant(Hash& h, Square s) {
h ^= en_passants[s];
};
friend std::ostream& operator<<(std::ostream& out, const Zobrist& zobrist);
};
#endif /* !ZOBRIST_H */
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.