text stringlengths 4 6.14k |
|---|
/*
* Copyright (C) 2012 Avionic Design GmbH
*
* 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/err.h>
#include <linux/i2c.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/iio/iio.h>
#include <linux/regulator/consumer.h>
struct adc081c {
struct i2c_client *i2c;
struct regulator *ref;
};
#define REG_CONV_RES 0x00
static int adc081c_read_raw(struct iio_dev *iio,
struct iio_chan_spec const *channel, int *value,
int *shift, long mask)
{
struct adc081c *adc = iio_priv(iio);
int err;
switch (mask) {
case IIO_CHAN_INFO_RAW:
err = i2c_smbus_read_word_swapped(adc->i2c, REG_CONV_RES);
if (err < 0)
return err;
*value = (err >> 4) & 0xff;
return IIO_VAL_INT;
case IIO_CHAN_INFO_SCALE:
err = regulator_get_voltage(adc->ref);
if (err < 0)
return err;
*value = err / 1000;
*shift = 8;
return IIO_VAL_FRACTIONAL_LOG2;
default:
break;
}
return -EINVAL;
}
static const struct iio_chan_spec adc081c_channel = {
.type = IIO_VOLTAGE,
.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
};
static const struct iio_info adc081c_info = {
.read_raw = adc081c_read_raw,
.driver_module = THIS_MODULE,
};
static int adc081c_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
struct iio_dev *iio;
struct adc081c *adc;
int err;
if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_WORD_DATA))
return -ENODEV;
iio = devm_iio_device_alloc(&client->dev, sizeof(*adc));
if (!iio)
return -ENOMEM;
adc = iio_priv(iio);
adc->i2c = client;
adc->ref = devm_regulator_get(&client->dev, "vref");
if (IS_ERR(adc->ref))
return PTR_ERR(adc->ref);
err = regulator_enable(adc->ref);
if (err < 0)
return err;
iio->dev.parent = &client->dev;
iio->name = dev_name(&client->dev);
iio->modes = INDIO_DIRECT_MODE;
iio->info = &adc081c_info;
iio->channels = &adc081c_channel;
iio->num_channels = 1;
err = iio_device_register(iio);
if (err < 0)
goto regulator_disable;
i2c_set_clientdata(client, iio);
return 0;
regulator_disable:
regulator_disable(adc->ref);
return err;
}
static int adc081c_remove(struct i2c_client *client)
{
struct iio_dev *iio = i2c_get_clientdata(client);
struct adc081c *adc = iio_priv(iio);
iio_device_unregister(iio);
regulator_disable(adc->ref);
return 0;
}
static const struct i2c_device_id adc081c_id[] = {
{ "adc081c", 0 },
{ }
};
MODULE_DEVICE_TABLE(i2c, adc081c_id);
#ifdef CONFIG_OF
static const struct of_device_id adc081c_of_match[] = {
{ .compatible = "ti,adc081c" },
{ }
};
MODULE_DEVICE_TABLE(of, adc081c_of_match);
#endif
static struct i2c_driver adc081c_driver = {
.driver = {
.name = "adc081c",
.owner = THIS_MODULE,
.of_match_table = of_match_ptr(adc081c_of_match),
},
.probe = adc081c_probe,
.remove = adc081c_remove,
.id_table = adc081c_id,
};
module_i2c_driver(adc081c_driver);
MODULE_AUTHOR("Thierry Reding <thierry.reding@avionic-design.de>");
MODULE_DESCRIPTION("Texas Instruments ADC081C021/027 driver");
MODULE_LICENSE("GPL v2");
|
/* With -ffast-math, the latice value for t changes from -0.0 to 0.0 in this
testcase. */
/* { dg-do compile } */
/* { dg-options "-O2 -ffast-math" } */
double test (int param)
{
double a = 0.0, b = -1.0, t;
int i;
for (i = 0; i < 100; i++)
{
t = a * b;
if (param)
b = 2.0;
}
return t;
}
|
/*
* digi00x.h - a part of driver for Digidesign Digi 002/003 family
*
* Copyright (c) 2014-2015 Takashi Sakamoto
*
* Licensed under the terms of the GNU General Public License, version 2.
*/
#ifndef SOUND_DIGI00X_H_INCLUDED
#define SOUND_DIGI00X_H_INCLUDED
#include <linux/compat.h>
#include <linux/device.h>
#include <linux/firewire.h>
#include <linux/module.h>
#include <linux/mod_devicetable.h>
#include <linux/delay.h>
#include <linux/slab.h>
#include <sound/core.h>
#include <sound/initval.h>
#include <sound/info.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <sound/firewire.h>
#include <sound/hwdep.h>
#include <sound/rawmidi.h>
#include "../lib.h"
#include "../iso-resources.h"
#include "../amdtp-stream.h"
struct snd_dg00x {
struct snd_card *card;
struct fw_unit *unit;
struct mutex mutex;
spinlock_t lock;
bool registered;
struct delayed_work dwork;
struct amdtp_stream tx_stream;
struct fw_iso_resources tx_resources;
struct amdtp_stream rx_stream;
struct fw_iso_resources rx_resources;
unsigned int substreams_counter;
/* for uapi */
int dev_lock_count;
bool dev_lock_changed;
wait_queue_head_t hwdep_wait;
/* For asynchronous messages. */
struct fw_address_handler async_handler;
u32 msg;
/* For asynchronous MIDI controls. */
struct snd_rawmidi_substream *in_control;
struct snd_fw_async_midi_port out_control;
};
#define DG00X_ADDR_BASE 0xffffe0000000ull
#define DG00X_OFFSET_STREAMING_STATE 0x0000
#define DG00X_OFFSET_STREAMING_SET 0x0004
#define DG00X_OFFSET_MIDI_CTL_ADDR 0x0008
/* For LSB of the address 0x000c */
/* unknown 0x0010 */
#define DG00X_OFFSET_MESSAGE_ADDR 0x0014
/* For LSB of the address 0x0018 */
/* unknown 0x001c */
/* unknown 0x0020 */
/* not used 0x0024--0x00ff */
#define DG00X_OFFSET_ISOC_CHANNELS 0x0100
/* unknown 0x0104 */
/* unknown 0x0108 */
/* unknown 0x010c */
#define DG00X_OFFSET_LOCAL_RATE 0x0110
#define DG00X_OFFSET_EXTERNAL_RATE 0x0114
#define DG00X_OFFSET_CLOCK_SOURCE 0x0118
#define DG00X_OFFSET_OPT_IFACE_MODE 0x011c
/* unknown 0x0120 */
/* Mixer control on/off 0x0124 */
/* unknown 0x0128 */
#define DG00X_OFFSET_DETECT_EXTERNAL 0x012c
/* unknown 0x0138 */
#define DG00X_OFFSET_MMC 0x0400
enum snd_dg00x_rate {
SND_DG00X_RATE_44100 = 0,
SND_DG00X_RATE_48000,
SND_DG00X_RATE_88200,
SND_DG00X_RATE_96000,
SND_DG00X_RATE_COUNT,
};
enum snd_dg00x_clock {
SND_DG00X_CLOCK_INTERNAL = 0,
SND_DG00X_CLOCK_SPDIF,
SND_DG00X_CLOCK_ADAT,
SND_DG00X_CLOCK_WORD,
SND_DG00X_CLOCK_COUNT,
};
enum snd_dg00x_optical_mode {
SND_DG00X_OPT_IFACE_MODE_ADAT = 0,
SND_DG00X_OPT_IFACE_MODE_SPDIF,
SND_DG00X_OPT_IFACE_MODE_COUNT,
};
#define DOT_MIDI_IN_PORTS 1
#define DOT_MIDI_OUT_PORTS 2
int amdtp_dot_init(struct amdtp_stream *s, struct fw_unit *unit,
enum amdtp_stream_direction dir);
int amdtp_dot_set_parameters(struct amdtp_stream *s, unsigned int rate,
unsigned int pcm_channels);
void amdtp_dot_reset(struct amdtp_stream *s);
int amdtp_dot_add_pcm_hw_constraints(struct amdtp_stream *s,
struct snd_pcm_runtime *runtime);
void amdtp_dot_set_pcm_format(struct amdtp_stream *s, snd_pcm_format_t format);
void amdtp_dot_midi_trigger(struct amdtp_stream *s, unsigned int port,
struct snd_rawmidi_substream *midi);
int snd_dg00x_transaction_register(struct snd_dg00x *dg00x);
int snd_dg00x_transaction_reregister(struct snd_dg00x *dg00x);
void snd_dg00x_transaction_unregister(struct snd_dg00x *dg00x);
extern const unsigned int snd_dg00x_stream_rates[SND_DG00X_RATE_COUNT];
extern const unsigned int snd_dg00x_stream_pcm_channels[SND_DG00X_RATE_COUNT];
int snd_dg00x_stream_get_external_rate(struct snd_dg00x *dg00x,
unsigned int *rate);
int snd_dg00x_stream_get_local_rate(struct snd_dg00x *dg00x,
unsigned int *rate);
int snd_dg00x_stream_set_local_rate(struct snd_dg00x *dg00x, unsigned int rate);
int snd_dg00x_stream_get_clock(struct snd_dg00x *dg00x,
enum snd_dg00x_clock *clock);
int snd_dg00x_stream_check_external_clock(struct snd_dg00x *dg00x,
bool *detect);
int snd_dg00x_stream_init_duplex(struct snd_dg00x *dg00x);
int snd_dg00x_stream_start_duplex(struct snd_dg00x *dg00x, unsigned int rate);
void snd_dg00x_stream_stop_duplex(struct snd_dg00x *dg00x);
void snd_dg00x_stream_update_duplex(struct snd_dg00x *dg00x);
void snd_dg00x_stream_destroy_duplex(struct snd_dg00x *dg00x);
void snd_dg00x_stream_lock_changed(struct snd_dg00x *dg00x);
int snd_dg00x_stream_lock_try(struct snd_dg00x *dg00x);
void snd_dg00x_stream_lock_release(struct snd_dg00x *dg00x);
void snd_dg00x_proc_init(struct snd_dg00x *dg00x);
int snd_dg00x_create_pcm_devices(struct snd_dg00x *dg00x);
int snd_dg00x_create_midi_devices(struct snd_dg00x *dg00x);
int snd_dg00x_create_hwdep_device(struct snd_dg00x *dg00x);
#endif
|
/* { dg-do compile } */
/* { dg-options "-mcpu=ultrasparc -mvis" } */
typedef char vec8 __attribute__((vector_size(4)));
typedef short vec16 __attribute__((vector_size(4)));
extern vec8 foo1_8(void);
extern vec8 foo2_8(void);
vec8 fun8(void)
{
return foo1_8 () & foo2_8 ();
}
extern vec16 foo1_16(void);
extern vec16 foo2_16(void);
vec16 fun16(void)
{
return foo1_16 () & foo1_16 ();
}
/* { dg-final { scan-assembler-times "fands\t%" 2 } } */
|
extern int zzz;
int zzz = 123;
|
/*
* Copyright (C) 2012 Freescale Semiconductor, Inc.
*
* 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/cpuidle.h>
#include <linux/module.h>
#include <asm/system_misc.h>
static int imx5_cpuidle_enter(struct cpuidle_device *dev,
struct cpuidle_driver *drv, int index)
{
arm_pm_idle();
return index;
}
static struct cpuidle_driver imx5_cpuidle_driver = {
.name = "imx5_cpuidle",
.owner = THIS_MODULE,
.states[0] = {
.enter = imx5_cpuidle_enter,
.exit_latency = 2,
.target_residency = 1,
.flags = CPUIDLE_FLAG_TIME_VALID,
.name = "IMX5 SRPG",
.desc = "CPU state retained,powered off",
},
.state_count = 1,
};
int __init imx5_cpuidle_init(void)
{
return cpuidle_register(&imx5_cpuidle_driver, NULL);
}
|
/* Copyright (C) 2000 MySQL AB
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 2 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, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#ifndef _decimal_h
#define _decimal_h
typedef enum
{TRUNCATE=0, HALF_EVEN, HALF_UP, CEILING, FLOOR}
decimal_round_mode;
typedef int32 decimal_digit_t;
typedef struct st_decimal_t {
int intg, frac, len;
my_bool sign;
decimal_digit_t *buf;
} decimal_t;
int internal_str2dec(const char *from, decimal_t *to, char **end,
my_bool fixed);
int decimal2string(decimal_t *from, char *to, int *to_len,
int fixed_precision, int fixed_decimals,
char filler);
int decimal2ulonglong(decimal_t *from, ulonglong *to);
int ulonglong2decimal(ulonglong from, decimal_t *to);
int decimal2longlong(decimal_t *from, longlong *to);
int longlong2decimal(longlong from, decimal_t *to);
int decimal2double(decimal_t *from, double *to);
int double2decimal(double from, decimal_t *to);
int decimal_actual_fraction(decimal_t *from);
int decimal2bin(decimal_t *from, uchar *to, int precision, int scale);
int bin2decimal(const uchar *from, decimal_t *to, int precision, int scale);
int decimal_size(int precision, int scale);
int decimal_bin_size(int precision, int scale);
int decimal_result_size(decimal_t *from1, decimal_t *from2, char op,
int param);
int decimal_intg(decimal_t *from);
int decimal_add(decimal_t *from1, decimal_t *from2, decimal_t *to);
int decimal_sub(decimal_t *from1, decimal_t *from2, decimal_t *to);
int decimal_cmp(decimal_t *from1, decimal_t *from2);
int decimal_mul(decimal_t *from1, decimal_t *from2, decimal_t *to);
int decimal_div(decimal_t *from1, decimal_t *from2, decimal_t *to,
int scale_incr);
int decimal_mod(decimal_t *from1, decimal_t *from2, decimal_t *to);
int decimal_round(decimal_t *from, decimal_t *to, int new_scale,
decimal_round_mode mode);
int decimal_is_zero(decimal_t *from);
void max_decimal(int precision, int frac, decimal_t *to);
#define string2decimal(A,B,C) internal_str2dec((A), (B), (C), 0)
#define string2decimal_fixed(A,B,C) internal_str2dec((A), (B), (C), 1)
/* set a decimal_t to zero */
#define decimal_make_zero(dec) do { \
(dec)->buf[0]=0; \
(dec)->intg=1; \
(dec)->frac=0; \
(dec)->sign=0; \
} while(0)
/*
returns the length of the buffer to hold string representation
of the decimal (including decimal dot, possible sign and \0)
*/
#define decimal_string_size(dec) (((dec)->intg ? (dec)->intg : 1) + \
(dec)->frac + ((dec)->frac > 0) + 2)
/* negate a decimal */
#define decimal_neg(dec) do { (dec)->sign^=1; } while(0)
/*
conventions:
decimal_smth() == 0 -- everything's ok
decimal_smth() <= 1 -- result is usable, but precision loss is possible
decimal_smth() <= 2 -- result can be unusable, most significant digits
could've been lost
decimal_smth() > 2 -- no result was generated
*/
#define E_DEC_OK 0
#define E_DEC_TRUNCATED 1
#define E_DEC_OVERFLOW 2
#define E_DEC_DIV_ZERO 4
#define E_DEC_BAD_NUM 8
#define E_DEC_OOM 16
#define E_DEC_ERROR 31
#define E_DEC_FATAL_ERROR 30
#endif
|
#include "BF538_cdef.h"
|
/* linux/arch/arm/plat-s3c/dev-i2c1.c
*
* Copyright 2008,2009 Simtec Electronics
* Ben Dooks <ben@simtec.co.uk>
* http://armlinux.simtec.co.uk/
*
* S3C series device definition for i2c device 1
*
* 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/kernel.h>
#include <linux/string.h>
#include <linux/platform_device.h>
#include <mach/irqs.h>
#include <mach/map.h>
#include <plat/regs-iic.h>
#include <plat/iic.h>
#include <plat/devs.h>
#include <plat/cpu.h>
static struct resource s3c_i2c_resource[] = {
[0] = {
.start = S3C_PA_IIC1,
.end = S3C_PA_IIC1 + SZ_4K - 1,
.flags = IORESOURCE_MEM,
},
[1] = {
.start = IRQ_IIC1,
.end = IRQ_IIC1,
.flags = IORESOURCE_IRQ,
},
};
struct platform_device s3c_device_i2c1 = {
.name = "s3c2410-i2c",
.id = 1,
.num_resources = ARRAY_SIZE(s3c_i2c_resource),
.resource = s3c_i2c_resource,
};
static struct s3c2410_platform_i2c default_i2c_data1 __initdata = {
.flags = 0,
.bus_num = 1,
.slave_addr = 0x10,
.frequency = 100*1000,
.sda_delay = 100,
};
void __init s3c_i2c1_set_platdata(struct s3c2410_platform_i2c *pd)
{
struct s3c2410_platform_i2c *npd;
if (!pd)
pd = &default_i2c_data1;
npd = kmemdup(pd, sizeof(struct s3c2410_platform_i2c), GFP_KERNEL);
if (!npd)
printk(KERN_ERR "%s: no memory for platform data\n", __func__);
else if (!npd->cfg_gpio)
npd->cfg_gpio = s3c_i2c1_cfg_gpio;
s3c_device_i2c1.dev.platform_data = npd;
}
|
/* ISC license. */
#ifndef FTRIGW_H
#define FTRIGW_H
#include <skalibs/bytestr.h>
extern int ftrigw_fifodir_make (char const *, int, int) ;
extern int ftrigw_notify (char const *, char) ;
extern int ftrigw_notifyb (char const *, char const *, unsigned int) ;
extern int ftrigw_notifyb_nosig (char const *, char const *, unsigned int) ;
#define ftrigw_notifys(f, s) ftrigw_notifyb(f, (s), str_len(s))
extern int ftrigw_clean (char const *) ;
#endif
|
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <sys/stat.h>
#include "channel-http.h"
struct serveable {
const char *urlpath;
const char *mimetype;
};
static const struct serveable whitelist[] = {
{ "/favicon.ico", "image/x-icon" },
{ "/libwebsockets.org-logo.png", "image/png" },
/* last one is the default served if no match */
{ "/test.html", "text/html" },
};
static const int nb_whitelist= (sizeof(whitelist) / sizeof(whitelist[0]) - 1);
int callback_http(struct libwebsocket_context *context,
struct libwebsocket *wsi,
enum libwebsocket_callback_reasons reason, void *user,
void *in, size_t len) {
char buf[256];
char leaf_path[1024];
int n=0, m=0;
unsigned char *p=NULL;
static unsigned char buffer[4096];
struct stat stat_buf;
struct per_session_data__http *pss =
(struct per_session_data__http *)user;
(void)len;
switch (reason) {
case LWS_CALLBACK_HTTP:
/* check for the "send a big file by hand" example case */
if (!strcmp((const char *)in, "/leaf.jpg")) {
if (strlen(resource_path) > sizeof(leaf_path) - 10)
return -1;
sprintf(leaf_path, "%s/leaf.jpg", resource_path);
/* well, let's demonstrate how to send the hard way */
p = buffer;
pss->fd = open(leaf_path, O_RDONLY);
if (pss->fd < 0)
return -1;
fstat(pss->fd, &stat_buf);
/*
* we will send a big jpeg file, but it could be
* anything. Set the Content-Type: appropriately
* so the browser knows what to do with it.
*/
p += sprintf((char *)p,
"HTTP/1.0 200 OK\x0d\x0a"
"Server: libwebsockets\x0d\x0a"
"Content-Type: image/jpeg\x0d\x0a"
"Content-Length: %u\x0d\x0a\x0d\x0a",
(unsigned int)stat_buf.st_size);
/*
* send the http headers...
* this won't block since it's the first payload sent
* on the connection since it was established
* (too small for partial)
*/
n = libwebsocket_write(wsi, buffer,
p - buffer, LWS_WRITE_HTTP);
if (n < 0) {
close(pss->fd);
return -1;
}
/*
* book us a LWS_CALLBACK_HTTP_WRITEABLE callback
*/
libwebsocket_callback_on_writable(context, wsi);
break;
}
/* if not, send a file the easy way */
for (n = 0; n < (int)nb_whitelist; n++)
if (in && strcmp((const char *)in, whitelist[n].urlpath) == 0)
break;
sprintf(buf, "%s%s", resource_path, whitelist[n].urlpath);
if (libwebsockets_serve_http_file(context, wsi, buf, whitelist[n].mimetype))
return -1; /* through completion or error, close the socket */
/*
* notice that the sending of the file completes asynchronously,
* we'll get a LWS_CALLBACK_HTTP_FILE_COMPLETION callback when
* it's done
*/
break;
case LWS_CALLBACK_HTTP_FILE_COMPLETION:
// lwsl_info("LWS_CALLBACK_HTTP_FILE_COMPLETION seen\n");
/* kill the connection after we sent one file */
return -1;
case LWS_CALLBACK_HTTP_WRITEABLE:
/*
* we can send more of whatever it is we were sending
*/
do {
n = read(pss->fd, buffer, sizeof buffer);
/* problem reading, close conn */
if (n < 0)
goto bail;
/* sent it all, close conn */
if (n == 0)
goto bail;
/*
* because it's HTTP and not websocket, don't need to take
* care about pre and postamble
*/
m = libwebsocket_write(wsi, buffer, n, LWS_WRITE_HTTP);
if (m < 0)
/* write failed, close conn */
goto bail;
if (m != n)
/* partial write, adjust */
lseek(pss->fd, m - n, SEEK_CUR);
} while (!lws_send_pipe_choked(wsi));
libwebsocket_callback_on_writable(context, wsi);
break;
bail:
close(pss->fd);
return -1;
/*
* callback for confirming to continue with client IP appear in
* protocol 0 callback since no websocket protocol has been agreed
* yet. You can just ignore this if you won't filter on client IP
* since the default uhandled callback return is 0 meaning let the
* connection continue.
*/
case LWS_CALLBACK_FILTER_NETWORK_CONNECTION:
#if 0
libwebsockets_get_peer_addresses(context, wsi, (int)(long)in, client_name,
sizeof(client_name), client_ip, sizeof(client_ip));
fprintf(stderr, "Received network connect from %s (%s)\n",
client_name, client_ip);
#endif
/* if we returned non-zero from here, we kill the connection */
break;
default:
break;
}
return 0;
}
|
//
// File: data_filter.h
//
// MATLAB Coder version : 2.8
// C/C++ source code generated on : 24-Nov-2016 16:51:51
//
#ifndef __DATA_FILTER_H__
#define __DATA_FILTER_H__
// Include Files
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include "rtwtypes.h"
#include "data_filter_types.h"
// Function Declarations
extern void data_filter(const emxArray_real_T *M, emxArray_real_T *data_out);
#endif
//
// File trailer for data_filter.h
//
// [EOF]
//
|
#pragma once
#include "Drawable2D.h"
class Circle : public Drawable2D
{
public:
Circle() {}
~Circle()
{
Drawable2D::~Drawable2D();
}
void Initialize(float x, float y, int radius);
void Draw(float dt);
void SetColor(float r, float g, float b, float a);
protected:
int radius, angles;
int r, g, b, a;
void BindData();
};
|
/*
* rtc.h
*
* Created on: 24 Dec 2018
* Author: raffael
*/
#ifndef FW_RTC_H_
#define FW_RTC_H_
void rtc_config();
void rtc_set_clock(uint32_t unix_timestamp);
void rtc_update_system_time();
// set new values for pause and resume times:
void rtc_set_pause_times(uint8_t p_hour, uint8_t p_min, uint8_t r_hour, uint8_t r_min);
void rtc_set_pause_times_compact(uint32_t value);
uint32_t rtc_get_pause_times_compact();
uint8_t rtc_get_p_min();
uint8_t rtc_get_r_min();
uint8_t rtc_get_p_hour();
uint8_t rtc_get_r_hour();
// polling function to check if it is time to shut down the system:
int rtc_is_it_time_to_pause();
// turns off the system tick and sets an alarm to wake up again in the evening:
void rtc_pause_system();
//turn on system again
void rtc_resume_system();
#endif /* FW_RTC_H_ */
|
#import <UIKit/UIKit.h>
@interface UIFont (Martel)
+ (instancetype)martelBoldFontOfSize:(CGFloat)size;
+ (instancetype)martelDemiBoldFontOfSize:(CGFloat)size;
+ (instancetype)martelExtraBoldFontOfSize:(CGFloat)size;
+ (instancetype)martelHeavyFontOfSize:(CGFloat)size;
+ (instancetype)martelLightFontOfSize:(CGFloat)size;
+ (instancetype)martelRegularFontOfSize:(CGFloat)size;
+ (instancetype)martelUltraLightFontOfSize:(CGFloat)size;
@end
|
#ifdef __MAKECINT__
#pragma link C++ namespace PLASMA;
#pragma link C++ class PLASMA::D1+;
#endif
|
/*
malloc.c
Copyright (c) 23 Yann BOUCHER (yann)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "liballoc/liballoc.h"
#ifdef __cplusplus
extern "C"
{
#endif
// TODO : remove
//void *malloc(size_t t)
//{
// return kmalloc(t);
//}
//void *realloc(void* ptr, size_t n)
//{
// return krealloc(ptr, n);
//}
//void *calloc(size_t a, size_t b)
//{
// return kcalloc(a,b);
//}
//void free(void* ptr)
//{
// kfree(ptr);
//}
#ifdef __cplusplus
}
#endif
|
/*
* Generated by class-dump 3.3.4 (64 bit).
*
* class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2011 by Steve Nygard.
*/
#import "NSObject.h"
@class NSString, UIAlertView, UIPrintingProgressViewController;
// Not exported
@interface UIPrintingProgress : NSObject
{
NSString *_printerName;
id _cancelHandler;
double _startTime;
double _displayTime;
UIAlertView *_alert;
UIPrintingProgressViewController *_viewController;
_Bool _donePrinting;
}
- (double)nextPrintDelay;
- (void)setPage:(long long)arg1 ofPage:(long long)arg2;
- (void)setPrintInfoState:(int)arg1;
- (void)endProgress;
- (void)alertView:(id)arg1 clickedButtonAtIndex:(long long)arg2;
- (void)alertViewCancel:(id)arg1;
- (void)didPresentAlertView:(id)arg1;
- (void)progressCancel;
- (void)hideProgressAnimated:(_Bool)arg1;
- (void)showProgress:(id)arg1 immediately:(_Bool)arg2;
- (_Bool)progressVisible;
- (void)dealloc;
- (id)initWithPrinterName:(id)arg1 cancelHandler:(id)arg2;
@end
|
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#else
#ifndef FOUNDATION_EXPORT
#if defined(__cplusplus)
#define FOUNDATION_EXPORT extern "C"
#else
#define FOUNDATION_EXPORT extern
#endif
#endif
#endif
#import "AWSSimpleDB.h"
#import "AWSSimpleDBModel.h"
#import "AWSSimpleDBResources.h"
#import "AWSSimpleDBService.h"
FOUNDATION_EXPORT double AWSSimpleDBVersionNumber;
FOUNDATION_EXPORT const unsigned char AWSSimpleDBVersionString[];
|
#pragma once
class fenwick_tree
{
public:
fenwick_tree(int capacity);
~fenwick_tree();
void update(int index, int delta);
int running_sum(int index) const;
private:
int m_capacity;
int* m_elements;
};
|
//
// TestObjectProvider.h
// CalendarView
//
// Created by Christian Tietze on 09.09.14.
// Copyright (c) 2014 Christian Tietze. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "CCLProvidesCalendarObjects.h"
@class CCLDateRange;
@interface TestObjectProvider : NSObject <CCLProvidesCalendarObjects>
@property (strong) CCLDateRange *dateRange;
- (instancetype)initWithDateRange:(CCLDateRange *)dateRange;
@end
|
#pragma once
#include "stdafx.h"
#include "GarageDoor/GPIO/Pin.h"
#include "GarageDoor/Filesystem.h"
#include "GarageDoor/Config.h"
#include "GarageDoor/Door.h"
#include "nlohmann/json/json.hpp"
typedef std::shared_ptr<GarageDoor::GPIO::Pin> pin_ptr;
typedef std::vector<pin_ptr> pin_map;
typedef std::shared_ptr<pin_map> pin_map_ptr;
typedef std::map<tstring, GarageDoor::Door> door_map;
using json = nlohmann::json;
namespace GarageDoor {
namespace GPIO {
class Manager
{
public:
Manager();
Manager(GarageDoor::Config*);
void LoadPins();
void UnloadPins();
int CountPins();
void LoadDoors();
pin_ptr GetPin(tstring);
private:
pin_map pinList;
door_map doorList;
GarageDoor::Config * Config;
};
}
}
|
/**
* This header is generated by class-dump-z 0.2a.
* class-dump-z is Copyright (C) 2009 by KennyTM~, licensed under GPLv3.
*
* Source: (null)
*/
#import "AWSRequest.h"
@class NSArray, NSString;
@interface AWSCognitoSyncUpdateRecordsRequest : AWSRequest {
NSString* _clientContext;
NSString* _datasetName;
NSString* _deviceId;
NSString* _identityId;
NSString* _identityPoolId;
NSArray* _recordPatches;
NSString* _syncSessionToken;
}
@property(retain, nonatomic) NSString* clientContext;
@property(retain, nonatomic) NSString* datasetName;
@property(retain, nonatomic) NSString* deviceId;
@property(retain, nonatomic) NSString* identityId;
@property(retain, nonatomic) NSString* identityPoolId;
@property(retain, nonatomic) NSArray* recordPatches;
@property(retain, nonatomic) NSString* syncSessionToken;
+ (id)JSONKeyPathsByPropertyKey;
+ (id)recordPatchesJSONTransformer;
- (void).cxx_destruct;
@end
|
#import <Foundation/Foundation.h>
@class CMTraversalObjectDir;
@class CMTraversalObjectFile;
@class CMTraversalObjectHardlink;
@class CMTraversalObjectSymlink;
@class CMTraversalObjectFifo;
@class CMTraversalObjectChar;
@class CMTraversalObjectBlock;
@class CMTraversalObjectOther;
@protocol CMTraversalObjectVisitor
-(void)visitDir:(CMTraversalObjectDir*)obj;
-(void)visitFile:(CMTraversalObjectFile*)obj;
-(void)visitHardlink:(CMTraversalObjectHardlink*)obj;
-(void)visitSymlink:(CMTraversalObjectSymlink*)obj;
-(void)visitFifo:(CMTraversalObjectFifo*)obj;
-(void)visitChar:(CMTraversalObjectChar*)obj;
-(void)visitBlock:(CMTraversalObjectBlock*)obj;
-(void)visitOther:(CMTraversalObjectOther*)obj;
@end
/*
when "exclude = YES" then the object should be ignored
examples of objects that users often want to ignore
.DS_Store
.svn
.git
*/
@interface CMTraversalObject : NSObject {
NSString* m_path;
BOOL m_exclude;
}
@property (retain) NSString* path;
@property (assign) BOOL exclude;
-(void)accept:(id <CMTraversalObjectVisitor>)v;
@end
@interface CMTraversalObjectDir : CMTraversalObject {
NSArray* m_child_traversal_objects;
}
@property (retain) NSArray* childTraversalObjects;
@end
@interface CMTraversalObjectFile : CMTraversalObject {}
@end
/*
link is either set to: CMTraversalObjectDir, CMTraversalObjectFile, CMTraversalObjectFifo
*/
@interface CMTraversalObjectHardlink : CMTraversalObject {
CMTraversalObject* m_link;
}
@property (retain) CMTraversalObject* link;
-(NSString*)linkPath;
@end
@interface CMTraversalObjectSymlink : CMTraversalObject {
NSString* m_link_path;
}
@property (retain) NSString* linkPath;
@end
@interface CMTraversalObjectFifo : CMTraversalObject {}
@end
@interface CMTraversalObjectChar : CMTraversalObject {
NSUInteger m_major;
NSUInteger m_minor;
}
@property (assign) NSUInteger major;
@property (assign) NSUInteger minor;
@end
@interface CMTraversalObjectBlock : CMTraversalObject {
NSUInteger m_major;
NSUInteger m_minor;
}
@property (assign) NSUInteger major;
@property (assign) NSUInteger minor;
@end
@interface CMTraversalObjectOther : CMTraversalObject {}
@end
|
/*
* rf Class Core
*
* Copyright (C) 2005 John Lenz <lenz@cs.wisc.edu>
* Copyright (C) 2005-2007 Richard Purdie <rpurdie@openedhand.com>
*
* 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/ctype.h>
#include <linux/device.h>
#include <linux/err.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/list.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/spinlock.h>
#include <linux/timer.h>
#include "rf.h"
static struct class *rf_class;
static ssize_t enabled_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct rf_classdev *rf_cdev = dev_get_drvdata(dev);
return sprintf(buf, "%u\n", rf_cdev->enabled);
}
static ssize_t enabled_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t size)
{
struct rf_classdev *rf_cdev = dev_get_drvdata(dev);
bool state;
ssize_t ret;
mutex_lock(&rf_cdev->rf_access);
ret = strtobool(buf, &state);
if (ret)
goto unlock;
rf_set_enabled(rf_cdev, state);
ret = size;
unlock:
mutex_unlock(&rf_cdev->rf_access);
return ret;
}
static DEVICE_ATTR_RW(enabled);
static ssize_t brightness_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct rf_classdev *rf_cdev = dev_get_drvdata(dev);
unsigned int val;
mutex_lock(&rf_cdev->rf_access);
rf_get_brightness(rf_cdev, &val);
mutex_unlock(&rf_cdev->rf_access);
return sprintf(buf, "%u\n", val);
}
static DEVICE_ATTR_RO(brightness);
static ssize_t offset_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct rf_classdev *rf_cdev = dev_get_drvdata(dev);
unsigned int val;
mutex_lock(&rf_cdev->rf_access);
rf_get_offset(rf_cdev, &val);
mutex_unlock(&rf_cdev->rf_access);
return sprintf(buf, "%u\n", val);
}
static DEVICE_ATTR_RO(offset);
static struct attribute *rf_class_attrs[] = {
&dev_attr_enabled.attr,
&dev_attr_brightness.attr,
&dev_attr_offset.attr,
NULL,
};
static const struct attribute_group rf_group = {
.attrs = rf_class_attrs,
};
static const struct attribute_group *rf_groups[] = {
&rf_group,
NULL,
};
static int match_name(struct device *dev, const void *data)
{
if (!dev_name(dev))
return 0;
return !strcmp(dev_name(dev), (char *)data);
}
static int rf_classdev_next_name(const char *init_name, char *name,
size_t len)
{
unsigned int i = 0;
int ret = 0;
strlcpy(name, init_name, len);
while (class_find_device(rf_class, NULL, name, match_name) &&
(ret < len))
ret = snprintf(name, len, "%s_%u", init_name, ++i);
if (ret >= len)
return -ENOMEM;
return i;
}
/**
* rf_classdev_register - register a new object of rf_classdev class.
* @parent: The device to register.
* @rf_cdev: the rf_classdev structure for this device.
*/
int rf_classdev_register(struct device *parent, struct rf_classdev *rf_cdev)
{
char name[64];
int ret;
ret = rf_classdev_next_name(rf_cdev->name, name, sizeof(name));
if (ret < 0)
return ret;
rf_cdev->dev = device_create_with_groups(rf_class, parent, 0,
rf_cdev, rf_cdev->groups, "%s", name);
if (IS_ERR(rf_cdev->dev))
return PTR_ERR(rf_cdev->dev);
if (ret)
dev_warn(parent, "range finder %s renamed to %s due to name collision",
rf_cdev->name, dev_name(rf_cdev->dev));
mutex_init(&rf_cdev->rf_access);
/* add to the list of rf */
down_write(&rf_list_lock);
list_add_tail(&rf_cdev->node, &rf_list);
up_write(&rf_list_lock);
dev_info(parent, "Registered range finder device: %s\n",
rf_cdev->name);
return 0;
}
EXPORT_SYMBOL(rf_classdev_register);
/**
* rf_classdev_unregister - unregisters a object of rf_properties class.
* @rf_cdev: the rf device to unregister
*
* Unregisters a previously registered via rf_classdev_register object.
*/
void rf_classdev_unregister(struct rf_classdev *rf_cdev)
{
device_unregister(rf_cdev->dev);
down_write(&rf_list_lock);
list_del(&rf_cdev->node);
up_write(&rf_list_lock);
mutex_destroy(&rf_cdev->rf_access);
}
EXPORT_SYMBOL(rf_classdev_unregister);
static void devm_rf_classdev_release(struct device *dev, void *res)
{
rf_classdev_unregister(*(struct rf_classdev **)res);
}
/**
* devm_rf_classdev_register - resource managed rf_classdev_register()
* @parent: The device to register.
* @rf_cdev: the rf_classdev structure for this device.
*/
int devm_rf_classdev_register(struct device *parent,
struct rf_classdev *rf_cdev)
{
struct rf_classdev **dr;
int rc;
dr = devres_alloc(devm_rf_classdev_release, sizeof(*dr), GFP_KERNEL);
if (!dr)
return -ENOMEM;
rc = rf_classdev_register(parent, rf_cdev);
if (rc) {
devres_free(dr);
return rc;
}
*dr = rf_cdev;
devres_add(parent, dr);
return 0;
}
EXPORT_SYMBOL(devm_rf_classdev_register);
static int devm_rf_classdev_match(struct device *dev, void *res, void *data)
{
struct rf_cdev **p = res;
if (WARN_ON(!p || !*p))
return 0;
return *p == data;
}
/**
* devm_rf_classdev_unregister() - resource managed rf_classdev_unregister()
* @parent: The device to unregister.
* @rf_cdev: the rf_classdev structure for this device.
*/
void devm_rf_classdev_unregister(struct device *dev,
struct rf_classdev *rf_cdev)
{
WARN_ON(devres_release(dev,
devm_rf_classdev_release,
devm_rf_classdev_match, rf_cdev));
}
EXPORT_SYMBOL(devm_rf_classdev_unregister);
static int __init rf_init(void)
{
rf_class = class_create(THIS_MODULE, "rfs");
if (IS_ERR(rf_class))
return PTR_ERR(rf_class);
rf_class->dev_groups = rf_groups;
return 0;
}
static void __exit rf_exit(void)
{
class_destroy(rf_class);
}
subsys_initcall(rf_init);
module_exit(rf_exit);
MODULE_AUTHOR("Michael Allwright <allsey87@gmail.com>");
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("Range Finder Class Interface");
|
#ifndef GRAPH_H
#define GRAPH_H
#include <set>
#include <iostream>
class Graph {
protected:
enum {
MAX_NODE = 20,
MAX_COORDINATE = 10000,
ERROR_TOO_MANY_NODES = 0x3000ffff
};
/* a node indicates a point on the plane */
class Node {
private:
double x, y;
int id;
public:
/* cmp used to organize a set */
friend bool operator <(const Node&, const Node&);
friend double distance(const Node&, const Node&);
Node(double _x = 0, double _y = 0, int _id = 0): x(_x), y(_y), id(_id) {};
inline int _id() const {
return this->id;
}
inline void print(char ending = '\n') const {
std::cout << "Node " << this->id << "(" << (int)this->x << ", " << (int)this->y << ")" << ending;
}
friend class MST;
};
/* an edge indicates a link between two edges */
class Edge {
private:
std::set<Node>::iterator u, v;
double len;
public:
/* cmp used to organize a set */
friend bool operator <(const Edge&, const Edge&);
Edge(std::set<Node>::iterator, std::set<Node>::iterator);
inline double length() const {
return this->len;
}
inline void print() const {
this->u->print('\t');
std::cout << "-\t";
this->v->print('\t');
std::cout.setf(std::ios::fixed);
std::cout.precision(2);
std::cout << " length = " << this->len << std::endl;
}
friend class MST;
friend class Tree;
};
/* sets of nodes and edges on this plane */
std::set<Node> nodes;
std::set<Edge> edges;
public:
/* cmp used to organize a set */
friend bool operator <(const Node&, const Node&);
friend double distance(const Node&, const Node&);
friend bool operator <(const Edge&, const Edge&);
/* add a random point to this plane and add edges from it to all other points */
void addRandomNodeOnPlan();
friend class MST;
friend class Tree;
};
bool operator <(const Graph::Node&, const Graph::Node&);
bool operator <(const Graph::Edge&, const Graph::Edge&);
#endif
|
//
// AttachmentListViewController.h
// CECiTurbo
//
// Created by DongXing on 4/28/15.
// Copyright (c) 2015 CEC. All rights reserved.
//
#import "MailListViewController.h"
@interface AttachmentListViewController : UITableViewController
@property (nonatomic,strong) AttachmentsFolder *attachmentsFolder;
@end
|
/**
* @cond ___LICENSE___
*
* Copyright (c) 2016-2018 Zefiros Software.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* @endcond
*/
#pragma once
#ifndef __ENGINE_LOCAL_H__
#define __ENGINE_LOCAL_H__
#include "manager/systemManager.h"
#include "manager/poolManager.h"
/// @addtogroup Pools
/**
* Retrieves and disposes a pool object in local scope using the RAII patttern.
*
* @tParam The type we want to pool.
*
* @sa NonCopyable
*/
template < typename tT, typename tBase = tT >
class Local
: NonCopyable < Local< tT, tBase >>
{
public:
/**
* Creates an object using a pool from the given managerHolder with the
* given namespace.
*
* @param [in,out] managerHolder If non-null, manager for holder.
* @param ns (optional) the namespace.
*/
explicit Local(ManagerHolder *const managerHolder, Namespace ns = 0u)
{
mPool = managerHolder->pool->Get< tT >(ns);
mPooledObject = mPool->Get();
}
/**
* Creates an object using a pool from the given pool with the
* given namespace.
*
* @param [in,out] pool If non-null, the pool.
*/
explicit Local(AbstractObjectPool< tBase > *const pool)
{
mPool = pool;
mPooledObject = mPool->Get();
}
/**
* Creates an object using a pool from the given pool using
* the given type from the correct namespace.
*
* @param ns (optional) the namespace.
*/
explicit Local(Namespace ns = 0u)
{
mPool = SystemManager::Get()->GetManagers()->pool->Get< tT >(ns);
mPooledObject = mPool->Get();
}
/**
* If there is a pooled object, we dispose it to the correct pool;
*/
~Local()
{
if (mPooledObject)
{
Dispose();
}
}
/// @name Returning
/// @{
/**
* Disposes our stored object to the correct object pool. Also sets our currently
* pooled object to nullptr.
*/
void Dispose()
{
mPool->Dispose(mPooledObject);
mPooledObject = nullptr;
}
// @}
/// @name Retrieval
/// @{
/**
* Gets the object this class holds.
*
* @return The object.
*/
tBase *Get() noexcept
{
return mPooledObject;
}
/**
* Gets the object this class holds.
*
* @return The object.
*/
const tBase *Get() const noexcept
{
return mPooledObject;
}
/**
* Gets the object this class holds.
*
* @return The object.
*/
operator tBase *() noexcept
{
return mPooledObject;
}
/**
* Gets the object this class holds.
*
* @return The object.
*/
tBase *operator*() noexcept
{
return mPooledObject;
}
/**
* Gets the object this class holds.
*
* @return The object.
*/
tBase *operator->() noexcept
{
return mPooledObject;
}
/**
* Gets the object this class holds.
*
* @return The object.
*/
const tBase *operator->() const noexcept
{
return mPooledObject;
}
/// @}
/// @name Recreation
/// @{
/**
* Recreates the stored object.
*/
void Recreate()
{
tBase *newObject = mPool->Get();
Dispose();
mPooledObject = newObject;
}
/// @}
private:
/// Stores our pooled object
tBase *mPooledObject;
/// The object pool
AbstractObjectPool< tBase > *mPool;
};
/// @}
#endif |
#include <stdint.h>
#include "compositeTypes.h"
typedef struct {
int foo; // FIXME
} notification_t;
typedef void (*ntfy_delegate_t)(uint32_t notificationId, constFatPtr_t msg, uint32_t senderId);
int ntfy_init(void);
int ntfy_post(uint32_t notificationId);
//int ntfy_postWith
|
//
// SecurityLoginViewController.h
// HRCocoaKit
//
// Created by 许昊然 on 2017/3/24.
// Copyright © 2017年 许昊然. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface SecurityLoginViewController : UIViewController
@end
|
//
// PizzaStore.h
// FactoryPattern
//
// Created by Vito on 12/10/13.
// Copyright (c) 2013 Vito. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "Pizza.h"
#import "SimplePizzaFactory.h"
@interface PizzaStore : NSObject
- (id)initWithFactory:(SimplePizzaFactory *)factory;
- (Pizza *)orderPizza:(NSString *)pizza;
@end
|
/* fspectral.h for ANSI C */
#ifndef FSPECTRAL_H
#define FSPECTRAL_H
#include "ffam.h"
#include "fres.h"
#include "fcho.h"
extern long fspectral_MaxN;
void fspectral_Fourier3 (ffam_Fam *fam, fres_Cont *res, fcho_Cho *cho,
int k, int r, int s,
int Nr, int j1, int j2, int jstep);
#endif
|
//The MIT License(MIT)
//
//Copyright(c) 2016 R-CO
//
//Permission is hereby granted, free of charge, to any person obtaining a copy
//of this software and associated documentation files(the "Software"), to deal
//in the Software without restriction, including without limitation the rights
//to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
//copies of the Software, and to permit persons to whom the Software is
//furnished to do so, subject to the following conditions :
//
//The above copyright notice and this permission notice shall be included in all
//copies or substantial portions of the Software.
//
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
//SOFTWARE.
/**
*** Author: R-CO
*** Mail: daniel1820kobe@gmail.com
*** Date: 2016-01-09
***/
#ifndef WX_PROJECT_TEMPLATE_MAIN_H
#define WX_PROJECT_TEMPLATE_MAIN_H
#include <wx/app.h>
namespace rco {
class WxProjectTemplateApp : public wxApp
{
public:
bool OnInit();
};
}
#endif
|
#ifndef scheduler_h
#define scheduler_h
#include "wren.h"
void schedulerResume(WrenValue* fiber);
void schedulerResumeBytes(WrenValue* fiber, const char* bytes, size_t length);
void schedulerResumeDouble(WrenValue* fiber, double value);
void schedulerResumeString(WrenValue* fiber, const char* text);
void schedulerResumeError(WrenValue* fiber, const char* error);
void schedulerShutdown();
#endif
|
#include <pebble.h>
#include <Watch_App_Face.h>
void init2();
void deinit2();
static Window *s_main_window;
Window *g_window;
// ------------------- BLUETOOTH combo attempt begin --------------------------
static TextLayer *try;
//Helper function-send numbers 1-3 corresponding to the options
//to the phone
void send_int(int key, int value) {
DictionaryIterator *iter;
app_message_outbox_begin(&iter);
dict_write_int(iter, key, &value, sizeof(int), true);
//Send the data!
app_message_outbox_send();
APP_LOG(APP_LOG_LEVEL_INFO, "Sent.");
}
// --------------------------------------Begin Button Press-------------------------------------------
void up_click_handler(ClickRecognizerRef recognizer, void *context) {
//TODO: Change to Emergency Call connection
init2();
text_layer_set_text(try, "Calling emergency contact");
layer_add_child(window_get_root_layer(s_main_window), text_layer_get_layer(try));
// psleep(4000);
send_int(1, 1);
deinit2();
}
void select_click_handler(ClickRecognizerRef recognizer, void *context) {
init2();
text_layer_set_text(try, "Calling 911");
layer_add_child(window_get_root_layer(s_main_window), text_layer_get_layer(try));
// send_int(2, 2);
deinit2();
}
void down_click_handler(ClickRecognizerRef recognizer, void *context) {
//TODO: Change to Send Text Message connection
init2();
text_layer_set_text(try, "Sending message");
layer_add_child(window_get_root_layer(s_main_window), text_layer_get_layer(try));
// send_int(3, 3);
deinit2();
}
void click_config_provider(void *context) {
// Register the ClickHandlers
window_single_click_subscribe(BUTTON_ID_UP, up_click_handler);
window_single_click_subscribe(BUTTON_ID_SELECT, select_click_handler);
window_single_click_subscribe(BUTTON_ID_DOWN, down_click_handler);
}
void main_window_load(Window *window) {
// Create output TextLayer
try = text_layer_create(GRect(0, 0, 144, 168));
text_layer_set_background_color(try, GColorBlack);
text_layer_set_text_color(try, GColorClear);
layer_add_child(window_get_root_layer(window), text_layer_get_layer(try));
// window_set_click_config_provider(s_main_window, click_config_provider);
}
void main_window_unload(Window *window) {
// Destroy output TextLayer
text_layer_destroy(try);
}
// ------------------- BLUETOOTH combo attempt end --------------------------
void init() {
//----------------------watch_app-------------------------------------
g_window = window_create();
window_set_window_handlers(g_window, (WindowHandlers)
{
.load = window_load,
.unload = window_unload,
});
window_set_click_config_provider(g_window, click_config_provider);
window_stack_push(g_window, true);
psleep(100);
//----------------------bluetooth-----------------------------------------------
// Create main Window
}
void deinit() {
//bluetooth
// Destroy main Window
//watch app
window_stack_remove(g_window,true);
window_destroy(g_window);
}
void init2()
{
s_main_window = window_create();
window_set_window_handlers(s_main_window, (WindowHandlers) {
.load = main_window_load,
.unload = main_window_unload
});
window_stack_push(s_main_window, true);
// text_layer_set_text(try, "Sending message");
APP_LOG(APP_LOG_LEVEL_INFO, "PUSHED.");
}
void deinit2()
{
// psleep(4000);
// window_stack_remove(s_main_window,true);
APP_LOG(APP_LOG_LEVEL_INFO, "POPPED.");
//window_destroy(s_main_window);
}
int main(void)
{
init();
app_event_loop();
deinit();
}
|
//
// UIAlertController+Speed.h
// LYCategory
//
// CREATED BY LUO YU ON 2017-03-17.
// Email: indie.luo@gmail.com
//
// The MIT License (MIT)
//
// Copyright (c) 2017 骆昱(Luo Yu). All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
// the Software, and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#import <UIKit/UIKit.h>
@interface UIAlertController (Speed)
/**
display an alert view controller with alertview style
@param viewvc from view controller
@param title title
@param message message
@param btnCancelTitle cancel button's title
@param btnConfirmTitle confirm button's title
@param btnConfirmBlock confirm action block
*/
+ (void)showAlertFromView:(UIViewController *)viewvc
withTitle:(NSString *)title
andMessage:(NSString *)message
cancelButtonTitle:(NSString *)btnCancelTitle
confirmButtonTitle:(NSString *)btnConfirmTitle
confirmAction:(void (^)(void))btnConfirmBlock;
/**
display an alert view controller with alertview style
@param viewvc from view controller
@param title title
@param message message
@param btnCancelTitle cancel button's title
@param btnCancelBlock cancel action block
*/
+ (void)showAlertFromView:(UIViewController *)viewvc
withTitle:(NSString *)title
andMessage:(NSString *)message
cancelButtonTitle:(NSString *)btnCancelTitle
cancelAction:(void (^)(void))btnCancelBlock;
/**
display an alert view controller for image picker with alertview style
@param viewvc from view controller
@param title title
@param message message
@param btnCancelTitle cancel button's title
@param btnCancelBlock cancel action block
@param buttonOneTitle button one's title
@param buttonOneBlock button one action block
@param buttonTwoTitle button two's title
@param buttonTwoBlock button two action block
*/
+ (void)showTwoItemActionSheetFromView:(UIViewController *)viewvc
withTitle:(NSString *)title
andMessage:(NSString *)message
cancelButtonTitle:(NSString *)btnCancelTitle
cancelAction:(void (^)(void))btnCancelBlock
buttonOneTitle:(NSString *)buttonOneTitle
buttonOneAction:(void (^)(void))buttonOneBlock
buttonTwoTitle:(NSString *)buttonTwoTitle
buttonTwoAction:(void (^)(void))buttonTwoBlock;
@end
|
#pragma once
#include <exception>
#include "include.h"
#include "environment.h"
#include "user.h"
//课程类
class Course
{
public:
Course(){}
Course(std::string id, std::string name, int credit);
~Course();
friend bool operator < (const Course& course1, const Course& course2);
friend std::istream& operator >> (std::istream& input, Course& course);
friend std::ostream& operator << (std::ostream& output, Course& course);
std::string getID();
std::string getName();
int getCredit();
int getCapicity();
void setCapicity(int num); //设置课程容量
Teacher* getTeacher(); //获取当前课程教师信息
void setTeacher(Teacher* teacher); //设置当前课程教师信息
std::set<Student*> getStudent(); //获取当前学生信息
void addStudent(Student* student); //添加学生信息
bool deleteStudent(Student* student); //删除当前学生信息
void clearStudent(); //清空学生信息
Student* findStudent(std::string id); //查找学生信息
bool checkStudent(Student* student);
bool checkTeacher(Teacher* teacher);
std::map<Student*, float> getStudentGrade(); //获取当前课程学生成绩
void setGrade(std::pair<Student*, float> student_grade); //设置学生成绩
float getMyGrade(Student* student); //获取指定学生的成绩
virtual float calculateGPA(Student*) {} //计算绩点
virtual int getCourseType() {} //获取课程类型(返回0代表选修,1代表必修)
protected:
std::map<Student*, float> m_student; //选课学生与对应成绩
private:
std::string m_ID; //课程编号
std::string m_name; //课程名称
int m_credit; //课程学分
int m_capicity = 100; //最大课程容量
Teacher* m_teacher = NULL; //授课教师
};
//必修课
class Obligatory_course: public Course
{
public:
using Course::Course;
float calculateGPA(Student* student) final override; //重载课程中计算GPA的虚函数
int getCourseType() final override;
};
//选修课
class Elective_course: public Course
{
public:
using Course::Course;
float calculateGPA(Student* student) final override; //重载课程中计算GPA的虚函数
int getCourseType() final override;
};
//重新包装权限后的课程类
class Course_user
{
public:
Course_user(){}
Course_user(Course* course){
this->m_course = course;
}
~Course_user(){}
friend bool operator < (const Course_user& course1, const Course_user& course2);
//学生与教师公共权限
std::string getID();
std::string getName();
int getCredit();
int getCourseType();
int getCapicity();
protected:
Course* m_course;
};
//学生端可操作的课程类
class Course_student: public Course_user
{
public:
Course_student(Course* course): Course_user(course){}
float getMyGrade(Student* student); //学生获取自己的成绩
float calculateGPA(Student* student); //计算绩点
std::string getTeacherName(); //获取当前教师信息
int getElectiveNum(); //学生获取选修课人数
void addElectiveStudent(Student* student); //学生增加选修课
bool deleteElectiveStudent(Student* student); //学生删除选修课
};
//教师端可操作的课程类
class Course_teacher: public Course_user
{
public:
Course_teacher(Course* course): Course_user(course){}
std::set<Student*> getStudent(); //获取当前学生信息
Student* findStudent(std::string id); //根据学号查找学生
std::map<Student*, float> getStudentGrade(); //获取当前课程学生成绩
void setGrade(std::pair<Student*, float> student_grade); //设置学生成绩
};
/*
//最高管理员权限的课程类
class Course_admin: public Course_teacher, public Course_student
{
public:
Course_admin(Course* course): Course_teacher(course), Course_student(course){}
using Course_student::operator<;
Teacher* getTeacher(); //获取当前课程教师信息
void setTeacher(Teacher* teacher); //设置当前课程教师信息
void setCapicity(int num);
bool addStudent(Student* student); //添加学生
bool deleteStudent(Student* student); //删除学生
};
*/
class AuthorityError: public std::exception
{
public:
const char* what()const throw()
{
return "该用户无操作权限";
}
};
|
/* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE127_Buffer_Underread__malloc_char_ncpy_14.c
Label Definition File: CWE127_Buffer_Underread__malloc.label.xml
Template File: sources-sink-14.tmpl.c
*/
/*
* @description
* CWE: 127 Buffer Under-read
* BadSource: Set data pointer to before the allocated memory buffer
* GoodSource: Set data pointer to the allocated memory buffer
* Sink: ncpy
* BadSink : Copy data to string using strncpy
* Flow Variant: 14 Control flow: if(globalFive==5) and if(globalFive!=5)
*
* */
#include "std_testcase.h"
#include <wchar.h>
#ifndef OMITBAD
void CWE127_Buffer_Underread__malloc_char_ncpy_14_bad()
{
char * data;
data = NULL;
if(globalFive==5)
{
{
char * dataBuffer = (char *)malloc(100*sizeof(char));
memset(dataBuffer, 'A', 100-1);
dataBuffer[100-1] = '\0';
/* FLAW: Set data pointer to before the allocated memory buffer */
data = dataBuffer - 8;
}
}
{
char dest[100];
memset(dest, 'C', 100-1); /* fill with 'C's */
dest[100-1] = '\0'; /* null terminate */
/* POTENTIAL FLAW: Possibly copy from a memory location located before the source buffer */
strncpy(dest, data, strlen(dest));
/* Ensure null termination */
dest[100-1] = '\0';
printLine(dest);
/* INCIDENTAL CWE-401: Memory Leak - data may not point to location
* returned by malloc() so can't safely call free() on it */
}
}
#endif /* OMITBAD */
#ifndef OMITGOOD
/* goodG2B1() - use goodsource and badsink by changing the globalFive==5 to globalFive!=5 */
static void goodG2B1()
{
char * data;
data = NULL;
if(globalFive!=5)
{
/* INCIDENTAL: CWE 561 Dead Code, the code below will never run */
printLine("Benign, fixed string");
}
else
{
{
char * dataBuffer = (char *)malloc(100*sizeof(char));
memset(dataBuffer, 'A', 100-1);
dataBuffer[100-1] = '\0';
/* FIX: Set data pointer to the allocated memory buffer */
data = dataBuffer;
}
}
{
char dest[100];
memset(dest, 'C', 100-1); /* fill with 'C's */
dest[100-1] = '\0'; /* null terminate */
/* POTENTIAL FLAW: Possibly copy from a memory location located before the source buffer */
strncpy(dest, data, strlen(dest));
/* Ensure null termination */
dest[100-1] = '\0';
printLine(dest);
/* INCIDENTAL CWE-401: Memory Leak - data may not point to location
* returned by malloc() so can't safely call free() on it */
}
}
/* goodG2B2() - use goodsource and badsink by reversing the blocks in the if statement */
static void goodG2B2()
{
char * data;
data = NULL;
if(globalFive==5)
{
{
char * dataBuffer = (char *)malloc(100*sizeof(char));
memset(dataBuffer, 'A', 100-1);
dataBuffer[100-1] = '\0';
/* FIX: Set data pointer to the allocated memory buffer */
data = dataBuffer;
}
}
{
char dest[100];
memset(dest, 'C', 100-1); /* fill with 'C's */
dest[100-1] = '\0'; /* null terminate */
/* POTENTIAL FLAW: Possibly copy from a memory location located before the source buffer */
strncpy(dest, data, strlen(dest));
/* Ensure null termination */
dest[100-1] = '\0';
printLine(dest);
/* INCIDENTAL CWE-401: Memory Leak - data may not point to location
* returned by malloc() so can't safely call free() on it */
}
}
void CWE127_Buffer_Underread__malloc_char_ncpy_14_good()
{
goodG2B1();
goodG2B2();
}
#endif /* OMITGOOD */
/* Below is the main(). It is only used when building this testcase on
* its own for testing or for building a binary to use in testing binary
* analysis tools. It is not used when compiling all the testcases as one
* application, which is how source code analysis tools are tested.
*/
#ifdef INCLUDEMAIN
int main(int argc, char * argv[])
{
/* seed randomness */
srand( (unsigned)time(NULL) );
#ifndef OMITGOOD
printLine("Calling good()...");
CWE127_Buffer_Underread__malloc_char_ncpy_14_good();
printLine("Finished good()");
#endif /* OMITGOOD */
#ifndef OMITBAD
printLine("Calling bad()...");
CWE127_Buffer_Underread__malloc_char_ncpy_14_bad();
printLine("Finished bad()");
#endif /* OMITBAD */
return 0;
}
#endif
|
@protocol IPosition, IVelocity, IMovable;
@protocol IRotation, IAngularVelocity, IRotatable;
@protocol IRadius, IRectangleSize;
@protocol IMass;
@protocol ICoefficientOfRestition;
@protocol IParticleCollider;
@protocol IHalfPlaneCollider, IAAHalfPlaneCollider;
@protocol IRectangleCollider, IAARectangleCollider;
@protocol ICustomCollider;
@protocol IParticle;
@protocol IRectParticle;
@protocol ILifetime;
@class Lifetime;
@protocol ISceneUser;
@protocol ICustomUpdate;
|
#define GLI_INCLUDE_ATI_SEPARATE_STENCIL
enum Main {
//GL_STENCIL_BACK_FUNC_ATI = 0x8800,
//GL_STENCIL_BACK_FAIL_ATI = 0x8801,
//GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI = 0x8802,
//GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI = 0x8803,
};
void glStencilOpSeparateATI( GLenum[Main] face, GLenum[Main] sfail, GLenum[Main] dpfail, GLenum[Main] dppass);
void glStencilFuncSeparateATI( GLenum[Main] frontfunc, GLenum[Main] backfunc, GLint ref, GLuint mask);
|
//
// GOLPosition.h
// GameOfLife
//
// Created by Will Grange on 16/07/2014.
// Copyright (c) 2014 Will Grange. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface GOLPosition : NSObject
@property (nonatomic, assign, readonly) NSInteger x;
@property (nonatomic, assign, readonly) NSInteger y;
- (instancetype)initWithX:(NSInteger)x Y:(NSInteger)y;
+ (GOLPosition *)positionWithX:(NSInteger)x Y:(NSInteger)y;
- (NSArray *)neighbours;
@end
|
/**
******************************************************************************
* @file stm32f4xx_hal_bluenrg_gpio.h
* @author MCD Application Team
* @version V1.0.0
* @date 01-October-2014
* @brief HAL specific implementation for stm32xx_lppuart.c
******************************************************************************
* @attention
*
* <h2><center>© COPYRIGHT(c) 2014 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_HAL_LPPUART_GPIO_H
#define __STM32F4XX_HAL_LPPUART_GPIO_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "stm32f4xx_hal.h"
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
/* Exported defines --------------------------------------------------------*/
#define GPIO_PIN_POSITION_0 ((uint8_t)0x00)
#define GPIO_PIN_POSITION_1 ((uint8_t)0x01)
#define GPIO_PIN_POSITION_2 ((uint8_t)0x02)
#define GPIO_PIN_POSITION_3 ((uint8_t)0x03)
#define GPIO_PIN_POSITION_4 ((uint8_t)0x04)
#define GPIO_PIN_POSITION_5 ((uint8_t)0x05)
#define GPIO_PIN_POSITION_6 ((uint8_t)0x06)
#define GPIO_PIN_POSITION_7 ((uint8_t)0x07)
#define GPIO_PIN_POSITION_8 ((uint8_t)0x08)
#define GPIO_PIN_POSITION_9 ((uint8_t)0x09)
#define GPIO_PIN_POSITION_10 ((uint8_t)0x0A)
#define GPIO_PIN_POSITION_11 ((uint8_t)0x0B)
#define GPIO_PIN_POSITION_12 ((uint8_t)0x0C)
#define GPIO_PIN_POSITION_13 ((uint8_t)0x0D)
#define GPIO_PIN_POSITION_14 ((uint8_t)0x0E)
#define GPIO_PIN_POSITION_15 ((uint8_t)0x0F)
/* Exported macros -----------------------------------------------------------*/
/* Exported functions ------------------------------------------------------- */
void HAL_LPPUART_GPIO_Set_PUPD(GPIO_TypeDef* GPIOx, uint32_t GPIO_Pin_Source, uint32_t GPIOPuPd);
void HAL_LPPUART_GPIO_Set_Mode(GPIO_TypeDef* GPIOx, uint32_t GPIO_Pin_Source, uint32_t GPIO_Mode);
void HAL_LPPUART_GPIO_Set_PinAFConfig(GPIO_TypeDef* GPIOx, uint32_t GPIO_Pin_Source, uint8_t GPIO_Alternate);
#ifdef __cplusplus
}
#endif
#endif /*__STM32F4XX_HAL_LPPUART_GPIO_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
#ifndef _TENSORFLOW_GPU_GEMM_H_
#define _TENSORFLOW_GPU_GEMM_H_
#include "gemm_engine.h"
namespace tensorflow {
class OpKernelContext;
class GEMMEngineTF : public octree::GEMMEngine<float> {
public:
void set_context(OpKernelContext* ctx) { context_ = ctx; }
virtual void gemm(const bool TransA, const bool TransB,
const int M, const int N, const int K, const float alpha,
const float* A, const float* B, const float beta, float* C) override;
public:
OpKernelContext* context_;
};
} // namespace tensorflow
#endif // _TENSORFLOW_GPU_GEMM_H_
|
/**
* Gallerizer — an image gallery indexing tool
* CLI version (pure libjpeg, no GD required)
* © 2012 Ilya I. Averkov (WST) <admin@jsmart.web.id>
*/
#include "string_functions.h"
#include <time.h>
#ifdef WIN32
char *strndup (const char *s, size_t n) {
char *result;
size_t len = strlen(s);
if(n < len) len = n;
result = (char *) malloc(len + 1);
if(!result) return 0;
result[len] = '\0';
return (char *) memcpy(result, s, len);
}
#endif
char *readfile(const char *filename) {
FILE *file = fopen(filename, "r");
fseek(file, 0, SEEK_END);
size_t filesize = ftell(file);
fseek(file, 0, SEEK_SET);
char *data = (char *) malloc(filesize + 1);
fread(data, 1, filesize, file);
fclose(file);
data[filesize] = 0;
return data;
}
char *substring(const char* str, size_t begin, size_t len) {
if(str == 0 || strlen(str) == 0 || strlen(str) < begin || strlen(str) < (begin+len)) return 0;
return strndup(str + begin, len);
}
long int strpos(const char *haystack, const char *needle) {
char *position = strstr(haystack, needle);
return position ? position - haystack : -1;
}
void append(char **source, const char *appendix) {
size_t string_length = strlen(*source);
size_t appendix_length = strlen(appendix);
size_t length = string_length + appendix_length;
*source = (char *) realloc(*source, length + 1);
memcpy(*source + string_length, appendix, appendix_length);
(* source)[length] = 0;
}
char *replaceStatic(char *where, const char *what, const char *with) {
char *offset = where;
char *position = 0;
char *result = calloc(1, 0);
size_t newlen = strlen(with);
size_t oldlen = strlen(what);
while(position = strstr(offset, what)) {
char *prefix = substring(offset, 0, (position - offset));
append(& result, prefix);
free(prefix);
append(& result, with);
offset = position + oldlen;
}
append(& result, offset);
return result;
}
void replace(char **where, const char *what, const char *with) {
char *offset = *where;
char *position = 0;
char *result = calloc(1, 0);
size_t newlen = strlen(with);
size_t oldlen = strlen(what);
while(position = strstr(offset, what)) {
char *prefix = substring(offset, 0, (position - offset));
append(& result, prefix);
free(prefix);
append(& result, with);
offset = position + oldlen;
}
append(& result, offset);
free(*where);
*where = result;
}
void replaceWithInteger(char **where, const char *what, unsigned long int with) {
char *replacement = integerToString(with);
replace(where, what, replacement);
free(replacement);
}
void replaceWithSize(char **where, const char *what, unsigned long int bytes) {
char *replacement = formatSize(bytes);
replace(where, what, replacement);
free(replacement);
}
void replaceWithNow(char **where, const char *what) {
char *replacement = date("%d.%m.%Y %H:%M");
replace(where, what, replacement);
free(replacement);
}
char *integerToString(unsigned long int value) {
char *buf = (char *) calloc(1, 40);
sprintf(buf, "%lu", value);
return buf;
}
char *formatDouble(double value) {
char *buf = (char *) calloc(1, 40);
sprintf(buf, "%.2F", value);
return buf;
}
char *formatSize(unsigned long int bytes) {
double dbytes = (double) bytes;
char *postfix[] = {" байт", " кб", " Мб", " Гб", " Тб"};
unsigned short int step = 0;
while(dbytes > 1024) {
dbytes /= 1024;
++ step;
}
char *left = formatDouble(dbytes);
char *result = concat(left, postfix[step]);
free(left);
return result;
}
char *concat(const char *left, const char *right) {
size_t left_length = strlen(left);
size_t right_length = strlen(right);
size_t length = left_length + right_length;
char *result = (char *) malloc(length + 1);
memcpy(result, left, left_length);
memcpy(result + left_length, right, right_length);
result[length] = 0;
return result;
}
char *date(const char *format) {
time_t rawtime;
struct tm *timeinfo;
time(& rawtime);
timeinfo = localtime(& rawtime);
char *buf = (char *) calloc(1, 40);
strftime(buf, 40, format, timeinfo);
return buf;
}
|
// libbari Copyright (C) Travis Whitaker 2015-2016
#include <math.h>
#include <bari.h>
// Magnitude (length) on bari_vec3.
float bari_mag3(bari_vec3 a)
{
return sqrtf((a.x * a.x) + (a.y * a.y) + (a.z * a.z));
}
|
// Copyright (c) 2013 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#ifndef ATOM_RENDERER_ATOM_RENDER_VIEW_OBSERVER_H_
#define ATOM_RENDERER_ATOM_RENDER_VIEW_OBSERVER_H_
#include "base/strings/string16.h"
#include "content/public/renderer/render_view_observer.h"
namespace base {
class ListValue;
}
namespace web_cache {
class WebCacheImpl;
}
namespace atom {
class AtomRendererClient;
class AtomRenderViewObserver : public content::RenderViewObserver {
public:
explicit AtomRenderViewObserver(content::RenderView* render_view,
AtomRendererClient* renderer_client,
web_cache::WebCacheImpl* web_cache_impl);
protected:
virtual ~AtomRenderViewObserver();
private:
// content::RenderViewObserver implementation.
void DidCreateDocumentElement(blink::WebLocalFrame* frame) override;
void DraggableRegionsChanged(blink::WebFrame* frame) override;
void OnDestruct() override;
void Navigate(const GURL& url) override;
// Whether the document object has been created.
web_cache::WebCacheImpl* web_cache_impl_; // not owned
bool document_created_;
DISALLOW_COPY_AND_ASSIGN(AtomRenderViewObserver);
};
} // namespace atom
#endif // ATOM_RENDERER_ATOM_RENDER_VIEW_OBSERVER_H_
|
//
// NSString+CZPath.h
//
// Created by 郑强飞 on 16/6/10.
// Copyright © 2016年 itcast. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface NSString (CZPath)
/// 给当前文件追加文档路径
- (NSString *)cz_appendDocumentDir;
/// 给当前文件追加缓存路径
- (NSString *)cz_appendCacheDir;
/// 给当前文件追加临时路径
- (NSString *)cz_appendTempDir;
@end
|
#include "pstructmember.h"
#include "pstringobject.h"
#include "pintobject.h"
#include "pfloatobject.h"
#include "plongobject.h"
#include "../pycodegen.h"
#include "../Python/pyver.h"
DEFINEFN
vinfo_t* PsycoMember_GetOne(PsycoObject* po, vinfo_t* addr, PyMemberDef* l)
{
condition_code_t cc;
vinfo_t* v;
vinfo_t* w1;
vinfo_t* w2;
defield_t rdf;
if (l->flags & READ_RESTRICTED)
goto fallback;
/* XXX add (some of) the missing types */
switch (l->type) {
case T_BYTE: /* read a byte, extend it signed */
rdf = FMUT(DEF_ARRAY(signed char, 0));
break;
case T_UBYTE: /* read a byte, extend it unsigned */
rdf = FMUT(UNSIGNED_ARRAY(unsigned char, 0));
break;
case T_SHORT: /* read a short, extend it signed */
rdf = FMUT(DEF_ARRAY(signed short, 0));
break;
case T_USHORT: /* read a short, extend it unsigned */
rdf = FMUT(UNSIGNED_ARRAY(unsigned short, 0));
break;
case T_INT:
case T_UINT:
case T_LONG:
case T_ULONG: /* read a long */
/* XXX assumes sizeof(int) == sizeof(long) */
rdf = FMUT(DEF_ARRAY(long, 0));
break;
#if HAVE_FP_FN_CALLS
case T_FLOAT: /* read a long, turn it into a float */
rdf = FMUT(DEF_ARRAY(float, 0));
w1 = psyco_get_field_offset(po, addr, rdf, l->offset);
if (w1 == NULL)
return NULL;
v = PsycoFloat_FromFloat(po, w1);
vinfo_decref(w1, po);
return v;
case T_DOUBLE: /* read two longs, turn them into a double */
rdf = FMUT(DEF_ARRAY(double, 0));
w1 = psyco_get_field_offset(po, addr, rdf, l->offset);
if (w1 == NULL)
return NULL;
w2 = psyco_get_field_offset(po, addr, FIELD_PART2(rdf),
l->offset);
if (w2 == NULL) {
vinfo_decref(w1, po);
return NULL;
}
v = PsycoFloat_FROM_DOUBLE(w1, w2);
return v;
#endif
case T_STRING: /* read a char*, turn it into a string */
rdf = FMUT(DEF_ARRAY(char*, 0));
w1 = psyco_get_field_offset(po, addr, rdf, l->offset);
if (w1 == NULL)
return NULL;
cc = integer_non_null(po, w1);
if (cc == CC_ERROR) {
vinfo_decref(w1, po);
return NULL;
}
if (runtime_condition_t(po, cc)) {
/* the char* is not NULL */
v = psyco_generic_call(po, PyString_FromString,
CfReturnRef|CfPyErrIfNull,
"v", w1);
if (v != NULL)
Psyco_AssertType(po, v, &PyString_Type);
}
else {
v = psyco_vi_None();
}
vinfo_decref(w1, po);
return v;
case T_STRING_INPLACE: /* read an array of characters from the struct */
w1 = integer_add_i(po, addr, l->offset, false);
if (w1 == NULL)
return NULL;
v = psyco_generic_call(po, PyString_FromString,
CfReturnRef|CfPyErrIfNull,
"v", w1);
if (v != NULL)
Psyco_AssertType(po, v, &PyString_Type);
vinfo_decref(w1, po);
return v;
case T_CHAR: /* read a byte, turn it into a char */
rdf = FMUT(UNSIGNED_ARRAY(unsigned char, 0));
w1 = psyco_get_field_offset(po, addr, rdf, l->offset);
if (w1 == NULL)
return NULL;
v = PsycoCharacter_New(w1);
vinfo_decref(w1, po);
return v;
case T_OBJECT: /* read a long, turn it into a PyObject with reference */
rdf = FMUT(DEF_ARRAY(PyObject*, 0));
v = psyco_get_field_offset(po, addr, rdf, l->offset);
if (v == NULL)
return NULL;
cc = integer_non_null(po, v);
if (cc == CC_ERROR) {
vinfo_decref(v, po);
return NULL;
}
if (runtime_condition_t(po, cc)) {
/* 'v' contains a non-NULL value */
need_reference(po, v);
}
else {
/* 'v' contains NULL */
vinfo_decref(v, po);
v = psyco_vi_None();
}
return v;
#ifdef T_OBJECT_EX
case T_OBJECT_EX: /* same as T_OBJECT, exception if NULL */
rdf = FMUT(DEF_ARRAY(PyObject*, 0));
v = psyco_get_field_offset(po, addr, rdf, l->offset);
if (v == NULL)
return NULL;
cc = integer_non_null(po, v);
if (cc == CC_ERROR) {
vinfo_decref(v, po);
return NULL;
}
if (runtime_condition_t(po, cc)) {
/* 'v' contains a non-NULL value */
need_reference(po, v);
}
else {
/* 'v' contains NULL */
vinfo_decref(v, po);
PycException_SetString(po, PyExc_AttributeError,
l->name);
return NULL;
}
return v;
#endif
default:
goto fallback;
}
/* for integer fields of any size */
v = psyco_get_field_offset(po, addr, rdf, l->offset);
if (v != NULL) {
if (!T_UINT_READS_AS_SIGNED && (l->type == T_UINT ||
l->type == T_ULONG)) {
vinfo_t* result = PsycoLong_FromUnsignedLong(po, v);
vinfo_decref(v, po);
v = result;
}
else
v = PsycoInt_FROM_LONG(v);
}
return v;
fallback:
/* call the Python implementation for cases we cannot handle directy */
return psyco_generic_call(po, PyMember_GetOne,
CfReturnRef|CfPyErrIfNull, "vl", addr, l);
}
|
/*
* automaton_transition_file_loader.h
*
* Created on: 5 Mar 2010
* Author: David
*/
#ifndef AUTOMATON_TRANSITION_FILE_LOADER_H_
#define AUTOMATON_TRANSITION_FILE_LOADER_H_
#include "ezxml/ezxml.h"
struct automaton;
struct automaton_set;
/*
* The maximum length of a line in the transition file. If this is exceeded
* then we abort the file.
*/
#define MAX_TRANSITION_FILE_LINE_LEN 1024
/*
* The number of different fields described in a transition block. Used to store
* all the lines for post processing.
*/
#define NUM_TRANSITION_FIELDS 4
/*
* The maximum length of a filename describing where the lua, csv files are in
* an automaton.
*/
#define MAX_INT_FILENAME_LEN 1024
/*
* PARSE_SINGLE_AUTOMATON_RET_CODES
*
* PARSE_SINGLE_AUTOMATON_OK - If the function was successful.
* PARSE_SINGLE_AUTOMATON_PARSE_FAIL - If any part of the file could not be
* parsed.
* PARSE_SINGLE_AUTOMATON_LOAD_MISSING_CSV_FILENAME - xml missing csv_filename
* tag.
* PARSE_SINGLE_AUTOMATON_MISSING_LUA_FILENAME - xml missing lua_filename tag.
* PARSE_SINGLE_AUTOMATON_LOAD_MISSING_START_STATE - xml missing start_state
* tag.
* PARSE_SINGLE_AUTOMATON_LOAD_INVALID_START_STATE - start_state tag doesn't match
* match any states in
* automaton.
*/
#define PARSE_SINGLE_AUTOMATON_OK 0
#define PARSE_SINGLE_AUTOMATON_PARSE_FAIL 1
#define PARSE_SINGLE_AUTOMATON_LOAD_MISSING_CSV_FILENAME 2
#define PARSE_SINGLE_AUTOMATON_LOAD_MISSING_LUA_FILENAME 3
#define PARSE_SINGLE_AUTOMATON_LOAD_MISSING_START_STATE 4
#define PARSE_SINGLE_AUTOMATON_LOAD_INVALID_START_STATE 5
/*
* AUTOMATON_XML_FILE_RET_CODES
*
* AUTOMATON_XML_FILE_OK - Function successful.
* AUTOMATON_XML_FILE_LOAD_FAIL - Failed to load the xml file.
* AUTOMATON_XML_FILE_PARSE_FAIL - Failed to parse the links for one of the
* automatons.
* AUTOMATON_XML_FILE_START_AUTOMATON_BAD - The automaton set does not have a
* starting automaton.
*/
#define AUTOMATON_XML_FILE_OK 0
#define AUTOMATON_XML_FILE_LOAD_FAIL 1
#define AUTOMATON_XML_FILE_LINKS_FAIL 2
#define AUTOMATON_XML_FILE_START_AUTOMATON_BAD 3
int parse_single_automaton(ezxml_t,
struct automaton *,
struct automaton_set *, char *, char *);
int parse_automaton_set_xml_file(char *,
struct automaton_set *,
int(*)(struct automaton_state ***, int),
int(*)(struct automaton_event ***),
struct match_state *);
#endif /* AUTOMATON_TRANSITION_FILE_LOADER_H_ */
|
//
// RootViewController.h
// IanScrollView
//
// Created by ian on 15/3/6.
// Copyright (c) 2015年 ian. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface RootViewController : UIViewController
@end
|
#ifndef _IVM_VM_INLINE_NUM_H_
#define _IVM_VM_INLINE_NUM_H_
#include "pub/com.h"
#include "pub/vm.h"
#include "vm/num.h"
#include "vm/obj.h"
IVM_COM_HEADER
IVM_INLINE
ivm_object_t *
ivm_numeric_new(ivm_vmstate_t *state, ivm_number_t val)
{
ivm_numeric_t *ret = ivm_vmstate_alloc(state, sizeof(*ret));
ivm_object_init(IVM_AS_OBJ(ret), IVM_BTTYPE(state, IVM_NUMERIC_T));
ret->val = val;
return IVM_AS_OBJ(ret);
}
IVM_INLINE
ivm_object_t *
ivm_bool_new(ivm_vmstate_t *state, ivm_bool_t val)
{
ivm_numeric_t *ret = ivm_vmstate_alloc(state, sizeof(*ret));
ivm_object_init(IVM_AS_OBJ(ret), IVM_BTTYPE(state, IVM_NUMERIC_T));
ret->val = !!val;
return IVM_AS_OBJ(ret);
}
IVM_COM_END
#endif
|
#ifndef __INPUT_H__
#define __INPUT_H__
#include "data.h"
void handleInput(char ch, AtcsoData *data, WINDOW *msgWin);
#endif
|
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
///btSoftBody implementation by Nathanael Presson
#ifndef SOFT_DEMO_H
#define SOFT_DEMO_H
#ifdef _WINDOWS
#include "Win32DemoApplication.h"
#define PlatformDemoApplication Win32DemoApplication
#else
#include "GlutDemoApplication.h"
#define PlatformDemoApplication GlutDemoApplication
#endif
#include "LinearMath/btAlignedObjectArray.h"
#include "BulletSoftBody/btSoftBody.h"
class btBroadphaseInterface;
class btCollisionShape;
class btOverlappingPairCache;
class btCollisionDispatcher;
class btConstraintSolver;
struct btCollisionAlgorithmCreateFunc;
class btDefaultCollisionConfiguration;
///collisions between two btSoftBody's
class btSoftSoftCollisionAlgorithm;
///collisions between a btSoftBody and a btRigidBody
class btSoftRididCollisionAlgorithm;
class btSoftRigidDynamicsWorld;
///CcdPhysicsDemo shows basic stacking using Bullet physics, and allows toggle of Ccd (using key '1')
class SoftDemo : public PlatformDemoApplication
{
public:
btAlignedObjectArray<btSoftSoftCollisionAlgorithm*> m_SoftSoftCollisionAlgorithms;
btAlignedObjectArray<btSoftRididCollisionAlgorithm*> m_SoftRigidCollisionAlgorithms;
btSoftBodyWorldInfo m_softBodyWorldInfo;
bool m_autocam;
bool m_cutting;
bool m_raycast;
btScalar m_animtime;
btClock m_clock;
int m_lastmousepos[2];
btVector3 m_impact;
btSoftBody::sRayCast m_results;
btSoftBody::Node* m_node;
btVector3 m_goal;
bool m_drag;
//keep the collision shapes, for deletion/cleanup
btAlignedObjectArray<btCollisionShape*> m_collisionShapes;
btBroadphaseInterface* m_broadphase;
btCollisionDispatcher* m_dispatcher;
btConstraintSolver* m_solver;
btCollisionAlgorithmCreateFunc* m_boxBoxCF;
btDefaultCollisionConfiguration* m_collisionConfiguration;
public:
void initPhysics();
void exitPhysics();
SoftDemo() : m_drag(false)
{
setTexturing(true);
setShadows(true);
}
virtual ~SoftDemo()
{
exitPhysics();
}
virtual void clientMoveAndDisplay();
virtual void displayCallback();
void createStack( btCollisionShape* boxShape, float halfCubeSize, int size, float zPos );
static DemoApplication* Create()
{
SoftDemo* demo = new SoftDemo;
demo->myinit();
demo->initPhysics();
return demo;
}
virtual void setDrawClusters(bool drawClusters);
virtual const btSoftRigidDynamicsWorld* getSoftDynamicsWorld() const
{
///just make it a btSoftRigidDynamicsWorld please
///or we will add type checking
return (btSoftRigidDynamicsWorld*) m_dynamicsWorld;
}
virtual btSoftRigidDynamicsWorld* getSoftDynamicsWorld()
{
///just make it a btSoftRigidDynamicsWorld please
///or we will add type checking
return (btSoftRigidDynamicsWorld*) m_dynamicsWorld;
}
//
void clientResetScene();
void renderme();
void keyboardCallback(unsigned char key, int x, int y);
void mouseFunc(int button, int state, int x, int y);
void mouseMotionFunc(int x,int y);
};
#define MACRO_SOFT_DEMO(a) class SoftDemo##a : public SoftDemo\
{\
public:\
static DemoApplication* Create()\
{\
SoftDemo* demo = new SoftDemo##a;\
extern int current_demo;\
current_demo=a;\
demo->myinit();\
demo->initPhysics();\
return demo;\
}\
};
MACRO_SOFT_DEMO(0) //Init_Cloth
MACRO_SOFT_DEMO(1) //Init_Pressure
MACRO_SOFT_DEMO(2)//Init_Volume
MACRO_SOFT_DEMO(3)//Init_Ropes
MACRO_SOFT_DEMO(4)//Init_Ropes_Attach
MACRO_SOFT_DEMO(5)//Init_ClothAttach
MACRO_SOFT_DEMO(6)//Init_Sticks
MACRO_SOFT_DEMO(7)//Init_Collide
MACRO_SOFT_DEMO(8)//Init_Collide2
MACRO_SOFT_DEMO(9)//Init_Collide3
MACRO_SOFT_DEMO(10)//Init_Impact
MACRO_SOFT_DEMO(11)//Init_Aero
MACRO_SOFT_DEMO(12)//Init_Friction
MACRO_SOFT_DEMO(13)//Init_Torus
MACRO_SOFT_DEMO(14)//Init_TorusMatch
MACRO_SOFT_DEMO(15)//Init_Bunny
MACRO_SOFT_DEMO(16)//Init_BunnyMatch
MACRO_SOFT_DEMO(17)//Init_Cutting1
MACRO_SOFT_DEMO(18)//Init_ClusterDeform
MACRO_SOFT_DEMO(19)//Init_ClusterCollide1
MACRO_SOFT_DEMO(20)//Init_ClusterCollide2
MACRO_SOFT_DEMO(21)//Init_ClusterSocket
MACRO_SOFT_DEMO(22)//Init_ClusterHinge
MACRO_SOFT_DEMO(23)//Init_ClusterCombine
MACRO_SOFT_DEMO(24)//Init_ClusterCar
MACRO_SOFT_DEMO(25)//Init_ClusterRobot
MACRO_SOFT_DEMO(26)//Init_ClusterStackSoft
MACRO_SOFT_DEMO(27)//Init_ClusterStackMixed
MACRO_SOFT_DEMO(28)//Init_TetraCube
MACRO_SOFT_DEMO(29)//Init_TetraBunny
#endif //CCD_PHYSICS_DEMO_H
|
/***************************************************************************************************
*
* SUBJECT:
* A Benckmark for Massive Multiplayer Online Games
* Game Server and Client
*
* AUTHOR:
* Mihai Paslariu
* Politehnica University of Bucharest, Bucharest, Romania
* mihplaesu@yahoo.com
*
* TIME AND PLACE:
* University of Toronto, Toronto, Canada
* March - August 2007
*
***************************************************************************************************/
#ifndef __RATE_MONITOR_H
#define __RATE_MONITOR_H
#define HOLD_VALUES 4096
/***************************************************************************************************
*
* RateMonitor - used fo bandwidth statistics
* - This class uses HOLD_VALUES samples. Each time a send/recv is called, the number of bytes
* transfered is added to the values vector and the timestamp is added to the timestamps vector.
* When the getAverage method is called, old values are discarded, then the average of the
* remaining values is computed, finaly even these values are discarded.
*
***************************************************************************************************/
class RateMonitor
{
private:
int n; /* number of samples */
Uint32 timestamps[HOLD_VALUES];
int values[HOLD_VALUES]; /* values for the number of bytes in send/recv calls */
public:
RateMonitor(); /* constructor */
void addValue(int x); /* add a sample to the vector */
float getAverage(); /* computes the average of recent values in the vector */
};
#endif
|
#include "user_config.h"
#if MOD_TC_MK2_ENABLE & I2C_ENABLE
#include "ets_sys.h"
#include "osapi.h"
#include "mem.h"
#include "queue.h"
#include "mod_tc_mk2.h"
#include "driver/i2c_master.h"
#include "driver/i2c_extention.h"
i2c_command tc_commands[] = {
{ .code = 0x20, .description = "Get ID" },
{ .code = 0x21, .description = "Get Temperature" }
};
void ICACHE_FLASH_ATTR tc_foreach(i2c_callback function) {
i2c_foreach(MOD_TC_MK2_ID, function);
}
i2c_config ICACHE_FLASH_ATTR *tc_init(uint8 *address, i2c_status *status) {
i2c_config *config = NULL;
*status = I2C_OK;
if (*address == 0) {
*address = MOD_TC_MK2_DEFAULT_ADDR;
}
config = i2c_find_config(*address, MOD_TC_MK2_ID);
// Check if there is device at address
if (i2c_check_device(*address) != I2C_OK) {
*status = I2C_DEVICE_NOT_FOUND;
return config;
}
uint8 id;
// Check if device is MOD-TC-MK2
if (i2c_read_id(*address, &id) != I2C_OK) {
*status = I2C_COMMUNICATION_FAILED;
return config;
}
if (id != MOD_TC_MK2_ID) {
*status = I2C_DEVICE_ID_DONT_MATCH;
return config;
}
if (config == NULL) {
config = i2c_add_config(*address, MOD_TC_MK2_ID, (void *)os_zalloc(sizeof(tc_config_data)));
tc_config_data *config_data = (tc_config_data *)config->data;
config_data->first = true;
}
return config;
}
i2c_status ICACHE_FLASH_ATTR tc_read(i2c_config *config) {
tc_config_data *config_data = (tc_config_data *)config->data;
i2c_master_start();
/* Send address */
i2c_master_writeByte(config->address << 1 | 0);
if (i2c_master_getAck()) {
i2c_master_stop();
return I2C_ADDRESS_NACK;
}
/* Send command */
i2c_master_writeByte(0x21);
if (i2c_master_getAck()) {
i2c_master_stop();
return I2C_DATA_NACK;
}
i2c_master_stop();
i2c_master_start();
i2c_master_writeByte(config->address << 1 | 1);
if (i2c_master_getAck()) {
i2c_master_stop();
return I2C_ADDRESS_NACK;
}
uint8 i;
uint8 data[4];
for (i=0; i < 4; i++) {
data[i] = i2c_master_readByte();
i2c_master_setAck(i == 3);
}
i2c_master_stop();
if ((data[2] & 0x01) != 0) {
return I2C_COMMUNICATION_FAILED;
}
sint16 d = data[3] * 256 + (data[2] & 0xFC);
// Low pass filter
if (config_data->first) {
config_data->first = false;
config_data->raw = d;
} else {
config_data->raw = config_data->raw + (d - config_data->raw) / MOD_TC_MK2_FILTER_FACTOR;
}
config_data->temperature = config_data->raw / 4;
float tf = 0.0625 * config_data->raw;
int ti = tf;
uint16 td = (tf - ti) * 100;
os_sprintf(config_data->temperature_str, "%d.%02d", ti, td);
return I2C_OK;
}
#endif
|
//
// NotasViewController.h
// MackNotas
//
// Created by Caio Remedio on 17/04/15.
// Copyright (c) 2015 Caio Remedio. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface NotasViewController : UITableViewController <UITabBarDelegate>
@end
|
void puts(char* string);
void putc(char* c);
void print_hex(int i);
|
/************************************************************
* Student Name: TreeBots *
* Exercise Name: Ex6 *
* File description: Declaration of Vector Class *
***********************************************************/
#ifndef __Robocup__SetTargetToTeamGoalNode__
#define __Robocup__SetTargetToTeamGoalNode__
#include "BehaviorTreeNode.h"
namespace behavior {
/****************************************************************************************************
* TurnNode Class: This command will turn the player’s body direction Moment *
* degrees relative to the current direction. Updates the Target's *
* Observable pointer. *
***************************************************************************************************/
class SetTargetToTeamGoalNode : public BehaviorTreeNode {
private:
double m_dDegreeThreshold;
public:
SetTargetToTeamGoalNode();
~SetTargetToTeamGoalNode();
virtual StatusType process();
};
}
#endif
|
//////////////////////////////////////////////////////////////////////////////
//
// Copyright 2014 Autodesk, Inc. All rights reserved.
//
// Use of this software is subject to the terms of the Autodesk license
// agreement provided at the time of installation or download, or which
// otherwise accompanies this software in either electronic or hard copy form.
//
//////////////////////////////////////////////////////////////////////////////
#ifndef ACUIDLGWORKSHEET_H
#define ACUIDLGWORKSHEET_H
#include "aduiDIalogWorksheet.h"
// CAcUiDialogWorksheet.h : header file
//
///////////////////////////////////////////////////////////////////////////////
//
// Introduction:
//
// Basics:
//
//
// Include File:
// CAcUiDialogWorksheet.h
//
///////////////////////////////////////////////////////////////////////////////
class ACUI_PORT CAcUiDialogWorksheet : public CAdUiDialogWorksheet
{
DECLARE_DYNAMIC(CAcUiDialogWorksheet);
// Construction
public:
CAcUiDialogWorksheet(UINT ID, CWnd* pParent = NULL, HINSTANCE hResInst=NULL); // standard constructor
~CAcUiDialogWorksheet();
// Dialog Data
//{{AFX_DATA(CAcUiDialogWorksheet)
enum { IDD = 0 };
// NOTE: the ClassWizard will add data members here
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAcUiDialogWorksheet)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CAcUiDialogWorksheet)
virtual BOOL OnInitDialog();
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg void OnPaint();
afx_msg void OnNcPaint();
afx_msg BOOL OnNcActivate(BOOL bActive);
afx_msg HCURSOR OnQueryDragIcon();
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
afx_msg BOOL OnEraseBkgnd(CDC *pDC);
afx_msg void OnNcLButtonDown( UINT nHitTest, CPoint point );
afx_msg void OnNcLButtonUp( UINT nHitTest, CPoint point );
afx_msg void OnNcMouseMove(UINT nHitTest,CPoint point);
afx_msg void OnMouseMove(UINT nHitTest,CPoint point);
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
#if _MSC_VER<1400
afx_msg UINT OnNcHitTest(CPoint point);
#else
afx_msg LRESULT OnNcHitTest(CPoint point);
#endif
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct);
afx_msg void OnSysColorChange();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif /* ACUIDLGWORKSHEET_H */
|
#include <stdio.h>
#include <string.h>
/*
M1_A_L PC15
M1_B_L PC14
M1_C_L PC13
M2_A_L PD2
M2_B_L PC11
M2_C_L PC12
M3_A_L PC10
M3_B_L PB2
M3_C_L PB13
M4_A_L PB15
M4_B_L PB12
M4_C_L PB14
*/
const char motor_channel_l[4][3][5] = {
"PC15",
"PC14",
"PC13",
"PD2",
"PC11",
"PC12",
"PC10",
"PB2",
"PB13",
"PB15",
"PB12",
"PB14"
};
/*
M1_A_H PB8
M1_B_H PB9
M1_C_H PB7
M2_A_H PB4
M2_B_H PB6
M2_C_H PB5
M3_A_H PC6
M3_B_H PC7
M3_C_H PC8
M4_A_H PA10
M4_B_H PC9
M4_C_H PA8
*/
const char motor_channel_h[4][3][5] = {
"PB8",
"PB9",
"PB7",
"PB4",
"PB6",
"PB5",
"PC6",
"PC7",
"PC8",
"PA10",
"PC9",
"PA8"
};
int port_offset(const char str[5])
{
return 0x400 * (str[1] - 'A');
}
int pin_offset(const char str[5])
{
int i;
sscanf(&(str[2]), "%d", &i);
return i;
}
void print_define_l_off()
{
int i, j;
for (i = 0; i < 4; i++) {
for (j = 0; j < 3; j++) {
printf("#define M%d_%c_L_OFF\t((uint32_t *)(0x42000000 + ((0x2001A + 0x%x) << 5) + (%2d << 2)))\n",
i + 1, j + 'A', port_offset(motor_channel_l[i][j]), pin_offset(motor_channel_l[i][j]));
}
}
}
void print_define_l_on()
{
int i, j;
for (i = 0; i < 4; i++) {
for (j = 0; j < 3; j++) {
printf("#define M%d_%c_L_ON\t((uint32_t *)(0x42000000 + ((0x20018 + 0x%x) << 5) + (%2d << 2)))\n",
i + 1, j + 'A', port_offset(motor_channel_l[i][j]), pin_offset(motor_channel_l[i][j]));
}
}
}
void print_define_pwm_ctrl()
{
int i, j;
for (i = 0; i < 4; i++) {
for (j = 0; j < 3; j++) {
printf("#define M%d_%c_PWM_CTRL_0\t((uint32_t *)(0x42000000 + ((0x20000 + 0x%x) << 5) + (%2d << 2)))\n",
i + 1, j + 'A', port_offset(motor_channel_h[i][j]), 2 * pin_offset(motor_channel_h[i][j]));
printf("#define M%d_%c_PWM_CTRL_1\t((uint32_t *)(0x42000000 + ((0x20000 + 0x%x) << 5) + (%2d << 2)))\n",
i + 1, j + 'A', port_offset(motor_channel_h[i][j]), 1 + 2 * pin_offset(motor_channel_h[i][j]));
}
}
}
void print_define_motor()
{
}
void print_define()
{
}
void main(void)
{
print_define_l_on();
print_define_l_off();
print_define_pwm_ctrl();
}
|
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "bits.h"
void test1()
{
unsigned int a = 9;
unsigned int b = 3;
printf("a:\n");
printBits(a);
printf("b:\n");
printBits(b);
printf("a&b:\n");
printBits(a&b);
printf("a|b:\n");
printBits(a|b);
printf("a^b:\n");
printBits(a^b);
printf("~a:\n");
printBits(~a);
}
void test2()
{
unsigned int a = 9;
printf("a:\n");
printBits(a);
setBitAt(&a, 10, 1);
printf("a after setBitAt(&a,10,1):\n");
printBits(a);
setBitAt(&a, 20, 1);
printf("a after setBitAt(&a,20,1):\n");
printBits(a);
setBitAt(&a, 0, 0);
printf("a after setBitAt(&a,0,0):\n");
printBits(a);
setBitAt(&a, 3, 0);
printf("a after setBitAt(&a,3,0):\n");
printBits(a);
}
void test3()
{
unsigned int a = 0xFFFF1009;
printf("a:\n");
printBits(a);
int v = getBitAt(a, 3);
printf("getBitAt(3)=%d\n", v);
v = getBitAt(a, 10);
printf("getBitAt(10)=%d\n", v);
v = getBitAt(a, 20);
printf("getBitAt(20)=%d\n", v);
v = getBitAt(a, 5);
printf("getBitAt(5)=%d\n", v);
}
void test4()
{
unsigned int a = 0x6F245FF2;
unsigned int b = 0x7F67FF89;
printf("a:\n");
printBits(a);
printf("countBits(a,1)=%d\n", countBits(a,1));
printf("countBits(a,0)=%d\n", countBits(a,0));
printf("b:\n");
printBits(b);
printf("countBits(b,1)=%d\n", countBits(b,1));
printf("countBits(b,0)=%d\n", countBits(b,0));
}
void test5()
{
unsigned int a = 0x6FE45F92;
unsigned int b = 0x7F67FF89;
int pos, count;
printf("a:\n");
printBits(a);
count = maxContinuousOnes(a, &pos);
printf("maxContinuousOnes(a, &pos)=%d pos=%d\n", count, pos);
printf("b:\n");
printBits(b);
count = maxContinuousOnes(b, &pos);
printf("maxContinuousOnes(b, &pos)=%d pos=%d\n", count, pos);
}
int main( int argc, char ** argv )
{
if (argc < 2) {
printf("test_bits [test1|test2|test3|test4|test5]\n");
exit(1);
}
if (strcmp(argv[1],"test1")==0) {
test1();
}
else if (strcmp(argv[1],"test2")==0) {
test2();
}
else if (strcmp(argv[1],"test3")==0) {
test3();
}
else if (strcmp(argv[1],"test4")==0) {
test4();
}
else if (strcmp(argv[1],"test5")==0) {
test5();
}
else {
printf("Invalid test\n");
return 1;
}
return 0;
}
|
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <em/em.h>
#include <matrix/matrix.h>
size_t const PREC = 53;
void print_help(char const* const name);
int read_mtx(char const* const file,
struct mtx ma,
struct mtx mc,
struct mtx mb0,
struct mtx mb1);
int main (int argc, char *argv[])
{
if (argc != 2)
{
print_help(argv[0]);
return -1;
}
struct mtx ma;
mtx_init(&ma, 125, 50, PREC);
struct mtx mb0;
mtx_init(&mb0, ma.nrows, 1, PREC);
struct mtx mb1;
mtx_init(&mb1, ma.nrows, 1, PREC);
struct mtx mc;
mtx_init(&mc, 1, ma.ncols, PREC);
struct mtx mx;
mtx_init(&mx, mc.ncols, mc.nrows, PREC);
if (read_mtx(argv[1], ma, mc, mb0, mb1))
return -1;
//mtx_fprint(stdout, ma);
//mtx_fprint(stdout, mc);
//mtx_fprint(stdout, mb0);
//mtx_fprint(stdout, mb1);
if (mtx_clear(ma) || mtx_clear(mb1) || mtx_clear(mb0) || mtx_clear(mc) || mtx_clear(mx))
return -1;
return 0;
}
void print_help(char const* const name)
{
printf("Usage:\n");
printf("\t%s FILE\n\n", name);
printf("FILE - file containing an optimization problem\n");
}
int read_mtx(char const* const file,
struct mtx ma,
struct mtx mc,
struct mtx mb0,
struct mtx mb1)
{
FILE* fp = fopen(file, "r");
if (NULL == fp)
{
printf("Can't open file '%s'\n", file);
return -1;
}
struct mtx mb;
mtx_init(&mb, 1, 125, PREC);
char buf[LINE_MAX];
fgets(buf, LINE_MAX, fp);
if (mtx_fscan(fp, mc, "\t"))
return -1;
fgets(buf, LINE_MAX, fp);
if (mtx_fscan(fp, mb, "\t"))
return -1;
if (mtx_tr(mb0, mb))
return -1;
fgets(buf, LINE_MAX, fp);
if (mtx_fscan(fp, mb, "\t"))
return -1;
if (mtx_tr(mb1, mb))
return -1;
fgets(buf, LINE_MAX, fp);
if (mtx_fscan(fp, ma, "\t"))
return -1;
if (fclose(fp))
return -1;
if (mtx_clear(mb))
return -1;
return 0;
}
|
// @file hit_spark.h
// @brief The hit_spark related functions and enumerates
// @author Mamoru Kaminaga
// @date 2017-08-13 14:22:51
// Copyright 2017 Mamoru Kaminaga
#ifndef HIT_SPARK_H_
#define HIT_SPARK_H_
#include <Vecmath.h>
#include <deque>
#include <vector>
#include "./counter.h"
#include "./scene.h"
enum HITSPARKSTATUS {
HITSPARKSTATUS_CREATE,
HITSPARKSTATUS_ACTIVE,
HITSPARKSTATUS_DESTROY,
};
struct HitSparkInitInfo {
int tex_id; // The texture id.
};
struct HitSparkUpdateInfo {
SceneData* scene_cmn_data; // The common data for scenes.
Point2d r0; // The position of the screen in the global system.
Vector2d v0; // The screen velocity in the global system.
};
struct HitSparkNewInfo {
Point2d r_ini; // The initial position.
};
struct HitSparkData {
int i_end; // The begin loop index.
int i_begin; // The end loop index.
std::vector<int> img_id; // The image id.
std::deque<int> img_index; // The current image id index.
std::deque<HITSPARKSTATUS> s; // The status.
std::deque<Point2d> r; // Positions.
std::deque<CounterData> cnt_img; // The frame counter for image.
};
bool InitHitSpark(const HitSparkInitInfo& init_info,
HitSparkData* hit_spark);
bool UpdateHitSpark(const HitSparkUpdateInfo& update_info,
HitSparkData* hit_spark);
void FinalizeHitSpark(HitSparkData* hit_spark);
bool NewHitSpark(const HitSparkNewInfo& new_info, HitSparkData* data);
#endif // HIT_SPARK_H_
|
/*
* Copyright (c) 2016, 2020 Oracle and/or its affiliates. All rights reserved.
*
* See the file EXAMPLES-LICENSE for license information.
*
*/
/*
* Head file for MacDonald Self-Service Ordering System.
*/
#include <sys/types.h>
#include <errno.h>
#include <fstream>
#include <iostream>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <iomanip>
#include <db_cxx.h>
#ifdef _WIN32
#define CLEANUP_CMD "rmdir envhome /q/s"
#define COPY_CMD \
"XCOPY ..\\..\\examples\\cxx\\excxx_order\\product.txt envhome"
#define PRODUCTFILE "envhome\\product.txt"
#else
#define CLEANUP_CMD "rm -rf envhome"
#define COPY_CMD "cp ../examples/cxx/excxx_order/product.txt ./envhome"
#define PRODUCTFILE "envhome/product.txt"
#endif
#define MAKEENV_CMD "mkdir envhome"
#define DEFAULT_HOMEDIR "envhome" /* Environment home directory. */
#define PRODUCTDB "productDB.db" /* Product database name. */
#define ORDERDB "orderDB.db" /* Order database name. */
#define MAXLEN 20 /* The length of string. */
/*
* BUFFERLENGTH is used in bulk operation.
* The buffer must be at least as large as the page size of
* the underlying database,aligned for unsigned integer access,
* and be a mutiple of 1024 bytes in size.
*/
#define BUFFERLENGTH (16 * 1024)
#define progname "MacDonald Self-service Ordering System"
using namespace std;
/*
* Product data structure.
*/
struct product {
public:
int product_no; /* The ID number of the product. */
char product_name[MAXLEN]; /* The name of the product. */
int product_price; /* The price of the product. */
char product_type[MAXLEN]; /* The type of the product. */
};
/*
* Order data structure.
*/
struct order {
public:
int product_no; /* The ID number of the product. */
int product_num; /* The number of the product. */
};
/*
* Customer data structure.
*/
class Customer
{
public:
void customer_run(Db *productdbp, Db *orderdbp, Db *productsdbp);
void operate_product(Db *productdbp, Db *orderdbp);
void order_product(Db *productdbp, Db *orderdbp);
void delete_order(Db *orderdbp);
void insert_into_order(product pro, Db *orderdbp, int num);
int delete_from_order(Db *orderdbp, int productno);
int search_product_no(int productno, Db *productdbp, product &pro);
int display_order_information(product pro, order ord);
int display_product_information(product pro);
void display_product_database(Db *productdbp);
void display_order_database(Db *orderdbp, Db *productdbp);
void display_product_based_on_type(Db *productsdbp);
void display_sdbp(string type, Db *productsdbp);
};
/*
* Administrator data structure.
*/
class Administrator
{
public:
Administrator();
int admin_login();
int admin_run();
void init_DbEnv();
void init_DbEnv_Recover();
void open_productdb();
void open_orderdb();
void bulk_read_product();
void show_product();
void print(product pro);
void read_product(string filename);
void bulk_update_product(string filename);
void delete_product();
product search_product_no(int productno, Db *productdb);
Db * get_productdb();
Db * get_orderdb();
Db * get_productsdb();
void close_db();
void throwException(DbEnv *dbenvp, int ret, const char *msg);
private:
DbEnv *dbenv; /* Environment handle. */
Db *product_dbp; /* Database containing product information. */
Db *product_type_sdbp; /* Secondary database based on product type. */
Db *order_dbp; /* Database containing order information. */
};
/*
* Function prototypes.
*/
int get_product_type(Db *sdbp, const Dbt *pkey, const Dbt *pdata, Dbt *skey);
|
#pragma once
#include <ionCore.h>
#include <ionMath.h>
#include "Enums.h"
#include "IShaderProgram.h"
#include "IVertexBuffer.h"
#include "IIndexBuffer.h"
#include "IUniform.h"
#include "ITexture.h"
#include "IPipelineState.h"
#include "IRenderTarget.h"
#include "CGraphicsAPI.h"
//! \defgroup ionGraphics ionGraphics
//!
//! ionGraphics is an abstract interface for hardware rendering libraries, i.e. OpenGL and DirectX
//! It is implemented for OpenGL in \ref ionGraphicsGL.
//! A DirectX implementation is not yet available.
//!
namespace ion
{
//! \brief Contains ionGraphics module and implementations
//!
//! Further documentation can be found
//! at the \ref ionGraphics page.
namespace Graphics
{
}
}
|
//-----------------------------------------------------------------------------
// MAEVARM M4 STM32F373 mBus
// version: 1.0
// date: March 22, 2013
// author: Neel Shah (neels@seas.upenn.edu)
//-----------------------------------------------------------------------------
#ifndef __m_bus
#define __m_bus
#include "mGeneral.h"
#define mBusStruct I2C1_DevStructure
/*
mBusGetLastError():
Returns the most recent mBus error code and clears the error.
Error code can be one of:
CPAL_I2C_ERR_NONE: No error
CPAL_I2C_ERR_TIMEOUT: Timeout occurred during communication or configuration
CPAL_I2C_ERR_BERR: Bus error
CPAL_I2C_ERR_ARLO: Lost arbitration
CPAL_I2C_ERR_AF: Acknowledge failure (slave gave a NACK instead of ACK)
CPAL_I2C_ERR_OVR: Overrun/underrun error
*/
uint32_t mBusGetLastError (void);
void mBusInit(void);
void mBusRestart(void);
uint8_t mBusPeriphReady(uint8_t slaveAddr);
uint8_t mBusWrite(uint8_t slaveAddr, uint8_t regAddr, uint8_t data);
uint8_t mBusRead (uint8_t slaveAddr, uint8_t regAddr);
uint8_t mBusWriteBurst(uint8_t slaveAddr, uint8_t regAddr, uint8_t length, uint8_t* data);
uint8_t mBusReadBurst (uint8_t slaveAddr, uint8_t regAddr, uint8_t length, uint8_t* data);
uint8_t mBusWriteNoAdd(uint8_t slaveAddr, uint8_t data);
uint8_t mBusReadNoAdd (uint8_t slaveAddr);
uint8_t mBusWriteBurstNoAdd(uint8_t slaveAddr, uint8_t length, uint8_t* data);
uint8_t mBusReadBurstNoAdd (uint8_t slaveAddr, uint8_t length, uint8_t* data);
//Non Blocking functions, user takes care of waiting and other stuff
uint8_t mBusWriteBurstNB(uint8_t slaveAddr, uint8_t regAddr, uint8_t length, uint8_t* data);
uint8_t mBusReadBurstStartNB(uint8_t slaveAddr, uint8_t regAddr, uint8_t length);
uint8_t mBusReadBurstDataNB (uint8_t length, uint8_t* data);
void CPAL_I2C_ERR_UserCallback(CPAL_DevTypeDef pDevInstance, uint32_t DeviceError);
uint32_t CPAL_TIMEOUT_UserCallback(CPAL_InitTypeDef* pDevInitStruct);
//void CPAL_I2C_TXTC_UserCallback(CPAL_InitTypeDef* pDevInitStruct);
//void CPAL_I2C_RXTC_UserCallback(CPAL_InitTypeDef* pDevInitStruct);
//void CPAL_I2C_TX_UserCallback(CPAL_InitTypeDef* pDevInitStruct);
//void CPAL_I2C_RX_UserCallback(CPAL_InitTypeDef* pDevInitStruct);
//void CPAL_I2C_DMATXTC_UserCallback(CPAL_InitTypeDef* pDevInitStruct);
//void CPAL_I2C_DMATXHT_UserCallback(CPAL_InitTypeDef* pDevInitStruct);
//void CPAL_I2C_DMATXTE_UserCallback(CPAL_InitTypeDef* pDevInitStruct);
void CPAL_I2C_DMARXTC_UserCallback(CPAL_InitTypeDef* pDevInitStruct);
//void CPAL_I2C_DMARXHT_UserCallback(CPAL_InitTypeDef* pDevInitStruct);
//void CPAL_I2C_DMARXTE_UserCallback(CPAL_InitTypeDef* pDevInitStruct);
#endif
|
//
// ExamineCell.h
// Guardian
//
// Created by WangQiang on 16/8/9.
// Copyright © 2016年 WangQiang. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface ExamineCell : UITableViewCell
@property (weak ,nonatomic)IBOutlet UILabel *contentLabel;
@end
|
#ifndef NATIVEHELPERS_H
#define NATIVEHELPERS_H
#include <QObject>
#include <QDomDocument>
#include <QDomElement>
#include <QtNetwork/QNetworkReply>
#include <QtCore/QFile>
#include <QtCore/QTime>
#include "helpers.h"
class nativehelpers : public QObject
{
Q_OBJECT
public:
nativehelpers(QObject *parent, helpers* helper=0);
helpers* m_phelpers;
public slots:
bool shellExecute(QString sAbsFN);
QString getFC(QString sFN);
bool setFC(QString sFN, QString sFC);
QString getCFG(QString sCfgEntryName);
bool setCFG(QString sCfgEntryName, QString sValue);
QString getSaveFileName(QString sPattern);
QString getOpenFileName(QString sPattern);
bool log(QString s);
void doQuit();
bool _access(QString sAbsFN);
bool copy(QString sAbsFNFrom,QString sAbsFNTo, bool bMakeReadOnly);
QString replacepeholders(QString s);
bool doDelete(QString sAbsFN);
qint64 getFileDate(QString sAbsFN);
bool isWritable(QString sAbsFN);
bool makeReadOnly(QString sAbsFN, bool bReadOnly);
};
#endif // NATIVEHELPERS_H
|
#ifndef PIPELINE_H
#define PIPELINE_H
#include <functional>
#include <vector>
template<class T>
class Pipeline
{
public:
typedef typename std::function<bool (T &)> ApplyFunction;
typedef typename std::function<void (T &)> RollbackFunction;
Pipeline<T> &AddStage(
ApplyFunction applyFunc,
RollbackFunction rollbackFunc = RollbackFunction());
bool operator()(T &message);
private:
std::vector<std::pair<ApplyFunction, RollbackFunction> > _stages;
};
template<class T>
Pipeline<T> &Pipeline<T>::AddStage(ApplyFunction applyFunc, RollbackFunction rollbackFunc)
{
_stages.push_back(std::make_pair(applyFunc, rollbackFunc));
return *this;
}
template<class T>
bool Pipeline<T>::operator()(T &message)
{
const int32_t count = _stages.size();
int32_t i;
for(i = 0; i < count; i++)
{
auto &stage = _stages[i].first;
if(!stage(message))
break;
}
if(i != count)
{
for(i--; i >= 0; i--)
{
auto &rollback = _stages[i].second;
if(rollback)
rollback(message);
}
}
return i == count;
}
#endif // PIPELINE_H |
/*
VerbLoad.h
(c)2000 Palestar Inc, Richard Lyle
*/
#ifndef VERBLOAD_H
#define VERBLOAD_H
#include "World/Verb.h"
#include "NounShip.h"
#include "GameDll.h"
//-------------------------------------------------------------------------------
class DLL VerbLoad : public Verb
{
public:
DECLARE_WIDGET_CLASS();
DECLARE_PROPERTY_LIST();
// Construction
VerbLoad();
VerbLoad( NounShip * pShip, Noun * pLoad );
// Verb Interface
Priority priority() const; // priority of this verb
Scope scope() const;
bool client() const; // is this a client verb, meaning okay to receive from a client
bool canAttach( Noun * pNoun );
void onExecute();
// Data
Noun::wRef m_pLoad;
// Static
static bool mayLoad( Noun * pLoad, NounShip * pShip );
static bool canLoad( Noun * pLoad, NounShip * pShip );
};
//----------------------------------------------------------------------------
#endif
//----------------------------------------------------------------------------
//EOF
|
//
// Stack.c
// 算法实战
//
// Created by 马远 on 2018/11/1.
// Copyright © 2018 Yuan. All rights reserved.
//
#include "Stack.h"
Stack *InitStack(void) {
Stack *stack = (Stack *)malloc(sizeof(Stack));
if (!stack) {
return NULL;
}
stack->top = -1;
return stack;
}
int IsFull(Stack *stack) {
if (stack->top == MAXSIZE -1) {
return 1;
}
return 0;
}
int IsEmpty(Stack *stack) {
if (stack->top == -1) {
return 1;
}
return 0;
}
void Push(Stack *stack, ElementType item) {
stack->data[++stack->top] = item;
}
ElementType Pop(Stack *stack) {
if (IsEmpty(stack)) {
return -404;
}
ElementType item = stack->data[stack->top];
stack->data[stack->top] = 0;
stack->top--;
return item;
}
void PrintStack(Stack *stack) {
for (int i = stack->top; i>=0; i--) {
printf("%d\n",stack->data[i]);
}
}
|
//
// FMChartSupport.h
// FMChartSupport
//
// Created by Keisuke Mori on 2015/09/21.
// Copyright © 2015 Keisuke Mori. All rights reserved.
//
#import <UIKit/UIKit.h>
//! Project version number for FMChartSupport.
FOUNDATION_EXPORT double FMChartSupportVersionNumber;
//! Project version string for FMChart.
FOUNDATION_EXPORT const unsigned char FMChartSupportVersionString[];
// In this header, you should import all the public headers of your framework using statements like #import <FMChartSupport/PublicHeader.h>
#import <FMChartSupport/DeviceResource.h>
#import <FMChartSupport/UIColor+Utility.h>
#import <FMChartSupport/chart_common.h>
#import <FMChartSupport/FMMetalChart.h>
#import <FMChartSupport/FMProjections.h>
#import <FMChartSupport/FMRenderables.h>
#import <FMChartSupport/FMRenderablesAux.h>
#import <FMChartSupport/FMProjectionUpdater.h>
#import <FMChartSupport/FMRangeFilters.h>
#import <FMChartSupport/FMInteractive.h>
#import <FMChartSupport/FMAxis.h>
#import <FMChartSupport/FMAxisLabel.h>
#import <FMChartSupport/FMAnimator.h>
#import <FMChartSupport/FMChartConfigurator.h>
#import <FMChartSupport/FMMetalView.h>
#import <FMChartSupport/Engine_common.h>
#import <FMChartSupport/Protocols.h>
#import <FMChartSupport/Engine.h>
#import <FMChartSupport/Buffers.h>
#import <FMChartSupport/Series.h>
#import <FMChartSupport/Line_common.h>
#import <FMChartSupport/LineBuffers.h>
#import <FMChartSupport/Lines.h>
#import <FMChartSupport/Point_common.h>
#import <FMChartSupport/PointBuffers.h>
#import <FMChartSupport/Points.h>
#import <FMChartSupport/Rect_common.h>
#import <FMChartSupport/RectBuffers.h>
#import <FMChartSupport/Rects.h>
#import <FMChartSupport/TextureQuad_common.h>
#import <FMChartSupport/TextureQuadBuffers.h>
#import <FMChartSupport/TextureQuads.h>
#import <FMChartSupport/circle_shared.h>
#import <FMChartSupport/CircleBuffers.h>
#import <FMChartSupport/Circles.h>
|
#ifndef CGUI_PIXEL_RENDERER_H
#define CGUI_PIXEL_RENDERER_H
#include <CDirectionType.h>
class CPixelRenderer;
class CGUIPixelRenderer {
private:
CPixelRenderer *renderer_;
public:
enum FrameStyle {
FRAME_RAISED,
FRAME_SUNKEN
};
CGUIPixelRenderer(CPixelRenderer *renderer) :
renderer_(renderer) {
}
virtual ~CGUIPixelRenderer() { }
public:
virtual void drawButton(int x, int y, int width, int height,
int thickness=2, bool pressed=false);
virtual void drawFrame(int x, int y, int width, int height,
int thickness=2, FrameStyle style=FRAME_RAISED);
virtual void drawTriangleButton(int x, int y, int width, int height,
CDirectionType direction, int thickness=2,
bool pressed=false);
};
#endif
|
/*
* Generated by class-dump 3.3.4 (64 bit).
*
* class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2011 by Steve Nygard.
*/
#import "NSNumber.h"
@interface NSNumber (iCalendarImport)
+ (id)boolFromICSString:(id)arg1;
@end
|
#pragma once
#include "ofMain.h"
//#include "surinachOsc.h"
#include "oscFFT.h"
//all other classes
#include "kai_01.h"
#include "soundizeMeApp.h"
#include "Angela.h"
#include "kiyo_circle.h"
#include "yu.h"
#define nBANDS 512
class ofApp : public ofBaseApp {
public:
void setup();
void update();
void draw();
void keyPressed(int key);
void keyReleased(int key);
void mouseMoved(int x, int y);
void mouseDragged(int x, int y, int button);
void mousePressed(int x, int y, int button);
void mouseReleased(int x, int y, int button);
void windowResized(int w, int h);
void dragEvent(ofDragInfo dragInfo);
void gotMessage(ofMessage msg);
int movementNumber;
float chan1Amp;
surinachOscFft oscFFT;
float smoothedFft_01[nBANDS];
float smoothedFft_02[nBANDS];
float smoothedAmp[4];
kai_01 kai;
santiSoundize santi;
Angela angela;
kiyoCircle kiyo1;
Yu yu;
};
|
//
// AppDelegate.h
// WLActivityViewController
//
// Created by Ling Wang on 3/17/15.
// Copyright (c) 2015 Moke. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@end
|
//
// SecondViewController.h
// Chatter
//
// Created by Steven on 4/5/13.
// Copyright (c) 2013 Steven. All rights reserved.
//
#import "ChannelHelper.h"
#import <UIKit/UIKit.h>
@interface HomeViewController : UIViewController <ChannelUpdatesDelegate, UITextFieldDelegate>
@property (strong, nonatomic) NSMutableArray *lstChannels;
@property (strong, nonatomic) IBOutlet UITableView *myTableView;
- (IBAction)addNewChannel:(id)sender;
@end
|
//
// JsenHomeViewController.h
// JsenKit
//
// Created by WangXuesen on 2017/11/2.
// Copyright © 2017年 WangXuesen. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "JsenViewController.h"
@interface JsenHomeViewController : JsenViewController
@end
|
//
// RVViewController.h
// RVAlertViewWithBlock
//
// Created by Rubén Vázquez on 9/15/13.
//
#import <UIKit/UIKit.h>
@interface RVViewController : UIViewController
@end
|
#define _WIN32_IE _WIN32_IE_IE70
#include "progress.h"
#include <stdio.h>
#include <windows.h>
#include <assert.h>
#include <versionhelpers.h>
#include <initguid.h>
#include <shlobj.h>
#define CHECK(result) if (FAILED(result)) {\
return result;\
}
#define CHECK_OBJ(obj, result) if (FAILED(result)) {\
obj->lpVtbl->Release(obj);\
return result;\
}
int wmain(int argc, wchar_t **argv) {
if (argc == 2) {
if (wcscmp(argv[1], L"--version") == 0) {
puts("2.0.0");
return 0;
}
if (wcscmp(argv[1], L"--help") == 0) {
puts("\n Move files and folders to the recycle bin\n\n Usage: recycle-bin <path> [...]\n\n Created by Sindre Sorhus");
return 0;
}
} else if (argc == 1) {
puts("Specify at least one path");
return 1;
}
int count = argc - 1;
wchar_t **files = argv + 1;
CHECK(CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE));
IFileOperation *op;
CHECK(CoCreateInstance(
&CLSID_FileOperation,
NULL,
CLSCTX_ALL,
&IID_IFileOperation,
(void**)&op
));
if (IsWindows8OrGreater()) {
CHECK_OBJ(op, op->lpVtbl->SetOperationFlags(
op,
FOFX_ADDUNDORECORD |
FOFX_RECYCLEONDELETE |
FOF_NOERRORUI |
FOF_NOCONFIRMATION |
FOF_SILENT |
FOFX_EARLYFAILURE
));
} else {
CHECK_OBJ(op, op->lpVtbl->SetOperationFlags(
op,
FOF_NO_UI |
FOF_ALLOWUNDO |
FOF_NOERRORUI |
FOF_SILENT |
FOFX_EARLYFAILURE
));
}
PCIDLIST_ABSOLUTE list[count];
for (int i = 0; i < count; i++) {
int len = GetFullPathName(files[i], 0, NULL, NULL);
if (len == 0) {
op->lpVtbl->Release(op);
return 1;
}
wchar_t *buf = malloc((len + 1) * sizeof(wchar_t));
GetFullPathName(files[i], len, buf, NULL);
list[i] = ILCreateFromPath(buf);
free(buf);
}
IShellItemArray *items;
DWORD cookie;
CHECK_OBJ(op, SHCreateShellItemArrayFromIDLists(count, list, &items));
CHECK_OBJ(op, op->lpVtbl->Advise(op, &progressSink, &cookie));
CHECK_OBJ(op, op->lpVtbl->DeleteItems(op, (IUnknown*)items));
CHECK_OBJ(op, op->lpVtbl->PerformOperations(op));
return op->lpVtbl->Release(op);
}
|
#include "cpio.h"
unsigned int cpio_validate(struct cpio_header *header)
{
return header->magic == 0x71C7;
}
unsigned int cpio_filedata(struct cpio_header *header)
{
return sizeof (struct cpio_header) + header->namesize + (header->namesize & 1);
}
unsigned int cpio_filesize(struct cpio_header *header)
{
return (header->filesize[0] << 16) | header->filesize[1];
}
unsigned int cpio_next(struct cpio_header *header)
{
unsigned int size = cpio_filesize(header);
return cpio_filedata(header) + size + (size & 1);
}
|
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#else
#ifndef FOUNDATION_EXPORT
#if defined(__cplusplus)
#define FOUNDATION_EXPORT extern "C"
#else
#define FOUNDATION_EXPORT extern
#endif
#endif
#endif
FOUNDATION_EXPORT double ContactCardVersionNumber;
FOUNDATION_EXPORT const unsigned char ContactCardVersionString[];
|
//
// RDMTeacherSignInViewController.h
// URLPusher-Teacher
//
// Created by Reese McLean on 8/5/13.
// Copyright (c) 2013 Reese McLean. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "RDMTeacherDataController.h"
@protocol RDMTeacherSignInViewControllerDelegate;
@interface RDMTeacherSignInViewController : UIViewController
@property (nonatomic, strong) RDMTeacherDataController *dataController;
@property (nonatomic, weak) id<RDMTeacherSignInViewControllerDelegate> delegate;
@end
@protocol RDMTeacherSignInViewControllerDelegate <NSObject>
-(void) signInVCDidPressCancel:(RDMTeacherSignInViewController*)vc;
-(void) signInVCDidPressForgotPassword:(RDMTeacherSignInViewController *)vc;
@end
|
//Thred Block Example
#include <stdio.h>
#define NUM_BLOCKS 16
#define BLOCK_WIDTH 1
__global__ void hello(){
printf("Hello world! I'm a thread in block %d\n", blockIdx.x);
}
int main(int argc, char **argv){
//launch the kernel
hello<<<NUM_BLOCKS, BLOCK_WIDTH>>>();
//force the printf()s to flush
cudaDeviceSynchronize();
printf("That's all!\n");
return 0;
} |
int main(void) {
float f;
float* ff = &f;
f = *ff;
f = ff;
}
|
/*
* Generated by class-dump 3.4 (64 bit).
*
* class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2012 by Steve Nygard.
*/
#import "MCMessage.h"
@interface MCMessage (MCMailboxAdapter)
- (id)mailMailbox;
@end
|
/*
* Copyright 1995-2017 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
*/
#include <string.h>
#include BOSS_OPENSSL_U_internal__nelem_h //original-code:"internal/nelem.h"
#include "testutil.h"
#if defined(OPENSSL_NO_DES) && !defined(OPENSSL_NO_MDC2)
# define OPENSSL_NO_MDC2
#endif
#ifndef OPENSSL_NO_MDC2
# include BOSS_OPENSSL_V_openssl__evp_h //original-code:<openssl/evp.h>
# include BOSS_OPENSSL_V_openssl__mdc2_h //original-code:<openssl/mdc2.h>
# ifdef CHARSET_EBCDIC
# include BOSS_OPENSSL_V_openssl__ebcdic_h //original-code:<openssl/ebcdic.h>
# endif
static unsigned char pad1[16] = {
0x42, 0xE5, 0x0C, 0xD2, 0x24, 0xBA, 0xCE, 0xBA,
0x76, 0x0B, 0xDD, 0x2B, 0xD4, 0x09, 0x28, 0x1A
};
static unsigned char pad2[16] = {
0x2E, 0x46, 0x79, 0xB5, 0xAD, 0xD9, 0xCA, 0x75,
0x35, 0xD8, 0x7A, 0xFE, 0xAB, 0x33, 0xBE, 0xE2
};
static int test_mdc2(void)
{
int testresult = 0;
unsigned char md[MDC2_DIGEST_LENGTH];
EVP_MD_CTX *c;
static char text[] = "Now is the time for all ";
size_t tlen = strlen(text);
# ifdef CHARSET_EBCDIC
ebcdic2ascii(text, text, tlen);
# endif
c = EVP_MD_CTX_new();
if (!TEST_ptr(c)
|| !TEST_true(EVP_DigestInit_ex(c, EVP_mdc2(), NULL))
|| !TEST_true(EVP_DigestUpdate(c, (unsigned char *)text, tlen))
|| !TEST_true(EVP_DigestFinal_ex(c, &(md[0]), NULL))
|| !TEST_mem_eq(md, MDC2_DIGEST_LENGTH, pad1, MDC2_DIGEST_LENGTH)
|| !TEST_true(EVP_DigestInit_ex(c, EVP_mdc2(), NULL)))
goto end;
/* FIXME: use a ctl function? */
((MDC2_CTX *)EVP_MD_CTX_md_data(c))->pad_type = 2;
if (!TEST_true(EVP_DigestUpdate(c, (unsigned char *)text, tlen))
|| !TEST_true(EVP_DigestFinal_ex(c, &(md[0]), NULL))
|| !TEST_mem_eq(md, MDC2_DIGEST_LENGTH, pad2, MDC2_DIGEST_LENGTH))
goto end;
testresult = 1;
end:
EVP_MD_CTX_free(c);
return testresult;
}
#endif
int setup_tests(void)
{
#ifndef OPENSSL_NO_MDC2
ADD_TEST(test_mdc2);
#endif
return 1;
}
|
//
// AppDelegate.h
// PaypalTestWebView
//
// Created by dev on 4/21/15.
// Copyright (c) 2015 self. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@end
|
//
// FOQueuedNavigationController.h
// FOQueuedNavigationController
//
// Created by Fábio Oliveira on 22/03/14.
// Copyright (c) 2014 Fábio Oliveira. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface FOQueuedNavigationController : UINavigationController
@end
|
//
// HomeViewController.h
// MyTabbar
//
// Created by 蔡成汉 on 2017/4/19.
// Copyright © 2017年 上海泰侠网络科技有限公司. All rights reserved.
//
#import "BaseViewController.h"
@interface HomeViewController : BaseViewController
@end
|
#ifndef GITCONFIG_H
#define GITCONFIG_H
// generated from class_header.h
#include <nan.h>
#include <string>
extern "C" {
#include <git2.h>
}
#include "../include/config.h"
// Forward declaration.
struct git_config {
};
using namespace node;
using namespace v8;
class GitConfig : public ObjectWrap {
public:
static Persistent<Function> constructor_template;
static void InitializeComponent (Handle<v8::Object> target);
git_config *GetValue();
git_config **GetRefValue();
void ClearValue();
static Handle<v8::Value> New(void *raw, bool selfFreeing);
bool selfFreeing;
private:
GitConfig(git_config *raw, bool selfFreeing);
~GitConfig();
static NAN_METHOD(JSNewFunction);
struct GetStringBaton {
int error_code;
const git_error* error;
const char * out;
const git_config * cfg;
const char * name;
};
class GetStringWorker : public NanAsyncWorker {
public:
GetStringWorker(
GetStringBaton *_baton,
NanCallback *callback
) : NanAsyncWorker(callback)
, baton(_baton) {};
~GetStringWorker() {};
void Execute();
void HandleOKCallback();
private:
GetStringBaton *baton;
};
static NAN_METHOD(GetString);
struct OpenDefaultBaton {
int error_code;
const git_error* error;
git_config * out;
};
class OpenDefaultWorker : public NanAsyncWorker {
public:
OpenDefaultWorker(
OpenDefaultBaton *_baton,
NanCallback *callback
) : NanAsyncWorker(callback)
, baton(_baton) {};
~OpenDefaultWorker() {};
void Execute();
void HandleOKCallback();
private:
OpenDefaultBaton *baton;
};
static NAN_METHOD(OpenDefault);
static NAN_METHOD(SetInt64);
static NAN_METHOD(SetMultivar);
struct SetStringBaton {
int error_code;
const git_error* error;
git_config * cfg;
const char * name;
const char * value;
};
class SetStringWorker : public NanAsyncWorker {
public:
SetStringWorker(
SetStringBaton *_baton,
NanCallback *callback
) : NanAsyncWorker(callback)
, baton(_baton) {};
~SetStringWorker() {};
void Execute();
void HandleOKCallback();
private:
SetStringBaton *baton;
};
static NAN_METHOD(SetString);
struct SnapshotBaton {
int error_code;
const git_error* error;
git_config * out;
git_config * config;
};
class SnapshotWorker : public NanAsyncWorker {
public:
SnapshotWorker(
SnapshotBaton *_baton,
NanCallback *callback
) : NanAsyncWorker(callback)
, baton(_baton) {};
~SnapshotWorker() {};
void Execute();
void HandleOKCallback();
private:
SnapshotBaton *baton;
};
static NAN_METHOD(Snapshot);
git_config *raw;
};
#endif
|
#include "quad.h"
/*
* Shift an (unsigned) quad value right (logical shift right).
*/
quad_t
__lshrdi3(quad_t a, qshift_t shift) {
union uu aa;
if (shift == 0) {
return (a);
}
aa.q = a;
if (shift >= INT_BITS) {
aa.ul[L] = aa.ul[H] >> (shift - INT_BITS);
aa.ul[H] = 0;
} else {
aa.ul[L] = (aa.ul[L] >> shift) |
(aa.ul[H] << (INT_BITS - shift));
aa.ul[H] >>= shift;
}
return (aa.q);
}
|
//
// AMCollectionViewController.h
// ScrollingNavbarDemo
//
// Created by David on 28/12/2013.
// Copyright (c) 2013 Andrea Mazzini. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "AMScrollingCollectionViewController.h"
@interface AMCollectionViewController : AMScrollingCollectionViewController
@end
|
#ifndef FIGHTERMENU_H
#define FIGHTERMENU_H
#include "Sprite.h"
#include "Text.h"
#include <utility>
#include <string>
#include <vector>
using std::string;
using std::vector;
#define N_SKINS 4
#define SKIN_SCALE 3
class FighterMenu {
private:
Sprite skin[N_SKINS];
Sprite disabled;
Text* name_text;
string name;
int n_frames;
bool enabled;
bool skin_available[N_SKINS];
public:
FighterMenu();
FighterMenu(string name, int frames, bool enabled = true);
bool is_enabled();
bool is_skin_available(int idx);
void lock_skin(int idx);
void unlock_skin(int idx);
Text* get_name_text();
string get_name();
string get_skin_name(int idx);
Sprite& get_skin(int idx);
Sprite& get_disabled();
};
#endif
|
#ifndef _PURPLE_BLOCK_H_
#define _PURPLE_BLOCK_H_
#include <animation.h>
#include <bitmapbase.h>
#include <graphics.h>
#include <nds.h>
#include "normalblock.h"
#include "purpleblockbmp.h"
#include "purpleblockbottombmp.h"
#include "purpleblockbottomleftbmp.h"
#include "purpleblockbottomleftrightbmp.h"
#include "purpleblockbottomrightbmp.h"
#include "purpleblockbounce1bmp.h"
#include "purpleblockbounce2bmp.h"
#include "purpleblockexplodebmp.h"
#include "purpleblockleftbmp.h"
#include "purpleblockleftrightbmp.h"
#include "purpleblockrightbmp.h"
#include "purpleblocktopbmp.h"
#include "purpleblocktopbottombmp.h"
#include "purpleblocktopleftbmp.h"
#include "purpleblocktopleftbottombmp.h"
#include "purpleblocktopleftrightbmp.h"
#include "purpleblocktopleftrightbottombmp.h"
#include "purpleblocktoprightbmp.h"
#include "purpleblocktoprightbottombmp.h"
#include "blockexplode1bmp.h"
#include "blockexplode2bmp.h"
#include "blockexplode3bmp.h"
#include "blockexplode4bmp.h"
#include "blockexplode5bmp.h"
/**
* A purple block.
*/
class PurpleBlock : public NormalBlock {
public:
/**
* Constructor.
*/
PurpleBlock() : NormalBlock(woopsiRGB(31, 0, 31)) {
_bitmaps[CONNECTION_NONE] = new PurpleBlockBmp();
_bitmaps[CONNECTION_TOP] = new PurpleBlockTopBmp();
_bitmaps[CONNECTION_BOTTOM] = new PurpleBlockBottomBmp();
_bitmaps[CONNECTION_TOP | CONNECTION_BOTTOM] = new PurpleBlockTopBottomBmp();
_bitmaps[CONNECTION_TOP | CONNECTION_LEFT] = new PurpleBlockTopLeftBmp();
_bitmaps[CONNECTION_TOP | CONNECTION_RIGHT] = new PurpleBlockTopRightBmp();
_bitmaps[CONNECTION_TOP | CONNECTION_LEFT | CONNECTION_RIGHT] = new PurpleBlockTopLeftRightBmp();
_bitmaps[CONNECTION_TOP | CONNECTION_BOTTOM | CONNECTION_LEFT] = new PurpleBlockTopLeftBottomBmp();
_bitmaps[CONNECTION_TOP | CONNECTION_BOTTOM | CONNECTION_RIGHT] = new PurpleBlockTopRightBottomBmp();
_bitmaps[CONNECTION_TOP | CONNECTION_BOTTOM | CONNECTION_LEFT | CONNECTION_RIGHT] = new PurpleBlockTopLeftRightBottomBmp();
_bitmaps[CONNECTION_BOTTOM | CONNECTION_LEFT] = new PurpleBlockBottomLeftBmp();
_bitmaps[CONNECTION_BOTTOM | CONNECTION_RIGHT] = new PurpleBlockBottomRightBmp();
_bitmaps[CONNECTION_BOTTOM | CONNECTION_LEFT | CONNECTION_RIGHT] = new PurpleBlockBottomLeftRightBmp();
_bitmaps[CONNECTION_LEFT] = new PurpleBlockLeftBmp();
_bitmaps[CONNECTION_RIGHT] = new PurpleBlockRightBmp();
_bitmaps[CONNECTION_LEFT | CONNECTION_RIGHT] = new PurpleBlockLeftRightBmp();
_explodingAnim->addFrame(&_explodeBmp1, 0);
_explodingAnim->addFrame(&_explodeBmp2, 0);
_explodingAnim->addFrame(&_explodeBmp3, 0);
_explodingAnim->addFrame(&_explodeBmp4, 0);
_explodingAnim->addFrame(&_explodeBmp5, 0);
_explodingAnim->addFrame(&_explodeBmp6, 0);
_landingAnim->addFrame(&_bounceBmp1, 0);
_landingAnim->addFrame(&_bounceBmp2, 0);
_landingAnim->addFrame(&_bounceBmp1, 0);
_landingAnim->addFrame(&_bounceBmp3, 0);
_landingAnim->addFrame(&_bounceBmp1, 0);
};
/**
* Destructor.
*/
~PurpleBlock() { };
private:
PurpleBlockExplodeBmp _explodeBmp1; /**< First explosion bitmap. */
BlockExplode1Bmp _explodeBmp2; /**< Second explosion bitmap. */
BlockExplode2Bmp _explodeBmp3; /**< Third explosion bitmap. */
BlockExplode3Bmp _explodeBmp4; /**< Fourth explosion bitmap. */
BlockExplode4Bmp _explodeBmp5; /**< Fifth explosion bitmap. */
BlockExplode5Bmp _explodeBmp6; /**< Sixth explosion bitmap. */
PurpleBlockBounce1Bmp _bounceBmp1; /**< First block bounce bitmap. */
PurpleBlockBounce2Bmp _bounceBmp2; /**< Second block bounce bitmap. */
PurpleBlockBmp _bounceBmp3; /**< Third block bounce bitmap. */
};
#endif
|
/*
* Copyright (c) 2016 Cormac Grindall (Mithreindeir)
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* vrFreely, subject to the following restrictions:
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*/
#ifndef NAPI_H
#define NAPI_H
#define _CRT_SECURE_NO_DEPRECATE 1
#include "cinterp.h"
#include "clexer.h"
#include "ast.h"
#include "ncomp.h"
#include "nstd.h"
//Opens and parses a file then runes
void nom_run_file(char * file);
//Function wrapper to be called in nom
void nom_import_wrapper(frame * cf);
//Imports a module and merges with current
void nom_import_file(frame * cf, char * file);
//Iterates through children to set var
void nom_set_var(frame * cf, nom_variable * n);
//Launches a nom interpreter / REPL
void nom_repl();
//Registers a C function to the interpreter
void nom_register_func(nom_interp * nom, char * name, nom_external_func func, int args);
//Registers a C funtion to a frame
void nom_register_func_frame(frame * f, char * name, nom_external_func func, int args);
#endif |
//
// 4sum.h
//
// Created by jeswang 27/06/2014.
//
/*
Description:
Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target.
Note:
Elements in a quadruplet (a,b,c,d) must be in non-descending order. (ie, a ≤ b ≤ c ≤ d)
The solution set must not contain duplicate quadruplets.
For example, given array S = {1 0 -1 0 -2 2}, and target = 0.
A solution set is:
(-1, 0, 0, 1)
(-2, -1, 1, 2)
(-2, 0, 0, 2)
*/
class Solution {
public:
void run() {
vector<int> input = {0,0,0};
vector<vector<int> > res = fourSum(input, 0);
for(auto i:res) {
for(auto j:i) {
cout<<j;
}
cout<<endl;
}
}
map<int, vector<pair<int, int> > > m;
vector<vector<int> > fourSum(vector<int> &num, int target) {
unsigned long len = num.size();
vector<vector<int> > res;
if (len==0) {
return res;
}
for(int i=0; i<len-1; i++) {
for(int j=i+1; j<len; j++) {
int k = num[i] + num[j];
if(m.find(k)==m.end()) {
vector<pair<int, int> > tmp;
tmp.push_back(make_pair(i, j));
m[k] = tmp;
}
else {
m[k].push_back(make_pair(i, j));
}
}
}
for(auto i=m.begin(); i!=m.end(); ) {
if(m.find(target-(*i).first)!=m.end()) {
//找到了,两两匹配
vector<pair<int, int> > first, second;
first = (*i).second;
second = m[target-(*i).first];
for(auto j:first)
for(auto k:second) {
vector<int> tmp;
if(j.first==k.second || j.first==k.first || j.second == k.first || j.second == k.second) {
continue;
}
else {
tmp.push_back(num[j.first]);
tmp.push_back(num[j.second]);
tmp.push_back(num[k.first]);
tmp.push_back(num[k.second]);
sort(tmp.begin(), tmp.end());
res.push_back(tmp);
}
}
i++;
}
else {
i = m.erase(i);
}
}
return res;
}
}; |
/**
* The MIT License (MIT)
*
* Copyright (c) 2013 cad-projects
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/**
* Author: Christian Pilato <christian.pilato@polimi.it>
*
* Description: This file contains support methods.
*/
#ifndef CADLIB_SUPPORT_H
#define CADLIB_SUPPORT_H
#include "llvm/ADT/OwningPtr.h"
#include "llvm/Instructions.h"
#include "llvm/Support/FormattedStream.h"
#include "llvm/Support/ToolOutputFile.h"
#include <list>
#include <set>
using namespace llvm;
namespace cadlib
{
std::string getOperator(const Instruction* I);
bool isMemoryRelated(const Value* I, std::set<const Value*>& alreadyAnalyzed, bool& isLoad, bool& isStore);
std::string getMemoryString(const Value* I);
void getMemoryUses(const Value* I, std::set<const Value*>& Uses);
const Value* getMemoryVar(const Value* I);
void getMemoryOps(const Value* I, std::list<const Value*>& operations);
const Value* getRealValue(const Value *I);
struct FormattedOutput
{
unsigned int IndentNum;
char OpeningChar;
char ClosingChar;
bool StartLine;
formatted_raw_ostream& oss;
FormattedOutput(formatted_raw_ostream &oss);
~FormattedOutput();
void Print(const std::string& str);
void Indent();
void DeIndent();
void PrintSpaces();
};
}
#endif
|
//
// Generated by class-dump 3.5 (64 bit).
//
// class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2013 by Steve Nygard.
//
#import "NSObject.h"
@class DVTMacroDefinitionTable, NSArray, NSMutableDictionary;
@interface IDEOverridingBuildProperties : NSObject
{
NSMutableDictionary *_macros;
NSArray *_arrayRepresentation;
unsigned long long _hash;
}
- (void).cxx_destruct;
- (id)dvt_detailedDebugDescription;
- (id)description;
- (unsigned long long)hash;
- (BOOL)isEqual:(id)arg1;
- (BOOL)isEmpty;
- (id)macroDefinitionTables;
@property(readonly, copy) DVTMacroDefinitionTable *macrosFromEnvironmentXcconfigFile;
@property(readonly, copy) DVTMacroDefinitionTable *macrosFromCommandLineXcconfigFile;
@property(readonly, copy) DVTMacroDefinitionTable *macrosFromCommandLine;
@property(readonly, copy) DVTMacroDefinitionTable *synthesizedMacros;
- (void)_setMacroDefinitionTable:(id)arg1 forLevel:(int)arg2;
- (id)macroDefinitionTableForLevel:(int)arg1;
- (id)mutableCopyWithZone:(struct _NSZone *)arg1;
- (id)copyWithZone:(struct _NSZone *)arg1;
- (id)_copyUsingOverridingPropertiesClass:(Class)arg1;
- (id)initWithMacroDefinitionTable:(id)arg1;
- (id)init;
@end
|
#pragma once
#include <string>
#include <map>
#include <vector>
#include <boost/rational.hpp>
#include "hex_generator.h"
/// TODO: replace with something slimmer
/// I don't need the 10 or so boost libraries that
/// boost rational includes
using rational_t = boost::rational<int32_t>;
// http://thealexandrian.net/wordpress/17320/roleplaying-games/hexcrawl-part-2-wilderness-travel
// http://thealexandrian.net/wordpress/17333/roleplaying-games/hexcrawl-part-4-encounter-tables
namespace fast_travel_sim
{
//assumed schedule
constexpr uint32_t num_hours_travelling = 8;
constexpr uint32_t num_hours_sleeping = 8;
constexpr uint32_t num_hours_surviving = 8;
//total = 24
// constexpr int32_t default_travel_rate = 24; //24 miles per day
constexpr int32_t default_travel_rate = 3; //24 miles per day
constexpr int32_t miles_per_hex = 6; // TEMP will make this variable later
enum path_type_e
{
path_paved = 0
, path_dirt
, path_none
, path_forest
, path_difficult
};
/// I could make path_type_e start at -2 and count upwards
/// but I prefer starting at 0 in case I want to index into
/// an array (it's common for me to have a constexpr array
/// of names)
constexpr int32_t path_difficulty_min = -2;
inline constexpr int32_t path_difficulty(path_type_e path)
{
return path_difficulty_min + path;
}
enum travel_pace_e
{
travel_pace_normal
, travel_pace_quick
, travel_pace_cautious
, travel_pace_exploring
, travel_pace_cautious_exploring
, travel_pace_foraging
, travel_pace_count
};
/// Experimenting with int percentages instead of floats
constexpr std::array<int32_t, travel_pace_count> travel_pace_percentages
{
100 // travel_pace_normal
, 150 // travel_pace_quick
, 75 // travel_pace_cautious
, 50 // travel_pace_exploring
, 20 // travel_pace_cautious_exploring
, 50 // travel_pace_foraging
};
constexpr std::array<char const*, travel_pace_count> travel_pace_strings =
{
"normal"
, "quick"
, "cautious"
, "exploring"
, "cautious exploring"
, "foraging"
};
struct route_segment_t
{
hex_coord_t coord;
path_type_e path = path_none;
travel_pace_e pace = travel_pace_normal;
rational_t dist = 0;
};
using journey_route_t = std::vector<route_segment_t>;
struct journey_segment_t : route_segment_t
{
std::vector<location_encounter_t> locations;
std::vector<plant_encounter_t> plants;
journey_segment_t(route_segment_t const& rseg)
: route_segment_t(rseg)
{}
};
// represents a day's worth of travel
struct journal_entry_t
{
std::vector<journey_segment_t> segments;
std::vector<creature_encounter_t> creatures;
int32_t rations_remaining = 0;
int32_t rations_gained = 0;
};
using journal_t = std::vector<journal_entry_t>;
/// WIP
struct daily_travel_schedule_t
{
uint32_t num_hours_travelling = 8;
uint32_t num_hours_sleeping = 8;
uint32_t num_hours_surviving = 8;
inline bool is_valid() const {
return num_hours_travelling
+ num_hours_sleeping
+ num_hours_surviving
== 24;
}
};
struct traveller_t
{
std::string name;
int32_t travel_rate = default_travel_rate;
int32_t survival_skill = 0;
int32_t navigation_skill = 0;
};
struct travel_group_t
{
std::vector<traveller_t> travellers;
int32_t slowest_travel_rate = std::numeric_limits<int32_t>::max();
int32_t highest_survival_skill = std::numeric_limits<int32_t>::min();
int32_t highest_navigation_skill = std::numeric_limits<int32_t>::min();
void add_traveller(traveller_t const& t);
void add_traveller(traveller_t&& t);
void adjust_cache(traveller_t const& t);
void rebuild_cache();
};
struct journey_t
{
travel_group_t travel_group;
journey_route_t route;
int32_t day_rations = 0;
size_t num_travellers() const
{ return travel_group.travellers.size(); }
};
inline std::string to_string(hex_coord_t const& c)
{
return "{" + std::to_string(c.x) + "," + std::to_string(c.y) + "}";
}
bool is_boring(generated_node_t const&);
bool is_boring(generated_hex_t const&);
bool is_boring(journal_entry_t const&);
int status_effect_value(generated_node_t const&);
journal_t simulate_journey(journey_t, hex_database_t const&);
std::string summarize(creature_encounter_t const&);
std::string summarize(location_encounter_t const&);
std::string summarize(plant_encounter_t const&);
std::string summarize(journey_segment_t const&);
std::string summarize(journal_entry_t const&);
std::string summarize(journal_t const&);
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.