text stringlengths 4 6.14k |
|---|
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "IOroBaseObject.generated.h"
// This class does not need to be modified.
UINTERFACE(MinimalAPI)
class UIOroBaseObject : public UInterface
{
GENERATED_UINTERFACE_BODY()
};
/**
*
*/
class OROUNREALPROTOTYPE_API IIOroBaseObject
{
GENERATED_IINTERFACE_BODY()
public:
UFUNCTION(BlueprintNativeEvent, BlueprintCallable)
void onCreate();
UFUNCTION(BlueprintNativeEvent, BlueprintCallable)
void onDestroy();
};
|
#include <data.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <time.h>
#define EXPECT(cond)\
if (!(cond)){\
fprintf(stderr, "Error: %s at %s:%d\n", #cond, __FILE__, __LINE__);\
exit(-1);\
}
void test000(const char* fname){
NGXARC arc = 0;
NGXBLK block = 0;
NGXBLK nblk = 0;
arc = ngxArcInit(fname, 0);
EXPECT(arc != 0);
EXPECT(ngxArcBlock(arc, 0xFFFF) == 0); // Invalid block id
block = ngxArcBlock(arc, 0);
EXPECT(block != 0);
EXPECT(ngxBlockID(0) == 0x0); // no segfault
EXPECT(ngxBlockNextID(0) == 0x0); // no segfault
EXPECT(ngxBlockID(block) == 0);
nblk = ngxArcBlock(arc, 1);
EXPECT(nblk != 0);
EXPECT(ngxBlockID(nblk) == 1);
EXPECT(ngxBlockNextID(nblk) == 0xFFFF);
EXPECT(ngxBlockSetNextID(block, 1) == 0);
EXPECT(ngxBlockNextID(block) == 1);
EXPECT(ngxArcUpdateBlock(arc, block) == 0);
ngxBlockCleanup(&nblk);
ngxBlockCleanup(&block);
EXPECT(nblk == 0);
EXPECT(block == 0);
ngxArcCleanup(&arc);
EXPECT(arc == 0);
}
#define DLEN (300)
void test001(const char* fname){
NGXARC arc = 0;
uint16_t blkid = 0xFFFF;
int* buf = 0;
uint32_t len = 0;
int* ibuf = malloc(sizeof(int)*DLEN);
for (int i = 0; i < DLEN; ++i){
ibuf[i] = rand();
}
arc = ngxArcInit(fname, 0);
blkid = ngxArcDataPut(arc, ibuf, DLEN*sizeof(int), 2);
EXPECT(blkid != 0xFFFF);
buf = (int*) ngxArcDataGet(arc, blkid, &len);
EXPECT(buf != 0);
EXPECT(len == DLEN*sizeof(int));
EXPECT(memcmp(buf, ibuf, len) == 0);
free(buf);
free(ibuf);
ngxArcCleanup(&arc);
}
int main(int argc, char* argv[]){
if (argc != 2){
fprintf(stderr, "Usage: %s FILENAME\n", argv[0]);
return -1;
}
srand(time(0));
test000(argv[1]);
test001(argv[1]);
}
|
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#ifndef STDAFX_H
#define STDAFX_H
#include "targetver.h"
#include <stdio.h>
#ifndef UCLA_HAVE_UNIX
#include <tchar.h>
#endif
#include <iostream>
// TODO: reference additional headers your program requires here
#endif // STDAFX_H
|
/*!*********************************************(C)**
+ Will Canada : DecipherOne Productions 2007 +
|--------------------------------------------------|
| This class is derived from TObject(base object |
| class) and is an somewhat abstract class for |
| creating and drawind specific shapes, which |
| will be derived from this class. |
| Additional classes such as models and such |
| will also be derived from this line of |
| inheritance. |
|__________________________________________________|
+--------------------------------------------------+*/
#ifndef _SHAPE_
#define _SHAPE_
class Shape : public TObject //!< Base Shape class : Derived from TObject
{
protected:
bool hasTexture; //!<Used to tell if the shape has a texture
public:
void SetHasTexture(bool arg); //!<Used to set if the shape has a texture
bool GetHasTexture(); //!<Used to see if shape has a texture
bool LoadTexture(char * arg, int imagetype); /*!< Function used to Load a texture into memory
for a shape. The Function takes 2 Arguments the first
is the path and name of the file to load. The second is
an integer value to pass to the PTexture function LoadTexture.
It should either be 0 for Bitmap, 1 For PNG, or 2 for a Targa File.
or 3 for FBO*/
PTexture Texture; //!< Texture Object for texture
Shape(std::string Narg); /*!< Overloaded Constructor takes a string argument as the human readable
form for the object. It then converts it to a char array and stores it
in the inherited data member Label for use with printing on the screen. */
Shape(); //!< Default Constructor
~Shape(); //!< Destructor : Automatically releases any textures associated with the object
};
#endif
|
/* Copyright (c) 2011 - Eric P. Mangold
* Copyright (c) 2011 - Peter Le Bek
*
* See LICENSE.txt for details.
*/
/* Just a few extra tests for lines/branches that have no coverage yet.
* The hash-table implementation was copied from CII and is generally
* believed to be bug-free. Even though we don't have direct tests
* for a lot of the code in table.c is seems very likely that if it was
* ever broken it would cause regressions elsewhere in the test
* suite. */
/* Check - C unit testing framework */
#include <check.h>
#include "table.h"
static int cmpatom(const void *x, const void *y)
{
return x != y;
}
static unsigned hashatom(const void *key)
{
/* all items go in same bucket */
return 0;
}
START_TEST(test_new_with_size)
{
/* A size hint should be respected */
Table_T *table = Table_new(130, cmpatom, hashatom);
fail_unless( Table_num_buckets(table) == 127 );
Table_free(&table);
}
END_TEST
START_TEST(test_put_replace)
{
/* New values replace old values with the same key. */
Table_T *table = Table_new(0, cmpatom, hashatom);
Table_put(table, (void*)0x12, (void*)0x34);
Table_put(table, (void*)0x12, (void*)0x56);
fail_unless( Table_length(table) == 1 );
fail_unless( Table_get(table, (void*)0x12) == (void*)0x56);
Table_remove(table, (void*)0x12);
Table_free(&table);
}
END_TEST
START_TEST(test_put_in_same_bucket)
{
/* Our hash function always places key/vals in the same bucket -
* assert that multiple items can be placed and retreived from
* the same bucket */
Table_T *table = Table_new(0, cmpatom, hashatom);
Table_put(table, (void*)0x12, (void*)0x34);
Table_put(table, (void*)0x56, (void*)0x78);
fail_unless( Table_length(table) == 2 );
fail_unless( Table_get(table, (void*)0x12) == (void*)0x34);
fail_unless( Table_get(table, (void*)0x56) == (void*)0x78);
Table_remove(table, (void*)0x12);
Table_remove(table, (void*)0x56);
Table_free(&table);
}
END_TEST
START_TEST(test_get)
{
/* Table_get() with non-existant key returns NULL */
Table_T *table = Table_new(0, cmpatom, hashatom);
Table_put(table, (void*)0x12, (void*)0x34);
fail_unless( Table_length(table) == 1 );
fail_unless( Table_get(table, (void*)0x12) == (void*)0x34);
/* non-existant key */
fail_unless( Table_get(table, (void*)0x34) == NULL);
Table_remove(table, (void*)0x12);
Table_free(&table);
}
END_TEST
Suite *make_table_suite(void)
{
Suite *s = suite_create ("Hash-Table");
TCase *tc_table = tcase_create("hash-table");
tcase_add_test(tc_table, test_new_with_size);
tcase_add_test(tc_table, test_put_replace);
tcase_add_test(tc_table, test_put_in_same_bucket);
tcase_add_test(tc_table, test_get);
suite_add_tcase(s, tc_table);
return s;
};
|
//
// GKNavigationBarViewController.h
// GKNavigationBarViewController
//
// Created by QuintGao on 2017/7/7.
// Copyright © 2017年 QuintGao. All rights reserved.
// 所有需要显示导航条的基类,可根据自己的需求设置导航栏
// 基本原理就是为每一个控制器添加自定义导航条,做到导航条与控制器相连的效果
#import <UIKit/UIKit.h>
#import "GKCategory.h"
#import "GKNavigationBar.h"
#import "GKNavigationBarConfigure.h"
@interface GKNavigationBarViewController : UIViewController
/// 自定义导航条
@property (nonatomic, strong, readonly) GKNavigationBar *gk_navigationBar;
/// 自定义导航条栏目
@property (nonatomic, strong, readonly) UINavigationItem *gk_navigationItem;
#pragma mark - 额外的快速设置导航栏的属性
@property (nonatomic, strong) UIColor *gk_navBarTintColor;
@property (nonatomic, strong) UIColor *gk_navBackgroundColor;
@property (nonatomic, strong) UIImage *gk_navBackgroundImage;
/** 设置导航栏分割线颜色或图片 */
@property (nonatomic, strong) UIColor *gk_navShadowColor;
@property (nonatomic, strong) UIImage *gk_navShadowImage;
@property (nonatomic, strong) UIColor *gk_navTintColor;
@property (nonatomic, strong) UIView *gk_navTitleView;
@property (nonatomic, strong) UIColor *gk_navTitleColor;
@property (nonatomic, strong) UIFont *gk_navTitleFont;
@property (nonatomic, strong) UIBarButtonItem *gk_navLeftBarButtonItem;
@property (nonatomic, strong) NSArray<UIBarButtonItem *> *gk_navLeftBarButtonItems;
@property (nonatomic, strong) UIBarButtonItem *gk_navRightBarButtonItem;
@property (nonatomic, strong) NSArray<UIBarButtonItem *> *gk_navRightBarButtonItems;
/** 页面标题-快速设置 */
@property (nonatomic, copy) NSString *gk_navTitle;
/// 是否隐藏导航栏分割线,默认为NO
@property (nonatomic, assign) BOOL gk_navLineHidden;
/// 显示导航栏分割线
- (void)showNavLine;
/// 隐藏导航栏分割线
- (void)hideNavLine;
/// 刷新导航栏frame
- (void)refreshNavBarFrame;
@end
|
// »ªÇڿƼ¼°æÈ¨ËùÓÐ 2008-2022
//
// ÎļþÃû£ºuisignal.h>
// ¹¦ ÄÜ£ºÐźÅÁ¿¡£
//
// ×÷ ÕߣºMPF¿ª·¢×é
// ʱ ¼ä£º2010-12-12
//
// ============================================================
#ifndef __UISIGNAL_H_
#define __UISIGNAL_H_
#include <System/Windows/Object.h>
namespace suic
{
class SUICORE_API UISignal
{
public:
UISignal(bool bSignal=true);
UISignal(bool bMenuReset,bool bSignal);
~UISignal();
operator Handle() const;
bool Wait(int iTimeout=INFINITE);
/// <summary>
/// µÈ´ýÄÚ²¿ºÍÍⲿʼþ¡£
/// </summary>
/// <param name="_Other">Íⲿʼþ</param>
/// <param name="iTimeout">³¬Ê±Ê±¼ä</param>
/// <returns>Èç¹û±¾Éíʼþ·µ»Ø,·µ»Ø1;Èç¹ûÍⲿʼþ·µ»Ø,·µ»Ø2;³¬Ê±·µ»Ø3;´íÎó-1</returns>
int Wait(UISignal& _Other, int iTimeout=INFINITE);
void Notify();
void Reset();
private:
Handle _signal;
};
}
#endif |
/*****************************************************************************
*
* \file
*
* \brief Generic 16-bit partial convolution function for the AVR32 UC3
*
* This file contains the code of the partial convolution.
*
* Copyright (c) 2014 Atmel Corporation. All rights reserved.
*
* \asf_license_start
*
* \page License
*
* 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. The name of Atmel may not be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* 4. This software may only be redistributed and used in connection with an
* Atmel microcontroller product.
*
* THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
* EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL 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.
*
* \asf_license_stop
*
******************************************************************************/
/**
* Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a>
*/
#include "dsp.h"
#include "preprocessor.h"
#if defined(FORCE_ALL_GENERICS) || \
defined(FORCE_GENERIC_VECT16_CONVPART) || \
!defined(TARGET_SPECIFIC_VECT16_CONVPART)
#define DSP16_SUM_ITEM(x, line) sum += pvect2[x]*pvect3[8 - x - 1];
#define DSP16_SUM_ITEM_INIT(x, line) sum += *pvect2++**--pvect3;
#define DSP16_CONVPART_KERNEL_X_FCT(x_num, data) \
static void TPASTE2(dsp16_vect_convpart_kernel_x, x_num)(dsp16_t *vect1, dsp16_t *vect2, int vect1_size, dsp16_t *vect3, int vect3_size) \
{ \
int i, j; \
dsp32_t sum; \
dsp16_t *pvect3, *pvect2; \
\
for(j=0; j<vect1_size; j++) \
{ \
sum = 0; \
pvect3 = &vect3[vect3_size]; \
pvect2 = &vect2[j]; \
\
MREPEAT(x_num, DSP16_SUM_ITEM_INIT, ) \
\
for(i=x_num; i<vect3_size; i += 8) \
{ \
pvect3 -= 8; \
MREPEAT8(DSP16_SUM_ITEM, ) \
pvect2 += 8; \
} \
\
vect1[j] = sum >> DSP16_QB; \
} \
}
DSP16_CONVPART_KERNEL_X_FCT(0, )
DSP16_CONVPART_KERNEL_X_FCT(1, )
DSP16_CONVPART_KERNEL_X_FCT(2, )
DSP16_CONVPART_KERNEL_X_FCT(3, )
DSP16_CONVPART_KERNEL_X_FCT(4, )
DSP16_CONVPART_KERNEL_X_FCT(5, )
DSP16_CONVPART_KERNEL_X_FCT(6, )
DSP16_CONVPART_KERNEL_X_FCT(7, )
void dsp16_vect_convpart(dsp16_t *vect1, dsp16_t *vect2, int vect2_size, dsp16_t *vect3, int vect3_size)
{
typedef void (*convpart_kernel_opti_t)(dsp16_t *, dsp16_t *, int, dsp16_t *, int);
static const convpart_kernel_opti_t convpart_kernel_opti[8] = {
dsp16_vect_convpart_kernel_x0,
dsp16_vect_convpart_kernel_x1,
dsp16_vect_convpart_kernel_x2,
dsp16_vect_convpart_kernel_x3,
dsp16_vect_convpart_kernel_x4,
dsp16_vect_convpart_kernel_x5,
dsp16_vect_convpart_kernel_x6,
dsp16_vect_convpart_kernel_x7
};
// Jump on different functions depending on the length of the partial convolution to compute
convpart_kernel_opti[vect3_size&0x7](vect1, vect2, vect2_size - vect3_size + 1, vect3, vect3_size);
}
#endif
|
void render_matrices(void)
{
static bool init=true;
static GLuint fb;
static GLuint fbo_points[4];
GLuint fb_type = GL_TEXTURE_RECTANGLE_ARB;
GLuint type = GL_TEXTURE_RECTANGLE_ARB;
static int fb_width = spline_tex.width;
static int fb_height = spline_tex.height;
if(init)
{
glGenFramebuffersEXT(1,&fb);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,fb);
fbo_points[0] = GFX::NewFloat16Tex(fb_width,fb_height,0,true);
fbo_points[1] = GFX::NewFloat16Tex(fb_width,fb_height,0,true);
fbo_points[2] = GFX::NewFloat16Tex(fb_width,fb_height,0,true);
spline_tex.handle_nbtpx_out = fbo_points[0];
spline_tex.handle_nbtpy_out = fbo_points[1];
spline_tex.handle_nbtpz_out = fbo_points[2];
glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT,
GL_COLOR_ATTACHMENT0_EXT, fb_type,
fbo_points[0], 0);
get_GL_error();
glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT,
GL_COLOR_ATTACHMENT1_EXT, fb_type,
fbo_points[1], 0);
get_GL_error();
glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT,
GL_COLOR_ATTACHMENT2_EXT, fb_type,
fbo_points[2], 0);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,0);
get_GL_error();
init = false;
}
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,fb);
get_GL_error();
GLenum dbuffers[] = {
GL_COLOR_ATTACHMENT0_EXT,
GL_COLOR_ATTACHMENT1_EXT,
GL_COLOR_ATTACHMENT2_EXT
};
glDrawBuffers(3, dbuffers);get_GL_error();
int viewport[4];
glGetIntegerv(GL_VIEWPORT, viewport);
glViewport(0,0,fb_width,fb_height); get_GL_error();
glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity();
glMatrixMode(GL_PROJECTION);glPushMatrix(); glLoadIdentity();
gluOrtho2D(0.0,fb_width,0.0,fb_height); get_GL_error();
glMatrixMode(GL_MODELVIEW);
glDisable(GL_CULL_FACE);
glDisable(GL_DEPTH_TEST);
glDepthMask(GL_FALSE);
// Matrix
glActiveTextureARB( GL_TEXTURE0 );
glBindTexture(type, spline_tex.handle_nbtpx);
glTexParameteri(type, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(type, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glActiveTextureARB( GL_TEXTURE1 );
glBindTexture(type, spline_tex.handle_nbtpy);
glTexParameteri(type, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(type, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glActiveTextureARB( GL_TEXTURE2 );
glBindTexture(type, spline_tex.handle_nbtpz);
glTexParameteri(type, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(type, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
// Params
glActiveTextureARB( GL_TEXTURE3 );
glBindTexture(type, spline_tex.handle_params);
glTexParameteri(type, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(type, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glActiveTextureARB( GL_TEXTURE0 );
//glClampColorARB(GL_CLAMP_VERTEX_COLOR_ARB, GL_FALSE);get_GL_error();
glMatrixMode(GL_MODELVIEW);
shader_matrices->begin();
// shader_matrices->setUniform1i("texSplineRowX",0);
// shader_matrices->setUniform1i("texSplineRowY",1);
// shader_matrices->setUniform1i("texSplineRowZ",2);
shader_matrices->setUniform1i("texSplineParams",3);
shader_matrices->setUniform1f("resolution",float(spline_tex.width));
shader_matrices->setUniform1f("adjust_rot",2);//float(1+GFX::mouseX*4));
shader_matrices->setUniform1f("adjust_pos",global_bend_adjust);//float(1+GFX::mouseY*5));
//shader_matrices->setUniform1f("pose_ofs",float(spline_tex.height));
glBegin(GL_QUADS);
glColor3f(1,1,1);
glMultiTexCoord2f( GL_TEXTURE0, 0.0, 0.0);
glVertex2f(0, 0);
glMultiTexCoord2f( GL_TEXTURE0, fb_width, 0.0);
glVertex2f(fb_width,0);
glMultiTexCoord2f( GL_TEXTURE0, fb_width, fb_height);
glVertex2f(fb_width, fb_height);
glMultiTexCoord2f( GL_TEXTURE0, 0.0, fb_height);
glVertex2f(0, fb_height);
glEnd();
shader_matrices->end();
get_GL_error();
glBindTexture(GL_TEXTURE_2D,0);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,0);
get_GL_error();
glEnable(GL_CULL_FACE);
glEnable(GL_DEPTH_TEST);
glDepthMask(GL_TRUE);
glMatrixMode(GL_PROJECTION);glPopMatrix();
glMatrixMode(GL_MODELVIEW); glPopMatrix();
glViewport(viewport[0],viewport[1],viewport[2],viewport[3]);
glDrawBuffer(GL_BACK);
}
|
#ifndef SHAPELENS_WEIGHTFUNCTION_H
#define SHAPELENS_WEIGHTFUNCTION_H
#include "../Typedef.h"
#include "Point.h"
namespace shapelens {
/// Abstract base class for weight functions.
class WeightFunction {
public:
/// Get value of weight function at position \p P.
virtual data_t operator()(const Point<data_t>& P) const = 0;
};
/// Default implementation of flat weight function.
class FlatWeightFunction : public WeightFunction {
public:
/// Constructor.
FlatWeightFunction();
/// Get value of weight function at position \p P.
/// Returns 1.
virtual data_t operator()(const Point<data_t>& P) const;
};
/// Localized weight function.
class LocalWeightFunction : public WeightFunction {
public:
/// Constructor.
LocalWeightFunction(const Point<data_t>& P);
/// Set the centroid.
virtual void setCentroid(const Point<data_t>& centroid);
/// Get centroid position.
virtual const Point<data_t>& getCentroid() const;
/// Get value of weight function at position \p P.
virtual data_t operator()(const Point<data_t>& P) const = 0;
protected:
/// Centroid/reference position.
Point<data_t> C;
};
/// Gaussian weight function.
/// Returns \f$W(x) = \exp\Bigl(\frac{-x^{\prime 2}}{2s^s}\Bigr)\f$, i.e.
/// the weight are drawn from a circular Gaussian of scale \f$s\f$,
/// centered at some predefined centroid position.\n
/// Derivatives (w.r.t. \f$s\f$ or \f$s^2\f$) can be accessed by
/// choosing the repective derivative order with setDerivative().
class GaussianWeightFunction : public LocalWeightFunction {
public:
/// Constructor.
GaussianWeightFunction(data_t scale, const Point<data_t>& centroid);
/// Get value of weight function.
virtual data_t operator()(const Point<data_t>& P) const;
/// Get scale.
data_t getScale() const;
/// Set scale.
void setScale(data_t scale);
/// Set derivative of weight function.
/// Positive \p n denotes derivatives w.r.t. \f$s\f$,
/// negative w.r.t. \f$s^2\f$. Orders up to 3 are implemented, order 0
/// recovers the original weight function.
void setDerivative(int n);
/// Get the current derivative.
int getDerivative() const;
protected:
int n;
data_t scale, sigma2;
data_t (GaussianWeightFunction::*fptr) (const Point<data_t>&) const;
data_t Gauss(data_t r) const;
data_t Gauss(const Point<data_t>& P) const;
data_t Gauss_(const Point<data_t>& P) const;
data_t Gauss__(const Point<data_t>& P) const;
data_t Gauss___(const Point<data_t>& P) const;
data_t Gauss_2(const Point<data_t>& P) const;
data_t Gauss__2(const Point<data_t>& P) const;
data_t Gauss___2(const Point<data_t>& P) const;
};
inline data_t GaussianWeightFunction::operator()(const Point<data_t>& P) const {
return (*this.*fptr)(P);
}
/// Weight function for power-law distance weighting.
class PowerLawWeightFunction : public LocalWeightFunction {
public:
/// Constructor
PowerLawWeightFunction(const Point<data_t>& centroid, data_t index);
/// Return \f$r^n\f$.
/// \f$ r\f$ is the Euclidean distance between \p P and the reference point
/// and \f$ n\f$ the power-law index.
virtual data_t operator() (const Point<data_t>& P) const;
private:
data_t n;
};
} // end namespace
#endif
|
//
// CMusicWesternHarmony.h
// CMusic
//
// Created by CHARLES GILLINGHAM on 10/2/15.
// Copyright (c) 2015 CharlesGillingham. All rights reserved.
//
#import "CMusicHarmony.h"
#import "CMusicHarmony+Scales.h"
// These six scales are the only scales where all intervals at a scale distance of 2 are major and minor thirds; i.e., these scales are exactly those that have a particular density of notes. For performance reasons, it is easier for this application to choose randomly between these predetermined choices, rather than reinventing the nature of scales on the fly. We can extend this to include other scales (such as pentatonic), but adding a distribution of the scale "density" is beyond me now.
// As a side effect, the distributions are easier to control, and they have names that you can recognize.
typedef SInt16 CMusicScaleType;
enum {
CMusicScaleType_Major = 0,
CMusicScaleType_MelodicMinor = 1,
CMusicScaleType_HarmonicMinor = 2,
CMusicScaleType_HarmonicMajor = 3,
CMusicScaleType_WholeTone = 4,
CMusicScaleType_EightNote = 5
};
enum {
CMusicScaleType_Min = 0,
CMusicScaleType_Max = 5,
CMusicScaleType_Count = 6
};
// An integer between 0 and 7, although the maximum depends on the scale.
// (Mode is zero-based here, unlike common practice.)
typedef SInt16 CMusicScaleMode;
enum {
CMusicMode_Ionian = 0,
CMusicMode_Dorian = 1,
CMusicMode_Phrygian = 2,
CMusicMode_Lydian = 3,
CMusicMode_Mixolydian = 4,
CMusicMode_Aeolian = 5,
CMusicMode_Locrian = 6,
CMusicMode_8thMode = 7
};
enum {
CMusicScaleMode_Min = 0, // Just to emphasize this is zero based, unlike common practice
CMusicWScaleMode_Count = 8, // The maximum number of modes for any western scale (actual count varies by type)
CMusicWScaleMode_Max = 7 // The maximum mode of any scale.
};
// These are the four types of triads, defined in terms of pitchClass distances.
typedef SInt16 CMusicChordType;
enum {
CMusicChordTypeMajor = 0,
CMusicChordTypeMinor = 1,
CMusicChordTypeAugmented = 2,
CMusicChordTypeDiminished = 3
};
enum {
MChordType_Max = 3,
MChordType_Count = 4
};
// Every western harmony represented here has a unique number. The total number of scales is:
// 4 seven note scales, in 12 keys with 7 modes and 7 chord roots.
// 1 six note scale, in 12 keys with 6 roots and 1 mode
// 1 eight note scale, in 12 keys with
// Note: the last two scales will have identical harmonic strengths for some key/chord combinations.
enum {
CMusicWesternHarmony_Count = (12*7*7)*4 + 12*6*1 + 12*8*2,
CMusicWesternHarmony_Min = 0,
CMusicWesternHarmony_Max = CMusicWesternHarmony_Count-1
};
@interface CMusicWesternHarmony : CMusicHarmony
@property CMusicScaleType scaleType;
@property CMusicScaleMode scaleMode;
@property SInt16 number;
@property (readonly) CMusicChordType chordType;
- (id) initWithType: (CMusicScaleType) type
mode: (CMusicScaleMode) mode
key: (CMusicPitchClass) key
chordRoot: (CMusicScaleDegree) sd;
+ (instancetype) CMajorI;
@end
|
#ifndef BINARYTREENODE_H
#define BINARYTREENODE_H
#include <iostream>
using namespace std;
struct binaryTreeNode
{
int element;
binaryTreeNode *leftChild,
*rightChild;
binaryTreeNode() {leftChild = rightChild = NULL;}
binaryTreeNode(const int& theElement)
{
element = theElement;
leftChild = rightChild = NULL;
}
binaryTreeNode(const int& theElement,
binaryTreeNode *theLeftChild,
binaryTreeNode *theRightChild)
{
element = theElement;
leftChild = theLeftChild;
rightChild = theRightChild;
}
};
#endif
|
/*
* boatWithSupport.h
*
* Created on: 16 de Abr de 2013
* Author: Windows
*/
#ifndef BOATWITHSUPPORT_H_
#define BOATWITHSUPPORT_H_
#include "Boat.h"
class BoatWithSupport: public Boat {
private:
int extraCap;
int lastTransported;
int lastMaxCap;
public:
/**
* Creates a new boat with support
* @param extraCapacity -> the max capacity of the support boat
*/
BoatWithSupport(int extraCapacity);
/**
* Creates a new boat with support
* @param extraCapacity -> the max capacity of the support boat
* @param capacity -> the max capacity of the boat
*/
BoatWithSupport(int capacity, int extraCapacity);
/**
*
* @return the max capacity of the boat
*/
int getMaxCapacity();
/**
*
* @return the max capacity of the support boat
*/
int getExtraCapacity();
virtual ~BoatWithSupport();
/**
* Sets the max capacity of the boat to the max capacity of the support boat
* and saves all the prior data
* */
void resize();
/**
* After using resize, this function is used to reset the values of max capacity
* and transported quantity to the prior levels
* */
void reset();
};
#endif /* BOATWITHSUPPORT_H_ */
|
/**
* Caesar cipher via command-line interface.
*/
#include <stdlib.h>
#include <stdio.h>
#include "caesar.h"
void parse_args(int argc, char** argv);
void print_help();
void run_caesar(char* input, int shift);
int main(int argc, char** argv) {
parse_args(argc, argv);
return 0;
}
void parse_args(int argc, char** argv) {
if (argc == 1) {
printf("\"shift\" and \"text\" arguments are missing\n");
goto error;
} else if (argc == 2) {
printf("\"text\" argument is missing\n");
goto error;
} else if (argc > 3) {
printf("Too many arguments\n");
goto error;
}
int shift;
int result = sscanf(argv[1], "%d", &shift);
if (result != 1) {
printf("\"shift\" argument must be an integer\n");
goto error;
}
char* input = argv[2];
if (strlen(input) < 1) {
printf("\"input\" must have at least one character\n");
goto error;
}
run_caesar(input, shift);
return;
error:
print_help();
}
void print_help() {
printf("Usage: caesar_cipher shift text\n");
}
void run_caesar(char* input, int shift) {
char* output = malloc(strlen(input) * sizeof(char));
caesar(output, input, shift);
printf("%s\n", output);
free(output);
}
|
//
// TTAITextAuxInputView.h
//
// Created by Doug Lovell on 4/16/13.
// Copyright (c) 2013 Douglas Lovell. MIT License.
//
/*
It bothers me as an old Java guy that I have to expose the txtActiveField instance
variable and the reset method in order to use them from the subclass. There are
posts on this topic at StackOverflow
http://stackoverflow.com/questions/3725857/protected-methods-in-objective-c
with some pissy comments. Sensitive topic, apparently. The "solution" there looks
more bothersome than the problem; so, here you are. Treat them as protected.
Or not. As you like.
*/
#import <Foundation/Foundation.h>
@interface TTAITextAuxInput : NSObject <UITextFieldDelegate>
@property (nonatomic, strong) UITextField* txtActiveField;
/*
Add cancel, undo, done button impementations as textField auxilliary input view.
Side effect is that this becomes the delegate of the text field.
*/
- (void)decorate:(UITextField *)textField;
// set text field content to value held prior to edit
- (void)reset;
@end
|
#include <stdio.h>
#include <stdlib.h>
#include <err.h>
#include "arg.h"
#include "util.h"
char *argv0;
int main(int argc, char **argv) {
int rflag = 0;
ARGBEGIN {
case 'r': // repeat
rflag = 1;
} ARGEND
if(argc < 2) {
USAGE("[-r] file1 file2");
exit(1);
}
FILE *f1 = argv[0][0] == '-' ? stdin : fopen(argv[0], "r");
if(!f1) errx(2, "failed to open %s", argv[0]);
FILE *f2 = argv[1][0] == '-' ? stdin : fopen(argv[1], "r");
if(!f2) errx(2, "failed to open %s", argv[1]);
if(f2 == stdin && rflag) errx(3, "cannot -r when reading from pipe");
while(1) {
char c1 = fgetc(f1);
char c2 = fgetc(f2);
if(c1 == EOF || (!rflag && c2 == EOF))
break;
if(c2 == EOF) {
rewind(f2);
c2 = fgetc(f2);
}
putchar(c1 ^ c2);
}
fclose(f1);
fclose(f2);
}
|
#pragma once
#include <inttypes.h>
#include "vector2.h"
#include "vector3.h"
// scaling factor from 1e-7 degrees to meters at equater
// == 1.0e-7 * DEG_TO_RAD * RADIUS_OF_EARTH
#define LOCATION_SCALING_FACTOR 0.011131884502145034L
// inverse of LOCATION_SCALING_FACTOR
#define LOCATION_SCALING_FACTOR_INV 89.83204953368922L
struct Location
{
int32_t lat = 0;
int32_t lng = 0;
int32_t alt = 0;
};
/*
* LOCATION
*/
// longitude_scale - returns the scaler to compensate for shrinking longitude as you move north or south from the equator
// Note: this does not include the scaling to convert longitude/latitude points to meters or centimeters
float longitude_scale(const struct Location &loc);
// return distance in meters between two locations
float get_distance(const struct Location &loc1, const struct Location &loc2);
// return distance in centimeters between two locations
uint32_t get_distance_cm(const struct Location &loc1, const struct Location &loc2);
// return bearing in centi-degrees between two locations
int32_t get_bearing_cd(const struct Location &loc1, const struct Location &loc2);
// see if location is past a line perpendicular to
// the line between point1 and point2. If point1 is
// our previous waypoint and point2 is our target waypoint
// then this function returns true if we have flown past
// the target waypoint
bool location_passed_point(const struct Location & location,
const struct Location & point1,
const struct Location & point2);
/*
return the proportion we are along the path from point1 to
point2. This will be less than >1 if we have passed point2
*/
float location_path_proportion(const struct Location &location,
const struct Location &point1,
const struct Location &point2);
// extrapolate latitude/longitude given bearing and distance
void location_update(struct Location &loc, float bearing, float distance);
// extrapolate latitude/longitude given distances north and east
void location_offset(struct Location &loc, float ofs_north, float ofs_east);
/*
return the distance in meters in North/East plane as a N/E vector
from loc1 to loc2
*/
Vector2f location_diff(const struct Location &loc1, const struct Location &loc2);
/*
return the distance in meters in North/East/Down plane as a N/E/D vector
from loc1 to loc2
*/
Vector3f location_3d_diff_NED(const struct Location &loc1, const struct Location &loc2);
/*
* check if lat and lng match. Ignore altitude and options
*/
bool locations_are_same(const struct Location &loc1, const struct Location &loc2);
/*
* convert invalid waypoint with useful data. return true if location changed
*/
bool location_sanitize(const struct Location &defaultLoc, struct Location &loc);
/*
print a int32_t lat/long in decimal degrees
*/
void print_latlon(int32_t lat_or_lon);
// Converts from WGS84 geodetic coordinates (lat, lon, height)
// into WGS84 Earth Centered, Earth Fixed (ECEF) coordinates
// (X, Y, Z)
void wgsllh2ecef(const Vector3d &llh, Vector3d &ecef);
// Converts from WGS84 Earth Centered, Earth Fixed (ECEF)
// coordinates (X, Y, Z), into WHS84 geodetic
// coordinates (lat, lon, height)
void wgsecef2llh(const Vector3d &ecef, Vector3d &llh);
// return true when lat and lng are within range
bool check_lat(float lat);
bool check_lng(float lng);
bool check_lat(int32_t lat);
bool check_lng(int32_t lng);
bool check_latlng(float lat, float lng);
bool check_latlng(int32_t lat, int32_t lng);
bool check_latlng(Location loc);
//
bool generate_WP_flyby(const double radius, const struct Location &wpA, const struct Location &wpB, const struct Location &wpC,
struct Location &wpB1, struct Location &wpB2, struct Location &wpB3, int8_t &dir);
Vector2d geo2planar(Vector2d &ref, Vector2d &wp);
Vector2d planar2geo(Vector2d &ref, Vector2d &wp); |
//
// WithingsError.h
// Withings-SDK-iOS
//
// Copyright (c) 2016 jdrevet
//
// 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 <Foundation/Foundation.h>
/**
* Error generated by the SDK.
* The domain is WITHINGS_DOMAIN_ERROR.
* The error codes are defined in WithingsErrorCode enum.
* The error returned by the Withings server are the code WithingsErrorServer (= 1). The server error code and message can be retrieved in the additional property serverErrorCode and serverErrorMessage.
*/
@interface WithingsError : NSError
/**
* The domain of the WithingsError
*/
extern NSString * const WITHINGS_DOMAIN_ERROR;
/**
* Error codes returned by the SDK.
*/
typedef NS_ENUM(NSInteger, WithingsErrorCode) {
/** Unknown error */
WithingsErrorUnknown = 0,
/** Error returned by the server */
WithingsErrorServer = 1,
/** Error during OAuth authorization process */
WithingsErrorOAuth = 2,
/** Authorization cannot be retrieved for the user. Use the method requestAccessAuthorizationWithCallbackScheme:presenterViewController:completion: of the WithingsAPI singleton to request authorization */
WithingsErrorNoUserAuthorization = 3,
/** An HTTP error occured during API call */
WithingsErrorHTTP = 4,
/** The response received from the server cannot be parsed */
WithingsErrorResponseParsing = 5
};
/**
* Error codes returned by the server.
* All the server errors are returned with the error code WithingsErrorServer (= 1). Server error code can be retrieved in the additional property serverErrorCode.
*/
typedef NS_ENUM(NSInteger, WithingsServerErrorCode) {
/** The userid provided is absent, or incorrect */
WithingsServerErrorWrongUserId = 247,
/** The provided userid and/or Oauth credentials do not match */
WithingsServerErrorWrongCredentials = 250,
/** No such subscription was found */
WithingsServerErrorSubscriptionNotFound = 286,
/** The callback URL is either absent or incorrect */
WithingsServerErrorWrongCallbackURL = 293,
/** No such subscription could be deleted */
WithingsServerErrorCannotDeleteSubscription = 294,
/** The comment is either absent or incorrect */
WithingsServerErrorWrongComment = 304,
/** Too many notifications are already set */
WithingsServerErrorTooManyNotifSet = 305,
/** The user is deactivated */
WithingsServerErrorUserDeactivated = 328,
/** The signature (using Oauth) is invalid */
WithingsServerErrorWrongOAuthSignature = 342,
/** Notification Callback Url does not exist */
WithingsServerErrorWrongNotifCallbackURL = 343,
/** Too Many Request */
WithingsServerErrorTooManyRequest = 601,
/** Wrong action or wrong webservice */
WithingsServerErrorWrongAction = 2554,
/** An unknown error occurred */
WithingsServerErrorUnknown = 2555,
/** Service is not defined */
WithingsServerErrorServiceUndefined = 2556
};
/**
* The error code returned by the server for the server error (code = WithingsErrorServer = 1).
*/
@property (readonly, nonatomic) WithingsServerErrorCode serverErrorCode;
/**
* The error message returned by the server for the server error (code = WithingsErrorServer = 1).
*/
@property (readonly, nonatomic) NSString *serverErrorMessage;
/**
* Creates and returns a WithingsError with the specified code and message
*
* @param code The error code
* @param message The error message which will be set as localized description
* @return The WithingsError initialized with the given attributes
*/
+ (instancetype)errorWithCode:(WithingsErrorCode)code message:(NSString*)message;
/**
* Creates and returns a WithingsError
*
* @param code The error code
* @param userInfo The userInfo dictionary for the error
* @return The WithingsError initialized with the given attributes
*/
+ (instancetype)errorWithCode:(WithingsErrorCode)code userInfo:(NSDictionary*)userInfo;
/**
* Creates and returns a WithingsError which represents a server error.
* The error code will be WithingsErrorServer (= 1).
* The error info returned by the server can be retrieved in additional properties serverErrorCode and serverErrorMessage.
*
* @param serverErrorCode The error code returned by the server
* @param serverErrorMessage The error message returned by the server
* @return The WithingsError initialized with the given attributes
*/
+ (instancetype)serverErrorWithCode:(WithingsServerErrorCode)serverErrorCode message:(NSString*)serverErrorMessage;
@end
|
/* Generated by file2c from "association_source.h.in" */
const unsigned char association_source[] =
{
0x45,0x6E,0x75,0x6D,0x5F,0x41,0x73,0x73,0x6F,0x63,0x69,0x61,0x74,0x6F,0x72,
0x5F,0x4E,0x61,0x6D,0x65,0x73,0x5F,0x53,0x74,0x61,0x74,0x75,0x73,0x20,0x3C,
0x43,0x4C,0x41,0x53,0x53,0x3E,0x5F,0x50,0x72,0x6F,0x76,0x69,0x64,0x65,0x72,
0x3A,0x3A,0x65,0x6E,0x75,0x6D,0x5F,0x61,0x73,0x73,0x6F,0x63,0x69,0x61,0x74,
0x6F,0x72,0x5F,0x6E,0x61,0x6D,0x65,0x73,0x28,0x0A,0x20,0x20,0x20,0x20,0x63,
0x6F,0x6E,0x73,0x74,0x20,0x49,0x6E,0x73,0x74,0x61,0x6E,0x63,0x65,0x2A,0x20,
0x69,0x6E,0x73,0x74,0x61,0x6E,0x63,0x65,0x2C,0x0A,0x20,0x20,0x20,0x20,0x63,
0x6F,0x6E,0x73,0x74,0x20,0x53,0x74,0x72,0x69,0x6E,0x67,0x26,0x20,0x72,0x65,
0x73,0x75,0x6C,0x74,0x5F,0x63,0x6C,0x61,0x73,0x73,0x2C,0x0A,0x20,0x20,0x20,
0x20,0x63,0x6F,0x6E,0x73,0x74,0x20,0x53,0x74,0x72,0x69,0x6E,0x67,0x26,0x20,
0x72,0x6F,0x6C,0x65,0x2C,0x0A,0x20,0x20,0x20,0x20,0x63,0x6F,0x6E,0x73,0x74,
0x20,0x53,0x74,0x72,0x69,0x6E,0x67,0x26,0x20,0x72,0x65,0x73,0x75,0x6C,0x74,
0x5F,0x72,0x6F,0x6C,0x65,0x2C,0x0A,0x20,0x20,0x20,0x20,0x45,0x6E,0x75,0x6D,
0x5F,0x41,0x73,0x73,0x6F,0x63,0x69,0x61,0x74,0x6F,0x72,0x5F,0x4E,0x61,0x6D,
0x65,0x73,0x5F,0x48,0x61,0x6E,0x64,0x6C,0x65,0x72,0x3C,0x49,0x6E,0x73,0x74,
0x61,0x6E,0x63,0x65,0x3E,0x2A,0x20,0x68,0x61,0x6E,0x64,0x6C,0x65,0x72,0x29,
0x0A,0x7B,0x0A,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6E,0x20,0x45,
0x4E,0x55,0x4D,0x5F,0x41,0x53,0x53,0x4F,0x43,0x49,0x41,0x54,0x4F,0x52,0x5F,
0x4E,0x41,0x4D,0x45,0x53,0x5F,0x55,0x4E,0x53,0x55,0x50,0x50,0x4F,0x52,0x54,
0x45,0x44,0x3B,0x0A,0x7D,0x0A,0x0A,0x45,0x6E,0x75,0x6D,0x5F,0x41,0x73,0x73,
0x6F,0x63,0x69,0x61,0x74,0x6F,0x72,0x73,0x5F,0x53,0x74,0x61,0x74,0x75,0x73,
0x20,0x3C,0x43,0x4C,0x41,0x53,0x53,0x3E,0x5F,0x50,0x72,0x6F,0x76,0x69,0x64,
0x65,0x72,0x3A,0x3A,0x65,0x6E,0x75,0x6D,0x5F,0x61,0x73,0x73,0x6F,0x63,0x69,
0x61,0x74,0x6F,0x72,0x73,0x28,0x0A,0x20,0x20,0x20,0x20,0x63,0x6F,0x6E,0x73,
0x74,0x20,0x49,0x6E,0x73,0x74,0x61,0x6E,0x63,0x65,0x2A,0x20,0x69,0x6E,0x73,
0x74,0x61,0x6E,0x63,0x65,0x2C,0x0A,0x20,0x20,0x20,0x20,0x63,0x6F,0x6E,0x73,
0x74,0x20,0x53,0x74,0x72,0x69,0x6E,0x67,0x26,0x20,0x72,0x65,0x73,0x75,0x6C,
0x74,0x5F,0x63,0x6C,0x61,0x73,0x73,0x2C,0x0A,0x20,0x20,0x20,0x20,0x63,0x6F,
0x6E,0x73,0x74,0x20,0x53,0x74,0x72,0x69,0x6E,0x67,0x26,0x20,0x72,0x6F,0x6C,
0x65,0x2C,0x0A,0x20,0x20,0x20,0x20,0x63,0x6F,0x6E,0x73,0x74,0x20,0x53,0x74,
0x72,0x69,0x6E,0x67,0x26,0x20,0x72,0x65,0x73,0x75,0x6C,0x74,0x5F,0x72,0x6F,
0x6C,0x65,0x2C,0x0A,0x20,0x20,0x20,0x20,0x45,0x6E,0x75,0x6D,0x5F,0x41,0x73,
0x73,0x6F,0x63,0x69,0x61,0x74,0x6F,0x72,0x73,0x5F,0x48,0x61,0x6E,0x64,0x6C,
0x65,0x72,0x3C,0x49,0x6E,0x73,0x74,0x61,0x6E,0x63,0x65,0x3E,0x2A,0x20,0x68,
0x61,0x6E,0x64,0x6C,0x65,0x72,0x29,0x0A,0x7B,0x0A,0x20,0x20,0x20,0x20,0x72,
0x65,0x74,0x75,0x72,0x6E,0x20,0x45,0x4E,0x55,0x4D,0x5F,0x41,0x53,0x53,0x4F,
0x43,0x49,0x41,0x54,0x4F,0x52,0x53,0x5F,0x55,0x4E,0x53,0x55,0x50,0x50,0x4F,
0x52,0x54,0x45,0x44,0x3B,0x0A,0x7D,0x0A,0x0A,0x45,0x6E,0x75,0x6D,0x5F,0x52,
0x65,0x66,0x65,0x72,0x65,0x6E,0x63,0x65,0x73,0x5F,0x53,0x74,0x61,0x74,0x75,
0x73,0x20,0x3C,0x43,0x4C,0x41,0x53,0x53,0x3E,0x5F,0x50,0x72,0x6F,0x76,0x69,
0x64,0x65,0x72,0x3A,0x3A,0x65,0x6E,0x75,0x6D,0x5F,0x72,0x65,0x66,0x65,0x72,
0x65,0x6E,0x63,0x65,0x73,0x28,0x0A,0x20,0x20,0x20,0x20,0x63,0x6F,0x6E,0x73,
0x74,0x20,0x49,0x6E,0x73,0x74,0x61,0x6E,0x63,0x65,0x2A,0x20,0x69,0x6E,0x73,
0x74,0x61,0x6E,0x63,0x65,0x2C,0x0A,0x20,0x20,0x20,0x20,0x63,0x6F,0x6E,0x73,
0x74,0x20,0x3C,0x43,0x4C,0x41,0x53,0x53,0x3E,0x2A,0x20,0x6D,0x6F,0x64,0x65,
0x6C,0x2C,0x0A,0x20,0x20,0x20,0x20,0x63,0x6F,0x6E,0x73,0x74,0x20,0x53,0x74,
0x72,0x69,0x6E,0x67,0x26,0x20,0x72,0x6F,0x6C,0x65,0x2C,0x0A,0x20,0x20,0x20,
0x20,0x45,0x6E,0x75,0x6D,0x5F,0x52,0x65,0x66,0x65,0x72,0x65,0x6E,0x63,0x65,
0x73,0x5F,0x48,0x61,0x6E,0x64,0x6C,0x65,0x72,0x3C,0x3C,0x43,0x4C,0x41,0x53,
0x53,0x3E,0x3E,0x2A,0x20,0x68,0x61,0x6E,0x64,0x6C,0x65,0x72,0x29,0x0A,0x7B,
0x0A,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6E,0x20,0x45,0x4E,0x55,
0x4D,0x5F,0x52,0x45,0x46,0x45,0x52,0x45,0x4E,0x43,0x45,0x53,0x5F,0x55,0x4E,
0x53,0x55,0x50,0x50,0x4F,0x52,0x54,0x45,0x44,0x3B,0x0A,0x7D,0x0A,0x0A,
0x00, /* null terminator */
};
|
//
// ViewController.h
// LDBTests
//
// Created by Emil Wojtaszek on 16.11.2015.
// Copyright © 2015 AppUnite. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
@end
|
/**
* \file
*
* Copyright (c) 2014 Atmel Corporation. All rights reserved.
*
* \asf_license_start
*
* \page License
*
* 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. The name of Atmel may not be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* 4. This software may only be redistributed and used in connection with an
* Atmel microcontroller product.
*
* THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
* EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL 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.
*
* \asf_license_stop
*
*/
/**
* Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a>
*/
#ifndef _SAM4N_GPBR_COMPONENT_
#define _SAM4N_GPBR_COMPONENT_
/* ============================================================================= */
/** SOFTWARE API DEFINITION FOR General Purpose Backup Register */
/* ============================================================================= */
/** \addtogroup SAM4N_GPBR General Purpose Backup Register */
/*@{*/
#if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))
/** \brief Gpbr hardware registers */
typedef struct {
RwReg SYS_GPBR[8]; /**< \brief (Gpbr Offset: 0x0) General Purpose Backup Register */
} Gpbr;
#endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */
/* -------- SYS_GPBR[8] : (GPBR Offset: 0x0) General Purpose Backup Register -------- */
#define SYS_GPBR_GPBR_VALUE_Pos 0
#define SYS_GPBR_GPBR_VALUE_Msk (0xffffffffu << SYS_GPBR_GPBR_VALUE_Pos) /**< \brief (SYS_GPBR[8]) Value of GPBR x */
#define SYS_GPBR_GPBR_VALUE(value) ((SYS_GPBR_GPBR_VALUE_Msk & ((value) << SYS_GPBR_GPBR_VALUE_Pos)))
/*@}*/
#endif /* _SAM4N_GPBR_COMPONENT_ */
|
//
// AboutViewController.h
// NetAsistant
//
// Created by Zzy on 11/29/14.
// Copyright (c) 2014 Zzy. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface SAAboutViewController : UITableViewController
@end
|
// Copyright (c) 2011-2015 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_QT_SENDCOINSENTRY_H
#define BITCOIN_QT_SENDCOINSENTRY_H
#include <qt/walletmodel.h>
#include <QStackedWidget>
class WalletModel;
namespace Ui {
class SendCoinsEntry;
}
/**
* A single entry in the dialog for sending bitcoins.
* Stacked widget, with different UIs for payment requests
* with a strong payee identity.
*/
class SendCoinsEntry : public QStackedWidget
{
Q_OBJECT
public:
explicit SendCoinsEntry(QWidget* parent = 0);
~SendCoinsEntry();
void setModel(WalletModel *model);
bool validate(interfaces::Node& node);
SendCoinsRecipient getValue();
/** Return whether the entry is still empty and unedited */
bool isClear();
void setValue(const SendCoinsRecipient &value);
void setAddress(const QString &address);
void setAmount(const CAmount &amount);
/** Set up the tab chain manually, as Qt messes up the tab chain by default in some cases
* (issue https://bugreports.qt-project.org/browse/QTBUG-10907).
*/
QWidget *setupTabChain(QWidget *prev);
void setFocus();
public Q_SLOTS:
void clear();
void checkSubtractFeeFromAmount();
void donateToFoundation();
Q_SIGNALS:
void removeEntry(SendCoinsEntry *entry);
void useAvailableBalance(SendCoinsEntry* entry);
void payAmountChanged();
void subtractFeeFromAmountChanged();
private Q_SLOTS:
void deleteClicked();
void useAvailableBalanceClicked();
void on_payTo_textChanged(const QString &address);
void on_addressBookButton_clicked();
void on_pasteButton_clicked();
void updateDisplayUnit();
protected:
void changeEvent(QEvent* e);
private:
SendCoinsRecipient recipient;
Ui::SendCoinsEntry *ui;
WalletModel *model;
/** Set required icons for buttons inside the dialog */
void setButtonIcons();
bool updateLabel(const QString &address);
};
#endif // BITCOIN_QT_SENDCOINSENTRY_H
|
#ifndef Hutils
#define Hutils
#include <sstream>
#include <vector>
#include "../struct.h"
using namespace std;
STtanggal getDate();
string char2Kelamin(char kelamin);
string char2Jenis(char jenis);
string int2string(int number);
string char2string(char ch);
string tolower(string text);
bool allisalnum(string text);
bool allisdigit(string text);
bool allisalpha(string text);
bool allistext(string text);
bool validationtext(int type, string text);
bool validationchar(char* allowed, int nAllowed, char ch);
int id2pos(vector<STpasien> datas, int id);
int id2pos(vector<STpenyakit> datas, int id);
int id2pos(vector<STobat> datas, int id);
int id2pos(vector<STresep> datas, int id);
int id2pos(vector<STcekup> datas, int id);
#endif
|
//
// SimpleLoadingView.h
// SimpleLoadingView
//
// Created by 庞平飞 on 2016/12/31.
// Copyright © 2016年 PangPingfei. All rights reserved.
//
#import <UIKit/UIKit.h>
//! Project version number for SimpleLoadingView.
FOUNDATION_EXPORT double SimpleLoadingViewVersionNumber;
//! Project version string for SimpleLoadingView.
FOUNDATION_EXPORT const unsigned char SimpleLoadingViewVersionString[];
// In this header, you should import all the public headers of your framework using statements like #import <SimpleLoadingView/PublicHeader.h>
|
//
// FullyReplaceSegue.h
// MMDrawerExample
//
// Created by Shwet Solanki on 09/01/15.
// Copyright (c) 2015 shwetsolanki. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface FullyReplaceSegue : UIStoryboardSegue
@end
|
// This file is distributed under the MIT license.
// See the LICENSE file for details.
#pragma once
#ifndef VSNRAY_COMMON_TIMER_H
#define VSNRAY_COMMON_TIMER_H 1
#include <chrono>
#ifdef __CUDACC__
#include <cuda.h>
#endif
namespace visionaray
{
//-------------------------------------------------------------------------------------------------
// Timer class using std::chrono's high-resolution clock
//
class timer
{
public:
typedef std::chrono::high_resolution_clock clock;
typedef clock::time_point time_point;
typedef clock::duration duration;
timer()
: start_(clock::now())
{
}
void reset()
{
start_ = clock::now();
}
double elapsed() const
{
return std::chrono::duration<double>(clock::now() - start_).count();
}
private:
time_point start_;
};
#ifdef __CUDACC__
namespace cuda
{
//-------------------------------------------------------------------------------------------------
// CUDA event-based timer class
//
class timer
{
public:
timer()
{
cudaEventCreate(&start_);
cudaEventCreate(&stop_);
reset();
}
~timer()
{
cudaEventDestroy(stop_);
cudaEventDestroy(start_);
}
void reset()
{
cudaEventRecord(start_);
}
double elapsed() const
{
cudaEventRecord(stop_);
cudaEventSynchronize(stop_);
float ms = 0.0f;
cudaEventElapsedTime(&ms, start_, stop_);
return static_cast<double>(ms) / 1000.0;
}
private:
cudaEvent_t start_;
cudaEvent_t stop_;
};
} // cuda
#endif
#ifdef __HIPCC__
namespace hip
{
//-------------------------------------------------------------------------------------------------
// HIP event-based timer class
//
class timer
{
public:
timer()
{
hipEventCreate(&start_);
hipEventCreate(&stop_);
reset();
}
~timer()
{
hipEventDestroy(stop_);
hipEventDestroy(start_);
}
void reset()
{
hipEventRecord(start_);
}
double elapsed() const
{
hipEventRecord(stop_);
hipEventSynchronize(stop_);
float ms = 0.0f;
hipEventElapsedTime(&ms, start_, stop_);
return static_cast<double>(ms) / 1000.0;
}
private:
hipEvent_t start_;
hipEvent_t stop_;
};
} // hip
#endif
//-------------------------------------------------------------------------------------------------
// basic_frame_counter
//
template <typename Timer>
class basic_frame_counter
{
public:
basic_frame_counter()
: count_(0)
{
}
void reset()
{
timer_.reset();
count_ = 0;
fps_ = 0.0;
}
double register_frame()
{
++count_;
double elapsed = timer_.elapsed();
if (elapsed > 0.5/*sec*/)
{
fps_ = count_ / elapsed;
timer_.reset();
count_ = 0;
}
return fps_;
}
private:
Timer timer_;
unsigned count_;
double fps_;
};
//-------------------------------------------------------------------------------------------------
// frame counter platform typedefs
//
using frame_counter = basic_frame_counter<timer>;
#ifdef __CUDACC__
namespace cuda
{
using frame_counter = basic_frame_counter<cuda::timer>;
}
#endif
#ifdef __HIPCC__
namespace hip
{
using frame_counter = basic_frame_counter<hip::timer>;
}
#endif
} // visionaray
#endif // VSNRAY_COMMON_TIMER_H
|
int sum (int a, int b) {
return 0;
}
int main() {
int a = sum(1, 2);
int *b = &a;
*b = 10;
*(b+1) + 7 = 20;
sum(1, 2) = 3;
1 + 2 = a;
"3" = a;
5 && 9 = "hello";
return 0;
}
|
#ifndef GAME_H
#define GAME_H
#include "Player.h"
#include "Enemy.h"
#include "Gambling.h"
#include "Store.h"
class Game {
public:
void MainMenu();
private:
enum MenuType {
eMain = 0,
ePlayerClass,
eHowToPlay
};
void SetPlayerData();
int InitializePlayerClass();
void SetPlayerClass(int);
std::string InitializePlayerName();
char InitializePlayerGender();
void SetEnemy();
bool PlayAgain();
void Intermission();
void StartGame();
void Battle();
void HowToPlay();
int GetChoice(MenuType menuType);
void DisplayMenu(MenuType menuType);
// Pointers needed to call functions from respective classes.
// They are pointers because they have child classes (they polymorph).
Player *_Player;
Enemy *_Enemy;
// This object is not a pointer because it does not have a child class.
Gambling _Gambling;
Store _Store;
};
#endif // GAME_H
|
//
// MTDealsViewController.h
// 美团HD
//
// Created by zhuzhu on 15/11/24.
// Copyright (c) 2014年 heima. All rights reserved.
// 团购列表控制器(父类)
#import <UIKit/UIKit.h>
@interface MTDealsViewController : UICollectionViewController
/**
* 设置请求参数:交给子类去实现
*/
- (void)setupParams:(NSMutableDictionary *)params;
@end
|
#pragma once
#include "GameObject.h"
class DSky : public DGameObject
{
public:
DSky(FLOAT length);
~DSky();
BOOL CreateSkybox(LPWSTR frontTextureFile, LPWSTR backTextureFile, LPWSTR leftTextureFile,
LPWSTR rightTextureFile, LPWSTR topTextureFile);
private:
BOOL InitVertices(LPD3DXMESH skyboxMesh);
BOOL InitIndices(LPD3DXMESH skyboxMesh, DWORD faceCount);
BOOL InitTexture(DMeshRender* meshRender, LPWSTR* textureFiles, INT fileCount);
VOID InitEffect(DMeshRender* meshRender);
private:
FLOAT m_skyLength;
}; |
#include <stdio.h>
int main(int argc, char *argv[]) {
int bugs = 100;
double bug_rate = 1.2;
printf("You have %d bugs at the imaginary rate of %f.\n",
bugs, bug_rate);
long universe_of_defects = 1L * 1024L * 1024L * 1024L;
printf("The entire universe has %ld bugs.\n",
universe_of_defects);
double expected_bugs = bugs * bug_rate;
printf("You are expected to have %f bugs.\n",
expected_bugs);
double part_of_universe = expected_bugs / universe_of_defects;
printf("That is only a %e portion of the universe.\n",
part_of_universe);
char nul_byte = '\0';
int care_percentage = bugs * nul_byte;
printf("Which means you should care %d%%.\n",
care_percentage);
return 0;
}
|
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
const int BUFFER_SIZE = 1024;
static void close_quietly(int fd) {
int e = errno;
close(fd);
errno = e;
}
static void print_usage(const char *name) {
fprintf(stderr, "Usage: %s [-n] file\n", name);
}
static int tee(const char *path, int append) {
int flags = O_WRONLY | O_CREAT;
if (append) {
flags = flags | O_APPEND;
} else {
flags = flags | O_TRUNC;
}
int fd = open(path, flags, 0644);
if (fd == -1) {
return 1;
}
int n;
char buffer[BUFFER_SIZE];
while ((n = read(STDIN_FILENO, buffer, BUFFER_SIZE)) > 0) {
if (write(STDOUT_FILENO, buffer, n) != n) {
close_quietly(fd);
return 1;
}
if (write(fd, buffer, n) != n) {
close_quietly(fd);
return 1;
}
}
if (n == -1) {
close_quietly(fd);
return 1;
}
if (close(fd) != 0) {
return 1;
}
return 0;
}
int main(int argc, char **argv) {
int opt;
int append = 0;
while ((opt = getopt(argc, argv, "a")) != -1) {
switch (opt) {
case 'a':
append = 1;
break;
default:
print_usage(argv[0]);
return 1;
}
}
if (optind != argc - 1) {
print_usage(argv[0]);
return 1;
}
if (tee(argv[optind], append) != 0) {
fprintf(stderr, "Error while performing tee: %s", strerror(errno));
return 1;
}
return 0;
} |
#include <stdio.h>
#include "funlib/funlib.h"
void main()
{
printf("Hello World!");
hello();
}
|
// The MIT License
//
// Copyright (c) 2013 Ryan Davies
//
// 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 <Foundation/Foundation.h>
#import "TSCReporter.h"
/** The default reporter class. Outputs test results in a more readable format than the SenTestingKit default, by indenting tests and displaying failures after each suite has ended. */
@interface TSCTidyReporter : NSObject <TSCReporter>
/** Writes a message to the debugger.
@param message The message to write to the debugger. */
- (void)log:(NSString *)message;
@end
|
//
// SMobiLogger.h
// SMobiLogger
//
// Created by Systango on 4/12/13.
// Copyright (c) 2013 Systango. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <Realm/Realm.h>
#import <KSCrash/KSCrash.h>
#import <KSCrash/KSCrashInstallationStandard.h>
#import <KSCrash/KSCrashInstallationEmail.h>
#import <KSCrash/KSCrashInstallationConsole.h>
#import <KSCrash/KSCrashInstallation+Alert.h>
#pragma mark - Blocks
typedef void (^smobiCompletionBlock)(BOOL success, id response);
#ifdef DEBUG
#define NSLog(args...) ExtendNSLogInfo(__FILE__,__LINE__,__PRETTY_FUNCTION__,args);
#define NSLogError(args...) ExtendNSLogError(__FILE__,__LINE__,__PRETTY_FUNCTION__,args);
#define NSLogWarning(args...) ExtendNSLogWarning(__FILE__,__LINE__,__PRETTY_FUNCTION__,args);
#else
#define NSLog(x...)
#endif
void ExtendNSLogInfo(const char *file, int lineNumber, const char *functionName, NSString *message, ...);
void ExtendNSLogError(const char *file, int lineNumber, const char *functionName, NSString *message, ...);
void ExtendNSLogWarning(const char *file, int lineNumber, const char *functionName, NSString *message, ...);
@interface SMobiLogger : NSObject {
dispatch_queue_t queue_;
}
// To create a sigelton object
+ (SMobiLogger *)sharedInterface;
// To delete old logs from db
- (void)refreshLogs:(NSNumber *)fromDaysOrNil;
// To Fetch all the logs from db
- (NSString *)fetchLogs;
// To send logs via email
- (void)sendEmailLogsWithRecipients:(NSArray *)recipients;
// To get device name
- (NSString *) deviceName;
// Save logs with particulare type
- (void)debug:(NSString *)title withDescription:(NSString *)description;
- (void)error:(NSString *)title withDescription:(NSString *)description;
- (void)info:(NSString *)title withDescription:(NSString *)description;
- (void)other:(NSString *)title withDescription:(NSString *)description;
- (void)warn:(NSString *)title withDescription:(NSString *)description;
- (void)unCaughtExceptionWithDescription:(NSString*)description;
// To start timer, which delete old logs
- (void)startMobiLogger;
#pragma mark - KSCrash
- (KSCrashInstallation *)installKSCrashConsoleWithCompletionBlock:(smobiCompletionBlock)block;
- (KSCrashInstallation *)installKSCrashWithURLString:(NSString *)urlPath withCompletionBlock:(smobiCompletionBlock)block;
- (KSCrashInstallation *)installKSCrashWithEmails:(NSArray *)emails withCompletionBlock:(smobiCompletionBlock)block;
- (KSCrashInstallation *)installKSCrashConsoleWithAlert:(BOOL)showAlert withCompletionBlock:(smobiCompletionBlock)block;
- (KSCrashInstallation *)installKSCrashWithURLString:(NSString *)urlPath withAlert:(BOOL)showAlert withCompletionBlock:(smobiCompletionBlock)block;
- (KSCrashInstallation *)installKSCrashWithEmails:(NSArray *)emails withAlert:(BOOL)showAlert withCompletionBlock:(smobiCompletionBlock)block;
@end
|
/***************************************************************
* Filename: READBIN.C
*
* Purpose: Read an input 8 or 16 bit binary image file into
* the array pointed to by "image_ptr".
*
* Passed Parameters:
* filename: name of input image data file
* image_ptr: pointer to image to fill with this data
* option: type of binary file:
* 1 - 8 bit 2 - 16 bit
*
* Returned Parameters:
* min: minimum data value (>= 0) in image
* max: maximum data value in image
*
* Programmer: Barbara Marks
*
* Date: 11 December 1992
*
* ID: $Id: readbin.c,v 2.4 1994/10/05 16:07:05 marks Exp marks $
***************************************************************/
#include <stdio.h>
#include "stats.h"
void read_binary (filename,image_ptr,option,min,max)
char *filename;
short *image_ptr;
short option;
short *min,*max;
{
FILE *fp;
char cval;
short *ptr;
int i,j;
int count_bck,count_intbck;
count_bck = count_intbck = 0;
*min = 9999;
*max = -9999;
total_size = 0;
land_border = FALSE;
MAX_CLASSES = -9999;
ptr = image_ptr;
/*
* total_size is defined in the include file stats.h. total_size is
* the number of cells inside the landscape (non-background cells).
*/
total_size = 0;
/*
* Open input image file
*/
if ((fp = fopen(filename,"rb")) == NULL) {
printf ("\nERROR! Can not open file: %s\n",filename);
exit(-1);
}
/*
* Read 8 bit binary stream file
*/
if (option == 1) {
for (i=0; i < num_rows*num_cols; i++) {
cval = fgetc(fp);
*ptr = (short) cval;
/*
* If there are cell values < 0 and not background, then this
* image includes a landscape border. Set a flag.
*/
if (*ptr < 0 && *ptr != background &&
*ptr != -background) land_border = TRUE;
/*
* Find the minimum and maximum class values (only consider those
* classes inside the landscape).
*/
if (*ptr != background && *ptr != -background) {
if (*ptr < *min && *ptr >= 0) *min = *ptr;
if (*ptr > *max) *max = *ptr;
if (*ptr >= 0) total_size ++;
/*
* Keep track of the maximum class found in the landscape, either
* positive or negative. These is needed by the routine getsizes.c
* to allocate space for arrays.
*/
if (*ptr >= 0 && *ptr > MAX_CLASSES)
MAX_CLASSES = *ptr;
if (*ptr < 0 && -(*ptr) > MAX_CLASSES)
MAX_CLASSES = -(*ptr);
}
/*
* The value of background cells was specified by the user. Change
* interior background cells to -990 (positive background value) and
* set background cells exterior to the landscape of interest to -999
* (these should have a negative background value).
*/
if (*ptr == -background) {
count_bck ++;
*ptr = -999;
}
if (*ptr == background) {
count_intbck ++;
*ptr = -990;
}
ptr++;
}
}
/*
* Read 16 bit binary stream file
*/
else {
fread (image_ptr,sizeof(short),num_rows*num_cols,fp);
for (i=0; i < num_rows; i++) {
for (j=0; j < num_cols; j++) {
if (*ptr < 0 && *ptr != background && *ptr != -background)
land_border = TRUE;
if (*ptr != background && *ptr != -background) {
if (*ptr < *min && *ptr >= 0) *min = *ptr;
if (*ptr > *max) *max = *ptr;
if (*ptr >= 0) total_size ++;
if (*ptr >= 0 && *ptr > MAX_CLASSES)
MAX_CLASSES = *ptr;
if (*ptr < 0 && -(*ptr) > MAX_CLASSES)
MAX_CLASSES = -(*ptr);
}
if (*ptr == -background) {
count_bck ++;
*ptr = -999;
}
if (*ptr == background) {
count_intbck ++;
*ptr = -990;
}
ptr++;
}
}
}
fclose (fp);
MAX_CLASSES ++;
bcode = 0;
printf ("\n");
if (count_bck > 0) {
printf ("\n... %d cells of background exterior to the landscape found",
count_bck);
bcode ++;
}
if (count_intbck > 0) {
printf ("\n... %d cells of background interior to the landscape found",
count_intbck);
bcode ++;
}
if (count_intbck == 0 && count_bck == 0)
printf ("\n... landscape does not contain background");
}
|
/**
* The MIT License
*
* Copyright (C) 2017 Kiyofumi Kondoh
*
* 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.
*/
#pragma once
namespace kk
{
class MemoryOperationMismatchClient;
namespace checker
{
bool
hookMemoryOperationMismatchCRTCPP( const HMODULE hModule, MemoryOperationMismatchClient* pMOM );
bool
unhookMemoryOperationMismatchCRTCPP( void );
} // namespace checker
} // namespace kk
|
#include "../vendor/unity/src/unity.h"
#include "../src/fibonacci.h"
/** Test that Fibonacci numbers generated through iteration match expected.
*
* @test The function iterativeFibonacci is called with a variety of n and its
* return asserted against the expected value of f(n).
*
*/
void test_iterativeFibonacci( void )
{
TEST_ASSERT_EQUAL_UINT64( 0, iterativeFibonacci( 0 ) );
TEST_ASSERT_EQUAL_UINT64( 1, iterativeFibonacci( 1 ) );
TEST_ASSERT_EQUAL_UINT64( 1, iterativeFibonacci( 2 ) );
TEST_ASSERT_EQUAL_UINT64( 2, iterativeFibonacci( 3 ) );
TEST_ASSERT_EQUAL_UINT64( 3, iterativeFibonacci( 4 ) );
TEST_ASSERT_EQUAL_UINT64( 5, iterativeFibonacci( 5 ) );
TEST_ASSERT_EQUAL_UINT64( 8, iterativeFibonacci( 6 ) );
TEST_ASSERT_EQUAL_UINT64( 13, iterativeFibonacci( 7 ) );
TEST_ASSERT_EQUAL_UINT64( 21, iterativeFibonacci( 8 ) );
TEST_ASSERT_EQUAL_UINT64( 34, iterativeFibonacci( 9 ) );
TEST_ASSERT_EQUAL_UINT64( 55, iterativeFibonacci( 10 ) );
TEST_ASSERT_EQUAL_UINT64( 6765, iterativeFibonacci( 20 ) );
TEST_ASSERT_EQUAL_UINT64( 832040, iterativeFibonacci( 30 ) );
TEST_ASSERT_EQUAL_UINT64( 102334155, iterativeFibonacci( 40 ) );
TEST_ASSERT_EQUAL_UINT64( 12586269025, iterativeFibonacci( 50 ) );
TEST_ASSERT_EQUAL_UINT64( 1548008755920, iterativeFibonacci( 60 ) );
TEST_ASSERT_EQUAL_UINT64( 190392490709135, iterativeFibonacci( 70 ) );
TEST_ASSERT_EQUAL_UINT64( 23416728348467685, iterativeFibonacci( 80 ) );
TEST_ASSERT_EQUAL_UINT64( 2880067194370816120, iterativeFibonacci( 90 ) );
TEST_ASSERT_EQUAL_UINT64( 4660046610375530309, iterativeFibonacci( 91 ) );
TEST_ASSERT_EQUAL_UINT64( 7540113804746346429, iterativeFibonacci( 92 ) );
TEST_ASSERT_EQUAL_UINT64( 12200160415121876738llu, iterativeFibonacci( 93 ) );
// higher than fibonacci(93) will return UINT64_MAX to avoid overflow
TEST_ASSERT_EQUAL_UINT64( UINT64_MAX, iterativeFibonacci( 94 ) );
}
/** Test that Fibonacci numbers generated through recursion match expected.
*
* @test The function recursiveFibonacci is called with a variety of n and its
* return asserted against the expected value of f(n).
*
* @note Only tested for small number of terms, as function is unused.
*
*/
void test_recursiveFibonacci( void )
{
TEST_ASSERT_EQUAL_UINT64( 0, recursiveFibonacci( 0 ) );
TEST_ASSERT_EQUAL_UINT64( 1, recursiveFibonacci( 1 ) );
TEST_ASSERT_EQUAL_UINT64( 1, recursiveFibonacci( 2 ) );
TEST_ASSERT_EQUAL_UINT64( 2, recursiveFibonacci( 3 ) );
TEST_ASSERT_EQUAL_UINT64( 3, recursiveFibonacci( 4 ) );
TEST_ASSERT_EQUAL_UINT64( 5, recursiveFibonacci( 5 ) );
TEST_ASSERT_EQUAL_UINT64( 8, recursiveFibonacci( 6 ) );
TEST_ASSERT_EQUAL_UINT64( 13, recursiveFibonacci( 7 ) );
TEST_ASSERT_EQUAL_UINT64( 21, recursiveFibonacci( 8 ) );
TEST_ASSERT_EQUAL_UINT64( 34, recursiveFibonacci( 9 ) );
TEST_ASSERT_EQUAL_UINT64( 55, recursiveFibonacci( 10 ) );
}
|
// Copyright mogemimi. Distributed under the MIT license.
#pragma once
#include "pomdog/basic/conditional_compilation.h"
#include "pomdog/basic/export.h"
#include "pomdog/math/forward_declarations.h"
#include "pomdog/math/vector2.h"
POMDOG_SUPPRESS_WARNINGS_GENERATED_BY_STD_HEADERS_BEGIN
#include <array>
POMDOG_SUPPRESS_WARNINGS_GENERATED_BY_STD_HEADERS_END
namespace pomdog {
/// BoundingBox2D is an axis-aligned bounding box in 2D space.
class POMDOG_EXPORT BoundingBox2D final {
public:
Vector2 Min;
Vector2 Max;
static constexpr int CornerCount = 4;
public:
BoundingBox2D() noexcept = default;
BoundingBox2D(const Vector2& min, const Vector2& max);
[[nodiscard]] ContainmentType
Contains(const Vector2& point) const;
[[nodiscard]] ContainmentType
Contains(const BoundingBox2D& box) const;
[[nodiscard]] ContainmentType
Contains(const BoundingCircle& circle) const;
[[nodiscard]] bool
Intersects(const BoundingBox2D& box) const;
[[nodiscard]] bool
Intersects(const BoundingCircle& circle) const;
[[nodiscard]] std::array<Vector2, CornerCount>
GetCorners() const noexcept;
};
} // namespace pomdog
|
// This file was generated based on 'C:\ProgramData\Uno\Packages\UnoCore\0.13.2\Source\Uno\Collections\$.uno'.
// WARNING: Changes might be lost if you edit this file directly.
#ifndef __APP_UNO_COLLECTIONS_I_ENUMERABLE__STRING_H__
#define __APP_UNO_COLLECTIONS_I_ENUMERABLE__STRING_H__
#include <app/Uno.Object.h>
#include <Uno.h>
namespace app {
namespace Uno {
namespace Collections {
::uInterfaceType* IEnumerable__string__typeof();
struct IEnumerable__string
{
::uObject*(*__fp_GetEnumerator)(void*);
static ::uObject* GetEnumerator(::uObject* __this) { return ((IEnumerable__string*)uGetInterfacePtr(__this, IEnumerable__string__typeof()))->__fp_GetEnumerator((::uByte*)__this + (__this->__obj_type->TypeType == uTypeTypeStruct ? sizeof(::uObject) : 0)); }
};
}}}
#endif
|
/*********************************************************************
*
* Copyright (C) 2002, Karlsruhe University
*
* File path: ctors.h
* Description: Prioritized constructors support
*
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
*
* $Id: ctors.h,v 1.1.4.1 2003/09/24 19:12:11 skoglund Exp $
*
********************************************************************/
#ifndef __CTORS_H__
#define __CTORS_H__
/**
* adds initialization priority to a static object
* @param prio_class major initialization group
* @param prio group-local priority, higher numbers
* indicate later initialization
*
* forces error message if @c prio is in next group
*
* example: foo_t foo CTORPRIO(CTORPRIO_CPU, 100);
*
*/
#define CTORPRIO(prio_class, prio) \
__attribute__((init_priority(prio >= 10000 ? 0 : 65535-(prio_class+prio))))
/// \defgroup Priority groups for static constructors
//@{
#define CTORPRIO_CPU 30000
#define CTORPRIO_NODE 20000
#define CTORPRIO_GLOBAL 10000
//@}
// prototypes
void call_cpu_ctors();
void call_node_ctors();
void call_global_ctors();
#endif /* !__CTORS_H__ */
|
/*
* Copyright(c) Sophist Solutions, Inc. 1990-2022. All rights reserved
*/
#ifndef _Stroika_Foundation_IO_Network_HTTP_Versions_h_
#define _Stroika_Foundation_IO_Network_HTTP_Versions_h_ 1
#include "../../../StroikaPreComp.h"
#include <map>
#include <string>
#include "../../../Configuration/Common.h"
/*
* TODO:
* @todo When we have a good C++ 'static string' class - maybe use that here.
* Maybe ONLY can do once we have compiler constexpr support?
*/
namespace Stroika::Foundation::IO::Network::HTTP {
// standard HTTP Versions one might want to access/retrieve
namespace Versions {
constexpr wstring_view kOnePointZero = L"1.0"sv;
constexpr wstring_view kOnePointOne = L"1.1"sv;
constexpr wstring_view kTwoPointZero = L"2.0"sv;
}
}
/*
********************************************************************************
***************************** Implementation Details ***************************
********************************************************************************
*/
#include "Versions.inl"
#endif /*_Stroika_Foundation_IO_Network_HTTP_Versions_h_*/
|
/*
* 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"
#import "SLMicroBlogSheetDelegate-Protocol.h"
#import "SLTwitterClientSessionProtocol-Protocol.h"
@class NSCache, SLRemoteSessionProxy<SLTwitterRemoteSessionProtocol>;
@interface SLTwitterSession : NSObject <SLTwitterClientSessionProtocol, SLMicroBlogSheetDelegate>
{
SLRemoteSessionProxy<SLTwitterRemoteSessionProtocol> *_remoteSession;
NSCache *_profileImageCache;
id _connectionResetBlock;
id _locationInformationChangedBlock;
}
+ (id)_remoteInterface;
@property(copy, nonatomic) id locationInformationChangedBlock; // @synthesize locationInformationChangedBlock=_locationInformationChangedBlock;
@property(copy, nonatomic) id connectionResetBlock; // @synthesize connectionResetBlock=_connectionResetBlock;
- (void).cxx_destruct;
- (id)serviceAccountTypeIdentifier;
- (void)getPermaLinkFromLastStatusUpdate:(id)arg1;
- (void)showSettingsIfNeeded;
- (void)acceptLocationUpdate:(id)arg1;
- (void)sendStatus:(id)arg1 completion:(id)arg2;
- (void)fetchGeotagStatus:(id)arg1;
- (void)overrideLocationWithLatitude:(float)arg1 longitude:(float)arg2 name:(id)arg3;
- (void)setOverrideGeotagInfo:(id)arg1;
- (void)setGeotagStatus:(int)arg1;
- (void)fetchRelationshipWithScreenName:(id)arg1 completion:(id)arg2;
- (void)fetchCurrentImageLimits:(id)arg1;
- (void)fetchCurrentUrlLimits:(id)arg1;
- (void)recordsMatchingPrefixString:(id)arg1 completion:(id)arg2;
- (id)cachedProfileImageDataForScreenName:(id)arg1;
- (void)fetchProfileImageDataForScreenName:(id)arg1 completion:(id)arg2;
- (void)fetchRecordForScreenName:(id)arg1 completion:(id)arg2;
- (void)ensureUserRecordStore;
- (void)fetchSessionInfo:(id)arg1;
- (void)setActiveAccountIdentifier:(id)arg1;
- (void)tearDownConnectionToRemoteSession;
- (id)init;
@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
FOUNDATION_EXPORT double Pods_DYLiveVersionNumber;
FOUNDATION_EXPORT const unsigned char Pods_DYLiveVersionString[];
|
#include "my_functions.h"
int main(void)
{
print_base16();
return (0);
}
|
#pragma once
#include <Skuld/Support/Path.h>
namespace Skuld
{
namespace PathInstances
{
extern PathImplementRef Posix;
extern PathImplementRef Win32;
};
} |
// Copyright (c) 2011-2013 The Bitcoin developers
// Copyright (c) 2014 Dyffy Inc.
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef OPTIONSMODEL_H
#define OPTIONSMODEL_H
#include <QAbstractListModel>
QT_BEGIN_NAMESPACE
class QNetworkProxy;
QT_END_NAMESPACE
/** Interface from Qt to configuration data structure for Catchcoin client.
To Qt, the options are presented as a list with the different options
laid out vertically.
This can be changed to a tree once the settings become sufficiently
complex.
*/
class OptionsModel : public QAbstractListModel
{
Q_OBJECT
public:
explicit OptionsModel(QObject *parent = 0);
enum OptionID {
StartAtStartup, // bool
MinimizeToTray, // bool
MapPortUPnP, // bool
MinimizeOnClose, // bool
ProxyUse, // bool
ProxyIP, // QString
ProxyPort, // int
ProxySocksVersion, // int
Fee, // qint64
DisplayUnit, // CatchcoinUnits::Unit
DisplayAddresses, // bool
Language, // QString
CoinControlFeatures, // bool
ThreadsScriptVerif, // int
DatabaseCache, // int
SpendZeroConfChange, // bool
OptionIDRowCount,
};
void Init();
void Reset();
int rowCount(const QModelIndex & parent = QModelIndex()) const;
QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;
bool setData(const QModelIndex & index, const QVariant & value, int role = Qt::EditRole);
/* Explicit getters */
bool getMinimizeToTray() { return fMinimizeToTray; }
bool getMinimizeOnClose() { return fMinimizeOnClose; }
int getDisplayUnit() { return nDisplayUnit; }
bool getDisplayAddresses() { return bDisplayAddresses; }
bool getProxySettings(QNetworkProxy& proxy) const;
bool getCoinControlFeatures() { return fCoinControlFeatures; }
const QString& getOverriddenByCommandLine() { return strOverriddenByCommandLine; }
/* Restart flag helper */
void setRestartRequired(bool fRequired);
bool isRestartRequired();
private:
/* Qt-only settings */
bool fMinimizeToTray;
bool fMinimizeOnClose;
QString language;
int nDisplayUnit;
bool bDisplayAddresses;
bool fCoinControlFeatures;
/* settings that were overriden by command-line */
QString strOverriddenByCommandLine;
signals:
void displayUnitChanged(int unit);
void transactionFeeChanged(qint64);
void coinControlFeaturesChanged(bool);
};
#endif // OPTIONSMODEL_H
|
#include <bert/encoder.h>
#include <bert/magic.h>
#include <bert/errno.h>
#include "test.h"
unsigned char output[2];
int main()
{
bert_encoder_t *encoder = test_encoder(output,2);
bert_data_t *data;
if (!(data = bert_data_create_int(0)))
{
test_fail("malloc failed");
}
int result;
if ((result = bert_encoder_push(encoder,data)) != BERT_ERRNO_SHORT_WRITE)
{
test_fail("bert_encoder_push returned %d, expected BERT_ERRNO_SHORT_READ",result);
}
bert_data_destroy(data);
bert_encoder_destroy(encoder);
return 0;
}
|
#ifndef DISK_COLLECT_H_INCLUDED
#define DISK_COLLECT_H_INCLUDED
#include "CollectProto.h"
#include "WMIUtil.h"
#include "WinSetupUtil.h"
class DiskCollector:
public AutoCreateDataCollector<DiskCollector>,
public WMIUtilLocal<DiskCollector>,
public WinSetupClientLocal<DiskCollector>
{
public:
DiskCollector()
{
}
long Collect(NVDataItem ** ReturnItem);
virtual ~DiskCollector() {};
private:
long CollectSingleDisk (IWbemClassObject * WMIDisk, NVDataItem *TargetItem, bool * KeepItem);
long CollectSingleCDROM (IWbemClassObject * WMIDisk, NVDataItem *TargetItem, bool * KeepItem);
};
#endif
|
//
// MarkerTextView.h
// Line View Test
//
// Created by Paul Kim on 10/4/08.
// Copyright (c) 2008 Noodlesoft, LLC. 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 <Cocoa/Cocoa.h>
#import "NoodleLineNumberView.h"
@interface NoodleMarkerLineNumberView : NoodleLineNumberView
{
NSImage *markerImage;
}
@end
|
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
* Copyright (c) 2007-2020, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
* \file cstring.c
*
* \brief Decode data that has been written as a C literal.
**/
#include "lib/encoding/cstring.h"
#include "lib/log/log.h"
#include "lib/log/util_bug.h"
#include "lib/malloc/malloc.h"
#include "lib/string/compat_ctype.h"
#include <string.h>
#define TOR_ISODIGIT(c) ('0' <= (c) && (c) <= '7')
/** Given a c-style double-quoted escaped string in <b>s</b>, extract and
* decode its contents into a newly allocated string. On success, assign this
* string to *<b>result</b>, assign its length to <b>size_out</b> (if
* provided), and return a pointer to the position in <b>s</b> immediately
* after the string. On failure, return NULL.
*/
const char *
unescape_string(const char *s, char **result, size_t *size_out)
{
const char *cp;
char *out;
if (s[0] != '\"')
return NULL;
cp = s+1;
while (1) {
switch (*cp) {
case '\0':
case '\n':
return NULL;
case '\"':
goto end_of_loop;
case '\\':
if (cp[1] == 'x' || cp[1] == 'X') {
if (!(TOR_ISXDIGIT(cp[2]) && TOR_ISXDIGIT(cp[3])))
return NULL;
cp += 4;
} else if (TOR_ISODIGIT(cp[1])) {
cp += 2;
if (TOR_ISODIGIT(*cp)) ++cp;
if (TOR_ISODIGIT(*cp)) ++cp;
} else if (cp[1] == 'n' || cp[1] == 'r' || cp[1] == 't' || cp[1] == '"'
|| cp[1] == '\\' || cp[1] == '\'') {
cp += 2;
} else {
return NULL;
}
break;
default:
++cp;
break;
}
}
end_of_loop:
out = *result = tor_malloc(cp-s + 1);
cp = s+1;
while (1) {
switch (*cp)
{
case '\"':
*out = '\0';
if (size_out) *size_out = out - *result;
return cp+1;
/* LCOV_EXCL_START -- we caught this in parse_config_from_line. */
case '\0':
tor_fragile_assert();
tor_free(*result);
return NULL;
/* LCOV_EXCL_STOP */
case '\\':
switch (cp[1])
{
case 'n': *out++ = '\n'; cp += 2; break;
case 'r': *out++ = '\r'; cp += 2; break;
case 't': *out++ = '\t'; cp += 2; break;
case 'x': case 'X':
{
int x1, x2;
x1 = hex_decode_digit(cp[2]);
x2 = hex_decode_digit(cp[3]);
if (x1 == -1 || x2 == -1) {
/* LCOV_EXCL_START */
/* we caught this above in the initial loop. */
tor_assert_nonfatal_unreached();
tor_free(*result);
return NULL;
/* LCOV_EXCL_STOP */
}
*out++ = ((x1<<4) + x2);
cp += 4;
}
break;
case '0': case '1': case '2': case '3': case '4': case '5':
case '6': case '7':
{
int n = cp[1]-'0';
cp += 2;
if (TOR_ISODIGIT(*cp)) { n = n*8 + *cp-'0'; cp++; }
if (TOR_ISODIGIT(*cp)) { n = n*8 + *cp-'0'; cp++; }
if (n > 255) { tor_free(*result); return NULL; }
*out++ = (char)n;
}
break;
case '\'':
case '\"':
case '\\':
case '\?':
*out++ = cp[1];
cp += 2;
break;
/* LCOV_EXCL_START */
default:
/* we caught this above in the initial loop. */
tor_assert_nonfatal_unreached();
tor_free(*result); return NULL;
/* LCOV_EXCL_STOP */
}
break;
default:
*out++ = *cp++;
}
}
}
|
/*
Author: Debbie Nuttall <debbie@cromulence.com>
Copyright (c) 2016 Cromulence LLC
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.
*/
#ifndef MSLS_HANDSHAKE_H
#define MSLS_HANDSHAKE_H
#define COOKIE_BASE1 MAGIC_PAGE
#define COOKIE_BASE2 (MAGIC_PAGE + 128*4)
#define SERVER_SECRET1 (MAGIC_PAGE + 512)
#define SERVER_SECRET2 (MAGIC_PAGE + 512 + 128*4)
#define PUBLIC_KEY_BASE1 (MAGIC_PAGE + 1024)
#define PUBLIC_KEY_BASE2 (MAGIC_PAGE + 1024 + 128*4)
#define RANDOM_BASE (MAGIC_PAGE + 2048)
#define RANDOM_END (MAGIC_PAGE + 4096)
#define MSLS_HS_CLIENT_HELLO 0x51
#define MSLS_HS_HELLO_VERIFY 0x52
#define MSLS_HS_SERVER_HELLO 0x53
#define MSLS_HS_CERTIFICATE 0x54
#define MSLS_HS_SERVER_KEYX 0x55
#define MSLS_HS_CLIENTKEYX 0x56
#define MSLS_HS_SERVER_DONE 0x57
#define MSLS_HS_CLIENT_DONE 0x58
#define MSLS_HS_FINISH 0x59
#pragma pack(push, 1)
typedef struct MSLSClientHello_s {
uint16_t client_version;
uint32_t random;
uint32_t session_id;
uint32_t cookie[MSLS_COOKIE_SIZE];
uint16_t cipher_suites[MAX_CIPHER_SUITES];
} MSLS_CLIENT_HELLO_MSG;
#define PUBLIC_KEY_LEN 128
typedef struct MSLSHelloVerify_s {
uint16_t server_version;
uint32_t cookie[MSLS_COOKIE_SIZE];
} MSLS_HELLO_VERIFY_MSG;
typedef struct MSLSServerHello_s {
uint16_t server_version;
uint32_t random;
uint16_t cipher_suite;
} MSLS_SERVER_HELLO_MSG;
#define NAME_LEN 32
typedef struct MSLSCertificate_s {
uint16_t certificate_id;
uint8_t name[NAME_LEN];
uint32_t public_key[PUBLIC_KEY_LEN];
uint32_t issuer_id;
} MSLS_CERTIFICATE_MSG;
typedef struct MSLSServerKeyX_s {
uint32_t key[PUBLIC_KEY_LEN];
} MSLS_SERVER_KEYX_MSG;
typedef struct MSLSClientKeyX_s {
uint32_t key[PUBLIC_KEY_LEN];
uint32_t pre_secret[PUBLIC_KEY_LEN];
} MSLS_CLIENT_KEYX_MSG;
typedef struct MSLSFinished_s {
uint32_t hash[PUBLIC_KEY_LEN];
} MSLS_FINISHED_MSG;
#pragma pack(pop)
void destroy_context(CLIENT_CONTEXT *context);
void msls_destroy_connection(SERVER_STATE *state, uint32_t client_id);
CLIENT_CONTEXT *msls_get_connection(SERVER_STATE *state, uint32_t client_id);
void msls_set_cookie(SERVER_STATE *state);
CLIENT_CONTEXT *msls_lookup_context(SERVER_STATE *state, uint32_t client_id);
void msls_send_server_hello(CLIENT_CONTEXT *context);
void msls_send_hello_verify(SERVER_STATE *state, uint32_t connection_id);
void msls_send_keyx(CLIENT_CONTEXT *context);
void msls_send_hello_done(CLIENT_CONTEXT *context);
void msls_send_finish(CLIENT_CONTEXT *context);
void msls_encrypt(uint8_t *buffer, uint32_t length, CLIENT_CONTEXT *connection);
void msls_decrypt(uint8_t *buffer, uint32_t length, CLIENT_CONTEXT *connection);
#endif |
/* The MIT License
Copyright (C) 2011, 2012 Zilong Tan (eric.zltan@gmail.com)
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.
*/
#ifndef __ULIB_TIMER_H
#define __ULIB_TIMER_H
#include <time.h>
typedef struct timespec ulib_timer_t;
static inline void timer_start(ulib_timer_t * ts)
{
clock_gettime(CLOCK_MONOTONIC, ts);
}
static inline double timer_stop(const ulib_timer_t * ts)
{
ulib_timer_t tsnow;
clock_gettime(CLOCK_MONOTONIC, &tsnow);
return (tsnow.tv_sec - ts->tv_sec +
(tsnow.tv_nsec - ts->tv_nsec) / 1000000000.0);
}
#endif /* __ULIB_TIMER_H */
|
//
// UIStoryboard+LM.h
// LMCategory
//
// Created by 李蒙 on 15/7/20.
// Copyright (c) 2015年 李蒙. All rights reserved.
//
#import <UIKit/UIKit.h>
#define LMInitialStoryboardName(name) [UIStoryboard lm_initialViewControllerWithStoryboardName:name]
#define LMInitialStoryboardNameIdentifier(name, identifier) [UIStoryboard lm_storyboardWithName:name instantiateViewControllerWithIdentifier:identifier]
#define LMInitialViewController [UIStoryboard lm_initialViewController]
#define LMMainStoryboardIdentifier(identifier) [UIStoryboard lm_mainStoryboardInstantiateViewControllerWithIdentifier:identifier]
@interface UIStoryboard (LM)
/**
* 快速创建ViewController
*
* @param name Storyboard Name
* @param identifier Storyboard ID
*
* @return id
*/
+ (id)lm_storyboardWithName:(NSString *)name instantiateViewControllerWithIdentifier:(NSString *)identifier;
/**
* 快速创建ViewController(Is InitialViewController)
*
* @param name storyboard Name
*
* @return id
*/
+ (id)lm_initialViewControllerWithStoryboardName:(NSString *)name;
/**
* 快速创建ViewController(Main Stroyboard && Is InitialViewController)
*
* @return id
*/
+ (id)lm_initialViewController;
/**
* 快速创建ViewController(Main Stroyboard)
*
* @param identifier Storyboard ID
*
* @return id
*/
+ (id)lm_mainStoryboardInstantiateViewControllerWithIdentifier:(NSString *)identifier;
@end
|
#ifndef _T_CFFEX_MARKET_
#define _T_CFFEX_MARKET_
#include "tdef.h"
//*****************************************************************************************
//ÒÔÉÏ·þÎñÊý¾ÝID±£ÁôÓëÔϵͳ¼æÈÝ£¬ÒÔÏ·þÎñIDÕë¶Ôÿ¸öÊг¡·Ö¿ª¶¨Òå
//-----------------------------------ÖнðËù-----------------------------------------------
#define ID_CFFEX_BASEINFO 3001 //ÆÚ»õ¼°ÆÚȨ»ù´¡ÐÅÏ¢
#define ID_CFFEX_MARKETDATA 3002 //ÆÚ»õ¼°ÆÚȨÐÐÇéÊý¾Ý
#define ID_CFFEX_FORQOUTE 3003 //ѯ¼Û֪ͨ
#define ID_CFFEX_MARKETDATAL2 3004 //ÆÚ»õ¼°ÆÚȨL2ÐÐÇéÊý¾Ý
#pragma pack(push, 1)
//1.1 ÖнðËùÆÚ»õÐÐÇé
typedef struct t_CFFEX_FutursMarketData
{
T_I32 nTime; //ʱ¼ä(HHMMSSmmmm)
T_I32 nStatus; //״̬
T_I64 iPreOpenInterest; //×ò³Ö²Ö
T_U32 uPreClose; //×òÊÕÅ̼Û
T_U32 uPreSettlePrice; //×ò½áËã
T_U32 uOpen; //¿ªÅ̼Û
T_U32 uHigh; //×î¸ß¼Û
T_U32 uLow; //×îµÍ¼Û
T_U32 uMatch; //×îмÛ
T_I64 iVolume; //³É½»×ÜÁ¿
T_I64 iTurnover; //³É½»×ܽð¶î
T_I64 iOpenInterest; //³Ö²Ö×ÜÁ¿
T_U32 uClose; //½ñÊÕÅÌ
T_U32 uSettlePrice; //½ñ½áËã
T_U32 uHighLimited; //ÕÇÍ£¼Û
T_U32 uLowLimited; //µøÍ£¼Û
T_I32 nPreDelta; //×òÐéʵ¶È
T_I32 nCurrDelta; //½ñÐéʵ¶È
T_U32 uAskPrice[5]; //ÉêÂô¼Û
T_U32 uAskVol[5]; //ÉêÂôÁ¿
T_U32 uBidPrice[5]; //ÉêÂò¼Û
T_U32 uBidVol[5]; //ÉêÂòÁ¿
char sTradingStatus; //½»Ò×״̬
char sRevs[3]; //±£Áô×Ö¶Î
} Futures_MarketData, T_CFFEX_FutursMarketData, *PCFFEX_FutursMarketData;
//1.2 ÖнðËùÆÚ»õ¼°ÆÚȨ»ù´¡ÐÅÏ¢
/////²úÆ·ÀàÐÍ-------------------------------------------------------
///ÆÚ»õ
#define THOST_FTDC_PC_Futures '1'
///ÆÚ»õÆÚȨ
#define THOST_FTDC_PC_Options '2'
///×éºÏ
#define THOST_FTDC_PC_Combination '3'
///¼´ÆÚ
#define THOST_FTDC_PC_Spot '4'
///ÆÚתÏÖ
#define THOST_FTDC_PC_EFP '5'
///ÏÖ»õÆÚȨ
#define THOST_FTDC_PC_SpotOption '6'
//ºÏÔ¼ÉúÃüÖÜÆÚ-----------------------------------------
///δÉÏÊÐ
#define THOST_FTDC_IP_NotStart '0'
///ÉÏÊÐ
#define THOST_FTDC_IP_Started '1'
///Í£ÅÆ
#define THOST_FTDC_IP_Pause '2'
///µ½ÆÚ
#define THOST_FTDC_IP_Expired '3'
//³Ö²ÖÀàÐÍ-------------------------------------------------
///¾»³Ö²Ö
#define THOST_FTDC_PT_Net '1'
///×ۺϳֲÖ
#define THOST_FTDC_PT_Gross '2'
/////////////////////////////////////////////////////////////////////////
//////³Ö²ÖÈÕÆÚÀàÐÍ
/////////////////////////////////////////////////////////////////////////
///ʹÓÃÀúÊ·³Ö²Ö
#define THOST_FTDC_PDT_UseHistory '1'
///²»Ê¹ÓÃÀúÊ·³Ö²Ö
#define THOST_FTDC_PDT_NoUseHistory '2'
/////////////////////////////////////////////////////////////////////////
///´ó¶îµ¥±ß±£Ö¤½ðËã·¨ÀàÐÍ
/////////////////////////////////////////////////////////////////////////
///²»Ê¹Óôó¶îµ¥±ß±£Ö¤½ðËã·¨
#define THOST_FTDC_MMSA_NO '0'
///ʹÓôó¶îµ¥±ß±£Ö¤½ðËã·¨
#define THOST_FTDC_MMSA_YES '1'
/////////////////////////////////////////////////////////////////////////
///ÆÚȨÀàÐÍÀàÐÍ
/////////////////////////////////////////////////////////////////////////
///¿´ÕÇ
#define THOST_FTDC_CP_CallOptions '1'
///¿´µø
#define THOST_FTDC_CP_PutOptions '2'
/////////////////////////////////////////////////////////////////////////
///×éºÏÀàÐÍÀàÐÍ
/////////////////////////////////////////////////////////////////////////
///ÆÚ»õ×éºÏ
#define THOST_FTDC_COMBT_Future '0'
///´¹Ö±¼Û²îBUL
#define THOST_FTDC_COMBT_BUL '1'
///´¹Ö±¼Û²îBER
#define THOST_FTDC_COMBT_BER '2'
///¿çʽ×éºÏ
#define THOST_FTDC_COMBT_STD '3'
///¿í¿çʽ×éºÏ
#define THOST_FTDC_COMBT_STG '4'
///±¸¶Ò×éºÏ
#define THOST_FTDC_COMBT_PRT '5'
///ʱ¼ä¼Û²î×éºÏ
#define THOST_FTDC_COMBT_CLD '6'
/////////////////////////////////////////////////////////////////////////
///ºÏÔ¼½»Ò×״̬ÀàÐÍ
/////////////////////////////////////////////////////////////////////////
///¿ªÅÌǰ
#define THOST_FTDC_IS_BeforeTrading '0'
///·Ç½»Ò×
#define THOST_FTDC_IS_NoTrading '1'
///Á¬Ðø½»Ò×
#define THOST_FTDC_IS_Continous '2'
///¼¯ºÏ¾º¼Û±¨µ¥
#define THOST_FTDC_IS_AuctionOrdering '3'
///¼¯ºÏ¾º¼Û¼Û¸ñƽºâ
#define THOST_FTDC_IS_AuctionBalance '4'
///¼¯ºÏ¾º¼Û´éºÏ
#define THOST_FTDC_IS_AuctionMatch '5'
///ÊÕÅÌ
#define THOST_FTDC_IS_Closed '6'
typedef struct t_CFFEX_BaseInfo
{
///ºÏÔ¼´úÂë
char sInstrumentID[31];
///½»Ò×Ëù´úÂë
char sExchangeID[9];
///ºÏÔ¼Ãû³Æ
char sInstrumentName[21];
///ºÏÔ¼ÔÚ½»Ò×ËùµÄ´úÂë
char sExchangeInstID[31];
///²úÆ·´úÂë
char sProductID[31];
///²úÆ·ÀàÐÍ
char cProductClass;
///½»¸îÄê·Ý
T_I32 nDeliveryYear;
///½»¸îÔÂ
T_I32 nDeliveryMonth;
///Êм۵¥×î´óϵ¥Á¿
T_I32 nMaxMarketOrderVolume;
///Êм۵¥×îСϵ¥Á¿
T_I32 nMinMarketOrderVolume;
///ÏÞ¼Ûµ¥×î´óϵ¥Á¿
T_I32 nMaxLimitOrderVolume;
///ÏÞ¼Ûµ¥×îСϵ¥Á¿
T_I32 nMinLimitOrderVolume;
///ºÏÔ¼ÊýÁ¿³ËÊý
T_I32 nVolumeMultiple;
///×îС±ä¶¯¼Ûλ,À©´ó10000±¶
T_I64 i64PriceTick;
///´´½¨ÈÕ
T_I32 nCreateDate;
///ÉÏÊÐÈÕ
T_I32 nOpenDate;
///µ½ÆÚÈÕ
T_I32 nExpireDate;
///¿ªÊ¼½»¸îÈÕ
T_I32 nStartDelivDate;
///½áÊø½»¸îÈÕ
T_I32 nEndDelivDate;
///ºÏÔ¼ÉúÃüÖÜÆÚ״̬
char cInstLifePhase;
///µ±Ç°ÊÇ·ñ½»Ò×
T_I32 nIsTrading;
///³Ö²ÖÀàÐÍ
char cPositionType;
///³Ö²ÖÈÕÆÚÀàÐÍ
char cPositionDateType;
///¶àÍ·±£Ö¤½ðÂÊ,À©´óÖÁ10000±¶
T_I64 i64LongMarginRatio;
///¿ÕÍ·±£Ö¤½ðÂÊ,À©´óÖÁ10000±¶
T_I64 i64ShortMarginRatio;
///ÊÇ·ñʹÓôó¶îµ¥±ß±£Ö¤½ðËã·¨
char cMaxMarginSideAlgorithm;
///»ù´¡ÉÌÆ·´úÂë
char sUnderlyingInstrID[31];
///Ö´ÐмÛ,À©´óÖÁ10000±¶
T_I64 i64StrikePrice;
///ÆÚȨÀàÐÍ
char cOptionsType;
///ºÏÔ¼»ù´¡ÉÌÆ·³ËÊý,À©´óÖÁ10000±¶
T_I64 i64UnderlyingMultiple;
///×éºÏÀàÐÍ
char cCombinationType;
} T_CFFEX_BaseInfo, *PCFFEX_BaseInfo;
///·¢¸ø×öÊÐÉ̵Äѯ¼ÛÇëÇó
typedef struct t_CFFEX_ForQuote
{
///½»Ò×ÈÕ
T_I32 nTradingDay;
///ºÏÔ¼´úÂë
char sInstrumentID[31];
///ѯ¼Û±àºÅ
char sForQuoteSysID[21];
///ѯ¼Ûʱ¼ä
T_I32 nForQuoteTime;
///ÒµÎñÈÕÆÚ
T_I32 nActionDay;
///½»Ò×Ëù´úÂë
char sExchangeID[9];
} T_CFFEX_ForQuote, *PCFFEX_ForQuote, T_ForQuote;
#pragma pack(pop)
#endif //_T_CFFEX_MARKET_ |
#pragma once
//------------------------------------------------------------------------------
/**
@class Oryol::_priv::urlLoader
@ingroup _priv
@brief processes a HTTP request and returns HTTP response
@see HTTPClient
*/
#if ORYOL_USE_LIBCURL
#include "HttpFS/private/curl/curlURLLoader.h"
namespace Oryol {
namespace _priv {
class urlLoader : public curlURLLoader {};
} }
#elif ORYOL_OSX
#include "HttpFS/private/osx/osxURLLoader.h"
namespace Oryol {
namespace _priv {
class urlLoader : public osxURLLoader {};
} }
#elif ORYOL_WINDOWS
#include "HttpFS/private/win/winURLLoader.h"
namespace Oryol {
namespace _priv {
class urlLoader : public winURLLoader {};
} }
#elif ORYOL_EMSCRIPTEN
#include "HttpFS/private/emsc/emscURLLoader.h"
namespace Oryol {
namespace _priv {
class urlLoader : public emscURLLoader {};
} }
#else
#include "HttpFS/private/baseURLLoader.h"
namespace Oryol {
namespace _priv {
class urlLoader : public baseURLLoader {};
} }
#endif
|
//
// Swiftly.h
// Swiftly
//
// Created by Nora Trapp on 6/23/15.
// Copyright (c) 2015 Trapp Design. All rights reserved.
//
#import <UIKit/UIKit.h>
//! Project version number for Swiftly.
FOUNDATION_EXPORT double SwiftlyVersionNumber;
//! Project version string for Swiftly.
FOUNDATION_EXPORT const unsigned char SwiftlyVersionString[];
|
#ifndef UTILS_H
#define UTILS_H
#include <stdio.h>
#define ERR(...) fprintf(stderr, __VA_ARGS__); return 1;
int rand_int(int min, int max);
int read_move(FILE *f, int *x, int *y);
void print_move(int x, int y);
#endif
|
/*
* ldisc.c: PuTTY line discipline. Sits between the input coming
* from keypresses in the window, and the output channel leading to
* the back end. Implements echo and/or local line editing,
* depending on what's currently configured.
*/
#include <stdio.h>
#include <ctype.h>
#include "putty.h"
#include "terminal.h"
#include "ldisc.h"
void lpage_send(void *handle,
int codepage, char *buf, int len, int interactive)
{
Ldisc ldisc = (Ldisc)handle;
wchar_t *widebuffer = 0;
int widesize = 0;
int wclen;
if (codepage < 0) {
ldisc_send(ldisc, buf, len, interactive);
return;
}
widesize = len * 2;
widebuffer = snewn(widesize, wchar_t);
wclen = mb_to_wc(codepage, 0, buf, len, widebuffer, widesize);
luni_send(ldisc, widebuffer, wclen, interactive);
sfree(widebuffer);
}
void luni_send(void *handle, wchar_t * widebuf, int len, int interactive)
{
Ldisc ldisc = (Ldisc)handle;
int ratio = (in_utf(ldisc->term))?3:1;
char *linebuffer;
int linesize;
int i;
char *p;
linesize = len * ratio * 2;
linebuffer = snewn(linesize, char);
if (in_utf(ldisc->term)) {
/* UTF is a simple algorithm */
for (p = linebuffer, i = 0; i < len; i++) {
unsigned long ch = widebuf[i];
if (IS_SURROGATE(ch)) {
#ifdef PLATFORM_IS_UTF16
if (i+1 < len) {
unsigned long ch2 = widebuf[i+1];
if (IS_SURROGATE_PAIR(ch, ch2)) {
ch = FROM_SURROGATES(ch, ch2);
i++;
}
} else
#endif
{
/* Unrecognised UTF-16 sequence */
ch = '.';
}
}
if (ch < 0x80) {
*p++ = (char) (ch);
} else if (ch < 0x800) {
*p++ = (char) (0xC0 | (ch >> 6));
*p++ = (char) (0x80 | (ch & 0x3F));
} else if (ch < 0x10000) {
*p++ = (char) (0xE0 | (ch >> 12));
*p++ = (char) (0x80 | ((ch >> 6) & 0x3F));
*p++ = (char) (0x80 | (ch & 0x3F));
} else {
*p++ = (char) (0xF0 | (ch >> 18));
*p++ = (char) (0x80 | ((ch >> 12) & 0x3F));
*p++ = (char) (0x80 | ((ch >> 6) & 0x3F));
*p++ = (char) (0x80 | (ch & 0x3F));
}
}
} else {
int rv;
rv = wc_to_mb(ldisc->term->ucsdata->line_codepage, 0, widebuf, len,
linebuffer, linesize, NULL, NULL, ldisc->term->ucsdata);
if (rv >= 0)
p = linebuffer + rv;
else
p = linebuffer;
}
if (p > linebuffer)
ldisc_send(ldisc, linebuffer, p - linebuffer, interactive);
sfree(linebuffer);
}
|
#pragma once
#include "material/material.h"
namespace AT_NAME
{
class FlakesNormal {
private:
FlakesNormal();
~FlakesNormal();
public:
static AT_DEVICE_MTRL_API aten::vec4 gen(
real u, real v,
real flake_scale = real(50.0), // Smaller values zoom into the flake map, larger values zoom out.
real flake_size = real(0.5), // Relative size of the flakes
real flake_size_variance = real(0.7), // 0.0 makes all flakes the same size, 1.0 assigns random size between 0 and the given flake size
real flake_normal_orientation = real(0.5)); // Blend between the flake normals (0.0) and the surface normal (1.0)
static inline AT_DEVICE_MTRL_API real computeFlakeDensity(
real flake_size,
real flakeMapAspect)
{
// NOTE
// size : mapサイズの長辺に占める割合.
// ex) w = 1280, h = 720, size = 0.5 -> flake radius = (w > h ? h : w) * size = 720 * 0.5 = 360
// scale : サイズを 1 / scale にする.
// NOTE
// 画面に占めるflakeの面積割合は以下のようになる.
// (Pi * radius * radius) * N / (w * h)
// radius : flake radius
// N : Number of flake
// w : map width
// h : map height
// ここで、w > h として、radius = (w > h ? h : w) * size / scale = size / scale * h を当てはめる.
// Density = Pi * (size / scale * h)^2 * N / (w * h)
// = Pi * (size / scale)^2 * N * h / w
// scale = 1 の場合、マップ全体にflakeが約1つとなると考えることができる.
// つまり、If scale = 1, N = 1 となる.
// scaleが大きくなっても、これが縦横にscale個繰り返されるだけなので、マップに占めるflakeの面積割合は変わらない.
// Density = Pi * (size / scale)^2 * N * h / w
// = Pi * size^2 * h / w
// TODO
// aspect = w / h の前提なので、h / w を取得したいため逆数にする.
auto aspect = real(1) / flakeMapAspect;
auto D = AT_MATH_PI * flake_size * flake_size * aspect;
D = aten::cmpMin(D, real(1));
return D;
}
};
}
|
/*
* 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 NSArray;
// Not exported
@interface UIWebOptGroup : NSObject
{
id <UIWebSelectedItemPrivate> _group;
NSArray *_options;
long long _offset;
}
@property(retain, nonatomic) NSArray *options; // @synthesize options=_options;
@property(retain, nonatomic) id <UIWebSelectedItemPrivate> group; // @synthesize group=_group;
@property(readonly, nonatomic) long long offset; // @synthesize offset=_offset;
- (void)dealloc;
- (id)initWithGroup:(id)arg1 itemOffset:(long long)arg2;
@end
|
//
// Copyright (c) 2008-2019 the Urho3D project.
//
// 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.
//
#pragma once
#include "../Scene/Component.h"
namespace Urho3D
{
/// A link between otherwise unconnected regions of the navigation mesh.
class URHO3D_API OffMeshConnection : public Component
{
URHO3D_OBJECT(OffMeshConnection, Component);
public:
/// Construct.
explicit OffMeshConnection(Context* context);
/// Destruct.
~OffMeshConnection() override;
/// Register object factory.
static void RegisterObject(Context* context);
/// Apply attribute changes that can not be applied immediately. Called after scene load or a network update.
void ApplyAttributes() override;
/// Visualize the component as debug geometry.
void DrawDebugGeometry(DebugRenderer* debug, bool depthTest) override;
/// Set endpoint node.
void SetEndPoint(Node* node);
/// Set radius.
void SetRadius(float radius);
/// Set bidirectional flag. Default true.
void SetBidirectional(bool enabled);
/// Set a user assigned mask
void SetMask(unsigned newMask);
/// Sets the assigned area Id for the connection
void SetAreaID(unsigned newAreaID);
/// Return endpoint node.
Node* GetEndPoint() const;
/// Return radius.
float GetRadius() const { return radius_; }
/// Return whether is bidirectional.
bool IsBidirectional() const { return bidirectional_; }
/// Return the user assigned mask
unsigned GetMask() const { return mask_; }
/// Return the user assigned area ID
unsigned GetAreaID() const { return areaId_; }
private:
/// Mark end point dirty.
void MarkEndPointDirty() { endPointDirty_ = true; }
/// Endpoint node.
WeakPtr<Node> endPoint_;
/// Endpoint node ID.
unsigned endPointID_;
/// Radius.
float radius_;
/// Bidirectional flag.
bool bidirectional_;
/// Endpoint changed flag.
bool endPointDirty_;
/// Flags mask to represent properties of this mesh
unsigned mask_;
/// Area id to be used for this off mesh connection's internal poly
unsigned areaId_;
};
}
|
//
// AppDelegate.h
// anima
//
// Created by Daniel Fliegauf on 06/06/14.
// Copyright (c) 2014 Daniel Fliegauf. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@end
|
#include "stack.h"
struct Stack *init_stack()
{
struct Stack *init = (struct Stack *)malloc(sizeof(struct Stack));
init->length = 0;
init->top = NULL;
init->bottom = NULL;
return init;
}
void push(struct Stack *s, BinTreeNode * data)
{
struct StackNode *node = (struct StackNode *)malloc(sizeof(struct StackNode));
node->data = data;
node->next = s->top;
if (s->length == 0)
{
s->bottom = node;
}
s->top = node;
s->length++;
}
BinTreeNode * pop(struct Stack *s)
{
if (s->length)
{
struct StackNode *temp = s->top;
BinTreeNode * data = temp->data;
s->top = temp->next;
s->length--;
return data;
}
else
{
return NULL;
}
}
int stack_len(struct Stack *s)
{
return s->length;
}
BinTreeNode * top(struct Stack *s)
{
return s->top->data;
} |
#ifndef FILECIPHER_H
#define FILECIPHER_H
class FileCipher
{
public:
FileCipher();
};
#endif // FILECIPHER_H
|
/*
Copyright (c) 2013 - Philippe Laulheret, Second Story [http://www.secondstory.com]
This code is protected under MIT license.
For more information visit : https://github.com/secondstory/LYT
*/
#pragma once
#ifndef _GLOBAL_H_
#define _GLOBAL_H_
#include <Adafruit_WS2801.h>
#include <Ethernet.h>
#include <EthernetUdp.h>
#include <OSCMessage.h>
#include <OSCBundle.h>
#include <SPI.h>
#include <algorithm> //for min max
#include "OSCRxTx.h"
extern int count;
//----------------------------------------------------------
// Layout Setting
//-----------------------------------------------------------
#define N_COL 55
#define N_LINE 6
#define N_PANNEL 3
#define MAX_OBJECT 1000
//----------------------------------------------------------
// Network Setting
//-----------------------------------------------------------
//IPAddress ip(192,168,4,17);
extern IPAddress ip; //Is the IP of the debug computer !
extern IPAddress touchServerIp;
extern IPAddress boardsIP[3]; //used for lookup
extern OSCRxTx osc;
extern int boardID;
//----------------------------------------------------------
// Animation setting
//-----------------------------------------------------------
extern float default_brightness;
extern float default_sat;
extern float current_hue;
extern float decaySpeed;
extern float hueSpeed;
extern float my_time[N_COL*N_LINE];
//----------------------------------------------------------
// Global Variables
//-----------------------------------------------------------
extern float bright[N_LINE*N_COL];
extern uint8_t pixelBuffer[N_COL*N_LINE*3];
extern uint8_t _r;
extern uint8_t _g;
extern uint8_t _b;
extern Adafruit_WS2801 strip;
bool getIndex(int &ix, int x, int y);
//-----------------------------------------
// Drawing functions
//------------------------------------------
void drawCircle(int x, int y, int radius);
void drawRectangle(int x, int y, int w, int h);
void drawPixel(int x, int y);
void setColor(uint8_t r, uint8_t g,uint8_t b);
void setColor(float hue, float saturation, float brightness);
void getRGBFromHSB(uint8_t &r, uint8_t &g, uint8_t &b, float hue, float saturation, float brightness );
#endif
|
// This code contains NVIDIA Confidential Information and is disclosed to you
// under a form of NVIDIA software license agreement provided separately to you.
//
// Notice
// NVIDIA Corporation and its licensors retain all intellectual property and
// proprietary rights in and to this software and related documentation and
// any modifications thereto. Any use, reproduction, disclosure, or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA Corporation is strictly prohibited.
//
// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
//
// Information and code furnished is believed to be accurate and reliable.
// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
// information or for any infringement of patents or other rights of third parties that may
// result from its use. No license is granted by implication or otherwise under any patent
// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
// This code supersedes and replaces all information previously supplied.
// NVIDIA Corporation products are not authorized for use as critical
// components in life support devices or systems without express written approval of
// NVIDIA Corporation.
//
// Copyright (c) 2008-2014 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef NV_NSFOUNDATION_NSSTRING_H
#define NV_NSFOUNDATION_NSSTRING_H
#include "NvPreprocessor.h"
#include "NvSimpleTypes.h"
#include <stdarg.h>
namespace nvidia
{
namespace shdfnd
{
// the following functions have C99 semantics. Note that C99 requires for snprintf and vsnprintf:
// * the resulting string is always NULL-terminated regardless of truncation.
// * in the case of truncation the return value is the number of characters that would have been created.
NV_FOUNDATION_API int32_t sscanf(const char* buffer, const char* format, ...);
NV_FOUNDATION_API int32_t strcmp(const char* str1, const char* str2);
NV_FOUNDATION_API int32_t strncmp(const char* str1, const char* str2, size_t count);
NV_FOUNDATION_API int32_t snprintf(char* dst, size_t dstSize, const char* format, ...);
NV_FOUNDATION_API int32_t vsnprintf(char* dst, size_t dstSize, const char* src, va_list arg);
// strlcat and strlcpy have BSD semantics:
// * dstSize is always the size of the destination buffer
// * the resulting string is always NULL-terminated regardless of truncation
// * in the case of truncation the return value is the length of the string that would have been created
NV_FOUNDATION_API size_t strlcat(char* dst, size_t dstSize, const char* src);
NV_FOUNDATION_API size_t strlcpy(char* dst, size_t dstSize, const char* src);
// case-insensitive string comparison
NV_FOUNDATION_API int32_t stricmp(const char* str1, const char* str2);
NV_FOUNDATION_API int32_t strnicmp(const char* str1, const char* str2, size_t count);
// in-place string case conversion
NV_FOUNDATION_API void strlwr(char* str);
NV_FOUNDATION_API void strupr(char* str);
/**
\brief The maximum supported formatted output string length
(number of characters after replacement).
@see printFormatted()
*/
static const size_t MAX_PRINTFORMATTED_LENGTH = 1024;
/**
\brief Prints the formatted data, trying to make sure it's visible to the app programmer
@see NS_MAX_PRINTFORMATTED_LENGTH
*/
NV_FOUNDATION_API void printFormatted(const char*, ...);
/**
\brief Prints the string literally (does not consume % specifier), trying to make sure it's visible to the app
programmer
*/
NV_FOUNDATION_API void printString(const char*);
}
}
#endif // #ifndef NV_NSFOUNDATION_NSSTRING_H
|
/*
* Copyright (C) 2013 Philippe Gerum <rpm@xenomai.org>.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
#ifndef _BOILERPLATE_COMPILER_H
#define _BOILERPLATE_COMPILER_H
#include <stddef.h>
#define container_of(ptr, type, member) \
({ \
const __typeof__(((type *)0)->member) *__mptr = (ptr); \
(type *)((char *)__mptr - offsetof(type, member)); \
})
#define __stringify_1(x...) #x
#define __stringify(x...) __stringify_1(x)
#ifndef likely
#define likely(x) __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect(!!(x), 0)
#endif
#ifndef __noreturn
#define __noreturn __attribute__((__noreturn__))
#endif
#ifndef __must_check
#define __must_check __attribute__((__warn_unused_result__))
#endif
#ifndef __weak
#define __weak __attribute__((__weak__))
#endif
#ifndef __maybe_unused
#define __maybe_unused __attribute__((__unused__))
#endif
#ifndef __aligned
#define __aligned(__n) __attribute__((aligned (__n)))
#endif
#ifndef __deprecated
#define __deprecated __attribute__((__deprecated__))
#endif
#ifdef __cplusplus
extern "C" {
#endif
void __invalid_operand_size(void);
#define ctz(__v) \
({ \
int __ret; \
if (!__v) \
__ret = sizeof(__v) * 8; \
else \
switch (sizeof(__v)) { \
case sizeof(int): \
__ret = __builtin_ctz((unsigned int)__v); \
break; \
case sizeof(long long): \
__ret = __builtin_ctzll(__v); \
break; \
default: \
__invalid_operand_size(); \
} \
__ret; \
})
#define clz(__v) \
({ \
int __ret; \
if (!__v) \
__ret = sizeof(__v) * 8; \
else \
switch (sizeof(__v)) { \
case sizeof(int): \
__ret = __builtin_clz((unsigned int)__v); \
break; \
case sizeof(long long): \
__ret = __builtin_clzll(__v); \
break; \
default: \
__invalid_operand_size(); \
} \
__ret; \
})
#ifdef __cplusplus
}
#endif
#endif /* _BOILERPLATE_COMPILER_H */
|
#ifndef pt_ifile_cache_h
#define pt_ifile_cache_h
#include "pt_idata_cache.h"
pt_idata_cache* pt_open_file_cache(pt_icache_callback callback, const char* url);
#endif |
/*
Author: Joe Rogers <joe@cromulence.com>
Copyright (c) 2015 Cromulence LLC
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 <libcgc.h>
#include "stdlib.h"
#include "stdio.h"
#include "common.h"
#include "string.h"
#include "L2.h"
#include "L3.h"
#include "L4.h"
// Send an echo packet to cb3 on startup to init L2Adjacencies
void SendEchoRequest(void) {
unsigned char Packet[MAX_FRAME_LEN];
pL3Hdr pL3 = (pL3Hdr)Packet;
pL4Hdr pL4 = (pL4Hdr)(Packet+sizeof(L3Hdr));
bzero(Packet, MAX_FRAME_LEN);
// build up the L4 header
pL4->Dst = 7; // echo port
pL4->Src = 1; // src port, don't care
pL4->Len = 4;
cgc_memcpy(Packet+sizeof(L3Hdr)+sizeof(L4Hdr), (void *)0x4347C000, 4);
// build up the L3 header
pL3->Dst = 0x0a010202;
pL3->Src = 0x0a010201;
pL3->Len = sizeof(L4Hdr)+pL4->Len;
pL3->NxtHdr = 0x1;
// Forward the Packet
L3_ForwardPacket(Packet);
}
int main(void) {
unsigned char Frame[MAX_FRAME_LEN];
unsigned char Packet[MAX_FRAME_LEN];
L2_InitCAM();
L3_InitInterfaces();
SendEchoRequest();
while (1) {
bzero(Packet, MAX_FRAME_LEN);
if (L3_RxPacket(FD_ROUTER, Packet)) {
L3_ForwardPacket(Packet);
}
L3_ServiceSendQueue();
}
return(0);
}
|
//----------------------------------------------------
// linbc 2014.11.28
// http://linbc.cnblogs.com/
// github: https://github.com/linbc/cocos2dx_xxtea_asset
#include "xxtea.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
static const char *progname = __FILE__;
char *optarg; /* argument associated with option */
int getopt(int nargc,char * const nargv[],const char *ostr);
const char *_getprogname(void) {
return progname;
}
static void usage(void) {
printf("Usage:\n"
"\n"
" %s [-e|-d] file1.lua -o file1.luac -s xxtea -k key -z \n"
"\n"
"Options:\n"
"\n"
" -e [lua script|*.jpg] encode file \n"
" -d <lua script|*.jpg> decode file \n"
" -i input file \n"
" -o output file \n"
" -s set xxteaSign_string \n"
" -k set xxtea_key_string \n"
" -h Show this help message.\n"
"",
progname);
exit(1);
}
typedef struct opts_holder_t{
int encode;
int decode;
int auto_by_header;
char input[1024];
char output[1024];
char xxteasign[1024];
char xxteakey[1024];
}opts_holder;
static void parse_opts(opts_holder *cf, int argc, char **argv) {
int opt;
int tmp;
progname = argv[0];
memset(cf,0,sizeof(*cf));
while (-1 != (opt = getopt(argc, argv, "i:o:s:k:aedh"))) {
switch (opt) {
case 'e': cf->encode = 1; break;
case 'd': cf->decode = 1; break;
case 'a': cf->auto_by_header = 1; break;
case 'i': strcpy(cf->input, optarg); break;
case 'o': strcpy(cf->output, optarg); break;
case 's': strcpy(cf->xxteasign, optarg); break;
case 'k': strcpy(cf->xxteakey, optarg); break;
default:
usage();
}
}
//½âÃܼ°¼ÓÃÜ¡¢¸ù¾ÝÎļþÍ·×Ô¶¯¾ö¶¨Ä£Ê½µÈ²»ÄÜͬʱ´æÔÚ
tmp = cf->encode + cf->decode + cf->auto_by_header;
if(tmp > 1 || tmp == 0)
usage();
//ÊäÈëºÍÊä³ö¶¼²»¿ÉÒÔΪ¿Õ
if (strlen(cf->input) == 0 || strlen(cf->output) == 0)
usage();
}
static int write_file(const char* sign, const char* content, int len, const char* file) {
int sign_len = 0;
FILE *f = fopen(file,"wb");
if(!f) {
printf("open file:%s failed!",file);
return -1;
}
//µ±½âÂëµÄʱºò¾Í²»ÐèÒªÎļþÍ·£¬ÈëÈë¿ÕÖ¸Õë¼´¿É
sign_len = sign == NULL? 0 :strlen(sign);
if(sign_len > 0)
fwrite(sign,1,sign_len,f);
fwrite(content, 1, len, f);
fclose(f);
return 0;
}
static int read_file(const char* inputf,char **out) {
char *p = NULL;
int total = 0;
char temp[8096];
FILE *f = fopen(inputf, "rb");
if(!f) {
printf("open file:%s failed!",inputf);
return -1;
}
p = (char*)malloc(1);
while(!feof(f)){
int n = fread(temp,1,sizeof(temp),f);
total += n;
p = (char*)realloc(p,total + 1);
memcpy(p + total - n,temp, n);
}
fclose(f);
*out = p;
return total;
}
static int encode_file(const char* input,const char*output, const char* sign,const char* key) {
char *in_content = NULL;
int in_total = 0;
char *encode_result = NULL;
xxtea_long result_size = 0;
//¶ÁÈ¡ÎļþÁ÷
if((in_total = read_file(input,&in_content)) == -1){
return -1;
}
//¼ÓÃÜ
encode_result = (char*)xxtea_encrypt((unsigned char*)in_content,in_total,
(unsigned char*)key,strlen(key),&result_size);
//дÈëÎļþÁ÷
if(write_file(sign,encode_result,result_size,output)){
free(encode_result);
return -2;
}
//Í깤
if (encode_result){
free(encode_result);
encode_result = NULL;
}
return 0;
}
static int decode_file(const char* input,const char*output, const char* sign,const char* key) {
int sign_len = 0;
char *in_content = NULL;
int in_total = 0;
char *encode_result = NULL;
xxtea_long result_size = 0;
//¶ÁÈ¡ÎļþÁ÷
if((in_total = read_file(input,&in_content)) == -1){
return -1;
}
//ÑéÖ¤Ò»ÏÂÎļþÍ·
sign_len = strlen(sign);
if(sign_len && strncmp(in_content, sign, sign_len) != 0) {
return -2;
}
//½âÃÜ, ºöÂÔÎļþÍ·
encode_result = (char*)xxtea_decrypt((unsigned char*)in_content + sign_len,in_total - sign_len,
(unsigned char*)key,strlen(key),&result_size);
//дÈëÎļþÁ÷
if(write_file(NULL,encode_result,result_size,output)){
free(encode_result);
return -3;
}
//Í깤
if (encode_result){
free(encode_result);
encode_result = NULL;
}
return 0;
}
int main(int argc, char **argv){
opts_holder opts;
parse_opts(&opts,argc,argv);
if (opts.encode){
encode_file(opts.input, opts.output, opts.xxteasign, opts.xxteakey);
} else if (opts.decode) {
decode_file(opts.input, opts.output, opts.xxteasign, opts.xxteakey);
}
return 0;
}
|
// @COPYRIGHT@
// Licensed under MIT license (LICENSE.txt)
// clxx/cl/functions/create_program_with_binary.t.h
/** // doc: clxx/cl/functions/create_program_with_binary.t.h {{{
* \file clxx/cl/functions/create_program_with_binary.t.h
* \todo Write documentation
*/ // }}}
#ifndef CLXX_CL_FUNCTIONS_CREATE_PROGRAM_WITH_BINARY_T_H_INCLUDED
#define CLXX_CL_FUNCTIONS_CREATE_PROGRAM_WITH_BINARY_T_H_INCLUDED
#include <cxxtest/TestSuite.h>
#include <clxx/cl/functions.hpp>
#include <clxx/common/exceptions.hpp>
#include <clxx/cl/mock.hpp>
namespace clxx { class functions_create_program_with_binary_test_suite; }
/** // doc: class clxx::functions_create_program_with_binary_test_suite {{{
* \todo Write documentation
*/ // }}}
class clxx::functions_create_program_with_binary_test_suite : public CxxTest::TestSuite
{
public:
////////////////////////////////////////////////////////////////////////////
// create_program_with_binary()
////////////////////////////////////////////////////////////////////////////
/** // doc: test__create_program_with_binary() {{{
* \todo Write documentation
*/ // }}}
void test__create_program_with_binary( )
{
//T::Dummy_clCreateProgramWithBinary mock((cl_program)0x1234, CL_SUCCESS);
//create_program_with_binary ((cl_context)0x567, 5, (const cl_device_id*)0x487, (const size_t*)0x634, (const unsigned char**)0x174, (cl_int*)0x757);
//TS_ASSERT(mock.called_once_with((cl_context)0x567, 5, (const cl_device_id*)0x487, (const size_t*)0x634, (const unsigned char**)0x174, (cl_int*)0x757));
}
/** // doc: test__create_program_with_binary__invalid_context() {{{
* \todo Write documentation
*/ // }}}
void test__create_program_with_binary__invalid_context( )
{
T::Dummy_clCreateProgramWithBinary mock((cl_program)NULL, CL_INVALID_CONTEXT);
TS_ASSERT_THROWS(create_program_with_binary((cl_context)NULL, 0, nullptr, nullptr, nullptr, nullptr),clerror_no<status_t::invalid_context>);
}
/** // doc: test__create_program_with_binary__invalid_value() {{{
* \todo Write documentation
*/ // }}}
void test__create_program_with_binary__invalid_value( )
{
T::Dummy_clCreateProgramWithBinary mock((cl_program)NULL, CL_INVALID_VALUE);
TS_ASSERT_THROWS(create_program_with_binary((cl_context)NULL, 0, nullptr, nullptr, nullptr, nullptr),clerror_no<status_t::invalid_value>);
}
/** // doc: test__create_program_with_binary__invalid_device() {{{
* \todo Write documentation
*/ // }}}
void test__create_program_with_binary__invalid_device( )
{
T::Dummy_clCreateProgramWithBinary mock((cl_program)NULL, CL_INVALID_DEVICE);
TS_ASSERT_THROWS(create_program_with_binary((cl_context)NULL, 0, nullptr, nullptr, nullptr, nullptr),clerror_no<status_t::invalid_device>);
}
/** // doc: test__create_program_with_binary__invalid_binary() {{{
* \todo Write documentation
*/ // }}}
void test__create_program_with_binary__invalid_binary( )
{
T::Dummy_clCreateProgramWithBinary mock((cl_program)NULL, CL_INVALID_BINARY);
TS_ASSERT_THROWS(create_program_with_binary((cl_context)NULL, 0, nullptr, nullptr, nullptr, nullptr),clerror_no<status_t::invalid_binary>);
}
/** // doc: test__create_program_with_binary__out_of_resources() {{{
* \todo Write documentation
*/ // }}}
void test__create_program_with_binary__out_of_resources( )
{
T::Dummy_clCreateProgramWithBinary mock((cl_program)NULL, CL_OUT_OF_RESOURCES);
TS_ASSERT_THROWS(create_program_with_binary((cl_context)NULL, 0, nullptr, nullptr, nullptr, nullptr),clerror_no<status_t::out_of_resources>);
}
/** // doc: test__create_program_with_binary__out_of_host_memory() {{{
* \todo Write documentation
*/ // }}}
void test__create_program_with_binary__out_of_host_memory( )
{
T::Dummy_clCreateProgramWithBinary mock((cl_program)NULL, CL_OUT_OF_HOST_MEMORY);
TS_ASSERT_THROWS(create_program_with_binary((cl_context)NULL, 0, nullptr, nullptr, nullptr, nullptr),clerror_no<status_t::out_of_host_memory>);
}
/** // doc: test__create_program_with_binary__unexpected_clerror() {{{
* \todo Write documentation
*/ // }}}
void test__create_program_with_binary__unexpected_clerror( )
{
T::Dummy_clCreateProgramWithBinary mock((cl_program)NULL, -0x1234567);
TS_ASSERT_THROWS(create_program_with_binary((cl_context)NULL, 0, nullptr, nullptr, nullptr, nullptr), unexpected_clerror);
}
};
#endif /* CLXX_CL_FUNCTIONS_CREATE_PROGRAM_WITH_BINARY_T_H_INCLUDED */
// vim: set expandtab tabstop=2 shiftwidth=2:
// vim: set foldmethod=marker foldcolumn=4:
|
#include <MaxSLiCInterface.h>
#include "Maxfiles.h"
#include "common/common.h"
#include "common/timer.h"
#include "common/matrix.h"
#include "common/matvec.h"
void mat_transform_rowstripes_pipes(int n, int m, int s, int p, float * src, float * dst) {
int d = 0;
for (int i = 0; i < n; i += s)
for (int j = 0; j < m / p; j++)
for (int k = 0; k < s; k++)
for (int l = 0; l < p; l++)
dst[d++] = src[(i + k) * m + (j * p + l)];
}
int main(int argc, char * argv[]) {
INIT_MATVEC;
mat_t matAT = mat_make(size, size);
mat_transform_rowstripes_pipes(size, size, MatVec_STRIPE_SIZE, MatVec_PIPE_COUNT, matA, matAT);
MatVec(size, matAT, vecB, vecC);
free(matAT);
DONE_MATVEC;
}
|
FIS_TYPE fis_sum(FIS_TYPE a, FIS_TYPE b)
{
return (a + b);
} |
#ifndef SerialManager_UI_h
#define SerialManager_UI_h
#include <Arduino.h> //for String
#include <TympanRemoteFormatter.h> //for TR_Page
//#include "SerialManagerBase.h"
#include <TympanRemoteFormatter.h>
class SerialManagerBase; //forward declaration
class SerialManager_UI {
public:
SerialManager_UI(void) {
ID_char = next_ID_char++;
ID_char_fn = ID_char;
};
SerialManager_UI(SerialManagerBase *_sm) {
ID_char = next_ID_char++;
ID_char_fn = ID_char;
setSerialManager(_sm);
}
// ///////// these are the methods that you must implement when you inheret
virtual void printHelp(void) {}; //default is to print nothing
virtual bool processCharacter(char c) { return false; } ; //default is to do nothing
virtual bool processCharacterTriple(char mode_char, char chan_char, char data_char) { return false; }; //default is to do nothing
virtual void setFullGUIState(bool activeButtonsOnly=false) {}; //default is to do nothing
// ///////////////////////
//create the button sets for the TympanRemote's GUI, which you can override
virtual TR_Page* addPage_default(TympanRemoteFormatter *gui) { return NULL; }
// predefined helper functions, which you can override
virtual char getIDchar() { return ID_char; }
virtual String getPrefix(void) { return String(quadchar_start_char) + String(ID_char) + prefix_globalChar; } //your class can use any and every String-able character in place of "x"...so, you class can have *a lot* of commands
virtual char get_ID_char_fn(void) { return ID_char_fn; }
virtual char set_ID_char_fn(char c) { return ID_char_fn = c; }
// here is a method to create the very-common card (button group) to create display a parameter value
// and to adjust its value with a plus and minus button. Very common!
virtual TR_Card* addCardPreset_UpDown(TR_Page *page_h, const String card_title, const String field_name, const String down_cmd, const String up_cmd);
virtual void addButtons_presetUpDown(TR_Card *card_h, const String field_name, const String down_cmd, const String up_cmd);
// here is a multi channel version of the up-down button display
virtual TR_Card* addCardPreset_UpDown_multiChan(TR_Page *page_h, const String card_title, const String field_name, const String down_cmd, const String up_cmd, int n_chan);
virtual void addButtons_presetUpDown_multiChan(TR_Card *card_h, const String field_name, const String down_cmd, const String up_cmd, int n_chan);
//Method to update the text associated the "button" used to display a parameter's values. This updates
//the button that was named by the convention used by "addCardPreset_UpDown()" so it pairs nicely with
//buttons created by that method.
virtual void updateCardPreset_UpDown(const String field_name,const String new_text);
virtual void updateCardPreset_UpDown(const String field_name,const String new_text, int Ichan);
//attach the SerialManager
virtual void setSerialManager(SerialManagerBase *_sm);
virtual SerialManagerBase *getSerialManager(void);
//useful value
const int capOffset = 65 - 97; //given lower case, add this value to get the upper case
//adjust the prefix characters
virtual char get_prefix_globalChar(void) { return prefix_globalChar; };
virtual char set_prefix_globalChar(char c) { prefix_globalChar = c; return get_prefix_globalChar(); }
protected:
char ID_char; //initialized in constructor.
char ID_char_fn; //initialized in constructor. this normally the same as ID_char, but can be made different if you want to overwrite someone else's fieldnames in the GUI widgets
static char quadchar_start_char; //see SerialManager_UI.cpp for where it gets initialized
SerialManagerBase *sm = NULL;
virtual void setButtonState(String btnId, bool newState, bool sendNow = true);
virtual void setButtonText(String btnId, String text);
virtual void sendTxBuffer(void);
char prefix_globalChar = 'x'; //by default, this character is used as the "channel" character. For most of your Audio classes, this won't matter at all.
#define SERIALUI_N_CHARMAP (10+26+1)
const int n_charMap = SERIALUI_N_CHARMAP;
char charMapUp[SERIALUI_N_CHARMAP] = "0123456789abcdefghijklmnopqrstuvwxyz"; //characters for raising
char charMapDown[SERIALUI_N_CHARMAP] = ")!@#$%^&*(ABCDEFGHIJKLMNOPQRSTUVWXYZ"; //characters for lowering
private:
static char next_ID_char; //see SerialManager_UI.cpp for where it gets initialized
};
#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"
@interface DVTByteBuffer : NSObject
{
char *_bytes;
unsigned long long _capacity;
unsigned long long _length;
unsigned long long _position;
BOOL _ownsBytes;
BOOL _isClosed;
}
- (void)printf:(const char *)arg1;
- (void)printf:(const char *)arg1 arguments:(struct __va_list_tag [1])arg2;
- (void)writePropertyList:(id)arg1;
- (void)writeUnsignedAsciiInteger:(unsigned long long)arg1;
- (void)writeString:(id)arg1;
- (void)writeUTF8String:(const char *)arg1;
- (void)writeLEB128:(long long)arg1;
- (void)writeUnsignedLEB128:(unsigned long long)arg1;
- (void)writeInt64:(long long)arg1;
- (void)writeUnsignedInt64:(unsigned long long)arg1;
- (void)writeInt32:(int)arg1;
- (void)writeUnsignedInt32:(unsigned int)arg1;
- (void)writeInt16:(short)arg1;
- (void)writeUnsignedInt16:(unsigned short)arg1;
- (void)writeInt8:(BOOL)arg1;
- (void)writeUnsignedInt8:(unsigned char)arg1;
- (unsigned long long)readHexBytes:(void *)arg1 length:(unsigned long long)arg2;
- (unsigned long long)writeHexBytes:(const void *)arg1 length:(unsigned long long)arg2;
- (unsigned long long)writeBytes:(const void *)arg1 length:(unsigned long long)arg2;
- (void)writeByte:(unsigned char)arg1;
- (id)readPropertyList;
- (unsigned long long)readUnsignedAsciiInteger;
- (unsigned long long)peekUTF8StringLength;
- (id)readString;
- (id)readUTF8String;
- (long long)readLEB128;
- (unsigned long long)readUnsignedLEB128;
- (long long)readInt64;
- (unsigned long long)readUnsignedInt64;
- (int)readInt32;
- (unsigned int)readUnsignedInt32;
- (short)readInt16;
- (unsigned short)readUnsignedInt16;
- (BOOL)readInt8;
- (unsigned char)readUnsignedInt8;
- (unsigned long long)readBytes:(void *)arg1 length:(unsigned long long)arg2;
- (unsigned char)readByte;
- (unsigned char)peekByte;
- (BOOL)isAtEnd;
- (unsigned long long)seek:(unsigned long long)arg1;
- (void)setPosition:(unsigned long long)arg1;
- (unsigned long long)position;
- (unsigned long long)length;
- (const char *)bytes;
- (BOOL)isClosed;
- (void)close;
- (void)dealloc;
- (id)init;
- (id)initWithCapacity:(unsigned long long)arg1;
- (id)initWithBytesNoCopy:(void *)arg1 length:(unsigned long long)arg2;
- (id)initWithBytes:(const void *)arg1 length:(unsigned long long)arg2;
- (id)initWithBytesNoCopy:(char *)arg1 length:(unsigned long long)arg2 capacity:(unsigned long long)arg3 ownsBytes:(unsigned long long)arg4;
@end
|
//
// TorBar.h
// TorBarExample
//
#import <Foundation/Foundation.h>
#import <TorServerKit/TorServerKit.h>
#import <SystemInfoKit/SystemInfoKit.h>
#import "NetworkMonitor.h"
@interface TorBar : NSObject
@property (strong) NSStatusItem *statusItem;
@property (strong) NSMenu *menu;
@property (strong) NSMenuItem *launchMenuItem;
//@property (strong) NSImage *menuIcon;
@property (strong) TorProcess *torProcess;
@property (strong) SINetworkMonitor *networkMonitor;
@property (strong) NSTimer *updateTimer;
@property (strong) NSMenuItem *toggleMenuItem;
//@property (strong) NSMenuItem *statusMenuItem;
@end
|
#pragma once
#include <stdint.h>
#include <memory>
#include "league.h"
namespace tippbot
{
namespace model
{
class Matchday
{
public:
Matchday(League *league, uint16_t day, uint16_t year) : id_(0), league_(league), day_(day), year_(year)
{
}
inline League *league() const { return this->league_; }
inline uint16_t id() const { return id_; }
inline uint16_t day() const { return this->day_; }
inline uint16_t year() const { return this->year_; }
inline void setId(uint16_t id) { id_ = id; }
inline void setDay(uint16_t day) { day_ = day; }
inline void setYear(uint16_t year) { year_ = year; }
private:
uint16_t id_;
League *league_;
uint16_t day_;
uint16_t year_;
};
}
}
namespace std
{
template <>
struct hash<tippbot::model::Matchday*>
{
size_t operator()(tippbot::model::Matchday* m) const
{
return ((hash<tippbot::model::League*>()(m->league())
^ (hash<int>()(m->day()) << 1)) >> 1)
^ (hash<int>()(m->year()) << 1);
}
};
} |
/* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE789_Uncontrolled_Mem_Alloc__malloc_wchar_t_connect_socket_22b.c
Label Definition File: CWE789_Uncontrolled_Mem_Alloc__malloc.label.xml
Template File: sources-sinks-22b.tmpl.c
*/
/*
* @description
* CWE: 789 Uncontrolled Memory Allocation
* BadSource: connect_socket Read data using a connect socket (client side)
* GoodSource: Small number greater than zero
* Sinks:
* GoodSink: Allocate memory with malloc() and check the size of the memory to be allocated
* BadSink : Allocate memory with malloc(), but incorrectly check the size of the memory to be allocated
* Flow Variant: 22 Control flow: Flow controlled by value of a global variable. Sink functions are in a separate file from sources.
*
* */
#include "std_testcase.h"
#ifndef _WIN32
#include <wchar.h>
#endif
#define HELLO_STRING L"hello"
#ifndef OMITBAD
/* The global variable below is used to drive control flow in the sink function */
extern int CWE789_Uncontrolled_Mem_Alloc__malloc_wchar_t_connect_socket_22_badGlobal;
void CWE789_Uncontrolled_Mem_Alloc__malloc_wchar_t_connect_socket_22_badSink(size_t data)
{
if(CWE789_Uncontrolled_Mem_Alloc__malloc_wchar_t_connect_socket_22_badGlobal)
{
{
wchar_t * myString;
/* POTENTIAL FLAW: No MAXIMUM limitation for memory allocation, but ensure data is large enough
* for the wcscpy() function to not cause a buffer overflow */
/* INCIDENTAL FLAW: The source could cause a type overrun in data or in the memory allocation */
if (data > wcslen(HELLO_STRING))
{
myString = (wchar_t *)malloc(data*sizeof(wchar_t));
/* Copy a small string into myString */
wcscpy(myString, HELLO_STRING);
printWLine(myString);
free(myString);
}
else
{
printLine("Input is less than the length of the source string");
}
}
}
}
#endif /* OMITBAD */
#ifndef OMITGOOD
/* The global variables below are used to drive control flow in the sink functions. */
extern int CWE789_Uncontrolled_Mem_Alloc__malloc_wchar_t_connect_socket_22_goodB2G1Global;
extern int CWE789_Uncontrolled_Mem_Alloc__malloc_wchar_t_connect_socket_22_goodB2G2Global;
extern int CWE789_Uncontrolled_Mem_Alloc__malloc_wchar_t_connect_socket_22_goodG2BGlobal;
/* goodB2G1() - use badsource and goodsink by setting the static variable to false instead of true */
void CWE789_Uncontrolled_Mem_Alloc__malloc_wchar_t_connect_socket_22_goodB2G1Sink(size_t data)
{
if(CWE789_Uncontrolled_Mem_Alloc__malloc_wchar_t_connect_socket_22_goodB2G1Global)
{
/* INCIDENTAL: CWE 561 Dead Code, the code below will never run */
printLine("Benign, fixed string");
}
else
{
{
wchar_t * myString;
/* FIX: Include a MAXIMUM limitation for memory allocation and a check to ensure data is large enough
* for the wcscpy() function to not cause a buffer overflow */
/* INCIDENTAL FLAW: The source could cause a type overrun in data or in the memory allocation */
if (data > wcslen(HELLO_STRING) && data < 100)
{
myString = (wchar_t *)malloc(data*sizeof(wchar_t));
/* Copy a small string into myString */
wcscpy(myString, HELLO_STRING);
printWLine(myString);
free(myString);
}
else
{
printLine("Input is less than the length of the source string or too large");
}
}
}
}
/* goodB2G2() - use badsource and goodsink by reversing the blocks in the if in the sink function */
void CWE789_Uncontrolled_Mem_Alloc__malloc_wchar_t_connect_socket_22_goodB2G2Sink(size_t data)
{
if(CWE789_Uncontrolled_Mem_Alloc__malloc_wchar_t_connect_socket_22_goodB2G2Global)
{
{
wchar_t * myString;
/* FIX: Include a MAXIMUM limitation for memory allocation and a check to ensure data is large enough
* for the wcscpy() function to not cause a buffer overflow */
/* INCIDENTAL FLAW: The source could cause a type overrun in data or in the memory allocation */
if (data > wcslen(HELLO_STRING) && data < 100)
{
myString = (wchar_t *)malloc(data*sizeof(wchar_t));
/* Copy a small string into myString */
wcscpy(myString, HELLO_STRING);
printWLine(myString);
free(myString);
}
else
{
printLine("Input is less than the length of the source string or too large");
}
}
}
}
/* goodG2B() - use goodsource and badsink */
void CWE789_Uncontrolled_Mem_Alloc__malloc_wchar_t_connect_socket_22_goodG2BSink(size_t data)
{
if(CWE789_Uncontrolled_Mem_Alloc__malloc_wchar_t_connect_socket_22_goodG2BGlobal)
{
{
wchar_t * myString;
/* POTENTIAL FLAW: No MAXIMUM limitation for memory allocation, but ensure data is large enough
* for the wcscpy() function to not cause a buffer overflow */
/* INCIDENTAL FLAW: The source could cause a type overrun in data or in the memory allocation */
if (data > wcslen(HELLO_STRING))
{
myString = (wchar_t *)malloc(data*sizeof(wchar_t));
/* Copy a small string into myString */
wcscpy(myString, HELLO_STRING);
printWLine(myString);
free(myString);
}
else
{
printLine("Input is less than the length of the source string");
}
}
}
}
#endif /* OMITGOOD */
|
#include <sys/time.h>
#include <sys/resource.h>
#define NumSearchPoints 5
#define FoundGoal 5
#define NumSearchPasses 2
#define Pass1 0
#define Pass2 1
#define DepthFirst 1
#define BreadthFirst 2
#define BranchAndBound 3
#define AveragePathCost 4
#define BestFirst 5
#define AStar 6
#define SQDIST(a,b,d)\
{\
int Xa,Ya,Xb,Yb;\
Ya = a/width;\
Xa = a - Ya*width;\
Yb = b/width;\
Xb = b - Yb*width;\
Xb = Xa-Xb;\
Yb = Ya-Yb;\
d = (int)sqrt((float)(Xb*Xb + Yb*Yb));\
}
typedef struct tree_struct
{
int point;
struct tree_struct *parent;
struct tree_struct *leaves;
struct tree_struct *next[NumSearchPoints];
int path_length;
int path_arc_cost;
int node_distance;
int node_arc_cost;
int goal_distance;
int depth ;
int direction;
}TREE;
typedef struct next_point_struct
{
int point;
int distance;
}NEXTPOINT;
#define LIST EDGE_LIST
/* macro to take a node from the fringe list, while still remaining in the tree */
/* used in search2goal.c */
#define RemoveFromLeavesList(list, member)\
{TREE *last, *ptr;\
last = list;\
ptr = list;\
while(ptr != NULL)\
{\
if(ptr->point == member->point)\
{\
if(ptr == ptr->leaves)\
{list = NULL;}\
else\
{\
if(ptr == list)\
list = list->leaves;\
else\
last->leaves = ptr->leaves;\
}\
break;\
}\
last = ptr;\
ptr = ptr->leaves;\
}}
#define AddToSearchedList(slist,member)\
member->leaves = slist;\
slist = member;\
candidates[slist->point] = AlreadySearched;
|
#pragma once
#include "Actor/Material/SurfaceMaterial.h"
#include "Math/math_fwd.h"
#include "FileIO/SDL/TCommandInterface.h"
#include "Actor/Image/Image.h"
#include "FileIO/FileSystem/Path.h"
#include <memory>
#include <vector>
namespace ph
{
class ThinFilm : public SurfaceMaterial, public TCommandInterface<ThinFilm>
{
public:
ThinFilm();
void genSurface(CookingContext& context, SurfaceBehavior& behavior) const override;
private:
std::vector<real> m_wavelengthTable;
std::vector<real> m_reflectanceTable;
std::vector<real> m_transmittanceTable;
// command interface
public:
explicit ThinFilm(const InputPacket& packet);
static SdlTypeInfo ciTypeInfo();
static void ciRegister(CommandRegister& cmdRegister);
};
}// end namespace ph
|
/******************************************************************************
* Spine Runtime Software License - Version 1.1
*
* Copyright (c) 2013, Esoteric Software
* All rights reserved.
*
* Redistribution and use in source and binary forms in whole or in part, with
* or without modification, are permitted provided that the following conditions
* are met:
*
* 1. A Spine Essential, Professional, Enterprise, or Education License must
* be purchased from Esoteric Software and the license must remain valid:
* http://esotericsoftware.com/
* 2. Redistributions of source code must retain this license, which is the
* above copyright notice, this declaration of conditions and the following
* disclaimer.
* 3. Redistributions in binary form must reproduce this license, which is the
* above copyright notice, this declaration of conditions and the following
* disclaimer, in the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifndef SPINE_SKELETONDATA_H_
#define SPINE_SKELETONDATA_H_
#include <BoneData.h>
#include <SlotData.h>
#include <Skin.h>
#include <EventData.h>
#include <Animation.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
int boneCount;
spBoneData** bones;
int slotCount;
spSlotData** slots;
int skinCount;
spSkin** skins;
spSkin* defaultSkin;
int eventCount;
spEventData** events;
int animationCount;
spAnimation** animations;
} spSkeletonData;
spSkeletonData* spSkeletonData_create ();
void spSkeletonData_dispose (spSkeletonData* self);
spBoneData* spSkeletonData_findBone (const spSkeletonData* self, const char* boneName);
int spSkeletonData_findBoneIndex (const spSkeletonData* self, const char* boneName);
spSlotData* spSkeletonData_findSlot (const spSkeletonData* self, const char* slotName);
int spSkeletonData_findSlotIndex (const spSkeletonData* self, const char* slotName);
spSkin* spSkeletonData_findSkin (const spSkeletonData* self, const char* skinName);
spEventData* spSkeletonData_findEvent (const spSkeletonData* self, const char* eventName);
spAnimation* spSkeletonData_findAnimation (const spSkeletonData* self, const char* animationName);
#ifdef SPINE_SHORT_NAMES
typedef spSkeletonData SkeletonData;
#define SkeletonData_create(...) spSkeletonData_create(__VA_ARGS__)
#define SkeletonData_dispose(...) spSkeletonData_dispose(__VA_ARGS__)
#define SkeletonData_findBone(...) spSkeletonData_findBone(__VA_ARGS__)
#define SkeletonData_findBoneIndex(...) spSkeletonData_findBoneIndex(__VA_ARGS__)
#define SkeletonData_findSlot(...) spSkeletonData_findSlot(__VA_ARGS__)
#define SkeletonData_findSlotIndex(...) spSkeletonData_findSlotIndex(__VA_ARGS__)
#define SkeletonData_findSkin(...) spSkeletonData_findSkin(__VA_ARGS__)
#define SkeletonData_findEvent(...) spSkeletonData_findEvent(__VA_ARGS__)
#define SkeletonData_findAnimation(...) spSkeletonData_findAnimation(__VA_ARGS__)
#endif
#ifdef __cplusplus
}
#endif
#endif /* SPINE_SKELETONDATA_H_ */
|
/* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved.
*
* The information contained herein is property of Nordic Semiconductor ASA.
* Terms and conditions of usage are described in detail in NORDIC
* SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
*
* Licensees are granted free, non-transferable use of the information. NO
* WARRANTY of ANY KIND is provided. This heading must NOT be removed from
* the file.
*
*/
/**@file
*
* @defgroup ant_stack_handler_types Types definitions for ANT support in SoftDevice handler.
* @{
* @ingroup app_common
* @brief This file contains the declarations of types required for ANT stack support. These
* types will be defined when the preprocessor define ANT_STACK_SUPPORT_REQD is defined.
*/
#ifndef ANT_STACK_HANDLER_TYPES_H__
#define ANT_STACK_HANDLER_TYPES_H__
#ifdef ANT_STACK_SUPPORT_REQD
#include <stdlib.h>
#define ANT_STACK_EVT_MSG_BUF_SIZE 32 /**< Size of ANT event message buffer. This will be provided to the SoftDevice while fetching an event. */
#define ANT_STACK_EVT_STRUCT_SIZE (sizeof(ant_evt_t)) /**< Size of the @ref ant_evt_t structure. This will be used by the @ref softdevice_handler.h to internal event buffer size needed. */
/**@brief ANT stack event type. */
typedef struct
{
uint8_t channel; /**< Channel number. */
uint8_t event; /**< Event code. */
uint8_t evt_buffer[ANT_STACK_EVT_MSG_BUF_SIZE]; /**< Event message buffer. */
} ant_evt_t;
/**@brief Application ANT stack event handler type. */
typedef void (*ant_evt_handler_t) (ant_evt_t * p_ant_evt);
/**@brief Function for registering for ANT events.
*
* @details The application should use this function to register for receiving ANT events from
* the SoftDevice. If the application does not call this function, then any ANT event
* that may be generated by the SoftDevice will NOT be fetched. Once the application has
* registered for the events, it is not possible to possible to cancel the registration.
* However, it is possible to register a different function for handling the events at
* any point of time.
*
* @param[in] ant_evt_handler Function to be called for each received ANT event.
*
* @retval NRF_SUCCESS Successful registration.
* @retval NRF_ERROR_NULL Null pointer provided as input.
*/
uint32_t softdevice_ant_evt_handler_set(ant_evt_handler_t ant_evt_handler);
#else
// The ANT Stack support is not required.
#define ANT_STACK_EVT_STRUCT_SIZE 0 /**< Since the ANT stack support is not required, this is equated to 0, so that the @ref softdevice_handler.h can compute the internal event buffer size without having to care for ANT events.*/
#endif // ANT_STACK_SUPPORT_REQD
#endif // ANT_STACK_HANDLER_TYPES_H__
/** @} */
|
#include <stdio.h>
int main()
{
int a,b;
scanf("%d %d",&a, &b);
printf("%d\n",a+b);
return 0;
}
|
#pragma once
#include <vector>
#include <bitset>
#include <iostream>
void test(void);
class CPPGroup
{
public:
std::vector<short> gvec;
int size_;
//std::bitset<4096> _inset;
CPPGroup() :
size_(0)
///_inset(4096)
{
gvec.reserve(10);
}
~CPPGroup() {
//std::cout << "this group was " << size_ << "elements" << std::endl;
}
int contains(int x ) {
for(int i = 0; i < gvec.size(); ++i) {
if (x == gvec[i]) {
return true;
}
}
return false;
//return _inset.test(x);
}
void insert(int x) {
if(!contains(x)) {
gvec.push_back(x);
size_++;
//_inset.set(x);// = 1;
}
}
};
|
/*
* Copyright (c) 2008, Willow Garage, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the Willow Garage, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef OGRE_TOOLS_GRID_H
#define OGRE_TOOLS_GRID_H
#include <stdint.h>
#include <vector>
#include <OGRE/OgreColourValue.h>
#include <OGRE/OgreMaterial.h>
namespace Ogre
{
class SceneManager;
class ManualObject;
class SceneNode;
class Any;
}
namespace rviz
{
class BillboardLine;
/**
* \class Grid
* \brief Displays a grid of cells, drawn with lines
*
* Displays a grid of cells, drawn with lines. A grid with an identity orientation is drawn along the XZ plane.
*/
class Grid
{
public:
enum Style
{
Lines,
Billboards,
};
/**
* \brief Constructor
*
* @param manager The scene manager this object is part of
* @param cell_count The number of cells to draw
* @param cell_length The size of each cell
* @param r Red color component, in the range [0, 1]
* @param g Green color component, in the range [0, 1]
* @param b Blue color component, in the range [0, 1]
*/
Grid( Ogre::SceneManager* manager, Ogre::SceneNode* parent_node, Style style, uint32_t cell_count, float cell_length, float line_width, const Ogre::ColourValue& color );
~Grid();
void create();
/**
* \brief Get the Ogre scene node associated with this grid
*
* @return The Ogre scene node associated with this grid
*/
Ogre::SceneNode* getSceneNode() { return scene_node_; }
/**
* \brief Sets user data on all ogre objects we own
*/
void setUserData( const Ogre::Any& data );
void setStyle(Style style);
Style getStyle() { return style_; }
void setColor(const Ogre::ColourValue& color);
Ogre::ColourValue getColor() { return color_; }
void setCellCount(uint32_t count);
float getCellCount() { return cell_count_; }
void setCellLength(float len);
float getCellLength() { return cell_length_; }
void setLineWidth(float width);
float getLineWidth() { return line_width_; }
void setHeight(uint32_t count);
uint32_t getHeight() { return height_; }
private:
Ogre::SceneManager* scene_manager_;
Ogre::SceneNode* scene_node_; ///< The scene node that this grid is attached to
Ogre::ManualObject* manual_object_; ///< The manual object used to draw the grid
BillboardLine* billboard_line_;
Ogre::MaterialPtr material_;
Style style_;
uint32_t cell_count_;
float cell_length_;
float line_width_;
uint32_t height_;
Ogre::ColourValue color_;
};
} // namespace rviz
#endif
|
/*************************************************************************
*** FORTE Library Element
***
*** This file was generated using the 4DIAC FORTE Export Filter V1.0.x!
***
*** Name: F_TIME_TO_BYTE
*** Description: convert TIME to BYTE
*** Version:
*** 0.0: 2013-08-29/4DIAC-IDE - 4DIAC-Consortium - null
*************************************************************************/
#ifndef _F_TIME_TO_BYTE_H_
#define _F_TIME_TO_BYTE_H_
#include <funcbloc.h>
#include <forte_time.h>
#include <forte_byte.h>
class FORTE_F_TIME_TO_BYTE: public CFunctionBlock{
DECLARE_FIRMWARE_FB(FORTE_F_TIME_TO_BYTE)
private:
static const CStringDictionary::TStringId scm_anDataInputNames[];
static const CStringDictionary::TStringId scm_anDataInputTypeIds[];
CIEC_TIME &IN() {
return *static_cast<CIEC_TIME*>(getDI(0));
};
static const CStringDictionary::TStringId scm_anDataOutputNames[];
static const CStringDictionary::TStringId scm_anDataOutputTypeIds[];
CIEC_BYTE &OUT() {
return *static_cast<CIEC_BYTE*>(getDO(0));
};
static const TEventID scm_nEventREQID = 0;
static const TForteInt16 scm_anEIWithIndexes[];
static const TDataIOID scm_anEIWith[];
static const CStringDictionary::TStringId scm_anEventInputNames[];
static const TEventID scm_nEventCNFID = 0;
static const TForteInt16 scm_anEOWithIndexes[];
static const TDataIOID scm_anEOWith[];
static const CStringDictionary::TStringId scm_anEventOutputNames[];
static const SFBInterfaceSpec scm_stFBInterfaceSpec;
FORTE_FB_DATA_ARRAY(1, 1, 1, 0);
void executeEvent(int pa_nEIID);
public:
FUNCTION_BLOCK_CTOR(FORTE_F_TIME_TO_BYTE){
};
virtual ~FORTE_F_TIME_TO_BYTE(){};
};
#endif //close the ifdef sequence from the beginning of the file
|
#pragma once
#include "DDEClientConversation.h"
/**
* DDE Client Transaction Manager.
*
* @author Alexander Kozlov (alex@pretty-tools.com)
*/
class DDEClientTransactionManager
{
private:
WJNIEnv m_env;
DWORD m_idInst;
CAtlMap<HCONV, DDEClientConversation*> m_mapHConvToDDEClient;
public:
DDEClientTransactionManager(void);
~DDEClientTransactionManager(void);
bool Initialize();
void Uninitialize();
void Connect(DDEClientConversation* pConversation) throw (...);
void Disconnect(DDEClientConversation* pConversation) throw (...);
void Execute(DDEClientConversation* pConversation, const CString &strCommand) throw (...);
void Execute(DDEClientConversation* pConversation, const CSimpleArray<BYTE> &arCommand) throw (...);
void Poke(DDEClientConversation* pConversation, const CString &strItem, const CString &strData) throw (...);
void Poke(DDEClientConversation* pConversation, const CString &strItem, const CSimpleArray<BYTE> &arData, UINT wFmt) throw (...);
CString Request(DDEClientConversation* pConversation, const CString &strItem) throw (...);
void StartAdvice(DDEClientConversation* pConversation, const CString &strItem) throw (...);
void StopAdvice(DDEClientConversation* pConversation, const CString &strItem) throw (...);
public:
void SetWJNIEnv(WJNIEnv env)
{
m_env = env;
}
HDDEDATA DdeClientCallback( UINT uType,
UINT uFmt,
HCONV hconv,
HDDEDATA hsz1,
HDDEDATA hsz2,
HDDEDATA hdata,
HDDEDATA dwData1,
HDDEDATA dwData2
);
};
|
#include "misc.h"
char errbuf[200];
char *progname;
int wantwarn = 0;
int dbg = 0;
// dbg = 1 : dump slugs
// dbg = 2 : dump ranges
// dbg = 4 : report function entry
// dbg = 8 : follow queue progress
// dbg = 16: follow page fill progress
|
/*******************************************************************************
* Copyright (c) 2012 4DIAC - consortium.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*******************************************************************************/
#ifndef _GEN_APPEND_STRING_H_
#define _GEN_APPEND_STRING_H_
#include <funcbloc.h>
#include <forte_any.h>
#include <forte_array.h>
class GEN_APPEND_STRING : public CFunctionBlock{
DECLARE_GENERIC_FIRMWARE_FB(GEN_APPEND_STRING)
private:
//we know for sure that there is one output event and one input event
static const TEventID scm_nEventCNFID = 0;
static const CStringDictionary::TStringId scm_anEventOutputNames[];
static const TEventID scm_nEventREQID = 0;
static const CStringDictionary::TStringId scm_anEventInputNames[];
CStringDictionary::TStringId *m_anDataInputNames;
CStringDictionary::TStringId *m_anDataInputTypeIds;
static const CStringDictionary::TStringId scm_anDataOutputNames[];
static const CStringDictionary::TStringId scm_anDataOutputTypeIds[];
static const TForteInt16 scm_anEIWithIndexes[];
TDataIOID *m_anEIWith;
static const TForteInt16 scm_anEOWithIndexes[];
static const TDataIOID scm_anEOWith[];
//maximum string buffer size for conversions into string values
static const TForteInt16 scm_maxStringBufSize;
//self-defined members
int m_nDInputs;
CStringDictionary::TStringId m_nConfiguredFBTypeNameId;
virtual void executeEvent(int pa_nEIID);
GEN_APPEND_STRING(const CStringDictionary::TStringId pa_nInstanceNameId, CResource *pa_poSrcRes);
virtual ~GEN_APPEND_STRING();
public:
CStringDictionary::TStringId getFBTypeId(void) const{
return m_nConfiguredFBTypeNameId;
}
bool configureFB(const char *pa_acConfigString);
};
#endif //close the ifdef sequence from the beginning of the file
|
/*
* Android File Transfer for Linux: MTP client for android devices
* Copyright (C) 2015 Vladimir Menshakov
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef MTP_EXCEPTION_H
#define MTP_EXCEPTION_H
#include <stdexcept>
namespace mtp { namespace usb
{
class Exception : public std::runtime_error
{
public:
Exception(const std::string &what) throw();
Exception(const std::string &what, int retCode) throw();
static std::string GetErrorMessage(int retCode);
};
}}
#endif
|
/*
* Copyright (c) 2002, Intel Corporation. All rights reserved.
* Created by: julie.n.fleischer REMOVE-THIS AT intel DOT com
* This file is licensed under the GPL license. For the full content
* of this license, see the COPYING file at the top level of this
* source tree.
*
* Test to see if timer_settime() sets errno = EINVAL when timerid =
* a timer ID of a deleted timer. Since this is a "may" assertion, either
* way is a pass.
*
* For this test, signal SIGTOTEST will be used.
* Clock CLOCK_REALTIME will be used.
*/
#include <time.h>
#include <signal.h>
#include <stdio.h>
#include <errno.h>
#include "posixtest.h"
#define SIGTOTEST SIGALRM
int main(int argc, char *argv[])
{
struct sigevent ev;
timer_t tid;
struct itimerspec its;
its.it_interval.tv_sec = 0;
its.it_interval.tv_nsec = 0;
its.it_value.tv_sec = 0;
its.it_value.tv_nsec = 0;
ev.sigev_notify = SIGEV_SIGNAL;
ev.sigev_signo = SIGTOTEST;
if (timer_create(CLOCK_REALTIME, &ev, &tid) != 0) {
perror("timer_create() did not return success\n");
return PTS_UNRESOLVED;
}
if (timer_delete(tid) != 0) {
perror("timer_delete() did not return success\n");
return PTS_UNRESOLVED;
}
if (timer_settime(tid, 0, &its, NULL) == -1) {
if (EINVAL == errno) {
printf("fcn returned -1 and errno==EINVAL\n");
return PTS_PASS;
} else {
printf("fcn returned -1 but errno!=EINVAL\n");
printf("Test FAILED\n");
return PTS_FAIL;
}
}
printf("fcn did not return -1\n");
return PTS_PASS;
}
|
#ifndef REGION_H
# define REGION_H
# include <kernel/types.h>
# include <kernel/klist.h>
# include <kernel/mem/as.h>
struct region
{
vaddr_t base;
uint32_t page_size;
int mapped;
struct klist list;
};
/*
* Initialize region inside an address space
*/
void region_initialize(struct as *as);
/*
* Reserve a region inside an address space
*
* if addr == 0 it just try to locate a region with size = page_size
*
* Return the address at the beginning of the region, 0 if it fails
*/
vaddr_t region_reserve(struct as *as, vaddr_t addr, size_t page_size);
/*
* Release a region inside an address space
*/
void region_release(struct as *as, vaddr_t addr);
/*
* Dump region in a specified address space
*/
void region_dump(struct as *as);
#endif /* !REGION_H */
|
/* $Id$ */
/*© copyright 1991-96 UserLand Software, Inc. All Rights Reserved.*/
#include <ioa.h>
#include <appletstrings.h>
#define textvertinset 2
static boolean cleangizmo (hdlobject h, short height, short width, Rect *r) {
hdlcard hc = (**h).owningcard;
short gridunits = (**hc).gridunits;
width = IOAmakemultiple (width + 6, gridunits);
width = max (width, 60); /*apply minimum button width*/
(*r).right = (*r).left + width;
if (((**h).objectfont == systemFont) && ((**h).objectfontsize == 12))
(*r).bottom = (*r).top + height;
else
(*r).bottom = (*r).top + IOAmakemultiple (height - (2 * textvertinset) + 6, gridunits);
return (true);
} /*cleangizmo*/
static boolean canreplicategizmo (hdlobject h) {
return (true); /*it can be replicated*/
} /*canreplicategizmo*/
static boolean getgizmoeditrect (hdlobject h, Rect *r) {
short height, width, extrapixels, offtop;
*r = (**h).objectrect;
IOAgetobjectsize (h, &height, &width);
extrapixels = ((*r).bottom - (*r).top) - height;
offtop = extrapixels / 2;
(*r).top += offtop;
(*r).bottom -= extrapixels - offtop;
return (true); /*can be edited*/
} /*getgizmoeditrect*/
static boolean getgizmovalue (hdlobject h, Handle *hvalue) {
return (IOAgetstringvalue (h, hvalue));
} /*getgizmovalue*/
static boolean debuggizmo (hdlobject h, bigstring errorstring) {
setstringlength (errorstring, 0);
return (true);
} /*debuggizmo*/
static boolean drawgizmo (hdlobject h) {
/*
DW 8/15/93: commented the pushing of the frame color before drawing
the gizmo outline. use the text color as set by the shell. makes
disabled gizmos look right.
*/
hdlcard hc = (**h).owningcard;
Rect routset;
Rect r;
boolean flbold;
Handle htext;
htext = (**h).objectvalue;
r = (**h).objectrect;
flbold = (**h).objectflag;
if (!(**h).objecttransparent)
EraseRect (&r);
routset = r;
if (flbold)
InsetRect (&routset, -4, -4);
if (!(**hc).flskiptext) {
Rect redit;
getgizmoeditrect (h, &redit);
IOAeditdrawtexthandle (htext, redit, (**h).objectjustification);
}
/*IOApushforecolor (&(**h).objectframecolor);*/
FrameRect (&r); /*must be after text drawing, 4/27/92 DW*/
if (flbold) {
PenState x;
GetPenState (&x); /*save the old pen state*/
PenSize (3, 3); /*make the pen fatter*/
FrameRect (&routset); /*draw the ring*/
SetPenState (&x); /*restore the pen state*/
}
/*IOApopforecolor ();*/
if ((**hc).tracking && (**hc).trackerpressed) {
Rect rinvert = r;
InsetRect (&rinvert, 1, 1);
InvertRect (&rinvert);
}
return (true);
} /*drawgizmo*/
static boolean flbold;
static boolean initgizmovisit (hdlobject h) {
if ((**h).objectflag) {
flbold = false; /*already is a bold gizmo*/
return (false); /*stop the traversal*/
}
return (true); /*keep looking*/
} /*initgizmovisit*/
static boolean initgizmo (tyobject *obj) {
hdlcard hc = (*obj).owningcard;
flbold = true;
IOAvisitobjects ((**hc).objectlist, &initgizmovisit);
(*obj).objectflag = flbold;
(*obj).objectjustification = centerjustified;
return (true); /*we do want to edit it*/
} /*initgizmo*/
static boolean getgizmoinvalrect (hdlobject h, Rect *r) {
*r = (**h).objectrect;
if ((**h).objectflag)
InsetRect (r, -4, -4);
return (true);
} /*getgizmoinvalrect*/
static boolean recalcgizmo (hdlobject h, boolean flmajorrecalc) {
bigstring errorstring;
Handle hvalue;
if (!IOAevalscript (h, (**h).objectrecalcscript, &hvalue, (**h).objectlanguage, errorstring))
return (false);
IOAsetobjectvalue (h, hvalue);
IOAinvalobject (h);
return (true);
} /*recalcgizmo*/
static boolean clickgizmo (hdlobject listhead, hdlobject h, Point pt, boolean flshiftkey, boolean fl2click) {
bigstring bs;
bigstring num;
Handle hvalue;
IOAcopystring ("\phit at (", bs);
NumToString (pt.h, num);
IOApushstring (num, bs);
IOApushstring ("\p, ", bs);
NumToString (pt.v, num);
IOApushstring (num, bs);
IOApushstring ("\p)", bs);
IOAnewtexthandle (bs, &hvalue);
IOAsetobjectvalue (h, hvalue);
DisposeHandle (hvalue);
return (true); /*do a minor recalc*/
} /*clickgizmo*/
static boolean catchreturngizmo (hdlobject h) {
return ((**h).objectflag); /*if the gizmo is bold, we want the Return key*/
} /*catchreturngizmo*/
void setupgizmo (tyconfigrecord *config);
void setupgizmo (tyconfigrecord *config) {
IOAcopystring ("\pGizmo", (*config).objectTypeName);
IOAcopystring ("\pGizmo Flag", (*config).objectFlagName);
(*config).objectTypeID = 101;
(*config).frameWhenEditing = false;
(*config).canEditValue = true;
(*config).toggleFlagWhenHit = false;
(*config).mutuallyExclusive = true;
(*config).speaksForGroup = false;
(*config).hasSpecialCard = true;
(*config).initObjectCallback = initgizmo;
(*config).drawObjectCallback = drawgizmo;
(*config).clickObjectCallback = clickgizmo;
(*config).cleanupObjectCallback = cleangizmo;
(*config).recalcObjectCallback = recalcgizmo;
(*config).canReplicateObjectCallback = canreplicategizmo;
(*config).catchReturnCallback = catchreturngizmo;
(*config).getObjectInvalRectCallback = getgizmoinvalrect;
(*config).getObjectEditRectCallback = getgizmoeditrect;
(*config).getValueForScriptCallback = getgizmovalue;
(*config).debugObjectCallback = debuggizmo;
} /*setupgizmo*/
|
#include "tree.h"
#include "gc.h"
#include "gc-internal.h"
static int gc_inhibited = 0;
static size_t alloc_array_sz = 10000;
static size_t alloc_ptr = 0;
static gc_obj *allocs = NULL;
static const int COLLECT_TREE_ALLOC = 2000;
void mark_tree(tree obj)
{
if (!obj)
return;
tree locus_file = obj->locus.file;
if (locus_file)
mark_object((gc_obj)locus_file);
mark_object((gc_obj)obj);
}
static int compare_allocs(const void *a1, const void *a2)
{
gc_obj p1 = *(gc_obj *)a1;
gc_obj p2 = *(gc_obj *)a2;
if (p1 < p2)
return 1;
else if (p1 > p2)
return -1;
else
return 0;
}
static int is_object(void *addr)
{
if (bsearch(&addr, allocs, alloc_ptr,
sizeof(*allocs), compare_allocs))
return 1;
return 0;
}
static void mark_potential_root(void *addr)
{
gc_obj obj;
if (!is_object(addr))
return;
obj = (gc_obj)addr;
mark_object(obj);
}
void *top_of_stack;
static void __attribute__((noinline)) mark_stack(void)
{
gc_obj bottom;
gc_obj *bottom_of_stack = &bottom, *ptr;
for (ptr = top_of_stack; ptr > bottom_of_stack; ptr--)
mark_potential_root(*ptr);
}
#if defined(BUILD_LINUX)
extern tree *__start_static_trees;
extern tree *__stop_static_trees;
#elif defined(BUILD_DARWIN)
extern tree *__start_static_trees __asm("section$start$__DATA$static_trees");
extern tree *__stop_static_trees __asm("section$end$__DATA$static_trees");
#else
#error "build OS"
#endif
static void mark_static(void)
{
tree **i;
for (i = &__start_static_trees; i < &__stop_static_trees; i++)
if (is_object(**i))
mark_tree(**i);
}
static void dealloc_object(gc_obj obj)
{
tree t = &obj->t;
switch (TYPE(t))
{
case T_INTEGER:
mpz_clear(tINT_VAL(t));
break;
case T_IDENTIFIER:
free(tID_STR(t));
break;
case T_STRING:
free(tSTRING_VAL(t));
break;
case E_ALLOC:
free(tALLOC_PTR(t));
break;
case T_CLOSURE:
ffi_closure_free(tCLOSURE_CLOSURE(t));
free(tCLOSURE_CIF(t));
free(tCLOSURE_TYPES(t));
break;
default:
/* All other types don't contain any other referencies to
* dynamic memory. */
break;
}
free(obj);
}
static void sweep(void)
{
size_t i;
for (i = 0; i < alloc_ptr; i++)
if (!allocs[i]->reachable) {
dealloc_object(allocs[i]);
allocs[i] = 0;
} else
allocs[i]->reachable = 0;
}
static void fixup_alloc_array()
{
qsort(allocs, alloc_ptr, sizeof(*allocs),
compare_allocs);
/* Run the alloc pointer backward to see when the first allocation
* is. */
while (alloc_ptr > 0 && !allocs[alloc_ptr])
alloc_ptr--;
alloc_ptr++;
}
static void collect(void)
{
/* This undocumented intrinsic should force all callee-saved
* registers on the stack. This will allow us to find objects
* that only have a reference kept in registers. */
__builtin_unwind_init();
fixup_alloc_array();
mark_stack();
mark_static();
sweep();
}
static void maybe_collect()
{
static int collect_counter = 0;
if (gc_inhibited)
return;
if (collect_counter++ > COLLECT_TREE_ALLOC) {
collect();
collect_counter = 0;
}
}
static void extend_allocs()
{
size_t old_alloc_array_sz = alloc_array_sz;
alloc_array_sz *= 2;
allocs = realloc(allocs, sizeof(*allocs) * alloc_array_sz);
memset(&allocs[old_alloc_array_sz], 0, old_alloc_array_sz);
}
static void track_new_alloc(gc_obj obj)
{
if (!allocs)
allocs = calloc(sizeof(obj), alloc_array_sz);
if (alloc_ptr >= alloc_array_sz)
extend_allocs();
allocs[alloc_ptr++] = obj;
}
void inhibit_gc()
{
gc_inhibited++;
}
void enable_gc()
{
if (!gc_inhibited)
return;
gc_inhibited--;
}
tree alloc_tree()
{
maybe_collect();
gc_obj ret = calloc(1, sizeof(*ret));
track_new_alloc(ret);
return &ret->t;
}
|
/* ----------------------------------------------------------------------
*
* *** Smooth Mach Dynamics ***
*
* This file is part of the USER-SMD package for LAMMPS.
* Copyright (2014) Georg C. Ganzenmueller, georg.ganzenmueller@emi.fhg.de
* Fraunhofer Ernst-Mach Institute for High-Speed Dynamics, EMI,
* Eckerstrasse 4, D-79104 Freiburg i.Br, Germany.
*
* ----------------------------------------------------------------------- */
/* -*- c++ -*- ----------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
http://lammps.sandia.gov, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
certain rights in this software. This software is distributed under
the GNU General Public License.
See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */
#ifdef FIX_CLASS
FixStyle(smd/setvelocity,FixSMDSetVel)
#else
#ifndef LMP_FIX_SMD_SET_VELOCITY_H
#define LMP_FIX_SMD_SET_VELOCITY_H
#include "fix.h"
namespace LAMMPS_NS {
class FixSMDSetVel : public Fix {
public:
FixSMDSetVel(class LAMMPS *, int, char **);
~FixSMDSetVel();
int setmask();
void init();
void setup(int);
void min_setup(int);
void initial_integrate(int);
void post_force(int);
double compute_vector(int);
double memory_usage();
private:
double xvalue,yvalue,zvalue;
int varflag,iregion;
char *xstr,*ystr,*zstr;
char *idregion;
int xvar,yvar,zvar,xstyle,ystyle,zstyle;
double foriginal[3],foriginal_all[3];
int force_flag;
int nlevels_respa;
int maxatom;
double **sforce;
};
}
#endif
#endif
/* ERROR/WARNING messages:
E: Illegal ... command
Self-explanatory. Check the input script syntax and compare to the
documentation for the command. You can use -echo screen as a
command-line option when running LAMMPS to see the offending line.
E: Region ID for fix setforce does not exist
Self-explanatory.
E: Variable name for fix setforce does not exist
Self-explanatory.
E: Variable for fix setforce is invalid style
Only equal-style variables can be used.
E: Cannot use non-zero forces in an energy minimization
Fix setforce cannot be used in this manner. Use fix addforce
instead.
*/
|
//*********************************************************************************
// Movie.h
//---------------------------------------------------------------------------------
//
//---------------------------------------------------------------------------------
// Hugo Mercier <hmercier31[at]gmail.com> (c) 2008
// Carlos Garcia Campos <carlosgc@gnome.org> (c) 2010
// Albert Astals Cid <aacid@kde.org> (c) 2017-2019
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//*********************************************************************************
#ifndef _MOVIE_H_
#define _MOVIE_H_
#include "Object.h"
struct MovieActivationParameters {
MovieActivationParameters();
~MovieActivationParameters();
// parse from a "Movie Activation" dictionary
void parseMovieActivation(const Object* aDict);
enum MovieRepeatMode {
repeatModeOnce,
repeatModeOpen,
repeatModeRepeat,
repeatModePalindrome
};
struct MovieTime {
MovieTime() { units_per_second = 0; }
unsigned long units;
int units_per_second; // 0 : defined by movie
};
MovieTime start; // 0
MovieTime duration; // 0
double rate; // 1.0
int volume; // 100
bool showControls; // false
bool synchronousPlay; // false
MovieRepeatMode repeatMode; // repeatModeOnce
// floating window position
bool floatingWindow;
double xPosition; // 0.5
double yPosition; // 0.5
int znum; // 1
int zdenum; // 1
};
class Movie {
public:
Movie(const Object *movieDict, const Object *aDict);
Movie(const Object *movieDict);
Movie(const Movie &other);
~Movie();
Movie& operator=(const Movie &) = delete;
bool isOk() const { return ok; }
const MovieActivationParameters* getActivationParameters() const { return &MA; }
const GooString* getFileName() const { return fileName; }
unsigned short getRotationAngle() const { return rotationAngle; }
void getAspect (int *widthA, int *heightA) const { *widthA = width; *heightA = height; }
Object getPoster() const { return poster.copy(); }
bool getShowPoster() const { return showPoster; }
bool getUseFloatingWindow() const { return MA.floatingWindow; }
void getFloatingWindowSize(int *width, int *height);
Movie* copy() const ;
private:
void parseMovie (const Object *movieDict);
bool ok;
unsigned short rotationAngle; // 0
int width; // Aspect
int height; // Aspect
Object poster;
bool showPoster;
GooString* fileName;
MovieActivationParameters MA;
};
#endif
|
/*
* CREATED BY Lucas Vieira Costa Nicolau - USP
* Used amoung with SDL2
* -- (good tutorial tip : SDL LAZY FOO --there's other, but this was the most
* used by me on learning)
*
* -- Open Source, Open to learn, Open to distribute.
* Just don't misrepresent my credits and time spend to make this library. Thanks.
*/
#ifndef EDITOR_MAPA_H
#define EDITOR_MAPA_H
#include "sdl_basics.h"
bool editor_mapa();
bool empty_mapa();
bool tradeImage(SDL_Surface **surface, const char *str);
SDL_Point toMatrizPosition(SDL_Point mPosition);
bool matrizToImage(SDL_Rect *offset, SDL_Surface *surface, SDL_Surface *screen);
bool load_up(SDL_Window **window, SDL_Surface **screen, SDL_Surface **img);
bool clean_up(SDL_Window **window, SDL_Surface **screen, SDL_Surface **img);
bool save_mapa();
bool save_undo();
bool save_redo();
bool load_undo();
bool load_redo();
bool load_mapa(const char *src);
void limpa_selecao();
void set_right(SDL_Point mPoint, int value);
void set_down(SDL_Point mPoint, int value);
void set_left(SDL_Point mPoint, int value);
void set_up(SDL_Point mPoint, int value);
void set_all(SDL_Point mPoint, int value);
bool external_load_map(SDL_Surface **screen);
//void retorna_valor_anterior(SDL_Point mPositionMatriz);
#endif /* EDITOR_MAPA_H */
|
#pragma once
class Money : public Item
{
public:
explicit Money(long amount) : amount_(amount) { }
virtual thisItemIs whatIsThis() const { return THIS_IS_MONEY; }
virtual Money* clone() const { return new Money(*this); }
explicit Money(const std::string& inputXml);
string showXml() const;
virtual string equip_title() const;
virtual const string& get_name() const { return get_itemtypename(); }
virtual long get_fencevalue() const { return amount_ * number_; }
virtual Money* split(int number);
virtual bool merge(Item& i);
virtual bool sort_compare_special(Item* other) const;
long get_amount() const { return amount_; }
void set_amount(long amount) { amount_ = amount; }
void add_amount(long amount) { amount_ += amount; }
void take_all_from(Money& more) { amount_ += more.amount_; more.amount_ = 0; }
void flatten() { amount_ = amount_ * number_; number_ = 1; }
private:
long amount_;
};
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.