text stringlengths 4 6.14k |
|---|
#pragma once
#include <stdio.h>
#include <stdint.h>
#include "../build.h"
#define VMHW_GPU_HWID 0x03
#define VMHW_GPU_IOPORT_BEGIN 0x9
// A,B,C,D,E,F
// vm_state
typedef struct vmhw_gpu
{
uint8_t* vm_dma;
uint16_t* m_Screen;
uint16_t* m_Framebuffer; // all operations write to this, on fb flip m_Screen = m_Framebuffer, and vice versa
uint16_t* m_Font;
uint8_t* m_Terminal;
uint16_t m_TerminalColor; // color used by the future terminal insertions
BOOL m_TerminalEnabled;
BOOL m_TransparencyMaskEnabled;
uint16_t m_TransparencyMask; // the vm will not do a draw operation with this color
} vmhw_gpu;
//extern vmhw_gpu* g_vmGpuDvc;
typedef void(*vmhw_gpu_operation_t)(vmhw_gpu* dvc, uint16_t* args);
extern vmhw_gpu_operation_t g_vmGpuOperations[0x1000]; // 0x0-0xFFF
void vmhw_gpu_init(uint16_t* io,uint8_t* dma);
void vmhw_gpu_think(uint16_t* io, uint8_t* dma);
#ifdef EMSCRIPTEN
uint16_t* EXPORT vmhw_gpu_get_screen_ptr();
#endif
|
//
// FiniteStateMachine.h
// ArDroneGameLib
//
// Created by clement choquereau on 5/4/11.
// Copyright 2011 Parrot. All rights reserved.
//
#import <Foundation/Foundation.h>
#define NO_STATE (-1)
@class FSMXMLParsing;
@interface FiniteStateMachine : NSObject <NSXMLParserDelegate>
{
id delegate;
unsigned int statesCount;
unsigned int actionsCount;
unsigned int currentState;
NSMutableDictionary *objects;
NSMutableDictionary *enterCallbacks;
NSMutableDictionary *quitCallbacks;
NSMutableDictionary *stateActions;
// should always be nil:
FSMXMLParsing *xml;
}
@property (nonatomic, retain) id delegate;
@property (readonly) id currentObject;
@property (readonly) unsigned int statesCount;
@property (readonly) unsigned int actionsCount;
@property unsigned int currentState;
/*
* You can create a FSM with a XML file:
* (For element 'state', attributes 'enter-callback', 'quit-callback' and 'object' aren't mandatory.)
*
* <?xml version="1.0"?>
* <fsm>
* <states>
* <state name="myState" enter-callback="onEnterState:" quit-callback="onQuitState:" object="aStringObject" />
* ...
* </states>
* <actions>
* <action name="myAction" />
* ...
* </actions>
* <associations>
* <association from-state="aState" action="anAction" to-state="anotherState" />
* </associations>
* </fsm>
*/
+ (id) fsm;
+ (id) fsmWithXML:(NSString *)fileName;
// Managing states:
- (unsigned int) createState;
- (void) createStates:(unsigned int)count inArray:(unsigned int *)states;
- (void) setObject:(id)object forState:(unsigned int)state;
- (void) setEnterStateCallback:(SEL)enter forState:(unsigned int)state;
- (void) setQuitStateCallback:(SEL)quit forState:(unsigned int)state;
- (unsigned int) createStateWithObject:(id)object andEnterStateCallback:(SEL)enter andQuitStateCallback:(SEL)quit;
- (void) createStates:(unsigned int)count withObjects:(id *)items andEnterStateCallbacks:(SEL *)enters andQuitStateCallbacks:(SEL *)quits inArray:(unsigned int *)states;
// Managing actions:
- (unsigned int) createAction;
- (void) createActions:(unsigned int)count inArray:(unsigned int *)actions;
// Associations:
- (void) createAssociationFromState:(unsigned int)start withAction:(unsigned int)action toState:(unsigned int)end;
- (void) createAssociationFromState:(unsigned int)start withActions:(unsigned int *)actions toStates:(unsigned int *)ends andNumAssociations:(unsigned int)count;
- (void) doAction:(unsigned int)action;
@end
|
/** @file generalvector.h
* @brief class for manipulation with vectors
*
* Defines the parent class for manipulation with vectors.
* The class is inherited from other third-party implementations, i.e. MinLin or PetscVector.
*
* @author Lukas Pospisil
*/
#ifndef PASC_GENERALVECTOR_H
#define PASC_GENERALVECTOR_H
#include "general/algebra/matrix/generalmatrixrhs.h"
#include "general/algebra/arrayoperation.h"
//#include <iostream>
#include <string>
namespace pascinference {
namespace algebra {
/** @class General_all_type
* @brief deal with vector(all)
*
* For each vector type define retype operator of our "all".
*
* @todo improve "gall", who to change it to "all"
*/
class General_all_type {
public:
#ifdef USE_PETSC
/* convert to PetscVector all */
//TODO:
// operator petscvector::petscvector_all_type() const {
// return petscvector::all;
// }
#endif
#ifdef USE_MINLIN
typedef minlin::detail::all_type *minlin_all_type;
/* convert to minlin all */
operator minlin_all_type() const {
return minlin::all;
}
#endif
};
static General_all_type gall;
/** @class GeneralVector
* @brief general vector class
*
* Extend the operations with original vector type.
* Add operator for multiplication with GeneralMatrix.
*
*/
template<class VectorBase>
class GeneralVector : public VectorBase {
public:
/** @brief call original constructor without arguments
*
*/
GeneralVector() : VectorBase() {
}
/** @brief call original constructor with one argument
*
* @todo for general number of arguments
*/
template<class ArgType> GeneralVector(ArgType arg) : VectorBase(arg) {
}
/** @brief call original constructor with two arguments
*
* @todo for general number of arguments
*/
template<class ArgType1,class ArgType2> GeneralVector(ArgType1 arg1, ArgType2 arg2) : VectorBase(arg1,arg2){
}
/** @brief matrix vector multiplication
*
* Set the values of vector equal to the values obtained from right hand-side
* vector A*v.
* \f[ \mathrm{this}~ = \underbrace{Av}_{= \mathrm{rhs}} \f]
*
* @param rhs right hand-size vector from A*v
*/
GeneralVector<VectorBase> &operator=(GeneralMatrixRHS<VectorBase> rhs);
/** @brief set random values
*
*/
virtual void set_random();
/** @brief set random values
*
*/
virtual void set_random2();
/** @brief get the name of the type
*
*/
static std::string get_name();
};
}
}
/* ------ IMPLEMENTATION ------ */
namespace pascinference {
namespace algebra {
template<class VectorBase>
GeneralVector<VectorBase> & GeneralVector<VectorBase>::operator=(GeneralMatrixRHS<VectorBase> rhs){
rhs.matmult(*this);
return *this;
}
template<class VectorBase>
void GeneralVector<VectorBase>::set_random(){
}
template<class VectorBase>
void GeneralVector<VectorBase>::set_random2(){
}
template<class VectorBase>
std::string GeneralVector<VectorBase>::get_name(){
return "GeneralVector";
}
}
}
// TODO: move to impl
namespace pascinference {
namespace algebra {
/* ------- MINLIN ------- */
#ifdef USE_MINLIN
typedef minlin::threx::HostVector<double> MinlinHostVector;
typedef minlin::threx::DeviceVector<double> MinlinDeviceVector;
template<>
void GeneralVector<MinlinHostVector>::set_random() {
int i;
for(i=0;i<this->size();i++){
(*this)(i) = std::rand()/(double)(RAND_MAX); /* generate random value */
}
}
template<>
void GeneralVector<MinlinDeviceVector>::set_random() {
int i;
for(i=0;i<this->size();i++){ // TODO: fill on Host and then transfer to device
(*this)(i) = std::rand()/(double)(RAND_MAX); /* generate random value */
}
}
#endif
}
} /* end of namespace */
#endif
|
//
// MyChildAccountViewController.h
// 雨掌柜
//
// Created by double on 17/5/20.
// Copyright © 2017年 Shanghai DuRui Information Technology Company. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface MyChildAccountViewController : UIViewController
@property (nonatomic,copy)void (^nameBlock)(NSString * name);
@end
|
/*numPass=0, numTotal=4
Verdict:WRONG_ANSWER, Visibility:1, Input:"3
1 1
2 3
4 5", ExpOutput:"no
", Output:"yes"
Verdict:WRONG_ANSWER, Visibility:1, Input:"4
1 1
2 3
4 6
7 0", ExpOutput:"yes
", Output:"no"
Verdict:WRONG_ANSWER, Visibility:0, Input:"4
0 0
4 5
5 4
3 6", ExpOutput:"no
", Output:"yes"
Verdict:WRONG_ANSWER, Visibility:0, Input:"4
1 2
5 4
4 7
0 0", ExpOutput:"yes
", Output:"no"
*/
#include <stdio.h>
int main() {
int n,r,c,i=0,j,x,m,z=0;
scanf("%d",&n);
int mt[n][2];
for(i=0;i<3;i++){
for(j=0;j<2;j++){
scanf("%d",&mt[i][j]);
}
}
for(i=0;i<n;i++){
for(m=1;m<n-1;m++){
x=mt[i][0]-mt[i+m][0];
if(x==0){
z=1;
}
else if((mt[i][1]-mt[i+m][1]==x)||(mt[i][1]-mt[i+m][1]==-x)||(mt[i][1]-mt[i+m][1]==0)){
z=1;
}
}
}
if(z==1){
printf("yes");
}
else printf("no");
return 0;
} |
//
// AFImageView.h
// AFParseKit
//
// Created by Ashkon Farhangi on 2/25/14.
// Copyright (c) 2014 Ashkon Farhangi. All rights reserved.
//
#import <UIKit/UIKit.h>
@class PFFile;
@interface AFImageView : UIImageView
@property (nonatomic) PFFile *imageFile;
- (void)setImageWithFile:(PFFile *)file placeholder:(UIImage *)placeholder;
@end
|
/**
* Copyright 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
#pragma once
#include <torch/extension.h> // @manual=//caffe2:torch_extension
void alignmentTrainCUDAWrapper(
const torch::Tensor& p_choose,
torch::Tensor& alpha,
float eps);
|
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by EncodeUTF8.rc
//
#define IDS_APP_TITLE 103
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 101
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
|
//
// BackgroundImgCell.h
// HHSD
//
// Created by alain serge on 3/26/17.
// Copyright © 2017 Alain Serge. All rights reserved.
//
//#import <UIKit/UIKit.h>
//
//@interface BackgroundImgCell : UITableViewCell
//
//@end
#import <UIKit/UIKit.h>
typedef void (^BgImgCellBlock) ();
@protocol BgImgCellDelegate <NSObject>
- (void)BgImgActionBtnClick:(Background_list *)mode;
@end
@interface BackgroundImgCell : UITableViewCell
@property (nonatomic, strong) UIImageView *leftImageView;
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel *timeLabel;
@property (nonatomic, strong) UILabel *addressLabel;
@property (nonatomic, strong) UILabel *contentLabel;
@property (nonatomic, strong) UILabel *companyLabel;
@property (nonatomic, strong) UILabel *numberLabel,*statusUsing;
@property (nonatomic, strong) UIButton *actionBtn; ;
@property (nonatomic, strong) Background_list *mainMode;
@property (nonatomic, weak) BgImgCellBlock actionBtnBlock;
@property (nonatomic, weak) id<BgImgCellDelegate>delegate;
- (void)setMode:(Background_list *)mode;
+ (CGFloat)getHeight;
@end
|
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
//
// AppDelegate.h
// UK Postage
//
// Created by ___FULLUSERNAME___ on ___DATE___.
// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <Cordova/CDVViewController.h>
@interface AppDelegate : NSObject <UIApplicationDelegate>{}
// invoke string is passed to your app on launch, this is only valid if you
// edit UK Postage-Info.plist to add a protocol
// a simple tutorial can be found here :
// http://iphonedevelopertips.com/cocoa/launching-your-own-application-via-a-custom-url-scheme.html
@property (nonatomic, strong) IBOutlet UIWindow* window;
@property (nonatomic, strong) IBOutlet CDVViewController* viewController;
@end
|
#pragma once
#include "battleunit.h"
class HeroCard : public BattleUnit
{
public:
HeroCard(void);
~HeroCard(void);
// public member
wstring mName;
wstring mCourtesyName;
int mGender;
int mBornYear;
string imgID;
};
|
// Copyright (c) 2019 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool. If making changes by
// hand only do so within the body of existing method and function
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=31b30ec0fc431a4d7dd9d2e1c3025065b2001987$
//
#ifndef CEF_LIBCEF_DLL_CTOCPP_DOWNLOAD_ITEM_CALLBACK_CTOCPP_H_
#define CEF_LIBCEF_DLL_CTOCPP_DOWNLOAD_ITEM_CALLBACK_CTOCPP_H_
#pragma once
#if !defined(WRAPPING_CEF_SHARED)
#error This file can be included wrapper-side only
#endif
#include "include/capi/cef_download_handler_capi.h"
#include "include/cef_download_handler.h"
#include "libcef_dll/ctocpp/ctocpp_ref_counted.h"
// Wrap a C structure with a C++ class.
// This class may be instantiated and accessed wrapper-side only.
class CefDownloadItemCallbackCToCpp
: public CefCToCppRefCounted<CefDownloadItemCallbackCToCpp,
CefDownloadItemCallback,
cef_download_item_callback_t> {
public:
CefDownloadItemCallbackCToCpp();
virtual ~CefDownloadItemCallbackCToCpp();
// CefDownloadItemCallback methods.
void Cancel() OVERRIDE;
void Pause() OVERRIDE;
void Resume() OVERRIDE;
};
#endif // CEF_LIBCEF_DLL_CTOCPP_DOWNLOAD_ITEM_CALLBACK_CTOCPP_H_
|
#ifndef NODE_NTPL_MODULE
#define NODE_NTPL_MODULE
#include <v8.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include "ntpl_mod.h"
namespace ntpl {
struct Replacements_;
struct Position_;
static inline Replacements* new_replacements() {};
static inline Position* new_position() {};
static inline Local<String> getInputPart( Position* pos ) {};
static inline Local<String> getInputSymbolPart( Position* pos ) {};
static Local<String> callModificator( Position* pos, Local<Object> modificators ) {};
static void pushVariable( Position* pos, Replacements* replace) {};
bool parseValidateArgs(const Arguments& args) {};
Handle<Value> parse(const Arguments& args) {};
}
#endif //NODE_NTPL_MODULE |
//
// DRConstant.h
// loop
//
// Created by doom on 16/8/1.
// Copyright © 2016年 DOOM. All rights reserved.
//
#ifndef DRConstant_h
#define DRConstant_h
/**
* Interface
*/
static const CGFloat kDefaultUserNameFont = 14;
static const CGFloat kDefaultContentFont = 12;
/**
* Color
*/
#define kDefaultBackGroundColor UIColorHex(ffffff)
#define kDefaultLineColor UIColorHex(dddddd)
#define kDefaultTextContentColor UIColorHex(000000)
/**
* Block
*/
typedef void (^VoidBlock)();
typedef BOOL (^BoolBlock)();
typedef int (^IntBlock)();
typedef id (^IDBlock)();
typedef void (^VoidBlock_int)(int);
typedef BOOL (^BoolBlock_int)(int);
typedef int (^IntBlock_int)(int);
typedef id (^IDBlock_int)(int);
typedef void (^VoidBlock_string)(NSString *);
typedef BOOL (^BoolBlock_string)(NSString *);
typedef int (^IntBlock_string)(NSString *);
typedef id (^IDBlock_string)(NSString *);
typedef void (^VoidBlock_id)(id);
typedef BOOL (^BoolBlock_id)(id);
typedef int (^IntBlock_id)(id);
typedef id (^IDBlock_id)(id);
/**
* AppInfo
*/
#define DR_APP_NAME ([[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"])
#define DR_APP_VERSION ([[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"])
#define DR_APP_BUILD ([[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"])
/**
* AppDelegate
*/
#define DRSharedAppDelegate ((AppDelegate *)[UIApplication sharedApplication].delegate)
//A better version of NSLog
#define NSLog(format, ...) do { \
fprintf(stderr, "<%s : %d> %s\n", \
[[[NSString stringWithUTF8String:__FILE__] lastPathComponent] UTF8String], \
__LINE__, __func__); \
(NSLog)((format), ##__VA_ARGS__); \
fprintf(stderr, "-------\n"); \
} while (0)
#ifdef DEBUG
#define DLog(format, ...) NSLog(format, ## __VA_ARGS__)
#else
#define DLog(format, ...)
#endif
#define BLOCK_EXEC(block, ...) if (block) { block(__VA_ARGS__); };
#define TrueAssign_EXEC(dic, value) if (value) { dic = value; };
#define IOS_VERSION_LOWER_THAN_8 (NSFoundationVersionNumber <= NSFoundationVersionNumber_iOS_7_1)
#define kKeyWindow [UIApplication sharedApplication].keyWindow
#define kScreen_Bounds (IOS_VERSION_LOWER_THAN_8 ? (UIInterfaceOrientationIsPortrait([UIApplication sharedApplication].statusBarOrientation) ? [[UIScreen mainScreen] bounds] : CGRectMake(0,0,[[UIScreen mainScreen] bounds].size.height, [[UIScreen mainScreen] bounds].size.width)) : [[UIScreen mainScreen] bounds])
#define kScreen_Width (IOS_VERSION_LOWER_THAN_8 ? (UIInterfaceOrientationIsPortrait([UIApplication sharedApplication].statusBarOrientation) ? [[UIScreen mainScreen] bounds].size.width : [[UIScreen mainScreen] bounds].size.height) : [[UIScreen mainScreen] bounds].size.width)
#define kScreen_Height (IOS_VERSION_LOWER_THAN_8 ? (UIInterfaceOrientationIsPortrait([UIApplication sharedApplication].statusBarOrientation) ? [[UIScreen mainScreen] bounds].size.height : [[UIScreen mainScreen] bounds].size.width) : [[UIScreen mainScreen] bounds].size.height)
#define kDevice_Is_iPhone4 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 960), [[UIScreen mainScreen] currentMode].size) : NO)
#define kDevice_Is_iPhone5 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 1136), [[UIScreen mainScreen] currentMode].size) : NO)
#define kDevice_Is_iPhone6 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(750, 1334), [[UIScreen mainScreen] currentMode].size) : NO)
#define kDevice_Is_iPhone6Plus ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1242, 2208), [[UIScreen mainScreen] currentMode].size) : NO)
#endif /* DRConstant_h */
|
//
// Generated by class-dump 3.5 (64 bit) (Debug version compiled Sep 30 2020 21:18:12).
//
// Copyright (C) 1997-2019 Steve Nygard.
//
#import <QuartzCore/CATextLayer.h>
@interface _TtC12SourceEditor18CoverageCountLayer : CATextLayer
{
}
+ (id)defaultActionForKey:(id)arg1;
- (id)initWithCoder:(id)arg1;
- (id)initWithLayer:(id)arg1;
- (id)init;
@end
|
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "pipeline_step_impllinks.h"
pipeline_step_impllinks_t *pipeline_step_impllinks_create(
link_t *self,
link_t *actions,
char *_class
) {
pipeline_step_impllinks_t *pipeline_step_impllinks_local_var = malloc(sizeof(pipeline_step_impllinks_t));
if (!pipeline_step_impllinks_local_var) {
return NULL;
}
pipeline_step_impllinks_local_var->self = self;
pipeline_step_impllinks_local_var->actions = actions;
pipeline_step_impllinks_local_var->_class = _class;
return pipeline_step_impllinks_local_var;
}
void pipeline_step_impllinks_free(pipeline_step_impllinks_t *pipeline_step_impllinks) {
if(NULL == pipeline_step_impllinks){
return ;
}
listEntry_t *listEntry;
if (pipeline_step_impllinks->self) {
link_free(pipeline_step_impllinks->self);
pipeline_step_impllinks->self = NULL;
}
if (pipeline_step_impllinks->actions) {
link_free(pipeline_step_impllinks->actions);
pipeline_step_impllinks->actions = NULL;
}
if (pipeline_step_impllinks->_class) {
free(pipeline_step_impllinks->_class);
pipeline_step_impllinks->_class = NULL;
}
free(pipeline_step_impllinks);
}
cJSON *pipeline_step_impllinks_convertToJSON(pipeline_step_impllinks_t *pipeline_step_impllinks) {
cJSON *item = cJSON_CreateObject();
// pipeline_step_impllinks->self
if(pipeline_step_impllinks->self) {
cJSON *self_local_JSON = link_convertToJSON(pipeline_step_impllinks->self);
if(self_local_JSON == NULL) {
goto fail; //model
}
cJSON_AddItemToObject(item, "self", self_local_JSON);
if(item->child == NULL) {
goto fail;
}
}
// pipeline_step_impllinks->actions
if(pipeline_step_impllinks->actions) {
cJSON *actions_local_JSON = link_convertToJSON(pipeline_step_impllinks->actions);
if(actions_local_JSON == NULL) {
goto fail; //model
}
cJSON_AddItemToObject(item, "actions", actions_local_JSON);
if(item->child == NULL) {
goto fail;
}
}
// pipeline_step_impllinks->_class
if(pipeline_step_impllinks->_class) {
if(cJSON_AddStringToObject(item, "_class", pipeline_step_impllinks->_class) == NULL) {
goto fail; //String
}
}
return item;
fail:
if (item) {
cJSON_Delete(item);
}
return NULL;
}
pipeline_step_impllinks_t *pipeline_step_impllinks_parseFromJSON(cJSON *pipeline_step_impllinksJSON){
pipeline_step_impllinks_t *pipeline_step_impllinks_local_var = NULL;
// define the local variable for pipeline_step_impllinks->self
link_t *self_local_nonprim = NULL;
// define the local variable for pipeline_step_impllinks->actions
link_t *actions_local_nonprim = NULL;
// pipeline_step_impllinks->self
cJSON *self = cJSON_GetObjectItemCaseSensitive(pipeline_step_impllinksJSON, "self");
if (self) {
self_local_nonprim = link_parseFromJSON(self); //nonprimitive
}
// pipeline_step_impllinks->actions
cJSON *actions = cJSON_GetObjectItemCaseSensitive(pipeline_step_impllinksJSON, "actions");
if (actions) {
actions_local_nonprim = link_parseFromJSON(actions); //nonprimitive
}
// pipeline_step_impllinks->_class
cJSON *_class = cJSON_GetObjectItemCaseSensitive(pipeline_step_impllinksJSON, "_class");
if (_class) {
if(!cJSON_IsString(_class))
{
goto end; //String
}
}
pipeline_step_impllinks_local_var = pipeline_step_impllinks_create (
self ? self_local_nonprim : NULL,
actions ? actions_local_nonprim : NULL,
_class ? strdup(_class->valuestring) : NULL
);
return pipeline_step_impllinks_local_var;
end:
if (self_local_nonprim) {
link_free(self_local_nonprim);
self_local_nonprim = NULL;
}
if (actions_local_nonprim) {
link_free(actions_local_nonprim);
actions_local_nonprim = NULL;
}
return NULL;
}
|
// This file was generated based on 'C:\ProgramData\Uno\Packages\Uno.Geometry\0.13.2\$.uno'.
// WARNING: Changes might be lost if you edit this file directly.
#ifndef __APP_UNO_GEOMETRY_RAY_H__
#define __APP_UNO_GEOMETRY_RAY_H__
#include <app/Uno.Float3.h>
#include <app/Uno.Object.h>
#include <Uno.h>
namespace app { namespace Uno { struct Float4x4; } }
namespace app {
namespace Uno {
namespace Geometry {
struct Ray;
struct Ray__uType : ::uStructType
{
};
Ray__uType* Ray__typeof();
void Ray___ObjInit(Ray* __this, ::app::Uno::Float3 pos, ::app::Uno::Float3 dir);
Ray Ray__New_1(::uStatic* __this, ::app::Uno::Float3 pos, ::app::Uno::Float3 dir);
Ray Ray__Transform(::uStatic* __this, Ray ray, ::app::Uno::Float4x4 transform);
struct Ray
{
::app::Uno::Float3 Position;
::app::Uno::Float3 Direction;
void _ObjInit(::app::Uno::Float3 pos, ::app::Uno::Float3 dir) { Ray___ObjInit(this, pos, dir); }
};
}}}
#endif
|
#pragma once
// Windows Header Files:
#include <windows.h>
// DX/Graphics Header Files:
#include <wrl/client.h>
#include <d3d11_1.h>
#include <DirectXMath.h>
#include <memory>
#include <agile.h> |
/*
* Copyright (c) 2013 - 2014, Freescale Semiconductor, 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:
*
* o Redistributions of source code must retain the above copyright notice, this list
* of conditions and the following disclaimer.
*
* o 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.
*
* o Neither the name of Freescale Semiconductor, 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 HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __FSL_GPIO_PINS_H__
#define __FSL_GPIO_PINS_H__
#include "fsl_gpio_driver.h"
/*! @file */
/*!*/
/*! This file contains gpio pin definitions used by gpio peripheral driver.*/
/*! The enums in _gpio_pins map to the real gpio pin numbers defined in*/
/*! gpioPinLookupTable. And this might be different in different board.*/
/*******************************************************************************
* Definitions
******************************************************************************/
/*! @brief gpio pin names.*/
/*!*/
/*! This should be defined according to board setting.*/
enum _gpio_pins
{
kGpioLED1 = GPIO_MAKE_PIN(HW_GPIOD, 4), /* TWR-K22F120M YEL/GRN LED */
kGpioLED2 = GPIO_MAKE_PIN(HW_GPIOD, 5), /* TWR-K22F120M YELLOW LED */
kGpioLED3 = GPIO_MAKE_PIN(HW_GPIOD, 6), /* TWR-K22F120M ORANGE LED */
kGpioLED4 = GPIO_MAKE_PIN(HW_GPIOD, 7), /* TWR-K22F120M BLUE LED */
kGpioSW1 = GPIO_MAKE_PIN(HW_GPIOC, 6), /* TWR-K22F120M SW1 */
kGpioSW2 = GPIO_MAKE_PIN(HW_GPIOC, 7), /* TWR-K22F120M SW3 */
kGpioAccelINT1 = GPIO_MAKE_PIN(HW_GPIOB, 0), /* TWR-K22F120M MMA8451Q/FXOS87000CB INT1 */
kGpioAccelINT2 = GPIO_MAKE_PIN(HW_GPIOB, 1), /* TWR-K22F120M MMA8451Q/FXOS87000CB INT2 */
kGpioUsbFLGA = GPIO_MAKE_PIN(HW_GPIOC, 8), /* TWR-K22F120M USB FLGA */
kGpioUsbENA = GPIO_MAKE_PIN(HW_GPIOC, 9), /* TWR-K22F120M USB EN_A */
kGpioUartDemoTX = GPIO_MAKE_PIN(HW_GPIOE, 0), /* TWR-K22F120M UART 2 TX pin (OSBDM port) */
kGpioUartDemoRX = GPIO_MAKE_PIN(HW_GPIOE, 1), /* TWR-K22F120M UART 2 RX pin (OSBDM port) */
kGpioI2Caddr1 = GPIO_MAKE_PIN(HW_GPIOB, 8), /* TWR-K22F120M I2C address pin */
kGpioI2Caddr2 = GPIO_MAKE_PIN(HW_GPIOB, 6), /* TWR-K22F120M I2C address pin */
kGpioSpi0Cs0 = GPIO_MAKE_PIN(HW_GPIOD, 0), /* TWR-K22F120M SPI0 CS0 pin */
kGpioSpi0Cs1 = GPIO_MAKE_PIN(HW_GPIOD, 4), /* TWR-K22F120M SPI0 CS1 pin */
};
extern gpio_input_pin_user_config_t switchPins[];
extern gpio_input_pin_user_config_t accelIntPins[];
extern gpio_input_pin_user_config_t i2cAddressPins[];
extern gpio_output_pin_user_config_t gpioUartDemoTxPin[];
extern gpio_input_pin_user_config_t gpioUartDemoRxPin[];
extern gpio_output_pin_user_config_t ledPins[];
extern gpio_output_pin_user_config_t spiCsPin[];
#endif /* __FSL_GPIO_PINS_H__ */
|
#pragma once
/*
The MIT License (MIT)
Copyright (c) 2015 Dennis Wandschura
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.
*/
struct ID3D12Device;
class UploadManager;
class GpuProfiler;
struct FrameData;
#include "d3d.h"
#include <vxLib/math/Vector.h>
#include "RenderSettings.h"
#include "PipelineState.h"
#include <vxEngineLib/Graphics/CommandQueue.h>
#include "RootSignature.h"
#include <memory>
namespace d3d
{
class ShaderManager;
class ResourceManager;
class CommandAllocator;
class GraphicsCommandList;
struct ThreadData;
}
class RenderPass
{
protected:
static d3d::ShaderManager* s_shaderManager;
static d3d::ResourceManager* s_resourceManager;
static UploadManager* s_uploadManager;
static vx::uint2 s_resolution;
static const RenderSettings* s_settings;
static GpuProfiler* s_gpuProfiler;
static d3d::ThreadData* s_threadData;
d3d::GraphicsCommandList* m_currentCommandList;
std::unique_ptr<d3d::GraphicsCommandList[]> m_commandLists;
d3d::RootSignature m_rootSignature;
d3d::PipelineState m_pipelineState;
RenderPass();
bool loadShaders(const wchar_t* const* name, u32 count);
bool createCommandLists(ID3D12Device* device, u32 type, d3d::CommandAllocator* allocators, u32 frameCount);
public:
virtual ~RenderPass();
static void provideData(d3d::ShaderManager* shaderManager, d3d::ResourceManager* resourceManager, UploadManager* uploadManager, const RenderSettings* settings,
GpuProfiler* gpuProfiler, d3d::ThreadData* threadData)
{
s_shaderManager = shaderManager;
s_resourceManager = resourceManager;
s_uploadManager = uploadManager;
s_resolution = settings->m_resolution;
s_settings = settings;
s_gpuProfiler = gpuProfiler;
s_threadData = threadData;
}
virtual void getRequiredMemory(u64* heapSizeBuffer, u32* bufferCount, u64* heapSizeTexture, u32* textureCount, u64* heapSizeRtDs, u32* rtDsCount, ID3D12Device* device) = 0;
virtual bool createData(ID3D12Device* device) = 0;
virtual bool initialize(ID3D12Device* device, d3d::CommandAllocator* allocators, u32 frameCount) = 0;
virtual void shutdown() = 0;
virtual void buildCommands(d3d::CommandAllocator* currentAllocator, u32 frameIndex) = 0;
virtual void submitCommands(Graphics::CommandQueue* queue) = 0;
}; |
/*
* $Id$
*
* Copyright(C) 1998-2008 Satoshi Nakamura
*
*/
#ifndef __MENU_H__
#define __MENU_H__
#include <qsmenu.h>
#include <qssax.h>
namespace qs {
/****************************************************************************
*
* MenuContentHandler
*
*/
class MenuContentHandler : public DefaultHandler
{
public:
MenuContentHandler(MenuManager* pMenuManager,
const ActionItem* pItem,
size_t nItemCount,
ActionParamMap* pActionParamMap,
DynamicMenuMap* pDynamicMenuMap);
virtual ~MenuContentHandler();
public:
virtual bool startElement(const WCHAR* pwszNamespaceURI,
const WCHAR* pwszLocalName,
const WCHAR* pwszQName,
const Attributes& attributes);
virtual bool endElement(const WCHAR* pwszNamespaceURI,
const WCHAR* pwszLocalName,
const WCHAR* pwszQName);
virtual bool characters(const WCHAR* pwsz,
size_t nStart,
size_t nLength);
private:
const ActionItem* getActionItem(const WCHAR* pwszAction) const;
private:
MenuContentHandler(const MenuContentHandler&);
MenuContentHandler& operator=(const MenuContentHandler&);
private:
enum State {
STATE_ROOT,
STATE_MENUS,
STATE_MENU,
STATE_MENUITEM,
STATE_SEPARATOR
};
private:
typedef std::vector<State> StateStack;
typedef std::vector<HMENU> MenuStack;
private:
MenuManager* pMenuManager_;
const ActionItem* pActionItem_;
size_t nActionItemCount_;
ActionParamMap* pActionParamMap_;
DynamicMenuMap* pDynamicMenuMap_;
StateStack stackState_;
MenuStack stackMenu_;
};
}
#endif // __MENU_H__
|
//
// IXCellBasedControl.h
// Ignite Engine
//
// Created by Robert Walsh on 6/4/14.
//
/****************************************************************************
The MIT License (MIT)
Copyright (c) 2015 Apigee Corporation
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 "IXBaseControl.h"
#import "IXCellBackgroundSwipeController.h"
@class IXDataRowDataProvider;
@class IXLayout;
@class IXSandbox;
@protocol IXCellContainerDelegate <NSObject>
@property (nonatomic,strong,readonly) IXCellBackgroundSwipeController* cellBackgroundSwipeController;
@property (nonatomic,strong) IXSandbox* cellSandbox;
@property (nonatomic,strong) IXLayout* layoutControl;
@property (nonatomic,strong) IXLayout* backgroundLayoutControl;
@property (nonatomic,assign) BOOL backgroundSlidesInFromSide;
@property (nonatomic,assign) BOOL adjustsBackgroundAlphaWithSwipe;
-(void)enableBackgroundSwipe:(BOOL)enableBackgroundSwipe swipeWidth:(CGFloat)swipeWidth;
@end
@interface IXCellBasedControl : IXBaseControl <IXCellBackgroundSwipeControllerDelegate>
@property (nonatomic,weak,readonly) IXDataRowDataProvider* dataProvider;
@property (nonatomic,assign,readonly) BOOL animateReload;
@property (nonatomic,assign,readonly) CGFloat animateReloadDuration;
@property (nonatomic,assign,readonly) BOOL scrollEnabled;
@property (nonatomic,assign,readonly) BOOL pagingEnabled;
@property (nonatomic,assign,readonly) BOOL showsVertScrollIndicators;
@property (nonatomic,assign,readonly) BOOL showsHorizScrollIndicators;
@property (nonatomic,assign,readonly) UIScrollViewIndicatorStyle scrollIndicatorStyle;
@property (nonatomic, assign) CGFloat backgroundViewSwipeWidth;
@property (nonatomic,assign,readonly) BOOL pullToRefreshEnabled;
@property (nonatomic,strong,readonly) UIRefreshControl* refreshControl;
-(CGSize)itemSize;
-(NSInteger)numberOfSections;
-(NSUInteger)rowCountForSection:(NSInteger)section;
-(void)reload;
-(void)dataProviderDidUpdate:(NSNotification*)notification;
-(void)refreshControlActivated;
-(CGSize)sizeForCellAtIndexPath:(NSIndexPath*)indexPath;
-(void)configureCell:(id<IXCellContainerDelegate>)cell withIndexPath:(NSIndexPath*)indexPath;
-(IXLayout*)headerViewForSection:(NSInteger)section;
@end
|
// TextFile.h
#ifndef __TEXTFILE_H__INCLUDED__
#define __TEXTFILE_H__INCLUDED__
#include <stdio.h>
#include <string.h>
#include "File.h"
const int TF_OVERFLOW = EOF - 1; // オーバーフロー
using namespace std;
class CTextFile : public CFile{
public:
int WriteString(const char* pszString); // 文字列を書き込む
int ReadLine(char* buffer, size_t nSize); // 1行読み出す関数
//public:
// bool Open(const char* pszFile, const char* pszFlags);
// ファイルを開く
private:
virtual bool ModifyFlags(const char* pszSource, char* pszDest, int nSize);
// フラグの調整
};
// 文字列を書き込む
inline int CTextFile::WriteString(const char* pszString){
return Write(pszString, strlen(pszString));
}
#endif
|
#include <wiringPi.h>
void main()
{
wiringPiSetup();
pinMode(0, OUTPUT);
int i;
for(i = 0; i < 5 ; i++)
{
digitalWrite(0, HIGH);
delay(500);
digitalWrite(0, LOW);
delay(500);
}
}
|
#ifndef CONSOLELOGTARGET_H
#define CONSOLELOGTARGET_H
#include "log_target.h"
/**
* @brief Forwards logs to stdout.
*/
class ConsoleLogTarget : public LogTarget
{
public:
/**
* @brief Constructor.
*/
ConsoleLogTarget();
/**
* @brief Destructor.
*/
~ConsoleLogTarget();
/**
* @brief Log function.
*
* @param[in] message The message to log.
*/
void log(const char* message) override;
};
#endif |
#ifndef SHA1_H
#define SHA1_H
typedef struct
{
unsigned long state[5];
unsigned long count[2];
unsigned char buffer[64];
}SHA1_CTX;
#ifdef __cplusplus
extern "C"
{
#endif
void SHA1Init(SHA1_CTX* context);
void SHA1Update(SHA1_CTX* context, unsigned char* data, unsigned int len);
void SHA1Final(unsigned char digest[20], SHA1_CTX* context);
void sha1(unsigned char *src, int srclen, unsigned char *des);
void sha1s(unsigned char *src, int srclen, char *des);
#ifdef __cplusplus
}
#endif
#endif
|
//
// ToDoList-Bridging-Header.h
// ToDoList
//
// Created by hakozaki on 2016/06/02.
// Copyright © 2016年 hakozaki. All rights reserved.
//
#ifndef ToDoList_Bridging_Header_h
#define ToDoList_Bridging_Header_h
#import "MagicalRecord.h"
#endif /* ToDoList_Bridging_Header_h */
|
#include "DAC.h"
/******************************************************************************/
void InitDAC(void)
{
RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPI2,ENABLE);
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB,ENABLE);
RCC_AHB1PeriphClockCmd(CS_RCC,ENABLE);
GPIO_PinAFConfig(GPIOB, GPIO_PinSource15, GPIO_AF_SPI2);
GPIO_PinAFConfig(GPIOB, GPIO_PinSource13, GPIO_AF_SPI2);
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_StructInit(&GPIO_InitStructure);
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_15|GPIO_Pin_13;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOB, &GPIO_InitStructure);
SPI_InitTypeDef SPI_InitStructS;
SPI_StructInit(&SPI_InitStructS);
GPIO_StructInit(&GPIO_InitStructure);
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN ;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_Pin = CS_PIN;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(CS_PORT, &GPIO_InitStructure);
DissableTransimt();
SPI_StructInit(&SPI_InitStructS);
SPI_InitStructS.SPI_Direction = SPI_Direction_1Line_Tx;
SPI_InitStructS.SPI_Mode = SPI_Mode_Master;
SPI_InitStructS.SPI_DataSize = SPI_DataSize_8b;
SPI_InitStructS.SPI_FirstBit =SPI_FirstBit_MSB;
SPI_InitStructS.SPI_CPOL = SPI_CPOL_Low;
SPI_InitStructS.SPI_CPHA = SPI_CPHA_1Edge;
SPI_InitStructS.SPI_NSS = SPI_NSS_Soft;
SPI_InitStructS.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_32 ;
SPI_Init(SPI2,&SPI_InitStructS);
SPI_Cmd(SPI2,ENABLE);
SPI_I2S_ITConfig(SPI2,SPI_I2S_IT_TXE|SPI_I2S_IT_RXNE| SPI_I2S_IT_ERR| I2S_IT_UDR|SPI_I2S_IT_TIFRFE,DISABLE);
SPI_NSSInternalSoftwareConfig(SPI2, SPI_NSSInternalSoft_Set);
}
/******************************************************************************/
void EnableTransimt(void)
{
GPIO_ResetBits(CS_PORT,CS_PIN);
}
/******************************************************************************/
void DissableTransimt(void)
{
GPIO_SetBits(CS_PORT,CS_PIN );
}
/******************************************************************************/
void WriteDAC(uint8_t Value)
{
EnableTransimt();
// do
// {
// }while(SPI_I2S_GetFlagStatus(SPI2, SPI_I2S_FLAG_BSY) == SET);
SPI_I2S_SendData(SPI2,Value);
// do
// {
// }while(SPI_I2S_GetFlagStatus(SPI2, SPI_I2S_FLAG_BSY) == SET);
DissableTransimt();
EnableTransimt();
};
/******************************************************************************/ |
/**
* @author ChalkPE <chalkpe@gmail.com>
* @since 2016-04-04
*/
#include <stdio.h>
int main(){
int kor, eng, mat, com, sum, avg;
scanf("%d %d %d %d", &kor, &eng, &mat, &com);
avg = (sum = kor + eng + mat + com) / 4;
printf("총점 %d점\n평균 %d점\n", sum, avg);
return 0;
}
//END OF FILE |
#include <stdio.h>
#include <string.h>
#define HASH_START_VALUE 42
long hash(char *);
int main()
{
char input_word[200];
long word_hash;
scanf("%s",input_word);
word_hash = hash(input_word);
printf("%ld\n", word_hash);
return 0;
}
long hash(char *word)
{
long word_hash = HASH_START_VALUE;
int word_lenght = strlen(word);
int i = 0;
for(;i < word_lenght; i++)
{
word_hash += word[i] * (i+1);
}
return word_hash;
}
|
//
// Generated by class-dump 3.5 (64 bit).
//
// class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2013 by Steve Nygard.
//
#import "PKPhysicsBody.h"
@class SKNode;
@interface PKPhysicsBody (SKPhysicsBody)
- (id)_descriptionClassName;
@property(readonly, nonatomic) __weak SKNode *node;
@end
|
/*
* Auto generated Run-Time-Environment Component Configuration File
* *** Do not modify ! ***
*
* Project: 'preflash_pca10056'
* Target: 'nrf52840_xxaa'
*/
#ifndef RTE_COMPONENTS_H
#define RTE_COMPONENTS_H
/*
* Define the Device Header File:
*/
#define CMSIS_device_header "nrf.h"
#endif /* RTE_COMPONENTS_H */
|
//
// Copyright(c) 2015 Gabi Melman.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
//
#pragma once
//
// Global registry functions
//
#include <spdlog.h>
#include <details/registry.h>
#include <sinks/file_sinks.h>
#include <sinks/stdout_sinks.h>
#include <sinks/syslog_sink.h>
#include <chrono>
#include <functional>
#include <memory>
#include <string>
inline void spdlog::register_logger(std::shared_ptr<logger> logger)
{
return details::registry::instance().register_logger(logger);
}
inline std::shared_ptr<spdlog::logger> spdlog::get(const std::string& name)
{
return details::registry::instance().get(name);
}
inline void spdlog::drop(const std::string &name)
{
details::registry::instance().drop(name);
}
// Create multi/single threaded rotating file logger
inline std::shared_ptr<spdlog::logger> spdlog::rotating_logger_mt(const std::string& logger_name, const std::string& filename, size_t max_file_size, size_t max_files, bool force_flush)
{
return create<spdlog::sinks::rotating_file_sink_mt>(logger_name, filename, "txt", max_file_size, max_files, force_flush);
}
inline std::shared_ptr<spdlog::logger> spdlog::rotating_logger_st(const std::string& logger_name, const std::string& filename, size_t max_file_size, size_t max_files, bool force_flush)
{
return create<spdlog::sinks::rotating_file_sink_st>(logger_name, filename, "txt", max_file_size, max_files, force_flush);
}
// Create file logger which creates new file at midnight):
inline std::shared_ptr<spdlog::logger> spdlog::daily_logger_mt(const std::string& logger_name, const std::string& filename, int hour, int minute, bool force_flush)
{
return create<spdlog::sinks::daily_file_sink_mt>(logger_name, filename, "txt", hour, minute, force_flush);
}
inline std::shared_ptr<spdlog::logger> spdlog::daily_logger_st(const std::string& logger_name, const std::string& filename, int hour, int minute, bool force_flush)
{
return create<spdlog::sinks::daily_file_sink_st>(logger_name, filename, "txt", hour, minute, force_flush);
}
// Create stdout/stderr loggers
inline std::shared_ptr<spdlog::logger> spdlog::stdout_logger_mt(const std::string& logger_name)
{
return details::registry::instance().create(logger_name, spdlog::sinks::stdout_sink_mt::instance());
}
inline std::shared_ptr<spdlog::logger> spdlog::stdout_logger_st(const std::string& logger_name)
{
return details::registry::instance().create(logger_name, spdlog::sinks::stdout_sink_st::instance());
}
inline std::shared_ptr<spdlog::logger> spdlog::stderr_logger_mt(const std::string& logger_name)
{
return details::registry::instance().create(logger_name, spdlog::sinks::stderr_sink_mt::instance());
}
inline std::shared_ptr<spdlog::logger> spdlog::stderr_logger_st(const std::string& logger_name)
{
return details::registry::instance().create(logger_name, spdlog::sinks::stderr_sink_st::instance());
}
#if defined(__linux__) || defined(__APPLE__)
// Create syslog logger
inline std::shared_ptr<spdlog::logger> spdlog::syslog_logger(const std::string& logger_name, const std::string& syslog_ident, int syslog_option)
{
return create<spdlog::sinks::syslog_sink>(logger_name, syslog_ident, syslog_option);
}
#endif
//Create logger with multiple sinks
inline std::shared_ptr<spdlog::logger> spdlog::create(const std::string& logger_name, spdlog::sinks_init_list sinks)
{
return details::registry::instance().create(logger_name, sinks);
}
template <typename Sink, typename... Args>
inline std::shared_ptr<spdlog::logger> spdlog::create(const std::string& logger_name, Args... args)
{
sink_ptr sink = std::make_shared<Sink>(args...);
return details::registry::instance().create(logger_name, { sink });
}
template<class It>
inline std::shared_ptr<spdlog::logger> spdlog::create(const std::string& logger_name, const It& sinks_begin, const It& sinks_end)
{
return details::registry::instance().create(logger_name, sinks_begin, sinks_end);
}
inline void spdlog::set_formatter(spdlog::formatter_ptr f)
{
details::registry::instance().formatter(f);
}
inline void spdlog::set_pattern(const std::string& format_string)
{
return details::registry::instance().set_pattern(format_string);
}
inline void spdlog::set_level(level::level_enum log_level)
{
return details::registry::instance().set_level(log_level);
}
inline void spdlog::set_async_mode(size_t queue_size, const async_overflow_policy overflow_policy, const std::function<void()>& worker_warmup_cb, const std::chrono::milliseconds& flush_interval_ms)
{
details::registry::instance().set_async_mode(queue_size, overflow_policy, worker_warmup_cb, flush_interval_ms);
}
inline void spdlog::set_sync_mode()
{
details::registry::instance().set_sync_mode();
}
inline void spdlog::drop_all()
{
details::registry::instance().drop_all();
}
|
#ifndef __ARM32_SETJMP_H__
#define __ARM32_SETJMP_H__
#ifdef __cplusplus
extern "C" {
#endif
struct __jmp_buf {
unsigned long long __jmp_buf[32];
};
typedef struct __jmp_buf jmp_buf[1];
int setjmp(jmp_buf);
void longjmp(jmp_buf, int);
#ifdef __cplusplus
}
#endif
#endif /* __ARM32_SETJMP_H__ */
|
#pragma once
#include "GameFramework/Pawn.h"
#include "PawnWithCamera.generated.h"
UCLASS()
class HOWTO_PLAYERCAMERA_API APawnWithCamera : public APawn
{
GENERATED_BODY()
public:
// Sets default values for this pawn's properties
APawnWithCamera();
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
public:
// Called every frame
virtual void Tick(float DeltaSeconds) override;
// Called to bind functionality to input
virtual void SetupPlayerInputComponent(class UInputComponent* InputComponent) override;
protected:
UPROPERTY(EditAnywhere)
USpringArmComponent* OurCameraSpringArm;
UCameraComponent* OurCamera;
//Input variables
FVector2D MovementInput;
FVector2D CameraInput;
float ZoomFactor;
bool bZoomingIn;
//Input functions
void MoveForward(float AxisValue);
void MoveRight(float AxisValue);
void PitchCamera(float AxisValue);
void YawCamera(float AxisValue);
void ZoomIn();
void ZoomOut();
}; |
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#endif
FOUNDATION_EXPORT double Pods_Aldo_ExampleVersionNumber;
FOUNDATION_EXPORT const unsigned char Pods_Aldo_ExampleVersionString[];
|
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// Use of this sample source code is subject to the terms of the Microsoft
// license agreement under which you licensed this sample source code. If
// you did not accept the terms of the license agreement, you are not
// authorized to use this sample source code. For the terms of the license,
// please see the license agreement between you and Microsoft or, if applicable,
// see the LICENSE.RTF on your install media or the root of your tools installation.
// THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES OR INDEMNITIES.
//
//------------------------------------------------------------------------------
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
//------------------------------------------------------------------------------
#include <windows.h>
#include <stdio.h>
#include <string.h>
//#include "io.h"
//
// Opens a file for reading and determines the file length
//
// Returns
// 0 on success
// >0 on failure
//
int OpenForReading(PCHAR fileName, FILE ** ppFile, ULONG * pLength)
{
fpos_t length;
// Check the caller's arguments
if (fileName == NULL || ppFile == NULL || pLength == NULL)
{
printf("OpenForReading: bad arguments\n");
return 1;
}
// Try to open the file
*ppFile = fopen(fileName, "rb");
if (*ppFile == NULL)
{
printf("OpenForReading: fopen() failed\n");
return 2;
}
// Determine the size of the file
if (fseek(*ppFile, 0, SEEK_END) != 0)
{
printf("OpenForReading: fseek() failed\n");
fclose(*ppFile);
return 3;
}
if (fgetpos(*ppFile, &length) != 0)
{
printf("OpenForReading: fgetpos() failed\n");
fclose(*ppFile);
return 4;
}
if (length > ((ULONG)-1))
{
printf("Files longer than 4GB are not supported\n");
fclose(*ppFile);
return 5;
}
*pLength = (ULONG)length;
if (fseek(*ppFile, 0, SEEK_SET) != 0)
{
printf("OpenForReading: fseek() failed\n");
fclose(*ppFile);
return 3;
}
return 0;
}
//
// Opens a file for writing
//
// Returns
// 0 on success
// >0 on failure
//
int OpenForWriting(PCHAR fileName, FILE ** ppFile)
{
// Check the caller's arguments
if (fileName == NULL || ppFile == NULL)
{
printf("OpenForWriting: bad arguments\n");
return 1;
}
// Try to open the file
*ppFile = fopen(fileName, "wb");
if (*ppFile == NULL)
{
printf("OpenForWriting: fopen() failed\n");
return 2;
}
return 0;
}
|
//
// Created by showtime on 9/11/2017.
//
#include "../../geometry/primitive_type.h"
#include <stdbool.h>
#ifndef EXOGFX_GRAPHICS_OGLES_FILTER_H
#define EXOGFX_GRAPHICS_OGLES_FILTER_H
#define FILTER_TYPE_PREVIEW 0xF000
#define FILTER_TYPE_GRAY 0xF001
#define FILTER_TYPE_INVERT 0xF002
#define FILTER_TYPE_VIGNETTE 0xF003
#define FILTER_TYPE_DISTORTION 0xFFFD
#define FILTER_TYPE_EFFECTS 0xFFFE
#define FILTER_TYPE_PRESENT 0xFFFF
#define VERTICES_DATA_POSITION_SIZE_1 1
#define VERTICES_DATA_POSITION_SIZE_2 2
#define VERTICES_DATA_POSITION_SIZE_3 3
#define VERTICES_DATA_UV_SIZE 2
#define ogles_filter_create(name) \
struct ogles_##name##_filter* ogles_##name##_filter_create
#define ogles_filter_init(name) \
void ogles_##name##_filter_init
#define ogles_filter_release(name) \
void ogles_##name##_filter_release
#define ogles_filter_safe_release(name) \
void ogles_##name##_filter_safe_release
#define ogles_filter_resize(name) \
void ogles_##name##_filter_resize
#define ogles_filter_pre_draw(name) \
void ogles_##name##_filter_pre_draw
#define ogles_filter_draw(name) \
void ogles_##name##_filter_draw
#define ogles_filter_post_draw(name) \
void ogles_##name##_filter_post_draw
#define ogles_filter_use_program(name) \
void ogles_##name##_filter_use_program
#define ogles_filter_register_handle(name) \
void ogles_##name##_filter_register_handle
#define UNIFORM(u) .u = {-1, #u}
#define ATTRIBUTE(a) .a = {-1, #a}
struct ogles_filter_base
{
uint32_t type;
GLuint program;
GLuint vertex_shader;
GLuint fragment_shader;
struct primitive *primitive;
struct ogles_fbo *fbo;
void (*init)(struct ogles_filter_base *base, primitive_type primitive_type, bool auto_fbo);
void (*resize)(struct ogles_filter_base *base, GLint width, GLint height);
void (*draw)(struct ogles_filter_base *base, GLuint *texture);
void (*release)(struct ogles_filter_base *base);
void (*safe_release)(struct ogles_filter_base *base);
};
struct uniform
{
GLint location;
const char *name;
};
struct attribute
{
GLint location;
const char *name;
};
#endif //EXOGFX_GRAPHICS_OGLES_FILTER_H
|
#ifndef __EMBER_SCRIPTING_SYSTEM_H
#define __EMBER_SCRIPTING_SYSTEM_H
/*
* @file ScriptingSystem.h
* @author PJ O Halloran
* @date 06/01/2017
*/
#include "app/AbstractSystem.h"
//#define SOL_USING_CXX_LUA
//#define SOL_USING_CXX_LUAJIT
#include <sol2/sol.hpp>
namespace ember
{
namespace scripting
{
using namespace ember::core;
using namespace ember::app;
class ScriptingSystem : public AbstractSystem
{
private:
static const char *Name;
sol::state *_lua;
bool InitDefaultConfig();
public:
ScriptingSystem( I32 initPriority, I32 updatePriority );
virtual ~ScriptingSystem() { }
virtual bool VInitialize( int argc, char **argv );
virtual bool VShutdown();
virtual void VUpdate() { }
virtual const char *VGetSystemName();
inline sol::state *Lua() const
{
return _lua;
};
bool RunScript( const char *configScript );
bool SetConfig( const char *configScript );
sol::table GetConfig( const char *name );
};
}
}
#endif
|
/*
* MinHook - Minimalistic API Hook Library
* Copyright (C) 2009 Tsuda Kageyu. All rights reserved.
*
* 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 the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
*/
#pragma once
#include <vector>
#include <windows.h>
#include "trampoline.h"
namespace MinHook
{
// CriticalSection with scoped lock feature.
class CriticalSection
{
CriticalSection(const CriticalSection&);
void operator=(const CriticalSection&);
public:
class ScopedLock
{
ScopedLock(const ScopedLock&);
void operator=(const ScopedLock&);
private:
CriticalSection& cs_;
public:
ScopedLock(CriticalSection& cs);
~ScopedLock();
};
private:
CRITICAL_SECTION cs_;
public:
CriticalSection();
~CriticalSection();
void enter();
void leave();
};
// Halt all other threads in the running process.
class ScopedThreadExclusive
{
private:
std::vector<DWORD> threads_;
public:
ScopedThreadExclusive(const std::vector<uintptr_t>& oldIPs, const std::vector<uintptr_t>& newIPs);
~ScopedThreadExclusive();
private:
static void GetThreads(std::vector<DWORD>& threads);
static void Freeze(
const std::vector<DWORD>& threads, const std::vector<uintptr_t>& oldIPs, const std::vector<uintptr_t>& newIPs);
static void Unfreeze(const std::vector<DWORD>& threads);
};
}
|
//
// popclock2AppDelegate.h
// popclock
//
// Created by crazypoo on 9/11/10.
// Copyright crazypoo 2010. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface AppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
}
@property (nonatomic, retain) UIWindow *window;
@end
|
#ifndef CQSVGFeDistantLight_H
#define CQSVGFeDistantLight_H
#include <CQSVGObject.h>
#include <CSVGFeDistantLight.h>
class CQSVG;
class CQSVGFeDistantLight : public CQSVGObject, public CSVGFeDistantLight {
Q_OBJECT
Q_PROPERTY(double elevation READ getElevation WRITE setElevation)
Q_PROPERTY(double azimuth READ getAzimuth WRITE setAzimuth )
public:
CQSVGFeDistantLight(CQSVG *svg);
void addProperties(CQPropertyTree *tree, const std::string &name) override;
};
#endif
|
// This file is part of Wintermute Engine
// For conditions of distribution and use, see copyright notice in license.txt
// http://dead-code.org/redir.php?target=wme
#pragma once
#include "WDynArray.h"
#include "enums.h"
#include "Interfaces.h"
namespace DeadCode { namespace WME { namespace Core
{
using namespace System;
using namespace DeadCode::WME::Core;
using namespace System::Runtime::InteropServices;
ref class WUIWindow;
public ref class WUIObject : public WObject, public IEditorResizable
{
public:
WUIObject(){};
WUIObject(WGame^ Game);
WUIObject(CUIObject* Native);
virtual ~WUIObject(void);
//////////////////////////////////////////////////////////////////////////
// Properties
//////////////////////////////////////////////////////////////////////////
property bool CanFocus
{
bool get()
{
return Native->m_CanFocus;
}
void set(bool Value)
{
Native->m_CanFocus = Value;
}
}
property bool Focused
{
bool get()
{
return Native->IsFocused();
}
}
property bool ParentNotify
{
bool get()
{
return Native->m_ParentNotify;
}
void set(bool Value)
{
Native->m_ParentNotify = Value;
}
}
property WUIWindow^ Parent
{
WUIWindow^ get()
{
if(Native->m_Parent) return (WUIWindow^)WUtils::CastUIObject(Native->m_Parent);
else return nullptr;
}
}
property bool SharedFonts
{
bool get()
{
return Native->m_SharedFonts;
}
void set(bool Value)
{
Native->m_SharedFonts = Value;
}
}
property bool SharedImages
{
bool get()
{
return Native->m_SharedImages;
}
void set(bool Value)
{
Native->m_SharedImages = Value;
}
}
property String^ Text
{
String^ get()
{
if(Native->m_Text) return gcnew String(Native->m_Text);
else return nullptr;
}
void set(String^ Value)
{
char* S = (char*)WUtils::GetString(Value);
Native->SetText(S);
WUtils::FreeString(S);
}
}
property bool Visible
{
bool get()
{
return Native->m_Visible;
}
void set(bool Value)
{
Native->m_Visible = Value;
}
}
property bool Disabled
{
bool get()
{
return Native->m_Disable;
}
void set(bool Value)
{
Native->m_Disable = Value;
}
}
property WFont^ Font
{
WFont^ get()
{
if(Native->m_Font) return gcnew WFont(Native->m_Font);
else return nullptr;
}
void set(WFont^ Value)
{
if(!Native->m_SharedFonts) Native->Game->m_FontStorage->RemoveFont(Native->m_Font);
Native->m_Font = NULL;
if(Value!=nullptr) Native->m_Font = Value->Native;
}
}
property WSprite^ Image
{
WSprite^ get()
{
if(Native->m_Image) return gcnew WSprite(Native->m_Image);
else return nullptr;
}
void set(WSprite^ Value)
{
if(!Native->m_SharedImages) SAFE_DELETE(Native->m_Image);
else Native->m_Image = NULL;
if(Value!=nullptr) Native->m_Image = Value->Native;
}
}
property WUITiledImage^ Back
{
WUITiledImage^ get()
{
if(Native->m_Back) return gcnew WUITiledImage(Native->m_Back);
else return nullptr;
}
void set(WUITiledImage^ Value)
{
SAFE_DELETE(Native->m_Back);
if(Value!=nullptr) Native->m_Back = Value->Native;
}
}
property int Width
{
virtual int get()
{
return Native->m_Width;
}
virtual void set(int Value)
{
Native->m_Width = Value;
}
}
property int Height
{
virtual int get() override
{
return Native->m_Height;
}
virtual void set(int Value) override
{
Native->m_Height = Value;
}
}
property WEUIObjectType Type
{
WEUIObjectType get()
{
return (WEUIObjectType)Native->m_Type;
}
void set(WEUIObjectType Value)
{
Native->m_Type = (TUIObjectType)Value;
}
}
property WUIObject^ FocusedControl
{
WUIObject^ get()
{
if(Native->m_FocusedWidget) return WUtils::CastUIObject(Native->m_FocusedWidget);
else return nullptr;
}
void set(WUIObject^ Value)
{
if(Value!=nullptr) Native->m_FocusedWidget = Value->Native;
else Native->m_FocusedWidget = NULL;
}
}
//////////////////////////////////////////////////////////////////////////
// Miscelaneous
//////////////////////////////////////////////////////////////////////////
bool GetTotalOffset([Out]int% OffsetX, [Out]int% OffsetY)
{
int X, Y;
bool Ret = SUCCEEDED(Native->GetTotalOffset(&X, &Y));
OffsetX = X;
OffsetY = Y;
return Ret;
}
bool Focus()
{
return SUCCEEDED(Native->Focus());
}
virtual bool Display(int OffsetX, int OffsetY)
{
return SUCCEEDED(Native->Display(OffsetX, OffsetY));
}
virtual bool Display()
{
return Display(0, 0);
}
virtual bool CorrectSize()
{
Native->CorrectSize();
return true;
}
//////////////////////////////////////////////////////////////////////////
// save / load
//////////////////////////////////////////////////////////////////////////
virtual bool SaveAsText(WDynBuffer^ Buffer, int Indent)
{
return SUCCEEDED(Native->SaveAsText(Buffer->Native, Indent));
}
virtual bool SaveAsText(WDynBuffer^ Buffer)
{
return SaveAsText(Buffer, 0);
}
virtual bool LoadFromBuffer(String^ Buffer, bool Complete)
{
return false;
}
virtual bool LoadFromBuffer(String^ Buffer)
{
return false;
}
internal:
property CUIObject* Native
{
CUIObject* get() { return (CUIObject*)m_Native; };
}
};
}}};
|
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#define MAXLEN 100000
struct TreeNode {
int val;
struct TreeNode *left;
struct TreeNode *right;
};
struct TreeNode *root;
struct TreeNode* newNode(int val, struct TreeNode *left, struct TreeNode *right) {
struct TreeNode *node = malloc(sizeof(struct TreeNode));
node->val = val;
node->left = left;
node->right = right;
return node;
}
int findPath(struct TreeNode* root, struct TreeNode* o, struct TreeNode** path) {
if (root == NULL)
return 0;
*path++ = root;
if (root == o) {
*path = NULL;
return 1;
}
if (findPath(root->left, o, path) == 1)
return 1;
if (findPath(root->right, o, path) == 1)
return 1;
*path-- = NULL;
return 0;
}
struct TreeNode* lowestCommonAncestor(struct TreeNode* root, struct TreeNode* p, struct TreeNode* q) {
struct TreeNode* p1[MAXLEN];
struct TreeNode* p2[MAXLEN];
findPath(root, p, p1);
findPath(root, q, p2);
struct TreeNode **c1 = p1, **c2= p2, *r = NULL;
while (*c1 != NULL && *c2 != NULL) {
printf("%d %d\n", (*c1)->val, (*c2)->val);
if (*c1 == *c2) {
r = *c1;
}
c1++;
c2++;
}
return r;
}
int main() {
struct TreeNode *node4 = newNode(4, NULL, NULL);
struct TreeNode *node7 = newNode(7, NULL, NULL);
struct TreeNode *node0 = newNode(0, NULL, NULL);
struct TreeNode *node8 = newNode(8, NULL, NULL);
struct TreeNode *node2 = newNode(2, node7, node4);
struct TreeNode *node1 = newNode(1, node0, node8);
struct TreeNode *node6 = newNode(6, NULL, NULL);
struct TreeNode *node5 = newNode(5, node6, node2);
struct TreeNode *node3 = newNode(3, node5, node1);
root = lowestCommonAncestor(node3, node7, node4);
printf("%d\n", root->val);
}
|
/* algo11-1.c µ÷ÓÃbo11-1.cµÄ³ÌÐò */
#include"c1.h"
typedef int InfoType; /* ¶¨ÒåÆäËüÊý¾ÝÏîµÄÀàÐÍ */
#include"c9.h"
#include"c10-1.h" /* ¶¨ÒåKeyType¡¢RedType¼°SqList */
#include"bo10-1.c"
#define k 5 /* k·¹é²¢ */
#include"bo11-1.c"
#define N 3 /* ÉèÿС¸öÎļþÓÐN¸öÊý¾Ý(¿É½«Õû¸öÎļþÒ»´Î¶ÁÈëÄÚ´æµÄ³ÆÎªÐ¡Îļþ) */
#define M 10 /* ÉèÊä³öM¸öÊý¾Ý»»ÐÐ */
void print(RedType t)
{
printf("(%d,%d)",t.key,t.otherinfo);
}
void main()
{
RedType a[k*N]={{16,1},{15,2},{10,3},{20,4},{9,5},{18,6},{22,7},{20,8},{40,9},{15,10},{25,11},{6,12},{12,13},{48,14},{37,15}}; /* ÓÐk*N¸ö¼Ç¼µÄÊý×é */
RedType r,t={MAXKEY}; /* СÎļþβ²¿µÄ½áÊø±êÖ¾ */
SqList l;
int i,j;
char fname[k][3],fori[4]="ori",fout[4]="out",s[3];
LoserTree ls;
/* ÓÉÊý×éa´´Ôì1¸ö´óÎļþ(²»Äܽ«Õû¸öÎļþÒ»´Î¶ÁÈëÄÚ´æµÄ³ÆÎª´óÎļþ) */
fp[k]=fopen(fori,"wb"); /* ÒÔдµÄ·½Ê½´ò¿ª´óÎļþfori */
fwrite(a,sizeof(RedType),k*N,fp[k]); /* ½«Êý×éaÖеÄÊý¾ÝдÈëÎļþforiÖÐ(±íʾ1¸ö´óÎļþ) */
fclose(fp[k]); /* ¹Ø±ÕÎļþfori */
fp[k]=fopen(fori,"rb"); /* ÒÔ¶ÁµÄ·½Ê½´ò¿ª´óÎļþfori */
printf("´óÎļþµÄ¼Ç¼Ϊ:\n");
for(i=1;i<=N*k;i++)
{
fread(&r,sizeof(RedType),1,fp[k]); /* ÒÀ´Î½«´óÎļþforiµÄÊý¾Ý¶ÁÈër */
print(r); /* Êä³örµÄÄÚÈÝ */
if(i%M==0)
printf("\n");
}
printf("\n");
rewind(fp[k]); /* ʹfp[k]µÄÖ¸ÕëÖØÐ·µ»Ø´óÎļþforiµÄÆðʼλÖã¬ÒÔ±ãÖØÐ¶ÁÈëÄڴ棬²úÉúÓÐÐòµÄ×ÓÎļþ */
for(i=0;i<k;i++) /* ½«´óÎļþforiµÄÊý¾Ý·Ö³Ék×飬ÿ×éN¸öÊý¾Ý */
{ /* ÅÅÐòºó·Ö±ð´æµ½Ð¡Îļþf0,f1,¡ÖÐ */
fread(&l.r[1],sizeof(RedType),N,fp[k]); /* ½«´óÎļþforiµÄN¸öÊý¾Ý¶ÁÈël */
l.length=N;
InsertSort(&l); /* ¶Ôl½øÐÐÄÚ²¿ÅÅÐò */
itoa(i,s,10); /* Éú³Ék¸öÎļþÃûf0,f1,f2,¡ */
strcpy(fname[i],"f");
strcat(fname[i],s);
fp[i]=fopen(fname[i],"wb"); /* ÒÔдµÄ·½Ê½´ò¿ªÎļþf0,f1,¡ */
fwrite(&l.r[1],sizeof(RedType),N,fp[i]); /* ½«ÅÅÐòºóµÄN¸öÊý¾Ý·Ö±ðдÈëf0,f1,¡ */
fwrite(&t,sizeof(RedType),1,fp[i]); /* ½«Îļþ½áÊø±êÖ¾·Ö±ðдÈëf0,f1,¡ */
fclose(fp[i]); /* ¹Ø±ÕÎļþf0,f1,¡ */
}
fclose(fp[k]); /* ¹Ø±Õ´óÎļþfori */
for(i=0;i<k;i++)
{ /* ÒÀ´Î´ò¿ªf0,f1,f2,¡,k¸öÎļþ */
itoa(i,s,10); /* Éú³Ék¸öÎļþÃûf0,f1,f2,¡ */
strcpy(fname[i],"f");
strcat(fname[i],s);
fp[i]=fopen(fname[i],"rb"); /* ÒÔ¶ÁµÄ·½Ê½´ò¿ªÎļþf0,f1,¡ */
printf("ÓÐÐò×ÓÎļþf%dµÄ¼Ç¼Ϊ:\n",i);
for(j=0;j<=N;j++)
{
fread(&r,sizeof(RedType),1,fp[i]); /* ÒÀ´Î½«f0,f1,¡µÄÊý¾Ý¶ÁÈër */
print(r); /* Êä³örµÄÄÚÈÝ */
}
printf("\n");
rewind(fp[i]); /* ʹfp[i]µÄÖ¸ÕëÖØÐ·µ»Øf0,f1,¡µÄÆðʼλÖã¬ÒÔ±ãÖØÐ¶ÁÈëÄÚ´æ */
}
fp[k]=fopen(fout,"wb"); /* ÒÔдµÄ·½Ê½´ò¿ª´óÎļþfout */
K_Merge(ls,b); /* ÀûÓðÜÕßÊ÷ls½«k¸öÊäÈë¹é²¢¶ÎÖеļǼ¹é²¢µ½Êä³ö¹é²¢¶Î£¬¼´´óÎļþfout */
for(i=0;i<k;i++)
fclose(fp[i]); /* ¹Ø±ÕÎļþf0,f1,¡ */
fclose(fp[k]); /* ¹Ø±ÕÎļþfout */
fp[k]=fopen(fout,"rb"); /* ÒÔ¶ÁµÄ·½Ê½´ò¿ª´óÎļþfoutÑéÖ¤ÅÅÐò */
printf("ÅÅÐòºóµÄ´óÎļþµÄ¼Ç¼Ϊ:\n");
for(i=1;i<=N*k+1;i++)
{
fread(&t,sizeof(RedType),1,fp[k]);
print(t);
if(i%M==0)
printf("\n");
}
printf("\n");
fclose(fp[k]); /* ¹Ø±ÕÎļþfout */
}
|
//
// IsaoTextField.h
// CCTextFieldEffects
//
// Created by Kelvin on 6/25/16.
// Copyright © 2016 Cokile. All rights reserved.
//
#import "CCTextField.h"
@interface IsaoTextField : CCTextField
#pragma mark - Public properties
/**
* The color of the border when it has no content.
*
* This property applies a color to the lower edge of the control. The default value for this property is a white color. This value is also applied to the placeholder color.
*/
@property (strong, nonatomic) UIColor *inactiveColor;
/**
* The color of the border when it has content.
*
* This property applies a color to the lower edge of the control. The default value for this property is a shallow red color.
*/
@property (strong, nonatomic) UIColor *activeColor;
/**
* The scale of the placeholder font.
*
* This property determines the size of the placeholder label relative to the font size of the text field.
*/
@property (nonatomic) CGFloat placeholderFontScale;
@end
|
// Copyright (c) 2011-2017 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
// Maza: Hive
#ifndef BITCOIN_QT_HIVETABLEMODEL_H
#define BITCOIN_QT_HIVETABLEMODEL_H
#include <qt/walletmodel.h>
#include <wallet/wallet.h>
#include <QAbstractTableModel>
#include <QStringList>
#include <QDateTime>
class CWallet;
class CBeeCreationTransactionInfoLessThan
{
public:
CBeeCreationTransactionInfoLessThan(int nColumn, Qt::SortOrder fOrder):
column(nColumn), order(fOrder) {}
bool operator()(CBeeCreationTransactionInfo &left, CBeeCreationTransactionInfo &right) const;
private:
int column;
Qt::SortOrder order;
};
class HiveTableModel: public QAbstractTableModel
{
Q_OBJECT
public:
explicit HiveTableModel(const PlatformStyle *_platformStyle, CWallet *wallet, WalletModel *parent);
~HiveTableModel();
enum ColumnIndex {
Created = 0,
Count = 1,
Status = 2,
EstimatedTime = 3,
Cost = 4,
Rewards = 5,
NUMBER_OF_COLUMNS
};
void updateBCTs(bool includeDeadBees);
void getSummaryValues(int &_immature, int &_mature, int &_dead, int &_blocksFound, CAmount &_cost, CAmount &_rewardsPaid, CAmount &_profit);
// Stuff overridden from QAbstractTableModel
int rowCount(const QModelIndex &parent) const;
int columnCount(const QModelIndex &parent) const;
QVariant data(const QModelIndex &index, int role) const;
bool setData(const QModelIndex &index, const QVariant &value, int role);
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
public Q_SLOTS:
void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
private:
static QString secondsToString(qint64 seconds);
void addBCT(const CBeeCreationTransactionInfo &bct);
const PlatformStyle *platformStyle;
WalletModel *walletModel;
QStringList columns;
QList<CBeeCreationTransactionInfo> list;
int sortColumn;
Qt::SortOrder sortOrder;
int immature, mature, dead, blocksFound;
CAmount cost, rewardsPaid, profit;
};
#endif // BITCOIN_QT_HIVETABLEMODEL_H
|
/*
*
* Confidential Information of Telekinesys Research Limited (t/a Havok). Not for disclosure or distribution without Havok's
* prior written consent. This software contains code, techniques and know-how which is confidential and proprietary to Havok.
* Product and Trade Secret source code contains trade secrets of Havok. Havok Software (C) Copyright 1999-2014 Telekinesys Research Limited t/a Havok. All Rights Reserved. Use of this software is subject to the terms of an end user license agreement.
*
*/
#ifndef HKP_RACKANDPINIONDRAWER_H
#define HKP_RACKANDPINIONDRAWER_H
#include <Physics/Constraint/Visualize/Drawer/hkpConstraintDrawer.h>
#include <Common/Visualize/Shape/hkDisplaySemiCircle.h>
#include <Physics/Constraint/Data/RackAndPinion/hkpRackAndPinionConstraintData.h>
/// Displays information about the rack-and-pinion constraint.
class HK_EXPORT_PHYSICS hkpRackAndPinionDrawer : public hkpConstraintDrawer
{
public:
HK_DECLARE_NONVIRTUAL_CLASS_ALLOCATOR( HKP_MEMORY_CLASS_VDB, hkpRackAndPinionDrawer );
void drawConstraint( const hkpRackAndPinionConstraintData* constraintData,
const hkTransform& localToWorldA, const hkTransform& localToWorldB,
hkDebugDisplayHandler* displayHandler, int id, int tag);
protected:
hkDisplaySemiCircle m_cogWheel;
};
#endif // HKP_RACKANDPINIONDRAWER_H
/*
* Havok SDK - NO SOURCE PC DOWNLOAD, BUILD(#20140907)
*
* Confidential Information of Havok. (C) Copyright 1999-2014
* Telekinesys Research Limited t/a Havok. All Rights Reserved. The Havok
* Logo, and the Havok buzzsaw logo are trademarks of Havok. Title, ownership
* rights, and intellectual property rights in the Havok software remain in
* Havok and/or its suppliers.
*
* Use of this software for evaluation purposes is subject to and indicates
* acceptance of the End User licence Agreement for this product. A copy of
* the license is included with this software and is also available at www.havok.com/tryhavok.
*
*/
|
//
// DefaultScrollVC.h
// SGPageViewExample
//
// Created by apple on 17/4/13.
// Copyright © 2017年 Sorgle. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface DefaultScrollVC : UIViewController
@end
|
/* NickServ core functions
*
* (C) 2003-2014 Anope Team
* Contact us at team@anope.org
*
* Please read COPYING and README for further details.
*
* Based on the original code of Epona by Lara.
* Based on the original code of Services by Andy Church.
*/
struct NSCertList
{
protected:
NSCertList() { }
public:
virtual ~NSCertList() { }
/** Add an entry to the nick's certificate list
*
* @param entry The fingerprint to add to the cert list
*
* Adds a new entry into the cert list.
*/
virtual void AddCert(const Anope::string &entry) = 0;
/** Get an entry from the nick's cert list by index
*
* @param entry Index in the certificaate list vector to retrieve
* @return The fingerprint entry of the given index if within bounds, an empty string if the vector is empty or the index is out of bounds
*
* Retrieves an entry from the certificate list corresponding to the given index.
*/
virtual Anope::string GetCert(unsigned entry) const = 0;
virtual unsigned GetCertCount() const = 0;
/** Find an entry in the nick's cert list
*
* @param entry The fingerprint to search for
* @return True if the fingerprint is found in the cert list, false otherwise
*
* Search for an fingerprint within the cert list.
*/
virtual bool FindCert(const Anope::string &entry) const = 0;
/** Erase a fingerprint from the nick's certificate list
*
* @param entry The fingerprint to remove
*
* Removes the specified fingerprint from the cert list.
*/
virtual void EraseCert(const Anope::string &entry) = 0;
/** Clears the entire nick's cert list
*
* Deletes all the memory allocated in the certificate list vector and then clears the vector.
*/
virtual void ClearCert() = 0;
virtual void Check() = 0;
};
class CertService : public Service
{
public:
CertService(Module *c) : Service(c, "CertService", "certs") { }
virtual NickCore* FindAccountFromCert(const Anope::string &cert) = 0;
};
|
#include <stdio.h>
#include <math.h>
int main()
{
double celsius = 0;
double fahren = 0;
printf("Celsius\tFahrenheit\n");
for(celsius=-6; celsius <= 6.0 ; celsius+=2.0 ){
fahren = 32.0 + (celsius*9.0)/5.0;
printf("%0.1lf\t%0.1lf\n",celsius,fahren);
}
return 0;
}
|
//
// XPhotoBrowser.h
// JYLibrary
//
// Created by XJY on 16/4/14.
// Copyright © 2016年 XJY. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface XPhotoBrowser : UIView
@property (nonatomic, strong) UIImage *placeHolderImage;
@property (nonatomic, assign) CGFloat maximumZoomScale; //default is 2.0
@property (nonatomic, assign) CGFloat minimumZoomScale; //default is 1.0
@property (nonatomic, strong) UIFont *pageNumberFont;
- (void)loadImages:(NSArray *)images;
@end
|
//
// Created by ekuch on 10/1/15.
//
#ifndef GITCPP_FWDDECL_H
#define GITCPP_FWDDECL_H
#include <memory>
namespace gitcpp {
class ICommit;
class IIndex;
class IObject;
class IObjectDatabase;
class IObjectId;
class IObjectType;
class IReference;
class IReferenceDatabase;
class IRepository;
template <typename T> class IIterator;
typedef std::shared_ptr<ICommit> ICommitPtr;
typedef std::shared_ptr<IObject> IObjectPtr;
typedef std::shared_ptr<IObjectType> IObjectTypePtr;
typedef std::shared_ptr<IObjectId> IObjectIdPtr;
typedef std::shared_ptr<IReference> IReferencePtr;
typedef std::shared_ptr<IRepository> IRepositoryPtr;
typedef std::shared_ptr<IObjectDatabase> IObjectDatabasePtr;
typedef std::shared_ptr<IReferenceDatabase> IReferenceDatabasePtr;
typedef std::shared_ptr<IIndex> IIndexPtr;
namespace annotated_commit {
class IAnnotatedCommit;
class IAnnotatedCommitRepositoryExt;
typedef std::shared_ptr<IAnnotatedCommit> IAnnotatedCommitPtr;
};
namespace config {
class IConfig;
class IConfigEntry;
class IConfigLevel;
typedef IIterator<IConfigEntry> IConfigEntryIterator;
typedef std::shared_ptr<IConfig> IConfigPtr;
typedef std::shared_ptr<IConfigEntry> IConfigEntryPtr;
typedef std::shared_ptr<IConfigLevel> IConfigLevelPtr;
typedef std::shared_ptr<IConfigEntryIterator> IConfigEntryIteratorPtr;
};
};
#endif //GITCPP_FWDDECL_H
|
/* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE78_OS_Command_Injection__wchar_t_connect_socket_popen_52c.c
Label Definition File: CWE78_OS_Command_Injection.one_string.label.xml
Template File: sources-sink-52c.tmpl.c
*/
/*
* @description
* CWE: 78 OS Command Injection
* BadSource: connect_socket Read data using a connect socket (client side)
* GoodSource: Fixed string
* Sink: popen
* BadSink : Execute command in data using popen()
* Flow Variant: 52 Data flow: data passed as an argument from one function to another to another in three different source files
*
* */
#include "std_testcase.h"
#include <wchar.h>
#ifdef _WIN32
#define FULL_COMMAND L"%WINDIR%\\system32\\cmd.exe /c dir "
#else
#include <unistd.h>
#define FULL_COMMAND L"/bin/sh ls -la "
#endif
#ifdef _WIN32
#include <winsock2.h>
#include <windows.h>
#include <direct.h>
#pragma comment(lib, "ws2_32") /* include ws2_32.lib when linking */
#define CLOSE_SOCKET closesocket
#else /* NOT _WIN32 */
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#define INVALID_SOCKET -1
#define SOCKET_ERROR -1
#define CLOSE_SOCKET close
#define SOCKET int
#endif
#define TCP_PORT 27015
#define IP_ADDRESS "127.0.0.1"
/* define POPEN as _popen on Windows and popen otherwise */
#ifdef _WIN32
#define POPEN _wpopen
#define PCLOSE _pclose
#else /* NOT _WIN32 */
#define POPEN popen
#define PCLOSE pclose
#endif
/* all the sinks are the same, we just want to know where the hit originated if a tool flags one */
#ifndef OMITBAD
void CWE78_OS_Command_Injection__wchar_t_connect_socket_popen_52c_badSink(wchar_t * data)
{
{
FILE *pipe;
/* POTENTIAL FLAW: Execute command in data possibly leading to command injection */
pipe = POPEN(data, L"wb");
if (pipe != NULL)
{
PCLOSE(pipe);
}
}
}
#endif /* OMITBAD */
#ifndef OMITGOOD
/* goodG2B uses the GoodSource with the BadSink */
void CWE78_OS_Command_Injection__wchar_t_connect_socket_popen_52c_goodG2BSink(wchar_t * data)
{
{
FILE *pipe;
/* POTENTIAL FLAW: Execute command in data possibly leading to command injection */
pipe = POPEN(data, L"wb");
if (pipe != NULL)
{
PCLOSE(pipe);
}
}
}
#endif /* OMITGOOD */
|
//
// PhotosDataSource.h
// Solver
//
// Created by Sergii Lantratov on 11/13/13.
// Copyright (c) 2013 Sergii Lantratov. All rights reserved.
//
@interface PhotosDataSource : NSObject
+ (PhotosDataSource *)defaultDataSource;
- (NSArray *)allPhotos;
- (UIImage *)photoAtIndex:(NSInteger)index;
- (void)removePhotoFromIndex:(NSInteger)index;
- (void)addPhoto:(UIImage *)photo;
- (void)clearPhotos;
- (void)savePhotos;
@end
|
//
// YBPlayerToolView.h
// VideoPlayerDemo
//
// Created by 焦英博 on 2017/6/27.
// Copyright © 2017年 焦英博. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface YBPlayerToolView : UIView
@property (weak, nonatomic) IBOutlet UILabel *currentTime;
@property (weak, nonatomic) IBOutlet UILabel *totalTime;
@property (weak, nonatomic) IBOutlet UIButton *playButton;
@property (weak, nonatomic) IBOutlet UIButton *fullButton;
@property (weak, nonatomic) IBOutlet UISlider *slider;
@property (weak, nonatomic) IBOutlet UIProgressView *progressView;
+ (instancetype)instanceView;
@end
|
#ifndef GUI_H
#define GUI_H
#include "../Primitive/Primitive.h"
#include "../../ResourceLoading/Texture/Texture.h"
namespace b2d{
// GUI Button Class
class GUIButton : private Square{
public:
// Constructors
GUIButton();
GUIButton (float X, float Y, int Width, int Height, char* TexNorm, char* TexOver, RGBA Colour = RGBA (1.0f, 1.0f, 1.0f, 1.0f));
// Functions
using Square::Move;
using Square::Translate;
using Square::Scale;
void Update();
void Draw();
bool GetClick();
bool GetOver();
void SwapTexture (char* TexNorm, char* TexOver);
void Reload (float X, float Y, int Width, int Height, char* TexNorm, char* TexOver, RGBA Colour = RGBA (1.0f, 1.0f, 1.0f, 1.0f));
void Destroy();
// Variables
using Square::position;
using Square::rotation;
using Square::canRender;
using Square::colour;
bool isClicked;
private:
// Variables
unsigned int glTexNorm;
unsigned int glTexOver;
unsigned int vboID;
Vector2::Point oldVerts[4];
};
}
#endif |
/* threadless.io
* Copyright (c) 2016 Justin R. Cutler
* Licensed under the MIT License. See LICENSE file in the project root for
* full license information.
*/
/** @file
* heap interface definition
* @author Justin R. Cutler <justin.r.cutler@gmail.com>
*/
#ifndef THREADLESS_HEAP_H
#define THREADLESS_HEAP_H
/* size_t, NULL */
#include <stddef.h>
/* allocation_t, allocator_t, allocation_init */
#include <threadless/allocation.h>
/** Heap descriptor type */
typedef struct heap heap_t;
/** Heap node type */
typedef struct {
/** Back-pointer to containing heap */
heap_t *heap;
/** Current index within @p heap */
size_t index;
} heap_node_t;
/** Heap node comparison function type
* @param[in] a first node
* @param[in] b second node
* @retval >0 @p a is "better" than @p b
* @retval 0 @p a is equivalent to @p b
* @retval <0 @p a is "worse" than @p b
*/
typedef int (heap_compare_function_t)(const heap_node_t *a,
const heap_node_t *b);
/** Heap descriptor structure */
struct heap {
/** Heap node pointer storage */
allocation_t allocation;
/** Number of nodes in heap */
size_t count;
/** Heap node comparison function */
heap_compare_function_t *compare;
};
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/** Initialize a heap descriptor
* @param[out] heap heap to initialize
* @param allocator allocator instance
* @param compare comparison function
* @post @p heap represents an empty heap with given @p compare function
*/
static inline void heap_init(heap_t *heap, allocator_t *allocator,
heap_compare_function_t *compare)
{
allocation_init(&heap->allocation, allocator);
heap->count = 0;
heap->compare = compare;
}
/** Peek at the "best" node in @p heap
* @param[in] heap heap
* @retval NULL @p heap is empty
* @retval non-NULL pointer to "best" node in @p heap
*/
static inline heap_node_t *heap_peek(const heap_t *heap)
{
heap_node_t **storage = heap->count ? heap->allocation.memory : NULL;
return storage ? *storage : NULL;
}
/** Push a @p node into @p heap
* @param[in,out] heap heap
* @param[in,out] node node
* @retval 0 success
* @retval -1 error
*/
int heap_push(heap_t *heap, heap_node_t *node);
/** Replace an existing @p old node in a heap with a new @p node
* @param[in,out] old old node
* @param[in,out] node new node
* @pre @p old must be in a heap
* @post @p old is no longer in a heap
* @post @p node is in the heap that previously contained @p old
*/
void heap_replace(heap_node_t *old, heap_node_t *node);
/** Remove an arbitrary @p node from its heap
* @param[in,out] node node
* @pre @p node must be in a heap
* @post @p node is no longer in a heap
*/
void heap_remove(heap_node_t *node);
/** Remove and return the "best" node in @p heap
* @param[in,out] heap heap
* @retval NULL @p heap was empty
* @retval non-NULL pointer to removed "best" node from @p heap
*/
heap_node_t *heap_pop(heap_t *heap);
/** Finalize a heap
* @param[in,out] heap heap
* @post All nodes have been removed from @p heap and all backing memory has
* been released
*/
void heap_fini(heap_t *heap);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* THREADLESS_HEAP_H */
|
//
// ringbuffer.h
// Firedrake
//
// Created by Sidney Just
// Copyright (c) 2012 by Sidney Just
// 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 _RINGBUFFER_H_
#define _RINGBUFFER_H_
#include <types.h>
typedef struct
{
uint8_t *buffer;
uint8_t *bufferLimit;
uint8_t *begin;
uint8_t *end;
size_t size;
size_t count;
} ringbuffer_t;
ringbuffer_t *ringbuffer_create(size_t size);
void ringbuffer_destroy(ringbuffer_t *ringbuffer);
void ringbuffer_write(ringbuffer_t *ringbuffer, uint8_t *data, size_t size);
size_t ringbuffer_read(ringbuffer_t *ringbuffer, uint8_t *buffer, size_t size);
size_t ringbuffer_length(ringbuffer_t *ringbuffer);
#endif /* _RINGBUFFER_H_ */
|
//
// fs_formats.h
// fast_science
//
//
// Created by Manuel on 20.06.15.
//
//
#ifndef include_fs_formats_h
#define include_fs_formats_h
#include "FastScience/format.h"
#include "FastScience/csvFormat.h"
#include "FastScience/gffFormat.h"
#include "FastScience/bedgraphFormat.h"
#endif
|
/* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE78_OS_Command_Injection__char_connect_socket_w32_spawnlp_53d.c
Label Definition File: CWE78_OS_Command_Injection.strings.label.xml
Template File: sources-sink-53d.tmpl.c
*/
/*
* @description
* CWE: 78 OS Command Injection
* BadSource: connect_socket Read data using a connect socket (client side)
* GoodSource: Fixed string
* Sink: w32_spawnlp
* BadSink : execute command with spawnlp
* Flow Variant: 53 Data flow: data passed as an argument from one function through two others to a fourth; all four functions are in different source files
*
* */
#include "std_testcase.h"
#include <wchar.h>
#ifdef _WIN32
#define COMMAND_INT_PATH "%WINDIR%\\system32\\cmd.exe"
#define COMMAND_INT "cmd.exe"
#define COMMAND_ARG1 "/c"
#define COMMAND_ARG2 "dir"
#define COMMAND_ARG3 data
#else /* NOT _WIN32 */
#include <unistd.h>
#define COMMAND_INT_PATH "/bin/sh"
#define COMMAND_INT "sh"
#define COMMAND_ARG1 "ls"
#define COMMAND_ARG2 "-la"
#define COMMAND_ARG3 data
#endif
#ifdef _WIN32
#include <winsock2.h>
#include <windows.h>
#include <direct.h>
#pragma comment(lib, "ws2_32") /* include ws2_32.lib when linking */
#define CLOSE_SOCKET closesocket
#else /* NOT _WIN32 */
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#define INVALID_SOCKET -1
#define SOCKET_ERROR -1
#define CLOSE_SOCKET close
#define SOCKET int
#endif
#define TCP_PORT 27015
#define IP_ADDRESS "127.0.0.1"
#include <process.h>
/* all the sinks are the same, we just want to know where the hit originated if a tool flags one */
#ifndef OMITBAD
void CWE78_OS_Command_Injection__char_connect_socket_w32_spawnlp_53d_badSink(char * data)
{
/* spawnlp - searches for the location of the command among
* the directories specified by the PATH environment variable */
/* POTENTIAL FLAW: Execute command without validating input possibly leading to command injection */
_spawnlp(_P_WAIT, COMMAND_INT, COMMAND_INT, COMMAND_ARG1, COMMAND_ARG2, COMMAND_ARG3, NULL);
}
#endif /* OMITBAD */
#ifndef OMITGOOD
/* goodG2B uses the GoodSource with the BadSink */
void CWE78_OS_Command_Injection__char_connect_socket_w32_spawnlp_53d_goodG2BSink(char * data)
{
/* spawnlp - searches for the location of the command among
* the directories specified by the PATH environment variable */
/* POTENTIAL FLAW: Execute command without validating input possibly leading to command injection */
_spawnlp(_P_WAIT, COMMAND_INT, COMMAND_INT, COMMAND_ARG1, COMMAND_ARG2, COMMAND_ARG3, NULL);
}
#endif /* OMITGOOD */
|
@interface SVGPathInterpreter : NSObject
{
BOOL _lastCommand; // 8 = 0x8
struct CGPoint _lastPoint; // 16 = 0x10
struct CGPoint _lastControl; // 32 = 0x20
}
+ (id)bezierPathFromPoints:(id)arg1;
+ (id)bezierPathFromCommands:(id)arg1 isPathClosed:(char *)arg2;
@property(nonatomic) BOOL lastCommand; // @synthesize lastCommand=_lastCommand;
@property(nonatomic) struct CGPoint lastControl; // @synthesize lastControl=_lastControl;
@property(nonatomic) struct CGPoint lastPoint; // @synthesize lastPoint=_lastPoint;
- (void)appendAComponents:(id)arg1 toBezierPath:(id)arg2;
- (void)appendaComponents:(id)arg1 toBezierPath:(id)arg2;
- (void)appendvComponents:(id)arg1 toBezierPath:(id)arg2;
- (void)appendhComponents:(id)arg1 toBezierPath:(id)arg2;
- (void)appendVComponents:(id)arg1 toBezierPath:(id)arg2;
- (void)appendHComponents:(id)arg1 toBezierPath:(id)arg2;
- (void)appendsComponents:(id)arg1 toBezierPath:(id)arg2;
- (void)appendTComponents:(id)arg1 toBezierPath:(id)arg2;
- (void)appendtComponents:(id)arg1 toBezierPath:(id)arg2;
- (void)appendQComponents:(id)arg1 toBezierPath:(id)arg2;
- (void)appendqComponents:(id)arg1 toBezierPath:(id)arg2;
- (struct CGPoint)lastControlReflected;
- (void)appendCurveQuadPoint1:(struct CGPoint)arg1 quadPoint2:(struct CGPoint)arg2 toBezierPath:(id)arg3;
- (void)appendcComponents:(id)arg1 toBezierPath:(id)arg2;
- (void)appendlComponents:(id)arg1 toBezierPath:(id)arg2;
- (void)appendmComponents:(id)arg1 toBezierPath:(id)arg2;
- (void)appendSComponents:(id)arg1 toBezierPath:(id)arg2;
- (void)appendCComponents:(id)arg1 toBezierPath:(id)arg2;
- (void)appendLComponents:(id)arg1 toBezierPath:(id)arg2;
- (void)appendMComponents:(id)arg1 toBezierPath:(id)arg2;
- (id)bezierPathFromCommands:(id)arg1 isPathClosed:(char *)arg2;
- (id)bezierPathFromPoints:(id)arg1;
@end
|
//
// EntryListViewController.h
// Logbook
//
// Created by Dulio Denis on 3/27/15.
// Copyright (c) 2015 Dulio Denis. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface EntryListViewController : UITableViewController
@end
|
// -*- C++ -*-
//=============================================================================
/**
* @file IIOP_SSL_Connection_Handler.h
*
* $Id: IIOP_SSL_Connection_Handler.h 935 2008-12-10 21:47:27Z mitza $
*
* @author Ossama Othman <ossama@dre.vanderbilt.edu>
*/
//=============================================================================
#ifndef TAO_IIOP_SSL_CONNECTION_HANDLER_H
#define TAO_IIOP_SSL_CONNECTION_HANDLER_H
#include /**/ "ace/pre.h"
#include "orbsvcs/SSLIOP/SSLIOP_Export.h"
#if !defined (ACE_LACKS_PRAGMA_ONCE)
#pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
#include "orbsvcs/SSLIOP/SSLIOP_Current.h"
#include "orbsvcs/SSLIOPC.h"
#include "tao/IIOP_Connection_Handler.h"
TAO_BEGIN_VERSIONED_NAMESPACE_DECL
namespace TAO
{
/**
* @class IIOP_SSL_Connection_Handler
*
* @brief
* IIOP connection handler designed to be "SSL aware," i.e. it is
* aware of the existence of the SSLIOP connection handler. It
* makes sure that SSL session state from a previous connection is
* not associated with the non-SSL connection handled by this
* handler.
*
* This class is just a place holder to create the
* TAO_IIOP_SSL_Transport which does the work of clearing the TSS
* SSL state.
*/
class IIOP_SSL_Connection_Handler : public TAO_IIOP_Connection_Handler
{
public:
/// Constructor.
IIOP_SSL_Connection_Handler (ACE_Thread_Manager* t = 0);
IIOP_SSL_Connection_Handler (TAO_ORB_Core *orb_core);
/// Destructor.
~IIOP_SSL_Connection_Handler (void);
};
// ****************************************************************
/**
* @class Null_SSL_State_Guard
*
* @brief
* This class sets up null TSS SSL state upon instantiation, and
* restores the previous TSS SSL state when that instance goes out
* of scope.
*
* This guard is used to make TSS SSL state configuration and
* deconfiguration during an upcall exception safe. Exceptions are
* not supposed to be propagated up to the scope this guard is used
* in, so this guard may be unnecessary. However, since proper TSS
* SSL state configuration/deconfiguration is critical to proper
* security support, this guard is used to ensure that
* configuration/deconfiguration is exception safe.
*/
class Null_SSL_State_Guard
{
public:
/// Constructor that sets up the null TSS SSL state.
Null_SSL_State_Guard (TAO::SSLIOP::Current_ptr current,
int &result);
/// Destructor that restores the previous TSS SSL state.
~Null_SSL_State_Guard (void);
private:
/// The SSLIOP::Current implementation that was previously
/// associated with the current thread and invocation.
/**
* It is stored here until the invocation completes, after which
* it placed back into TSS.
*/
TAO::SSLIOP::Current_Impl *previous_current_impl_;
/// Reference to the SSLIOP::Current object.
TAO::SSLIOP::Current_ptr current_;
/// Flag that specifies whether or not setup of the SSLIOP::Current
/// object completed for the current thread and invocation.
bool setup_done_;
};
} // End TAO namespace.
TAO_END_VERSIONED_NAMESPACE_DECL
#if defined (__ACE_INLINE__)
#include "orbsvcs/SSLIOP/IIOP_SSL_Connection_Handler.inl"
#endif /* __ACE_INLINE__ */
#include /**/ "ace/post.h"
#endif /* TAO_IIOP_SSL_CONNECTION_HANDLER_H */
|
/*
* Copyright (c) 2014 by Joern Dinkla, www.dinkla.com, All rights reserved.
*
* See the LICENSE file in the root directory.
*/
#pragma once
#include <cuda_runtime_api.h>
#include "node.h"
#include "CudaExecConfig.h"
#include <thrust/device_vector.h>
__host__ __device__ inline
bool find(const node* n, const int elem)
{
if (n == 0) return false;
if (n->n == elem) return true;
else if (elem < n->n) return find(n->left, elem);
else return find(n->right, elem);
}
void rec_find(
CudaExecConfig cnf,
const node* n,
thrust::device_vector<int>& elems,
thrust::device_vector<bool>& found
);
|
#pragma once
#include "GLee.h"
#include <iostream>
class Shader
{
protected:
static unsigned long getFileLength(std::ifstream& file);
public:
Shader();
~Shader();
static void bind_shader();
static int loadshader(char* filename, GLchar** ShaderSource, unsigned long *len);
static void unloadshader(GLubyte** ShaderSource);
static void compile(GLuint shader_object, UINT8 *msg);
static void link(GLuint vertex_object, GLuint fragment_object, UINT8 *msg);
};
|
/*
* Copyright (c) 2018-2020 Arm Limited.
*
* SPDX-License-Identifier: MIT
*
* 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 ARM_COMPUTE_CLCHANNELSHUFFLELAYERKERNEL_H
#define ARM_COMPUTE_CLCHANNELSHUFFLELAYERKERNEL_H
#include "src/core/CL/ICLKernel.h"
namespace arm_compute
{
class ICLTensor;
/** Interface for the channel shuffle kernel */
class CLChannelShuffleLayerKernel : public ICLKernel
{
public:
/** Default constructor */
CLChannelShuffleLayerKernel();
/** Prevent instances of this class from being copied (As this class contains pointers) */
CLChannelShuffleLayerKernel(const CLChannelShuffleLayerKernel &) = delete;
/** Prevent instances of this class from being copied (As this class contains pointers) */
CLChannelShuffleLayerKernel &operator=(const CLChannelShuffleLayerKernel &) = delete;
/** Allow instances of this class to be moved */
CLChannelShuffleLayerKernel(CLChannelShuffleLayerKernel &&) = default;
/** Allow instances of this class to be moved */
CLChannelShuffleLayerKernel &operator=(CLChannelShuffleLayerKernel &&) = default;
/** Default destructor */
~CLChannelShuffleLayerKernel() = default;
/** Configure function's inputs and outputs.
*
* @param[in] input Input tensor. Data types supported: All.
* @param[out] output Output tensor. Data type supported: Same as @p input
* @param[in] num_groups Number of groups. Must be greater than 1 and the number of channels of the tensors must be a multiple of the number of groups.
*/
void configure(const ICLTensor *input, ICLTensor *output, unsigned int num_groups);
/** Configure function's inputs and outputs.
*
* @param[in] compile_context The compile context to be used.
* @param[in] input Input tensor. Data types supported: All.
* @param[out] output Output tensor. Data type supported: Same as @p input
* @param[in] num_groups Number of groups. Must be greater than 1 and the number of channels of the tensors must be a multiple of the number of groups.
*/
void configure(const CLCompileContext &compile_context, const ICLTensor *input, ICLTensor *output, unsigned int num_groups);
/** Static function to check if given info will lead to a valid configuration of @ref CLChannelShuffleLayerKernel
*
* @param[in] input Input tensor info. Data types supported: All.
* @param[in] output Output tensor info. Data type supported: Same as @p input
* @param[in] num_groups Number of groups. Must be greater than 1 and the number of channels of the tensors must be a multiple of the number of groups.
*
* @return a status
*/
static Status validate(const ITensorInfo *input, const ITensorInfo *output, unsigned int num_groups);
// Inherited methods overridden:
void run(const Window &window, cl::CommandQueue &queue) override;
private:
const ICLTensor *_input;
ICLTensor *_output;
};
} // namespace arm_compute
#endif /* ARM_COMPUTE_CLCHANNELSHUFFLELAYERKERNEL_H */
|
#ifndef EFFECTS_STARFIELD_H
#define EFFECTS_STARFIELD_H
#include <SFML/Graphics.hpp>
#include <vector>
#include "effect.h"
#include "star.h"
namespace effects
{
/**
* Starfield is an effect that simulates a parralox scrolling starfield.
*/
class Starfield : public Effect
{
public:
/**
* Create a new Starfield instance.
*
* @param window a reference to the render window to draw to
*/
Starfield(sf::RenderWindow &window);
/**
* Update the starfield.
*
* @param elapsed the elapsed time
*/
void update(sf::Time elapsed) override;
/**
* Draw the effect.
*/
void draw() override;
private:
/** Destroy dead stars. */
void remove_dead_stars();
/** Add new stars as required. */
void add_new_stars();
/** Move the stars. */
void move_stars();
/** Update the stars texture. */
void update_stars_texture();
/** Maximum star sizes. */
int max_small_stars_, max_medium_stars_, max_large_stars_;
/** Target window size. */
sf::Vector2u window_size_;
/** Random generators for x and y dimensions. */
std::default_random_engine random_engine_x_, random_engine_y_;
/** Uniform distributions for x and y axis. */
std::uniform_int_distribution<int> distribution_x_, distribution_y_;
/** Stars. */
std::vector<Star> small_stars_, medium_stars_, large_stars_;
/** Star images */
sf::Image stars_image_, small_star_image_, medium_star_image_, large_star_image_;
/** The star texture. */
sf::Texture stars_texture_;
/** The star sprite. */
sf::Sprite stars_sprite_;
};
}
#endif
|
/*
* VB9ListControllers.h
* VolumeBar9
*
* Created by cgm616
* Copyright (c) 2016 cgm616. All rights reserved.
*/
#import <Preferences/PSListController.h>
#import <Preferences/PSSpecifier.h>
#import <libcolorpicker.h>
#import <FrontBoard/FBSystemService.h>
@interface VB9RootListController : PSListController
@end
@interface VB9ChildListController : PSListController
@end
@interface VB9ChildAboutListController : VB9ChildListController
@end
@interface VB9ChildAnimateListController : VB9ChildListController
@end
@interface VB9ChildBannerListController : VB9ChildListController
@end
@interface VB9ChildCreditListController : VB9ChildListController
@end
|
#ifndef STATICFILESERVING_H
#define STATICFILESERVING_H
#include <QObject>
#include <QMimeDatabase>
#include "QtHttpServer.h"
#include "QtHttpRequest.h"
#include "QtHttpReply.h"
#include "QtHttpHeader.h"
#include "CgiHandler.h"
#include <hyperion/Hyperion.h>
#include <utils/Logger.h>
#include <utils/JsonProcessor.h>
class StaticFileServing : public QObject {
Q_OBJECT
public:
explicit StaticFileServing (Hyperion *hyperion, QString baseUrl, quint16 port, QObject * parent = nullptr);
virtual ~StaticFileServing (void);
public slots:
void onServerStopped (void);
void onServerStarted (quint16 port);
void onServerError (QString msg);
void onRequestNeedsReply (QtHttpRequest * request, QtHttpReply * reply);
private:
Hyperion * _hyperion;
QString _baseUrl;
QtHttpServer * _server;
QMimeDatabase * _mimeDb;
CgiHandler _cgi;
Logger * _log;
JsonProcessor * _jsonProcessor;
void printErrorToReply (QtHttpReply * reply, QtHttpReply::StatusCode code, QString errorMessage);
};
#endif // STATICFILESERVING_H
|
//
// InReadScrollViewController.h
// TeadsSDKDemo
//
// Created by Nikolaï Roycourt on 16/01/2015.
// Copyright (c) 2015 Teads. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <TeadsSDK/TeadsNativeVideo.h>
@interface InReadScrollViewController : UIViewController <UIScrollViewDelegate, TeadsNativeVideoDelegate>
@property (strong, nonatomic) IBOutlet UIScrollView *scrollView;
@property (strong, nonatomic) IBOutlet UIView *inReadView;
@end
|
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include <memory.h>
#include <string.h>
#ifdef WEBRTC_ANDROID
#include <stdlib.h>
#endif
#include BOSS_WEBRTC_U_modules__audio_coding__codecs__isac__main__source__pitch_estimator_h //original-code:"modules/audio_coding/codecs/isac/main/source/pitch_estimator.h"
#include BOSS_WEBRTC_U_modules__audio_coding__codecs__isac__main__source__isac_vad_h //original-code:"modules/audio_coding/codecs/isac/main/source/isac_vad.h"
static void WebRtcIsac_AllPoleFilter(double* InOut,
double* Coef,
size_t lengthInOut,
int orderCoef) {
/* the state of filter is assumed to be in InOut[-1] to InOut[-orderCoef] */
double scal;
double sum;
size_t n;
int k;
//if (fabs(Coef[0]-1.0)<0.001) {
if ( (Coef[0] > 0.9999) && (Coef[0] < 1.0001) )
{
for(n = 0; n < lengthInOut; n++)
{
sum = Coef[1] * InOut[-1];
for(k = 2; k <= orderCoef; k++){
sum += Coef[k] * InOut[-k];
}
*InOut++ -= sum;
}
}
else
{
scal = 1.0 / Coef[0];
for(n=0;n<lengthInOut;n++)
{
*InOut *= scal;
for(k=1;k<=orderCoef;k++){
*InOut -= scal*Coef[k]*InOut[-k];
}
InOut++;
}
}
}
static void WebRtcIsac_AllZeroFilter(double* In,
double* Coef,
size_t lengthInOut,
int orderCoef,
double* Out) {
/* the state of filter is assumed to be in In[-1] to In[-orderCoef] */
size_t n;
int k;
double tmp;
for(n = 0; n < lengthInOut; n++)
{
tmp = In[0] * Coef[0];
for(k = 1; k <= orderCoef; k++){
tmp += Coef[k] * In[-k];
}
*Out++ = tmp;
In++;
}
}
static void WebRtcIsac_ZeroPoleFilter(double* In,
double* ZeroCoef,
double* PoleCoef,
size_t lengthInOut,
int orderCoef,
double* Out) {
/* the state of the zero section is assumed to be in In[-1] to In[-orderCoef] */
/* the state of the pole section is assumed to be in Out[-1] to Out[-orderCoef] */
WebRtcIsac_AllZeroFilter(In,ZeroCoef,lengthInOut,orderCoef,Out);
WebRtcIsac_AllPoleFilter(Out,PoleCoef,lengthInOut,orderCoef);
}
void WebRtcIsac_AutoCorr(double* r, const double* x, size_t N, size_t order) {
size_t lag, n;
double sum, prod;
const double *x_lag;
for (lag = 0; lag <= order; lag++)
{
sum = 0.0f;
x_lag = &x[lag];
prod = x[0] * x_lag[0];
for (n = 1; n < N - lag; n++) {
sum += prod;
prod = x[n] * x_lag[n];
}
sum += prod;
r[lag] = sum;
}
}
static void WebRtcIsac_BwExpand(double* out,
double* in,
double coef,
size_t length) {
size_t i;
double chirp;
chirp = coef;
out[0] = in[0];
for (i = 1; i < length; i++) {
out[i] = chirp * in[i];
chirp *= coef;
}
}
void WebRtcIsac_WeightingFilter(const double* in,
double* weiout,
double* whiout,
WeightFiltstr* wfdata) {
double tmpbuffer[PITCH_FRAME_LEN + PITCH_WLPCBUFLEN];
double corr[PITCH_WLPCORDER+1], rc[PITCH_WLPCORDER+1];
double apol[PITCH_WLPCORDER+1], apolr[PITCH_WLPCORDER+1];
double rho=0.9, *inp, *dp, *dp2;
double whoutbuf[PITCH_WLPCBUFLEN + PITCH_WLPCORDER];
double weoutbuf[PITCH_WLPCBUFLEN + PITCH_WLPCORDER];
double *weo, *who, opol[PITCH_WLPCORDER+1], ext[PITCH_WLPCWINLEN];
int k, n, endpos, start;
/* Set up buffer and states */
memcpy(tmpbuffer, wfdata->buffer, sizeof(double) * PITCH_WLPCBUFLEN);
memcpy(tmpbuffer+PITCH_WLPCBUFLEN, in, sizeof(double) * PITCH_FRAME_LEN);
memcpy(wfdata->buffer, tmpbuffer+PITCH_FRAME_LEN, sizeof(double) * PITCH_WLPCBUFLEN);
dp=weoutbuf;
dp2=whoutbuf;
for (k=0;k<PITCH_WLPCORDER;k++) {
*dp++ = wfdata->weostate[k];
*dp2++ = wfdata->whostate[k];
opol[k]=0.0;
}
opol[0]=1.0;
opol[PITCH_WLPCORDER]=0.0;
weo=dp;
who=dp2;
endpos=PITCH_WLPCBUFLEN + PITCH_SUBFRAME_LEN;
inp=tmpbuffer + PITCH_WLPCBUFLEN;
for (n=0; n<PITCH_SUBFRAMES; n++) {
/* Windowing */
start=endpos-PITCH_WLPCWINLEN;
for (k=0; k<PITCH_WLPCWINLEN; k++) {
ext[k]=wfdata->window[k]*tmpbuffer[start+k];
}
/* Get LPC polynomial */
WebRtcIsac_AutoCorr(corr, ext, PITCH_WLPCWINLEN, PITCH_WLPCORDER);
corr[0]=1.01*corr[0]+1.0; /* White noise correction */
WebRtcIsac_LevDurb(apol, rc, corr, PITCH_WLPCORDER);
WebRtcIsac_BwExpand(apolr, apol, rho, PITCH_WLPCORDER+1);
/* Filtering */
WebRtcIsac_ZeroPoleFilter(inp, apol, apolr, PITCH_SUBFRAME_LEN, PITCH_WLPCORDER, weo);
WebRtcIsac_ZeroPoleFilter(inp, apolr, opol, PITCH_SUBFRAME_LEN, PITCH_WLPCORDER, who);
inp+=PITCH_SUBFRAME_LEN;
endpos+=PITCH_SUBFRAME_LEN;
weo+=PITCH_SUBFRAME_LEN;
who+=PITCH_SUBFRAME_LEN;
}
/* Export filter states */
for (k=0;k<PITCH_WLPCORDER;k++) {
wfdata->weostate[k]=weoutbuf[PITCH_FRAME_LEN+k];
wfdata->whostate[k]=whoutbuf[PITCH_FRAME_LEN+k];
}
/* Export output data */
memcpy(weiout, weoutbuf+PITCH_WLPCORDER, sizeof(double) * PITCH_FRAME_LEN);
memcpy(whiout, whoutbuf+PITCH_WLPCORDER, sizeof(double) * PITCH_FRAME_LEN);
}
|
#pragma once
#include "afxwin.h"
class CNewMenu :
public CMenu
{
public:
CNewMenu(void);
~CNewMenu(void);
virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
virtual void MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct);
void ChangeMenuItem(CMenu *pMenu);
void SetWith(int with);
private:
int with;
vector<CString *> m_relea;
};
|
#pragma once
// Named Property Cache
namespace cache
{
struct NamePropNames
{
std::wstring name;
std::wstring guid;
std::wstring dasl;
std::wstring bestPidLid;
std::wstring otherPidLid;
};
class namedPropCacheEntry
{
public:
namedPropCacheEntry(const MAPINAMEID* lpPropName, ULONG _ulPropID, _In_ const std::vector<BYTE>& _sig = {});
// Disables making copies of NamedPropCacheEntry
namedPropCacheEntry(const namedPropCacheEntry&) = delete;
namedPropCacheEntry& operator=(const namedPropCacheEntry&) = delete;
static std::shared_ptr<namedPropCacheEntry>& empty() noexcept
{
static std::shared_ptr<namedPropCacheEntry> _empty = std::make_shared<namedPropCacheEntry>(nullptr, 0);
return _empty;
}
_Check_return_ inline static std::shared_ptr<cache::namedPropCacheEntry>
make(const MAPINAMEID* lpPropName, ULONG _ulPropID, _In_ const std::vector<BYTE>& _sig = {})
{
return std::make_shared<cache::namedPropCacheEntry>(lpPropName, _ulPropID, _sig);
}
static inline bool valid(std::shared_ptr<cache::namedPropCacheEntry> item) noexcept
{
return item && item->ulPropID && item->ulPropID != PT_ERROR &&
(item->mapiNameId.Kind.lID || item->mapiNameId.Kind.lpwstrName);
}
ULONG getPropID() const noexcept { return ulPropID; }
const NamePropNames& getNamePropNames() const noexcept { return namePropNames; }
void setNamePropNames(const NamePropNames& _namePropNames) noexcept
{
namePropNames = _namePropNames;
bStringsCached = true;
}
bool hasCachedStrings() const noexcept { return bStringsCached; }
const MAPINAMEID* getMapiNameId() const noexcept { return &mapiNameId; }
void setSig(const std::vector<BYTE>& _sig) { sig = _sig; }
_Check_return_ bool
match(const std::shared_ptr<namedPropCacheEntry>& entry, bool bMatchID, bool bMatchName) const;
// Compare given a signature, MAPINAMEID
_Check_return_ bool match(_In_ const std::vector<BYTE>& _sig, _In_ const MAPINAMEID& _mapiNameId) const;
// Compare given a signature and property ID (ulPropID)
_Check_return_ bool match(_In_ const std::vector<BYTE>& _sig, ULONG _ulPropID) const;
// Compare given a id, MAPINAMEID
_Check_return_ bool match(ULONG _ulPropID, _In_ const MAPINAMEID& _mapiNameId) const noexcept;
void output() const;
private:
ULONG ulPropID{}; // MAPI ID (ala PROP_ID) for a named property
MAPINAMEID mapiNameId{}; // guid, kind, value
GUID guid{};
std::wstring name{};
std::vector<BYTE> sig{}; // Value of PR_MAPPING_SIGNATURE
NamePropNames namePropNames{};
bool bStringsCached{}; // We have cached strings
};
constexpr ULONG __LOWERBOUND = 0x8000;
constexpr ULONG __UPPERBOUND = 0xFFFF;
_Check_return_ std::shared_ptr<namedPropCacheEntry>
GetNameFromID(_In_ const LPMAPIPROP lpMAPIProp, _In_opt_ const SBinary* sig, _In_ ULONG ulPropTag, ULONG ulFlags);
_Check_return_ std::shared_ptr<namedPropCacheEntry>
GetNameFromID(_In_ const LPMAPIPROP lpMAPIProp, _In_ ULONG ulPropTag, ULONG ulFlags);
// No signature form: look up and use signature if possible
_Check_return_ std::vector<std::shared_ptr<namedPropCacheEntry>>
GetNamesFromIDs(_In_opt_ const LPMAPIPROP lpMAPIProp, _In_opt_ LPSPropTagArray lpPropTags, ULONG ulFlags);
// Signature form: if signature not passed then do not use a signature
_Check_return_ std::vector<std::shared_ptr<namedPropCacheEntry>> GetNamesFromIDs(
_In_opt_ const LPMAPIPROP lpMAPIProp,
_In_opt_ const SBinary* sig,
_In_opt_ LPSPropTagArray lpPropTags,
ULONG ulFlags);
_Check_return_ LPSPropTagArray
GetIDsFromNames(_In_ const LPMAPIPROP lpMAPIProp, _In_ std::vector<MAPINAMEID> nameIDs, _In_ ULONG ulFlags);
NamePropNames NameIDToStrings(
ULONG ulPropTag, // optional 'original' prop tag
_In_opt_ LPMAPIPROP lpMAPIProp, // optional source object
_In_opt_ const MAPINAMEID* lpNameID, // optional named property information to avoid GetNamesFromIDs call
_In_opt_ const SBinary* sig, // optional mapping signature for object to speed named prop lookups
bool bIsAB); // true for an address book property (they can be > 8000 and not named props)
std::vector<std::wstring> NameIDToPropNames(_In_opt_ const MAPINAMEID* lpNameID);
ULONG FindHighestNamedProp(_In_ LPMAPIPROP lpMAPIProp);
_Check_return_ std::shared_ptr<namedPropCacheEntry> find(
const std::vector<std::shared_ptr<namedPropCacheEntry>>& list,
const std::function<bool(const std::shared_ptr<namedPropCacheEntry>&)>& compare);
} // namespace cache |
#import <Cocoa/Cocoa.h>
@interface NSFont (UltraLight)
/**
Returns the same font as the receiver but with an Ultra Light weight, if available.
If an Ultra Light variant is not available, this method returns the receiver.
@return An Ultra Light variant of the receiver if available, or the receiver if an
Ultra Light variant is not available.
*/
- (NSFont * _Nonnull)aha_ultraLightVariant;
@end
|
// 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 SAMPLE_CHARACTER_CLOTH_FLAG_H
#define SAMPLE_CHARACTER_CLOTH_FLAG_H
#include "cloth/PxCloth.h"
#include "PhysXSample.h"
class SampleCharacterCloth;
class RenderClothActor;
class SampleCharacterClothFlag
{
public:
SampleCharacterClothFlag(SampleCharacterCloth& sample, const PxTransform &pose, PxU32 resX, PxU32 resY, PxReal sizeX, PxReal sizeY, PxReal height);
void setWind(const PxVec3 &dir, PxReal strength, const PxVec3& range);
void update(PxReal dtime);
void release();
PxCloth* getCloth() { return mCloth; }
protected:
RenderClothActor* mRenderActor;
SampleCharacterCloth& mSample;
PxCloth* mCloth;
SampleArray<PxVec2> mUVs;
PxVec3 mWindDir;
PxVec3 mWindRange;
PxReal mWindStrength;
PxReal mTime;
PxRigidDynamic* mCapsuleActor;
private:
SampleCharacterClothFlag& operator=(const SampleCharacterClothFlag&);
};
#endif
|
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2013 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef DIAMOND_TXMEMPOOL_H
#define DIAMOND_TXMEMPOOL_H
#include <list>
#include "coins.h"
#include "core.h"
#include "sync.h"
inline bool AllowFree(double dPriority)
{
// Large (in bytes) low-priority (new, small-coin) transactions
// need a fee.
return dPriority > COIN * 144 / 250;
}
/** Fake height value used in CCoins to signify they are only in the memory pool (since 0.8) */
static const unsigned int MEMPOOL_HEIGHT = 0x7FFFFFFF;
/*
* CTxMemPool stores these:
*/
class CTxMemPoolEntry
{
private:
CTransaction tx;
CAmount nFee; // Cached to avoid expensive parent-transaction lookups
size_t nTxSize; // ... and avoid recomputing tx size
size_t nModSize; // ... and modified size for priority
int64_t nTime; // Local time when entering the mempool
double dPriority; // Priority when entering the mempool
unsigned int nHeight; // Chain height when entering the mempool
public:
CTxMemPoolEntry(const CTransaction& _tx, const CAmount& _nFee,
int64_t _nTime, double _dPriority, unsigned int _nHeight);
CTxMemPoolEntry();
CTxMemPoolEntry(const CTxMemPoolEntry& other);
const CTransaction& GetTx() const { return this->tx; }
double GetPriority(unsigned int currentHeight) const;
CAmount GetFee() const { return nFee; }
size_t GetTxSize() const { return nTxSize; }
int64_t GetTime() const { return nTime; }
unsigned int GetHeight() const { return nHeight; }
};
class CMinerPolicyEstimator;
/*
* CTxMemPool stores valid-according-to-the-current-best-chain
* transactions that may be included in the next block.
*
* Transactions are added when they are seen on the network
* (or created by the local node), but not all transactions seen
* are added to the pool: if a new transaction double-spends
* an input of a transaction in the pool, it is dropped,
* as are non-standard transactions.
*/
class CTxMemPool
{
private:
bool fSanityCheck; // Normally false, true if -checkmempool or -regtest
unsigned int nTransactionsUpdated;
CMinerPolicyEstimator* minerPolicyEstimator;
CFeeRate minRelayFee; // Passed to constructor to avoid dependency on main
uint64_t totalTxSize; // sum of all mempool tx' byte sizes
public:
mutable CCriticalSection cs;
std::map<uint256, CTxMemPoolEntry> mapTx;
std::map<COutPoint, CInPoint> mapNextTx;
std::map<uint256, std::pair<double, CAmount> > mapDeltas;
CTxMemPool(const CFeeRate& _minRelayFee);
~CTxMemPool();
/*
* If sanity-checking is turned on, check makes sure the pool is
* consistent (does not contain two transactions that spend the same inputs,
* all inputs are in the mapNextTx array). If sanity-checking is turned off,
* check does nothing.
*/
void check(const CCoinsViewCache *pcoins) const;
void setSanityCheck(bool _fSanityCheck) { fSanityCheck = _fSanityCheck; }
bool addUnchecked(const uint256& hash, const CTxMemPoolEntry &entry);
void remove(const CTransaction &tx, std::list<CTransaction>& removed, bool fRecursive = false);
void removeConflicts(const CTransaction &tx, std::list<CTransaction>& removed);
void removeForBlock(const std::vector<CTransaction>& vtx, unsigned int nBlockHeight,
std::list<CTransaction>& conflicts);
void clear();
void queryHashes(std::vector<uint256>& vtxid);
void pruneSpent(const uint256& hash, CCoins &coins);
unsigned int GetTransactionsUpdated() const;
void AddTransactionsUpdated(unsigned int n);
/** Affect CreateNewBlock prioritisation of transactions */
void PrioritiseTransaction(const uint256 hash, const std::string strHash, double dPriorityDelta, const CAmount& nFeeDelta);
void ApplyDeltas(const uint256 hash, double &dPriorityDelta, CAmount &nFeeDelta);
void ClearPrioritisation(const uint256 hash);
unsigned long size()
{
LOCK(cs);
return mapTx.size();
}
uint64_t GetTotalTxSize()
{
LOCK(cs);
return totalTxSize;
}
bool exists(uint256 hash)
{
LOCK(cs);
return (mapTx.count(hash) != 0);
}
bool lookup(uint256 hash, CTransaction& result) const;
// Estimate fee rate needed to get into the next
// nBlocks
CFeeRate estimateFee(int nBlocks) const;
// Estimate priority needed to get into the next
// nBlocks
double estimatePriority(int nBlocks) const;
// Write/Read estimates to disk
bool WriteFeeEstimates(CAutoFile& fileout) const;
bool ReadFeeEstimates(CAutoFile& filein);
};
/** CCoinsView that brings transactions from a memorypool into view.
It does not check for spendings by memory pool transactions. */
class CCoinsViewMemPool : public CCoinsViewBacked
{
protected:
CTxMemPool &mempool;
public:
CCoinsViewMemPool(CCoinsView *baseIn, CTxMemPool &mempoolIn);
bool GetCoins(const uint256 &txid, CCoins &coins) const;
bool HaveCoins(const uint256 &txid) const;
};
#endif // DIAMOND_TXMEMPOOL_H
|
#ifndef LOGDATABASE_H
#define LOGDATABASE_H
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <sstream>
#include <time.h>
#include <sqlite3.h>
using namespace std;
class LogDatabase {
public:
static sqlite3 *database;
static const char *path;
static void InitDatabase(const char *path);
static void OpenLog();
static void CloseLog();
static void CreateLogTable();
static void DropLogTable();
static void ClearLogTable();
static void InsertLog(string name, string channel, string log);
static string LastSeen(string name);
static string GetLog();
private:
};
#endif
|
// Copyright (c) 2014 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#ifndef SHELL_BROWSER_UI_X_WINDOW_STATE_WATCHER_H_
#define SHELL_BROWSER_UI_X_WINDOW_STATE_WATCHER_H_
#include "ui/events/platform/x11/x11_event_source.h"
#include "ui/gfx/x/event.h"
#include "shell/browser/native_window_views.h"
namespace electron {
class WindowStateWatcher : public x11::EventObserver {
public:
explicit WindowStateWatcher(NativeWindowViews* window);
~WindowStateWatcher() override;
protected:
// x11::EventObserver:
void OnEvent(const x11::Event& x11_event) override;
private:
bool IsWindowStateEvent(const x11::Event& x11_event) const;
NativeWindowViews* window_;
gfx::AcceleratedWidget widget_;
const x11::Atom net_wm_state_atom_;
const x11::Atom net_wm_state_hidden_atom_;
const x11::Atom net_wm_state_maximized_vert_atom_;
const x11::Atom net_wm_state_maximized_horz_atom_;
const x11::Atom net_wm_state_fullscreen_atom_;
DISALLOW_COPY_AND_ASSIGN(WindowStateWatcher);
};
} // namespace electron
#endif // SHELL_BROWSER_UI_X_WINDOW_STATE_WATCHER_H_
|
#import "WMFGeometry.h"
#include <CoreGraphics/CGAffineTransform.h>
#pragma mark - Aggregate Operations
CGRect WMFConvertAndNormalizeCGRectUsingSize(CGRect rect, CGSize size) {
CGAffineTransform normalizeAndConvertTransform =
CGAffineTransformConcat(WMFAffineCoreGraphicsToUIKitTransformMake(size),
WMFAffineNormalizeTransformMake(size));
return CGRectApplyAffineTransform(rect, normalizeAndConvertTransform);
}
#pragma mark - Normalization
CGRect WMFNormalizeRectUsingSize(CGRect rect, CGSize size) {
if (CGSizeEqualToSize(size, CGSizeZero) || CGRectIsEmpty(rect)) {
return CGRectZero;
}
return CGRectApplyAffineTransform(rect, WMFAffineNormalizeTransformMake(size));
}
CGRect WMFDenormalizeRectUsingSize(CGRect rect, CGSize size) {
if (CGSizeEqualToSize(size, CGSizeZero) || CGRectIsEmpty(rect)) {
return CGRectZero;
}
return CGRectApplyAffineTransform(rect, WMFAffineDenormalizeTransformMake(size));
}
#pragma mark - Normalization Transforms
CGAffineTransform WMFAffineNormalizeTransformMake(CGSize size) {
if (CGSizeEqualToSize(size, CGSizeZero)) {
return CGAffineTransformIdentity;
}
return CGAffineTransformMakeScale(1.0f / size.width, 1.0f / size.height);
}
CGAffineTransform WMFAffineDenormalizeTransformMake(CGSize size) {
return CGAffineTransformInvert(WMFAffineNormalizeTransformMake(size));
}
#pragma mark - Coordinate System Conversions
CGRect WMFConvertCGCoordinateRectToUICoordinateRectUsingSize(CGRect cgRect, CGSize size) {
return CGRectApplyAffineTransform(cgRect, WMFAffineCoreGraphicsToUIKitTransformMake(size));
}
CGRect WMFConvertUICoordinateRectToCGCoordinateRectUsingSize(CGRect uiRect, CGSize size) {
return CGRectApplyAffineTransform(uiRect, WMFAffineUIKitToCoreGraphicsTransformMake(size));
}
#pragma mark - Coordinate System Conversion Transforms
CGAffineTransform WMFAffineCoreGraphicsToUIKitTransformMake(CGSize size) {
if (CGSizeEqualToSize(size, CGSizeZero)) {
return CGAffineTransformIdentity;
}
CGAffineTransform transform = CGAffineTransformMakeScale(1, -1);
return CGAffineTransformTranslate(transform, 0, -size.height);
}
CGAffineTransform WMFAffineUIKitToCoreGraphicsTransformMake(CGSize size) {
return CGAffineTransformInvert(WMFAffineCoreGraphicsToUIKitTransformMake(size));
}
|
// Soln for csse2310-ass3 By Joel Fenwick
#ifndef DECK_H
#define DECK_H
#include <stdio.h>
#include <stdbool.h>
/* Declaration of a deck */
typedef struct deckstruct {
// Has array of 20 cards
char cards[20];
// Has a size
unsigned size;
// The current card (number)
unsigned current;
// The card set aside at beginning
char aside;
// The next deck
struct deckstruct* next;
} deck_t;
/* Linked List */
typedef struct {
deck_t* head;
deck_t* tail;
deck_t* current;
} decks_t;
bool load_deck(deck_t* d, FILE* f);
void free_deck(deck_t* d);
char draw_card(deck_t* d, int current);
char get_leftover(deck_t* d);
bool deck_empty(deck_t* d, int current);
void reset_deck(deck_t* d);
decks_t* copy(decks_t* copyDeck);
decks_t* alloc_decklist();
// missed opportunity to call this clear_decks
void free_decklist(decks_t* d);
bool add_deck(decks_t* d, FILE* f);
deck_t* get_deck(decks_t* d);
#endif
|
/* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE78_OS_Command_Injection__wchar_t_console_system_15.c
Label Definition File: CWE78_OS_Command_Injection.one_string.label.xml
Template File: sources-sink-15.tmpl.c
*/
/*
* @description
* CWE: 78 OS Command Injection
* BadSource: console Read input from the console
* GoodSource: Fixed string
* Sink: system
* BadSink : Execute command in data using system()
* Flow Variant: 15 Control flow: switch(6)
*
* */
#include "std_testcase.h"
#include <wchar.h>
#ifdef _WIN32
#define FULL_COMMAND L"%WINDIR%\\system32\\cmd.exe /c dir "
#else
#include <unistd.h>
#define FULL_COMMAND L"/bin/sh ls -la "
#endif
#ifdef _WIN32
#define SYSTEM _wsystem
#else /* NOT _WIN32 */
#define SYSTEM system
#endif
#ifndef OMITBAD
void CWE78_OS_Command_Injection__wchar_t_console_system_15_bad()
{
wchar_t * data;
wchar_t data_buf[100] = FULL_COMMAND;
data = data_buf;
switch(6)
{
case 6:
{
/* Read input from the console */
size_t dataLen = wcslen(data);
/* if there is room in data, read into it from the console */
if (100-dataLen > 1)
{
/* POTENTIAL FLAW: Read data from the console */
if (fgetws(data+dataLen, (int)(100-dataLen), stdin) != NULL)
{
/* The next few lines remove the carriage return from the string that is
* inserted by fgetws() */
dataLen = wcslen(data);
if (dataLen > 0 && data[dataLen-1] == L'\n')
{
data[dataLen-1] = L'\0';
}
}
else
{
printLine("fgetws() failed");
/* Restore NUL terminator if fgetws fails */
data[dataLen] = L'\0';
}
}
}
break;
default:
/* INCIDENTAL: CWE 561 Dead Code, the code below will never run */
printLine("Benign, fixed string");
break;
}
/* POTENTIAL FLAW: Execute command in data possibly leading to command injection */
if (SYSTEM(data) <= 0)
{
printLine("command execution failed!");
exit(1);
}
}
#endif /* OMITBAD */
#ifndef OMITGOOD
/* goodG2B1() - use goodsource and badsink by changing the switch to switch(5) */
static void goodG2B1()
{
wchar_t * data;
wchar_t data_buf[100] = FULL_COMMAND;
data = data_buf;
switch(5)
{
case 6:
/* INCIDENTAL: CWE 561 Dead Code, the code below will never run */
printLine("Benign, fixed string");
break;
default:
/* FIX: Append a fixed string to data (not user / external input) */
wcscat(data, L"*.*");
break;
}
/* POTENTIAL FLAW: Execute command in data possibly leading to command injection */
if (SYSTEM(data) <= 0)
{
printLine("command execution failed!");
exit(1);
}
}
/* goodG2B2() - use goodsource and badsink by reversing the blocks in the switch */
static void goodG2B2()
{
wchar_t * data;
wchar_t data_buf[100] = FULL_COMMAND;
data = data_buf;
switch(6)
{
case 6:
/* FIX: Append a fixed string to data (not user / external input) */
wcscat(data, L"*.*");
break;
default:
/* INCIDENTAL: CWE 561 Dead Code, the code below will never run */
printLine("Benign, fixed string");
break;
}
/* POTENTIAL FLAW: Execute command in data possibly leading to command injection */
if (SYSTEM(data) <= 0)
{
printLine("command execution failed!");
exit(1);
}
}
void CWE78_OS_Command_Injection__wchar_t_console_system_15_good()
{
goodG2B1();
goodG2B2();
}
#endif /* OMITGOOD */
/* Below is the main(). It is only used when building this testcase on
* its own for testing or for building a binary to use in testing binary
* analysis tools. It is not used when compiling all the testcases as one
* application, which is how source code analysis tools are tested.
*/
#ifdef INCLUDEMAIN
int main(int argc, char * argv[])
{
/* seed randomness */
srand( (unsigned)time(NULL) );
#ifndef OMITGOOD
printLine("Calling good()...");
CWE78_OS_Command_Injection__wchar_t_console_system_15_good();
printLine("Finished good()");
#endif /* OMITGOOD */
#ifndef OMITBAD
printLine("Calling bad()...");
CWE78_OS_Command_Injection__wchar_t_console_system_15_bad();
printLine("Finished bad()");
#endif /* OMITBAD */
return 0;
}
#endif
|
/* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE761_Free_Pointer_Not_at_Start_of_Buffer__char_file_64a.c
Label Definition File: CWE761_Free_Pointer_Not_at_Start_of_Buffer.label.xml
Template File: source-sinks-64a.tmpl.c
*/
/*
* @description
* CWE: 761 Free Pointer not at Start of Buffer
* BadSource: file Read input from a file
* Sinks:
* GoodSink: free() memory correctly at the start of the buffer
* BadSink : free() memory not at the start of the buffer
* Flow Variant: 64 Data flow: void pointer to data passed from one function to another in different source files
*
* */
#include "std_testcase.h"
#include <wchar.h>
#ifdef _WIN32
#define FILENAME "C:\\temp\\file.txt"
#else
#define FILENAME "/tmp/file.txt"
#endif
#define SEARCH_CHAR 'S'
#ifndef OMITBAD
/* bad function declaration */
void CWE761_Free_Pointer_Not_at_Start_of_Buffer__char_file_64b_badSink(void * dataVoidPtr);
void CWE761_Free_Pointer_Not_at_Start_of_Buffer__char_file_64_bad()
{
char * data;
data = (char *)malloc(100*sizeof(char));
data[0] = '\0';
{
/* Read input from a file */
size_t dataLen = strlen(data);
FILE * pFile;
/* if there is room in data, attempt to read the input from a file */
if (100-dataLen > 1)
{
pFile = fopen(FILENAME, "r");
if (pFile != NULL)
{
/* POTENTIAL FLAW: Read data from a file */
if (fgets(data+dataLen, (int)(100-dataLen), pFile) == NULL)
{
printLine("fgets() failed");
/* Restore NUL terminator if fgets fails */
data[dataLen] = '\0';
}
fclose(pFile);
}
}
}
CWE761_Free_Pointer_Not_at_Start_of_Buffer__char_file_64b_badSink(&data);
}
#endif /* OMITBAD */
#ifndef OMITGOOD
/* goodB2G uses the BadSource with the GoodSink */
void CWE761_Free_Pointer_Not_at_Start_of_Buffer__char_file_64b_goodB2GSink(void * dataVoidPtr);
static void goodB2G()
{
char * data;
data = (char *)malloc(100*sizeof(char));
data[0] = '\0';
{
/* Read input from a file */
size_t dataLen = strlen(data);
FILE * pFile;
/* if there is room in data, attempt to read the input from a file */
if (100-dataLen > 1)
{
pFile = fopen(FILENAME, "r");
if (pFile != NULL)
{
/* POTENTIAL FLAW: Read data from a file */
if (fgets(data+dataLen, (int)(100-dataLen), pFile) == NULL)
{
printLine("fgets() failed");
/* Restore NUL terminator if fgets fails */
data[dataLen] = '\0';
}
fclose(pFile);
}
}
}
CWE761_Free_Pointer_Not_at_Start_of_Buffer__char_file_64b_goodB2GSink(&data);
}
void CWE761_Free_Pointer_Not_at_Start_of_Buffer__char_file_64_good()
{
goodB2G();
}
#endif /* OMITGOOD */
/* Below is the main(). It is only used when building this testcase on
its own for testing or for building a binary to use in testing binary
analysis tools. It is not used when compiling all the testcases as one
application, which is how source code analysis tools are tested. */
#ifdef INCLUDEMAIN
int main(int argc, char * argv[])
{
/* seed randomness */
srand( (unsigned)time(NULL) );
#ifndef OMITGOOD
printLine("Calling good()...");
CWE761_Free_Pointer_Not_at_Start_of_Buffer__char_file_64_good();
printLine("Finished good()");
#endif /* OMITGOOD */
#ifndef OMITBAD
printLine("Calling bad()...");
CWE761_Free_Pointer_Not_at_Start_of_Buffer__char_file_64_bad();
printLine("Finished bad()");
#endif /* OMITBAD */
return 0;
}
#endif
|
#include <stdio.h>
#include <math.h>
#include "meh.h"
#define PI 3.14159265
// comment
int unum = 1;
int scalar (int a, int b) {
int array[10];
for (int i = 0; i < 10; i++) {
if (a < b) a -= b;
array[i] = a;
}
/***********
* comment *
***********/
if (a > b) {
a /= b - unum * 2 - (4 <= a - b);
int j = 10;
int k = (b + 115) * (2 * 10 / 5);
} else if (a < b) {
b += a / -unum + (8 >= b * a);
} else {
b = a;
}
return a * a + b + (b - a) * b;
}
float pi = 3.14159265;
int main () {
int quantas_trincas = 33, valor1 = 821;
int tk[3] = { -1, 0, 1 };
valor1 = scalar(quantas_trincas - tk[2], valor1) - (tk[0] + valor1);
return 0;
}
|
#ifdef __cplusplus
extern "C" {
#endif
#define DECLARE_STRUCT(name) typedef struct _##name name
DECLARE_STRUCT(Exiv2ImageFactory);
DECLARE_STRUCT(Exiv2Image);
DECLARE_STRUCT(Exiv2ExifData);
DECLARE_STRUCT(Exiv2ExifDatum);
DECLARE_STRUCT(Exiv2Error);
Exiv2Image* exiv2_image_factory_open(const char *path, Exiv2Error **error);
void exiv2_image_read_metadata(Exiv2Image *img, Exiv2Error **error);
Exiv2ExifData* exiv2_image_get_exif_data(const Exiv2Image *img);
void exiv2_image_free(Exiv2Image *img);
Exiv2ExifDatum* exiv2_exif_data_find_key(const Exiv2ExifData *data, const char *key, Exiv2Error **error);
void exiv2_exif_data_free(Exiv2ExifData *data);
char* exiv2_exif_datum_to_string(const Exiv2ExifDatum *datum);
void exiv2_exif_datum_free(Exiv2ExifDatum *datum);
int exiv2_error_code(const Exiv2Error *e);
const char *exiv2_error_what(const Exiv2Error *e);
void exiv2_error_free(Exiv2Error *e);
#ifdef __cplusplus
} // extern "C"
#endif
|
//
// UICollectionViewCell+LBCycleScrollView.h
// LBCycleScrollView
//
// Created by iLB on 2017/3/17.
// Copyright © 2017年 iLB. All rights reserved.
//
/**
Sample Code:
******************************* ExampleCell.h *********************************
#import UICollectionViewCell+LBCycleScrollView.h
@interface ExampleCell : UICollectionViewCell
@property (nonatomic, strong) UILabel *titleLabel;
@end
******************************* ExampleCell.m *********************************
#import ExampleCell.h
#import ExampleModel.h
@implementation ExampleCell
- (instancetype)initWithFrame:(CGRect)frame {
if (self == [super initWithFrame:frame]) {
self.titleLabel = [[UILabel alloc] initWithFrame:self.bounds];
[self.contentView addSubview:self.titleLabel];
}
return self;
}
- (void)assignmentValueToView {
if ([self.cellItem isKindOfClass:[ExampleModel class]]) {
ExampleModel *model = (ExampleModel *)self.cellItem;
self.titleLabel.text = model.title;
}
}
@end
*/
#import <UIKit/UIKit.h>
@protocol UICollectionViewCellAssignment <NSObject>
@optional
- (void)assignmentValueToView;
@end
@interface UICollectionViewCell (LBCycleScrollView) <UICollectionViewCellAssignment>
// the data will display in cell
@property (nonatomic, strong) id cellItem;
@end
|
#include "../Commands/commands.h"
#include "ESP8266.h"
#include "WifiGetCommand.h"
extern Service DefaultWifiService;
static byte* WifiResetCommandImplementation(const char* args[], struct CommandEngine* commandEngine)
{
ResetWifiModule(&DefaultWifiService);
return CMD_CRLF "Wifi is resetting.." CMD_CRLF;
}
const Command WifiResetCommand = {
"wifi-reset",
WifiResetCommandImplementation,
"Resets the wifi services"
}; |
/* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE78_OS_Command_Injection__wchar_t_connect_socket_w32spawnl_22b.c
Label Definition File: CWE78_OS_Command_Injection.strings.label.xml
Template File: sources-sink-22b.tmpl.c
*/
/*
* @description
* CWE: 78 OS Command Injection
* BadSource: connect_socket Read data using a connect socket (client side)
* GoodSource: Fixed string
* Sink: w32spawnl
* BadSink : execute command with wspawnl
* 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"
#include <wchar.h>
#ifdef _WIN32
#define COMMAND_INT_PATH L"%WINDIR%\\system32\\cmd.exe"
#define COMMAND_INT L"cmd.exe"
#define COMMAND_ARG1 L"/c"
#define COMMAND_ARG2 L"dir"
#define COMMAND_ARG3 data
#else /* NOT _WIN32 */
#include <unistd.h>
#define COMMAND_INT_PATH L"/bin/sh"
#define COMMAND_INT L"sh"
#define COMMAND_ARG1 L"ls"
#define COMMAND_ARG2 L"-la"
#define COMMAND_ARG3 data
#endif
#ifdef _WIN32
#include <winsock2.h>
#include <windows.h>
#include <direct.h>
#pragma comment(lib, "ws2_32") /* include ws2_32.lib when linking */
#define CLOSE_SOCKET closesocket
#else /* NOT _WIN32 */
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#define INVALID_SOCKET -1
#define SOCKET_ERROR -1
#define CLOSE_SOCKET close
#define SOCKET int
#endif
#define TCP_PORT 27015
#define IP_ADDRESS "127.0.0.1"
#ifndef OMITBAD
/* The global variable below is used to drive control flow in the source function */
extern int CWE78_OS_Command_Injection__wchar_t_connect_socket_w32spawnl_22_badGlobal;
wchar_t * CWE78_OS_Command_Injection__wchar_t_connect_socket_w32spawnl_22_badSource(wchar_t * data)
{
if(CWE78_OS_Command_Injection__wchar_t_connect_socket_w32spawnl_22_badGlobal)
{
{
#ifdef _WIN32
WSADATA wsaData;
int wsaDataInit = 0;
#endif
int recvResult;
struct sockaddr_in service;
wchar_t *replace;
SOCKET connectSocket = INVALID_SOCKET;
size_t dataLen = wcslen(data);
do
{
#ifdef _WIN32
if (WSAStartup(MAKEWORD(2,2), &wsaData) != NO_ERROR)
{
break;
}
wsaDataInit = 1;
#endif
/* POTENTIAL FLAW: Read data using a connect socket */
connectSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (connectSocket == INVALID_SOCKET)
{
break;
}
memset(&service, 0, sizeof(service));
service.sin_family = AF_INET;
service.sin_addr.s_addr = inet_addr(IP_ADDRESS);
service.sin_port = htons(TCP_PORT);
if (connect(connectSocket, (struct sockaddr*)&service, sizeof(service)) == SOCKET_ERROR)
{
break;
}
/* Abort on error or the connection was closed, make sure to recv one
* less char than is in the recv_buf in order to append a terminator */
/* Abort on error or the connection was closed */
recvResult = recv(connectSocket, (char *)(data + dataLen), sizeof(wchar_t) * (100 - dataLen - 1), 0);
if (recvResult == SOCKET_ERROR || recvResult == 0)
{
break;
}
/* Append null terminator */
data[dataLen + recvResult / sizeof(wchar_t)] = L'\0';
/* Eliminate CRLF */
replace = wcschr(data, L'\r');
if (replace)
{
*replace = L'\0';
}
replace = wcschr(data, L'\n');
if (replace)
{
*replace = L'\0';
}
}
while (0);
if (connectSocket != INVALID_SOCKET)
{
CLOSE_SOCKET(connectSocket);
}
#ifdef _WIN32
if (wsaDataInit)
{
WSACleanup();
}
#endif
}
}
return data;
}
#endif /* OMITBAD */
#ifndef OMITGOOD
/* The global variables below are used to drive control flow in the source functions. */
extern int CWE78_OS_Command_Injection__wchar_t_connect_socket_w32spawnl_22_goodG2B1Global;
extern int CWE78_OS_Command_Injection__wchar_t_connect_socket_w32spawnl_22_goodG2B2Global;
/* goodG2B1() - use goodsource and badsink by setting the static variable to false instead of true */
wchar_t * CWE78_OS_Command_Injection__wchar_t_connect_socket_w32spawnl_22_goodG2B1Source(wchar_t * data)
{
if(CWE78_OS_Command_Injection__wchar_t_connect_socket_w32spawnl_22_goodG2B1Global)
{
/* INCIDENTAL: CWE 561 Dead Code, the code below will never run */
printLine("Benign, fixed string");
}
else
{
/* FIX: Append a fixed string to data (not user / external input) */
wcscat(data, L"*.*");
}
return data;
}
/* goodG2B2() - use goodsource and badsink by reversing the blocks in the if in the source function */
wchar_t * CWE78_OS_Command_Injection__wchar_t_connect_socket_w32spawnl_22_goodG2B2Source(wchar_t * data)
{
if(CWE78_OS_Command_Injection__wchar_t_connect_socket_w32spawnl_22_goodG2B2Global)
{
/* FIX: Append a fixed string to data (not user / external input) */
wcscat(data, L"*.*");
}
return data;
}
#endif /* OMITGOOD */
|
//
// SQRedStampsCell.h
// ired6
//
// Created by zhangchong on 2017/1/26.
// Copyright © 2017年 ired6. All rights reserved.
//
#import <UIKit/UIKit.h>
@class SQRedStampsModel;
@interface SQRedStampsCell : UITableViewCell
@property (nonatomic, strong) SQRedStampsModel *model;
@end
|
#pragma once
#include <geneial/namespaces.h>
#include <geneial/core/operations/crossover/MultiValueChromosomeCrossoverOperation.h>
#include <geneial/utility/mixins/EnableMakeShared.h>
#include <cassert>
geneial_private_namespace(geneial)
{
geneial_private_namespace(operation)
{
geneial_private_namespace(crossover)
{
using ::geneial::population::Population;
using ::geneial::population::chromosome::MultiValueChromosome;
using ::geneial::utility::EnableMakeShared;
geneial_export_namespace
{
template<typename VALUE_TYPE, typename FITNESS_TYPE>
class MultiValueCrossoverLambdaAdapter: public MultiValueChromosomeCrossoverOperation<VALUE_TYPE,FITNESS_TYPE>,
public virtual EnableMakeShared<MultiValueCrossoverLambdaAdapter<VALUE_TYPE,FITNESS_TYPE>>
{
private:
const bool _operationIsSymmetric;
const function_type _function;
protected:
MultiValueCrossoverLambdaAdapter(
const std::shared_ptr<MultiValueChromosomeFactory<VALUE_TYPE, FITNESS_TYPE>> &builderFactory,
const function_type &function,
const bool isSymmetric = false
) : MultiValueChromosomeCrossoverOperation<VALUE_TYPE,FITNESS_TYPE>(builderFactory),
_function(function),
_operationIsSymmetric(isSymmetric)
{
}
public:
using return_type = typename BaseCrossoverOperation<FITNESS_TYPE>::crossover_result_set;
using arg_type = const typename MultiValueChromosome<VALUE_TYPE, FITNESS_TYPE>::const_ptr&;
using function_type =
typename std::function
<return_type(
arg_type mommy,
arg_type daddy,
MultiValueCrossoverLambdaAdapter<VALUE_TYPE,FITNESS_TYPE>&
)>;
virtual ~MultiValueCrossoverLambdaAdapter()
{
}
bool isSymmetric() const override
{
return false;
}
virtual typename BaseCrossoverOperation<FITNESS_TYPE>::crossover_result_set doMultiValueCrossover(
const typename MultiValueChromosome<VALUE_TYPE, FITNESS_TYPE>::const_ptr &mommy,
const typename MultiValueChromosome<VALUE_TYPE, FITNESS_TYPE>::const_ptr &daddy) const override
{
return _function(mommy,daddy,*this);
}
class Builder : public MultiValueChromosomeCrossoverOperation<VALUE_TYPE,FITNESS_TYPE>::Builder
{
bool _operationIsSymmetric;
function_type _function;
public:
Builder(const std::shared_ptr<MultiValueChromosomeFactory<VALUE_TYPE, FITNESS_TYPE>> & builderFactory,
const function_type function,
const bool operationIsSymmetric = false) : MultiValueChromosomeCrossoverOperation<VALUE_TYPE, FITNESS_TYPE>::Builder(builderFactory),
_function(function),
_operationIsSymmetric(operationIsSymmetric)
{
}
virtual typename BaseCrossoverOperation<FITNESS_TYPE>::ptr create() override
{
if(! this->_builderFactory )
{
throw new std::runtime_error("Must set a Chromosome Factory to build MultiValueCrossover");
}
return MultiValueCrossoverLambdaAdapter<VALUE_TYPE, FITNESS_TYPE>::makeShared(this->_builderFactory,_function,_operationIsSymmetric);
}
};
};
} /* geneial_export_namespace */
} /* private namespace crossover */
} /* private namespace operation */
} /* private namespace geneial */
#include <geneial/core/operations/crossover/MultiValueChromosomeAverageCrossover.hpp>
|
//
// MWPhoto.h
// MWPhotoBrowser
//
// Created by Michael Waterfall on 17/10/2010.
// Copyright 2010 d3i. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "MWPhotoProtocol.h"
// This class models a photo/image and it's caption
// If you want to handle photos, caching, decompression
// yourself then you can simply ensure your custom data model
// conforms to MWPhotoProtocol
@interface MWPhoto : NSObject <MWPhoto>
// Properties
@property (nonatomic, strong) NSString *caption;
@property (nonatomic, readonly) UIImage *image;
@property (nonatomic, readonly) NSURL *photoURL;
@property (nonatomic, readonly) NSString *filePath __attribute__((deprecated("Use photoURL"))); // Depreciated
// Class
+ (MWPhoto *)photoWithImage:(UIImage *)image;
+ (MWPhoto *)photoWithFilePath:(NSString *)path __attribute__((deprecated("Use photoWithURL: with a file URL"))); // Depreciated
+ (MWPhoto *)photoWithURL:(NSURL *)url;
// Init
- (id)initWithImage:(UIImage *)image;
- (id)initWithURL:(NSURL *)url;
- (id)initWithFilePath:(NSString *)path __attribute__((deprecated("Use initWithURL: with a file URL"))); // Depreciated
@end
|
#ifndef BPRINTER_TABLE_PRINTER_H_
#define BPRINTER_TABLE_PRINTER_H_
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <sstream>
#include <cmath>
//#include "../utils.hpp"
namespace bprinter {
class endl{};
/** \class TablePrinter
Print a pretty table into your output of choice.
Usage:
TablePrinter tp(&std::cout);
tp.AddColumn("Name", 25);
tp.AddColumn("Age", 3);
tp.AddColumn("Position", 30);
tp.PrintHeader();
tp << "Dat Chu" << 25 << "Research Assistant";
tp << "John Doe" << 26 << "Professional Anonymity";
tp << "Jane Doe" << tp.SkipToNextLine();
tp << "Tom Doe" << 7 << "Student";
tp.PrintFooter();
\todo Add support for padding in each table cell
*/
class TablePrinter{
public:
TablePrinter(std::ostream * output, const std::string & separator = "|");
~TablePrinter();
int get_num_columns() const;
int get_table_width() const;
void set_separator(const std::string & separator);
void AddColumn(const std::string & header_name, int column_width);
void PrintHeader();
void PrintFooter();
void SetTableColor(const std::string & color) { this->table_color=color; }
void SetContentColor(const std::string & color) { this->content_color=color; }
void SetBorderColor(const std::string & color) { this->border_color=color; }
TablePrinter& operator<<(endl input){
while (j_ != 0){
*this << "";
}
return *this;
}
// Can we merge these?
TablePrinter& operator<<(float input);
TablePrinter& operator<<(double input);
template<typename T> TablePrinter& operator<<(T input){
if (j_ == 0)
*out_stream_ << border_color << "|" << table_color;
// Leave 3 extra space: One for negative sign, one for zero, one for decimal
//*out_stream_ << content_color << std::setw(column_widths_.at(j_))
// << input;
std::ostringstream oss;
oss << input;
std::string print;
// if output is wider than column width
if (oss.str().size() >= column_widths_.at(j_)) {
// cut and add "..."
print = oss.str().substr(0,column_widths_.at(j_)-4) + "...";
}
else {
// if last char of output is new line
if(oss.str().at(oss.str().size()-1)=='\n') print = oss.str().substr(0,oss.str().size()-1);
else print = oss.str();
}
*out_stream_ << content_color << std::setw(column_widths_.at(j_)) << print;
if (j_ == get_num_columns()-1){ // end row
*out_stream_ << border_color << "|\n" << table_color;
i_ = i_ + 1;
j_ = 0;
} else { // only separator
*out_stream_ << border_color << separator_ << table_color;
j_ = j_ + 1;
}
return *this;
}
private:
void PrintHorizontalLine();
template<typename T> void OutputDecimalNumber(T input);
std::ostream * out_stream_;
std::vector<std::string> column_headers_;
std::vector<int> column_widths_;
std::string separator_;
std::string table_color;
std::string no_color;
std::string content_color;
std::string border_color;
int i_; // index of current row
int j_; // index of current column
int table_width_;
};
}
#include "impl/table_printer.tpp.h"
#endif
|
/*
Template for GSL functions which operate on X-Y value pairs
*/
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#if defined(OP_FITLINE)
#define OP_LINEST
#define OP_CORRELATION
#endif
#if defined(OP_LINEST)
# include <gsl/gsl_fit.h>
#endif
#if defined(OP_CORRELATION)
# include <gsl/gsl_statistics_double.h>
#endif
#include "double_matrix.h"
#define SINGLE_STEP 1
#define X_DATA 0
#define Y_DATA 1
#if defined(OP_LINEST)
typedef struct {
double C0;
double C1;
double COV00;
double COV01;
double COV11;
double SUMSQ;
} Fit_Data;
Fit_Data *get_fit_data(const Double_Matrix *);
double get_estimate(const Fit_Data *, double);
#endif /* defined(OP_LINEST) */
Double_Matrix *data = NULL;
int
main(int argc, char *argv[]) {
size_t i = 0;
#if defined(SINGLE_ARG)
char *endptr = NULL;
double arg;
#endif
#if defined(OP_LINEST)
Fit_Data *fit_data = NULL;
#endif
#if defined(OP_CORRELATION)
double correlation = 0.0;
#endif
#if defined(SINGLE_ARG)
if (2 == argc) {
arg = strtod(argv[ 1 ], &endptr);
if (0 == arg && endptr == argv[1]) {
fprintf(stderr, "Argument (%s) is not a valid number\n", argv[ 1 ]);
return 1;
}
} else {
fprintf(stderr, "Argument required\n");
return 1;
}
#else
if (1 != argc) {
fprintf(stderr, "No argument required.\n");
return 1;
}
#endif
data = double_matrix_new();
yyparse(data);
if (2 != double_matrix_width(data)) {
fprintf(stderr, "Must provide X data in column 1 and Y data in column 2\n");
double_matrix_free(data);
return 1;
}
#if defined(OP_LINEST)
fit_data = get_fit_data(data);
#if defined(OP_FITLINE)
printf("m:%.10g\nb:%.10g\nR²:", fit_data->C1, fit_data->C0);
#else
printf("%.10g\n", get_estimate(fit_data, arg));
#endif /* defined(OP_FITLINE) */
free(fit_data);
#endif /* defined(OP_LINEST) */
#if defined(OP_CORRELATION)
correlation = gsl_stats_correlation(double_matrix_col_data(data, X_DATA), SINGLE_STEP,
double_matrix_col_data(data, Y_DATA), SINGLE_STEP,
double_matrix_depth(data));
printf("%.10g\n", correlation);
#endif
double_matrix_free(data);
return 0;
}
#if defined(OP_LINEST)
Fit_Data *
get_fit_data(const Double_Matrix *matrix) {
Fit_Data *result = malloc(sizeof(Fit_Data));
assert(NULL != result);
gsl_fit_linear(double_matrix_col_data(matrix, X_DATA), SINGLE_STEP,
double_matrix_col_data(matrix, Y_DATA), SINGLE_STEP,
double_matrix_depth(matrix),
&result->C0,
&result->C1,
&result->COV00,
&result->COV01,
&result->COV11,
&result->SUMSQ);
return result;
}
double
get_estimate(const Fit_Data *eqn, double x) {
double y, y_error;
gsl_fit_linear_est(x, eqn->C0, eqn->C1, eqn->COV00, eqn->COV01, eqn->COV11, &y, &y_error);
return y;
}
#endif /* defined(OP_LINEST) */
|
/* -*- C -*-; c-basic-offset: 4; indent-tabs-mode: nil */
/*!
* @file ofmutator_c.h
* @brief C wrapper for Mutator
*/
/*
* Copyright (c) 2014 Cisco Systems, Inc. and others. 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
*/
#include "offramework_c.h"
#ifndef OPFLEX_C_OFMUTATOR_H
#define OPFLEX_C_OFMUTATOR_H
/**
* @addtogroup cwrapper
* @{
* @addtogroup cmodb
* @{
*/
/**
* @defgroup cmutator Mutator
* A mutator represents a set of changes to apply to the data store.
* When modifying data through the managed object accessor classes,
* changes are not actually written into the store, but rather are
* written into the Mutator registered using the framework in a
* thread-local variable. These changes will not become visible until
* the mutator is committed by calling @ref ofmutator_commit()
*
* The changes are applied to the data store all at once but not
* necessarily guaranteed to be atomic. That is, a read in another
* thread could see some objects updated but not others. Each
* individual object update is applied atomically, however, so the
* fields within that object will either all be modified or none.
*
* This is most similar to a database transaction with an isolation
* level set to read uncommitted.
* @{
*/
/**
* A pointer to a mutator object
*/
typedef ofobj_p ofmutator_p;
#ifdef __cplusplus
extern "C" {
#endif
/**
* Create a new mutator that will work with the provided framework
* instance.
*
* @param framework the framework instance
* @param owner the owner string that will control which fields can be
* modified.
* @param mutator a pointer to memory that will receive the
* pointer to the newly-allocated object.
* @return a status code
*/
ofstatus ofmutator_create(offramework_p framework,
const char* owner,
/* out */ ofmutator_p* mutator);
/**
* Destroy a mutator, and zero the pointer. Any uncommitted
* changes will be lost.
*
* @param mutator a pointer to memory containing the OF framework
* pointer.
* @return a status code
*/
ofstatus ofmutator_destroy(/* out */ ofmutator_p* mutator);
/**
* Commit the changes stored in the mutator. If this function is
* not called, these changes will simply be lost.
*
* @param mutator the mutator
* @return a status code
*/
ofstatus ofmutator_commit(ofmutator_p mutator);
#ifdef __cplusplus
} /* extern "C" */
#endif
/** @} mutator */
/** @} cmodb */
/** @} cwrapper */
#endif /* OPFLEX_C_OFMUTATOR_H */
|
// The ROCCC Compiler Infrastructure
// This file is distributed under the University of California Open Source
// License. See ROCCCLICENSE.TXT for details.
#ifndef STRIP_ANNOTES_PASS_H
#define STRIP_ANNOTES_PASS_H
#include "suifpasses/passes.h"
#include "suifnodes/suif.h"
class StripAnnotesPass : public PipelinablePass
{
private:
SuifEnv* theEnv ;
ProcedureDefinition* procDef ;
public:
StripAnnotesPass( SuifEnv* suif_env );
virtual ~StripAnnotesPass() {}
virtual Module* clone() const { return(Module*)this; }
virtual void do_procedure_definition(ProcedureDefinition *p);
};
#endif
|
//===-- llvm/AutoUpgrade.h - AutoUpgrade Helpers ----------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// These functions are implemented by lib/VMCore/AutoUpgrade.cpp.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_AUTOUPGRADE_H
#define LLVM_AUTOUPGRADE_H
namespace llvm {
class Function;
class CallInst;
class BasicBlock;
/// This is a more granular function that simply checks an intrinsic function
/// for upgrading, and returns true if it requires upgrading. It may return
/// null in NewFn if the all calls to the original intrinsic function
/// should be transformed to non-function-call instructions.
bool UpgradeIntrinsicFunction(Function *F, Function *&NewFn);
/// This is the complement to the above, replacing a specific call to an
/// intrinsic function with a call to the specified new function.
void UpgradeIntrinsicCall(CallInst *CI, Function *NewFn);
/// This is an auto-upgrade hook for any old intrinsic function syntaxes
/// which need to have both the function updated as well as all calls updated
/// to the new function. This should only be run in a post-processing fashion
/// so that it can update all calls to the old function.
void UpgradeCallsToIntrinsic(Function* F);
} // End llvm namespace
#endif
|
@interface ItemsController : UIViewController<UICollectionViewDataSource,UICollectionViewDelegate,UICollectionViewDelegateFlowLayout>
@property(nonatomic,strong) NSArray *items;
@property(nonatomic) BOOL isLoading;
-(void)setItemsAttributes:(NSArray*)itemsAttributes;
-(UICollectionViewFlowLayout*)layout;
-(UICollectionView*)collectionView;
-(UIRefreshControl*)refreshControl;
@end
|
//
// IBMPIGeofence.h
// IBMPIGeofence
//
// Created by slizeray on 03/03/16.
// Copyright © 2016 IBM. All rights reserved.
//
#import <UIKit/UIKit.h>
//! Project version number for IBMPIGeofence.
FOUNDATION_EXPORT double IBMPIGeofenceVersionNumber;
//! Project version string for IBMPIGeofence.
FOUNDATION_EXPORT const unsigned char IBMPIGeofenceVersionString[];
// In this header, you should import all the public headers of your framework using statements like #import <IBMPIGeofence/PublicHeader.h>
|
/* Multi Monitor Plugin for Xfce
* Copyright (C) 2007,2014 Yuuki Harano
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "../config.h"
#include <glib.h>
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h>
#include <math.h>
#include <cairo.h>
#include "types.h"
#include "list.h"
#include "draw.h"
#include "memory.h"
struct data_t {
gint64 total;
gint64 free;
gint64 anon;
gint64 buffers;
gint64 cached;
gint64 kernel;
};
static int dir = -1;
static GList *list = NULL;
static gchar tooltip[128];
void mem_init(void)
{
dir = open("/proc", O_RDONLY);
}
void mem_read_data(gint type)
{
if (dir < 0)
return;
struct data_t data;
data.total = data.anon = data.free = data.buffers = data.cached = data.kernel = 0;
int fd = openat(dir, "meminfo", O_RDONLY);
if (fd >= 0) {
FILE *fp = fdopen(fd, "rt");
while (!feof(fp)) {
char name[128];
gint64 value;
if (fscanf(fp, "%s %"G_GINT64_FORMAT" kB", name, &value) == 2) {
if (strcmp(name, "MemTotal:") == 0)
data.total = value;
else if (strcmp(name, "MemFree:") == 0)
data.free = value;
else if (strcmp(name, "Buffers:") == 0)
data.buffers = value;
else if (strcmp(name, "Cached:") == 0)
data.cached = value;
else if (strcmp(name, "AnonPages:") == 0)
data.anon = value;
}
}
fclose(fp);
data.kernel = data.total - data.free - data.anon - data.buffers - data.cached;
}
struct data_t *p = g_new0(struct data_t, 1);
*p = data;
list = g_list_prepend(list, p);
}
static void draw_0(gint type, GdkPixbuf *pix, gint w, gint h, struct data_t *p, gint x)
{
if (p != NULL && p->total > 0) { // ÆÉ¤á¤Ê¤«¤Ã¤¿¥¿¥¤¥ß¥ó¥°¤¬Â¸ºß¤¹¤ë¡£
draw_line(pix, x, 0, h - 1, color_bg_normal);
draw_line(pix, x, h - h * (p->anon + p->buffers + p->cached + p->kernel) / p->total, h - 1, color_fg_anon);
draw_line(pix, x, h - h * (p->buffers + p->cached + p->kernel) / p->total, h - 1, color_fg_buffers);
draw_line(pix, x, h - h * (p->cached + p->kernel) / p->total, h - 1, color_fg_cached);
draw_line(pix, x, h - h * (p->kernel) / p->total, h - 1, color_fg_kernel);
} else {
draw_line(pix, x, 0, h - 1, color_err);
}
}
void mem_draw_1(gint type, GdkPixbuf *pix)
{
gint w = gdk_pixbuf_get_width(pix);
gint h = gdk_pixbuf_get_height(pix);
struct data_t *p = NULL;
GList *lp = list;
if (lp != NULL)
p = (struct data_t *) lp->data;
draw_0(type, pix, w, h, p, w - 1);
}
void mem_draw_all(gint type, GdkPixbuf *pix)
{
gint w = gdk_pixbuf_get_width(pix);
gint h = gdk_pixbuf_get_height(pix);
gint x = w - 1;
for (GList *lp = list; lp != NULL && x >= 0; lp = g_list_next(lp), x--) {
struct data_t *p = (struct data_t *) lp->data;
draw_0(type, pix, w, h, p, x);
}
for ( ; x >= 0; x--)
draw_0(type, pix, w, h, NULL, x);
}
void mem_discard_data(gint type, gint size)
{
list = list_truncate(list, size);
}
static gint append_usage(gchar *buf, gint bufsiz, const gchar *label, gint64 size)
{
if (size >= 1024 * 1024)
return snprintf(buf, bufsiz, "%s:%.1fGB\n", label, (gdouble) size / 1024 / 1024);
if (size >= 1024)
return snprintf(buf, bufsiz, "%s:%.1fMB\n", label, (gdouble) size / 1024);
return snprintf(buf, bufsiz, "%s:%dKB\n", label, (gint) size);
}
const gchar *mem_tooltip(gint type)
{
struct data_t *p = NULL;
if (list != NULL)
p = list->data;
if (p == NULL)
return NULL;
gchar *tp = tooltip;
gint ts = sizeof tooltip;
gint s;
s = append_usage(tp, ts, "Anon", p->anon);
tp += s;
ts -= s;
s = append_usage(tp, ts, "Buffers", p->buffers);
tp += s;
ts -= s;
s = append_usage(tp, ts, "Cached", p->cached);
tp += s;
ts -= s;
s = append_usage(tp, ts, "Kernel", p->kernel);
tp += s;
ts -= s;
gint len = strlen(tooltip);
if (len > 0 && tooltip[len - 1] == '\n')
tooltip[len - 1] = '\0';
return tooltip;
}
|
/*
* boblightservice.h
*
* Copyright (C) 2013 - Christian Völlinger
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef __BOBLIGHT_H
#define __BOBLIGHT_H
#include "common.h"
#include "config.h"
#include "ambiservice.h"
class cBoblight : public cAmbiService
{
public:
cBoblight() {};
~cBoblight() { close(); }
int open();
int close();
int writePix(int *rgb);
int writeColor(int *rgb, int x, int y);
int setScanRange(int width, int height);
int ping();
int send();
int sendOptions();
private:
void* m_boblight;
};
#endif
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.