text
stringlengths
4
6.14k
#include<stdio.h> #include<unistd.h> #include<stdlib.h> #include<string.h> int main(){ int pid1,pid2,pid3,pid4; int p1[2],p2[2]; char bufr[30],rev[30]; int countL=0,countU=0,i=-1,j=0,countV=0,len; pipe(p1); pipe(p2); if(pid1=fork()==0){ if(pid2=fork()==0){ read(p2[0],bufr,sizeof(bufr)); len=strlen(bufr); for(i=len-1,j=0;j<len;i--,j++) rev[j]=bufr[i]; rev[j]='\0'; printf("Proccess D---- Reverse = %s \n",rev); exit(1); } else{ read(p1[0],bufr,sizeof(bufr)); write(p2[1],bufr,sizeof(bufr)); if(pid3=fork()==0){ printf("Poccess C--- ID of B = %d and ID of C = %d \n",getppid(),getpid()); exit(1); } else{ while(bufr[++i]!='\0') if(bufr[i]>='A' && bufr[i]<='Z') countU++; i=-1; while(bufr[++i]!='\0') if(bufr[i]>='a' && bufr[i]<='z') countL++; printf("Poccess B--- No of UpperCase letters = %d \n",countU); printf("Poccess B--- No of LowerCase letters = %d \n",countL); waitpid(pid2,NULL,0); waitpid(pid3,NULL,0); } } exit(1); } else{ printf("Poccess A--- Enter a sentence "); gets(bufr); write(p1[1],bufr,sizeof(bufr)); while(bufr[++i]!='\0') if(bufr[i]=='a' || bufr[i]=='e' || bufr[i]=='i' || bufr[i]=='o' || bufr[i]=='u' || bufr[i]=='A' || bufr[i]=='E' || bufr[i]=='I' || bufr[i]=='O' || bufr[i]=='U' ) countV++; printf("Poccess A--- No of Vowels = %d \n",countV); waitpid(pid1,NULL,0); } close(p1[0]); close(p1[1]); return 0; }
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* get_next_line.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: gmange <[email protected]> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2013/12/02 16:03:39 by gmange #+# #+# */ /* Updated: 2016/09/27 10:53:59 by gmange ### ########.fr */ /* */ /* ************************************************************************** */ #include <unistd.h> #include "libft.h" #include "get_next_line.h" /* ** returns 0 when reading 0 and, leaves line == NULL ** ONLY if there is an empty end of line at the end of file... */ /* ** structures with the same fd are set in a row */ /* ** 3 reasons to come in: ** 1. chck, remaining struct with corresponding fd from previous read ** 2. chck buf after reading ** 3. read last bits. */ /* ** EOF == -1 in C or read == 0 */ /* ** I check I have no new line already in memory ** would I have I fill line and send it already ** else ** I create a new structure to read in it ** I check it and read again until I find a line or finishes reading */ static int del_cur(t_read **root, t_read *cur, int continu) { t_read *tmp; if (cur == *root) *root = GNL_NXT; else { tmp = *root; while (tmp->nxt != cur) tmp = tmp->nxt; tmp->nxt = GNL_NXT; } ft_memdel((void**)&GNL_BUF); ft_memdel((void**)&cur); return (continu); } static int line_from_lst(char **line, t_read **root, int const fd) { t_read *cur; t_read *tmp; size_t i; cur = *root; while (GNL_FD != fd) cur = GNL_NXT; i = 0; while (cur && GNL_FD == fd) { while (GNL_IDX < GNL_SZE && GNL_BUF[GNL_IDX] != CHAR) (*line)[i++] = GNL_BUF[GNL_IDX++]; if (GNL_BUF[GNL_IDX] == CHAR && ++GNL_IDX >= GNL_SZE) return (del_cur(root, cur, 1)); if (GNL_IDX < GNL_SZE) return (1); tmp = GNL_NXT; if (GNL_IDX >= GNL_SZE) del_cur(root, cur, 1); cur = tmp; } return (0); } static int find_endl(char **line, t_read **root, t_read *cur, int continu) { t_read *tmp; size_t len; len = GNL_IDX; while (len < GNL_SZE && (unsigned char)GNL_BUF[len] != (unsigned char)CHAR) len++; if (!continu || (unsigned char)GNL_BUF[len] == (unsigned char)CHAR) { len -= GNL_IDX; tmp = *root; while (tmp->fd != GNL_FD) tmp = tmp->nxt; while (tmp != cur && (len += tmp->sze)) tmp = tmp->nxt; if (!continu && len == 0) return (del_cur(root, cur, continu)); if (!(*line = (char*)ft_memalloc(sizeof(char) * (len + 1)))) return (-1); return (line_from_lst(line, root, GNL_FD)); } return (0); } static t_read *new_read(t_read **root, int const fd) { t_read *cur; if (!(cur = (t_read*)ft_memalloc(sizeof(*cur)))) return (NULL); GNL_FD = fd; if (!(GNL_BUF = (char*)ft_memalloc(sizeof(*GNL_BUF) * GNL_BUF_SZE))) { ft_memdel((void**)&cur); return (NULL); } if ((int)(GNL_SZE = read(GNL_FD, GNL_BUF, GNL_BUF_SZE)) < 0) { ft_memdel((void**)&GNL_BUF); ft_memdel((void**)&cur); return (NULL); } GNL_IDX = 0; GNL_NXT = NULL; if (*root) GNL_NXT = (*root)->nxt; if (*root) (*root)->nxt = cur; else *root = cur; return (cur); } int get_next_line(int const fd, char **line) { size_t ret; static t_read *root = NULL; t_read *cur; if (!line || (*line = NULL)) return (-1); cur = root; while (cur && GNL_FD != fd) cur = GNL_NXT; if (cur && GNL_FD == fd && (ret = find_endl(line, &root, cur, 1))) return (ret); while (cur && GNL_FD == fd && GNL_NXT) cur = GNL_NXT; while (1) { if (root && !(cur = new_read(&cur, fd))) return (-1); if (!root && !(cur = new_read(&root, fd))) return (-1); if (!GNL_SZE) return (find_endl(line, &root, cur, 0)); if ((ret = find_endl(line, &root, cur, 1))) return (ret); } }
#define NC0_As 0x0E #define NC0_B 0x0D #define NC1_C 0x15 #define NC1_Cs 0x1E #define NC1_D 0x1D #define NC1_Ds 0x26 #define NC1_E 0x24 #define NC1_F 0x2D #define NC1_Fs 0x2E #define NC1_G 0x2C #define NC1_Gs 0x36 #define NC1_A 0x35 #define NC1_As 0x3D #define NC1_B 0x3C #define NC2_C 0x43 #define NC2_Cs 0x46 #define NC2_D 0x44 #define NC2_Ds 0x45 #define NC2_E 0x4D #define NC2_F 0x54 #define NC2_Fs 0x55 #define NC2_G 0x5B #define NC2_Gs 0x5D #define NC2_A 0x12 #define NC2_As 0x58 #define NC2_B 0x1A #define NC_OCTAVEUP 0x05 #define NC_OCTAVEDOWN 0x06 #define NC_INSTRUP 0x04 #define NC_INSTRDOWN 0x0C #define NC_TABLEUP 0x03 #define NC_TABLEDOWN 0x0B #define NC_PULSETOGGLE 0x0A #define NC_TABLERUN 0x29 #define NC_NOP 0x00
#include "src/math/float/log10f.c" #include "log.h" int main(void) { test(log10f, log10); }
#include <math.h> #include <stdio.h> #include <pthread.h> #include <stdlib.h> #define THREAD_COUNT 4 typedef struct { int start; int end; } range_t; void *calculate_range(void* range) { range_t* curr_range = (range_t*)range; void* result = (void*)1; for (int i = curr_range->start; i < curr_range->end; i++) { double a = cos(i) * cos(i) + sin(i) * sin(i); if (a > 1.0005 || a < 0.9995) { result = (void*)0; } } free(curr_range); return result; } int main() { pthread_t threads[THREAD_COUNT]; int arg_start = 0; for (int i = 0; i < THREAD_COUNT; i++) { range_t *curr_range = (range_t*)malloc(sizeof(range_t)); curr_range->start = arg_start; curr_range->end = arg_start + 25000000; int res = pthread_create(&threads[i], NULL, calculate_range, curr_range); if (res != 0) { perror("Could not spawn new thread"); exit(-1); } arg_start = curr_range->end; } long final_result = 1; for (int i = 0; i < THREAD_COUNT; i++) { void *thread_result; int res = pthread_join(threads[i], (void **)&thread_result); if (res != 0) { perror("Could not spawn thread"); exit(-1); } final_result <<= (long)thread_result; } if (final_result & (1 << 4)) { printf("OK!\n"); } else { printf("Not OK!\n"); } return 0; }
#ifndef VECTOR4_H #define VECTOR4_H #include "gamemath_internal.h" GAMEMATH_NAMESPACE_BEGIN GAMEMATH_ALIGNEDTYPE_PRE class GAMEMATH_ALIGNEDTYPE_MID Vector4 : public AlignedAllocation { friend class Matrix4; friend GAMEMATH_INLINE Vector4 operator +(const Vector4 &a, const Vector4 &b); friend GAMEMATH_INLINE Vector4 operator -(const Vector4 &a, const Vector4 &b); friend GAMEMATH_INLINE Vector4 operator *(const float, const Vector4 &vector); friend GAMEMATH_INLINE Vector4 operator *(const Vector4 &vector, const float); friend class Ray3d; friend class Box3d; public: Vector4(); Vector4(const float x, const float y, const float z, const float w); #if !defined(GAMEMATH_NO_INTRINSICS) Vector4(const __m128 value); #endif /** * Returns the x component of this vector. */ float x() const; /** * Returns the y component of this vector. */ float y() const; /** * Returns the z component of this vector. */ float z() const; /** * Returns the w component of this vector. Usually 1 means this is a position vector, while 0 * means this is a directional vector. */ float w() const; /** * Changes the X component of this vector. */ void setX(float x); /** * Changes the Y component of this vector. */ void setY(float y); /** * Changes the Z component of this vector. */ void setZ(float z); /** * Changes the W component of this vector. */ void setW(float w); /** * Computes the squared length of this vector. This method is significantly * faster than computing the normal length, since the square root can be omitted. */ float lengthSquared() const; /** * Computes this vector's length. */ float length() const; /** * Normalizes this vector by dividing its components by this vectors length. */ Vector4 &normalize(); /** * Normalizes using a reciprocal square root, which only has 11-bit precision. Use this if the * result doesn't need to be very precisely normalized. */ Vector4 &normalizeEstimated(); /** * Normalizes this vector and returns it in a new object, while leaving this object untouched. */ Vector4 normalized() const; /** * Computes the dot product between this and another vector. */ float dot(const Vector4 &vector) const; /** Returns the absolute of this vector. */ Vector4 absolute() const; /** Returns true if one of the components of this vector are negative or positive infinity. */ bool isInfinite() const; /** * Computes the three-dimensional cross product of two vectors, interpreting both vectors as directional vectors * (w=0). If either vector's w is not zero, the result may be wrong. * * @return this x vector */ Vector4 cross(const Vector4 &vector) const; /** * Adds another vector to this vector. */ Vector4 &operator +=(const Vector4 &vector); /** * Multiplies this vector with a scalar factor. * Only the x,y, and z components of the vector are multiplied. */ Vector4 &operator *=(const float factor); /** * Subtracts another vector from this vector. */ Vector4 &operator -=(const Vector4 &vector); /** * Returns a negated version of this vector, negating only the x, y, and z components. */ Vector4 operator -() const; #if !defined(GAMEMATH_NO_INTRINSICS) operator __m128() const; #endif /** Checks two vectors for equality. */ bool operator ==(const Vector4 &other) const; const float *data() const; float *data(); private: #if !defined(GAMEMATH_NO_INTRINSICS) union { struct { float mX; float mY; float mZ; float mW; }; __m128 mSse; }; #else float mX; float mY; float mZ; float mW; #endif // GAMEMATH_NO_INTRINSICS } GAMEMATH_ALIGNEDTYPE_POST; GAMEMATH_INLINE float Vector4::x() const { return mX; } GAMEMATH_INLINE float Vector4::y() const { return mY; } GAMEMATH_INLINE float Vector4::z() const { return mZ; } GAMEMATH_INLINE float Vector4::w() const { return mW; } GAMEMATH_INLINE void Vector4::setX(float x) { mX = x; } GAMEMATH_INLINE void Vector4::setY(float y) { mY = y; } GAMEMATH_INLINE void Vector4::setZ(float z) { mZ = z; } GAMEMATH_INLINE void Vector4::setW(float w) { mW = w; } GAMEMATH_INLINE const float *Vector4::data() const { return &mX; } GAMEMATH_INLINE float *Vector4::data() { return &mX; } GAMEMATH_NAMESPACE_END #if !defined(GAMEMATH_NO_INTRINSICS) #include "vector4_sse.h" #else #include "vector4_sisd.h" #endif // GAMEMATH_NO_INTRINSICS #endif // VECTOR4_H
// // LJRouterPath.h // LJControllerRouterExample // // Created by Jinxing Liao on 12/14/15. // Copyright © 2015 Jinxing Liao. All rights reserved. // #import <Foundation/Foundation.h> @interface LJRouterPath : NSObject @property (nonatomic, strong) NSString *schema; @property (nonatomic, strong) NSArray *components; @property (nonatomic, strong) NSDictionary *params; - (instancetype)initWithRouterURL:(NSString *)URL; @end
// // EPTTimer.h // PodcastTimer // // Created by Eric Jones on 6/7/14. // Copyright (c) 2014 Effective Programming. All rights reserved. // #import <Foundation/Foundation.h> @protocol EPTTimerDelegate <NSObject> - (void)timerFired; @end @interface EPTTimer : NSObject @property (nonatomic) id<EPTTimerDelegate> delegate; - (void)scheduleTimer; - (void)stopTimer; @end
#pragma once #include "platform.h" #include "value.h" #include "vm.h" #include "result.h" #include <memory> #include <vector> namespace imq { class IMQ_API ScriptFunction : public QFunction { public: ScriptFunction(const String& funcName, Context* outerCtx, const std::shared_ptr<VBlock> block, const std::vector<String>& argNames); virtual ~ScriptFunction(); virtual Result execute(VMachine* vm, int32_t argCount, QValue* args, QValue* result) override; virtual size_t GC_getSize() const override; virtual bool GC_isDynamic() const override { return false; } protected: virtual void GC_markChildren() override; private: ScriptFunction(const ScriptFunction& other) = default; ScriptFunction& operator=(const ScriptFunction& other) = default; String funcName; Context* outerCtx; std::shared_ptr<VBlock> block; std::vector<String> argNames; }; class IMQ_API DefineFunctionExpr : public VExpression { public: DefineFunctionExpr(const String& funcName, VBlock* block, const std::vector<String>& argNames, const VLocation& loc); DefineFunctionExpr(VBlock* block, const std::vector<String>& argNames, const VLocation& loc); virtual ~DefineFunctionExpr(); virtual String getName() const override; virtual Result execute(Context* context, QValue* result) override; private: String funcName; VBlock* initialBlock; std::shared_ptr<VBlock> block; std::vector<String> argNames; }; }
// // AAAreaspline.h // AAChartKit // // Created by An An on 17/3/15. // Copyright © 2017年 An An. All rights reserved. //*************** ...... SOURCE CODE ...... *************** //***...................................................*** //*** https://github.com/AAChartModel/AAChartKit *** //*** https://github.com/AAChartModel/AAChartKit-Swift *** //***...................................................*** //*************** ...... SOURCE CODE ...... *************** /* * ------------------------------------------------------------------------------- * * 🌕 🌖 🌗 🌘 ❀❀❀ WARM TIPS!!! ❀❀❀ 🌑 🌒 🌓 🌔 * * Please contact me on GitHub,if there are any problems encountered in use. * GitHub Issues : https://github.com/AAChartModel/AAChartKit/issues * ------------------------------------------------------------------------------- * And if you want to contribute for this project, please contact me as well * GitHub : https://github.com/AAChartModel * StackOverflow : https://stackoverflow.com/users/12302132/codeforu * JianShu : https://www.jianshu.com/u/f1e6753d4254 * SegmentFault : https://segmentfault.com/u/huanghunbieguan * * ------------------------------------------------------------------------------- */ #import <Foundation/Foundation.h> @class AADataLabels; @interface AAAreaspline : NSObject AAPropStatementAndPropSetFuncStatement(strong, AAAreaspline, AADataLabels *, dataLabels) @end
#include <pthread.h> #include <assert.h> int g = 17; // matches expected precise read pthread_mutex_t A = PTHREAD_MUTEX_INITIALIZER; pthread_mutex_t B = PTHREAD_MUTEX_INITIALIZER; pthread_mutex_t C = PTHREAD_MUTEX_INITIALIZER; void *t_fun(void *arg) { pthread_mutex_lock(&B); pthread_mutex_lock(&C); g = 42; pthread_mutex_unlock(&B); g = 17; pthread_mutex_unlock(&C); return NULL; } int main(void) { pthread_t id; pthread_create(&id, NULL, t_fun, NULL); pthread_mutex_lock(&A); pthread_mutex_lock(&B); pthread_mutex_lock(&C); assert(g == 17); pthread_mutex_unlock(&A); pthread_mutex_unlock(&B); pthread_mutex_unlock(&C); return 0; }
#pragma once #include "animations/display.h" #include "animations/AnimationProgram.h" #include "animations/PaintPixel.h" #include "blewiz/BLECharacteristic.h" #include "freertos/task.h" class BadgeService : public BLEService { public: BadgeService(Display &display, AnimationProgram &animationProgram); virtual ~BadgeService(); void init(); void setPaintPixel(PaintPixel *paintPixel) { this->paintPixel = paintPixel; } void onStarted() override; void onConnect() override; void onDisconnect() override; private: Display &display; AnimationProgram &animationProgram; PaintPixel *paintPixel; BLECharacteristic batteryCharacteristic; BLEDescriptor batteryNotifyDesciptor; BLECharacteristic brightnessCharacteristic; BLECharacteristic programCharacteristic; BLECharacteristic downloadCharacteristic; BLECharacteristic paintPixelCharacteristic; BLECharacteristic paintFrameCharacteristic; BLECharacteristic appVersionCharacteristic; BLECharacteristic frameDumpCharacteristic; static void batteryTask(void *parameters); TaskHandle_t taskHandle; std::vector<uint8_t> paintFrame; };
// // Copyright(c) 2017-2018 Paweł Księżopolski ( pumexx ) // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files(the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and / or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions : // // The above copyright notice and this permission notice shall be included in all // copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. // #pragma once #include <memory> #include <vector> #include <mutex> #include <vulkan/vulkan.h> #include <pumex/Export.h> #include <pumex/PerObjectData.h> namespace pumex { class Descriptor; class RenderContext; struct PUMEX_EXPORT DescriptorValue { enum Type { Undefined, Image, Buffer }; DescriptorValue(); DescriptorValue(VkBuffer buffer, VkDeviceSize offset, VkDeviceSize range); DescriptorValue(VkSampler sampler, VkImageView imageView, VkImageLayout imageLayout); Type vType; union { VkDescriptorBufferInfo bufferInfo; VkDescriptorImageInfo imageInfo; }; }; // Resource is an object stored in a descriptor ( SampledImage, UniformBuffer, etc. ) class PUMEX_EXPORT Resource : public std::enable_shared_from_this<Resource> { public: Resource(PerObjectBehaviour perObjectBehaviour, SwapChainImageBehaviour swapChainImageBehaviour); virtual ~Resource(); void addDescriptor(std::shared_ptr<Descriptor> descriptor); void removeDescriptor(std::shared_ptr<Descriptor> descriptor); // invalidateDescriptors() is called to inform the scenegraph that validate() needs to be called virtual void invalidateDescriptors(); // notifyDescriptors() is called from within validate() when some serious change in resource occured // ( getDescriptorValue() will return new values, so vkUpdateDescriptorSets must be called by DescriptorSet ). virtual void notifyDescriptors(const RenderContext& renderContext); virtual std::pair<bool,VkDescriptorType> getDefaultDescriptorType(); virtual void validate(const RenderContext& renderContext) = 0; virtual DescriptorValue getDescriptorValue(const RenderContext& renderContext) = 0; protected: mutable std::mutex mutex; std::vector<std::weak_ptr<Descriptor>> descriptors; PerObjectBehaviour perObjectBehaviour; SwapChainImageBehaviour swapChainImageBehaviour; uint32_t activeCount; }; }
#ifndef LWEXML_H #define LWEXML_H #include <LWCore/LWText.h> #include <functional> #include "LWETypes.h" #define LWEXMLMAXNAMELEN 32 #define LWEXMLMAXVALUELEN 256 #define LWEXMLMAXTEXTLEN 1024 struct LWXMLAttribute { char m_Name[LWEXMLMAXNAMELEN]; char m_Value[LWEXMLMAXVALUELEN]; }; struct LWEXMLNode { enum { MaxAttributes = 32 }; LWXMLAttribute m_Attributes[MaxAttributes]; char m_Text[LWEXMLMAXTEXTLEN]; char m_Name[LWEXMLMAXNAMELEN]; uint32_t m_AttributeCount; LWEXMLNode *m_Parent; LWEXMLNode *m_Next; LWEXMLNode *m_FirstChild; LWEXMLNode *m_LastChild; bool PushAttribute(const char *Name, const char *Value); bool PushAttributef(const char *Name, const char *ValueFmt, ...); bool RemoveAttribute(uint32_t i); bool RemoveAttribute(LWXMLAttribute *Attr); LWEXMLNode &SetName(const char *Name); LWEXMLNode &SetText(const char *Text); LWEXMLNode &SetTextf(const char *TextFmt, ...); LWXMLAttribute *FindAttribute(const LWText &Name); }; struct LWEXMLParser { char m_Name[LWEXMLMAXNAMELEN]; std::function<bool(LWEXMLNode *, void *, LWEXML *)> m_Callback; void *m_UserData; }; class LWEXML { public: enum { NodePoolSize = 256, MaxParsers = 32 }; static bool LoadFile(LWEXML &XML, LWAllocator &Allocator, const LWText &Path, bool StripFormatting, LWEXMLNode *Parent, LWEXMLNode *Prev, LWFileStream *ExistingStream = nullptr); static bool LoadFile(LWEXML &XML, LWAllocator &Allocator, const LWText &Path, bool StripFormatting, LWFileStream *ExistingStream = nullptr); static bool ParseBuffer(LWEXML &XML, LWAllocator &Allocator, const char *Buffer, bool StripFormatting, LWEXMLNode *Parent, LWEXMLNode *Prev); static bool ParseBuffer(LWEXML &XML, LWAllocator &Allocator, const char *Buffer, bool StripFormatting); static uint32_t ConstructBuffer(LWEXML &XML, char *Buffer, uint32_t BufferLen, bool Format); LWEXMLNode *NextNode(LWEXMLNode *Current, bool SkipChildren=false); LWEXMLNode *NextNode(LWEXMLNode *Current, LWEXMLNode *Top, bool SkipChildren = false); LWEXMLNode *NextNodeWithName(LWEXMLNode *Current, const LWText &Name, bool SkipChildren =false); template<class Method, class Obj> LWEXML &PushMethodParser(const LWText &XMLNodeName, Method CB, Obj *O, void *UserData) { return PushParser(XMLNodeName, std::bind(CB, O, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3), UserData); } LWEXML &PushParser(const LWText &XMLNodeName, std::function<bool(LWEXMLNode*, void*, LWEXML*)> Callback, void *UserData); LWEXML &Process(void); LWEXMLNode *GetInsertedNodeAfter(LWEXMLNode *Parent, LWEXMLNode *Prev, LWAllocator &Allocator); LWEXMLNode *GetFirstNode(void); LWEXMLNode *GetLastNode(void); LWEXML(); ~LWEXML(); private: LWEXMLNode **m_NodePool; LWEXMLParser m_Parsers[MaxParsers]; uint32_t m_NodeCount; uint32_t m_ParserCount; LWEXMLNode *m_FirstNode; LWEXMLNode *m_LastNode; }; #endif
// // SLWordViewController.h // 百思不得姐 // // Created by Anthony on 17/3/30. // Copyright © 2017年 SLZeng. All rights reserved. // #import "SLTopicViewController.h" @interface SLWordViewController : SLTopicViewController @end
// // YWPayViewController.h // YuWa // // Created by 黄佳峰 on 16/10/10. // Copyright © 2016年 Shanghai DuRui Information Technology Company. All rights reserved. // #import <UIKit/UIKit.h> typedef NS_ENUM(NSInteger,PayCategory){ PayCategoryQRCodePay=0, //二维码支付 PayCategoryWritePay //手写支付 }; @interface YWPayViewController : UIViewController @property(nonatomic,assign)PayCategory whichPay; //哪种支付 @property(nonatomic,strong)NSString*shopID; //店铺的id @property(nonatomic,strong)NSString*shopName; //店铺的名字 @property(nonatomic,assign)CGFloat shopZhekou; //店铺的折扣 //如果是 扫码支付 就得有下面的参数 否则就不需要 @property(nonatomic,assign)CGFloat payAllMoney; //需要支付的总额 @property(nonatomic,assign)CGFloat NOZheMoney; //不打折的金额 //---------------------------------------------- //折扣多少 +(instancetype)payViewControllerCreatWithWritePayAndShopNameStr:(NSString*)shopName andShopID:(NSString*)shopID andZhekou:(CGFloat)shopZhekou; +(instancetype)payViewControllerCreatWithQRCodePayAndShopNameStr:(NSString*)shopName andShopID:(NSString*)shopID andZhekou:(CGFloat)shopZhekou andpayAllMoney:(CGFloat)payAllMoney andNOZheMoney:(CGFloat)NOZheMoney; @end
/**************************************************************************** * * Copyright (c) 2005 - 2012 by Vivante Corp. All rights reserved. * * The material in this file is confidential and contains trade secrets * of Vivante Corporation. This is proprietary information owned by * Vivante Corporation. No part of this work may be disclosed, * reproduced, copied, transmitted, or used in any way for any purpose, * without the express written permission of Vivante Corporation. * *****************************************************************************/ /** * \file sarea.h * SAREA definitions. * * \author Kevin E. Martin <[email protected]> * \author Jens Owen <[email protected]> * \author Rickard E. (Rik) Faith <[email protected]> */ /* * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. * Copyright 2000 VA Linux Systems, Inc. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sub license, 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 (including the * next paragraph) 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 NON-INFRINGEMENT. * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS 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 _SAREA_H_ #define _SAREA_H_ #include "xf86drm.h" /* SAREA area needs to be at least a page */ #if defined(__alpha__) #define SAREA_MAX 0x2000 #elif defined(__ia64__) #define SAREA_MAX 0x10000 /* 64kB */ #else /* Intel 830M driver needs at least 8k SAREA */ #define SAREA_MAX 0x2000 #endif #define SAREA_MAX_DRAWABLES 256 #define SAREA_DRAWABLE_CLAIMED_ENTRY 0x80000000 /** * SAREA per drawable information. * * \sa _XF86DRISAREA. */ typedef struct _XF86DRISAREADrawable { unsigned int stamp; unsigned int flags; } XF86DRISAREADrawableRec, *XF86DRISAREADrawablePtr; /** * SAREA frame information. * * \sa _XF86DRISAREA. */ typedef struct _XF86DRISAREAFrame { unsigned int x; unsigned int y; unsigned int width; unsigned int height; unsigned int fullscreen; } XF86DRISAREAFrameRec, *XF86DRISAREAFramePtr; /** * SAREA definition. */ typedef struct _XF86DRISAREA { /** first thing is always the DRM locking structure */ drmLock lock; /** \todo Use readers/writer lock for drawable_lock */ drmLock drawable_lock; XF86DRISAREADrawableRec drawableTable[SAREA_MAX_DRAWABLES]; XF86DRISAREAFrameRec frame; drm_context_t dummy_context; } XF86DRISAREARec, *XF86DRISAREAPtr; typedef struct _XF86DRILSAREA { drmLock lock; drmLock otherLocks[31]; } XF86DRILSAREARec, *XF86DRILSAREAPtr; #endif
@import Foundation; #import "FDObjectTransformerAdapter.h" @interface FDURLComponentsTransformerAdapter : NSObject < FDObjectTransformerAdapter > @end
#include <stdlib.h> #include <stdio.h> #include <string.h> #include <time.h> #include "search.h" #include "marcov.h" #define ORDER 2 int main(int argc, char **argv) { int limit = 128; if(argc > 1) { limit = atoi(argv[1]); } void *strings = NULL; struct timespec t; clock_gettime(CLOCK_MONOTONIC, &t); srand(t.tv_nsec); marcov_t *m = NULL; marcov_load(&strings, &m, 0); char *nl = stringidx(&strings, "\n"); wordlist_t nlstart = (wordlist_t) {.num = 1, .w = &nl}; wordlist_t *wl = NULL; wl = marcov_randomstart(m, &nlstart); if(!wl) { wl = marcov_randomstart(m, NULL); } for(int i = 0; i < limit; i++) { char *line = marcov_getline(m); if(!line) { break; } printf("%s", line); free(line); } return 0; }
// Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2015 The Bitcoin developers // Copyright (c) 2015-2020 The Bitcoin Unlimited developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef BITCOIN_POLICY_POLICY_H #define BITCOIN_POLICY_POLICY_H #include "consensus/consensus.h" #include "script/interpreter.h" #include "script/standard.h" #include <string> class CCoinsViewCache; /** Default for -blockmaxsize and -blockminsize, which control the range of sizes the mining code will create **/ // this is now set in chain params static const unsigned int DEFAULT_BLOCK_MAX_SIZE_REGTEST = 1000; static const unsigned int DEFAULT_BLOCK_MAX_SIZE = 8 * ONE_MEGABYTE; static const unsigned int DEFAULT_BLOCK_MAX_SIZE_TESTNET4 = 2 * ONE_MEGABYTE; static const unsigned int DEFAULT_BLOCK_MAX_SIZE_SCALENET = 256 * ONE_MEGABYTE; // Maximum number of mining candidates that this node will remember simultaneously static const unsigned int DEFAULT_MAX_MINING_CANDIDATES = 10; // Send an existing mining candidate if a request comes in within this many seconds of its construction static const unsigned int DEFAULT_MIN_CANDIDATE_INTERVAL = 30; /** Default for -blockprioritysize for priority or zero/low-fee transactions **/ static const unsigned int DEFAULT_BLOCK_PRIORITY_SIZE = 0; /** The maximum size for transactions we're willing to relay/mine */ static const unsigned int MAX_STANDARD_TX_SIZE = 100000; /** * Biggest 'standard' txin is a 15-of-15 P2SH multisig with compressed * keys (remember the 520 byte limit on redeemScript size). That works * out to a (15*(33+1))+3=513 byte redeemScript, 513+1+15*(73+1)+3=1627 * bytes of scriptSig, which we round off to 1650 bytes for some minor * future-proofing. That's also enough to spend a 20-of-20 CHECKMULTISIG * scriptPubKey, though such a scriptPubKey is not considered standard. */ static constexpr unsigned int MAX_TX_IN_SCRIPT_SIG_SIZE = 1650; /** Maximum number of signature check operations in an IsStandard() P2SH script */ static const unsigned int MAX_P2SH_SIGOPS = 15; /** The maximum number of sigops we're willing to relay/mine in a single tx */ static const unsigned int MAX_STANDARD_TX_SIGOPS = MAX_TX_SIGOPS_COUNT / 5; /** Default for -maxmempool, maximum megabytes of mempool memory usage */ static const unsigned int DEFAULT_MAX_MEMPOOL_SIZE = 300; /** Dust threshold in satoshis. Historically this value was calculated as * minRelayTxFee/1000 * 546. However now we just allow the operator to set * a simple dust threshold independant of any other value or relay fee. */ static const unsigned int DEFAULT_DUST_THRESHOLD = 546; /** * Standard script verification flags that standard transactions will comply * with. However scripts violating these flags may still be present in valid * blocks and we must accept those blocks. */ /* clang-format off */ static const unsigned int STANDARD_SCRIPT_VERIFY_FLAGS = MANDATORY_SCRIPT_VERIFY_FLAGS | SCRIPT_VERIFY_DERSIG | SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS | SCRIPT_VERIFY_CLEANSTACK | SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY | SCRIPT_VERIFY_CHECKSEQUENCEVERIFY | SCRIPT_VERIFY_SIGPUSHONLY | SCRIPT_ENABLE_CHECKDATASIG | SCRIPT_DISALLOW_SEGWIT_RECOVERY; /* clang-format on */ /** For convenience, standard but not mandatory verify flags. */ static const unsigned int STANDARD_NOT_MANDATORY_VERIFY_FLAGS = STANDARD_SCRIPT_VERIFY_FLAGS & ~MANDATORY_SCRIPT_VERIFY_FLAGS; /** Used as the flags parameter to sequence and nLocktime checks in non-consensus code. */ static const unsigned int STANDARD_LOCKTIME_VERIFY_FLAGS = LOCKTIME_VERIFY_SEQUENCE | LOCKTIME_MEDIAN_TIME_PAST; bool IsStandard(const CScript &scriptPubKey, txnouttype &whichType); /** * Check for standard transaction types * @return True if all outputs (scriptPubKeys) use only standard transaction forms */ bool IsStandardTx(const CTransactionRef tx, std::string &reason); /** * Check for standard transaction types * @param[in] mapInputs Map of previous transactions that have outputs we're spending * @return True if all inputs (scriptSigs) use only standard transaction forms */ bool AreInputsStandard(const CTransactionRef tx, const CCoinsViewCache &mapInputs, bool isMay2020Enabled); #endif // BITCOIN_POLICY_POLICY_H
/* * main.c * * Created on: 31 May 2016 * Author: ajuaristi <[email protected]> */ #include <stdio.h> #include <signal.h> #include <getopt.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <linux/videodev2.h> #include <sys/stat.h> #include "utils.h" #include "appbase.h" #include "uvc.h" #define DEFAULT_WAIT_TIME 5 int stop; #define SHOULD_STOP(v) (stop = v) #define IS_STOPPED() (stop) static char *create_debug_filename() { #define COUNT_LIMIT 9 static unsigned int count = 0; char filename_template[] = "picture"; size_t size = sizeof(filename_template) + 2; char *filename = ec_malloc(size); snprintf(filename, size, "%s.%d", filename_template, count++); if (count > COUNT_LIMIT) count = 0; return filename; #undef COUNT_LIMIT } static void write_to_disk(const unsigned char *data, size_t size) { FILE *f; char *filename = create_debug_filename(); f = fopen(filename, "w"); if (f) { fwrite(data, size, 1, f); fclose(f); fprintf(stderr, "DEBUG: Frame written to file '%s'\n", filename); } free(filename); } static void print_usage_and_exit(const char *name) { if (name) { printf("Usage: %s [OPTIONS] <app name> <username> <password>\n" "Options:\n" " -w secs Sleep this amount of seconds between shots\n" " -d Display debug messages\n" " -s Take one single shot and exit\n" " -j Convert frames to JPEG\n" " -S Stream as fast as possible\n", name); } exit(1); } static void sighandler(int s) { char *signame; switch (s) { case SIGINT: signame = "SIGINT"; break; case SIGQUIT: signame = "SIGQUIT"; break; case SIGTERM: signame = "SIGTERM"; break; case SIGABRT: signame = "SIGABRT"; break; case SIGTRAP: signame = "SIGTRAP"; break; default: signame = NULL; break; } if (signame) fprintf(stderr, "Received %s. Exiting.", signame); else fprintf(stderr, "Received %d. Exiting.", s); /* Stop! */ SHOULD_STOP(1); } static void do_stream(struct appbase *ab, bool jpeg) { struct camera *c; c = uvc_open(); if (!c) fatal("Could not find any camera for capturing pictures"); c->frame = uvc_alloc_frame(320, 240, V4L2_PIX_FMT_YUYV); if (!c->frame) fatal("Could not allocate enough memory for frames"); if (!uvc_init(c)) fatal("Could not start camera for streaming"); while (!IS_STOPPED() && uvc_capture_frame(c)) { if (jpeg) frame_convert_yuyv_to_jpeg(c->frame); if (!appbase_push_frame(ab, c->frame->frame_data, c->frame->frame_bytes_used, &c->frame->capture_time)) { fprintf(stderr, "ERROR: Could not capture frame\n"); break; } c->frame->frame_bytes_used = 0; } uvc_close(c); } void do_capture(struct appbase *ab, unsigned int wait_time, bool oneshot, bool jpeg, bool debug) { struct camera *c; struct frame *f; while (!IS_STOPPED()) { c = uvc_open(); if (!c) fatal("Could not find any camera for capturing pictures"); c->frame = uvc_alloc_frame(320, 240, V4L2_PIX_FMT_YUYV); if (!c->frame) fatal("Could not allocate enough memory for frames"); if (!uvc_init(c)) fatal("Could not start camera for streaming"); if (uvc_capture_frame(c)) { f = c->frame; if (jpeg) frame_convert_yuyv_to_jpeg(f); if (!appbase_push_frame(ab, f->frame_data, f->frame_bytes_used, &f->capture_time)) fprintf(stderr, "ERROR: Could not send frame\n"); if (debug) write_to_disk(f->frame_data, f->frame_bytes_used); memset(f->frame_data, 0, f->frame_size); f->frame_bytes_used = 0; } else { fprintf(stderr, "ERROR: Could not capture frame\n"); } uvc_close(c); if (oneshot) break; /* * sleep(3) should not interfere with our signal handlers, * unless we're also handling SIGALRM */ sleep(wait_time); } } int main(int argc, char **argv) { int opt; char *endptr; long int wait_time = DEFAULT_WAIT_TIME; bool debug = false, oneshot = false, stream = false, jpeg = false; struct sigaction sig; struct appbase *ab; /* Parse command-line options */ while ((opt = getopt(argc, argv, "w:dsSj")) != -1) { switch (opt) { case 'w': wait_time = strtol(optarg, &endptr, 10); if (*endptr || wait_time < 0) print_usage_and_exit(argv[0]); break; case 'd': debug = true; break; case 's': oneshot = true; break; case 'S': stream = true; break; case 'j': jpeg = true; break; default: print_usage_and_exit(argv[0]); break; } } /* Set signal handlers and set stop condition to zero */ SHOULD_STOP(0); memset(&sig, 0, sizeof(sig)); sig.sa_handler = sighandler; sig.sa_flags = SA_RESETHAND; sigemptyset(&sig.sa_mask); sigaction(SIGINT, &sig, NULL); sigaction(SIGQUIT, &sig, NULL); sigaction(SIGTERM, &sig, NULL); sigaction(SIGABRT, &sig, NULL); sigaction(SIGTRAP, &sig, NULL); /* Set up Appbase handle * We need the app name, username and password to build the REST URL, and these * should came now as parameters. We expect optind to point us to the first one. */ if (argc - optind < 3) print_usage_and_exit(argv[0]); ab = appbase_open( argv[optind], // app name argv[optind + 1], // username argv[optind + 2], // password false); // streaming off if (!ab) fatal("Could not log into Appbase"); if (debug) { appbase_enable_progress(ab, true); appbase_enable_verbose(ab, true); } if (stream) do_stream(ab, jpeg); else do_capture(ab, wait_time, oneshot, jpeg, debug); appbase_close(ab); return 0; }
//estrutura com os dados lidos struct { float tensao; float corrente; float temperaturaBaterias; float temperaturaCockpit; float velocidade; //velocidade calculada do carro double hodometro; //armazena a quantidade de metros percorridos } dados; //estrutura com as configuracoes do controlador struct { long intervaloLeitura; //intervalo de leitura dos sensores float raioRoda; // raio da roda em mm byte qtdPulsos; // pulsos por volta recebidos pelo sensor de velocidade } cfg; void enviar(String cod, String msg) { Serial.println(" {\"" + cod + "\":\"" + msg + "\"}"); } /* * Funcao de regressao linear com com valores em ponto flutuante */ float converte(float x, float in_min, float in_max, float out_min, float out_max) { return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; } const int chipSelect = 10; /* Abre cartao de memoria */ boolean abreCartao(boolean forcar) { static boolean cartaoOK = false; if (!cartaoOK || forcar) { cartaoOK = SD.begin(chipSelect); if (!cartaoOK) { enviar("20", "Erro ao abrir o cartao SD!"); } } return cartaoOK; }
/******************************************************* * File name: pando_subdevice.h * Author: razr * Versions: 1.0 * Description: pando iot embeded framework. * History: * 1.Date: Sep 11, 2015 * Author: razr * Modification: initial code *********************************************************/ #ifndef PANDO_FRAMEWORK_H_ #define PANDO_FRAMEWORK_H_ void pando_framework_init(void); #endif /* PANDO_FRAMEWORK_H_ */
#ifndef ZOMBIE_HUMANPLAYER_H #define ZOMBIE_HUMANPLAYER_H #include "device.h" #include "physics/moving/unit.h" #include "player.h" #include "physics/moving/unit.h" #include <glm/gtx/rotate_vector.hpp> namespace zombie { class HumanPlayer : public Player { public: HumanPlayer(DevicePtr device, std::unique_ptr<Unit> unit) : device_{std::move(device)} , unit_{std::move(unit)} { } void updateInput(double time, double deltaTime) override { unit_->setInput(device_->nextInput()); unit_->updatePhysics(time, deltaTime); } void draw(sdl::Graphic& graphic) override { auto pos = unit_->getPosition(); graphic.addCircle({pos.x, pos.y}, unit_->getRadius(), sdl::color::html::DeepSkyBlue); graphic.addCircleOutline({pos.x, pos.y}, unit_->getViewDistance(), 0.1f, sdl::color::html::Firebrick); graphic.addLine({pos.x, pos.y}, glm::vec2{pos.x, pos.y} + glm::rotate(glm::vec2{1.f, 0.f}, unit_->getDirection()), 0.1f, sdl::color::html::Firebrick); } Unit* getUnit() const { return unit_.get(); } PhysicalObject* getPhysicalObject() override { return unit_.get(); } private: DevicePtr device_; std::unique_ptr<Unit> unit_; }; using HumanPlayerPtr = std::unique_ptr<HumanPlayer>; } #endif
// Copyright (c) 2014 The Okcash Developers // Distributed under the MIT/X11 software license, see the accompanying // file license.txt or http://www.opensource.org/licenses/mit-license.php. #ifndef COIN_STATE_H #define COIN_STATE_H #include <string> #include <limits> #include "sync.h" enum eNodeType { NT_FULL = 1, NT_THIN, NT_UNKNOWN // end marker }; enum eNodeState { NS_STARTUP = 1, NS_GET_HEADERS, NS_GET_FILTERED_BLOCKS, NS_READY, NS_UNKNOWN // end marker }; enum eBlockFlags { BLOCK_PROOF_OF_STAKE = (1 << 0), // is proof-of-stake block BLOCK_STAKE_ENTROPY = (1 << 1), // entropy bit for stake modifier BLOCK_STAKE_MODIFIER = (1 << 2), // regenerated stake modifier }; /* nServices flags top 32 bits of CNode::nServices are used to mark services required */ enum { NODE_NETWORK = (1 << 0), THIN_SUPPORT = (1 << 1), THIN_STAKE = (1 << 2), // deprecated THIN_STEALTH = (1 << 3), SMSG_RELAY = (1 << 4), }; const int64_t GENESIS_BLOCK_TIME = 1416737561; static const int64_t COIN = 100000000; static const int64_t CENT = 1000000; /** Fees smaller than this (in satoshi) are considered zero fee (for transaction creation) */ static const int64_t MIN_TX_FEE = 10000; static const int64_t MIN_TX_FEE_ANON = 1000000; /** Fees smaller than this (in satoshi) are considered zero fee (for relaying) */ static const int64_t MIN_RELAY_TX_FEE = MIN_TX_FEE; static const int64_t COIN_YEAR_REWARD = 69 * CENT; // 69% 1st Year static const int64_t SCOIN_YEAR_REWARD = 20 * CENT; // 20% 1st halving static const int64_t CCOIN_YEAR_REWARD = 10 * CENT; // 10% 2nd halving static const int64_t KCOIN_YEAR_REWARD = 5 * CENT; // 5% 3rd halving static const int64_t ICOIN_YEAR_REWARD = 2.5 * CENT; // 2.5% 4th halving static const int64_t OCOIN_YEAR_REWARD = 22 * CENT; // 22% 5th halving static const int64_t DCOIN_YEAR_REWARD = 11 * CENT; // 11% 6th halving static const int64_t RCOIN_YEAR_REWARD = 6.9 * CENT; // 6.9% 7th halving static const int64_t ECOIN_YEAR_REWARD = 3.9 * CENT; // 3.9% 8th halving static const int64_t ACOIN_YEAR_REWARD = 3.6 * CENT; // 3.6% 9th halving static const int64_t MCOIN_YEAR_REWARD = 3.3 * CENT; // 3.3% 10th halving static const int64_t ZCOIN_YEAR_REWARD = 3 * CENT; // 3% 11th halving static const int64_t XCOIN_YEAR_REWARD = 2 * CENT; // 2% 12th halving static const int64_t BCOIN_YEAR_REWARD = 1 * CENT; // 1% 13th halving static const int64_t GCOIN_YEAR_REWARD = 0.69 * CENT; // 0.69% 14th halving static const int64_t FCOIN_YEAR_REWARD = 0.33 * CENT; // 0.33% 15th halving and onwards static const int64_t MBLK_RECEIVE_TIMEOUT = 60; // seconds extern int nNodeMode; extern int nNodeState; extern int nMaxThinPeers; extern int nBloomFilterElements; extern int nMinStakeInterval; extern int nThinIndexWindow; static const int nTryStakeMempoolTimeout = 5 * 60; // seconds static const int nTryStakeMempoolMaxAsk = 16; extern uint64_t nLocalServices; extern uint32_t nLocalRequirements; extern bool fTestNet; extern bool fDebug; extern bool fDebugNet; extern bool fDebugSmsg; extern bool fDebugChain; extern bool fDebugRingSig; extern bool fDebugPoS; extern bool fNoSmsg; extern bool fPrintToConsole; extern bool fPrintToDebugLog; //extern bool fShutdown; extern bool fDaemon; extern bool fServer; extern bool fCommandLine; extern std::string strMiscWarning; extern bool fNoListen; extern bool fLogTimestamps; extern bool fReopenDebugLog; extern bool fThinFullIndex; extern bool fReindexing; extern bool fHaveGUI; extern volatile bool fIsStaking; extern bool fMakeExtKeyInitials; extern volatile bool fPassGuiAddresses; extern bool fConfChange; extern bool fEnforceCanonical; extern unsigned int nNodeLifespan; extern unsigned int nDerivationMethodIndex; extern unsigned int nMinerSleep; extern unsigned int nBlockMaxSize; extern unsigned int nBlockPrioritySize; extern unsigned int nBlockMinSize; extern int64_t nMinTxFee; extern unsigned int nStakeSplitAge; extern int nStakeMinConfirmations; extern int64_t nStakeSplitThreshold; extern int64_t nStakeCombineThreshold; extern uint32_t nExtKeyLookAhead; extern int64_t nTimeLastMblkRecv; #endif /* COIN_STATE_H */
/*********************************************************************** * Copyright (c) 2015 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * * file COPYING or https://www.opensource.org/licenses/mit-license.php.* ***********************************************************************/ /**** * Please do not link this file directly. It is not part of the libsecp256k1 * project and does not promise any stability in its API, functionality or * presence. Projects which use this code should instead copy this header * and its accompanying .c file directly into their codebase. ****/ /* This file defines a function that parses DER with various errors and * violations. This is not a part of the library itself, because the allowed * violations are chosen arbitrarily and do not follow or establish any * standard. * * In many places it matters that different implementations do not only accept * the same set of valid signatures, but also reject the same set of signatures. * The only means to accomplish that is by strictly obeying a standard, and not * accepting anything else. * * Nonetheless, sometimes there is a need for compatibility with systems that * use signatures which do not strictly obey DER. The snippet below shows how * certain violations are easily supported. You may need to adapt it. * * Do not use this for new systems. Use well-defined DER or compact signatures * instead if you have the choice (see secp256k1_ecdsa_signature_parse_der and * secp256k1_ecdsa_signature_parse_compact). * * The supported violations are: * - All numbers are parsed as nonnegative integers, even though X.609-0207 * section 8.3.3 specifies that integers are always encoded as two's * complement. * - Integers can have length 0, even though section 8.3.1 says they can't. * - Integers with overly long padding are accepted, violation section * 8.3.2. * - 127-byte long length descriptors are accepted, even though section * 8.1.3.5.c says that they are not. * - Trailing garbage data inside or after the signature is ignored. * - The length descriptor of the sequence is ignored. * * Compared to for example OpenSSL, many violations are NOT supported: * - Using overly long tag descriptors for the sequence or integers inside, * violating section 8.1.2.2. * - Encoding primitive integers as constructed values, violating section * 8.3.1. */ #ifndef SECP256K1_CONTRIB_LAX_DER_PARSING_H #define SECP256K1_CONTRIB_LAX_DER_PARSING_H /* #include secp256k1.h only when it hasn't been included yet. This enables this file to be #included directly in other project files (such as tests.c) without the need to set an explicit -I flag, which would be necessary to locate secp256k1.h. */ #ifndef SECP256K1_H #include <secp256k1.h> #endif #ifdef __cplusplus extern "C" { #endif /** Parse a signature in "lax DER" format * * Returns: 1 when the signature could be parsed, 0 otherwise. * Args: ctx: a secp256k1 context object * Out: sig: a pointer to a signature object * In: input: a pointer to the signature to be parsed * inputlen: the length of the array pointed to be input * * This function will accept any valid DER encoded signature, even if the * encoded numbers are out of range. In addition, it will accept signatures * which violate the DER spec in various ways. Its purpose is to allow * validation of the Syscoin blockchain, which includes non-DER signatures * from before the network rules were updated to enforce DER. Note that * the set of supported violations is a strict subset of what OpenSSL will * accept. * * After the call, sig will always be initialized. If parsing failed or the * encoded numbers are out of range, signature validation with it is * guaranteed to fail for every message and public key. */ int ecdsa_signature_parse_der_lax( const secp256k1_context* ctx, secp256k1_ecdsa_signature* sig, const unsigned char *input, size_t inputlen ) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3); #ifdef __cplusplus } #endif #endif /* SECP256K1_CONTRIB_LAX_DER_PARSING_H */
// This file was generated based on 'C:\ProgramData\Uno\Packages\Uno.Collections\0.13.2\Extensions\$.uno'. // WARNING: Changes might be lost if you edit this file directly. #ifndef __APP_UNO_COLLECTIONS_UNION_ENUMERATOR__OUTRACKS_SIMULATOR_BYTECODE_STATEMENT_H__ #define __APP_UNO_COLLECTIONS_UNION_ENUMERATOR__OUTRACKS_SIMULATOR_BYTECODE_STATEMENT_H__ #include <app/Uno.Collections.IEnumerator.h> #include <app/Uno.Collections.IEnumerator__Outracks_Simulator_Bytecode_Statement.h> #include <app/Uno.IDisposable.h> #include <app/Uno.Object.h> #include <Uno.h> namespace app { namespace Outracks { namespace Simulator { namespace Bytecode { struct Statement; } } } } namespace app { namespace Uno { namespace Collections { struct UnionEnumerator__Outracks_Simulator_Bytecode_Statement; struct UnionEnumerator__Outracks_Simulator_Bytecode_Statement__uType : ::uClassType { ::app::Uno::Collections::IEnumerator__Outracks_Simulator_Bytecode_Statement __interface_0; ::app::Uno::IDisposable __interface_1; ::app::Uno::Collections::IEnumerator __interface_2; }; UnionEnumerator__Outracks_Simulator_Bytecode_Statement__uType* UnionEnumerator__Outracks_Simulator_Bytecode_Statement__typeof(); void UnionEnumerator__Outracks_Simulator_Bytecode_Statement___ObjInit(UnionEnumerator__Outracks_Simulator_Bytecode_Statement* __this, ::uObject* first, ::uObject* second); void UnionEnumerator__Outracks_Simulator_Bytecode_Statement__Dispose(UnionEnumerator__Outracks_Simulator_Bytecode_Statement* __this); ::app::Outracks::Simulator::Bytecode::Statement* UnionEnumerator__Outracks_Simulator_Bytecode_Statement__get_Current(UnionEnumerator__Outracks_Simulator_Bytecode_Statement* __this); bool UnionEnumerator__Outracks_Simulator_Bytecode_Statement__MoveNext(UnionEnumerator__Outracks_Simulator_Bytecode_Statement* __this); UnionEnumerator__Outracks_Simulator_Bytecode_Statement* UnionEnumerator__Outracks_Simulator_Bytecode_Statement__New_1(::uStatic* __this, ::uObject* first, ::uObject* second); void UnionEnumerator__Outracks_Simulator_Bytecode_Statement__Reset(UnionEnumerator__Outracks_Simulator_Bytecode_Statement* __this); struct UnionEnumerator__Outracks_Simulator_Bytecode_Statement : ::uObject { ::uStrong< ::uObject*> _current; ::uStrong< ::uObject*> _first; ::uStrong< ::uObject*> _second; void _ObjInit(::uObject* first, ::uObject* second) { UnionEnumerator__Outracks_Simulator_Bytecode_Statement___ObjInit(this, first, second); } void Dispose() { UnionEnumerator__Outracks_Simulator_Bytecode_Statement__Dispose(this); } ::app::Outracks::Simulator::Bytecode::Statement* Current() { return UnionEnumerator__Outracks_Simulator_Bytecode_Statement__get_Current(this); } bool MoveNext() { return UnionEnumerator__Outracks_Simulator_Bytecode_Statement__MoveNext(this); } void Reset() { UnionEnumerator__Outracks_Simulator_Bytecode_Statement__Reset(this); } }; }}} #endif
#ifndef SKULL_SERVICE_TYPES_H #define SKULL_SERVICE_TYPES_H #include "api/sk_txn.h" #include "api/sk_service.h" struct _skull_service_t { sk_service_t* service; const sk_txn_t* txn; sk_txn_taskdata_t* task; // If freezed == 1, user cannot use set/get apis to touch data. Instead // user should create a new service job for that purpose int freezed; int _reserved; }; #endif
#ifndef APPSETTINGSSTORAGE_H #define APPSETTINGSSTORAGE_H #include <QDebug> #include <QCoreApplication> #include <QString> #include <QMap> #include <QSettings> #include <QDir> class AppSettingsStorage { public: enum Settings { ACCOUNT_LOGIN = 0, ACCOUNT_PASS, APP_RUN_ON_BOOT, APP_START_MINIMIZED, APP_STATUS }; AppSettingsStorage(); static void initColumnNames() { settingsMap.insert(ACCOUNT_LOGIN, "account/login"); settingsMap.insert(ACCOUNT_PASS, "account/password"); settingsMap.insert(APP_RUN_ON_BOOT, "app/runOnbootCheckBox"); settingsMap.insert(APP_START_MINIMIZED, "app/startMinimizedCheckBox"); settingsMap.insert(APP_STATUS, "app/status"); } QMap<QString, QString> loadSettings(); void storeSettings(QMap<QString, QString> properties); signals: public slots: public: const static QSettings *settings; static QMap<Settings, QString> settingsMap; }; #endif // APPSETTINGSSTORAGE_H
#include <stdio.h> int main() { int current_char, previous_char; printf("Input text below, multiple spaces will be escaped:\n"); previous_char = -1; while((current_char = getchar()) != EOF) { if (!(current_char == ' ' && previous_char == ' ')) { putchar(current_char); } previous_char = current_char; } }
6650 #include "types.h" 6651 #include "x86.h" 6652 6653 void* 6654 memset(void *dst, int c, uint n) 6655 { 6656 if ((int)dst%4 == 0 && n%4 == 0){ 6657 c &= 0xFF; 6658 stosl(dst, (c<<24)|(c<<16)|(c<<8)|c, n/4); 6659 } else 6660 stosb(dst, c, n); 6661 return dst; 6662 } 6663 6664 int 6665 memcmp(const void *v1, const void *v2, uint n) 6666 { 6667 const uchar *s1, *s2; 6668 6669 s1 = v1; 6670 s2 = v2; 6671 while(n-- > 0){ 6672 if(*s1 != *s2) 6673 return *s1 - *s2; 6674 s1++, s2++; 6675 } 6676 6677 return 0; 6678 } 6679 6680 void* 6681 memmove(void *dst, const void *src, uint n) 6682 { 6683 const char *s; 6684 char *d; 6685 6686 s = src; 6687 d = dst; 6688 if(s < d && s + n > d){ 6689 s += n; 6690 d += n; 6691 while(n-- > 0) 6692 *--d = *--s; 6693 } else 6694 while(n-- > 0) 6695 *d++ = *s++; 6696 6697 return dst; 6698 } 6699 6700 // memcpy exists to placate GCC. Use memmove. 6701 void* 6702 memcpy(void *dst, const void *src, uint n) 6703 { 6704 return memmove(dst, src, n); 6705 } 6706 6707 int 6708 strncmp(const char *p, const char *q, uint n) 6709 { 6710 while(n > 0 && *p && *p == *q) 6711 n--, p++, q++; 6712 if(n == 0) 6713 return 0; 6714 return (uchar)*p - (uchar)*q; 6715 } 6716 6717 char* 6718 strncpy(char *s, const char *t, int n) 6719 { 6720 char *os; 6721 6722 os = s; 6723 while(n-- > 0 && (*s++ = *t++) != 0) 6724 ; 6725 while(n-- > 0) 6726 *s++ = 0; 6727 return os; 6728 } 6729 6730 // Like strncpy but guaranteed to NUL-terminate. 6731 char* 6732 safestrcpy(char *s, const char *t, int n) 6733 { 6734 char *os; 6735 6736 os = s; 6737 if(n <= 0) 6738 return os; 6739 while(--n > 0 && (*s++ = *t++) != 0) 6740 ; 6741 *s = 0; 6742 return os; 6743 } 6744 6745 6746 6747 6748 6749 6750 int 6751 strlen(const char *s) 6752 { 6753 int n; 6754 6755 for(n = 0; s[n]; n++) 6756 ; 6757 return n; 6758 } 6759 6760 6761 6762 6763 6764 6765 6766 6767 6768 6769 6770 6771 6772 6773 6774 6775 6776 6777 6778 6779 6780 6781 6782 6783 6784 6785 6786 6787 6788 6789 6790 6791 6792 6793 6794 6795 6796 6797 6798 6799
#ifndef LM75_H_ #define LM75_H_ /******************************************************************************/ /** \file Lm75.h ******************************************************************************* * * \brief This module allows to read the temperature of an attached lm75 * device. * <p> * The LM75A is an industry-standard digital temperature sensor * with an integrated Sigma-Delta analog-to-digital converter and * I2C interface. The LM75A provides 9-bit digital temperature * readings with an accuracy of +/-2°C from -25°C to 100°C and * +/-3°C over -55°C to 125°C. The temperature data output of the * LM75 is available at all times via the I2C bus. * * \author wht4 * ******************************************************************************/ /* * function readTempLm75 * ******************************************************************************/ //----- Header-Files ----------------------------------------------------------- #include <stdint.h> #include "BBBTypes.h" //----- Macros ----------------------------------------------------------------- #define LM75_DEVICE "/dev/i2c-1" #define LM75_ADDR ( 0x48 ) //----- Data types ------------------------------------------------------------- //----- Function prototypes ---------------------------------------------------- extern BBBError readTempLm75(int32_t *ps32Temp); //----- Data ------------------------------------------------------------------- #endif /* LM75_H_ */
#include<stdio.h> #include<math.h> #include<conio.h> #include<ctype.h> int i,j,cash=100; void wheel(); void game(int r); void game_over(); int suit_bet(); int cash_bet(); int roll_wheel(); int roll_dice(); void wheel_count(int c,int h,int s); void dice_count(int d,int h); int w[9][9]={ {32,32,32,32,2,32,32,32,32}, {32,32,32,3,5,4,32,32,32}, {32,32,5,4,3,6,5,32,32}, {32,4,3,6,5,3,4,6,32}, {2,6,5,4,15,5,3,6,2}, {32,3,6,3,4,5,4,3,32}, {32,32,5,6,3,4,5,32,32}, {32,32,32,4,6,6,32,32,32}, {32,32,32,32,2,32,32,32,32} }; void main(){ int round; char e; //game intro printf("\t\t\tWelcome to Roullette\n\n"); //game instruction printf("Game Instructions:\n\n"); printf("Diamond(d)=%c Hearts(h)=%c Clubs(c)=%c Spades(s)=%c Jack(j)=%c Bull's Eye=%c \n",4,3,5,6,2,15); printf("\n-The game starts with $100 \n-You chooses how many rounds to play \n-Then bet with cash on Suits,Jack and Null spaces of the wheel on which the dice will hit \n-A dice is thrown \n-If the dice hits the betting suit then you earn the betting cash.\n"); printf("-If the dice hits suits other than the betting one then you lose $10\n"); printf("-If it hits any of the Null spaces which is not bet then you lose bet cash \n"); printf("-If it hits the Jack which is bet then you earn the beting cash + $100 otherwise you earn only the bet cash \n"); printf("-Your cash is doubled if you hit the Bull's Eye \n"); printf("\n\n"); printf("Press Enter to Start Game"); scanf("%c",&e); if(e=='\n'){ printf("\nThe Roullette Wheel: \n\n"); wheel(); printf("\n\nYour Cash: $%d",cash); printf("\n\nHow many rounds you want to play: "); scanf("%d",&round); printf("\n\nYour Cash : $%d \n",cash); game(round); printf("\n\n"); printf("\t %d rounds completed!! \n\n\tYou Earned Total $%d !!\n\n",round,cash); } else{ printf("\nSorry!!\nYou Entered The Wrong Key!!\n"); } } //game on void game(int r){ int count; for(count=1;count<=r;count++){ int suit,ca,hit,dice; fflush(stdin); suit=suit_bet(); ca=cash_bet(); hit=roll_wheel(); dice=roll_dice(); wheel_count(ca,hit,suit); dice_count(dice,hit); printf("\n"); wheel(); printf("\n\nCash: $%d \nSuit Bet: %c \nCash Bet: $%d \nWheel Hit: %c \nDice: %d\n\n\n",cash,suit,ca,hit,dice); } } //show wheel void wheel(){ for(i=0;i<9;i++){ for(j=0;j<9;j++){ printf("%c ",w[i][j]); } printf("\n"); } } //betting on suit int suit_bet(){ char s; int k; printf("Suit Bet: "); s=getchar(); s=tolower(s); switch(s){ case 'h': k=3; break; case 'd': k=4; break; case 'c': k=5; break; case 's': k=6; break; case 'j': k=2; break; case 'n': k=32; break; default: k=0; } return k; } //betting on cash int cash_bet(){ int c; printf("Cash Bet: $"); scanf("%d",&c); return c; } //rolling the wheel int roll_wheel(){ float m,n; int wh1,wh2,res; m=rand()/32768.0; n=rand()/32768.0; wh1=(int) (m*9); wh2=(int) (n*9); res=w[wh1][wh2]; w[wh1][wh2]=249; return res; } //rolling the dice int roll_dice(){ float d; int res; d=rand()/32768.0; res=(int) (d*6)+1; return res; } //cash update form wheel hit void wheel_count(int c,int h,int s){ if(h==s){ if(h==2){ cash=cash+c+100; }else{ cash=cash+c; } } else if(h==3 || h==4 || h==5 || h==6){ cash=cash-10; } else if(h==32){ cash=cash-c; } else if(h==2){ cash=cash+c; } if(s==2 && h!=2){ cash=cash-50; } } //cash update from dice throw void dice_count(int d,int h){ if(h==3 || h==4 || h==5 || h==6){ if(d==6){ cash=cash+20; } } else if(h==15){ cash=2*cash; } else if(h==249){ if(d==6){ cash=cash+20; } } } //game end/over
#include "..\stdafx.h" #pragma once class CMutex { private: HANDLE m_mutex; bool m_isLocked; void Lock() { WaitForSingleObject(this->m_mutex, INFINITE); } void Unlock() { if (this->m_isLocked) { this->m_isLocked = false; ReleaseMutex(this->m_mutex); } } public: CMutex() { this->m_mutex = CreateMutex(NULL, FALSE, NULL); } ~CMutex() { CloseHandle(this->m_mutex); } friend class CMutexLock; }; class CMutexLock { private: CMutex* m_mutexObj; public: CMutexLock(CMutex* mutex) { this->m_mutexObj = mutex; this->m_mutexObj->Lock(); } ~CMutexLock() { this->m_mutexObj->Unlock(); } };
/******************************************************************************** * The MIT License (MIT) * * * * Copyright (C) 2016 Alex Nolasco * * * *Permission is hereby granted, free of charge, to any person obtaining a copy * *of this software and associated documentation files (the "Software"), to deal * *in the Software without restriction, including without limitation the rights * *to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * *copies of the Software, and to permit persons to whom the Software is * *furnished to do so, subject to the following conditions: * *The above copyright notice and this permission notice shall be included in * *all copies or substantial portions of the Software. * * * *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * *IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * *FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * *AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * *LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * *OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * *THE SOFTWARE. * *********************************************************************************/ #import <Foundation/Foundation.h> #import "HL7SummaryProtocol.h" @class HL7PatientSummary; @class HL7ClinicalDocumentSummary; typedef NSDictionary<NSString *, id<HL7SummaryProtocol>> NSDictionaryTemplateIdToSummary; @interface HL7CCDSummary : NSObject <NSCopying, NSCoding> - (HL7ClinicalDocumentSummary *_Nullable)document; - (HL7PatientSummary *_Nullable)patient; - (NSDictionaryTemplateIdToSummary *_Nullable)summaries; - (id<HL7SummaryProtocol> _Nullable)getSummaryByClass:(Class _Nonnull)className; @end
// // ViewController.h // MKDevice // // Created by Michal Konturek on 18/11/2013. // Copyright (c) 2013 Michal Konturek. All rights reserved. // #import <UIKit/UIKit.h> @interface ViewController : UIViewController @property (nonatomic, strong) IBOutlet UIButton *button; - (IBAction)onAction:(id)sender; @end
// // UIBarButtonItem+initWithImageName.h // lottowinnersv2 // // Created by Mac Mini on 4/17/14. // Copyright (c) 2014 com.qaik. All rights reserved. // #import <UIKit/UIKit.h> @interface UIBarButtonItem (initWithImageName) + (instancetype)barbuttonItemWithImage:(UIImage *)image target:(id)target action:(SEL)action; + (instancetype)barbuttonItemWithImage:(UIImage *)image title:(NSString *)title target:(id)target action:(SEL)action; + (instancetype)barbuttonItemWithImage:(UIImage *)image disableImage:(UIImage *)disableImage title:(NSString *)title target:(id)target action:(SEL)action; @end
#ifndef _SIMPLE_POLYGON_H #define _SIMPLE_POLYGON_H #include <vector> #include <QtOpenGL> #include "AGVector.h" #include "Triangulate.h" #define MAX_DIST 0.1 using std::vector; class SimplePolygon { public: SimplePolygon(); ~SimplePolygon(); void DrawPolygon(); void Clear(); void Update(AGVector v, bool remove); void Update(); bool getTriangulate() {return _triangulate;}; void setTriangulate(bool b) {_triangulate = b;}; bool isColored() {return _color;}; void setColored(bool b) {_color = b;}; private: vector<AGVector> *vertices; vector<AGVector *> *triVerts; int findPoint(AGVector v); bool threeColor(vector<AGVector *> &tris); int adjacent(AGVector **tri1, AGVector **tri2); bool _triangulate; bool _color; }; #endif /* _SIMPLE_POLYGON_H */
// // XCPreferenceController.h // XCRegex // // Created by alexiuce  on 2017/6/22. // Copyright © 2017年 zhidier. All rights reserved. // #import <Cocoa/Cocoa.h> @interface XCPreferenceController : NSWindowController @end
// // Generated by class-dump 3.5 (64 bit). // // class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2013 by Steve Nygard. // #import "NSObject.h" @class IBConnection, NSSet, NSString; @interface IBDragConnectionContext : NSObject { NSString *connectionName; long long relationshipType; NSString *sourceClassName; id source; IBConnection *prototype; BOOL limitToInterfaceBuilder; NSSet *endPointProvidingDocuments; } @property(readonly) NSSet *endPointProvidingDocuments; // @synthesize endPointProvidingDocuments; @property(readonly) BOOL limitToInterfaceBuilder; // @synthesize limitToInterfaceBuilder; @property(readonly) NSString *connectionName; // @synthesize connectionName; @property(readonly) long long relationshipType; // @synthesize relationshipType; @property(readonly) NSString *sourceClassName; // @synthesize sourceClassName; @property(readonly) IBConnection *prototype; // @synthesize prototype; @property(readonly) id source; // @synthesize source; - (void).cxx_destruct; - (id)initWithConnectionName:(id)arg1 relationshipType:(long long)arg2 sourceClassName:(id)arg3 endPointProvidingDocuments:(id)arg4 limitedToInterfaceBuilder:(BOOL)arg5; - (id)initWithPrototype:(id)arg1 endPointProvidingDocuments:(id)arg2; - (id)initWithSource:(id)arg1 endPointProvidingDocuments:(id)arg2; @end
/* * engine.h * * Created on: Mar 9, 2017 * Author: sushil */ #ifndef ENGINE_H_ #define ENGINE_H_ class InputMgr; #include <GfxMgr.h> #include <inputMgr.h> #include <EntityMgr.h> #include <gameMgr.h> #include <Types.h> #include <UiMgr.h> #include <SoundMgr.h> #include <Grid.h> class EntityMgr; class Engine { private: public: Engine(); ~Engine(); EntityMgr* entityMgr; GfxMgr* gfxMgr; InputMgr* inputMgr; GameMgr* gameMgr; UiMgr* uiMgr; SoundMgr* soundMgr; Grid* gridMgr; //ControlMgr* controlMgr; void init(); void run(); void tickAll(float dt); void stop(); void shutdown(); void loadLevel(); // bool keepRunning; bool omegaOn; STATE theState;//Stores the current state that the engine is in float timeSinceLastEvent;//Stores the time (usually) since last state change }; #endif /* ENGINE_H_ */
// // ViewController.h // Examples // // Created by Tim Moose on 2/11/14. // Copyright (c) 2014 Tractable Labs. All rights reserved. // #import <UIKit/UIKit.h> #import <TLIndexPathTools/TLTableViewController.h> @interface SelectorTableViewController : TLTableViewController @end
/* * PanoramaGL library * Version 0.1 * Copyright (c) 2010 Javier Baez <[email protected]> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #import <UIKit/UIKit.h> @interface AppDelegate : UIResponder <UIApplicationDelegate> @property (strong, nonatomic) UIWindow *window; - (void)logout; @end
/* * Copyright (c) Tomohiro Iizuka. All rights reserved. * Licensed under the MIT license. */ #ifndef SYSTEM_HASHEDRAWARRAY_H_ #define SYSTEM_HASHEDRAWARRAY_H_ namespace alinous { template <typename T, typename H, typename C> class HashedRawArray { public: void* operator new(size_t size) throw() { return SysThread::getMalloc()->allocate(size); } void* operator new(size_t size, MemoryInterface* ctx) throw() { return ctx->alloc->allocate(size); } void operator delete(void* p, size_t size) throw() { SysThread::getMalloc()->freeMemory((char*)p, size); } int MAX_HASH = 128; int MAX_HASH_MASK = 128 - 1; RawArray<T, C> **arrays; RawBitSet bitset; const H hashBaseFunc; int numElements; HashedRawArray(int maxHash) throw() : MAX_HASH(maxHash), MAX_HASH_MASK(maxHash - 1), bitset(MAX_HASH / 8), hashBaseFunc(), numElements(0) { initArrays(); } HashedRawArray() throw() : bitset(MAX_HASH / 8), hashBaseFunc(), numElements(0) { initArrays(); } private: void initArrays() throw() { this->MAX_HASH_MASK = this->MAX_HASH - 1; this->arrays = new RawArray<T, C>* [this->MAX_HASH]; int maxLoop = this->MAX_HASH; RawArray<T, C>** ptr = this->arrays; for(int i = 0; i != maxLoop; ++i){ ptr[i] = new RawArray<T, C>(); } } public: virtual ~HashedRawArray() throw() { int maxLoop = this->MAX_HASH; for(int i = 0; i != maxLoop; ++i){ delete this->arrays[i]; } delete [] this->arrays; this->arrays = nullptr; } int size() const throw() { return this->numElements; } T* addElement(T* ptr) throw() { u_int64_t hashcode = getHash(ptr); arrays[hashcode]->addElementWithSorted(ptr); bitset.set(hashcode); ++numElements; return ptr; } bool removeByObj(const T* obj) throw() { int hashcode = getHash(obj); bool result = arrays[hashcode]->removeByObj(obj); if(result){ --numElements; } if(arrays[hashcode]->size() == 0){ bitset.clear(hashcode); } return result; } T* search(const T* value)throw(){ int hashcode = getHash(value); return arrays[hashcode]->search(value); } void reset() throw() { for(int i = 0; i != MAX_HASH; i++){ arrays[i]->reset(); } bitset.clear(); numElements = 0; } class Iterator { public: int MAX_HASH; int hashCode; int index; RawArray<T, C>** arrays; const RawBitSet* bitset; Iterator(RawArray<T, C>** ptr, RawBitSet* bitset, int MAX_HASH) throw() : MAX_HASH(MAX_HASH), hashCode(0), index(0), arrays(ptr), bitset(bitset) {} bool hasNext() const throw() { RawArray<T, C>* current = arrays[hashCode]; if(current->size() == index){ const int nextHash = hashCode + 1; if(nextHash == MAX_HASH){ return false; } int next = bitset->nextSetBit(nextHash); if(next < 0){ return false; } return true; } return true; } T* next() throw() { const RawArray<T, C>* current = arrays[hashCode]; if(current->size() == index){ const int nextHash = hashCode + 1; int next = bitset->nextSetBit(nextHash); if(nextHash == MAX_HASH || next < 0){ return nullptr; } index = 0; hashCode = next; } current = *(arrays + hashCode); return current->get(index++); } }; Iterator iterator() throw() { return Iterator(arrays, &bitset, this->MAX_HASH); } private: u_int64_t getHash(const T* ptr) const throw() { u_int64_t num = hashBaseFunc(ptr); //int code = FNVHash::fnv_1_hash_32((uint8_t *)&num, sizeof(u_int64_t)) % MAX_HASH; //int code = (num >> 1) % MAX_HASH; u_int64_t code = ((num * 2654404609L) >> 32) & MAX_HASH_MASK; //wprintf(L"%llx --> %d\n", num, code); return code; } }; } /* namespace alinous */ #endif /* SYSTEM_HASHEDRAWARRAY_H_ */
#ifndef MYY_DATA_SECTION_H #define MYY_DATA_SECTION_H 1 #include <stdint.h> struct data_section_status { unsigned int allocated; void * address; }; struct data_symbol { uint32_t id; uint32_t align; uint32_t size; uint8_t * name; uint8_t * data; }; struct data_section { struct data_symbol * symbols; uint32_t stored; uint32_t next_id; uint32_t base_address; uint32_t max_symbols_before_realloc; }; struct data_section_symbol_added { unsigned int added; unsigned int id; }; struct data_section * generate_data_section(); unsigned int expand_data_symbols_storage_in (struct data_section * __restrict const data_section); struct data_section_symbol_added data_section_add (struct data_section * __restrict const data_section, unsigned int const alignment, unsigned int const size, uint8_t const * __restrict const name, uint8_t const * __restrict const data); struct uint32_result { unsigned int found; uint32_t value; }; struct symbol_found { unsigned int found; struct data_symbol * address; }; struct symbol_found get_data_symbol_infos (struct data_section const * __restrict const data_infos, uint32_t id); void exchange_symbols_order (struct data_section * __restrict const data_section, unsigned int const id1, unsigned int const id2); uint32_t write_data_section_content (struct data_section const * __restrict const symbols, uint8_t * __restrict const dest); void delete_data_symbol (struct data_section * __restrict const data_section, uint32_t id); uint32_t data_section_size (struct data_section const * __restrict const data_section); #define data_address_func_sig struct data_section const * __restrict const data_section,\ uint32_t const data_id uint32_t data_address(data_address_func_sig); uint32_t data_address_upper16(data_address_func_sig); uint32_t data_address_lower16(data_address_func_sig); uint32_t data_size(data_address_func_sig); void update_data_symbol (struct data_section * __restrict const data_section, uint32_t const id, uint32_t const align, uint32_t const data_size, uint8_t const * __restrict const name, uint8_t const * __restrict const data); void data_section_set_base_address (struct data_section * __restrict const data_section, uint32_t const base_address); #endif
//********************************************** //Singleton Texture Manager class //Written by Ben English //[email protected] // //For use with OpenGL and the FreeImage library //********************************************** #ifndef TextureManager_H #define TextureManager_H #include <windows.h> //#include <GL/glew.h> //#include <GL/glfw.h> #include <gl/gl.h> #include "FreeImage.h" #include <map> class TextureManager { public: static TextureManager* Inst(); virtual ~TextureManager(); //load a texture an make it the current texture //if texID is already in use, it will be unloaded and replaced with this texture bool LoadTexture(const char* filename, //where to load the file from const unsigned int texID, //arbitrary id you will reference the texture by //does not have to be generated with glGenTextures GLenum image_format = GL_RGB, //format the image is in GLint internal_format = GL_RGB, //format to store the image in GLint level = 0, //mipmapping level GLint border = 0); //border size //free the memory for a texture bool UnloadTexture(const unsigned int texID); //set the current texture bool BindTexture(const unsigned int texID); //free all texture memory void UnloadAllTextures(); protected: TextureManager(); TextureManager(const TextureManager& tm); TextureManager& operator=(const TextureManager& tm); static TextureManager* m_inst; std::map<unsigned int, GLuint> m_texID; }; #endif
#import "MOBProjection.h" @interface MOBProjectionEPSG102713 : MOBProjection @end
#ifndef __UIDICTIONARY_H #define __UIDICTIONARY_H #include <System/Tools/Array.h> #include <System/Tools/HashHelper.h> namespace suic { template<typename TKey, typename TValue, typename Comparer> class Dictionary1 { public: Dictionary1() { Initialize(0); } Dictionary1(int capacity) { Initialize(capacity); } public: void Add(TKey key, TValue value) { Insert(key, value, true); } bool Remove(TKey key) { if (_buckets.Length() > 0) { int num = _comparer.GetHashCode(key) & 0x7fffffff; int index = num % _buckets.length; int num3 = -1; for (int i = _buckets[index]; i >= 0; i = _entries[i].next) { if ((_entries[i].hashCode == num) && _comparer.Equals(_entries[i].key, key)) { if (num3 < 0) { _buckets[index] = _entries[i].next; } else { _entries[num3].next = _entries[i].next; } _entries[i].hashCode = -1; _entries[i].next = freeList; OnCleanPair(_entries[i]); _entries[i].key = TKey(); _entries[i].value = TValue(); freeList = i; freeCount++; version++; return true; } num3 = i; } } return false; } bool TryGetValue(TKey key, TValue& value) { int index = FindEntry(key); if (index >= 0) { value = _entries[index].value; return true; } else { value = TValue(); return false; } } void Clear() { if (count > 0) { for (int i = 0; i < _buckets.length; i++) { _buckets[i] = -1; } for (int i = 0; i < _entries.Length(); ++i) { if (_entries[i].hashCode > 0) { OnCleanPair(_entries[i]); } } _entries.Clear(); freeList = -1; count = 0; freeCount = 0; version++; } } bool ContainsKey(TKey key) { return (FindEntry(key) >= 0); } private: int FindEntry(TKey key) { if (_buckets.Length() > 0) { int num = _comparer.GetHashCode(key) & 0x7fffffff; for (int i = _buckets[num % _buckets.length]; i >= 0; i = _entries[i].next) { if ((_entries[i].hashCode == num) && _comparer.Equals(_entries[i].key, key)) { return i; } } } return -1; } void Initialize(int capacity) { int prime = HashHelper::GetPrime(capacity); _buckets.Resize(prime); for (int i = 0; i < _buckets.length; i++) { _buckets[i] = -1; } _entries.Resize(prime); freeList = -1; } void Insert(TKey key, TValue value, bool add) { int freeList = 0; if (_buckets.Length() == 0) { Initialize(1); } int num = _comparer.GetHashCode(key) & 0x7fffffff; int index = num % _buckets.length; int num3 = 0; for (int i = _buckets[index]; i >= 0; i = _entries[i].next) { if ((_entries[i].hashCode == num) && _comparer.Equals(_entries[i].key, key)) { // ÒѾ­´æÔÚ if (add) { throw InvalidOperationException(_U("Key of dictionary is exist!"), __FILELINE__); } _entries[i].value = value; version++; OnReplaceItem(_entries[i], value); return; } num3++; } if (freeCount > 0) { freeList = freeList; freeList = _entries[freeList].next; freeCount--; } else { if (count == _entries.length) { Resize(); index = num % _buckets.length; } freeList = count; count++; } _entries[freeList].hashCode = num; _entries[freeList].next = _buckets[index]; _entries[freeList].key = key; _entries[freeList].value = value; _buckets[index] = freeList; version++; OnAddPair(_entries[freeList]); } private: void Resize() { Resize(HashHelper::ExpandPrime(count), false); } void Resize(int newSize, bool forceNewHashCodes) { ArrayType<int> numArray; numArray.Resize(newSize); for (int i = 0; i < numArray.length; i++) { numArray[i] = -1; } _entries.Resize(newSize); if (forceNewHashCodes) { for (int k = 0; k < count; k++) { if (_entries[k].hashCode != -1) { _entries[k].hashCode = _comparer.GetHashCode(_entries[k].key) & 0x7fffffff; } } } for (int j = 0; j < count; j++) { int index = _entries[j].hashCode % newSize; _entries[j].next = numArray[index]; numArray[index] = j; } _buckets.Attach(numArray); } protected: virtual void OnCleanPair(Entry<TKey, TValue>& val) {} virtual void OnAddPair(Entry<TKey, TValue>& val) {} virtual void OnReplaceItem(Entry<TKey, TValue>& oldVal, TValue newVal) {} private: int count; int version; int freeList; int freeCount; Comparer _comparer; ArrayType<int> _buckets; ArrayType<Entry<TKey, TValue> > _entries; }; } #endif
/******************************************************************************* @file startup.h @author Rajmund Szymanski @date 11.12.2019 @brief Startup file header for iar c compiler. *******************************************************************************/ #pragma once /******************************************************************************* Additional definitions *******************************************************************************/ #define __ALIAS(function) __attribute__ ((weak, alias(#function))) #define __VECTORS __attribute__ ((used, section(".intvec"))) #define __CAST(sp) (void(*)(void))(intptr_t)(sp) /******************************************************************************* Prototypes of external functions *******************************************************************************/ __NO_RETURN void __iar_program_start( void ); /******************************************************************************* Default reset procedures *******************************************************************************/ __STATIC_INLINE __NO_RETURN void __main( void ) { /* Call the application's entry point */ __iar_program_start(); } /******************************************************************************/
#ifndef TELEMETRY_H #define TELEMETRY_H #include <Arduino.h> #include <HardwareSerial.h> #include "common.h" #include "queuelist.h" static const unsigned WHEEL_EVENT_MIN_INTERVAL = 5; class Telemetry { public: Telemetry(HardwareSerial port, unsigned speed); void serialPolling(); void wheelEvent(rot_one left, rot_one right); void sonarEvent(packet *sonarPacket); void sendPing(bool &ready, uint32_t &delay); packet *getMainLoopPacket(); void freePacket(packet *p); packet *getEmptyPacket(); void putMainLoopPacket(packet *p); void errorCounter(uint32_t count, char const *name); private: enum receiveStates { RS_BEGIN, //!< Waiting for framing 0x7e RS_DATA, //!< Incoming data RS_ESCAPE, //!< Received 0x7d - XOR next byte with 0x20 }; enum transmitStates { TS_BEGIN, //!< Nothing sent yet, deliver 0x7e TS_DATA, //!< Sending normal data TS_ESCAPE, //!< Escape has been sent, escByte is next TS_CHKSUM, //!< Last data byte sent, checksum is next TS_CHECKSUM_ESC, //!< checksum needs escaping TS_END, //!< Checksum sent, frame is next. Can be skipped if there is a next packet in queue TS_IDLE, //!< No data to transmit. }; HardwareSerial serialPort; // Outgoing packet queues queuelist priorityQueue; // allow for 4 queuelist rotationQueue; // allow for 2 queuelist sonarQueue[MAX_NO_OF_SONAR]; // allow for 6+2 // Free buffers queuelist freeList; // Internal processing queue queuelist mainLoop; // RX data housekeeping packet *rxCurrentPacket; //!< Packet being received receiveStates rxState; //!< state of packet reception uint16_t rxCurrentOffset; //!< Bytes received so far uint16_t rxChecksum; //!< Checksum so far // Error counters bool counterUpdate; // TX data housekeeping packet *txCurrentPacket; //!< The currently transmitting packet uint16_t txTotalSize; //!< Total number of bytes (payload - note escaped) in bufefr uint16_t txCurrentOffset; //!< Current offset for transmission transmitStates txState; //!< State for packet transmission byte txEscByte; //!< stuffed byte, i.e. value xor'ed with 0x20 to transmit. uint16_t txChecksum; //!< TX checksum // Protocol housekeeping bool *pingReady; uint32_t *pingDelay; // Static array of packet buffers to flow around the queues static const unsigned bufferCount = 32; packet packetPool[bufferCount]; // Mechanism to cycle between available output queues uint16_t sequenceIdx; static const unsigned sequenceMax = MAX_NO_OF_SONAR+1; // sonars + wheels queuelist* queueSequence[sequenceMax]; // This is used to cycle between queues // Functions void initQueues(); packet *txGetPacketFromQueues(); size_t getPacketLength(packet *p); inline void crcUpdate(uint16_t &chksum, byte b); bool rxGetBuffer(); void rxHandleUartByte(byte b); void rxCalcChecksum(byte b); bool rxEndOfPacketHandling(); void rxReInitPacket(); void rxSaveByte(byte b); void rxPacketForwarding(packet *p); bool txEndOfPacketHandling(); bool txGetPacketByte(byte &b); }; #endif // TELEMETRY_H
// // parser.h // homework_4 // // Created by Asen Lekov on 12/29/14. // Copyright (c) 2014 fmi. All rights reserved. // #ifndef __homework_4__parser__ #define __homework_4__parser__ #include <string> class XMLParser { public: //private: bool is_open_tag(const std::string& tag) const; bool is_close_tag(const std::string& tag) const; bool is_tag(const std::string& tag) const; std::string get_tag_name(const std::string& tag) const; }; #endif /* defined(__homework_4__parser__) */
/******************************************************************** Software License Agreement: The software supplied herewith by Microchip Technology Incorporated (the "Company") for its PIC(R) Microcontroller is intended and supplied to you, the Company's customer, for use solely and exclusively on Microchip PIC Microcontroller products. The software is owned by the Company and/or its supplier, and is protected under applicable copyright laws. All rights are reserved. Any use in violation of the foregoing restrictions may subject the user to criminal sanctions under applicable laws, as well as to civil liability for the breach of the terms and conditions of this license. THIS SOFTWARE IS PROVIDED IN AN "AS IS" CONDITION. NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. *******************************************************************/ #include <xc.h> #include <system.h> #include <system_config.h> #include <usb/usb.h> // PIC24FJ64GB002 Configuration Bit Settings #include <xc.h> // CONFIG4 #pragma config DSWDTPS = DSWDTPS3 // DSWDT Postscale Select (1:128 (132 ms)) #pragma config DSWDTOSC = LPRC // Deep Sleep Watchdog Timer Oscillator Select (DSWDT uses Low Power RC Oscillator (LPRC)) #pragma config RTCOSC = SOSC // RTCC Reference Oscillator Select (RTCC uses Secondary Oscillator (SOSC)) #pragma config DSBOREN = OFF // Deep Sleep BOR Enable bit (BOR disabled in Deep Sleep) #pragma config DSWDTEN = OFF // Deep Sleep Watchdog Timer (DSWDT disabled) // CONFIG3 #pragma config WPFP = WPFP0 // Write Protection Flash Page Segment Boundary (Page 0 (0x0)) #pragma config SOSCSEL = IO // Secondary Oscillator Pin Mode Select (SOSC pins have digital I/O functions (RA4, RB4)) #pragma config WUTSEL = LEG // Voltage Regulator Wake-up Time Select (Default regulator start-up time used) #pragma config WPDIS = WPDIS // Segment Write Protection Disable (Segmented code protection disabled) #pragma config WPCFG = WPCFGDIS // Write Protect Configuration Page Select (Last page and Flash Configuration words are unprotected) #pragma config WPEND = WPENDMEM // Segment Write Protection End Page Select (Write Protect from WPFP to the last page of memory) // CONFIG2 #pragma config POSCMOD = XT // Primary Oscillator Select (XT Oscillator mode selected) #pragma config I2C1SEL = PRI // I2C1 Pin Select bit (Use default SCL1/SDA1 pins for I2C1 ) #pragma config IOL1WAY = OFF // IOLOCK One-Way Set Enable (The IOLOCK bit can be set and cleared using the unlock sequence) #pragma config OSCIOFNC = ON // OSCO Pin Configuration (OSCO pin functions as port I/O (RA3)) #pragma config FCKSM = CSDCMD // Clock Switching and Fail-Safe Clock Monitor (Sw Disabled, Mon Disabled) #pragma config FNOSC = PRIPLL // Initial Oscillator Select (Primary Oscillator with PLL module (XTPLL, HSPLL, ECPLL)) #pragma config PLL96MHZ = ON // 96MHz PLL Startup Select (96 MHz PLL Startup is enabled automatically on start-up) #pragma config PLLDIV = DIV2 // USB 96 MHz PLL Prescaler Select (Oscillator input divided by 2 (8 MHz input)) #pragma config IESO = OFF // Internal External Switchover (IESO mode (Two-Speed Start-up) disabled) // CONFIG1 #pragma config WDTPS = PS1 // Watchdog Timer Postscaler (1:1) #pragma config FWPSA = PR32 // WDT Prescaler (Prescaler ratio of 1:32) #pragma config WINDIS = OFF // Windowed WDT (Standard Watchdog Timer enabled,(Windowed-mode is disabled)) #pragma config FWDTEN = OFF // Watchdog Timer (Watchdog Timer is disabled) #pragma config ICS = PGx1 // Emulator Pin Placement Select bits (Emulator functions are shared with PGEC1/PGED1) #pragma config GWRP = OFF // General Segment Write Protect (Writes to program memory are allowed) #pragma config GCP = OFF // General Segment Code Protect (Code protection is disabled) #pragma config JTAGEN = OFF // JTAG Port Enable (JTAG port is disabled) /********************************************************************* * Function: void SYSTEM_Initialize( SYSTEM_STATE state ) * * Overview: Initializes the system. * * PreCondition: None * * Input: SYSTEM_STATE - the state to initialize the system into * * Output: None * ********************************************************************/ void SYSTEM_Initialize( SYSTEM_STATE state ) { //On the PIC24FJ64GB004 Family of USB microcontrollers, the PLL will not power up and be enabled //by default, even if a PLL enabled oscillator configuration is selected (such as HS+PLL). //This allows the device to power up at a lower initial operating frequency, which can be //advantageous when powered from a source which is not gauranteed to be adequate for 32MHz //operation. On these devices, user firmware needs to manually set the CLKDIV<PLLEN> bit to //power up the PLL. { unsigned int pll_startup_counter = 600; CLKDIVbits.PLLEN = 1; while(pll_startup_counter--); } switch(state) { case SYSTEM_STATE_USB_HOST: PRINT_SetConfiguration(PRINT_CONFIGURATION_UART); break; case SYSTEM_STATE_USB_HOST_HID_KEYBOARD: LED_Enable(LED_USB_HOST_HID_KEYBOARD_DEVICE_READY); //also setup UART here PRINT_SetConfiguration(PRINT_CONFIGURATION_UART); //timwuu 2015.04.11 LCD_CursorEnable(true); TIMER_SetConfiguration(TIMER_CONFIGURATION_1MS); break; } } void __attribute__((interrupt,auto_psv)) _USB1Interrupt() { USB_HostInterruptHandler(); }
// // Generated by class-dump 3.5 (64 bit). // // class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2013 by Steve Nygard. // #import "CDStructures.h" #import "IDEProvisioningSigningIdentity-Protocol.h" @class NSDate, NSString; @interface IDEProvisioningSigningIdentityPrototype : NSObject <IDEProvisioningSigningIdentity> { BOOL _distribution; NSString *_certificateKind; } @property(nonatomic, getter=isDistribution) BOOL distribution; // @synthesize distribution=_distribution; @property(copy, nonatomic) NSString *certificateKind; // @synthesize certificateKind=_certificateKind; @property(readonly, copy) NSString *description; @property(readonly, copy, nonatomic) NSDate *expirationDate; @property(readonly, copy, nonatomic) NSString *teamMemberID; @property(readonly, nonatomic) NSString *serialNumber; - (id)enhancedSigningIdentityWithState:(unsigned long long)arg1; - (BOOL)matchesSigningIdentity:(id)arg1; // Remaining properties @property(readonly, copy) NSString *debugDescription; @property(readonly) unsigned long long hash; @property(readonly) Class superclass; @end
// // DZTextFieldStyle.h // DZStyle // // Created by baidu on 15/7/23. // Copyright (c) 2015年 dzpqzb. All rights reserved. // #import "DZViewStyle.h" #import "DZTextStyle.h" #define DZTextFiledStyleMake(initCode) DZStyleMake(initCode, DZTextFieldStyle) #define IMP_SHARE_TEXTFIELD_STYLE(name , initCode) IMP_SHARE_STYLE(name , initCode, DZTextFieldStyle) #define EXTERN_SHARE_TEXTFIELD_STYLE(name) EXTERN_SHARE_STYLE(name, DZTextFieldStyle); @interface DZTextFieldStyle : DZViewStyle @property (nonatomic, copy) DZTextStyle* textStyle; @end
#include "mesh_adapt.h" #include "mesh_adj.h" #include "mesh_mod.h" #include "cavity_op.h" static void find_best_edge_split(mesh* m, split* s, ment e, ment v[2]) { double mq; double q; unsigned ne; unsigned i; ment v_[2]; ne = simplex_ndown[e.t][EDGE]; mq = -1; for (i = 0; i < ne; ++i) { mesh_down(m, e, EDGE, i, v_); split_start(s, EDGE, v_, ment_null); q = split_quality(s); if (q > mq) { mq = q; v[0] = v_[0]; v[1] = v_[1]; } split_cancel(s); } } static split* the_split; static void refine_op(mesh* m, ment e) { ment v[2]; find_best_edge_split(m, the_split, e, v); split_edge(the_split, v); } void mesh_refine(mesh* m, mflag* f) { the_split = split_new(m); cavity_exec_flagged(m, f, refine_op, mesh_elem(m)); split_free(the_split); } void mesh_refine_all(mesh* m) { mflag* f = mflag_new_all(m, mesh_elem(m)); mesh_refine(m, f); mflag_free(f); }
// // TextViewController.h // Galary // // Created by joshuali on 16/6/24. // Copyright © 2016年 joshuali. All rights reserved. // #import <UIKit/UIKit.h> @interface TextViewController : UIViewController @end
// ////////////////////////////////////////////////////////////////////////////// // // Copyright 2018 Autodesk, Inc. All rights reserved. // // Use of this software is subject to the terms of the Autodesk license // agreement provided at the time of installation or download, or which // otherwise accompanies this software in either electronic or hard copy form. // ////////////////////////////////////////////////////////////////////////////// // // #ifndef __AXPNT2D_H_ #define __AXPNT2D_H_ #include "gept2dar.h" #include "gepnt2d.h" #include "gevec2d.h" #pragma pack (push, 8) #ifndef AXAUTOEXP #ifdef AXAUTO_DLL #define AXAUTOEXP __declspec(dllexport) #else #define AXAUTOEXP __declspec(dllimport) #endif #endif #pragma warning(disable : 4290) class AXAUTOEXP AcAxPoint2d : public AcGePoint2d { public: // constructors AcAxPoint2d(); AcAxPoint2d(double x, double y); AcAxPoint2d(const AcGePoint2d& pt); AcAxPoint2d(const AcGeVector2d& pt); AcAxPoint2d(const VARIANT* var) throw(HRESULT); AcAxPoint2d(const VARIANT& var) throw(HRESULT); AcAxPoint2d(const SAFEARRAY* safeArrayPt) throw(HRESULT); // equal operators AcAxPoint2d& operator=(const AcGePoint2d& pt); AcAxPoint2d& operator=(const AcGeVector2d& pt); AcAxPoint2d& operator=(const VARIANT* var) throw(HRESULT); AcAxPoint2d& operator=(const VARIANT& var) throw(HRESULT); AcAxPoint2d& operator=(const SAFEARRAY* safeArrayPt) throw(HRESULT); // type requests VARIANT* asVariantPtr() const throw(HRESULT); SAFEARRAY* asSafeArrayPtr() const throw(HRESULT); VARIANT& setVariant(VARIANT& var) const throw(HRESULT); VARIANT* setVariant(VARIANT* var) const throw(HRESULT); // utilities private: AcAxPoint2d& fromSafeArray(const SAFEARRAY* safeArrayPt) throw(HRESULT); }; #pragma warning(disable : 4275) class AXAUTOEXP AcAxPoint2dArray : public AcGePoint2dArray { public: // equal operators AcAxPoint2dArray& append(const AcGePoint2d& pt); AcAxPoint2dArray& append(const VARIANT* var) throw(HRESULT); AcAxPoint2dArray& append(const VARIANT& var) throw(HRESULT); AcAxPoint2dArray& append(const SAFEARRAY* safeArrayPt) throw(HRESULT); // type requests SAFEARRAY* asSafeArrayPtr() const throw(HRESULT); VARIANT& setVariant(VARIANT& var) const throw(HRESULT); VARIANT* setVariant(VARIANT* var) const throw(HRESULT); // utilities private: AcAxPoint2dArray& fromSafeArray(const SAFEARRAY* safeArrayPt) throw(HRESULT); }; #pragma pack (pop) #endif
#include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <errno.h> #include <string.h> #include <fcntl.h> /* Definition of AT_* constants */ #ifndef _MSC_VER #include <unistd.h> #include <dirent.h> #else #pragma warning(disable:4996) #endif #include "logging.h" #include "config.h" #include "oracle.h" #include "tempfs.h" #include "util.h" #include "query.h" static int dbr_refresh_object(const char *schema, const char *ora_type, const char *object, time_t last_ddl_time) { char object_with_suffix[300]; // convert oracle type to filesystem type char *fs_type = strdup(ora_type); if (fs_type == NULL) { logmsg(LOG_ERROR, "dbr_refresh_object(): unable to allocate memory for ora_type"); return EXIT_FAILURE; } utl_ora2fstype(&fs_type); // get suffix based on type char *suffix = NULL; if (str_suffix(&suffix, ora_type) != EXIT_SUCCESS) { logmsg(LOG_ERROR, "dbr_refresh_object(): unable to determine file suffix"); if (suffix != NULL) free(suffix); if (fs_type != NULL) free(fs_type); return EXIT_FAILURE; } snprintf(object_with_suffix, 299, "%s%s", object, suffix); // get cache filename char *fname = NULL; if (qry_object_fname(schema, fs_type, object_with_suffix, &fname) != EXIT_SUCCESS) { logmsg(LOG_ERROR, "dbr_refresh_object(): unable to determine cache filename for [%s] [%s].[%s]", ora_type, schema, object_with_suffix); if (fname != NULL) free(fname); if (suffix != NULL) free(suffix); if (fs_type != NULL) free(fs_type); return EXIT_FAILURE; } // if cache file is already up2date if (tfs_validate2(fname, last_ddl_time) == EXIT_SUCCESS) { // then mark it as verified by this mount if (tfs_setldt(fname, last_ddl_time) != EXIT_SUCCESS) { logmsg(LOG_ERROR, "dbr_refresh_object(): unable to mark [%s] [%s].[%s] as verified by this mount.", ora_type, schema, object); if (fname != NULL) free(fname); if (suffix != NULL) free(suffix); if (fs_type != NULL) free(fs_type); return EXIT_FAILURE; } } free(fname); free(suffix); free(fs_type); return EXIT_SUCCESS; } static int dbr_delete_obsolete() { #ifdef _MSC_VER logmsg(LOG_ERROR, "dbr_delete_obsolete() - this function is not yet implemented for Windows platform!"); return EXIT_FAILURE; #else char cache_fn[4096]; DIR *dir = opendir(g_conf._temppath); if (dir == NULL) { logmsg(LOG_ERROR, "dbr_delete_obsolete() - unable to open directory: %d - %s", errno, strerror(errno)); return EXIT_FAILURE; } struct dirent *dir_entry = NULL; while ((dir_entry = readdir(dir)) != NULL) { if (dir_entry->d_type != DT_REG) continue; size_t name_len = strlen(dir_entry->d_name); if (name_len < 5) continue; char *suffix = dir_entry->d_name + name_len - 4; if (strcmp(suffix, ".tmp") != 0) continue; snprintf(cache_fn, 4095, "%s/%s", g_conf._temppath, dir_entry->d_name); time_t last_ddl_time = 0; time_t mount_stamp = 0; pid_t mount_pid = 0; if (tfs_getldt(cache_fn, &last_ddl_time, &mount_pid, &mount_stamp) != EXIT_SUCCESS) { logmsg(LOG_ERROR, "dbr_delete_obsolete() - tfs_getldt returned error"); closedir(dir); return EXIT_FAILURE; } if ((mount_pid != g_conf._mount_pid) || (mount_stamp != g_conf._mount_stamp)) { tfs_rmfile(cache_fn); logmsg(LOG_DEBUG, "dbr_delete_obsolete() - removed obsolete cache file [%s]", cache_fn); } } closedir(dir); return EXIT_SUCCESS; #endif } int dbr_refresh_cache() { int retval = EXIT_SUCCESS; const char *query = "select o.owner, o.object_type, o.object_name, \ to_char(o.last_ddl_time, 'yyyy-mm-dd hh24:mi:ss') as last_ddl_time\ from all_objects o\ where generated='N'\ and (o.object_type != 'TYPE' or o.subobject_name IS NULL)\ and object_type IN (\ 'TABLE',\ 'VIEW',\ 'PROCEDURE',\ 'FUNCTION',\ 'PACKAGE',\ 'PACKAGE BODY',\ 'TRIGGER',\ 'TYPE',\ 'TYPE BODY',\ 'JAVA SOURCE')"; ORA_STMT_PREPARE(dbr_refresh_state); ORA_STMT_DEFINE_STR_I(dbr_refresh_state, 1, schema, 300); ORA_STMT_DEFINE_STR_I(dbr_refresh_state, 2, type, 300); ORA_STMT_DEFINE_STR_I(dbr_refresh_state, 3, object, 300); ORA_STMT_DEFINE_STR_I(dbr_refresh_state, 4, last_ddl_time, 25); ORA_STMT_EXECUTE(dbr_refresh_state, 0); while (ORA_STMT_FETCH) { dbr_refresh_object( ORA_NVL(schema, "_UNKNOWN_SCHEMA_"), ORA_NVL(type, "_UNKNOWN_TYPE_"), ORA_NVL(object, "_UNKNOWN_OBJECT_"), utl_str2time(ORA_NVL(last_ddl_time, "1990-01-01 03:00:01"))); } dbr_delete_obsolete(); dbr_refresh_state_cleanup: ORA_STMT_FREE; return retval; }
// // This file is part of nuBASIC // Copyright (c) Antonino Calderone ([email protected]) // All rights reserved. // Licensed under the MIT License. // See COPYING file in the project root for full license information. // /* -------------------------------------------------------------------------- */ #ifndef __NU_STMT_FUNCTION_H__ #define __NU_STMT_FUNCTION_H__ /* -------------------------------------------------------------------------- */ #include "nu_expr_any.h" #include "nu_prog_ctx.h" #include "nu_stmt.h" #include "nu_token_list.h" #include "nu_var_scope.h" #include "nu_variable.h" #include <algorithm> #include <string> /* -------------------------------------------------------------------------- */ namespace nu { /* -------------------------------------------------------------------------- */ class stmt_function_t : public stmt_t { public: stmt_function_t() = delete; stmt_function_t(const stmt_function_t&) = delete; stmt_function_t& operator=(const stmt_function_t&) = delete; using vec_size_t = expr_any_t::handle_t; stmt_function_t(prog_ctx_t& ctx, const std::string& id); void define(const std::string& var, const std::string& vtype, vec_size_t vect_size, prog_ctx_t& ctx, const std::string& id); void define_ret_type(const std::string& type, prog_ctx_t& ctx, size_t array_size) { auto& fproto = ctx.proc_prototypes.data[_id].second; fproto.ret_type = type; fproto.array_size = array_size; } stmt_cl_t get_cl() const noexcept override; void run(rt_prog_ctx_t& ctx) override; protected: std::string _id; std::set<std::string> _vars_rep_check; }; /* -------------------------------------------------------------------------- */ } /* -------------------------------------------------------------------------- */ #endif //__NU_STMT_FUNCTION_H__
#ifndef __BK_MESH_SAMPLING_H__ #define __BK_MESH_SAMPLING_H__ // blackhart headers. #include "foundation\BkExport.h" #include "foundation\BkAtomicDataType.h" // Forward declarations. struct BkPoint3; // ~~~~~ Dcl(PUBLIC) ~~~~~ /*! \brief Samples a list of triangles. * * \param vertices The vertices of each triangles. Must be sorted. * \param number_of_geoms The number of triangles. * \param number_of_points The number of points to sample. */ extern BK_API void BkMeshSampling_Sample(struct BkPoint3 const* vertices, size_t const number_of_geoms, size_t const number_of_points); #endif
// // ISNetworkingResponse.h // InventorySystemForiPhone // // Created by yangboshan on 16/4/28. // Copyright © 2016年 yangboshan. All rights reserved. // #import <Foundation/Foundation.h> #import "ISNetworkingConfiguration.h" @interface ISNetworkingResponse : NSObject @property (nonatomic, assign, readonly) ISURLResponseStatus status; @property (nonatomic, copy, readonly) NSString *contentString; @property (nonatomic, readonly) id content; @property (nonatomic, assign, readonly) NSInteger requestId; @property (nonatomic, copy, readonly) NSURLRequest *request; @property (nonatomic, copy, readonly) NSData *responseData; @property (nonatomic, copy) NSDictionary *requestParams; @property (nonatomic, assign, readonly) BOOL isCache; /** * * * @param responseString * @param requestId * @param request * @param responseData * @param status * * @return */ - (instancetype)initWithResponseString:(NSString *)responseString requestId:(NSNumber *)requestId request:(NSURLRequest *)request responseData:(NSData *)responseData status:(ISURLResponseStatus)status; /** * * * @param responseString * @param requestId * @param request * @param responseData * @param error * * @return */ - (instancetype)initWithResponseString:(NSString *)responseString requestId:(NSNumber *)requestId request:(NSURLRequest *)request responseData:(NSData *)responseData error:(NSError *)error; /** * 使用initWithData的response,它的isCache是YES,上面两个函数生成的response的isCache是NO * * @param data * * @return */ - (instancetype)initWithData:(NSData *)data; @end
#pragma once #include "toolscollector.h" #include "widgetsettings.h" #include "toolbase.h" namespace Engine { namespace Tools { struct GuiEditor : public Tool<GuiEditor> { SERIALIZABLEUNIT(GuiEditor); GuiEditor(ImRoot &root); virtual Threading::Task<bool> init() override; virtual void render() override; virtual void renderMenu() override; virtual void update() override; std::string_view key() const override; private: void renderSelection(Widgets::WidgetBase *hoveredWidget = nullptr); void renderHierarchy(Widgets::WidgetBase **hoveredWidget = nullptr); bool drawWidget(Widgets::WidgetBase *w, Widgets::WidgetBase **hoveredWidget = nullptr); private: Widgets::WidgetManager *mWidgetManager = nullptr; WidgetSettings *mSelected = nullptr; std::list<WidgetSettings> mSettings; bool mMouseDown = false; bool mDragging = false; bool mDraggingLeft = false, mDraggingTop = false, mDraggingRight = false, mDraggingBottom = false; }; } } RegisterType(Engine::Tools::GuiEditor);
#ifndef BARBERPOLE_H #define BARBERPOLE_H #include "iLampAnimation.h" #include "Lamp.h" class BarberPole : public iLampAnimation { public: BarberPole(Lamp* lamp); int itterate(); void reset(); protected: int cur_led = 0; int offset = 0; uint8_t hue = 0; uint8_t fps = 60; private: }; #endif // BarberPole_H
#pragma once #include "SYCL/detail/common.h" namespace cl { namespace sycl { namespace detail { using counter_t = unsigned int; template <class T, counter_t start = 0> class counter { private: static counter_t internal_count; counter_t counter_id; public: counter() : counter_id(internal_count++) {} counter(const counter& copy) : counter() {} counter(counter&& move) noexcept : counter_id(move.counter_id) {} counter& operator=(const counter& copy) { counter_id = copy.counter_id; return *this; } counter& operator=(counter&& move) noexcept { return *this; } ~counter() = default; static counter_t get_total_count() { return internal_count; } counter_t get_count_id() const { return counter_id; } }; template <class T, counter_t start> counter_t counter<T, start>::internal_count = start; } // namespace detail } // namespace sycl } // namespace cl
// EX.1 - READ A TEXT FILE CHAR BY CHAR #include <stdio.h> #include <stdlib.h> #include <string.h> int main() { FILE *bin; //declare a file pointer variable FILE *numfile; char s[20] = "1234"; int ch; int i; char line[50]; numfile = fopen("numbers.txt","r"); bin = fopen("numbers.txt","wb"); //open the file, text reading mode if (numfile == NULL) { //test if everything was ok printf("Cannot open file.\n"); exit(1); } // Error checking while(fgets(line,50,numfile) != NULL) { i = atoi(s); fwrite(&i,sizeof(int),1,bin); } getchar(); fclose(bin); fclose(numfile); //close the files return 0; } // end main()
/***************************************************************** * syscall.c * adapted from MIT xv6 by Zhiyi Huang, [email protected] * University of Otago * ********************************************************************/ #include "types.h" #include "defs.h" #include "param.h" #include "memlayout.h" #include "mmu.h" #include "proc.h" #include "arm.h" #include "syscall.h" // User code makes a system call with INT T_SYSCALL. // System call number in %eax. // Arguments on the stack, from the user call to the C // library system call function. The saved user %esp points // to a saved program counter, and then the first argument. // Fetch the int at addr from the current process. int fetchint(uint addr, int *ip) { if(addr >= curr_proc->sz || addr+4 > curr_proc->sz) return -1; *ip = *(int*)(addr); return 0; } // Fetch the nul-terminated string at addr from the current process. // Doesn't actually copy the string - just sets *pp to point at it. // Returns length of string, not including nul. int fetchstr(uint addr, char **pp) { char *s, *ep; if(addr >= curr_proc->sz) return -1; *pp = (char*)addr; ep = (char*)curr_proc->sz; for(s = *pp; s < ep; s++) if(*s == 0) return s - *pp; return -1; } // Fetch the nth 32-bit system call argument. int argint(int n, int *ip) { return fetchint(curr_proc->tf->sp + 4*n, ip); } // Fetch the nth word-sized system call argument as a pointer // to a block of memory of size n bytes. Check that the pointer // lies within the process address space. int argptr(int n, char **pp, int size) { int i; if(argint(n, &i) < 0) return -1; if((uint)i >= curr_proc->sz || (uint)i+size > curr_proc->sz) return -1; *pp = (char*)i; return 0; } // Fetch the nth word-sized system call argument as a string pointer. // Check that the pointer is valid and the string is nul-terminated. // (There is no shared writable memory, so the string can't change // between this check and being used by the kernel.) int argstr(int n, char **pp) { int addr; if(argint(n, &addr) < 0) return -1; return fetchstr(addr, pp); } extern int sys_chdir(void); extern int sys_close(void); extern int sys_dup(void); extern int sys_exec(void); extern int sys_exit(void); extern int sys_fork(void); extern int sys_fstat(void); extern int sys_getpid(void); extern int sys_kill(void); extern int sys_link(void); extern int sys_mkdir(void); extern int sys_mknod(void); extern int sys_open(void); extern int sys_pipe(void); extern int sys_read(void); extern int sys_sbrk(void); extern int sys_sleep(void); extern int sys_unlink(void); extern int sys_wait(void); extern int sys_write(void); extern int sys_uptime(void); static int (*syscalls[])(void) = { [SYS_fork] sys_fork, [SYS_exit] sys_exit, [SYS_wait] sys_wait, [SYS_pipe] sys_pipe, [SYS_read] sys_read, [SYS_kill] sys_kill, [SYS_exec] sys_exec, [SYS_fstat] sys_fstat, [SYS_chdir] sys_chdir, [SYS_dup] sys_dup, [SYS_getpid] sys_getpid, [SYS_sbrk] sys_sbrk, [SYS_sleep] sys_sleep, [SYS_uptime] sys_uptime, [SYS_open] sys_open, [SYS_write] sys_write, [SYS_mknod] sys_mknod, [SYS_unlink] sys_unlink, [SYS_link] sys_link, [SYS_mkdir] sys_mkdir, [SYS_close] sys_close, }; void syscall(void) { int num; num = curr_proc->tf->r0; if(num > 0 && num < NELEM(syscalls) && syscalls[num]) { // cprintf("\n%d %s: sys call %d syscall address %x\n", // curr_proc->pid, curr_proc->name, num, syscalls[num]); if(num == SYS_exec) { if(syscalls[num]() == -1) curr_proc->tf->r0 = -1; } else curr_proc->tf->r0 = syscalls[num](); } else { cprintf("%d %s: unknown sys call %d\n", curr_proc->pid, curr_proc->name, num); curr_proc->tf->r0 = -1; } }
// // EmailComposer.h // // // Created by Jesse MacFadyen on 10-04-05. // Copyright 2010 Nitobi. All rights reserved. // #import <Foundation/Foundation.h> #import <MessageUI/MFMailComposeViewController.h> #import <MobileCoreServices/MobileCoreServices.h> #import <Cordova/CDV.h> @interface EmailComposer : CDVPlugin < MFMailComposeViewControllerDelegate > { NSString* _callbackId; } @property(nonatomic, strong) NSString* callbackId; /// support dependency injection of a mock MFMailComposeViewController for unit testing @property(nonatomic, strong) MFMailComposeViewController* picker; - (void) show:(CDVInvokedUrlCommand*)command; @end
#pragma once #include "cinder/app/App.h" namespace reza { namespace paths { bool createDirectory( const ci::fs::path& path ); bool createDirectories( const ci::fs::path& path ); void createAssetDirectories(); ci::fs::path getWorkingPath(); ci::fs::path getPath( std::string path = "" ); ci::fs::path getPresetsPath( std::string path = "" ); ci::fs::path getDataPath( std::string path = "" ); ci::fs::path getAudioPath( std::string path = "" ); ci::fs::path getVideoPath( std::string path = "" ); ci::fs::path getFontsPath( std::string path = "" ); ci::fs::path getModelsPath( std::string path = "" ); ci::fs::path getImagesPath( std::string path = "" ); ci::fs::path getMatCapsPath( std::string path = "" ); ci::fs::path getPalettesPath( std::string path = "" ); ci::fs::path getRendersPath( std::string path = "" ); ci::fs::path getShadersPath( std::string path = "" ); } } // namespace reza::paths
// MusicXML Class Library // Copyright (c) by Matthew James Briggs // Distributed under the MIT License #pragma once #include "mxtest/control/CompileControl.h" #ifdef MX_COMPILE_CORE_TESTS #include "mxtest/core/HelperFunctions.h" #include "mx/core/Elements.h" namespace mxtest { mx::core::FullNoteGroupPtr tgenFullNoteGroup( TestMode v ); void tgenFullNoteGroupExpected(std::ostream& os, int indentLevel, TestMode v ); } #endif
// // MSProfileViewController.h // Minsta // // Created by maocl023 on 16/5/12. // Copyright © 2016年 jjj2mdd. All rights reserved. // #import <AsyncDisplayKit/AsyncDisplayKit.h> @interface MSProfileViewController : ASViewController @end
// // GKCartServiceMock.h // GKCommerce // // Created by 小悟空 on 1/31/15. // Copyright (c) 2015 GKCommerce. All rights reserved. // #import <Foundation/Foundation.h> @interface GKCartServiceMock : NSObject - (RACSignal *)fetchCartWithUser:(GKUser *)user; - (RACSignal *)addItem:(CartItem *)item; - (RACSignal *)addItemWithProduct:(Product *)product cart:(Cart *)aCart; - (RACSignal *)updateItem:(CartItem *)item oldQuantity:(NSInteger)anOldQuantity; - (RACSignal *)removeItem:(CartItem *)item; - (RACSignal *)removeItems:(NSArray *)items; @end
/** * The MIT License (MIT) * * * Copyright (C) 2013 Yu Jing ([email protected]) * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute,sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED,INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ #include "dirTraversal.h" #include <stdio.h> #include <stdlib.h> #include <string.h> #ifndef WIN32 // for linux #undef __STRICT_ANSI__ #define D_GNU_SOURCE #define _GNU_SOURCE #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/dir.h> #else // for windows #include <io.h> #endif //WIN32 #ifndef WIN32 // for linux inline int isDir(const char* path) { struct stat st; lstat(path, &st); return S_ISDIR(st.st_mode); } // int doTraversal(const char *path, int recursive,file_callback xCallback,void * usr) { DIR *pdir; struct dirent *pdirent; char tmp[1024]; pdir = opendir(path); if(pdir) { while((pdirent = readdir(pdir)) != 0) { //ignore "." && ".." if(!strcmp(pdirent->d_name, ".")|| !strcmp(pdirent->d_name, "..")) continue; sprintf(tmp, "%s/%s", path, pdirent->d_name); xCallback(usr,tmp,isDir(tmp)); //if is Dir and recursive is true , into recursive if(isDir(tmp) && recursive) { doTraversal(tmp, recursive,xCallback,usr); } } }else { fprintf(stderr,"opendir error:%s\n", path); } closedir(pdir); return 1; } //interface int dirTraversal(const char *path, int recursive,file_callback xCallback,void * usr) { int len; char tmp[256]; len = strlen(path); strcpy(tmp, path); if(tmp[len - 1] == '/') tmp[len -1] = '\0'; if(isDir(tmp)) { doTraversal(tmp, recursive,xCallback,usr); } else { //printf("%s\n", path); xCallback(usr,path,isDir(path)); } return 1; } #else //for windows /** * */ //int dirTraversal(const char *path, int recursive,file_callback xCallback) int dirTraversal(const char *path, int recursive,file_callback xCallback,void * usr) { int len = strlen(path)+3; long handle; char mypath[1024]; char searchpath[1024]; char tmppath[1024]; char nxtpath[1024]; char sp = '/'; int i; struct _finddata_t fileinfo; sprintf(mypath,"%s",path); switch(mypath[len-1]) { case '\\': sp = '\\'; len -= 1; mypath[len-1] = '\0'; break; case '/': len -= 1; mypath[len-1] = '\0'; case '.': sp = '/'; break; default : for(i=0;i<len;i++) { if(mypath[i]=='\\'||mypath[i]=='/') { sp = mypath[i]; break; } } } sprintf(tmppath,"%s",mypath); sprintf(searchpath,"%s%c%s",mypath,sp,"*"); for(handle=_findfirst(searchpath,&fileinfo);!_findnext(handle,&fileinfo);) { if(-1==handle) return -1; // sprintf(nxtpath,"%s%c%s",tmppath,sp,fileinfo.name); // call back if((0 != strcmp(fileinfo.name,".")) && (0 != strcmp(fileinfo.name,".."))) xCallback(usr,nxtpath,((fileinfo.attrib & _A_SUBDIR)!=0)); if(((fileinfo.attrib & _A_SUBDIR)!=0) && recursive && 0 != strcmp(fileinfo.name,".") && 0 != strcmp(fileinfo.name,"..")) dirTraversal(nxtpath,recursive,xCallback,usr); } _findclose(handle); return 1; } #endif //end of linux/windows
#include "../common/gba.h" #include "../common/fixed.c" typedef struct{ union{ struct{ fixed x; fixed y; }; fixed vec[2]; }; } Vec2; fixed DotProduct(Vec2 a, Vec2 b){ return fixMult(a.x, b.x) + fixMult(a.y, b.y); } Vec2 VecSub(Vec2 a, Vec2 b){ Vec2 retVal = {a.x - b.x, a.y - b.y}; return retVal; } Vec2 VecAdd(Vec2 a, Vec2 b){ Vec2 retVal = {a.x + b.x, a.y + b.y}; return retVal; } Vec2 VecScale(Vec2 v, fixed s){ Vec2 retVal = {fixMult(v.x, s), fixMult(v.y, s)}; return retVal; } Vec2 AngleToVec(fixed angle){ Vec2 forward = {mySin(angle), myCos(angle)}; return forward; } typedef struct{ Vec2 start; Vec2 end; rgb15 col; } Wall; #define MAX_WALL_COUNT 20 Wall walls[MAX_WALL_COUNT]; int wallCount = 0; void AddWall(Wall wall){ walls[wallCount] = wall; wallCount++; } #define FRAME_MEM ((volatile uint16*)MEM_VRAM) static inline fixed mySqrt(fixed in){ int reduce = (in >= makeFixed(4)); if(reduce){ in /= 4; } in -= FIXED_ONE; fixed guess = FIXED_ONE + in/2 - fixMult(in,in)/8 + fixPow(in,3)/16 - 5*fixPow(in,4)/128 + 7*fixPow(in,5)/256; in += FIXED_ONE; for(int i = 0; i < 10; i++){ if(guess == 0){ break; } guess = (guess + fixDiv(in, guess))/2; } if(reduce){ guess *= 2; } return abs(guess); } int main(void) { INT_VECTOR = InterruptMain; BNS_REG_IME = 0; REG_DISPSTAT |= LCDC_VBL; BNS_REG_IE |= IRQ_VBLANK; BNS_REG_IME = 1; REG_DISPLAY = 0x0403; for(int i = 0; i < SCREEN_WIDTH*SCREEN_HEIGHT; i++){ FRAME_MEM[i] = 0; } Wall firstWall = {{fixedFromFlt(-5.0f), fixedFromFlt(0.0f)}, {fixedFromFlt(5.0f), fixedFromFlt(4.0f)}, 0x3448}; AddWall(firstWall); fixed playerAngle = 0; Vec2 playerPos = {fixedFromFlt(0.0f), fixedFromFlt(-4.0f)}; uint32 keyStates = 0; uint32 prevStates = 0; while(1){ asm("swi 0x05"); keyStates = ~REG_KEY_INPUT & KEY_ANY; Vec2 playerForward = AngleToVec(playerAngle); Vec2 playerRight = {playerForward.y, -playerForward.x}; if(keyStates & KEY_UP){ playerPos = VecAdd(playerPos, VecScale(playerForward, fixedFromFlt(0.f))); } if(keyStates & KEY_DOWN){ playerPos = VecSub(playerPos, VecScale(playerForward, fixedFromFlt(0.5f))); } if(keyStates & KEY_LEFT){ playerPos = VecSub(playerPos, VecScale(playerRight, fixedFromFlt(0.f))); } if(keyStates & KEY_RIGHT){ playerPos = VecAdd(playerPos, VecScale(playerRight, fixedFromFlt(0.f))); } if(keyStates & BUTTON_L){ playerAngle += fixedFromFlt(2.5f); } if(keyStates & BUTTON_R){ playerAngle -= fixedFromFlt(2.5f); } //uint16 for(int i = 0; i < wallCount; i++){ Vec2 playerToWallStart = VecSub(walls[i].start, playerPos); Vec2 playerToWallEnd = VecSub(walls[i].end, playerPos); fixed forwardDotToStart = DotProduct(playerToWallStart, playerForward); fixed forwardDotToEnd = DotProduct(playerToWallEnd, playerForward); if(forwardDotToStart > 0 || forwardDotToEnd > 0){ Vec2 startProj = VecSub(walls[i].start, VecScale(playerForward, forwardDotToStart)); Vec2 endProj = VecSub(walls[i].end, VecScale(playerForward, forwardDotToEnd)); fixed startProjDotRight = DotProduct(startProj, playerRight); fixed endProjDotRight = DotProduct(endProj, playerRight); int32 pixelStart = roundFixedToInt(startProjDotRight*SCREEN_WIDTH)+SCREEN_WIDTH/2; int32 pixelEnd = roundFixedToInt( endProjDotRight*SCREEN_WIDTH)+SCREEN_WIDTH/2; fixed startDepth = mySqrt(forwardDotToStart); fixed endDepth = mySqrt(forwardDotToEnd); if(pixelStart > pixelEnd){ int32 temp = pixelStart; pixelStart = pixelEnd; pixelEnd = temp; fixed depthTmp = startDepth; startDepth = endDepth; endDepth = depthTmp; } if(pixelEnd < 0 || pixelStart >= SCREEN_WIDTH){ continue; } else{ if(pixelStart < 0){ fixed ratio = makeFixed(-pixelStart)/makeFixed(pixelEnd-pixelStart); pixelStart = 0; startDepth = fixMult(FIXED_ONE-ratio, startDepth) + fixMult(ratio, endDepth); } if(pixelEnd >= SCREEN_WIDTH){ fixed ratio = makeFixed(pixelEnd - SCREEN_WIDTH)/makeFixed(pixelEnd); pixelEnd = SCREEN_WIDTH - 1; endDepth = fixMult(FIXED_ONE-ratio, endDepth) + fixMult(ratio, startDepth); } fixed depthIncrement = fixDiv(endDepth - startDepth, makeFixed(pixelEnd - pixelStart + 1)); fixed currDepth = startDepth; rgb15 wallCol = walls[i].col; for(int32 x = pixelStart; x <= pixelEnd; x++){ int32 wallHeight = roundFixedToInt(fixDiv(makeFixed(SCREEN_HEIGHT), currDepth)); int32 y = 0; for(; y < SCREEN_HEIGHT/2-wallHeight; y++){ FRAME_MEM[y*SCREEN_WIDTH+x] = 0x4433; } for(;y < SCREEN_HEIGHT/2+wallHeight; y++){ FRAME_MEM[y*SCREEN_WIDTH+x] = wallCol; } for(;y < SCREEN_HEIGHT; y++){ FRAME_MEM[y*SCREEN_WIDTH+x] = 0x2211; } currDepth += depthIncrement; } } } } prevStates = keyStates; } return 0; }
/* * Generated by class-dump 3.3.4 (64 bit). * * class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2011 by Steve Nygard. */ #import <iWorkImport/GQDBGPlaceholder.h> #import "GQDNameMappable-Protocol.h" @class GQDWPLayoutFrame; // Not exported @interface GQDBGTitlePlaceholder : GQDBGPlaceholder <GQDNameMappable> { GQDWPLayoutFrame *mFrame; } + (const struct StateSpec *)stateForReading; - (_Bool)isBlank; - (id)layoutFrame; - (void)dealloc; @end
/* Copyright (c) 2017-2018 Tom Hancocks 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 __VKERNEL_DEVICE_PS2_KEYBOARD__ #define __VKERNEL_DEVICE_PS2_KEYBOARD__ /** Initialises and prepares the PS/2 keyboard driver for use. This will ensure the PS/2 keyboard is in a usable state. NOTE: This driver is rudimentary and should really be fleshed out into a full PS/2 driver that properly manages the PS/2 controller state and configuration. */ void ps2_keyboard_initialise(void); #endif
static void cnrom_switchchr(int bank) { int size = 8192; backend_read(romfn, 16 + (16384 * header.prgromsize) + (bank * size), size, ppu_memory); } static void cnrom_access(unsigned int address, unsigned char data) { if (address > 0x7fff && address < 0x10000) cnrom_switchchr(data & (header.chrromsize - 1)); } static void cnrom_reset() { }
/* Copyright (c) 2015 Mathias Panzenböck * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ #include "au.h" struct au_header { uint32_t magic; uint32_t data_offset; uint32_t data_size; uint32_t encoding; uint32_t sample_rate; uint32_t channels; }; int au_isfile(const uint8_t *data, size_t input_len, size_t *lengthptr) { if (input_len < AU_HEADER_SIZE || MAGIC(data) != AU_MAGIC) return 0; const struct au_header *header = (const struct au_header *)data; size_t data_offset = be32toh(header->data_offset); size_t data_size = be32toh(header->data_size); uint32_t encoding = be32toh(header->encoding); uint32_t channels = be32toh(header->channels); if (data_offset % 8 != 0 || encoding < 1 || encoding > 27 || channels == 0 || data_size == 0 || data_size == 0xffffffff) return 0; if (SIZE_MAX - data_offset < data_size) return 0; size_t length = data_offset + data_size; // I'm pretty sure it's a truncated AU file when this happens if (length > input_len) length = input_len; if (lengthptr) *lengthptr = length; return 1; }
// // SettingVCPopAnimator.h // BlackNoise // // Created by 李金 on 2016/11/24. // Copyright © 2016年 kingandyoga. All rights reserved. // #import <Foundation/Foundation.h> @interface SettingVCPopAnimator : NSObject<UIViewControllerAnimatedTransitioning> @end
// // TuneFightAppDelegate.h // TuneFight // // Created by Pit Garbe on 14.01.11. // Copyright 2011 __MyCompanyName__. All rights reserved. // #import <UIKit/UIKit.h> @class RootViewController; @interface TuneFightAppDelegate : NSObject <UIApplicationDelegate> @property (nonatomic, strong) UIWindow *window; @end
#ifndef _RELLIK_H_ #define _RELLIK_H_ #include "gametime.h" typedef struct rellik Rellik; Rellik *rellik_Create(); void rellik_Destroy(Rellik *self); void rellik_Initialize(Rellik *self); void rellik_Update(Rellik *self, GameTime gameTime); void rellik_Render(Rellik *self); #endif
// // BlackHoleDemo.h // Drawing // // Created by Adrian Russell on 16/12/2013. // Copyright (c) 2013 Adrian Russell. All rights reserved. // #ifndef __Drawing__BlackHoleDemo__ #define __Drawing__BlackHoleDemo__ #include "PhysicsDemo.h" #include "ForceGenerator.h" class BlackHoleDemo : public PhysicsDemo { public: BlackHoleDemo(); ~BlackHoleDemo(); //void update(); void mouseMoved(int x, int y); void mouseEvent(int button, int state, int x, int y); void keyPressed(unsigned char key, int x, int y); void keyUnpressed(int key, int x, int y) {}; std::string name() { return "Black Hole"; }; void draw(); private: Array *_blackHoles; Array *_particles; }; #endif /* defined(__Drawing__BlackHoleDemo__) */
#import <Flutter/Flutter.h> @interface AdbflibPlugin : NSObject<FlutterPlugin> @end
// // ViewController.h // DSCrashDemo // // Created by dasheng on 16/4/11. // Copyright © 2016年 dasheng. All rights reserved. // #import <UIKit/UIKit.h> @interface ViewController : UIViewController @end
/* crypto/bf/blowfish.h */ /* Copyright (C) 1995-1998 Eric Young ([email protected]) * All rights reserved. * * This package is an SSL implementation written * by Eric Young ([email protected]). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson ([email protected]). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * 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 copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young ([email protected])" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson ([email protected])" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #ifndef HEADER_BLOWFISH_H # define HEADER_BLOWFISH_H # include <VialerPJSIP/openssl/e_os2.h> #ifdef __cplusplus extern "C" { #endif # ifdef OPENSSL_NO_BF # error BF is disabled. # endif # define BF_ENCRYPT 1 # define BF_DECRYPT 0 /*- * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! * ! BF_LONG has to be at least 32 bits wide. If it's wider, then ! * ! BF_LONG_LOG2 has to be defined along. ! * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ # if defined(__LP32__) # define BF_LONG unsigned long # elif defined(OPENSSL_SYS_CRAY) || defined(__ILP64__) # define BF_LONG unsigned long # define BF_LONG_LOG2 3 /* * _CRAY note. I could declare short, but I have no idea what impact * does it have on performance on none-T3E machines. I could declare * int, but at least on C90 sizeof(int) can be chosen at compile time. * So I've chosen long... * <[email protected]> */ # else # define BF_LONG unsigned int # endif # define BF_ROUNDS 16 # define BF_BLOCK 8 typedef struct bf_key_st { BF_LONG P[BF_ROUNDS + 2]; BF_LONG S[4 * 256]; } BF_KEY; # ifdef OPENSSL_FIPS void private_BF_set_key(BF_KEY *key, int len, const unsigned char *data); # endif void BF_set_key(BF_KEY *key, int len, const unsigned char *data); void BF_encrypt(BF_LONG *data, const BF_KEY *key); void BF_decrypt(BF_LONG *data, const BF_KEY *key); void BF_ecb_encrypt(const unsigned char *in, unsigned char *out, const BF_KEY *key, int enc); void BF_cbc_encrypt(const unsigned char *in, unsigned char *out, long length, const BF_KEY *schedule, unsigned char *ivec, int enc); void BF_cfb64_encrypt(const unsigned char *in, unsigned char *out, long length, const BF_KEY *schedule, unsigned char *ivec, int *num, int enc); void BF_ofb64_encrypt(const unsigned char *in, unsigned char *out, long length, const BF_KEY *schedule, unsigned char *ivec, int *num); const char *BF_options(void); #ifdef __cplusplus } #endif #endif
// Copyright (c) 2018 Slack Technologies, Inc. // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. #ifndef SHELL_COMMON_GIN_UTIL_H_ #define SHELL_COMMON_GIN_UTIL_H_ #include "gin/converter.h" #include "gin/function_template.h" namespace gin_util { template <typename T> bool SetMethod(v8::Local<v8::Object> recv, const base::StringPiece& key, const T& callback) { v8::Isolate* isolate = v8::Isolate::GetCurrent(); auto context = isolate->GetCurrentContext(); return recv ->Set(context, gin::StringToV8(isolate, key), gin::CreateFunctionTemplate(isolate, callback) ->GetFunction(context) .ToLocalChecked()) .ToChecked(); } } // namespace gin_util #endif // SHELL_COMMON_GIN_UTIL_H_
// // PASConnectionTransformation.h // ximber // // Created by Paul Samuels on 15/09/2014. // Copyright (c) 2014 Paul Samuels. All rights reserved. // @import Foundation; /** * The connection transformation is a basic data structure that holds a block that is * executed on each node found at the xpath */ @interface PASConnectionTransformation : NSObject @property (nonatomic, copy, readonly) NSString *xPath; @property (nonatomic, copy, readonly) NSString *(^keyTransformer)(NSString *key); + (instancetype)connectionTransformationWithXPath:(NSString *)xPath keyTransformer:(NSString *(^)(NSString *key))keyTransformer; @end
#include "strm.h" #include <math.h> static int num_plus(strm_stream* strm, int argc, strm_value* args, strm_value* ret) { strm_value x, y; strm_get_args(strm, argc, args, "NN", &x, &y); if (strm_int_p(x) && strm_int_p(y)) { *ret = strm_int_value(strm_value_int(x)+strm_value_int(y)); return STRM_OK; } if (strm_number_p(x) && strm_number_p(y)) { *ret = strm_float_value(strm_value_float(x)+strm_value_float(y)); return STRM_OK; } return STRM_NG; } static int num_minus(strm_stream* strm, int argc, strm_value* args, strm_value* ret) { if (argc == 1) { if (strm_int_p(args[0])) { *ret = strm_int_value(-strm_value_int(args[0])); return STRM_OK; } if (strm_float_p(args[0])) { *ret = strm_float_value(-strm_value_float(args[0])); return STRM_OK; } } else { strm_value x, y; strm_get_args(strm, argc, args, "NN", &x, &y); if (strm_int_p(x) && strm_int_p(y)) { *ret = strm_int_value(strm_value_int(x)-strm_value_int(y)); return STRM_OK; } if (strm_number_p(x) && strm_number_p(y)) { *ret = strm_float_value(strm_value_float(x)-strm_value_float(y)); return STRM_OK; } } return STRM_NG; } static int num_mult(strm_stream* strm, int argc, strm_value* args, strm_value* ret) { strm_value x, y; strm_get_args(strm, argc, args, "NN", &x, &y); if (strm_int_p(x) && strm_int_p(y)) { *ret = strm_int_value(strm_value_int(x)*strm_value_int(y)); return STRM_OK; } *ret = strm_float_value(strm_value_float(x)*strm_value_float(y)); return STRM_OK; } static int num_div(strm_stream* strm, int argc, strm_value* args, strm_value* ret) { double x, y; strm_get_args(strm, argc, args, "ff", &x, &y); *ret = strm_float_value(x/y); return STRM_OK; } static int num_bar(strm_stream* strm, int argc, strm_value* args, strm_value* ret) { strm_value x, y; strm_get_args(strm, argc, args, "ii", &x, &y); *ret = strm_int_value(strm_value_int(x)|strm_value_int(y)); return STRM_OK; } static int num_mod(strm_stream* strm, int argc, strm_value* args, strm_value* ret) { strm_value x; strm_int y; strm_get_args(strm, argc, args, "Ni", &x, &y); if (strm_int_p(x)) { *ret = strm_int_value(strm_value_int(x)%y); return STRM_OK; } if (strm_float_p(x)) { *ret = strm_float_value(fmod(strm_value_float(x), y)); return STRM_OK; } return STRM_NG; } static int num_gt(strm_stream* strm, int argc, strm_value* args, strm_value* ret) { double x, y; strm_get_args(strm, argc, args, "ff", &x, &y); *ret = strm_bool_value(x>y); return STRM_OK; } static int num_ge(strm_stream* strm, int argc, strm_value* args, strm_value* ret) { double x, y; strm_get_args(strm, argc, args, "ff", &x, &y); *ret = strm_bool_value(x>=y); return STRM_OK; } static int num_lt(strm_stream* strm, int argc, strm_value* args, strm_value* ret) { double x, y; strm_get_args(strm, argc, args, "ff", &x, &y); *ret = strm_bool_value(x<y); return STRM_OK; } static int num_le(strm_stream* strm, int argc, strm_value* args, strm_value* ret) { double x, y; strm_get_args(strm, argc, args, "ff", &x, &y); *ret = strm_bool_value(x<=y); return STRM_OK; } static int num_number(strm_stream* strm, int argc, strm_value* args, strm_value* ret) { strm_get_args(strm, argc, args, "N", ret); return STRM_OK; } strm_state* strm_ns_number; void strm_number_init(strm_state* state) { strm_ns_number = strm_ns_new(NULL, "number"); strm_var_def(strm_ns_number, "+", strm_cfunc_value(num_plus)); strm_var_def(strm_ns_number, "-", strm_cfunc_value(num_minus)); strm_var_def(strm_ns_number, "*", strm_cfunc_value(num_mult)); strm_var_def(strm_ns_number, "/", strm_cfunc_value(num_div)); strm_var_def(strm_ns_number, "%", strm_cfunc_value(num_mod)); strm_var_def(strm_ns_number, "|", strm_cfunc_value(num_bar)); strm_var_def(strm_ns_number, "<", strm_cfunc_value(num_lt)); strm_var_def(strm_ns_number, "<=", strm_cfunc_value(num_le)); strm_var_def(strm_ns_number, ">", strm_cfunc_value(num_gt)); strm_var_def(strm_ns_number, ">=", strm_cfunc_value(num_ge)); strm_var_def(state, "number", strm_cfunc_value(num_number)); }
// // AWSAppDelegate.h // TAWS // // Created by CocoaPods on 05/27/2015. // Copyright (c) 2014 suwa.yuki. All rights reserved. // @import UIKit; @interface AWSAppDelegate : UIResponder <UIApplicationDelegate> @property (strong, nonatomic) UIWindow *window; @end
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE78_OS_Command_Injection__wchar_t_connect_socket_w32spawnl_18.c Label Definition File: CWE78_OS_Command_Injection.strings.label.xml Template File: sources-sink-18.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: 18 Control flow: goto statements * * */ #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" #include <process.h> #ifndef OMITBAD void CWE78_OS_Command_Injection__wchar_t_connect_socket_w32spawnl_18_bad() { wchar_t * data; wchar_t dataBuffer[100] = L""; data = dataBuffer; goto source; source: { #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 } /* wspawnl - specify the path where the command is located */ /* POTENTIAL FLAW: Execute command without validating input possibly leading to command injection */ _wspawnl(_P_WAIT, COMMAND_INT_PATH, COMMAND_INT_PATH, COMMAND_ARG1, COMMAND_ARG2, COMMAND_ARG3, NULL); } #endif /* OMITBAD */ #ifndef OMITGOOD /* goodG2B() - use goodsource and badsink by reversing the blocks on the goto statement */ static void goodG2B() { wchar_t * data; wchar_t dataBuffer[100] = L""; data = dataBuffer; goto source; source: /* FIX: Append a fixed string to data (not user / external input) */ wcscat(data, L"*.*"); /* wspawnl - specify the path where the command is located */ /* POTENTIAL FLAW: Execute command without validating input possibly leading to command injection */ _wspawnl(_P_WAIT, COMMAND_INT_PATH, COMMAND_INT_PATH, COMMAND_ARG1, COMMAND_ARG2, COMMAND_ARG3, NULL); } void CWE78_OS_Command_Injection__wchar_t_connect_socket_w32spawnl_18_good() { goodG2B(); } #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_connect_socket_w32spawnl_18_good(); printLine("Finished good()"); #endif /* OMITGOOD */ #ifndef OMITBAD printLine("Calling bad()..."); CWE78_OS_Command_Injection__wchar_t_connect_socket_w32spawnl_18_bad(); printLine("Finished bad()"); #endif /* OMITBAD */ return 0; } #endif
/* * file: twi.h * created: 20160807 * author(s): mr-augustine * * These are the Two-Wire Interface (TWI) bit mask definitions * They were copied from the following site: * http://www.nongnu.org/avr-libc/user-manual/group__util__twi.html * * The mnemonics are defined as follows: * TW_MT_xxx: Master Transmitter * TW_MR_xxx: Master Receiver * TW_ST_xxx: Slave Transmitter * TW_SR_xxx: Slave Receiver * * SLA: Slave Address * Comments are appended to the mask definitions we use */ #ifndef _TWI_H_ #define _TWI_H_ #define TW_START 0x08 // Start condition transmitted #define TW_REP_START 0x10 // Repeated Start condition transmitted #define TW_MT_SLA_ACK 0x18 // SLA+W transmitted, ACK received #define TW_MT_SLA_NACK 0x20 #define TW_MT_DATA_ACK 0x28 // Data transmitted, ACK received #define TW_MT_DATA_NACK 0x30 #define TW_MT_ARB_LOST 0x38 #define TW_MR_ARB_LOST 0x38 #define TW_MR_SLA_ACK 0x40 // SLA+R transmitted, ACK received #define TW_MR_SLA_NACK 0x48 #define TW_MR_DATA_ACK 0x50 // Data received, ACK returned #define TW_MR_DATA_NACK 0x58 // Data received, NACK returned #define TW_ST_SLA_ACK 0xA8 #define TW_ST_ARB_LOST_SLA_ACK 0xB0 #define TW_ST_DATA_ACK 0xB8 #define TW_ST_DATA_NACK 0xC0 #define TW_ST_LAST_DATA 0xC8 #define TW_SR_SLA_ACK 0x60 #define TW_SR_ARB_LOST_SLA_ACK 0x68 #define TW_SR_GCALL_ACK 0x70 #define TW_SR_ARB_LOST_GCALL_ACK 0x78 #define TW_SR_DATA_ACK 0x80 #define TW_SR_DATA_NACK 0x88 #define TW_SR_GCALL_DATA_ACK 0x90 #define TW_SR_GCALL_DATA_NACK 0x98 #define TW_SR_STOP 0xA0 #define TW_NO_INFO 0xF8 #define TW_BUS_ERROR 0x00 #define TW_STATUS (TWSR & TW_NO_INFO) // Grab the status bits #define TW_READ 1 // Read-mode flag #define TW_WRITE 0 // Write-mode flag #endif // #ifndef _TWI_H_
#ifndef ACCOUNTDIALOG_H #define ACCOUNTDIALOG_H #include <QDialog> namespace Ui { class AccountDialog; } class AccountDialog : public QDialog { Q_OBJECT public: explicit AccountDialog(QWidget *parent = 0); ~AccountDialog(); private slots: // TODO: 三个槽变成一个 void on_azureDefaultRadioButton_clicked(); void on_azureChinaRadioButton_clicked(); void on_azureOtherRadioButton_clicked(); void on_testAccessPushButton_clicked(); void on_savePushButton_clicked(); private: Ui::AccountDialog *ui; }; #endif // ACCOUNTDIALOG_H
// // JMColor.h // JMChartView // // Created by chengjiaming on 15/3/26. // Copyright (c) 2015年 chengjiaming. All rights reserved. // #import <UIKit/UIKit.h> /** * 主色系 */ #define JMBlue [UIColor colorWithRed:38 / 255.0 green:173 / 255.0 blue:223 / 255.0 alpha:1] /** * 背景色 */ #define JMCloudWhite [UIColor colorWithRed:38 / 255.0 green:173 / 255.0 blue:223 / 255.0 alpha:1] //范围 struct Range { CGFloat max; CGFloat min; }; typedef struct Range JMRange; CG_INLINE JMRange JMRangeMake(CGFloat max, CGFloat min); CG_INLINE JMRange JMRangeMake(CGFloat max, CGFloat min){ JMRange p; p.max = max; p.min = min; return p; } static const JMRange JMRangeZero = {0,0}; @interface JMColor : NSObject @end
#include "../include/csl.h" void MultipleEscape ( ) { _MultipleEscape ( _Context_->Lexer0 ) ; } void CSL_Strlen ( ) { DataStack_Push ( (int64) Strlen ( (char*) DataStack_Pop ( ) ) ) ; } void CSL_Strcmp ( ) { DataStack_Push ( (int64) Strcmp ( (byte*) DataStack_Pop ( ), (byte*) DataStack_Pop ( ) ) ) ; } void CSL_Stricmp ( ) { DataStack_Push ( (int64) Stricmp ( (byte*) DataStack_Pop ( ), (byte*) DataStack_Pop ( ) ) ) ; } //char * strcat ( char * destination, const char * source ); void CSL_StrCat ( ) { //Buffer * b = Buffer_New ( BUFFER_SIZE ) ; byte * buffer = Buffer_Data ( _CSL_->StrCatBuffer ); byte *str ; char * src = (char*) DataStack_Pop ( ) ; char * dst = (char*) DataStack_Pop ( ) ; strcpy ( (char*) buffer, dst ) ; if (src) strcat ( (char *) buffer, src ) ; str = String_New ( buffer, TEMPORARY ) ; //String_New ( (byte*) buffer, DICTIONARY ) ; DataStack_Push ( (int64) str ) ; //Buffer_SetAsUnused ( b ) ; ; } void CSL_StrCpy ( ) { // !! nb. this cant really work !! what do we want here ?? DataStack_Push ( (int64) strcpy ( (char*) DataStack_Pop ( ), (char*) DataStack_Pop ( ) ) ) ; } void String_GetStringToEndOfLine ( ) { DataStack_Push ( (int64) _String_Get_ReadlineString_ToEndOfLine ( ) ) ; }
#pragma once #include <stddef.h> #include <sys/queue.h> #include "options.h" #include "util.h" struct window { struct window *parent; enum window_split_type { WINDOW_LEAF, WINDOW_SPLIT_VERTICAL, WINDOW_SPLIT_HORIZONTAL } split_type; // The size of the window. Only valid for the root window. size_t w; size_t h; struct { #define OPTION(name, type, _) type name; WINDOW_OPTIONS #undef OPTION } opt; union { struct { // The buffer being edited. struct buffer *buffer; char *alternate_path; // The coordinates of the top left cell visible on screen. size_t top; size_t left; // Window-local working directory if set (otherwise NULL). char *pwd; // The offset of the cursor. struct mark *cursor; // The incremental match if 'incsearch' is enabled. bool have_incsearch_match; struct region incsearch_match; // The visual mode selection. // NULL if not in visual mode. struct region *visual_mode_selection; TAILQ_HEAD(tag_list, tag_jump) tag_stack; struct tag_jump *tag; }; struct { struct window *first; struct window *second; size_t point; } split; }; }; struct window *window_create(struct buffer *buffer, size_t w, size_t h); void window_free(struct window *window); // Closes the current window and returns a pointer to the "next" window. // Caller should use window_free on passed-in window afterwards. struct window *window_close(struct window *window); enum window_split_direction { WINDOW_SPLIT_LEFT, WINDOW_SPLIT_RIGHT, WINDOW_SPLIT_ABOVE, WINDOW_SPLIT_BELOW }; struct window *window_split(struct window *window, enum window_split_direction direction); void window_resize(struct window *window, int dw, int dh); void window_equalize(struct window *window, enum window_split_type type); struct window *window_root(struct window *window); struct window *window_left(struct window *window); struct window *window_right(struct window *window); struct window *window_up(struct window *window); struct window *window_down(struct window *window); struct window *window_first_leaf(struct window *window); void window_set_buffer(struct window *window, struct buffer *buffer); size_t window_cursor(struct window *window); void window_set_cursor(struct window *window, size_t pos); void window_center_cursor(struct window *window); size_t window_w(struct window *window); size_t window_h(struct window *window); size_t window_x(struct window *window); size_t window_y(struct window *window); void window_page_up(struct window *window); void window_page_down(struct window *window); void window_clear_working_directories(struct window *window);
/* * Generated by class-dump 3.3.4 (64 bit). * * class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2011 by Steve Nygard. */ #import "NSObject.h" #import "IBBinaryArchiving-Protocol.h" #import "NSCoding-Protocol.h" @interface IBAutolayoutGuide : NSObject <NSCoding, IBBinaryArchiving> { } - (void)encodeWithBinaryArchiver:(id)arg1; - (id)initWithBinaryUnarchiver:(id)arg1; - (void)encodeWithCoder:(id)arg1; - (id)initWithCoder:(id)arg1; @end
// // EnlargedImageViewController.h // ProjectCrystalBlue-iOS // // Created by Ryan McGraw on 4/20/14. // Copyright (c) 2014 Project Crystal Blue. All rights reserved. // #import <UIKit/UIKit.h> #import "Sample.h" #import "AbstractCloudLibraryObjectStore.h" @interface EnlargedImageViewController : UIViewController<UIAlertViewDelegate> { __strong IBOutlet UIImageView *imgView; } @property(nonatomic) Sample* selectedSample; @property (nonatomic, strong) AbstractCloudLibraryObjectStore *libraryObjectStore; - (id)initWithSample:(Sample*)initSample withLibrary:(AbstractCloudLibraryObjectStore*)initLibrary withImage:(UIImage*)initImage withDescription:(NSString*)initDescription; @end
#include "genfft.h" /** * NAME: cc1fft * * DESCRIPTION: complex to complex FFT * * USAGE: * void cc1fft(complex *data, int n, int sign) * * INPUT: - *data: complex 1D input vector * - n: number of samples in input vector data * - sign: sign of the Fourier kernel * * OUTPUT: - *data: complex 1D output vector unscaled * * NOTES: Optimized system dependent FFT's implemented for: * - inplace FFT from Mayer and SU (see file fft_mayer.c) * * AUTHOR: * Jan Thorbecke ([email protected]) * The Netherlands * * *---------------------------------------------------------------------- * REVISION HISTORY: * VERSION AUTHOR DATE COMMENT * 1.0 Jan Thorbecke Feb '94 Initial version (TU Delft) * 1.1 Jan Thorbecke June '94 faster in-place FFT * 2.0 Jan Thorbecke July '97 added Cray SGI calls * 2.1 Alexander Koek June '98 updated SCS for use inside * parallel loops * * ----------------------------------------------------------------------*/ #if defined(ACML440) #if defined(DOUBLE) #define acmlcc1fft zfft1dx #else #define acmlcc1fft cfft1dx #endif #endif void cc1fft(complex *data, int n, int sign) { #if defined(HAVE_LIBSCS) int ntable, nwork, zero=0; static int isys, nprev[MAX_NUMTHREADS]; static float *work[MAX_NUMTHREADS], *table[MAX_NUMTHREADS], scale=1.0; int pe, i; #elif defined(ACML440) static int nprev=0; int nwork, zero=0, one=1, inpl=1, i; static int isys; static complex *work; REAL scl; complex *y; #endif #if defined(HAVE_LIBSCS) pe = mp_my_threadnum(); assert ( pe <= MAX_NUMTHREADS ); if (n != nprev[pe]) { isys = 0; ntable = 2*n + 30; nwork = 2*n; /* allocate memory on each processor locally for speed */ if (work[pe]) free(work[pe]); work[pe] = (float *)malloc(nwork*sizeof(float)); if (work[pe] == NULL) fprintf(stderr,"cc1fft: memory allocation error\n"); if (table[pe]) free(table[pe]); table[pe] = (float *)malloc(ntable*sizeof(float)); if (table[pe] == NULL) fprintf(stderr,"cc1fft: memory allocation error\n"); ccfft_(&zero, &n, &scale, data, data, table[pe], work[pe], &isys); nprev[pe] = n; } ccfft_(&sign, &n, &scale, data, data, table[pe], work[pe], &isys); #elif defined(ACML440) scl = 1.0; if (n != nprev) { isys = 0; nwork = 5*n + 100; if (work) free(work); work = (complex *)malloc(nwork*sizeof(complex)); if (work == NULL) fprintf(stderr,"rc1fft: memory allocation error\n"); acmlcc1fft(zero, scl, inpl, n, data, 1, y, 1, work, &isys); nprev = n; } acmlcc1fft(sign, scl, inpl, n, data, 1, y, 1, work, &isys); #else cc1_fft(data, n, sign); #endif return; } /****************** NO COMPLEX DEFINED ******************/ void Rcc1fft(float *data, int n, int sign) { cc1fft((complex *)data, n , sign); return; } /****************** FORTRAN SHELL *****************/ void cc1fft_(complex *data, int *n, int *sign) { cc1fft(data, *n, *sign); return; }
/* * This file contains pieces of the Linux TCP/IP stack needed for modular * TOE support. * * Copyright (C) 2006-2009 Chelsio Communications. All rights reserved. * See the corresponding files in the Linux tree for copyrights of the * original Linux code a lot of this file is based on. * * Written by Dimitris Michailidis ([email protected]) * * 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 LICENSE file included in this * release for licensing terms and conditions. */ /* The following tags are used by the out-of-kernel Makefile to identify * supported kernel versions if a module_support-<kver> file is not found. * Do not remove these tags. * $SUPPORTED KERNEL 2.6.23$ * $SUPPORTED KERNEL 2.6.24$ * $SUPPORTED KERNEL 2.6.25$ * $SUPPORTED KERNEL 2.6.26$ * $SUPPORTED KERNEL 2.6.27$ * $SUPPORTED KERNEL 2.6.28$ * $SUPPORTED KERNEL 2.6.29$ * $SUPPORTED KERNEL 2.6.30$ * $SUPPORTED KERNEL 2.6.31$ * $SUPPORTED KERNEL 2.6.32$ * $SUPPORTED KERNEL 2.6.33$ * $SUPPORTED KERNEL 2.6.34$ * $SUPPORTED KERNEL 2.6.35$ * $SUPPORTED KERNEL 2.6.36$ * $SUPPORTED KERNEL 2.6.37$ */ #include <net/tcp.h> #include <linux/pkt_sched.h> #include <linux/kprobes.h> #include "defs.h" #include <asm/tlbflush.h> #if defined(CONFIG_SMP) && !defined(PPC64_TLB_BATCH_NR) static unsigned long (*kallsyms_lookup_name_p)(const char *name); static void (*flush_tlb_mm_p)(struct mm_struct *mm); static void (*flush_tlb_page_p)(struct vm_area_struct *vma, unsigned long va); void flush_tlb_mm_offload(struct mm_struct *mm); #endif void flush_tlb_page_offload(struct vm_area_struct *vma, unsigned long addr) { #if defined(CONFIG_SMP) && !defined(PPC64_TLB_BATCH_NR) flush_tlb_page_p(vma, addr); #endif } int sysctl_tcp_window_scaling = 1; int sysctl_tcp_adv_win_scale = 2; #define ECN_OR_COST(class) TC_PRIO_##class const __u8 ip_tos2prio[16] = { TC_PRIO_BESTEFFORT, ECN_OR_COST(FILLER), TC_PRIO_BESTEFFORT, ECN_OR_COST(BESTEFFORT), TC_PRIO_BULK, ECN_OR_COST(BULK), TC_PRIO_BULK, ECN_OR_COST(BULK), TC_PRIO_INTERACTIVE, ECN_OR_COST(INTERACTIVE), TC_PRIO_INTERACTIVE, ECN_OR_COST(INTERACTIVE), TC_PRIO_INTERACTIVE_BULK, ECN_OR_COST(INTERACTIVE_BULK), TC_PRIO_INTERACTIVE_BULK, ECN_OR_COST(INTERACTIVE_BULK) }; /* * Adapted from tcp_minisocks.c */ void tcp_time_wait(struct sock *sk, int state, int timeo) { struct inet_timewait_sock *tw = NULL; const struct inet_connection_sock *icsk = inet_csk(sk); const struct tcp_sock *tp = tcp_sk(sk); int recycle_ok = 0; if (tcp_death_row.tw_count < tcp_death_row.sysctl_max_tw_buckets) tw = inet_twsk_alloc(sk, state); if (tw != NULL) { struct tcp_timewait_sock *tcptw = tcp_twsk((struct sock *)tw); const int rto = (icsk->icsk_rto << 2) - (icsk->icsk_rto >> 1); tw->tw_rcv_wscale = tp->rx_opt.rcv_wscale; tcptw->tw_rcv_nxt = tp->rcv_nxt; tcptw->tw_snd_nxt = tp->snd_nxt; tcptw->tw_rcv_wnd = tcp_receive_window(tp); tcptw->tw_ts_recent = tp->rx_opt.ts_recent; tcptw->tw_ts_recent_stamp = tp->rx_opt.ts_recent_stamp; /* Linkage updates. */ __inet_twsk_hashdance(tw, sk, &tcp_hashinfo); /* Get the TIME_WAIT timeout firing. */ if (timeo < rto) timeo = rto; if (recycle_ok) { tw->tw_timeout = rto; } else { tw->tw_timeout = TCP_TIMEWAIT_LEN; if (state == TCP_TIME_WAIT) timeo = TCP_TIMEWAIT_LEN; } inet_twsk_schedule(tw, &tcp_death_row, timeo, TCP_TIMEWAIT_LEN); inet_twsk_put(tw); } else { /* Sorry, if we're out of memory, just CLOSE this * socket up. We've got bigger problems than * non-graceful socket closings. */ if (net_ratelimit()) printk(KERN_INFO "TCP: time wait bucket table overflow\n"); } tcp_done(sk); } void flush_tlb_mm_offload(struct mm_struct *mm) { #if defined(CONFIG_SMP) && !defined(PPC64_TLB_BATCH_NR) if (flush_tlb_mm_p) flush_tlb_mm_p(mm); #endif } #if defined(CONFIG_SMP) && !defined(PPC64_TLB_BATCH_NR) static int find_kallsyms_lookup_name(void) { int err = 0; #if defined(KPROBES_KALLSYMS) struct kprobe kp; memset(&kp, 0, sizeof kp); kp.symbol_name = "kallsyms_lookup_name"; err = register_kprobe(&kp); if (!err) { kallsyms_lookup_name_p = (void *)kp.addr; unregister_kprobe(&kp); } #else kallsyms_lookup_name_p = (void *)KALLSYMS_LOOKUP; #endif if (!err) err = kallsyms_lookup_name_p == NULL; return err; } #endif int prepare_tom_for_offload(void) { #if defined(CONFIG_SMP) && !defined(PPC64_TLB_BATCH_NR) if (!kallsyms_lookup_name_p) { int err = find_kallsyms_lookup_name(); if (err) return err; } flush_tlb_mm_p = (void *)kallsyms_lookup_name_p("flush_tlb_mm"); if (!flush_tlb_mm_p) { printk(KERN_ERR "Could not locate flush_tlb_mm"); return -1; } flush_tlb_page_p = (void *)kallsyms_lookup_name_p("flush_tlb_page"); if (!flush_tlb_page_p) { printk(KERN_ERR "Could not locate flush_tlb_page"); return -1; } #endif return 0; }
/* ** rq_xml_util.h ** ** Written by Brett Hutley - [email protected] ** ** Copyright (C) 2009 Brett Hutley ** ** This file is part of the Risk Quantify Library ** ** Risk Quantify is free software; you can redistribute it and/or ** modify it under the terms of the GNU Library General Public ** License as published by the Free Software Foundation; either ** version 2 of the License, or (at your option) any later version. ** ** Risk Quantify is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ** Library General Public License for more details. ** ** You should have received a copy of the GNU Library General Public ** License along with Risk Quantify; if not, write to the Free ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef rq_xml_util_h #define rq_xml_util_h #ifdef __cplusplus extern "C" { #if 0 } // purely to not screw up my indenting... #endif #endif #include "rq_stream.h" /** Get the start and end position of a valid piece of XML. */ RQ_EXPORT rq_error_code rq_xml_util_get_start_end_pos(rq_stream_t stream, const char *tag, long *start_pos, long *end_pos); #ifdef __cplusplus #if 0 { // purely to not screw up my indenting... #endif }; #endif #endif
#include <string.h> #include <stdlib.h> #include "libterm.h" #include "cursor.h" #include "screen.h" #include "bitarr.h" int cursor_visibility(int tid, int sid, char visibility) { if(SCR(tid, sid).curs_invisible != !visibility) { SCR(tid, sid).curs_invisible = !visibility; if(!record_update(tid, sid, visibility ? UPD_CURS : UPD_CURS_INVIS)) { if(ltm_curerr.err_no == ESRCH) return 0; else return -1; } } return 0; } int cursor_abs_move(int tid, int sid, enum axis axis, ushort num) { int ret = 0; uint old; SCR(tid, sid).curs_prev_not_set = 0; switch(axis) { case X: old = SCR(tid, sid).cursor.x; if(num < SCR(tid, sid).cols) SCR(tid, sid).cursor.x = num; else SCR(tid, sid).cursor.x = SCR(tid, sid).cols-1; if(old == SCR(tid, sid).cursor.x) return 0; break; case Y: old = SCR(tid, sid).cursor.y; if(num < SCR(tid, sid).lines) SCR(tid, sid).cursor.y = num; else SCR(tid, sid).cursor.y = SCR(tid, sid).lines-1; if(old == SCR(tid, sid).cursor.y) return 0; break; default: LTM_ERR(EINVAL, "Invalid axis", error); } if(!record_update(tid, sid, UPD_CURS)) { if(ltm_curerr.err_no == ESRCH) return 0; else return -1; } error: return ret; } int cursor_rel_move(int tid, int sid, enum direction direction, ushort num) { int ret = 0; if(!num) return 0; switch(direction) { case UP: return cursor_abs_move(tid, sid, Y, num <= SCR(tid, sid).cursor.y ? SCR(tid, sid).cursor.y - num : 0); case DOWN: return cursor_abs_move(tid, sid, Y, SCR(tid, sid).cursor.y + num); case LEFT: return cursor_abs_move(tid, sid, X, num <= SCR(tid, sid).cursor.x ? SCR(tid, sid).cursor.x - num : 0); case RIGHT: return cursor_abs_move(tid, sid, X, SCR(tid, sid).cursor.x + num); default: LTM_ERR(EINVAL, "Invalid direction", error); } error: return ret; } int cursor_horiz_tab(int tid, int sid) { /* don't hardcode 8 here in the future? */ char dist = 8 - (SCR(tid, sid).cursor.x % 8); return cursor_rel_move(tid, sid, RIGHT, dist); } int cursor_down(int tid, int sid) { if(SCR(tid, sid).cursor.y == SCR(tid, sid).lines-1 && SCR(tid, sid).autoscroll) return screen_scroll(tid, sid); else return cursor_rel_move(tid, sid, DOWN, 1); } int cursor_vertical_tab(int tid, int sid) { if(cursor_down(tid, sid) == -1) return -1; bitarr_unset_index(SCR(tid, sid).wrapped, SCR(tid, sid).cursor.y); return 0; } int cursor_line_break(int tid, int sid) { if(cursor_vertical_tab(tid, sid) == -1) return -1; if(cursor_abs_move(tid, sid, X, 0) == -1) return -1; return 0; } int cursor_wrap(int tid, int sid) { if(cursor_down(tid, sid) == -1) return -1; bitarr_set_index(SCR(tid, sid).wrapped, SCR(tid, sid).cursor.y); if(cursor_abs_move(tid, sid, X, 0) == -1) return -1; return 0; } int cursor_advance(int tid, int sid) { if(SCR(tid, sid).cursor.x == SCR(tid, sid).cols-1) { if(!SCR(tid, sid).curs_prev_not_set) { SCR(tid, sid).curs_prev_not_set = 1; return 0; } return cursor_wrap(tid, sid); } else return cursor_rel_move(tid, sid, RIGHT, 1); }