text
stringlengths
4
6.14k
struct _EImportImporter *evolution_ldif_importer_peek(void); struct _EImportImporter *evolution_vcard_importer_peek(void); struct _EImportImporter *evolution_csv_outlook_importer_peek(void); struct _EImportImporter *evolution_csv_mozilla_importer_peek(void); struct _EImportImporter *evolution_csv_evolution_importer_peek(void);
//===========================================================================// // // // Îļþ£º ICMP.C // // ˵Ã÷£º BW-DK5438¿ª·¢°åÒÔÌ«ÍøÊý¾Ý½á¹¹¶¨ÒåÍ·Îļþ // // ±àÒ룺 IAR Embedded Workbench IDE for MSP430 v4.21 // // °æ±¾£º v1.1 // // ±àд£º JASON.ZHANG // // °æÈ¨£º ±±¾©ÍØÆÕ²©Î¬µç×Ó¼¼ÊõÓÐÏÞ¹«Ë¾ // // ÈÕÆÚ£º 2010.09.25 // // // //===========================================================================// typedef unsigned char INT8U ; typedef unsigned int INT16U; typedef unsigned long INT32U; #define IP_PACKET 0x0008 #define ARP_PACKET 0x0608 #define RARP_PACKET 0x3580 #define MaxLenARPtable 0x02 typedef struct { INT32U ip; // IPµØÖ· INT32U mask; // ×ÓÍøÑÚÂë INT32U gate; // Íø¹Ø INT16U port; // ¶Ë¿ÚºÅ INT8U mac[6]; // ÒÔÌ«ÍøµØÖ· }net_node ; // ±¾»ú½ÚµãÐÅÏ¢; typedef struct { INT8U ipbytes[4]; INT8U maskbytes[4]; INT8U gatebytes[4]; INT8U portbytes[2]; INT16U macwords[3] ; }net_nodebytes; typedef union { net_node node ; net_nodebytes nodebytes ; }NetNode; #define IP4_ADDR(a,b,c,d) ((INT32U)(a & 0xff) << 24) | ((INT32U)(b & 0xff) << 16) | \ ((INT32U)(c & 0xff) << 8) | (INT32U)(d & 0xff) typedef union { INT16U words[3]; INT8U bytes[6]; }ethernet_address_type; typedef union { INT32U dwords; INT16U words[2]; INT8U bytes[4]; }ip_address_type; typedef union { INT8U bytes[12]; INT16U words[6]; struct{ INT8U status; INT8U ttl; ip_address_type ip_address; ethernet_address_type ethernet_address; }arp; //״̬,Éú´æÊ±¼ä,ipµØÖ·,ÒÔÌ«ÍøµØÖ· }arp_table_type; //ÒÔÌ«ÍøÖ¡ typedef struct { INT8U status; //½ÓÊÕ״̬ INT8U nextpage; //ÏÂÒ»¸öÒ³ INT16U length; //ÒÔÌ«Íø³¤¶È£¬ÒÔ×Ö½ÚΪµ¥Î» INT8U destnodeid[6]; //Ä¿µÄÍø¿¨µØÖ· INT8U sourcenodeid[6]; //Ô´Íø¿¨µØÖ· INT16U protocal; //ÏÂÒ»²ãЭÒé INT8U packet[300]; //°üµÄÄÚÈÝ }ethernet; //IP°ü ½öµ±IHL=5ʱÓà µ±IHL!=5ʱ×÷ת»» typedef struct { INT16U head[9]; //ÒÔÌ«Íø°üÍ· INT8U verandihl; //°æ±¾ÓëÍ·³¤¶È INT8U typeofserver; //·þÎñÀàÐÍ INT16U totallength; //×ܳ¤¶È INT16U frameindex; //IPÖ¡ÐòºÅ INT16U segment; //·Ö¶Î±êÖ¾ INT8U ttl; //Éú´æÊ±¼ä INT8U protocal; //ÏÂÒ»²ãЭÒé INT16U crc; //УÑéºÍ INT8U sourceip[4]; //Ô´IP INT8U destip[4]; //Ä¿µÄIP INT8U packet[280]; //IP°üµÄÄÚÈÝ }ip; typedef struct { INT16U head[9]; //ÒÔÌ«Íø°üÍ· INT8U ippacket[300]; //IP°üµÄÄÚÈÝ }ippacket; typedef struct { INT16U head[9]; //ÒÔÌ«ÍøÍ· //arp±¨ÎĵÄÄÚÈÝ×ܳ¤28×Ö½Ú INT16U harewaretype; //ÒÔÌ«ÍøÎª0x0001 INT16U protocaltype; //ip Ϊ0X0800 INT8U halength; //=0X06 INT8U palength; //=0X04 INT16U operation; //²Ù×÷ 0X0001ΪÇëÇó 0X0002ΪӦ´ð 0X0003Ϊ·´ÏòµØÖ·ÇëÇó 0X0004Ϊ·´ÏòµØÖ·Ó¦´ð INT8U sourcenodeid[6]; //Ô´Íø¿¨µØÖ· INT8U sourceip[4]; //Ô´IPµØÖ· INT8U destnodeid[6]; //Ä¿µÄÍø¿¨µØÖ· INT8U destip[4]; //Ä¿µÄIPµØÖ· }arp; typedef struct { //°üº¬ÔÚIP°üÖУ¬ÊÇIPµÄÉϲãΪ0X01µÄÓ¦Óà INT16U head[9]; //ÒÔÌ«ÍøÍ· INT16U iphead[10]; //IPÍ· INT8U type; //0X08 PINGÇëÇó 0X00 PINGÓ¦´ð INT8U option; //0X00 PING INT16U crc; INT16U id; INT16U seq; INT8U icmpdata[272]; }icmp; typedef struct { INT16U head[9]; INT16U iphead[10]; INT16U sourceport; //Ô´¶Ë¿Ú INT16U destport; //Ä¿µÄ¶Ë¿Ú INT16U seqnumberH; //˳ÐòºÅ INT16U seqnumberL; INT16U acknumberH; INT16U acknumberL; //È·ÈϺŠINT8U offset; //Êý¾ÝÆ«ÒÆÁ¿ INT8U control; //Á¬½Ó¿ØÖÆ INT16U window; //Á÷¿Ø INT16U crc; //УÑéºÍ £¬°üÀ¨Î±Í·²¿£¬TCPÍ·²¿£¬Êý¾Ý INT16U urg; //½ô¼±Ö¸Õë INT8U tcpdata[260]; //TCPÊý¾Ý }tcp; typedef struct { INT16U head[9]; INT16U iphead[10]; INT16U sourceport; //Ô´¶Ë¿Ú INT16U destport; //Ä¿µÄ¶Ë¿Ú INT16U length; INT16U crc; //УÑéºÍ £¬°üÀ¨Î±Í·²¿£¬udpÍ·²¿£¬Êý¾Ý INT8U udpdata[272]; //udpÊý¾Ý }udp; typedef struct { INT16U head[9]; INT16U iphead[10]; INT16U udphead[4]; INT16U opencode; // ¶Áд´úÂë±êÖ¾ INT8U fileandmode[270]; // ÎļþÃûºÍ²Ù×÷ÀàÐÍ }tftprw; typedef struct { INT16U head[9]; INT16U iphead[10]; INT16U udphead[4]; INT16U opencode; // ¶Áд´úÂë±êÖ¾ INT16U number; // ¿é±àºÅ»òÕß²î´íÂë INT8U tftpdata[268]; // Êý¾Ý»òÕß²î´íÐÅÏ¢ }tftpd; typedef struct { INT8U bytebuf[336]; }bytes; //ËùÓÐЭÒéµÄ¹²ÓÃÌå typedef union { bytes bytedata; ethernet etherframe; arp arpframe; icmp icmpframe; tcp tcpframe; ip ipframe; udp udpframe; ippacket ippacket; tftprw tftprwframe; tftpd tftpdataframe; }netcard; typedef struct { ip_address_type ipaddr; ip_address_type his_sequence; ip_address_type my_sequence; ip_address_type old_sequence; ip_address_type his_ack; INT16U port; INT8U timer; INT8U inactivity; INT8U state; INT8U query[23]; }tcpconnection;
/* ** 2001 September 15 ** ** The author disclaims copyright to this source code. In place of ** a legal notice, here is a blessing: ** ** May you do good and not evil. ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** Header file for the Virtual DataBase Engine (VDBE) ** ** This header defines the interface to the virtual database engine ** or VDBE. The VDBE implements an abstract machine that runs a ** simple program to access and modify the underlying database. ** ** $Id: vdbe.h,v 1.1 2006/08/01 01:03:39 kyndig Exp $ */ #ifndef _SQLITE_VDBE_H_ #define _SQLITE_VDBE_H_ #include <stdio.h> /* ** A single VDBE is an opaque structure named "Vdbe". Only routines ** in the source file sqliteVdbe.c are allowed to see the insides ** of this structure. */ typedef struct Vdbe Vdbe; /* ** A single instruction of the virtual machine has an opcode ** and as many as three operands. The instruction is recorded ** as an instance of the following structure: */ struct VdbeOp { u8 opcode; /* What operation to perform */ int p1; /* First operand */ int p2; /* Second parameter (often the jump destination) */ char *p3; /* Third parameter */ int p3type; /* One of the P3_xxx constants defined below */ #ifdef VDBE_PROFILE int cnt; /* Number of times this instruction was executed */ long long cycles; /* Total time spend executing this instruction */ #endif }; typedef struct VdbeOp VdbeOp; /* ** A smaller version of VdbeOp used for the VdbeAddOpList() function because ** it takes up less space. */ struct VdbeOpList { u8 opcode; /* What operation to perform */ signed char p1; /* First operand */ short int p2; /* Second parameter (often the jump destination) */ char *p3; /* Third parameter */ }; typedef struct VdbeOpList VdbeOpList; /* ** Allowed values of VdbeOp.p3type */ #define P3_NOTUSED 0 /* The P3 parameter is not used */ #define P3_DYNAMIC (-1) /* Pointer to a string obtained from sqliteMalloc() */ #define P3_STATIC (-2) /* Pointer to a static string */ #define P3_COLLSEQ (-4) /* P3 is a pointer to a CollSeq structure */ #define P3_FUNCDEF (-5) /* P3 is a pointer to a FuncDef structure */ #define P3_KEYINFO (-6) /* P3 is a pointer to a KeyInfo structure */ #define P3_VDBEFUNC (-7) /* P3 is a pointer to a VdbeFunc structure */ #define P3_MEM (-8) /* P3 is a pointer to a Mem* structure */ /* When adding a P3 argument using P3_KEYINFO, a copy of the KeyInfo structure ** is made. That copy is freed when the Vdbe is finalized. But if the ** argument is P3_KEYINFO_HANDOFF, the passed in pointer is used. It still ** gets freed when the Vdbe is finalized so it still should be obtained ** from a single sqliteMalloc(). But no copy is made and the calling ** function should *not* try to free the KeyInfo. */ #define P3_KEYINFO_HANDOFF (-9) /* ** The following macro converts a relative address in the p2 field ** of a VdbeOp structure into a negative number so that ** sqlite3VdbeAddOpList() knows that the address is relative. Calling ** the macro again restores the address. */ #define ADDR(X) (-1-(X)) /* ** The makefile scans the vdbe.c source file and creates the "opcodes.h" ** header file that defines a number for each opcode used by the VDBE. */ #include "opcodes.h" /* ** Prototypes for the VDBE interface. See comments on the implementation ** for a description of what each of these routines does. */ Vdbe *sqlite3VdbeCreate(sqlite3*); void sqlite3VdbeCreateCallback(Vdbe*, int*); int sqlite3VdbeAddOp(Vdbe*,int,int,int); int sqlite3VdbeOp3(Vdbe*,int,int,int,const char *zP3,int); int sqlite3VdbeAddOpList(Vdbe*, int nOp, VdbeOpList const *aOp); void sqlite3VdbeChangeP1(Vdbe*, int addr, int P1); void sqlite3VdbeChangeP2(Vdbe*, int addr, int P2); void sqlite3VdbeJumpHere(Vdbe*, int addr); void sqlite3VdbeChangeP3(Vdbe*, int addr, const char *zP1, int N); VdbeOp *sqlite3VdbeGetOp(Vdbe*, int); int sqlite3VdbeMakeLabel(Vdbe*); void sqlite3VdbeDelete(Vdbe*); void sqlite3VdbeMakeReady(Vdbe*,int,int,int,int); int sqlite3VdbeFinalize(Vdbe*); void sqlite3VdbeResolveLabel(Vdbe*, int); int sqlite3VdbeCurrentAddr(Vdbe*); void sqlite3VdbeTrace(Vdbe*,FILE*); int sqlite3VdbeReset(Vdbe*); int sqliteVdbeSetVariables(Vdbe*,int,const char**); void sqlite3VdbeSetNumCols(Vdbe*,int); int sqlite3VdbeSetColName(Vdbe*, int, const char *, int); void sqlite3VdbeCountChanges(Vdbe*); sqlite3 *sqlite3VdbeDb(Vdbe*); #ifndef NDEBUG void sqlite3VdbeComment(Vdbe*, const char*, ...); # define VdbeComment(X) sqlite3VdbeComment X #else # define VdbeComment(X) #endif #endif
/* * FSString.h * Transform SWF * * Copyright (c) 2001-2004 Flagstone Software Ltd.. All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * Neither the name of Flagstone Software Ltd. nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef __FSString_h__ #define __FSString_h__ 1 #include "FSValue.h" namespace transform { /** * FSString is a wrapper class for characters strings that will added to objects used to generate Flash files. * * Strings are mostly commonly used from the Transform SWF5 Edition onwards where strings are pushed onto * the Flash Players stack to execute object methods and other calculations. * * Every object which uses the FSString class provides accessor methods which pass and return C-strings so * create FSString objects directly is not necessary. To support localization the array of bytes comprising * the characters is terminated by a null character '\\0'. No encoding scheme is assumed so the objects can * safely be used with most coding sets such as ASCII, SJIS or Unicode (UTF8). */ class DLL_DECL FSString : public FSValue { public: FSString(FSInputStream* aStream); /** Constructs and FSString object with the specified string. @param aValue a c-string. */ FSString(const char* aValue = ""); FSString(const FSString& rhs); ~FSString(); const FSString& operator= (const FSString& rhs); FSString* clone() const { return new FSString(*this); } const char* className() const; int length() const { return strLength; } /** Append operator. @param rhs an FSString object containing a string that will be appended to this object. @return a reference to this object. */ const FSString& operator+= (const FSString& rhs); /** Returns the array of bytes containing the character data. @return the bytes representing the characters. */ const char* c_str() const { return buffer; } int lengthInStream(FSOutputStream* aStream); void encodeToStream(FSOutputStream* aStream); void decodeFromStream(FSInputStream* aStream); private: char* buffer; int strLength; int bufferLength; }; FSString operator+ (const FSString& lhs, const FSString& rhs); // Concatenation } #endif
/* * This file is part of the KDE project * * Copyright (C) 2013 Arjen Hiemstra <ahiemstra@heimr.nl> * * This library 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. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. * */ #ifndef CALLIGRA_COMPONENTS_SPREADSHEETCONTENTSMODELIMPL_H #define CALLIGRA_COMPONENTS_SPREADSHEETCONTENTSMODELIMPL_H #include "ContentsModelImpl.h" class KoDocument; namespace Calligra { namespace Components { class SpreadsheetContentsModelImpl : public ContentsModelImpl { public: SpreadsheetContentsModelImpl(KoDocument* document); ~SpreadsheetContentsModelImpl(); virtual int rowCount() const Q_DECL_OVERRIDE; virtual QVariant data(int index, Calligra::Components::ContentsModel::Role role) const Q_DECL_OVERRIDE; virtual void setThumbnailSize(const QSize& size) Q_DECL_OVERRIDE; virtual QImage thumbnail(int index, int width) const Q_DECL_OVERRIDE; private: class Private; Private* const d; }; } } #endif // CALLIGRA_COMPONENTS_SPREADSHEETCONTENTSMODELIMPL_H
/* -*- OpenSAF -*- * * (C) Copyright 2014 The OpenSAF Foundation * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. This file and program are licensed * under the GNU Lesser General Public License Version 2.1, February 1999. * The complete license can be accessed from the following location: * http://opensource.org/licenses/lgpl-license.php * See the Copying file included with the OpenSAF distribution for full * licensing terms. * * Author(s): Ericsson AB * */ #ifndef SA_EXTENDED_NAME_SOURCE #define SA_EXTENDED_NAME_SOURCE #endif #define _GNU_SOURCE #include <stdlib.h> #include <string.h> #include "osaf_extended_name.h" #include "ncsgl_defs.h" enum { /* Index in the SaNameT._opaque array where the string pointer will be stored when the distinguished name is longer than 255 bytes. By storing the pointer at an aligned address, Valgrind will be able to detect the pointer and thus the memory leak detection in Valgrind will work with these strings. Note though that since the largest member in the SaNameT structure is a 16-bit integer, there is no guarantee that the SaNameT structure itself is stored at an aligned address. */ kExtendedNamePointerOffset = sizeof(SaConstStringT) / sizeof(SaUint16T) }; static inline SaConstStringT get_ptr(const SaNameT* name); static inline void set_ptr(SaConstStringT value, SaNameT* name); bool osaf_extended_names_enabled = false; static bool extended_names_initialized = false; static inline SaConstStringT get_ptr(const SaNameT* name) { union { SaConstStringT pointer; SaUint8T bytes[sizeof(SaConstStringT)]; } tmp; memcpy(tmp.bytes, name->_opaque + kExtendedNamePointerOffset, sizeof(SaConstStringT)); return tmp.pointer; } static inline void set_ptr(SaConstStringT value, SaNameT* name) { union { SaConstStringT pointer; SaUint8T bytes[sizeof(SaConstStringT)]; } tmp; tmp.pointer = value; name->_opaque[0] = kOsafExtendedNameMagic; memcpy(name->_opaque + kExtendedNamePointerOffset, tmp.bytes, sizeof(SaConstStringT)); } void osaf_extended_name_init(void) { if (!extended_names_initialized) { char* enable = getenv("SA_ENABLE_EXTENDED_NAMES"); if (enable != NULL && enable[0] == '1' && enable[1] == '\0') { osaf_extended_names_enabled = true; } else { osaf_extended_names_enabled = false; } extended_names_initialized = true; } } void osaf_extended_name_lend(SaConstStringT value, SaNameT* name) { size_t length = strlen(value); if (length < SA_MAX_UNEXTENDED_NAME_LENGTH) { name->_opaque[0] = length; memcpy(name->_opaque + 1, value, length + 1); } else { set_ptr(value, name); } } SaConstStringT osaf_extended_name_borrow(const SaNameT* name) { size_t length = name->_opaque[0]; SaConstStringT value; if (length != kOsafExtendedNameMagic) { value = (SaConstStringT) (name->_opaque + 1); } else { value = get_ptr(name); } return value; } bool osaf_is_an_extended_name(const SaNameT* name) { return name->_opaque[0] == kOsafExtendedNameMagic; } bool osaf_is_extended_name_valid(const SaNameT* name) { size_t length = name->_opaque[0]; bool is_valid; if (length != kOsafExtendedNameMagic) { is_valid = length < SA_MAX_UNEXTENDED_NAME_LENGTH; } else { is_valid = osaf_extended_names_enabled && strnlen(get_ptr(name), SA_MAX_UNEXTENDED_NAME_LENGTH) >= SA_MAX_UNEXTENDED_NAME_LENGTH; } return is_valid; } bool osaf_is_extended_name_empty(const SaNameT* name) { size_t length = name->_opaque[0]; bool is_empty; if (length != kOsafExtendedNameMagic) { is_empty = length == 0; } else { is_empty = *get_ptr(name) == '\0'; } return is_empty; } size_t osaf_extended_name_length(const SaNameT* name) { size_t length = name->_opaque[0]; if (length != kOsafExtendedNameMagic) { osafassert(length < SA_MAX_UNEXTENDED_NAME_LENGTH); length = strnlen((const char*) (name->_opaque + 1), length); } else { length = strlen(get_ptr(name)); osafassert(osaf_extended_names_enabled && length >= SA_MAX_UNEXTENDED_NAME_LENGTH); } return length; } void osaf_extended_name_clear(SaNameT* name) { name->_opaque[0] = 0; *(char*) (name->_opaque + 1) = '\0'; memset(name->_opaque + kExtendedNamePointerOffset, 0, sizeof(SaConstStringT)); } void osaf_extended_name_steal(SaStringT value, SaNameT* name) { if (value != NULL) { size_t length = strlen(value); if (length < SA_MAX_UNEXTENDED_NAME_LENGTH) { name->_opaque[0] = length; memcpy(name->_opaque + 1, value, length + 1); free(value); } else { set_ptr(value, name); } } else { osaf_extended_name_clear(name); } } void osaf_extended_name_alloc(SaConstStringT value, SaNameT* name) { if (value != NULL) { size_t length = strlen(value); void* pointer; if (length < SA_MAX_UNEXTENDED_NAME_LENGTH) { name->_opaque[0] = length; pointer = name->_opaque + 1; } else { pointer = malloc(length + 1); set_ptr(pointer, name); } memcpy(pointer, value, length + 1); } else { osaf_extended_name_clear(name); } } void osaf_extended_name_free(SaNameT* name) { if (name != NULL) { if (name->_opaque[0] == kOsafExtendedNameMagic) { free((SaStringT*) get_ptr(name)); } name->_opaque[0] = 0xffff; memset(name->_opaque + kExtendedNamePointerOffset, 0, sizeof(SaConstStringT)); } }
#include <linux/kernel.h> #include <linux/errno.h> #include <linux/amba/pl330.h> #include <linux/scatterlist.h> #include <linux/imap_pl330.h> static inline bool pl330_filter(struct dma_chan *chan, void *param) { struct dma_pl330_peri *peri = chan->private; return peri->peri_id == (unsigned)param; } static int imapx800_dma_getposition(unsigned ch, dma_addr_t *src, dma_addr_t *dst) { struct dma_chan *chan = (struct dma_chan *)ch; return chan->device->device_dma_getposition(chan, src, dst); } static unsigned imapx800_dmadev_request(enum dma_ch dma_ch, struct imapx800_dma_info *info) { struct dma_chan *chan; dma_cap_mask_t mask; struct dma_slave_config slave_config; dma_cap_zero(mask); dma_cap_set(info->cap, mask); chan = dma_request_channel(mask, pl330_filter, (void *)dma_ch); if (info->direction == DMA_FROM_DEVICE) { memset(&slave_config, 0, sizeof(struct dma_slave_config)); slave_config.direction = info->direction; slave_config.src_addr = info->fifo; slave_config.src_addr_width = info->width; slave_config.src_maxburst = 8; dmaengine_slave_config(chan, &slave_config); } else if (info->direction == DMA_TO_DEVICE) { memset(&slave_config, 0, sizeof(struct dma_slave_config)); slave_config.direction = info->direction; slave_config.dst_addr = info->fifo; slave_config.dst_addr_width = info->width; slave_config.dst_maxburst = 8; dmaengine_slave_config(chan, &slave_config); } return (unsigned)chan; } static int imapx800_dmadev_release(unsigned ch, struct imapx800_dma_client *client) { dma_release_channel((struct dma_chan *)ch); return 0; } static int imapx800_dmadev_prepare(unsigned ch, struct imapx800_dma_prep_info *info) { struct scatterlist sg; struct dma_chan *chan = (struct dma_chan *)ch; struct dma_async_tx_descriptor *desc; switch (info->cap) { case DMA_SLAVE: sg_init_table(&sg, 1); sg_dma_len(&sg) = info->len; sg_set_page(&sg, pfn_to_page(PFN_DOWN(info->buf)), info->len, offset_in_page(info->buf)); sg_dma_address(&sg) = info->buf; desc = chan->device->device_prep_slave_sg(chan, &sg, 1, info->direction, DMA_PREP_INTERRUPT); break; case DMA_CYCLIC: desc = chan->device->device_prep_dma_cyclic(chan, info->buf, info->len, info->period, info->direction); break; case DMA_LLI: desc = chan->device->device_prep_dma_lli(chan, info->buf, info->len, info->period, info->direction); break; default: dev_err(&chan->dev->device, "unsupported format\n"); return -EFAULT; } if (!desc) { dev_err(&chan->dev->device, "cannot prepare cyclic dma\n"); return -EFAULT; } desc->callback = info->fp; desc->callback_param = info->fp_param; dmaengine_submit((struct dma_async_tx_descriptor *)desc); return 0; } static inline int imapx800_dmadev_trigger(unsigned ch) { dma_async_issue_pending((struct dma_chan *)ch); return 0; } static inline int imapx800_dmadev_flush(unsigned ch) { return dmaengine_terminate_all((struct dma_chan *)ch); } struct imapx800_dma_ops dmadev_ops = { .request = imapx800_dmadev_request, .release = imapx800_dmadev_release, .prepare = imapx800_dmadev_prepare, .trigger = imapx800_dmadev_trigger, .started = NULL, .flush = imapx800_dmadev_flush, .stop = imapx800_dmadev_flush, .dma_getposition = imapx800_dma_getposition, }; void *imapx800_dmadev_get_ops(void) { return &dmadev_ops; } EXPORT_SYMBOL(imapx800_dmadev_get_ops);
/* Configuration file for Linux Android targets. Copyright (C) 2008, 2010 Free Software Foundation, Inc. Contributed by Doug Kwan (dougkwan@google.com) Rewritten by CodeSourcery, Inc. This file is part of GCC. GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GCC; see the file COPYING3. If not see <http://www.gnu.org/licenses/>. */ #define ANDROID_TARGET_OS_CPP_BUILTINS() \ do { \ if (OPTION_ANDROID) \ builtin_define ("__ANDROID__"); \ } while (0) #if ANDROID_DEFAULT # define NOANDROID "mno-android" #else # define NOANDROID "!mandroid" #endif #define LINUX_OR_ANDROID_CC(LINUX_SPEC, ANDROID_SPEC) \ "%{" NOANDROID "|tno-android-cc:" LINUX_SPEC ";:" ANDROID_SPEC "}" #define LINUX_OR_ANDROID_LD(LINUX_SPEC, ANDROID_SPEC) \ "%{" NOANDROID "|tno-android-ld:" LINUX_SPEC ";:" ANDROID_SPEC "}" #define ANDROID_LINK_SPEC \ "%{shared: -Bsymbolic}" #define ANDROID_CC1_SPEC \ "%{!mglibc:%{!muclibc:%{!mbionic: -mbionic}}} " \ "%{!fno-pic:%{!fno-PIC:%{!fpic:%{!fPIC: -fPIC}}}}" #define ANDROID_CC1PLUS_SPEC \ "%{!fexceptions:%{!fno-exceptions: -fno-exceptions}} " \ "%{!frtti:%{!fno-rtti: -fno-rtti}}" #define ANDROID_LIB_SPEC \ "%{!static: -ldl}" #define ANDROID_STARTFILE_SPEC \ "%{shared: crtbegin_so%O%s;:" \ " %{static: crtbegin_static%O%s;: crtbegin_dynamic%O%s}}" #define ANDROID_ENDFILE_SPEC \ "%{shared: crtend_so%O%s;: crtend_android%O%s}"
#include <stdio.h> #include <math.h> int main () { float c_rad, c_circ, c_area; printf("\nIngrese el valor del radio del circulo: "); scanf("%f", &c_rad); //circ = pi * 2r //area = pi * r2 c_circ = M_PI * 2 * c_rad; c_area = M_PI * (c_rad * c_rad); printf("\nCircunferencia: %.2f\t\tArea: %.2f\n\n", c_circ, c_area); return 0; }
/* * Copyright (c) 2003-2009 by FlashCode <flashcode@flashtux.org> * See README for License detail, AUTHORS for developers list. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef __WEECHAT_GUI_BAR_WINDOW_H #define __WEECHAT_GUI_BAR_WINDOW_H 1 struct t_gui_window; enum t_gui_bar_position position; struct t_gui_bar_window { struct t_gui_bar *bar; /* pointer to bar */ int x, y; /* position of window */ int width, height; /* window size */ int scroll_x, scroll_y; /* X-Y scroll in bar */ int cursor_x, cursor_y; /* use to move cursor on screen (for */ /* input_text item) */ int current_size; /* current size (width or height) */ int items_count; /* number of bar items */ int *items_subcount; /* number of sub items */ char ***items_content; /* content for each item/sub item of bar*/ int **items_refresh_needed; /* refresh needed for (sub)item? */ void *gui_objects; /* pointer to a GUI specific struct */ struct t_gui_bar_window *prev_bar_window; /* link to previous bar win */ /* (only for non-root bars) */ struct t_gui_bar_window *next_bar_window; /* link to next bar win */ /* (only for non-root bars) */ }; /* functions */ extern int gui_bar_window_valid (struct t_gui_bar_window *bar_window); extern void gui_bar_window_calculate_pos_size (struct t_gui_bar_window *bar_window, struct t_gui_window *window); extern void gui_bar_window_content_build (struct t_gui_bar_window *bar_window, struct t_gui_window *window); extern char *gui_bar_window_content_get_with_filling (struct t_gui_bar_window *bar_window, struct t_gui_window *window); extern struct t_gui_bar_window *gui_bar_window_search_bar (struct t_gui_window *window, struct t_gui_bar *bar); extern int gui_bar_window_get_current_size (struct t_gui_bar_window *bar_window); extern void gui_bar_window_set_current_size (struct t_gui_bar_window *bar_window, struct t_gui_window *window, int size); extern int gui_bar_window_get_size (struct t_gui_bar *bar, struct t_gui_window *window, enum t_gui_bar_position position); extern int gui_bar_window_new (struct t_gui_bar *bar, struct t_gui_window *window); extern void gui_bar_window_free (struct t_gui_bar_window *bar_window, struct t_gui_window *window); extern int gui_bar_window_remove_unused_bars (struct t_gui_window *window); extern int gui_bar_window_add_missing_bars (struct t_gui_window *window); extern void gui_bar_window_scroll (struct t_gui_bar_window *bar_window, struct t_gui_window *window, int add_x, int scroll_beginning, int scroll_end, int add, int percent, int value); extern int gui_bar_window_add_to_infolist (struct t_infolist *infolist, struct t_gui_bar_window *bar_window); extern void gui_bar_window_print_log (struct t_gui_bar_window *bar_window); /* functions (GUI dependent) */ extern int gui_bar_window_objects_init (struct t_gui_bar_window *bar_window); extern void gui_bar_window_objects_free (struct t_gui_bar_window *bar_window); extern void gui_bar_window_create_win (struct t_gui_bar_window *bar_window); extern void gui_bar_window_draw (struct t_gui_bar_window *bar_window, struct t_gui_window *window); extern void gui_bar_window_objects_print_log (struct t_gui_bar_window *bar_window); #endif /* gui-bar-window.h */
#ifndef HANDLESVIEW_H #define HANDLESVIEW_H #include "StdTable.h" #include <QVBoxLayout> #include <QSplitter> class HandlesView : public QWidget { Q_OBJECT public: explicit HandlesView(QWidget* parent = nullptr); public slots: void reloadData(); void refreshShortcuts(); void dbgStateChanged(DBGSTATE state); void handlesTableContextMenuSlot(const QPoint & pos); void tcpConnectionsTableContextMenuSlot(const QPoint & pos); void privilegesTableContextMenuSlot(const QPoint & pos); void closeHandleSlot(); void disablePrivilegeSlot(); void enablePrivilegeSlot(); void disableAllPrivilegesSlot(); void enableAllPrivilegesSlot(); private: QVBoxLayout* mVertLayout; QSplitter* mSplitter; StdTable* mHandlesTable; StdTable* mTcpConnectionsTable; StdTable* mPrivilegesTable; QAction* mActionRefresh; QAction* mActionCloseHandle; QAction* mActionDisablePrivilege; QAction* mActionEnablePrivilege; QAction* mActionDisableAllPrivileges; QAction* mActionEnableAllPrivileges; void enumHandles(); void enumTcpConnections(); void enumPrivileges(); void AppendPrivilege(int row, const char* PrivilegeString); }; #endif // HANDLESVIEW_H
/** * Marlin 3D Printer Firmware * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] * * Based on Sprinter and grbl. * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ #pragma once #include "../inc/MarlinConfigPre.h" typedef struct { uint8_t active_speed, // 0-255 (fullspeed); Speed with enabled stepper motors idle_speed; // 0-255 (fullspeed); Speed after idle period with all motors are disabled uint16_t duration; // Duration in seconds for the fan to run after all motors are disabled bool auto_mode; // Default true } controllerFan_settings_t; #ifndef CONTROLLERFAN_SPEED_ACTIVE #define CONTROLLERFAN_SPEED_ACTIVE 255 #endif #ifndef CONTROLLERFAN_SPEED_IDLE #define CONTROLLERFAN_SPEED_IDLE 0 #endif #ifndef CONTROLLERFAN_IDLE_TIME #define CONTROLLERFAN_IDLE_TIME 60 #endif static constexpr controllerFan_settings_t controllerFan_defaults = { CONTROLLERFAN_SPEED_ACTIVE, CONTROLLERFAN_SPEED_IDLE, CONTROLLERFAN_IDLE_TIME, true }; #if ENABLED(USE_CONTROLLER_FAN) class ControllerFan { private: static uint8_t speed; static void set_fan_speed(const uint8_t s); public: #if ENABLED(CONTROLLER_FAN_EDITABLE) static controllerFan_settings_t settings; #else static const controllerFan_settings_t constexpr &settings = controllerFan_defaults; #endif static inline bool state() { return speed > 0; } static inline void init() { reset(); } static inline void reset() { #if ENABLED(CONTROLLER_FAN_EDITABLE) settings = controllerFan_defaults; #endif } static void setup(); static void update(); }; extern ControllerFan controllerFan; #endif
#ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> namespace Ui { class MainWindow; } class MainWindow : public QMainWindow { Q_OBJECT public: explicit MainWindow(QWidget *parent = 0); ~MainWindow(); private slots: void on_quit_btn_clicked(); void on_play_btn_clicked(); void on_pause_btn_clicked(); void on_next_btn_clicked(); void on_prev_btn_clicked(); void on_add_library_act_triggered(); void on_music_lib_list_doubleClicked(const QModelIndex &index); private: Ui::MainWindow *ui; }; #endif // MAINWINDOW_H
/* Copyright (C) 2017 Ramiro Jose Garcia Moraga This file is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This file is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with the this software. If not, see <http://www.gnu.org/licenses/>. */ #include "gwebsocket.h" struct _GWebSocketMessage { GWebSocketMessageType type; union{ guint8 * data; gchar * text; } content; gsize length; }; GWebSocketMessage * g_websocket_message_new_text( const gchar * text, gssize length ) { GWebSocketMessage * message = g_new0(GWebSocketMessage,1); if(length < 0) length = g_utf8_strlen(text,1024); message->content.text = g_strndup(text,length); message->type = G_WEBSOCKET_MESSAGE_TEXT; message->length = length; return message; } GWebSocketMessage * g_websocket_message_new_data( const guint8 * data, gsize length ) { GWebSocketMessage * message = g_new0(GWebSocketMessage,1); message->content.data = g_memdup(data,length); message->type = G_WEBSOCKET_MESSAGE_BINARY; message->length = length; return message; } GWebSocketMessageType g_websocket_message_get_type( GWebSocketMessage * message ) { return message->type; } const gchar * g_websocket_message_get_text( GWebSocketMessage * message ) { g_return_val_if_fail(message->type == G_WEBSOCKET_MESSAGE_TEXT,NULL); return message->content.text; } const guint8 * g_websocket_message_get_data( GWebSocketMessage * message ) { g_return_val_if_fail(message->type == G_WEBSOCKET_MESSAGE_BINARY,NULL); return message->content.data; } gsize g_websocket_message_get_length( GWebSocketMessage * message ) { return message->length; } void g_websocket_message_free( GWebSocketMessage * message ) { g_free(message->content.data); g_free(message); }
// Pekka Pirila's sports timekeeping program (Finnish: tulospalveluohjelma) // Copyright (C) 2015 Pekka Pirila // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. //--------------------------------------------------------------------------- #ifndef UnitTietoTulkH #define UnitTietoTulkH //--------------------------------------------------------------------------- #include <System.Classes.hpp> #include <Vcl.Controls.hpp> #include <Vcl.StdCtrls.hpp> #include <Vcl.Forms.hpp> #include <Vcl.Grids.hpp> #include <Vcl.Menus.hpp> #include <Vcl.ExtCtrls.hpp> #include <Vcl.Dialogs.hpp> #include <tputil.h> //--------------------------------------------------------------------------- class TFormTietoTulk : public TForm { __published: // IDE-managed Components TMemo *Memo1; TStringGrid *SG1; TMainMenu *MainMenu1; TMenuItem *iedosto1; TMenuItem *Luetiedottiedostosta1; TMenuItem *yhjenntekstialue1; TMenuItem *Liittiedotleikepydlt1; TPanel *Panel1; TComboBox *CBErotin; TEdit *EdtCols; TCheckBox *CBOtsRivi; TButton *Button1; TLabel *LblData; TEdit *EdtData; TLabel *Label3; TLabel *Label1; TLabel *LblTunn; TEdit *EdtTunn; TMenuItem *Sulje1; TOpenDialog *OpenDialog1; TMenuItem *Help1; TCheckBox *CBLainMerk; void __fastcall Luetiedottiedostosta1Click(TObject *Sender); void __fastcall yhjenntekstialue1Click(TObject *Sender); void __fastcall Liittiedotleikepydlt1Click(TObject *Sender); void __fastcall FormResize(TObject *Sender); void __fastcall FormShow(TObject *Sender); void __fastcall Sulje1Click(TObject *Sender); void __fastcall Button1Click(TObject *Sender); void __fastcall EdtTunnExit(TObject *Sender); void __fastcall EdtDataExit(TObject *Sender); private: // User declarations int tunnCol; int dataCol; public: // User declarations __fastcall TFormTietoTulk(TComponent* Owner); wchar_t *tunniste(wchar_t *st, int len, int r); wchar_t *tieto(wchar_t *st, int len, int r); int tietolkm; int NaytaSar; }; //--------------------------------------------------------------------------- extern PACKAGE TFormTietoTulk *FormTietoTulk; //--------------------------------------------------------------------------- #endif
/* Diacritics processing for a few character codes. Copyright (C) 1990-1993, 2009-2010 Free Software Foundation, Inc. François Pinard <pinard@iro.umontreal.ca>, 1988. All this file is a temporary hack, waiting for locales in GNU. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ extern const char diacrit_base[]; /* characters without diacritics */ extern const char diacrit_diac[]; /* diacritic code for each character */ /* Returns CHAR without its diacritic. CHAR is known to be alphabetic. */ #define tobase(Char) (diacrit_base[(unsigned char) (Char)]) /* Returns a diacritic code for CHAR. CHAR is known to be alphabetic. */ #define todiac(Char) (diacrit_diac[(unsigned char) (Char)])
#define MAD_MEM_TEST_NOMAIN #include "tests/mad_mem.c"
/*********************************************************** BatteryLookup.h - Support Library for the OSBMS Cell Monitors. Created by David Burkitt, May 28, 2017. Released into the public domain. The DARC Cell Monitors mount on LiFePO4 cells. Calculates the State-of-Charge (SoC) of a cell from the open circuit voltage. Actually calculates 3 values, 1 for the millivolts given and 2 for the upper and lower tolerances of the cell voltage reading. The upper and lower values give a margin of error, LiFePO4 cells exhibit a very flat voltage curve so the cell voltage measurement needs to be VERY accurate. The resistors should be at least 1% 50ppm. The voltage reference should be very accurate and temperature stable. ***********************************************************/ #ifndef BatteryLookup_h #define BatteryLookup_h #include "Arduino.h" // Three voltage maps are available to choose from. #define LFP_A123 (1) #define LFP_TI (2) #define LFP_SP (3) // I have SinoPoly cells so this is the default #define DATASET (LFP_SP) #define MV_MARGIN (50) // +- mv either side of reading for component tolerances. 50mv = 1% #define SOC_100PCT (10000) class BatteryLookup { public: BatteryLookup(void); void getSoC(int millivolts, int* socArray); private: int lookupOcvSoc(int cellMv); }; // ------------------------------------------------------ #endif
#ifndef UAE_GFXBOARD_H #define UAE_GFXBOARD_H extern int gfxboard_get_configtype (struct rtgboardconfig*); extern const TCHAR *gfxboard_get_name(int); extern const TCHAR *gfxboard_get_configname(int); #define GFXBOARD_UAE_Z2 0 #define GFXBOARD_UAE_Z3 1 #define GFXBOARD_HARDWARE 2 #endif /* UAE_GFXBOARD_H */
/* Copyright (C) 2018 Magnus Lång and Tuan Phong Ngo * This benchmark is part of SWSC */ #include <assert.h> #include <stdint.h> #include <stdatomic.h> #include <pthread.h> atomic_int vars[4]; atomic_int atom_1_r1_1; atomic_int atom_1_r12_0; void *t0(void *arg){ label_1:; atomic_store_explicit(&vars[0], 1, memory_order_seq_cst); atomic_store_explicit(&vars[1], 1, memory_order_seq_cst); return NULL; } void *t1(void *arg){ label_2:; int v2_r1 = atomic_load_explicit(&vars[1], memory_order_seq_cst); int v3_r3 = v2_r1 ^ v2_r1; atomic_store_explicit(&vars[2+v3_r3], 1, memory_order_seq_cst); int v5_r6 = atomic_load_explicit(&vars[2], memory_order_seq_cst); int v7_r7 = atomic_load_explicit(&vars[2], memory_order_seq_cst); int v8_r8 = v7_r7 ^ v7_r7; int v11_r9 = atomic_load_explicit(&vars[3+v8_r8], memory_order_seq_cst); int v13_r11 = atomic_load_explicit(&vars[3], memory_order_seq_cst); int v14_cmpeq = (v13_r11 == v13_r11); if (v14_cmpeq) goto lbl_LC00; else goto lbl_LC00; lbl_LC00:; int v16_r12 = atomic_load_explicit(&vars[0], memory_order_seq_cst); int v20 = (v2_r1 == 1); atomic_store_explicit(&atom_1_r1_1, v20, memory_order_seq_cst); int v21 = (v16_r12 == 0); atomic_store_explicit(&atom_1_r12_0, v21, memory_order_seq_cst); return NULL; } int main(int argc, char *argv[]){ pthread_t thr0; pthread_t thr1; atomic_init(&vars[3], 0); atomic_init(&vars[1], 0); atomic_init(&vars[0], 0); atomic_init(&vars[2], 0); atomic_init(&atom_1_r1_1, 0); atomic_init(&atom_1_r12_0, 0); pthread_create(&thr0, NULL, t0, NULL); pthread_create(&thr1, NULL, t1, NULL); pthread_join(thr0, NULL); pthread_join(thr1, NULL); int v17 = atomic_load_explicit(&atom_1_r1_1, memory_order_seq_cst); int v18 = atomic_load_explicit(&atom_1_r12_0, memory_order_seq_cst); int v19_conj = v17 & v18; if (v19_conj == 1) assert(0); return 0; }
/***************************************************************************** * Copyright (c) 2014-2018 OpenRCT2 developers * * For a complete list of all authors, please refer to contributors.md * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 * * OpenRCT2 is licensed under the GNU General Public License version 3. *****************************************************************************/ #ifndef _INPUT_H_ #define _INPUT_H_ #include "interface/Window.h" enum INPUT_FLAGS { INPUT_FLAG_WIDGET_PRESSED = (1 << 0), // The dropdown can stay open if the mouse is released, set on flag DROPDOWN_FLAG_STAY_OPEN INPUT_FLAG_DROPDOWN_STAY_OPEN = (1 << 1), // The mouse has been released and the dropdown is still open // INPUT_FLAG_DROPDOWN_STAY_OPEN is already set if this happens INPUT_FLAG_DROPDOWN_MOUSE_UP = (1 << 2), INPUT_FLAG_TOOL_ACTIVE = (1 << 3), // Left click on a viewport INPUT_FLAG_4 = (1 << 4), INPUT_FLAG_5 = (1 << 5), // Some of the map tools (clear, footpath, scenery) // never read as far as I know. INPUT_FLAG_6 = (1 << 6), INPUT_FLAG_VIEWPORT_SCROLLING = (1 << 7) }; enum MOUSE_STATE { MOUSE_STATE_RELEASED, MOUSE_STATE_LEFT_PRESS, MOUSE_STATE_LEFT_RELEASE, MOUSE_STATE_RIGHT_PRESS, MOUSE_STATE_RIGHT_RELEASE }; enum INPUT_STATE { INPUT_STATE_RESET, INPUT_STATE_NORMAL, INPUT_STATE_WIDGET_PRESSED, INPUT_STATE_POSITIONING_WINDOW, INPUT_STATE_VIEWPORT_RIGHT, INPUT_STATE_DROPDOWN_ACTIVE, INPUT_STATE_VIEWPORT_LEFT, INPUT_STATE_SCROLL_LEFT, INPUT_STATE_RESIZING, INPUT_STATE_SCROLL_RIGHT }; enum PLACE_OBJECT_MODIFIER { PLACE_OBJECT_MODIFIER_NONE = 0, PLACE_OBJECT_MODIFIER_SHIFT_Z = (1 << 0), PLACE_OBJECT_MODIFIER_COPY_Z = (1 << 1), }; struct widget_ref { rct_windowclass window_classification; rct_windownumber window_number; rct_widgetindex widget_index; }; extern uint8 gInputPlaceObjectModifier; extern sint32 gInputDragLastX; extern sint32 gInputDragLastY; extern widget_ref gHoverWidget; extern widget_ref gPressedWidget; extern uint16 gTooltipTimeout; extern widget_ref gTooltipWidget; extern sint32 gTooltipCursorX; extern sint32 gTooltipCursorY; extern TOOL_IDX gCurrentToolId; extern widget_ref gCurrentToolWidget; // TODO: Move to openrct2-ui and make static again extern INPUT_STATE _inputState; extern uint8 _inputFlags; extern uint16 _tooltipNotShownTicks; void input_window_position_begin(rct_window *w, rct_widgetindex widgetIndex, sint32 x, sint32 y); void title_handle_keyboard_input(); void game_handle_input(); void game_handle_keyboard_input(); void game_handle_edge_scroll(); sint32 get_next_key(); void store_mouse_input(sint32 state, sint32 x, sint32 y); void input_set_flag(INPUT_FLAGS flag, bool on); bool input_test_flag(INPUT_FLAGS flag); void input_reset_flags(); bool input_test_place_object_modifier(PLACE_OBJECT_MODIFIER modifier); void input_set_state(INPUT_STATE state); INPUT_STATE input_get_state(); void reset_tooltip_not_shown(); void input_reset_place_obj_modifier(); void input_scroll_viewport(sint32 scrollX, sint32 scrollY); #endif
/* * fft_private.h -- fast Fourier transform related routines - private functions * * Copyright 2014 Holger Kohr <kohr@num.uni-sb.de> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. * * */ #ifndef __FFT_PRIVATE_H__ #define __FFT_PRIVATE_H__ #ifdef HAVE_CONFIG_H #include <config.h> #endif #include "gfunc3.h" void gfunc3_grid_fwd_reciprocal (gfunc3 *gf); void gfunc3_grid_bwd_reciprocal (gfunc3 *gf); #endif /* __FFT_PRIVATE_H__ */
/* -*- c++ -*- */ /* * Copyright 2014 Ron Economos. * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3, or (at your option) * any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this software; see the file COPYING. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, * Boston, MA 02110-1301, USA. */ #ifndef INCLUDED_DVBS2_PHYSICAL_CC_H #define INCLUDED_DVBS2_PHYSICAL_CC_H #include <dvbs2/api.h> #include <dvbs2/dvbs2_config.h> #include <gnuradio/block.h> namespace gr { namespace dvbs2 { /*! * \brief <+description of block+> * \ingroup dvbs2 * */ class DVBS2_API physical_cc : virtual public gr::block { public: typedef boost::shared_ptr<physical_cc> sptr; /*! * \brief Return a shared_ptr to a new instance of dvbs2::physical_cc. * * To avoid accidental use of raw pointers, dvbs2::physical_cc's * constructor is in a private implementation * class. dvbs2::physical_cc::make is the public interface for * creating new instances. */ static sptr make(dvbs2_constellation_t constellation, dvbs2_code_rate_t rate, dvbs2_pilots_t pilots, dvbs2_framesize_t framesize, int goldcode); }; } // namespace dvbs2 } // namespace gr #endif /* INCLUDED_DVBS2_PHYSICAL_CC_H */
#include <tcl.h> #include <string.h> #if defined(__STDC__) || defined(HAS_STDARG) # include <stdarg.h> #else # include <varargs.h> #endif int Tcl_Invoke TCL_VARARGS_DEF(Tcl_Interp *, arg1) { va_list argList; Tcl_Interp *interp; char *cmd; /* Command name */ char *arg; /* Command argument */ char **argv; /* String vector for arguments */ int argc, i, max; /* Number of arguments */ Tcl_CmdInfo info; /* Info about command procedures */ int result; /* TCL_OK or TCL_ERROR */ interp = TCL_VARARGS_START(Tcl_Interp *, arg1, argList); Tcl_ResetResult(interp); /* * Map from the command name to a C procedure */ cmd = va_arg(argList, char *); if (! Tcl_GetCommandInfo(interp, cmd, &info)) { Tcl_AppendResult(interp, "unknown command \"", cmd, "\"", NULL); va_end(argList); return TCL_ERROR; } max = 20; /* Initial size of argument vector */ #if TCL_MAJOR_VERSION > 7 /* * Check whether the object interface is preferred for * this command */ if (info.isNativeObjectProc) { Tcl_Obj **objv; /* Object vector for arguments */ Tcl_Obj *resultPtr; /* The result object */ int objc; objv = (Tcl_Obj **) Tcl_Alloc(max * sizeof(Tcl_Obj *)); objv[0] = Tcl_NewStringObj(cmd, strlen(cmd)); Tcl_IncrRefCount(objv[0]); /* ref count == 1*/ objc = 1; /* * Build a vector out of the rest of the arguments */ while (1) { arg = va_arg(argList, char *); if (arg == (char *)NULL) { objv[objc] = (Tcl_Obj *)NULL; break; } objv[objc] = Tcl_NewStringObj(arg, strlen(arg)); Tcl_IncrRefCount(objv[objc]); /* ref count == 1*/ objc++; if (objc >= max) { /* allocate a bigger vector and copy old one */ Tcl_Obj **oldv = objv; max *= 2; objv = (Tcl_Obj **) Tcl_Alloc(max * sizeof(Tcl_Obj *)); for (i = 0 ; i < objc ; i++) { objv[i] = oldv[i]; } Tcl_Free((char *)oldv); } } va_end(argList); /* * Invoke the C procedure */ result = (*info.objProc)(info.objClientData, interp, objc, objv); /* * Make sure the string value of the result is valid * and release our references to the arguments */ (void) Tcl_GetStringResult(interp); for (i = 0 ; i < objc ; i++) { Tcl_DecrRefCount(objv[i]); } Tcl_Free((char *)objv); return result; } #endif argv = (char **) Tcl_Alloc(max * sizeof(char *)); argv[0] = cmd; argc = 1; /* * Build a vector out of the rest of the arguments */ while (1) { arg = va_arg(argList, char *); argv[argc] = arg; if (arg == (char *)NULL) { break; } argc++; if (argc >= max) { /* allocate a bigger vector and copy old one */ char **oldv = argv; max *= 2; argv = (char **) Tcl_Alloc(max * sizeof(char *)); for (i = 0 ; i < argc ; i++) { argv[i] = oldv[i]; } Tcl_Free((char *) oldv); } } va_end(argList); /* * Invoke the C procedure */ result = (*info.proc)(info.clientData, interp, argc, argv); /* * Release the arguments */ Tcl_Free((char *) argv); return result; }
/* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * PortDecorators.h * Header file for the Port Decorators classes * Copyright (C) 2010 Simon Newton */ #ifndef INCLUDE_OLAD_PORTDECORATORS_H_ #define INCLUDE_OLAD_PORTDECORATORS_H_ #include <ola/Logging.h> #include <olad/Port.h> #include <olad/TokenBucket.h> namespace ola { /* * A Decorator for an Output Port that throttles the writes */ class ThrottledOutputPortDecorator: public OutputPortDecorator { public: explicit ThrottledOutputPortDecorator( OutputPort *port, const TimeStamp *wake_time, unsigned int initial_count, unsigned int rate): OutputPortDecorator(port), m_bucket(initial_count, rate, rate, *wake_time), m_wake_time(wake_time) {} bool WriteDMX(const DmxBuffer &buffer, uint8_t priority) { if (m_bucket.GetToken(*m_wake_time)) return m_port->WriteDMX(buffer, priority); else OLA_INFO << "Port rated limited, dropping frame"; return true; } private: TokenBucket m_bucket; const TimeStamp *m_wake_time; }; } // ola #endif // INCLUDE_OLAD_PORTDECORATORS_H_
// Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder #ifndef _UNIT_H_ #define _UNIT_H_ //#include "map.h" struct block_list; struct unit_data; struct map_session_data; #include "clif.h" // clr_type #include "map.h" // struct block_list #include "path.h" // struct walkpath_data #include "skill.h" // struct skill_timerskill, struct skill_unit_group, struct skill_unit_group_tickset struct unit_data { struct block_list *bl; struct walkpath_data walkpath; struct skill_timerskill *skilltimerskill[MAX_SKILLTIMERSKILL]; struct skill_unit_group *skillunit[MAX_SKILLUNITGROUP]; struct skill_unit_group_tickset skillunittick[MAX_SKILLUNITGROUPTICKSET]; short attacktarget_lv; short to_x,to_y; short skillx,skilly; uint16 skill_id,skill_lv; int skilltarget; int skilltimer; int target; int target_to; int attacktimer; int walktimer; int chaserange; unsigned int attackabletime; unsigned int canact_tick; unsigned int canmove_tick; uint8 dir; unsigned char walk_count; unsigned char target_count; struct { unsigned change_walk_target : 1 ; unsigned skillcastcancel : 1 ; unsigned attack_continue : 1 ; unsigned walk_easy : 1 ; unsigned running : 1; unsigned speed_changed : 1; } state; }; struct view_data { #ifdef __64BIT__ unsigned int class_; #endif unsigned short #ifndef __64BIT__ class_, #endif weapon, shield, //Or left-hand weapon. robe, head_top, head_mid, head_bottom, hair_style, hair_color, cloth_color; char sex; unsigned dead_sit : 2; }; // PC, MOB, PET ‚É‹¤’Ê‚·‚鏈—‚ð‚P‚‚ɂ܂Ƃ߂éŒv‰æ // •àsŠJŽn // –ß‚è’l‚́A0 ( ¬Œ÷ ), 1 ( ޏ”s ) int unit_walktoxy( struct block_list *bl, short x, short y, int easy); int unit_walktobl( struct block_list *bl, struct block_list *target, int range, int easy); int unit_run(struct block_list *bl); int unit_calc_pos(struct block_list *bl, int tx, int ty, uint8 dir); // •às’âŽ~ // type‚͈ȉº‚Ì‘g‚ݍ‡‚킹 : // 1: ˆÊ’uî•ñ‚Ì‘—M( ‚±‚̊֐”‚ÌŒã‚Ɉʒuî•ñ‚𑗐M‚·‚éê‡‚Í•s—v ) // 2: ƒ_ƒ[ƒWƒfƒBƒŒƒC—L‚è // 4: •s–¾(MOB‚̂݁H) int unit_stop_walking(struct block_list *bl,int type); int unit_can_move(struct block_list *bl); int unit_is_walking(struct block_list *bl); int unit_set_walkdelay(struct block_list *bl, unsigned int tick, int delay, int type); int unit_escape(struct block_list *bl, struct block_list *target, short dist); // ˆÊ’u‚Ì‹­§ˆÚ“®(‚«”ò‚΂µ‚È‚Ç) int unit_movepos(struct block_list *bl, short dst_x, short dst_y, int easy, bool checkpath); int unit_warp(struct block_list *bl, short map, short x, short y, clr_type type); int unit_setdir(struct block_list *bl,unsigned char dir); uint8 unit_getdir(struct block_list *bl); int unit_blown(struct block_list* bl, int dx, int dy, int count, int flag); // ‚»‚±‚܂ŕàs‚Å‚½‚ǂ蒅‚¯‚é‚©‚Ì”»’è bool unit_can_reach_pos(struct block_list *bl,int x,int y,int easy); bool unit_can_reach_bl(struct block_list *bl,struct block_list *tbl, int range, int easy, short *x, short *y); // UŒ‚ŠÖ˜A int unit_stop_attack(struct block_list *bl); int unit_attack(struct block_list *src,int target_id,int continuous); int unit_cancel_combo(struct block_list *bl); // ƒXƒLƒ‹Žg—p int unit_skilluse_id(struct block_list *src, int target_id, uint16 skill_id, uint16 skill_lv); int unit_skilluse_pos(struct block_list *src, short skill_x, short skill_y, uint16 skill_id, uint16 skill_lv); // ƒXƒLƒ‹Žg—p( •␳Ï‚݃LƒƒƒXƒgŽžŠÔAƒLƒƒƒ“ƒZƒ‹•s‰ÂÝ’è•t‚« ) int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, uint16 skill_lv, int casttime, int castcancel); int unit_skilluse_pos2( struct block_list *src, short skill_x, short skill_y, uint16 skill_id, uint16 skill_lv, int casttime, int castcancel); // ‰r¥ƒLƒƒƒ“ƒZƒ‹ int unit_skillcastcancel(struct block_list *bl,int type); int unit_counttargeted(struct block_list *bl); int unit_set_target(struct unit_data* ud, int target_id); // unit_data ‚̏‰Šú‰»ˆ— void unit_dataset(struct block_list *bl); int unit_fixdamage(struct block_list *src,struct block_list *target,unsigned int tick,int sdelay,int ddelay,int64 damage,int div,int type,int64 damage2); // ‚»‚Ì‘¼ struct unit_data* unit_bl2ud(struct block_list *bl); struct unit_data* unit_bl2ud2(struct block_list *bl); void unit_remove_map_pc(struct map_session_data *sd, clr_type clrtype); void unit_free_pc(struct map_session_data *sd); #define unit_remove_map(bl,clrtype) unit_remove_map_(bl,clrtype,__FILE__,__LINE__,__func__) int unit_remove_map_(struct block_list *bl, clr_type clrtype, const char* file, int line, const char* func); int unit_free(struct block_list *bl, clr_type clrtype); int unit_changeviewsize(struct block_list *bl,short size); // ‰Šú‰»ƒ‹[ƒ`ƒ“ int do_init_unit(void); int do_final_unit(void); /** * Ranger **/ int unit_wugdash(struct block_list *bl, struct map_session_data *sd); extern const short dirx[8]; extern const short diry[8]; #endif /* _UNIT_H_ */
// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- /* * Copyright (C) 2010, 2011 Canonical Ltd * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * Authored by: Neil Jagdish Patel <neil.patel@canonical.com> */ #ifndef UNITY_ICON_LOADER_H #define UNITY_ICON_LOADER_H #include <boost/utility.hpp> #include <string> #include <map> #include <vector> #include <sigc++/sigc++.h> #include <gtk/gtk.h> namespace unity { class IconLoader : public boost::noncopyable { public: typedef sigc::slot<void, std::string const&, unsigned, GdkPixbuf*> IconLoaderCallback; IconLoader(); ~IconLoader(); static IconLoader& GetDefault(); /** * Each of the Load functions return an opaque handle. The sole use for * this is to disconnect the callback slot. */ int LoadFromIconName(std::string const& icon_name, unsigned size, IconLoaderCallback slot); int LoadFromGIconString(std::string const& gicon_string, unsigned size, IconLoaderCallback slot); int LoadFromFilename(std::string const& filename, unsigned size, IconLoaderCallback slot); int LoadFromURI(std::string const& uri, unsigned size, IconLoaderCallback slot); void DisconnectHandle(int handle); private: class Impl; Impl* pimpl; }; } #endif // UNITY_ICON_LOADER_H
/** * \file */ #include <config.h> #ifdef HOST_WIN32 /* For select */ #include <winsock2.h> #endif #include "mono-poll.h" #include <errno.h> #ifdef DISABLE_SOCKETS #include <glib.h> int mono_poll (mono_pollfd *ufds, unsigned int nfds, int timeout) { g_assert_not_reached (); return -1; } #else #if defined(HAVE_POLL) && !defined(__APPLE__) int mono_poll (mono_pollfd *ufds, unsigned int nfds, int timeout) { return poll (ufds, nfds, timeout); } #else int mono_poll (mono_pollfd *ufds, unsigned int nfds, int timeout) { struct timeval tv, *tvptr; int i, fd, events, affected, count; fd_set rfds, wfds, efds; int nexc = 0; int maxfd = 0; if (timeout < 0) { tvptr = NULL; } else { tv.tv_sec = timeout / 1000; tv.tv_usec = (timeout % 1000) * 1000; tvptr = &tv; } FD_ZERO (&rfds); FD_ZERO (&wfds); FD_ZERO (&efds); for (i = 0; i < nfds; i++) { ufds [i].revents = 0; fd = ufds [i].fd; if (fd < 0) continue; #ifdef HOST_WIN32 if (nexc >= FD_SETSIZE) { ufds [i].revents = MONO_POLLNVAL; return 1; } #else if (fd >= FD_SETSIZE) { ufds [i].revents = MONO_POLLNVAL; return 1; } #endif events = ufds [i].events; if ((events & MONO_POLLIN) != 0) FD_SET (fd, &rfds); if ((events & MONO_POLLOUT) != 0) FD_SET (fd, &wfds); FD_SET (fd, &efds); nexc++; if (fd > maxfd) maxfd = fd; } affected = select (maxfd + 1, &rfds, &wfds, &efds, tvptr); if (affected == -1) { #ifdef HOST_WIN32 int error = WSAGetLastError (); switch (error) { case WSAEFAULT: errno = EFAULT; break; case WSAEINVAL: errno = EINVAL; break; case WSAEINTR: errno = EINTR; break; /* case WSAEINPROGRESS: errno = EINPROGRESS; break; */ case WSAEINPROGRESS: errno = EINTR; break; case WSAENOTSOCK: errno = EBADF; break; #ifdef ENOSR case WSAENETDOWN: errno = ENOSR; break; #endif default: errno = 0; } #endif return -1; } count = 0; for (i = 0; i < nfds && affected > 0; i++) { fd = ufds [i].fd; if (fd < 0) continue; events = ufds [i].events; if ((events & MONO_POLLIN) != 0 && FD_ISSET (fd, &rfds)) { ufds [i].revents |= MONO_POLLIN; affected--; } if ((events & MONO_POLLOUT) != 0 && FD_ISSET (fd, &wfds)) { ufds [i].revents |= MONO_POLLOUT; affected--; } if (FD_ISSET (fd, &efds)) { ufds [i].revents |= MONO_POLLERR; affected--; } if (ufds [i].revents != 0) count++; } return count; } #endif #endif /* #ifndef DISABLE_SOCKETS */
/* * File: spieler.h * Created on 15. Juni 2011, 14:07 */ #ifndef SPIELER_H #define SPIELER_H #include "kartenstapel.h" #include "eingaben.h" #include "menue.h" // include(s) oder // weitere Angaben using namespace std; class Spieler { // Attribute private: /** Die Karten des Spielers, die er spielen kann. */ Kartenstapel *karten; /** Der Nickname des Spielers. */ string nickname; /** Ist Mensch- (true) oder KI-Spieler (false). */ bool ist_mensch; // Konstruktoren public: Spieler(); Spieler(const Kartenstapel& die_karten, const string ein_nickname, bool ein_mensch); ~Spieler(); Spieler(const Spieler& original); Spieler& operator=(const Spieler& ein_spieler); // Methoden string liefere_nickname() const; bool liefere_ob_mensch() const; int liefere_anzahl_karten() const; int liefere_anzahl_augen() const; string liefere_karten_info(unsigned int index) const; Kartenstapel *liefere_karten() const; virtual Karte spiele_karte(const Karte& karte_auf_ablage); int hat_passende_karten(const Karte& eine_karte) const; int hat_passende_wunsch_karten(const Karte& eine_wunsch_karte) const; int hat_sieben() const; int hat_ass() const; void nimm_karte(const Karte& eine_karte); virtual string liefere_wunschfarbe() const; private: virtual Karte spiele_passende_karte(const Karte& eine_karte); virtual Karte spiele_wunsch_karte(const Karte& eine_wunsch_karte); virtual Karte spiele_sieben(); virtual Karte spiele_ass(); int waehle_karte(const vector<Karte>& passende_karten) const; }; // eventuell Deklaration // weiterer Funktionen #endif /* SPIELER_H */
#ifndef __VGKSTRINGUTILITY_H__ #define __VGKSTRINGUTILITY_H__ #include <vgKernel/vgkForward.h> namespace vgKernel { /** @date 2008/08/01 19:56 @author xy @brief @see */ class VGK_EXPORT StringUtility { private: StringUtility() { } public: ~StringUtility() { } public: template< typename Source > static String textCast(const Source &arg) { std::ostringstream result; result << arg; return result.str(); } /// ½«Êý¾Ý×óÓÒµÄÖîÈç¿Õ¸ñµÈÐÅϢɾ³ý. static void trim( String& str, bool left = true, bool right = true , const String& delstr = " \t\r"); static int replace( String& str, const String& pattern, const String& newpat); /// ½«×Ö·û´®±äΪСд. static void toLowerCase( String& str ); /// ½«×Ö·û´®±äΪ´óд. static void toUpperCase( String& str ); static std::wstring convertStringToWString( const std::string& str ); static std::string convertWStringToString( const std::wstring& wstr ); /** Method for splitting a fully qualified filename into the base name and path. @remarks Path is standardised as in standardisePath */ static void splitFilename(const String& qualifiedName, String& outBasename, String& outPath); /** Simple pattern-matching routine allowing a wildcard pattern. @param str String to test @param pattern Pattern to match against; can include simple '*' wildcards @param caseSensitive Whether the match is case sensitive or not */ static bool match(const String& str, const String& pattern, bool caseSensitive = true); static String getFilenameFromAbsolutePath( const String& abs_path ); static String getFilenameWithoutExtFromAbsPath( const String& abs_path ); /** ·µ»ØµÄ±£Ö¤ÒÔ\»òÕß/½áβ */ static String getPathFromAbsoluteFilename( const String& abs_filename ); static String getFilenameWithoutExtension( const String& filename ); static String getFileExtension( const String& filename ); /** tok ÊÇ·Ö¸ôµÄ×Ö·û¼¯ trim ÌáʾÊÇ·ñ±£Áô¿Õ´®,falseΪ±£Áô null_subst Ìáʾ¶Ô¿Õ´®½øÐеÄÌæ´ú×Ö·û. ±ÈÈç: string src = ", ab,cde;,,fg,," ; string tok = ",;" ; vector<string> v2 = tokenize(src, tok ,false, "<null>"); v2Êä³ö: <null> ab cde <null> <null> fg <null> <null> */ static StringVector tokenize(const String& src, const String& tok, bool trim=false, String null_subst = "" ); /** ÓëtokenizeµÄÇø±ðÔÚÓÚ, delimit²éÕÒÊǾ«È·µÄ. Èç: string s = "######123#4###56########789###"; string del = "###"; vector<string> v3 = split(s, del, "<null>"); Êä³ö: <null> <null> 123#4 56 <null> ##789 <null> */ static StringVector split(const String& src, const String& delimit, const String& null_subst = "" ); }; }// end of namespace vgKernel #endif // end of __VGKSTRINGUTILITY_H__
/** * Snoopy - A lightweight bypass censorship system for HTTP * Copyright (C) 2012- Changli Gao <xiaosuo@gmail.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef __RULE_H #define __RULE_H #include "types.h" #include <stdbool.h> typedef struct rule_list rule_list_t; rule_list_t *rule_list_load(const char *fn); bool rule_list_match(rule_list_t *l, be32_t _ip, be16_t _port); void rule_list_free(rule_list_t *l); int rule_list_dump(rule_list_t *l, const char *fn); #endif /* __RULE_H */
/* * Copyright (c) 2011 The WebRTC@AnyRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ /* * This file contains the function WebRtcSpl_FilterMAFastQ12(). * The description header can be found in signal_processing_library.h * */ #include "webrtc/common_audio/signal_processing/include/signal_processing_library.h" void WebRtcSpl_FilterMAFastQ12(const int16_t* in_ptr, int16_t* out_ptr, const int16_t* B, size_t B_length, size_t length) { size_t i, j; for (i = 0; i < length; i++) { int32_t o = 0; for (j = 0; j < B_length; j++) { o += B[j] * in_ptr[i - j]; } // If output is higher than 32768, saturate it. Same with negative side // 2^27 = 134217728, which corresponds to 32768 in Q12 // Saturate the output o = WEBRTC_SPL_SAT((int32_t)134215679, o, (int32_t)-134217728); *out_ptr++ = (int16_t)((o + (int32_t)2048) >> 12); } return; }
// chartgrid2d.h #ifndef _JUDE_CHARTS2_CHARTGRID2D_H #define _JUDE_CHARTS2_CHARTGRID2D_H #include "drawS2/drawgroup2d.h" #include "drawS2/line2d.h" #include "chartS2/chartaxis2d.h" using namespace jude::base; using namespace jude::S2; using namespace jude::drawS2; namespace jude { namespace chartS2 { class ChartGrid2D { DrawGroup2D top_draw_group; JColour grid_col; public: ChartGrid2D(); ~ChartGrid2D(); const DrawGroup2D& topDrawGroup() const { return top_draw_group; } void setAxes(const ChartAxis2D& x_axis, const ChartAxis2D& y_axis); }; } } // namespace jude::chartS2 #endif // _JUDE_CHARTS2_CHARTGRID2D_H
/* * GRUB -- GRand Unified Bootloader * Copyright (C) 2009, 2010 Free Software Foundation, Inc. * * GRUB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GRUB is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GRUB. If not, see <http://www.gnu.org/licenses/>. */ #ifndef GRUB_POSIX_SYS_TYPES_H #define GRUB_POSIX_SYS_TYPES_H 1 #include <grub/misc.h> typedef grub_size_t size_t; typedef grub_ssize_t ssize_t; #ifndef GRUB_POSIX_BOOL_DEFINED typedef enum { false = 0, true = 1 } bool; #define GRUB_POSIX_BOOL_DEFINED 1 #endif typedef grub_uint8_t uint8_t; typedef grub_uint16_t uint16_t; typedef grub_uint32_t uint32_t; typedef grub_uint64_t uint64_t; typedef grub_int8_t int8_t; typedef grub_int16_t int16_t; typedef grub_int32_t int32_t; typedef grub_int64_t int64_t; #ifdef GRUB_CPU_WORDS_BIGENDIAN #define WORDS_BIGENDIAN #else #undef WORDS_BIGENDIAN #endif #endif
/** * OpenGeoDa TM, Copyright (C) 2011 by Luc Anselin - all rights reserved * * This file is part of OpenGeoDa. * * OpenGeoDa is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * OpenGeoDa is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef __GEODA_CENTER_PERMUTATION_COUNTER_DLG_H__ #define __GEODA_CENTER_PERMUTATION_COUNTER_DLG_H__ #include <wx/textctrl.h> #define IDD_PERMUTATION_COUNT 10000 #define SYMBOL_CPERMUTATIONCOUNTERDLG_STYLE wxCAPTION|wxSYSTEM_MENU|wxCLOSE_BOX #define SYMBOL_CPERMUTATIONCOUNTERDLG_TITLE "Set Number of Permutation" #define SYMBOL_CPERMUTATIONCOUNTERDLG_IDNAME IDD_PERMUTATION_COUNT #define SYMBOL_CPERMUTATIONCOUNTERDLG_SIZE wxDefaultSize #define SYMBOL_CPERMUTATIONCOUNTERDLG_POSITION wxDefaultPosition class PermutationCounterDlg: public wxDialog { DECLARE_CLASS( PermutationCounterDlg ) DECLARE_EVENT_TABLE() public: PermutationCounterDlg( ); PermutationCounterDlg( wxWindow* parent, wxWindowID id = -1, const wxString& caption="Set Number of Permutation", const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxCAPTION|wxSYSTEM_MENU ); bool Create( wxWindow* parent, wxWindowID id = -1, const wxString& caption = "Set Number of Permutation", const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxCAPTION|wxSYSTEM_MENU ); void CreateControls(); void OnOkClick( wxCommandEvent& event ); wxTextCtrl* m_number; wxString s_int; }; #endif
/* * ALSA sequencer Priority Queue * Copyright (c) 1998 by Frank van de Pol <fvdpol@coil.demon.nl> * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #ifndef __SND_SEQ_PRIOQ_H #define __SND_SEQ_PRIOQ_H #include "seq_memory.h" /* === PRIOQ === */ struct snd_seq_prioq { struct snd_seq_event_cell *head; /* pointer to head of prioq */ struct snd_seq_event_cell *tail; /* pointer to tail of prioq */ int cells; spinlock_t lock; }; /* create new prioq (constructor) */ struct snd_seq_prioq *snd_seq_prioq_new(void); /* delete prioq (destructor) */ void snd_seq_prioq_delete(struct snd_seq_prioq **fifo); /* enqueue cell to prioq */ int snd_seq_prioq_cell_in(struct snd_seq_prioq *f, struct snd_seq_event_cell *cell); /* dequeue cell from prioq */ struct snd_seq_event_cell *snd_seq_prioq_cell_out(struct snd_seq_prioq *f); /* return number of events available in prioq */ int snd_seq_prioq_avail(struct snd_seq_prioq *f); /* peek at cell at the head of the prioq */ struct snd_seq_event_cell *snd_seq_prioq_cell_peek(struct snd_seq_prioq *f); /* client left queue */ void snd_seq_prioq_leave(struct snd_seq_prioq *f, int client, int timestamp); /* Remove events */ void snd_seq_prioq_remove_events(struct snd_seq_prioq *f, int client, struct snd_seq_remove_events *info); #endif
/* * Copyright (C) 2009 Daniel Prevost <dprevost@photonsoftware.org> * * This file is part of Photon (photonsoftware.org). * * This file may be distributed and/or modified under the terms of the * GNU General Public License version 2 or version 3 as published by the * Free Software Foundation and appearing in the file COPYING.GPL2 and * COPYING.GPL3 included in the packaging of this software. * * Licensees holding a valid Photon Commercial license can use this file * in accordance with the terms of their license. * * This software 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. */ /* --+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+-- */ #include "folderTest.h" const bool expectedToPass = false; /* --+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+-- */ int main() { #if defined(USE_DBC) psonFolder* pFolder; psonSessionContext context; bool ok; psonTxStatus status; psoObjectDefinition def = { PSO_HASH_MAP, 0, 0, 0 }; psonKeyDefinition keyDef; psonDataDefinition fieldDef; psonDataDefinition * retDataDef = NULL; psoObjectDefinition retDef; pFolder = initFolderTest( expectedToPass, &context ); psonTxStatusInit( &status, SET_OFFSET( context.pTransaction ) ); ok = psonFolderInit( pFolder, 0, 1, 0, &status, 5, "Test1", 1234, &context ); if ( ok != true ) { ERROR_EXIT( expectedToPass, &context.errorHandler, ; ); } ok = psonFolderInsertObject( pFolder, "test2", "Test2", 5, &def, &fieldDef, &keyDef, 1, 0, &context ); if ( ok != true ) { ERROR_EXIT( expectedToPass, &context.errorHandler, ; ); } ok = psonFolderGetDefinition( pFolder, "test2", 5, &retDef, &retDataDef, NULL, &context ); ERROR_EXIT( expectedToPass, NULL, ; ); #else return 1; #endif } /* --+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+-- */
/* Copyright (c) 2016 Ian Hernandez * * 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 UTIL__H #define UTIL__H #include <stdbool.h> #include <stdio.h> /** Definition of the generic pointer data-type. */ typedef void * pointer; /** Definition of the character string data-type. */ typedef char * string; /** Struct that stores an array of elements and its length. */ typedef struct _BdwArray { pointer elements; /**< Elements of the array. */ unsigned int len; /**< Array's length. */ } BdwArray; /** * Function used to concatenate the given strings. * * @param arg NULL-terminated series of strings. * @return The concatenation of the strings given. */ string bdw_utils_strconcat (const char * arg, ...); /** * Function that creates a copy of the given string. * * @param arg String to be copied. * @return An exact copy of the given string. */ string bdw_utils_strcopy (const string arg); /** * Function that compares two strings. * * @param arg1 One of string to be compared. * @param arg2 The string to be compared with arg1. * @return * - @ref true if the strings are the same. * - @ref false otherwise. */ bool bdw_utils_strequals (const string arg1, const string arg2); /** * Function that trims a string at the first occurrence of a given character. * * @param str String to be trimmed. * @param delim Character used as delimiter for the trimming. */ void bdw_utils_strtrim (const string str, char delim); /** * Function that appends a character to a given string. * * @param dest String to be processed. * @param c Character to be appended. */ void bdw_utils_strappendchr (string dest, char c); /** * Function used to tokenize (or split) a given string by a given delimiter. * * @param str String to be tokenized (split). * @param delim String used as a delimiter for the tokenization. * @return The NULL-terminated array of strings result of the tokenization. */ string * bdw_utils_strsplit (const string str, const string delim); /** * Function that obtains the length of a NULL-terminated array of elements. * * @param array Pointer to the NULL-terminated array to be processed. * @return The length of the given array. */ int bdw_utils_nullarraylen (pointer array); /** * Function that creates and initializes a new BdwArray struct. * * @return A pointer to the newly created BdwArray struct. */ BdwArray * bdw_array_new (void); /** * Function that destroys and existing BdwArray struct. * * @param self Pointer to the BdwArray struct to be destroyed. */ void bdw_array_destroy (BdwArray * self); /** * Function that reads a line from a text file. * * @param file Text file from which the line will be read. * @return The line of text that was read from the file. */ string bdw_utils_filegetline (FILE * file); #endif /* UTIL__H */
/****************************************************************************** This file is part of XCygwinSetup, which is part of UserLib. Copyright (C) 1995-2014 Oliver Kreis (okdev10@arcor.de) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. ******************************************************************************/ #pragma once #include "FilePath.h" #include "WProcess.h" class CBashScript { public: CBashScript(CStringLiteral _installDir); ~CBashScript(void); void run(ConstRef(CFilePath) _file); private: CProcess _process; CFilePath _cmd; CStringBuffer _args; CDataVectorT<CStringBuffer> _env; CFilePath _startDir; void InitializeEnv(CStringLiteral _installDir); CBashScript(void); }; class CCmdScript { public: CCmdScript(CStringLiteral _installDir); ~CCmdScript(void); void run(ConstRef(CFilePath) _file); private: CProcess _process; CFilePath _cmd; CStringBuffer _args; CDataVectorT<CStringBuffer> _env; CFilePath _startDir; CCmdScript(void); };
/* GIMP - The GNU Image Manipulation Program * Copyright (C) 1995 Spencer Kimball and Peter Mattis * * gimpbrush-scale.h * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef __GIMP_BRUSH_SCALE_H__ #define __GIMP_BRUSH_SCALE_H__ /* virtual functions of GimpBrush, don't call directly */ void gimp_brush_real_transform_size (GimpBrush *brush, gdouble scale, gdouble aspect_ratio, gdouble angle, gint *scaled_width, gint *scaled_height); TempBuf * gimp_brush_real_transform_mask (GimpBrush *brush, gdouble scale, gdouble aspect_ratio, gdouble angle, gdouble hardness); TempBuf * gimp_brush_real_transform_pixmap (GimpBrush *brush, gdouble scale, gdouble aspect_ratio, gdouble angle, gdouble hardness); void gimp_brush_transform_matrix (gdouble width, gdouble height, gdouble scale, gdouble aspect_ratio, gdouble angle, GimpMatrix3 *matrix); #endif /* __GIMP_BRUSH_SCALE_H__ */
//Programming Exercise 4.8.8 #include <stdio.h> #define GL_TO_L 3.785 //1 gallon is about 3.785 liters int main(void) { const float M_TO_KM = 1.609; //1 miles is about 1.609 kilometres float miles, gallons; printf("Please enter the number of miles traveled:\n"); scanf("%f", &miles); printf("Please enter the number of gallons of gasoline:\n"); scanf("%f", &gallons); printf("the miles-per-gallon value of your car is %.1f\n", miles / gallons); printf("and the liters-per-100-km value of your car is %.1f\n", (gallons * GL_TO_L) / (miles * M_TO_KM / 100)); return 0; }
// // MSGRDEMOLoginViewController.h // MsgrDemo // // Created by Ke Zeng on 13-10-12. // Copyright (c) 2013年 msgr. All rights reserved. // #import <UIKit/UIKit.h> #import "MSGRDEMOLoginCell.h" @interface MSGRDEMOLoginViewController : UITableViewController<MSGRDEMOLoginCellDelegate> @end
/* =========================================================================== Copyright (c) 2010-2015 Darkstar Dev Teams This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/ This file is part of DarkStar-server source code. =========================================================================== */ #ifndef _PET_CONTROLLER_H #define _PET_CONTROLLER_H #include "ai_controller.h" class CPetEntity; class CPetController : public CAIController { public: CPetController(CPetEntity* PPet); static constexpr float PetRoamDistance {2.1f}; virtual void DoRoamTick(time_point tick) override; protected: bool PetIsHealing(); virtual void Tick(time_point tick) override; virtual void HandleEnmity() override {} virtual bool TryDeaggro() override; virtual void TryLink() override {} virtual void Ability(uint16 targid, uint16 abilityid) override; private: CPetEntity* const PPet; }; #endif // _AI_CONTROLLER_H
// -*- mode: C++; c-basic-offset: 4 -*- // Copyright (C) 2015 Joerg Faschingbauer // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public License // as published by the Free Software Foundation; either version 2.1 of // the License, or (at your option) any later version. // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 // USA #ifndef HAVE_JF_LINUXTOOLS_THREADPOOL_H #define HAVE_JF_LINUXTOOLS_THREADPOOL_H #include "joinable-thread.h" #include "message-queue.h" #include <vector> namespace jf { namespace linuxtools { class ThreadPool { public: class Command { public: virtual ~Command() {} virtual void execute() = 0; }; public: ThreadPool(size_t numthreads); ~ThreadPool(); // execute the command. returns once the command has been fully // executed. void execute(Command *); public: // this is like a future, but with no data. simply carries a // "done" flag which is waited upon. class Synchronizer { public: Synchronizer(); void wait(); void done(); private: bool is_done_; Mutex lock_; Condition done_; }; private: // the queue which we send commands and their syncers over. MessageQueue<std::pair<Command*, class Synchronizer*> > command_queue_; // threads and their worker objects typedef std::vector<std::pair<JoinableThreadStarter*,JoinableThreadStarter::Worker*> > ThreadsAndWorkers; ThreadsAndWorkers threads_and_workers_; }; } } #endif
void foo() { int x, y; x = 0; y = 0; while (y >= 0) { y = y + x; } assert(false); }
/* Standard */ #include <signal.h> /* System */ #if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_11 #include <CoreAudio/CoreAudio.h> #include <AudioToolbox/AudioToolbox.h> #include <AudioUnit/AudioUnit.h> #endif /* Me */ #include "audio_io.h" #include "beats.h" OSStatus ByteBeat(void * inRefCon, AudioUnitRenderActionFlags * ioActionFlags, const AudioTimeStamp * inTimeStamp, UInt32 inBusNumber, UInt32 inNumberFrames, AudioBufferList * ioData) { sound_format_t * sound = (sound_format_t *)inRefCon; Float32 * outputBuffer = (Float32 *)ioData->mBuffers[0].mData; register int32_t t = sound->cursor; for(int i = 0; i < inNumberFrames; i++) { outputBuffer[i] = sound->cb(t); t++; } sound->cursor = t; for(int i = 1; i < ioData->mNumberBuffers; i++) { memcpy(ioData->mBuffers[i].mData, outputBuffer, ioData->mBuffers[i].mDataByteSize); } return noErr; } void audio_startup(AudioUnit * unit, session_t * session) { OSStatus ok; AudioComponentDescription outputUnitDescription = { .componentType = kAudioUnitType_Output, .componentSubType = kAudioUnitSubType_DefaultOutput, .componentManufacturer = kAudioUnitManufacturer_Apple }; AudioComponent outputComponent = AudioComponentFindNext(NULL, &outputUnitDescription); AudioComponentInstanceNew(outputComponent, unit); AudioUnitInitialize(*unit); AudioStreamBasicDescription ASBD = { .mSampleRate = session->sound.sampleRate, .mFormatID = kAudioFormatLinearPCM, .mFormatFlags = kAudioFormatFlagsNativeFloatPacked, .mChannelsPerFrame = 1, .mFramesPerPacket = 1, .mBitsPerChannel = sizeof(Float32) * 8, .mBytesPerPacket = sizeof(Float32), .mBytesPerFrame = sizeof(Float32) }; ok = AudioUnitSetProperty(*unit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, 0, &ASBD, sizeof(ASBD)); if ( ok != noErr ) { fprintf(stderr, "Unable to assign Audio Stream Description propery.\n"); raise(SIGABRT); } AURenderCallbackStruct callbackInfo = { .inputProc = ByteBeat, .inputProcRefCon = &(session->sound), }; ok = AudioUnitSetProperty(*unit, kAudioUnitProperty_SetRenderCallback, kAudioUnitScope_Global, 0, &callbackInfo, sizeof(callbackInfo)); if ( ok != noErr ) { fprintf(stderr, "Unable to assign Program Callback propery.\n"); raise(SIGABRT); } ok = AudioOutputUnitStart(*unit); if ( ok != noErr ) { fprintf(stderr, "Could not start audio output!\n"); raise(SIGABRT); } } void audio_teardown(AudioUnit * unit) { AudioOutputUnitStop(*unit); AudioUnitUninitialize(*unit); AudioComponentInstanceDispose(*unit); }
#pragma once #include "GL.h" #include "GLShader.h" class GLShaderProgram { public: GLShaderProgram(); virtual ~GLShaderProgram(); GLenum GetProgram() const; void LinkProgram(); void UseProgram(); void BindVertexArray(); void UnbindVertexArray(); void RegisterVertexArray(float *vertices, int vertexSize, unsigned int *indices, int indexSize); void UnregisterVertexArray(); private: GLenum m_uiProgram; GLuint m_uiVAO; // Vertex Array Object GLuint m_uiVBO; // Vertex Buffer Object GLuint m_uiEBO; // Element Buffer Object GLShader *cVertexShader; GLShader *cFragmentShader; };
#ifndef MENU_H #define MENU_H #include <QFrame> #include "centralwidget.h" namespace Ui { class Menu; } class MainEngine; class TeamHolder; class Menu : public QFrame, public CentralWidgetInterface { Q_OBJECT public: explicit Menu(TeamHolder *t); ~Menu(); /* Creates a menu bar to give to the main window */ QMenuBar *createMenuBar(MainEngine *w); void showChangeLog(); signals: void goToTeambuilder(); void goToOnline(); void goToCredits(); void goToExit(); void downloadUpdateRequested(); public slots: void loadTeam(); void loadAll(const TeamHolder&); void setUpdateData(const QString &data); void setChangeLogData(const QString &data); void prevTip(); void nextTip(); private slots: void on_updateButton_clicked(); protected: bool event(QEvent *e); private: Ui::Menu *ui; TeamHolder *team; QStringList msgs; int currentTip; void updateTip(); }; #endif // MENU_H
/****************************************************************************** ** ** Copyright 2016 Dale Eason ** This file is part of DFTFringe ** is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation version 3 of the License ** DFTFringe is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with DFTFringe. If not, see <http://www.gnu.org/licenses/>. ****************************************************************************/ #ifndef VORTEX_H #define VORTEX_H #include <opencv/cv.h> void vortex(cv::Mat &dft, const char *ext, double low, double smooth, double *phase, const char *what); #endif // VORTEX_H
// ShellToolExt.h : CShellToolExt µÄÉùÃ÷ #pragma once #include "resource.h" // Ö÷·ûºÅ #include "ShellTools_i.h" #include <ShlObj.h> #include <comdef.h> #include <vector> #include <string> using namespace std; #include "Menu.h" #if defined(_WIN32_WCE) && !defined(_CE_DCOM) && !defined(_CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA) #error "Windows CE ƽ̨(Èç²»ÌṩÍêÈ« DCOM Ö§³ÖµÄ Windows Mobile ƽ̨)ÉÏÎÞ·¨ÕýÈ·Ö§³Öµ¥Ïß³Ì COM ¶ÔÏó¡£¶¨Òå _CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA ¿ÉÇ¿ÖÆ ATL Ö§³Ö´´½¨µ¥Ïß³Ì COM ¶ÔÏóʵÏÖ²¢ÔÊÐíʹÓÃÆäµ¥Ïß³Ì COM ¶ÔÏóʵÏÖ¡£rgs ÎļþÖеÄÏß³ÌÄ£ÐÍÒѱ»ÉèÖÃΪ¡°Free¡±£¬Ô­ÒòÊǸÃÄ£ÐÍÊÇ·Ç DCOM Windows CE ƽ̨֧³ÖµÄΨһÏß³ÌÄ£ÐÍ¡£" #endif // CShellToolExt class ATL_NO_VTABLE CShellToolExt : public CComObjectRootEx<CComSingleThreadModel>, public CComCoClass<CShellToolExt, &CLSID_ShellToolExt>, public IDispatchImpl<IShellToolExt, &IID_IShellToolExt, &LIBID_ShellToolsLib, /*wMajor =*/ 1, /*wMinor =*/ 1>, public IShellExtInit, public IContextMenu3 { public: CShellToolExt(); DECLARE_REGISTRY_RESOURCEID(IDR_SHELLTOOLEXT) BEGIN_COM_MAP(CShellToolExt) COM_INTERFACE_ENTRY(IShellToolExt) COM_INTERFACE_ENTRY(IDispatch) COM_INTERFACE_ENTRY(IShellExtInit) COM_INTERFACE_ENTRY(IContextMenu3) COM_INTERFACE_ENTRY(IContextMenu2) COM_INTERFACE_ENTRY(IContextMenu) END_COM_MAP() DECLARE_PROTECT_FINAL_CONSTRUCT() HRESULT FinalConstruct() { return S_OK; } void FinalRelease() { } public: //IShellExtInit STDMETHOD(Initialize)(LPCITEMIDLIST, LPDATAOBJECT, HKEY); //IContextMenu3 STDMETHOD(GetCommandString)(UINT, UINT, UINT*, LPSTR, UINT); STDMETHOD(InvokeCommand)(LPCMINVOKECOMMANDINFO); STDMETHOD(QueryContextMenu)(HMENU, UINT, UINT, UINT, UINT); STDMETHOD(HandleMenuMsg)(UINT, WPARAM, LPARAM); STDMETHOD(HandleMenuMsg2)(UINT, WPARAM, LPARAM, LRESULT*); protected: enum { FTYPE_FILE = 0x01, FTYPE_DIR = 0x02, FTYPE_BACK = 0x04, }; bool ReadPlugFile(int type, const vector<string>& files); vector<string> m_FileNames; vector<Menu> m_menus; HBITMAP m_hBitmap; }; OBJECT_ENTRY_AUTO(__uuidof(ShellToolExt), CShellToolExt)
/* SuperCollider real time audio synthesis system Copyright (c) 2002 James McCartney. All rights reserved. http://www.audiosynth.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* PyrSlot is a value holder for SC variables. A PyrSlot is an 8-byte value which is either a double precision float or a 32-bit tag plus a 32-bit value. */ #ifndef _PYRSLOT_H_ #define _PYRSLOT_H_ #if ( __SIZEOF_POINTER__ == 8 ) || defined(__x86_64__) || defined(_M_X64) || defined(__LP64__) || defined(_WIN64) #define SC_USE_128BIT_SLOT #include "PyrSlot64.h" #elif ( __SIZEOF_POINTER__ == 4 ) || defined(__i386__) || defined(_M_IX86) || defined(__ILP32__) || defined(_WIN32) || defined(__ppc__) || defined(__arm__) #include "PyrSlot32.h" #else #error "no PyrSlot imlementation for this platform" #endif extern PyrSlot o_nil, o_true, o_false, o_inf; extern PyrSlot o_fhalf, o_fnegone, o_fzero, o_fone, o_ftwo; extern PyrSlot o_negone, o_zero, o_one, o_two; extern PyrSlot o_emptyarray, o_onenilarray, o_argnamethis; extern PyrSymbol *s_object; // "Object" extern PyrSymbol *s_this; // "this" extern PyrSymbol *s_super; // "super" void dumpPyrSlot(PyrSlot* slot); void slotString(PyrSlot *slot, char *str); void slotOneWord(PyrSlot *slot, char *str); bool postString(PyrSlot *slot, char *str); const char *slotSymString(PyrSlot* slot); int asCompileString(PyrSlot *slot, char *str); int slotIntVal(PyrSlot* slot, int *value); int slotFloatVal(PyrSlot* slot, float *value); int slotDoubleVal(PyrSlot *slot, double *value); int slotStrVal(PyrSlot *slot, char *str, int maxlen); int slotStrLen(PyrSlot *slot); int slotPStrVal(PyrSlot *slot, unsigned char *str); int slotSymbolVal(PyrSlot *slot, PyrSymbol **symbol); #endif
#ifndef Irq2Operation_H #define Irq2Operation_H #include "PinOperation.h" #include "GPIOTypes.h" class Irq2Operation : public PinOperation { public: Irq2Operation(); virtual string toString(); virtual bool execute(AppInfo * appInfo); static string help(); string cmd1; string cmd2; long int debounceMS; protected: virtual bool build(AppInfo * appInfo, list<string> * &paramList, list<string>::iterator * &paramIter); }; #endif
// // Created by Frank Steiler on 9/28/16 as part of NOOBS4IoT (https://github.com/steilerDev/NOOBS4IoT) // // Utility.h: // This file contains general utility functions required by the application. // For more information see https://github.com/steilerDev/NOOBS4IoT/wiki. // // This file is based on several files from the NOOBS project (c) 2013, Raspberry Pi All rights reserved. // See https://github.com/raspberrypi/noobs for more information. // // This file is licensed under a GNU General Public License v3.0 (c) Frank Steiler. // See https://raw.githubusercontent.com/steilerDev/NOOBS4IoT/master/LICENSE for more information. // #ifndef RECOVERY_UTLILITY_H #define RECOVERY_UTLILITY_H #include <QString> #include <QVariant> #include "libs/easylogging++.h" #include "libs/QRCode/QrCode.hpp" /* Partitioning settings */ #define PARTITION_ALIGNMENT 8192 #define PARTITION_GAP 2 /* Allow partitions to be shrinked PARTITION_GAP sectors if that prevents having a 4 MiB gap between the next one */ #define SHRINK_PARTITIONS_TO_MINIMIZE_GAPS #define SETTINGS_PARTITION "/dev/mmcblk0p5" #define SETTINGS_DIR "/settings" #define SYSTEMS_PARTITION "/dev/mmcblk0p1" #define SYSTEMS_DIR "/mnt" #define SETTINGS_PARTITION_SIZE (32 * 2048 - PARTITION_GAP) // This file contains the partition device that the system will automatically boot into #define DEFAULT_BOOT_PARTITION_FILE "/settings/default_boot_partition" /* RiscOS magic */ #define RISCOS_OFFSET (1760) #define RISCOS_SECTOR_OFFSET (RISCOS_OFFSET * 2048) #define RISCOS_BLOB_FILENAME "/mnt/riscos-boot.bin" #define RISCOS_BLOB_SECTOR_OFFSET (1) /* Maximum number of partitions */ #define MAXIMUM_PARTITIONS 32 namespace Utility { namespace Json { QMap<QString, QVariant> parseJson(const QString &jsonString); QMap<QString, QVariant> parseJson(const QByteArray &json); QVariant loadFromFile(const QString &filename); bool saveToFile(const QString &filename, const QVariant &json); void printJson(QMap<QString, QVariant> &json); void printJsonArray(QList<QVariant> &json); // This function attemps to parse an entry to the given format. It returns true on success and writes the value into target. // If optional is set to true, the function will return true without writing to the target if the value was not found in the provided map. // description is used for logging reasons. template <typename T> static bool parseEntry(const QMap<QString, QVariant> source, const QString &key, T* target, const bool optional, const std::string &description) { LDEBUG << "Trying to parse " << description; if(source.contains(key)) { if(source.value(key).canConvert<T>()) { *target = source.value(key).value<T>(); return true; } else { LFATAL << "Unable to parse " << description << " (wrong format)"; return false; } } else { if(optional) { LWARNING << "Unable to find " << description; return true; } else { LFATAL << "Unable to find " << description; return false; } } } } namespace Sys { bool mountSystemsPartition(); bool unmountSystemsPartition(); bool mountSettingsPartition(); bool unmountSettingsPartition(); bool mountPartition(const QString &partition, const QString &dir, const QString &args = QString()); bool unmountPartition(const QString &dir); bool remountPartition(const QString &partition, const QString &args = QString()); bool partitionIsMounted(const QString &partition, const QString &dir = QString()); QByteArray getFileContents(const QString &filename); bool putFileContents(const QString &filename, const QByteArray &data); } namespace Debug { QMap<QString, QVariant>* getRaspbianJSON(); } void printQrCode(const qrcodegen::QrCode &qrCode); } #endif //RECOVERY_UTLILITY_H
/* °ÔÀÓ ¼³¸í - ºÏÂÊ¿¡¼­´Â °øÁ߸÷°ú Áö»ó¸÷ÀÌ ÀÏÁ¤ ÁÖ±â·Î »ý»ê - ³²ÂÊ¿¡¼­´Â ÁÂŬ¸¯(Áö»ó) ¿ìŬ¸¯(°øÁß) »ý»ê°¡´É - È­¸éÈçµé¸²Àº ³Ê¹« ¾îÁö·¯¿ï ¼ö À־ °Ç¹°ÀÌ ¹ß»çÇÏ´Â ÃѾËÀÌ °Ç¹°¿¡ ºÎµúÈú °æ¿ì¸¸ È­¸éÈçµé¸² - ÃÑ¾Ë È­»ì ÆÄƼŬ, Äɸ¯ÅÍ ÀüºÎ ½ºÇÁ¶óÀÌÆ® À̹ÌÁö »ç¿ë - ÃÑ¾Ë ¹ß»ç½Ã »ç¿îµå Ãâ·Â, ij¸¯ÅÍ »ý¼º½Ã »ç¿îµå Ãâ·Â, °ÔÀÓ ¹è°æÀ½Á¸Àç - ij¸¯ÅÍ Ãæµ¹ ÀÌÈÄ Àû±ºÀÌ »ç¶óÁ®µµ ¿òÁ÷ÀÌÁö ¾Ê´Â°ÍÀº ÀǵµÇÑ °Í. (¿òÁ÷ÀÌ´Ù°¡ À§Ä¡ ¹ß°¢µÇ¸é Àº¾öÆóÄÁ¼Á) - ¿ÀºêÁ§Æ® ¼Ó¼ºÁß¿¡ ¾îÅà ŸÀÔ, À¯´Ö ŸÀÔ, »óÅ º¯¼ö Ãß°¡ - À¯´Ö ŸÀÔÀº ÀÌ À¯´ÖÀÌ Áö»óÀ¯´ÖÀÎÁö °øÁßÀ¯´ÖÀÎÁö ÆÄ¾Ç, °ø°ÝŸÀÔÀº °ø°Ý°¡´ÉÇÑ À¯´Ö ´ë»ó ³ªÅ¸³¿ , »óꝼö´Â À¯´ÖÀÌ ¸ØÃß¾ú´ÂÁö ¿òÁ÷ÀÌ´ÂÁö¿¡ ´ëÇÑ °ª - °Ç¹°ÀÌ ¸ðµÎ ¾ø¾îÁø Ç÷¹À̾ ÀÖ´Ù¸é ¸ÞÀηçÇÁ Å»ÃâÇÏ¸ç °ÔÀÓ Á¾·á */
// This file is part of GtkEveMon. // // GtkEveMon is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // You should have received a copy of the GNU General Public License // along with GtkEveMon. If not, see <http://www.gnu.org/licenses/>. #ifndef GTK_SERVER_HEADER #define GTK_SERVER_HEADER #include <gtkmm.h> #include "bits/server.h" class GtkServer : public Gtk::Table { private: ServerPtr server; Gtk::Button status_but; Gtk::Label name; Gtk::Label status; Gtk::Label status_desc; void force_refresh (void); void set_status_icon (const Glib::ustring icon_name); public: GtkServer (ServerPtr server); void update (void); }; #endif /* GTK_SERVER_HEADER */
#ifndef DEFINES_H #define DEFINES_H #include <QString> #include <QStringList> #include "core/warlibexception.h" const int SAVE_VERSION(3); const QString MODEL_PATH("models"); const QString ARMY_PATH("armies"); const QString MAGICAL_OBJECT_PATH("magical_objects"); const QString TERRAIN_PATH("terrains"); const QString AUTOSAVE_PATH("autosaves"); const QString AUTOSAVE_FILE_NAME("autosave"); const QString CAVALERY_STRING("Cavalerie"); const QString CHARACTER_STRING("Personnage"); const QString CHARRIOT_STRING("Char"); const QString INFANTERY_STRING("Infanterie"); const QString MONSTER_STRING("Monstre"); const QString WARMACHINE_STRING("Machine de Guerre"); const QString MESSAGE_LIST_ARGUMENT("ml"); const QString NO_GRAPHICS_ARGUMENT("no-graphics"); const QString LAUNCH_SERVER_OPTION("launch-server"); const QString AUTOSAVE_ARGUMENT("autosave"); // Autosave interval = x * 60 * 1000 ms => X minutes // Here default interval is 60 minnutes #define AUTOSAVE_INTERVAL 60 * 60 * 1000 #define CAVALERY_TYPE 0 #define CHARACTER_TYPE 1 #define CHARRIOT_TYPE 2 #define INFANTERY_TYPE 3 #define MONSTER_TYPE 4 #define WARMACHINE_TYPE 5 #define UNKNOWN 99 enum ModelType { BASE, SPECIAL, RARE, CHARACTER }; #endif // DEFINES_H
/* * arch/arch/mach-ixp4xx/fsg-pci.c * * FSG board-level PCI initialization * * Author: Rod Whitby <rod@whitby.id.au> * Maintainer: http://www.nslu2-linux.org/ * * based on ixdp425-pci.c: * Copyright (C) 2002 Intel Corporation. * Copyright (C) 2003-2004 MontaVista Software, Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * */ #include <linux/pci.h> #include <linux/init.h> #include <linux/irq.h> #include <asm/mach/pci.h> #include <asm/mach-types.h> #define MAX_DEV 3 #define IRQ_LINES 3 /* PCI controller GPIO to IRQ pin mappings */ #define INTA 6 #define INTB 7 #define INTC 5 void __init fsg_pci_preinit(void) { irq_set_irq_type(IXP4XX_GPIO_IRQ(INTA), IRQ_TYPE_LEVEL_LOW); irq_set_irq_type(IXP4XX_GPIO_IRQ(INTB), IRQ_TYPE_LEVEL_LOW); irq_set_irq_type(IXP4XX_GPIO_IRQ(INTC), IRQ_TYPE_LEVEL_LOW); ixp4xx_pci_preinit(); } static int __init fsg_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) { static int pci_irq_table[IRQ_LINES] = { IXP4XX_GPIO_IRQ(INTC), IXP4XX_GPIO_IRQ(INTB), IXP4XX_GPIO_IRQ(INTA), }; int irq = -1; slot -= 11; if (slot >= 1 && slot <= MAX_DEV && pin >= 1 && pin <= IRQ_LINES) { irq = pci_irq_table[slot - 1]; } printk(KERN_INFO "%s: Mapped slot %d pin %d to IRQ %d\n", __func__, slot, pin, irq); return irq; } struct hw_pci fsg_pci __initdata = { .nr_controllers = 1, .ops = &ixp4xx_ops, .preinit = fsg_pci_preinit, .setup = ixp4xx_setup, .map_irq = fsg_map_irq, }; int __init fsg_pci_init(void) { if (machine_is_fsg()) { pci_common_init(&fsg_pci); } return 0; } subsys_initcall(fsg_pci_init);
/* This file is part of Cute Chess. Cute Chess is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Cute Chess is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Cute Chess. If not, see <http://www.gnu.org/licenses/>. */ #ifndef ELO_H #define ELO_H #include <QtGlobal> /*! * \brief Utility class for calculating Elo statistics for a single player * * The Elo class can be used to calculate Elo difference, Elo error margin, * etc. based on player's W/D/L statistics. At its present state it's very * suitable for matches between two players but not that accurate when * there are more than 2 players in a tournament. This is because the ratings * are calculated as if each player's results were against a single opponent. */ class LIB_EXPORT Elo { public: /*! Creates a new Elo object. */ Elo(int wins, int losses, int draws); /*! Returns the Elo difference. */ qreal diff() const; /*! Returns the error margin in Elo points. */ qreal errorMargin() const; /*! Returns the ratio of points won. */ qreal pointRatio() const; /*! Returns the ratio of drawn games. */ qreal drawRatio() const; private: int m_wins; int m_losses; int m_draws; qreal m_mu; qreal m_stdev; // Elo difference static qreal diff(qreal p); // Inverted error function static qreal erfInv(qreal x); // Quantile function for the standard Gaussian law: // probability -> quantile static qreal phiInv(qreal p); }; #endif // ELO_H
/* * @note : Óû§·þÎñÆ÷ * @author £ºAndy.Ro * @email £ºQwuloo@qq.com * @date £º2014-06 * @mark £ºÓõ½ÁËËĸöÀࣺxClient£¬xClientFactory£¬xConnection£¬xConnectionFactory ¹©Íⲿ¼Ì³Ð(λÓÚ/xNet/Ŀ¼ÏÂ) * */ #ifndef _XUSER_SERVER_H_INCLUDE_ #define _XUSER_SERVER_H_INCLUDE_ // Óõ½µÄÏà¹ØÀàÉùÃ÷ class xClient; // ×÷Ϊ TCP ·þÎñÆ÷½¨Á¢µÄÓë¿Í»§¶ËÁ¬½Ó¶ÔÏó´úÀí»ùÀà class xConnection; // ×÷Ϊ TCP ¿Í»§¶Ë½¨Á¢µÄÓë·þÎñÆ÷Á¬½Ó¶ÔÏó´úÀí»ùÀà class xClientFactory; // Óë¿Í»§¶ËÁ¬½Ó´úÀí·þÎñÀà(×÷Ϊ TCP ·þÎñÆ÷) class xConnectionFactory; // Óë·þÎñÆ÷Á¬½Ó´úÀí·þÎñÀà(×÷Ϊ TCP ¿Í»§¶Ë) class C2SClient; class C2S_Server; // Óû§·þÎñÆ÷(×÷Ϊ TCP ·þÎñÆ÷) class S2PConnection; class S2P_Server; // Óû§·þÎñÆ÷(×÷Ϊ TCP ¿Í»§¶Ë) typedef C2S_Server UserServer; //------------------------------------------------------------------------ // C2SClient //------------------------------------------------------------------------ class C2SClient : public xClient { friend class C2S_Server; private: C2SClient(C2S_Server* factory); C2SClient* init(C2S_Server* factory); protected: int onMade(void); int onLost(u32_t err); int onRecv(char const* buf, u64_t len); public: u32_t _uid; public: ~C2SClient(void); }; //------------------------------------------------------------------------ // C2S_Server //------------------------------------------------------------------------ class C2S_Server : public xClientFactory { public: typedef std::map<u32_t,C2SClient*> map_id_client_t; typedef map_id_client_t::iterator itor_id_client_t; typedef map_id_client_t map_uID_C2S_client; typedef map_uID_C2S_client itor_uID_C2S_client; public: C2S_Server(void); inline u32_t getsid(void) { return this->m_sid; } inline u32_t getpid(void) { return this->m_pid; } public: xClient * create(void); void free (xClient * object); void onAdd(xClient * object); void onDel(xClient * object); void onMsg(xClient * object, char const* buf, u64_t len); protected: u32_t m_sid; // Óû§·þid u32_t m_pid; // ËùÔÚÆ½Ì¨·þid public: virtual ~C2S_Server(void); }; //------------------------------------------------------------------------ // S2PConnection //------------------------------------------------------------------------ class S2PConnection : public xConnection { friend class S2P_Server; private: S2PConnection(S2P_Server* factory); S2PConnection* init(S2P_Server* factory); protected: int onMade(void); int onLost(u32_t err); int onRecv(char const* buf, u64_t len); int S2PRegister(void); protected: public: ~S2PConnection(void); }; //------------------------------------------------------------------------ // S2P_Server //------------------------------------------------------------------------ class S2P_Server : public xConnectionFactory { typedef std::map<SOCKET,xConnection* > map_fd_conncection_t; typedef map_fd_conncection_t::iterator itor_fd_conncection_t; public: S2P_Server(void); xConnection * create(void); void free (xConnection * object); void onAdd(xConnection * object); void onDel(xConnection * object); void onMsg(xConnection * object, char const* buf, u64_t len); public: ~S2P_Server(void); }; #endif // _XUSER_SERVER_H_INCLUDE_
/* * GPInstruct - Programmed Instruction * Copyright (C) 2011-2012 Arnel A. Borja <kyoushuu@yahoo.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef _GPINSTRUCT_LESSON_READING_PAGE_H_ #define _GPINSTRUCT_LESSON_READING_PAGE_H_ #include <glib-object.h> G_BEGIN_DECLS #define GPINSTRUCT_TYPE_LESSON_READING_PAGE (gpinstruct_lesson_reading_page_get_type ()) #define GPINSTRUCT_LESSON_READING_PAGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GPINSTRUCT_TYPE_LESSON_READING_PAGE, GPInstructLessonReadingPage)) #define GPINSTRUCT_LESSON_READING_PAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GPINSTRUCT_TYPE_LESSON_READING_PAGE, GPInstructLessonReadingPageClass)) #define GPINSTRUCT_IS_LESSON_READING_PAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GPINSTRUCT_TYPE_LESSON_READING_PAGE)) #define GPINSTRUCT_IS_LESSON_READING_PAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GPINSTRUCT_TYPE_LESSON_READING_PAGE)) #define GPINSTRUCT_LESSON_READING_PAGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GPINSTRUCT_TYPE_LESSON_READING_PAGE, GPInstructLessonReadingPageClass)) typedef struct _GPInstructLessonReadingPageClass GPInstructLessonReadingPageClass; typedef struct _GPInstructLessonReadingPage GPInstructLessonReadingPage; struct _GPInstructLessonReadingPageClass { GPInstructLessonViewPageClass parent_class; }; struct _GPInstructLessonReadingPage { GPInstructLessonViewPage parent_instance; }; GType gpinstruct_lesson_reading_page_get_type (void) G_GNUC_CONST; GPInstructLessonReadingPage *gpinstruct_lesson_reading_page_new (GPInstructLessonReading *reading); G_END_DECLS #endif /* _GPINSTRUCT_LESSON_READING_PAGE_H_ */
/* See LICENSE file for copyright and license details. */ #define IN_LIBGAMMA_DUMMY #include "common.h" /** * Restore the gamma ramps all CRTC:s with a partition to the system settings * * @param this The partition state * @return Zero on success, otherwise (negative) the value of an * error identifier provided by this library */ int libgamma_dummy_partition_restore(struct libgamma_partition_state *restrict this) { struct libgamma_dummy_partition *data = this->data; size_t i; if (!libgamma_dummy_internal_configurations.capabilities.partition_restore) { errno = ENOTSUP; return LIBGAMMA_ERRNO_SET; } for (i = 0; i < data->crtc_count; i++) if (libgamma_dummy_internal_crtc_restore_forced(data->crtcs + i)) return -1; return 0; }
/* * log_op.h * * Created on: Dec 4, 2013 * Author: reboot */ #ifndef LOG_OP_H_ #define LOG_OP_H_ #include <glutil.h> #include <fp_types.h> #include <im_hdr.h> char * g_dgetf (char *str); typedef int _d_ag_handle_i (__g_handle); int determine_datatype (__g_handle hdl, char *file); int g_proc_mr (__g_handle hdl); char *_print_ptr, *_print_ptr_post, *_print_ptr_pre, *_cl_print_ptr; int data_backup_records (char *file); int rebuild (void *arg); int d_gen_dump (char *arg); #endif /* LOG_OP_H_ */
/* * Copyright (C) 2012 Yee Young Han <websearch@naver.com> (http://blog.naver.com/websearch) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _SIP_STACK_SETUP_H_ #define _SIP_STACK_SETUP_H_ /** * @ingroup SipStack * @brief SIP stack ¼³Á¤ Ŭ·¡½º */ class CSipStackSetup { public: CSipStackSetup(); ~CSipStackSetup(); bool Check( ); int GetLocalPort( ESipTransport eTransport ); /** SIP ¸Þ½ÃÁö¿¡ ÀúÀåµÇ´Â ·ÎÄà IP ÁÖ¼Ò */ std::string m_strLocalIp; /** SIP ¸Þ½ÃÁö Àü¼Û/¼ö½Å¿ë UDP Æ÷Æ® ¹øÈ£ */ int m_iLocalUdpPort; /** SIP ¸Þ½ÃÁö ¼ö½Å¿ë UDP ¾²·¹µå °³¼ö */ int m_iUdpThreadCount; /** SIP ¸Þ½ÃÁö Àü¼Û/¼ö½Å¿ë TCP Æ÷Æ® ¹øÈ£ */ int m_iLocalTcpPort; /** SIP ¸Þ½ÃÁö Àü¼Û/¼ö½Å¿ë TLS Æ÷Æ® ¹øÈ£ */ int m_iLocalTlsPort; /** SIP ¸Þ½ÃÁö ¼ö½Å¿ë TCP ¾²·¹µå °³¼ö */ int m_iTcpThreadCount; /** SIP ¸Þ½ÃÁö ¼ö½Å callback 󸮸¦ À§ÇÑ TCP ¾²·¹µå °³¼ö. º» °³¼ö°¡ 0 À̸é TCP ¼ö½Å ¾²·¹µå¿¡¼­ callback À» È£ÃâÇϰí 0 º¸´Ù Å©¸é tcp callback ¾²·¹µå¿¡¼­ callback À» È£ÃâÇÑ´Ù. */ int m_iTcpCallBackThreadCount; /** SIP ¸Þ½ÃÁö ¼ö½Å¿ë TCP ¾²·¹µå Çϳª¿¡ Æ÷Ç﵃ ¼ö ÀÖ´Â ÃÖ´ë ¼ÒÄÏ °³¼ö */ int m_iTcpMaxSocketPerThread; /** SIP ¸Þ½ÃÁö ¼ö½Å¿ë TCP ¼ÒÄÏÀÇ ¼ö½Å ´ë±â ½Ã°£ (ÃÊ´ÜÀ§) */ int m_iTcpRecvTimeout; /** TCP ¼¼¼Ç ¿¬°á timeout ½Ã°£ (ÃÊ´ÜÀ§) */ int m_iTcpConnectTimeout; /** TLS ¼¼¼Ç handshake ´ë±â ½Ã°£ (ÃÊ´ÜÀ§) */ int m_iTlsAcceptTimeout; /** TLS ¼¼¼ÇÀ» À§ÇÑ ¼­¹ö ÀÎÁõ¼­ + °³ÀÎ۸¦ Æ÷ÇÔÇÑ PEM ÆÄÀÏ */ std::string m_strCertFile; /** TLS ¼¼¼ÇÀ¸·Î ¿¬°áÇÑ Å¬¶óÀÌ¾ðÆ® ÀÎÁõÀ» À§ÇÑ ÀÎÁõ ±â°ü ÀÎÁõ¼­ PEM ÆÄÀÏ */ std::string m_strCaCertFile; /** SIP UserAgent Çì´õ¿¡ ÀúÀåµÉ ¹®ÀÚ¿­ */ std::string m_strUserAgent; /** SIP ¸Þ½ÃÁö¸¦ »ý¼ºÇÒ ¶§¿¡ compact form À¸·Î »ý¼ºÇÒÁö ¼³Á¤ */ bool m_bUseSipCompactForm; /** SIP stack ½ÇÇà ÁÖ±â (ms ´ÜÀ§) */ int m_iStackExecutePeriod; /** timer D ¸¸·á½Ã°£ (ms ´ÜÀ§) */ int m_iTimerD; /** timer J ¸¸·á½Ã°£ (ms ´ÜÀ§) */ int m_iTimerJ; /** IPv6 »ç¿ë À¯¹« */ bool m_bIpv6; /** Stateful SIP stack Àΰ¡? */ bool m_bStateful; /** TLS Ŭ¶óÀÌ¾ðÆ®¸¸ »ç¿ëÇϴ°¡? SIP Ŭ¶óÀÌ¾ðÆ®¿¡¼­ TLS ¼­¹ö´Â »ç¿ëÇÏÁö ¾Ê°í TLS Ŭ¶óÀÌ¾ðÆ®¸¸ »ç¿ëÇÏ´Â °æ¿ì true ·Î ¼³Á¤ÇÑ´Ù. */ bool m_bTlsClient; /** SIP ¿äû ¸Þ½ÃÁö¸¦ Àü¼ÛÇÒ ¶§¿¡ Contact Çì´õ¿¡ ¼ö½Å Æ÷Æ® ¹øÈ£¸¦ »ç¿ëÇÏ´Â °æ¿ì true ·Î ¼³Á¤ÇÑ´Ù. */ bool m_bUseContactListenPort; /** SIP REGISTER ¸¦ Àü¼ÛÇÑ ÈÄ, ¼ö½ÅÇÑ 401 ÀÀ´äÀÇ Authenticate ¸¦ ÀúÀåÇÏ¿©¼­ ´ÙÀ½ ÁÖ±âÀÇ SIP REGISTER ¸Þ½ÃÁö¸¦ »ý¼ºÇÒ ¶§¿¡ »ç¿ëÇÏ´Â °æ¿ì true ·Î ¼³Á¤ÇÑ´Ù. */ bool m_bUseRegisterSession; /** UDP Àü¼Û/¼ö½Å ¹öÆÛ ÃÖ´ë Å©±â */ int m_iUdpBufSize; }; #endif
#ifndef __PLAYLIST_PLAYER__HOD #define __PLAYLIST_PLAYER__HOD #include <playlist/playlist.h> #include <audio/audio.h> #define PLAYLIST_PLAYER_MAX_PRESETS 12 typedef enum { PLAYLIST_PLAYER_STOPPED, PLAYLIST_PLAYER_PLAYING, PLAYLIST_PLAYER_PAUSED, } playlist_player_state_t; typedef enum { PLP_CMD_DESTROY = 0, PLP_CMD_PLAY = 1, PLP_CMD_PAUSE = 2, PLP_CMD_SET_TRACK = 3, PLP_CMD_SEEK = 4, PLP_CMD_NEXT = 5, PLP_CMD_PREVIOUS = 6, PLP_CMD_RESTART_TRACK = 7, PLP_CMD_NO_REPEAT = 8, PLP_CMD_TRACK_REPEAT = 9, PLP_CMD_LIST_REPEAT = 10, PLP_CMD_SET_PLAYLIST = 11, PLP_CMD_SET_VOLUME = 14, PLP_CMD_NONE = 20 } playlist_player_cmd_enum; typedef enum { PLP_NO_REPEAT = 0, PLP_REPEAT_OFF = 0, PLP_TRACK_REPEAT = 1, PLP_LIST_REPEAT = 2 } playlist_player_repeat_t; typedef struct { playlist_player_cmd_enum cmd; void* data; } playlist_player_cmd_t; DECLARE_FIFO(playlist_player_command_fifo, playlist_player_cmd_t); typedef struct { audio_worker_t* worker; playlist_t* playlist; playlist_player_command_fifo* player_control; int current_track; long current_position_in_ms; long track_position_in_ms; long preset_positions_in_ms[PLAYLIST_PLAYER_MAX_PRESETS]; el_bool track_changed; playlist_player_state_t player_state; playlist_player_repeat_t repeat; double volume_percentage; long long playlist_hash; pthread_mutex_t *mutex; pthread_t playlist_player_thread; } playlist_player_t; playlist_player_t *playlist_player_new(void); void playlist_player_destroy(playlist_player_t* plp); void playlist_player_set_playlist(playlist_player_t* player, playlist_t* playlist); void playlist_player_play(playlist_player_t* player); void playlist_player_pause(playlist_player_t* player); void playlist_player_set_track(playlist_player_t* player, int track); void playlist_player_next(playlist_player_t* player); void playlist_player_previous(playlist_player_t* player); void playlist_player_again(playlist_player_t* player); void playlist_player_seek(playlist_player_t* player, long position_in_ms); void playlist_player_set_repeat(playlist_player_t* player, playlist_player_repeat_t repeat); void playlist_player_set_preset(playlist_player_t* player, int preset_number); void playlist_player_clear_preset(playlist_player_t* player, int preset_number); void playlist_player_seek_preset(playlist_player_t* plp, int preset_number); el_bool playlist_player_preset_set(playlist_player_t* player, int preset_number); int playlist_player_get_track_index(playlist_player_t* player); track_t* playlist_player_get_track(playlist_player_t* player); long playlist_player_get_current_position_in_ms(playlist_player_t* player); long playlist_player_get_track_position_in_ms(playlist_player_t* player); long long playlist_player_get_hash(playlist_player_t* player); el_bool playlist_player_get_track_changed(playlist_player_t* player); playlist_t* playlist_player_get_playlist(playlist_player_t* player); el_bool playlist_player_is_playing(playlist_player_t* plp); el_bool playlist_player_is_paused(playlist_player_t* plp); el_bool playlist_player_does_nothing(playlist_player_t* plp); playlist_player_repeat_t playlist_player_get_repeat(playlist_player_t* plp); double playlist_player_get_volume(playlist_player_t* plp); void playlist_player_set_volume(playlist_player_t* plp, double percentage); #endif
#include "bwa.h" #include "bwamem.h" #include "bntseq.h" #include "kstring.h" /*************************** * SMEM iterator interface * ***************************/ struct __smem_i { const bwt_t *bwt; const uint8_t *query; int start, len; bwtintv_v *matches; // matches; to be returned by smem_next() bwtintv_v *sub; // sub-matches inside the longest match; temporary bwtintv_v *tmpvec[2]; // temporary arrays }; smem_i *smem_itr_init(const bwt_t *bwt) { smem_i *itr; itr = calloc(1, sizeof(smem_i)); itr->bwt = bwt; itr->tmpvec[0] = calloc(1, sizeof(bwtintv_v)); itr->tmpvec[1] = calloc(1, sizeof(bwtintv_v)); itr->matches = calloc(1, sizeof(bwtintv_v)); itr->sub = calloc(1, sizeof(bwtintv_v)); return itr; } void smem_itr_destroy(smem_i *itr) { free(itr->tmpvec[0]->a); free(itr->tmpvec[0]); free(itr->tmpvec[1]->a); free(itr->tmpvec[1]); free(itr->matches->a); free(itr->matches); free(itr->sub->a); free(itr->sub); free(itr); } void smem_set_query(smem_i *itr, int len, const uint8_t *query) { itr->query = query; itr->start = 0; itr->len = len; } const bwtintv_v *smem_next(smem_i *itr) { int i, max, max_i, ori_start; itr->tmpvec[0]->n = itr->tmpvec[1]->n = itr->matches->n = itr->sub->n = 0; if (itr->start >= itr->len || itr->start < 0) return 0; while (itr->start < itr->len && itr->query[itr->start] > 3) ++itr->start; // skip ambiguous bases if (itr->start == itr->len) return 0; ori_start = itr->start; itr->start = bwt_smem1(itr->bwt, itr->len, itr->query, ori_start, 1, itr->matches, itr->tmpvec); // search for SMEM if (itr->matches->n == 0) return itr->matches; // well, in theory, we should never come here for (i = max = 0, max_i = 0; i < itr->matches->n; ++i) { // look for the longest match bwtintv_t *p = &itr->matches->a[i]; int len = (uint32_t)p->info - (p->info>>32); if (max < len) max = len, max_i = i; } return itr->matches; } /*********************** *** Extra functions *** ***********************/ mem_alnreg_v mem_align1(const mem_opt_t *opt, const bwt_t *bwt, const bntseq_t *bns, const uint8_t *pac, int l_seq, const char *seq_) { // the difference from mem_align1_core() is that this routine: 1) calls mem_mark_primary_se(); 2) does not modify the input sequence extern mem_alnreg_v mem_align1_core(const mem_opt_t *opt, const bwt_t *bwt, const bntseq_t *bns, const uint8_t *pac, int l_seq, char *seq); extern void mem_mark_primary_se(const mem_opt_t *opt, int n, mem_alnreg_t *a, int64_t id); mem_alnreg_v ar; char *seq; seq = malloc(l_seq); memcpy(seq, seq_, l_seq); // makes a copy of seq_ ar = mem_align1_core(opt, bwt, bns, pac, l_seq, seq); mem_mark_primary_se(opt, ar.n, ar.a, lrand48()); free(seq); return ar; } void mem_reg2ovlp(const mem_opt_t *opt, const bntseq_t *bns, const uint8_t *pac, bseq1_t *s, mem_alnreg_v *a) { int i; kstring_t str = {0,0,0}; for (i = 0; i < a->n; ++i) { const mem_alnreg_t *p = &a->a[i]; int is_rev, rid, qb = p->qb, qe = p->qe; int64_t pos, rb = p->rb, re = p->re; pos = bns_depos(bns, rb < bns->l_pac? rb : re - 1, &is_rev); rid = bns_pos2rid(bns, pos); assert(rid == p->rid); pos -= bns->anns[rid].offset; kputs(s->name, &str); kputc('\t', &str); kputw(s->l_seq, &str); kputc('\t', &str); if (is_rev) qb ^= qe, qe ^= qb, qb ^= qe; // swap kputw(qb, &str); kputc('\t', &str); kputw(qe, &str); kputc('\t', &str); kputs(bns->anns[rid].name, &str); kputc('\t', &str); kputw(bns->anns[rid].len, &str); kputc('\t', &str); kputw(pos, &str); kputc('\t', &str); kputw(pos + (re - rb), &str); kputc('\t', &str); ksprintf(&str, "%.3f", (double)p->truesc / opt->a / (qe - qb > re - rb? qe - qb : re - rb)); kputc('\n', &str); } s->sam = str.s; }
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // // $NoKeywords: $ //============================================================================= #ifndef CL_DEMOSMOOTHING_H #define CL_DEMOSMOOTHING_H #ifdef _WIN32 #pragma once #endif #include "vector.h" #include "quakedef.h" #include "tier0/platform.h" #define FDEMO_NORMAL 0 #define FDEMO_USE_ORIGIN2 (1<<0) #define FDEMO_USE_ANGLES2 (1<<1) struct democmdinfo_t { // Default constructor democmdinfo_t() { flags = FDEMO_NORMAL; viewOrigin.Init(); viewAngles.Init(); localViewAngles.Init(); // Resampled origin/angles viewOrigin2.Init(); viewAngles2.Init(); localViewAngles2.Init(); } // Copy constructor // Assignment democmdinfo_t& operator=(const democmdinfo_t& src ) { if ( this == &src ) return *this; flags = src.flags; viewOrigin = src.viewOrigin; viewAngles = src.viewAngles; localViewAngles = src.localViewAngles; viewOrigin2 = src.viewOrigin2; viewAngles2 = src.viewAngles2; localViewAngles2 = src.localViewAngles2; return *this; } const Vector& GetViewOrigin() { if ( flags & FDEMO_USE_ORIGIN2 ) { return viewOrigin2; } return viewOrigin; } const QAngle& GetViewAngles() { if ( flags & FDEMO_USE_ANGLES2 ) { return viewAngles2; } return viewAngles; } const QAngle& GetLocalViewAngles() { if ( flags & FDEMO_USE_ANGLES2 ) { return localViewAngles2; } return localViewAngles; } void Reset( void ) { flags = 0; viewOrigin2 = viewOrigin; viewAngles2 = viewAngles; localViewAngles2 = localViewAngles; } int flags; Vector viewOrigin; QAngle viewAngles; QAngle localViewAngles; // Resampled origin/angles Vector viewOrigin2; QAngle viewAngles2; QAngle localViewAngles2; }; struct demosmoothing_t { demosmoothing_t() { file_offset = 0; framenumber = 0; frametime = 0; selected = false; samplepoint = false; vecmoved.Init(); angmoved.Init(); targetpoint = false; vectarget.Init(); } demosmoothing_t& operator=(const demosmoothing_t& src ) { if ( this == &src ) return *this; file_offset = src.file_offset; framenumber = src.framenumber; frametime = src.frametime; selected = src.selected; samplepoint = src.samplepoint; vecmoved = src.vecmoved; angmoved = src.angmoved; targetpoint = src.targetpoint; vectarget = src.vectarget; info = src.info; return *this; } int file_offset; int framenumber; float frametime; bool selected; // For moved sample points bool samplepoint; Vector vecmoved; QAngle angmoved; bool targetpoint; Vector vectarget; democmdinfo_t info; }; struct CSmoothingContext { CSmoothingContext() { active = false; filename[ 0 ] = 0; } CSmoothingContext& operator=(const CSmoothingContext& src ) { if ( this == &src ) return *this; active = src.active; strcpy( filename, src.filename ); smooth.RemoveAll(); int c = src.smooth.Count(); int i; for ( i = 0; i < c; i++ ) { demosmoothing_t newitem; newitem = src.smooth[ i ]; smooth.AddToTail( newitem ); } return *this; } bool active; char filename[ MAX_OSPATH ]; CUtlVector< demosmoothing_t > smooth; }; #endif // CL_DEMOSMOOTHING_H
semaphore rmutex = 1; semaphore wmutex = 1; int readcount = 0; void reader() { while(1) { P(rmutex); readcount++; if(readcount == 0) P(wmutex); V(rmutex); read_data_base(); P(rmutex); readcount--; if(readcount == 0) V(wmutex); V(rmutex); use_dataread(); } } void writer() { while(1) { think_up_data(); P(wmutex); write_data_base(); V(wmutex); } }
#include <avr/io.h> #include <avr/pgmspace.h> #include <stdint.h> #include <util/delay.h> #include <stdio.h> #include <stdlib.h> #include "sprite.h" #include "lcd.h" #include "graphics.h" #include "cpu_speed.h" #define BUFF_LENGTH 20 // define some macros #define BAUD 9600 // define baud rate #define BAUDRATE ((F_CPU)/(BAUD*16UL)-1) //function declaration void uart_transmit(unsigned char data); unsigned char uart_receive(void); void init_hardware(void); void uart_init(void); // Basic command interpreter for controlling port pins int main(void) { // the buffer to store received characters unsigned char rcv; //set clock speed to 8MhZ set_clock_speed(CPU_8MHz); //initialise LCD and ports init_hardware(); clear_screen(); //display a message on the screen draw_string(5,5, "UART serial demo"); show_screen(); // main loop while (1) { //detect button pressed if ((PINF>>PINF5)&1){ clear_screen(); draw_string(0,10, "Button 3 pressed"); draw_string(0,20, "Sending 'a' "); uart_transmit('a'); show_screen(); } //detect button pressed if ((PINF>>PINF6)&1){ clear_screen(); draw_string(0,10, "Button 2 pressed"); draw_string(0,20, "Sending 'b' "); uart_transmit('b'); show_screen(); } //receive character rcv = uart_receive(); //draw received character draw_string(0,30, "rx:"); draw_char(0,38, rcv); show_screen(); _delay_ms(10); } return 0; } //initialise ports and LCD screen void init_hardware() { DDRB |= (1<<PINB2)|(1<<PINB3); //LED0 and LED1 as outputs DDRF &= ~((1<<PINF5)|(1<<PINF6)); //Switch0 and Switch1 as input PORTB = 0xF0; // Turn everything off to start with lcd_init( LCD_DEFAULT_CONTRAST ); clear_screen(); show_screen(); // Initialise the USB serial uart_init(); } //initialise the uart void uart_init(void) { //UBRRH = (BAUDRATE>>8); // shift the register right by 8 bits UBRR1 = BAUDRATE; // set baud rate UCSR1B|= (1<<TXEN1)|(1<<RXEN1); // enable receiver and transmitter UCSR1C|= (1<<UCSZ10)|(1<<UCSZ11); // 8bit data format } void uart_transmit(unsigned char data){ while (!(( UCSR1A >> UDRE1) & 1)); // wait while register is free UDR1 = data; } unsigned char uart_receive(void){ while(!(UCSR1A) & (1<<RXC1)); // wait while data is being received return UDR1; }
#pragma once #include "math.h" #include "CVector3.h" #include "CRay3.h" namespace Math { class CPlane3 { public: double dDistance; CVector3 vNormal; //! Default constructor inline CPlane3 () { dDistance = 0.0; } //! Constructor with components inline CPlane3 (double dNewDistance, CVector3 vNewNormal) { dDistance = dNewDistance; vNormal = vNewNormal; } //! Copy constructor inline CPlane3 (const CPlane3& Target) { *this = Target; } //! Equality operator inline bool operator == (const CPlane3& V2) const { return (dDistance == V2.dDistance) && (vNormal == V2.vNormal); } //! Inequality operator inline bool operator != (const CPlane3& V2) const { return !(*this == V2); } //! Assign operator inline CPlane3& operator = (const CPlane3& Target) { dDistance = Target.dDistance; vNormal = Target.vNormal; return *this; } //! Distance d'intersection avec un rayon, valide si > 0 inline RayTracingResult intersect(const CRay3& rRay) { // Find t. double t = - (vNormal.dot(rRay.vOrigin) + dDistance) / (vNormal.dot(rRay.vNormal)); if (t < 0) // the ray does not hit the surface, that is, the surface is "behind" the ray return 0; // Get a point on the plane. CVector3 p = rRay.vOrigin + rRay.vNormal * t; // Does the ray intersect the plane inside or outside? CVector3 planeToRayStart = rRay.vOrigin - p; double dot = planeToRayStart.dot(vNormal); if (dot <= 0) return 0; return RayTracingResult(t, nullptr, vNormal); } //! Normalisation inline void normalize() { vNormal = vNormal.normalized(); } }; }
/* Copyright (C) 2016 Thomas Mijieux This file is part of libtomtix. libtomtix is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. libtomtix is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Foobar. If not, see <http://www.gnu.org/licenses/>. */ #include <glib.h> #include "tomtix/heap.h" struct t_heap_ { int (*compare)(void*, void*); unsigned size; void **buf; }; t_heap * t_heap_new(unsigned size, int (*compare)(void*, void*)) { t_heap *h = g_malloc0(sizeof*h); h->compare = compare; h->size = 0; h->buf = g_malloc0(sizeof*h->buf * (size + 1)); return h; } void t_heap_delete(t_heap *h) { g_free(h->buf); g_free(h); } #define GREATER_CHILD(h, i) \ ((2*(i) == (h)->size) ? \ (2*(i)) : \ ((h->compare(h->buf[2*i], h->buf[2*i+1]) > 0) ? \ (2*(i)) : \ (2*(i)+1))) #define HEAP_SWAP(h, i, k) \ do { \ void *tmp_M; \ tmp_M = (h)->buf[(i)]; \ (h)->buf[(i)] = (h)->buf[(k)]; \ (h)->buf[(k)] = tmp_M; \ } while(0) #define EXTRACT_PROBLEM(h, i) \ ((2*(i) == (h)->size && \ (h)->compare((h)->buf[2*(i)], (h)->buf[(i)]) > 0) || \ (2*(i)+1 <= (h)->size && \ ((h)->compare((h)->buf[2*(i)], (h)->buf[(i)]) > 0 || \ (h)->compare((h)->buf[2*(i)+1], (h)->buf[(i)]) > 0))) static inline unsigned extract_resolve(t_heap *h, unsigned i) { unsigned k = GREATER_CHILD(h, i); HEAP_SWAP(h, i, k); return k; } void *t_heap_extract_max(t_heap *heap) { void *max = heap->buf[0]; heap->buf[0] = heap->buf[--heap->size]; for( unsigned i = 0; EXTRACT_PROBLEM(heap, i); i = extract_resolve(heap, i)) { } return max; } void *t_heap_max(t_heap const *heap) { return heap->buf[0]; } #define INSERT_PROBLEM(h, i) ((h)->compare((h)->buf[(i)], (h)->buf[(i)/2]) > 0) void t_heap_insert(t_heap *h, void *k) { unsigned i = h->size ++; h->buf[i] = k; while (INSERT_PROBLEM(h, i)) { HEAP_SWAP(h, i, i/2); i /= 2; } } unsigned heap_size(t_heap const *heap) { return heap->size; }
#pragma once #include <Scene.h> #include <Collider.h> #include <Renderer.h> #include <ResourceManager.h> #include <cameras/TopDownCamera.h> #include <map/Direction.h> #include <components/HealthComponent.h> #include "Room.h" class HudRenderer; class HallwayRoom : public Room { public: HallwayRoom(bool includeObstacle); ~HallwayRoom(); void loadGameObjects() override ; private: bool includeObstacle; void addCrates(chag::float3 centerPosition) const; std::shared_ptr<GameObject> getCrateObject() const; std::shared_ptr<GameObject> getEnemyObject(std::function<void(std::weak_ptr<GameObject>, std::shared_ptr<Texture>)> spawnBullet, std::vector<std::shared_ptr<GameObject>> playerObject, HudRenderer *hudRenderer, chag::float3 location); void loadRevivePoint(chag::float3 locationOrigin); void randomlyGenerateObjectAtPos(chag::float3 location); };
#ifndef DRILL_NET_SOCKET_H_ #define DRILL_NET_SOCKET_H_ #include <drill/net/addr_inet.h> #include <string> struct tcp_info; namespace drill { namespace net { class Socket { public: Socket(bool own = false); ~Socket(); bool connect( AddrInet& addr) ; bool bind( AddrInet& addr) ; bool listen(int backlog = 5); int accept(AddrInet& peeraddr); void shutdown(); void close(); void setFd(int socketHandle); int getFd(); int write(const void *data, int len); int read(void *data, int len); bool setKeepAlive(bool on) { return setIntOption(SO_KEEPALIVE, on ? 1 : 0); } bool setReuseAddress(bool on) { return setIntOption(SO_REUSEADDR, on ? 1 : 0); } /* * setSoLinger */ bool setSoLinger (bool doLinger, int seconds); /* * setTcpNoDelay */ bool setTcpNoDelay(bool noDelay); /* * setTcpQuickAck */ bool setTcpQuickAck(bool quickAck); /* * setIntOption */ bool setIntOption(int option, int value); /* * setTimeOption */ bool setTimeOption(int option, int milliseconds); /* * if blocked */ bool setSoBlocking(bool on =false); /* * check if socket be created */ bool checkSocketHandle(); bool getTcpInfo(struct tcp_info*) const; bool getTcpInfoString(char* buf, int len) const; /* * get socket error */ int getSoError(); int _savedErr; protected: int _socketHandle; // socket description bool _own; }; } } #endif /*SOCKET_H_*/
/* STM32F1 Test of timer IRQ LED is blinked in timer ISR. Timer is disabled in IRQ, then re-enabled after a poll loop. Uses the update interrupt. Tests: Timer Interrupt. GPIO basic output The board used is the stm32f4-discovery with LEDs on port D pins 12-15 */ /* * This file is part of the libopencm3 project. * * Copyright (C) 2010 Thomas Otto <tommi@viadmin.org> * * This library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this library. If not, see <http://www.gnu.org/licenses/>. */ #include <libopencm3/stm32/rcc.h> #include <libopencm3/stm32/flash.h> #include <libopencm3/stm32/gpio.h> #include <libopencm3/stm32/timer.h> #include <libopencm3/cm3/nvic.h> /*--------------------------------------------------------------------*/ void clock_setup(void) { rcc_clock_setup_hse_3v3(&hse_8mhz_3v3[CLOCK_3V3_168MHZ]); } /*--------------------------------------------------------------------*/ void gpio_setup(void) { /* Port C are on AHB1 */ rcc_periph_clock_enable(RCC_GPIOC); /* Digital Test output PC1 */ gpio_mode_setup(GPIOC, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, GPIO0 | GPIO1); gpio_set_output_options(GPIOC, GPIO_OTYPE_PP, GPIO_OSPEED_2MHZ, GPIO0 | GPIO1); /* Signal output PD */ rcc_periph_clock_enable(RCC_GPIOD); gpio_mode_setup(GPIOD, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, GPIO12 | GPIO13 | GPIO14 | GPIO15); gpio_set_output_options(GPIOD, GPIO_OTYPE_PP, GPIO_OSPEED_2MHZ, GPIO12 | GPIO13 | GPIO14 | GPIO15); } /*--------------------------------------------------------------------*/ void timer_setup(void) { rcc_periph_clock_enable(RCC_TIM2); nvic_enable_irq(NVIC_TIM2_IRQ); nvic_set_priority(NVIC_TIM2_IRQ, 1); timer_reset(TIM2); /* Timer global mode: - Divider 4, Alignment edge, Direction up */ timer_set_mode(TIM2, TIM_CR1_CKD_CK_INT, TIM_CR1_CMS_EDGE, TIM_CR1_DIR_UP); timer_continuous_mode(TIM2); /* Set timer prescaler. 72MHz/1440 => 50000 counts per second. */ timer_set_prescaler(TIM2, 1440); /* End timer value. If this is reached an interrupt is generated. */ timer_set_period(TIM2, 5000); /* Update interrupt enable. */ timer_enable_irq(TIM2, TIM_DIER_UIE); /* Start timer. */ timer_enable_counter(TIM2); } /*--------------------------------------------------------------------*/ void tim2_isr(void) { gpio_toggle(GPIOD, GPIO12); /* LED2 on/off. */ if (timer_get_flag(TIM2, TIM_SR_UIF)) timer_clear_flag(TIM2, TIM_SR_UIF); /* Clear interrrupt flag. */ timer_get_flag(TIM2, TIM_SR_UIF); /* Reread to force the previous (buffered) write before leaving */ timer_disable_irq(TIM2, TIM_DIER_UIE); timer_disable_counter(TIM2); } /*--------------------------------------------------------------------*/ int main(void) { clock_setup(); gpio_setup(); timer_setup(); while (1) /* Halt. */ { /* Update interrupt enable. */ timer_enable_irq(TIM2, TIM_DIER_UIE); /* Start timer. */ timer_enable_counter(TIM2); gpio_toggle(GPIOD, GPIO13); /* LED on/off */ int i; for (i = 0; i < 6400000; i++) /* Wait a bit. */ __asm__("nop"); } return 0; }
#pragma once #include <string> #include <unordered_map> #include <functional> #include <boost/property_tree/ptree.hpp> #include "Scene.h" #include "Material.h" #include "Vec3.h" typedef std::function<std::shared_ptr<Material>(boost::property_tree::ptree&)> MaterialLoader; typedef std::function<std::shared_ptr<Hitable>(boost::property_tree::ptree&)> HitableLoader; class SceneLoader { public: static SceneLoader& get(); std::shared_ptr<Scene> load(const std::string& path); private: std::unordered_map< std::string, std::shared_ptr<Material> > m_materials; std::unordered_map<std::string, MaterialLoader> m_materialLoaders; std::unordered_map<std::string, HitableLoader> m_hitableLoaders; SceneLoader(); std::shared_ptr<Material> loadDiffuseBSDF(boost::property_tree::ptree& root); std::shared_ptr<Material> loadGlossyBSDF(boost::property_tree::ptree& root); std::shared_ptr<Material> loadGlassBSDF(boost::property_tree::ptree& root); std::shared_ptr<Hitable> loadSphere(boost::property_tree::ptree& root); Vec3 loadVec3(boost::property_tree::ptree& root); };
#ifndef INCLUDE_DRIVER_GRIDSEED_H #define INCLUDE_DRIVER_GRIDSEED_H #ifdef USE_GRIDSEED #include "util.h" #define GRIDSEED_MINER_THREADS 1 #define GRIDSEED_LATENCY 4 #define GRIDSEED_DEFAULT_BAUD 115200 #define GRIDSEED_DEFAULT_FREQUENCY "600" #define GRIDSEED_DEFAULT_CHIPS 5 #define GRIDSEED_DEFAULT_MODULES 1 #define GRIDSEED_DEFAULT_USEFIFO 0 #define GRIDSEED_DEFAULT_BTCORE 16 #define GRIDSEED_COMMAND_DELAY 20 #define GRIDSEED_READ_SIZE 12 #define GRIDSEED_MCU_QUEUE_LEN 8 #define GRIDSEED_SOFT_QUEUE_LEN (GRIDSEED_MCU_QUEUE_LEN+2) #define GRIDSEED_READBUF_SIZE 8192 #define GRIDSEED_PROXY_PORT 3350 #define transfer(gridseed, request_type, bRequest, wValue, wIndex, cmd) \ _transfer(gridseed, request_type, bRequest, wValue, wIndex, NULL, 0, cmd) #endif #endif /* INCLUDE_DRIVER_GRIDSEED_H */
/* * * Copyright 2017 Eero Talus * * This file is part of Open Image Pipeline. * * Open Image Pipeline is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Open Image Pipeline is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Open Image Pipeline. If not, see <http://www.gnu.org/licenses/>. * */ #ifndef INCLUDED_CACHE #define INCLUDED_CACHE #include <stdlib.h> #include <time.h> #include "oipcore/ptrarray.h" typedef struct CACHE_FILE_STRUCT { char *fname; char *fpath; time_t tstamp; } CACHE_FILE; PTRARRAY_TYPE_DEF(CACHE_FILE); typedef struct CACHE_STRUCT { char *name; char *path; unsigned int max_files; PTRARRAY_TYPE(CACHE_FILE) *db; } CACHE; PTRARRAY_TYPE_DEF(CACHE); CACHE *cache_create(const char *cache_name); void cache_destroy(CACHE *cache, int del_files); int cache_setup(void); void cache_cleanup(int del_files); int cache_db_file_unreg(CACHE *cache, const char *fname); CACHE_FILE *cache_db_file_reg(CACHE *cache, const char *fname, unsigned int auto_rm); int cache_delete_file(CACHE *cache, const char *fname); int cache_has_file(const CACHE *cache, const char *fname); char *cache_get_path_to_file(const CACHE *cache, const char *fname); void cache_dump_all(void); void cache_dump(const CACHE *cache); CACHE *cache_get_by_name(const char *name); #endif
/** ****************************************************************************** * @file I2C/I2C_TwoBoards_ComPolling/Inc/main.h * @author MCD Application Team * @version V1.2.7 * @date 17-February-2017 * @brief Header for main.c module ****************************************************************************** * @attention * * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2> * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __MAIN_H #define __MAIN_H /* Includes ------------------------------------------------------------------*/ #include "stm32f4xx_hal.h" #include "stm32f4_discovery.h" /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ /* User can use this section to tailor I2Cx/I2Cx instance used and associated resources */ /* Definition for I2Cx clock resources */ #define I2Cx I2C1 #define I2Cx_CLK_ENABLE() __HAL_RCC_I2C1_CLK_ENABLE() #define I2Cx_SDA_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE() #define I2Cx_SCL_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE() #define I2Cx_FORCE_RESET() __HAL_RCC_I2C1_FORCE_RESET() #define I2Cx_RELEASE_RESET() __HAL_RCC_I2C1_RELEASE_RESET() /* Definition for I2Cx Pins */ #define I2Cx_SCL_PIN GPIO_PIN_6 #define I2Cx_SCL_GPIO_PORT GPIOB #define I2Cx_SCL_AF GPIO_AF4_I2C1 #define I2Cx_SDA_PIN GPIO_PIN_9 #define I2Cx_SDA_GPIO_PORT GPIOB #define I2Cx_SDA_AF GPIO_AF4_I2C1 /* Size of Transmission buffer */ #define TXBUFFERSIZE (COUNTOF(aTxBuffer) - 1) /* Size of Reception buffer */ #define RXBUFFERSIZE TXBUFFERSIZE /* Exported macro ------------------------------------------------------------*/ #define COUNTOF(__BUFFER__) (sizeof(__BUFFER__) / sizeof(*(__BUFFER__))) /* Exported functions ------------------------------------------------------- */ #endif /* __MAIN_H */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
/* * This file is part of the TVShows source code. * * TVShows is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * You should have received a copy of the GNU General Public License * along with TVShows. If not, see <http://www.gnu.org/licenses/>. */ @import Foundation; @import AFNetworking; @class RARBGSearchOperation; @interface RARBGClient : AFHTTPRequestOperationManager - (RARBGSearchOperation *)search:(NSString *)search; @end
#ifndef PENNY_BITS_H_ #define PENNY_BITS_H_ #pragma once #include <assert.h> #include <stdint.h> #include <penny/math.h> /* based on the second algorithm given here: * https://graphics.stanford.edu/~seander/bithacks.html#ReverseParallel * * Also see: * - http://corner.squareup.com/2013/07/reversing-bits-on-arm.html */ static inline uintmax_t reverse_bits_v(uintmax_t v, int_least8_t s) { // bit size; must be power of 2 assert(is_power_of_2(s)); uintmax_t mask = ~INTMAX_C(0); while ((s >>= 1) > 0) { mask ^= (mask << s); v = ((v >> s) & mask) | ((v << s) & ~mask); } return v; } #define reverse_bits(v) reverse_bits_v(v, sizeof(v) * CHAR_BIT) #endif
#include <ctype.h> #include "cw.h" int cw_stricmp(char const *a, char const *b) { for (;; a++, b++) { int d = tolower(*a) - tolower(*b); if (d != 0 || !*a) return d; } }
// This file is part of BOINC. // http://boinc.berkeley.edu // Copyright (C) 2008 University of California // // BOINC is free software; you can redistribute it and/or modify it // under the terms of the GNU Lesser General Public License // as published by the Free Software Foundation, // either version 3 of the License, or (at your option) any later version. // // BOINC is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. // See the GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with BOINC. If not, see <http://www.gnu.org/licenses/>. // flags determining what is written to standard out. // (errors go to stderr) // // NOTE: all writes to stdout should have an if (log_flags.*) {} around them. // #ifndef _CC_CONFIG_H_ #define _CC_CONFIG_H_ #include <vector> #include <string> #include "proxy_info.h" #include "coproc.h" class XML_PARSER; #define MAX_FILE_XFERS_PER_PROJECT 2 #define MAX_FILE_XFERS 8 // kind of arbitrary struct LOG_FLAGS { // If you add anything, you must add it to parse() and write() // on by default; intended for all users // bool file_xfer; // file transfer start and finish bool sched_ops; // interactions with schedulers bool task; // task start and finish // off by default; intended for developers and testers // bool app_msg_receive; // show shared-mem message from apps bool app_msg_send; // show shared-mem message to apps bool benchmark_debug; // debug CPU benchmarks bool checkpoint_debug; bool coproc_debug; // show coproc reserve/free and startup msgs bool cpu_sched; // preemption and resumption bool cpu_sched_debug; // explain scheduler decisions bool cpu_sched_status; // show what's running bool dcf_debug; // show changes to duration correction factors bool priority_debug; // info related to REC and scheduling priority bool file_xfer_debug; // show completion of FILE_XFER bool gui_rpc_debug; bool heartbeat_debug; bool http_debug; bool http_xfer_debug; bool mem_usage_debug; // memory usage bool network_status_debug; bool poll_debug; // show what polls are responding bool proxy_debug; bool rr_simulation; // results of RR sim bool rrsim_detail; // details of RR sim bool sched_op_debug; bool scrsave_debug; bool slot_debug; // allocation of slots bool state_debug; // print textual summary of CLIENT_STATE initially // and after each scheduler RPC and garbage collect // also show actions of garbage collector bool statefile_debug; // show when and why state file is written bool std_debug; // changes to short-term debt bool task_debug; // task start and control details, and when apps checkpoint bool time_debug; // changes in on_frac, active_frac, connected_frac bool trickle_debug; // show trickle messages bool unparsed_xml; // show unparsed XML lines bool work_fetch_debug; // work fetch policy bool notice_debug; LOG_FLAGS(); void init(); int parse(XML_PARSER&); void show(); int write(MIOFILE& out); }; struct EXCLUDE_GPU { std::string url; std::string type; // empty means all types std::string appname; // empty means all apps int device_num; // -1 means all instances int parse(XML_PARSER&); }; // if you add anything, you must add it to // defaults(), parse_options(), and write() // struct CONFIG { bool abort_jobs_on_exit; bool allow_multiple_clients; bool allow_remote_gui_rpc; std::vector<std::string> alt_platforms; std::string client_version_check_url; std::string client_download_url; COPROCS config_coprocs; char data_dir[256]; bool disallow_attach; bool dont_check_file_sizes; bool dont_contact_ref_site; std::vector<EXCLUDE_GPU> exclude_gpus; std::vector<std::string> exclusive_apps; std::vector<std::string> exclusive_gpu_apps; bool exit_after_finish; bool exit_before_start; bool exit_when_idle; bool fetch_minimal_work; std::string force_auth; bool http_1_0; int http_transfer_timeout_bps; int http_transfer_timeout; std::vector<int> ignore_ati_dev; std::vector<int> ignore_nvidia_dev; int max_file_xfers; int max_file_xfers_per_project; int max_stderr_file_size; int max_stdout_file_size; int max_tasks_reported; int ncpus; std::string network_test_url; bool no_alt_platform; bool no_gpus; bool no_info_fetch; bool no_priority_change; bool os_random_only; PROXY_INFO proxy_info; double rec_half_life; bool report_results_immediately; bool run_apps_manually; int save_stats_days; bool skip_cpu_benchmarks; bool simple_gui_only; double start_delay; bool stderr_head; bool suppress_net_info; bool unsigned_apps_ok; bool use_all_gpus; bool use_certs; bool use_certs_only; // overrides use_certs bool zero_debts; CONFIG(); void defaults(); int parse(FILE*); int parse(XML_PARSER&, LOG_FLAGS&); int parse_client(FILE*); int parse_options(XML_PARSER&); int parse_options_client(XML_PARSER&); int write(MIOFILE&, LOG_FLAGS&); void show(); }; #endif
/* utility/julian_add_hours.c */ /* ---------------------------------------------------- */ /* Freely available software: see Appaserver.org */ /* ---------------------------------------------------- */ #include <stdlib.h> #include <stdio.h> #include <string.h> #include "timlib.h" #include "julian.h" #include "piece.h" int main( int argc, char **argv ) { int hours_offset; int date_piece_offset; int time_piece_offset; char buffer[ 1024 ]; char date_buffer[ 128 ]; char time_buffer[ 128 ]; JULIAN *j; int delimiter; char append_time_character = {0}; if ( argc < 5 ) { fprintf( stderr, "Usage: %s hours_offset date_piece_offset time_piece_offset delimiter [append_time_character]\n", argv[ 0 ] ); exit( 1 ); } hours_offset = atoi( argv[ 1 ] ); date_piece_offset = atoi( argv[ 2 ] ); time_piece_offset = atoi( argv[ 3 ] ); delimiter = *argv[ 4 ]; if ( argc == 6 ) append_time_character = *argv[ 5 ]; while( get_line( buffer, stdin ) ) { if ( !*buffer ) continue; if ( !piece( date_buffer, delimiter, buffer, date_piece_offset ) ) { fprintf( stderr, "%s\n", buffer ); continue; } if ( !piece( time_buffer, delimiter, buffer, time_piece_offset ) ) { fprintf( stderr, "%s\n", buffer ); continue; } fprintf( stderr, "got date_buffer = [%s]\n", date_buffer ); fprintf( stderr, "got time_buffer = [%s]\n", time_buffer ); j = julian_yyyy_mm_dd_hhmm_new( date_buffer, time_buffer ); j->current = julian_increment_hours( j->current, hours_offset ); fprintf( stderr, "before buffer = [%s]\n", buffer ); piece_replace( buffer, delimiter, julian_display_yyyy_mm_dd( j->current ), date_piece_offset ); fprintf( stderr, "after buffer = [%s]\n", buffer ); if ( append_time_character ) { sprintf( time_buffer, "%s%c", julian_display_hhmm( j->current ), append_time_character ); } else { strcpy( time_buffer, julian_display_hhmm( j->current ) ); } piece_replace( buffer, delimiter, time_buffer, time_piece_offset ); printf( "%s\n", buffer ); julian_free( j ); } return 0; } /* main() */
#ifndef SETTINGSLOCKER_H #define SETTINGSLOCKER_H class QSettings; #include "global.h" #include <QMutex> class OLOLORD_EXPORT SettingsLocker { private: static QMutex mutex; private: QSettings * const S; public: explicit SettingsLocker(); ~SettingsLocker(); public: QSettings *operator ->() const; }; #endif // SETTINGSLOCKER_H
/* libpronghorn Block Range Library * Copyright (C) 2012 Department of Defence Australia * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ /** * \file block_range.c * \brief Library functions for block ranges */ #include <string.h> #include <errno.h> #include <prong_assert.h> #include "structures.pb-c.h" #include "block_range.h" /** * A unique ID to identify a block_range reference. * * It's just four bytes taken from /dev/urandom */ static const unsigned int BLOCK_RANGE_MAGIC = 0xFA044ABE; block_range_t block_range_init(const char *initial_values, unsigned int initial_values_size) { BlockRange temp = BLOCK_RANGE__INIT; BlockRange *b = (BlockRange *) g_malloc(sizeof(BlockRange)); memcpy(b, &temp, sizeof(BlockRange)); b->has_magic = 1; b->magic = BLOCK_RANGE_MAGIC; if (initial_values != NULL) { // We need to free unpacked_block_range using block_range__free_unpacked // Unfortunately this means we need to copy all the internal variables to our own structure BlockRange *unpacked_block_range = block_range__unpack(NULL, initial_values_size, (const unsigned char *) initial_values); if ((unpacked_block_range == NULL) || (unpacked_block_range->has_magic != 1) || (unpacked_block_range->magic != BLOCK_RANGE_MAGIC)) { block_range_close((block_range_t) b); errno = EINVAL; return NULL; } b->has_offset = unpacked_block_range->has_offset; b->offset = unpacked_block_range->offset; b->has_length = unpacked_block_range->has_length; b->length = unpacked_block_range->length; block_range__free_unpacked(unpacked_block_range, NULL); } return (block_range_t) b; } char *block_range_serialise(block_range_t _b, unsigned int *output_data_size) { prong_assert(_b != NULL); BlockRange *b = (BlockRange *) _b; prong_assert(b->magic == BLOCK_RANGE_MAGIC); *output_data_size = block_range__get_packed_size(b); char *buf = (char *) g_malloc(*output_data_size); block_range__pack(b, (unsigned char *) buf); return buf; } block_range_t block_range_clone(block_range_t _b) { unsigned int size; char *b_serialised = block_range_serialise(_b, &size); if (b_serialised == NULL) { return NULL; } block_range_t new_block_range = block_range_init(b_serialised, size); g_free(b_serialised); return new_block_range; } int block_range_set_range(block_range_t _b, unsigned long long position, unsigned long long length) { prong_assert(_b != NULL); prong_assert(length > 0); BlockRange *b = (BlockRange *) _b; prong_assert(b->magic == BLOCK_RANGE_MAGIC); b->has_offset = 1; b->offset = position; b->has_length = 1; b->length = length; return 0; } int block_range_get_range(block_range_t _b, unsigned long long *position, unsigned long long *length) { prong_assert(_b != NULL); BlockRange *b = (BlockRange *) _b; prong_assert(b->magic == BLOCK_RANGE_MAGIC); if (b->has_offset == 0) { // The values aren't populated return -1; } *position = b->offset; *length = b->length; return 0; } int block_range_close(block_range_t _b) { if (_b == NULL) { return -1; } BlockRange *b = (BlockRange *) _b; prong_assert(b->magic == BLOCK_RANGE_MAGIC); g_free(b); return 0; }
#pragma once #include "VM/Compiler/AST/ASTNode.h" namespace Compiler { class InvokeNativeNode : public ASTNode { public: void Accept(ASTVisitor &visitor) override { visitor.Visit(this); } }; }
#pragma once namespace minedotcpp { namespace common { enum cell_param { // State cell_states = 3, cell_state_empty = 0, cell_state_filled = 1, cell_state_wall = 2, // Flags cell_flags = 3 << 2, cell_flag_none = 0 << 2, cell_flag_has_mine = 1 << 2, cell_flag_doesnt_have_mine = 2 << 2, //cell_flag_not_sure = 3 << 2 }; inline cell_param operator | (cell_param a, cell_param b) { return static_cast<cell_param>(static_cast<int>(a) | static_cast<int>(b)); } inline cell_param operator & (cell_param a, cell_param b) { return static_cast<cell_param>(static_cast<int>(a) & static_cast<int>(b)); } inline cell_param operator ~ (cell_param a) { return static_cast<cell_param>(~static_cast<int>(a)); } } }
#ifndef GOAP_COMPARERSTATEMETER_H #define GOAP_COMPARERSTATEMETER_H #include "refcounter.h" #include "goap/istate.h" #include "planningstatemeter.h" #include "numericstatecomparer.h" #include "newptr.h" namespace goap { /** * Helper class for measuring the distance from a given state to the goal state. * This class must be overrided to implement valid measuring functions. */ class ComparerStateMeter : public PlanningStateMeter { IMPLEMENT_REFCOUNTER_PARENT(PlanningStateMeter) protected: IPlanningStateComparer::Ptr _comparer; public: typedef explicit_ptr<ComparerStateMeter> Ptr; typedef explicit_ptr<const ComparerStateMeter> CPtr; ComparerStateMeter() { } ComparerStateMeter(IState::CPtr goalState, IPlanningStateComparer::Ptr stateComparer = {}) : PlanningStateMeter(goalState) { comparer(stateComparer); } void comparer(IPlanningStateComparer::Ptr stateComparer = {}) { _comparer = stateComparer ? stateComparer : NumericStateComparer::singleton(); } float distance(IState::CPtr state) const override { return _comparer->distance(state, _goalState); } bool enough(IState::CPtr state) const override { return _comparer->enough(state, _goalState); } IPlanningStateComparer::Ptr comparer() { return _comparer; } }; } #endif // COMPARERSTATEMETER_H
#include <stdio.h> #include <stdlib.h> #include <stdint.h> #include <string.h> #include <unistd.h> #include <pthread.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <sys/mman.h> static const char hpet_name[] = "/dev/hpet"; static const size_t timer_value_offset = 0xF0; static volatile uint64_t *hpet_time_ptr = NULL; static int hpet_init() { int fd; void *ptr; fd = open(hpet_name, O_RDONLY); if (fd < 0) { fprintf(stderr, "hpet_init(): cannot open %s\n", hpet_name); return -1;; } ptr = mmap(0, 4 * 1024, PROT_READ, MAP_PRIVATE, fd, 0); if (ptr == MAP_FAILED) { fprintf(stderr, "hpet_init(): cannot mmap() HPET\n"); return -2; } hpet_time_ptr = (uint64_t *)((char *)ptr + timer_value_offset); return 0; } static uint64_t rdtscp(uint32_t *apic_id) { uint32_t a; uint32_t d; uint32_t c; uint64_t r; asm volatile ( "cpuid;" "rdtscp;" :"=a"(a), "=d"(d), "=c"(c) : :"rbx" ); r = (((uint64_t)d) << 32) | a; *apic_id = c; return r; } static void test1() { int i; uint64_t val[1000]; for (i = 0; i < 1000; ++i) { val[i] = (*hpet_time_ptr); } for (i = 1; i < 1000; ++i) { fprintf(stderr, "%016lX %ld\n", val[i], val[i] - val[i - 1]); } } static uint64_t v1 = 0; static uint64_t v2 = 0; static uint64_t w1 = 0; static uint64_t w2 = 0; static volatile int s = 0; static void *work1(void *ptr) { uint64_t v; while(!s) {} while(s) { v = (*hpet_time_ptr); if (v < v2) { ++w1; } v1 = v; } return NULL; } static void *work2(void *ptr) { uint64_t v; while(!s) {} while(s) { v = (*hpet_time_ptr); if (v < v1) { ++w2; } v2 = v; } return NULL; } static void test2() { int i; pthread_t t1; pthread_t t2; pthread_create(&t1, NULL, work1, NULL); pthread_create(&t2, NULL, work2, NULL); usleep(1000000); s = 1; for (i = 0; i < 100; ++i) { usleep(100000); fprintf(stderr, "w1 = %lu w2 = %lu\n", w1, w2); } } int main() { if (hpet_init()) { return 1; } test2(); return 0; }
/******************************************* Author : LHearen E-mail : LHearen@126.com Time : 2016-02-24 16:23 Description : Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x. You should preserve the original relative order of the nodes in each of the two partitions. For example, Given 1->4->3->2->5->2 and x = 3, return 1->2->2->4->3->5. Source : https://leetcode.com/problems/partition-list/ *******************************************/ struct ListNode { int val; struct ListNode *next; }; #include <stdlib.h> struct ListNode* partition(struct ListNode* head, int x) { if(!head) return NULL; struct ListNode *less = (struct ListNode*)malloc(sizeof(struct ListNode)); //used as head; struct ListNode *greater = (struct ListNode*)malloc(sizeof(struct ListNode)); struct ListNode *l=less, *g=greater; //used to track the chain for connecting; while(head) { if(head->val < x) { l->next = head; l = l->next; } else { g->next = head; g = g->next; } head = head->next; } g->next = NULL; l->next = greater->next; return less->next; }
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* s_string_add_string.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: qperez <qperez42@gmail.com> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2013/10/25 18:44:48 by qperez #+# #+# */ /* Updated: 2015/07/04 20:56:07 by qperez ### ########.fr */ /* */ /* ************************************************************************** */ /* ** <This file contains s_string_add_string function> ** < add_str, add_char > ** Copyright (C) <2013> Quentin Perez <qperez42@gmail.com> ** This file is part of 42-toolkit. ** 42-toolkit is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation, either version 3 of the License, or ** (at your option) any later version. ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** You should have received a copy of the GNU General Public License ** along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <string/s_string.h> #include <f_string/f_str_tools.h> #include <f_string/f_string.h> bool f_string_add_str(t_string *v_this, const char *str) { size_t size; size = uf_str_len(str); if (size == 0) return (true); size = size + 1; if (v_this->v_size + size > v_this->v_capacity && uf_string_realloc(v_this, size) == false) return (false); uf_strcat(v_this->v_str + v_this->v_size, str); v_this->v_size = v_this->v_size + size - 1; return (true); } bool f_string_add_char(t_string *v_this, unsigned char c) { if (v_this->v_size + 2 > v_this->v_capacity && uf_string_realloc(v_this, 2) == false) return (false); v_this->v_str[v_this->v_size] = (char)c; v_this->v_size = v_this->v_size + 1; v_this->v_str[v_this->v_size] = '\0'; return (true); } bool f_string_add_nstr(t_string *v_this, const char *str, size_t size) { if (size == 0) return (true); if (v_this->v_size + size + 1 > v_this->v_capacity && uf_string_realloc(v_this, size + 1) == false) return (false); uf_strncat(v_this->v_str + v_this->v_size, str, size); v_this->v_size = v_this->v_size + size; return (true); }
#define pr_fmt(fmt) "market ] " fmt #include <errno.h> #include <math.h> #include <string.h> #include <gtk/gtk.h> #include <ccutils/log.h> #include "geye/ge.h" #include "geye/calc.h" #include "geye/event.h" #include "geye/common.h" static GtkStyleContext *gcontext; enum { NC_CODE = 0, NC_PRICE, NC_DIFF, NC_DIFF_FG, NC_ROC, NC_NAME, NC_MPROC, NC_MPROC_FG, NC_END, }; static int g_market_timer_running = 0; static void market_window_set_active(GtkWidget *widget, int active) { if(active) gtk_window_set_keep_above(GTK_WINDOW(widget), TRUE); } int market_list_event_cb(GtkWidget *widget, GdkEvent *event, gpointer p) { // pr_info("%s, event type = %d\n", __func__, event->type); switch(event->type) { case GDK_FOCUS_CHANGE: if(gtk_window_is_active(GTK_WINDOW(widget))) { gtk_widget_hide(widget); market_window_set_active(widget, 0); } else market_window_set_active(widget, 1); break; case GDK_DELETE: g_market_timer_running = 0; break; } return FALSE; } void market_list_activate_default_cb(GtkWindow *win, gpointer p) { pr_info("%s\n", __func__); } static int market_netdata_update(struct golden_eye_2 *ge) { int rc; if(event_netdata_update(ge) < 0) { pr_err("netdata update fail\n"); return - EINVAL; } calc_realtime_info_v2(ge); calc_print_info(ge); return 0; } static void market_widget_clearset_color(GtkWidget *widget, GtkStyleProvider *provider, char *color) { const char *clsa[] = { "index_raise", "index_drop", }; int i; GtkStyleContext *context; context = gtk_widget_get_style_context(widget); for(i = 0; i < ARRAY_SIZE(clsa); i++) { if(gtk_style_context_has_class(context, clsa[i])) gtk_style_context_remove_class(context, clsa[i]); } geye_widget_add_class(widget, provider, color); } static void market_display_update_index(struct golden_eye_2 *ge) { struct ge_index *idx; struct ge_idxdat *idxd; char color[32]; char str[128]; const char *tpl = "<span foreground='%s'>%.2f</span>"; const char *tpl_p = "<span foreground='%s'>%.2f%</span>"; for(idx = ge->index_list.cqh_first; idx != (void *)&ge->index_list; idx = idx->list.cqe_next) { idxd = &idx->data; geye_roc_to_colorname(color, idxd->roc, "#bbb"); sprintf(str, tpl, color, idxd->index); gtk_label_set_markup(GTK_LABEL(ge->ui.market.sh.price), str); sprintf(str, tpl_p, color, idxd->roc); gtk_label_set_markup(GTK_LABEL(ge->ui.market.sh.roc), str); sprintf(str, tpl, color, idxd->diff); gtk_label_set_markup(GTK_LABEL(ge->ui.market.sh.diff), str); } } static void market_display_update(struct golden_eye_2 *ge) { struct ge_stock *stock; struct ge_stkdat *stkd; GtkTreeIter iter; char price_str[16], roc_str[16], diff_str[16], mproc_str[16]; char color[16]; market_display_update_index(ge); gtk_list_store_clear(GTK_LIST_STORE(ge->ui.market.lstore)); for(stock = ge->stock_list.cqh_first; stock != (void *)&ge->stock_list; stock = stock->list.cqe_next) { stkd = &stock->data; sprintf(price_str, "%.2f", stkd->price); sprintf(roc_str, "%.2f", fabsf(stock->roc * 100)); sprintf(diff_str, "%.2f", fabsf(stock->diff)); geye_roc_to_colorname(color, stock->roc, "#bbb"); gtk_list_store_append(GTK_LIST_STORE(ge->ui.market.lstore), &iter); gtk_list_store_set(GTK_LIST_STORE(ge->ui.market.lstore), &iter, 0, stock->code, 1, price_str, 2, diff_str, 3, color, 4, roc_str, NC_NAME, stkd->name, -1); } } static gboolean market_net_request(struct golden_eye_2 *ge) { int rc; rc = market_netdata_update(ge); if(rc < 0) return TRUE; if(!g_market_timer_running) { pr_info("window deleted, stop timer\n"); return FALSE; } market_display_update(ge); return TRUE; } static void market_ui_visual_setup(GtkWidget *win) { gtk_widget_set_app_paintable(win, TRUE); GdkScreen *screen = gdk_screen_get_default(); GdkVisual *visual = gdk_screen_get_rgba_visual(screen); if(visual && gdk_screen_is_composited(screen)) { gtk_widget_set_visual(win, visual); } } void market_ui_build(GtkApplication *app, struct golden_eye_2 *ge) { GtkBuilder *builder = gtk_builder_new_from_file("layout/market_list.glade"); GtkWidget *win = GTK_WIDGET(gtk_builder_get_object(builder, "market_list")); /* load css */ GtkStyleContext *context = gtk_widget_get_style_context(win); GtkStyleProvider *provider = (GtkStyleProvider *)gtk_css_provider_new(); gtk_css_provider_load_from_path(GTK_CSS_PROVIDER(provider), "res/styles.css", NULL); gtk_style_context_add_provider(context, provider, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); ge->ui.market.win = win; ge->ui.market.context = context; ge->ui.market.provider = provider; ge->ui.market.lstore = GTK_WIDGET(gtk_builder_get_object(builder, "market_index_liststore")); ge->ui.market.sh.price = GTK_WIDGET(gtk_builder_get_object(builder, "market_index_sh_price")); ge->ui.market.sh.roc = GTK_WIDGET(gtk_builder_get_object(builder, "market_index_sh_roc")); ge->ui.market.sh.diff = GTK_WIDGET(gtk_builder_get_object(builder, "market_index_sh_diff")); gtk_window_set_keep_below(GTK_WINDOW(win), TRUE); gtk_application_add_window(app, GTK_WINDOW(win)); gtk_builder_connect_signals(builder, NULL); g_object_unref(G_OBJECT(builder)); gtk_widget_show_all(win); } void market_ui_start(GtkApplication *app, struct golden_eye_2 *ge) { GtkWidget *win; pr_info("%s\n", __func__); market_ui_build(app, ge); g_market_timer_running = 1; g_timeout_add(20000, (GSourceFunc)market_net_request, ge); market_net_request(ge); }
#include <stdio.h> #include <stdlib.h> #include "../aquaPicBus.h" void apbMessageHandler(void); struct apbObjStruct apbInstStruct; apbObj apbInst = &apbInstStruct; #define NUM_CHANNELS 4 uint16_t ct[] = {0x1122, 0x3344, 0x5566, 0x7788}; int main(int argc, char** argv) { int i; apb_init (apbInst, &apbMessageHandler, 0x01, 5, NULL, 0); apb_framing(apbInst); apb_framing(apbInst); { uint8_t message[] = {1, 10, 6, 1, 0, 0}; uint8_t crc[2]; apb_crc16(message, crc, 6); message[4] = crc[0]; message[5] = crc[1]; printf("Receiving message "); for (i = 0; i < 6; ++i) { printf("0x%02x ", message[i]); apb_run(apbInst, message[i]); } } { uint8_t message[] = {1, 10, 8, 1, 0x44, 0x33, 0, 0}; uint8_t crc[2]; apb_crc16(message, crc, 8); message[6] = crc[0]; message[7] = crc[1]; printf("Expected message "); for (i = 0; i < 8; ++i) { printf("0x%02x ", message[i]); apb_run(apbInst, message[i]); } printf("\n"); } apb_framing(apbInst); apb_framing(apbInst); { uint8_t message[] = {1, 1, 5, 0, 0}; uint8_t crc[2]; apb_crc16(message, crc, 5); message[3] = crc[0]; message[4] = crc[1]; printf("Receiving message "); for (i = 0; i < 5; ++i) { printf("0x%02x ", message[i]); apb_run(apbInst, message[i]); } } { uint8_t message[] = {1, 1, 5, 0, 0}; uint8_t crc[2]; apb_crc16(message, crc, 5); message[3] = crc[0]; message[4] = crc[1]; printf("Expected message "); for (i = 0; i < 5; ++i) { printf("0x%02x ", message[i]); apb_run(apbInst, message[i]); } printf("\n"); } return (EXIT_SUCCESS); } void apbMessageHandler(void) { printf("\n"); switch (apbInst->function) { case 10: { //read single channel value uint8_t channel = apbInst->message[3]; uint16_t value = ct[channel]; apb_initResponse(apbInst); apb_appendToResponse(apbInst, channel); apb_addToResponse(apbInst, &value, sizeof(uint16_t)); apb_sendResponse(apbInst); break; } case 1: { apb_sendDefualtResponse(apbInst); break; } default: break; } }
#ifndef CHESSY_PERFT_H #define CHESSY_PERFT_H #include "move.h" #include "board.h" uint64_t perft(int, struct CBoard *, int, int); int run_all_tests(); #endif //CHESSY_PERFT_H
/* Copyright 2016 Alexander Melnyk / Олександр Мельник * * This file is part of brickfuck package. * * brickfuck is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) * any later version. * * brickfuck is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License along with * brickfuck. If not, see <http://www.gnu.org/licenses/>. */ #include <stdio.h> #include <errno.h> #include <string.h> #include <stdlib.h> #include <sys/stat.h> #include "brickfuck.h" extern int errno; int main(int argc, char *argv[]){ FILE *source; struct stat filstat; char *bf_code; if(argc <= 1){ puts("Specify brainfuck source file."); } else { source = fopen(argv[1], "r"); if(!source){ /* This is for nice error reporting: 'brainfuck: <file>: <error>' */ char err_info[strlen("brickfuck: ") + 1 + strlen(argv[1]) + 1]; strcpy(err_info, "brickfuck: "); strcat(err_info, argv[1]); perror(err_info); } else { /* File size is given to strip_source so we can be sure there will be * enough memory even if there are no non-bf characters in file, but not * so much it would be undoubtedly wasted. */ fstat(fileno(source), &filstat); bf_code = strip_source(source, filstat.st_size); fclose(source); /* File is not needed anymore at this point */ interpret_brainfuck(bf_code); free(bf_code); } } return 0; } /* Takes a FILE pointer source and reads it into char array, stripping off * everything that is not a bf instruction. Char array starts off with a size * of 'lenght' (so do not give it super large files), but after stripping it * will be truncated so memory is used efficiently. * * length - length of the source file in chars. You can obtain this from fstat * or by other means. Do not fseek to end and ftell - standart does not support * that! * * Returns null terminated char array with stripped source that should be freed * by caller or NULL if length is 0 or less. If lenght is incorrect, returned * array may contain EOF. */ char * strip_source(FILE *source, long length){ char *buf = calloc(length, sizeof(char)); char *buf_iter = buf; char c; if(length <= 0){ return NULL; } for(int i = 0; i < length; i++){ c = getc(source); switch(c){ case '>': case '<': case '+': case '-': case '.': case ',': case '[': case ']': *buf_iter++ = c; } } long long result_length = buf_iter - buf + 1; /* Null terminated array */ buf = realloc(buf, result_length + 1); buf[result_length] = '\0'; return buf; } /* Interpreter itself. source - null-terminated array of char that should contain only valid bf instructions. */ void interpret_brainfuck(char *source){ if(!source){ return; } short bf_tape[30000] = {0}; short *bf_ptr = bf_tape; char *i = source; char *stack[1024] = {0}; /* Stack is needed for bracket loops. Supports */ char **stack_ptr = stack; /* up to 1024 nested loops like this. */ while(*i != '\0'){ switch(*i){ case '>': bf_ptr++; break; case '<': bf_ptr--; break; case '+': (*bf_ptr)++; break; case '-': (*bf_ptr)--; break; case '.': putchar(*bf_ptr); break; case ',': *bf_ptr = getchar(); if(*bf_ptr == EOF){ /* Sadly, different bf interpreters/compilers show different approaches * to EOF. That is, some treat 0 as EOF, some treat -1 as EOF, some are * even more crazy. So this clause is needed to fine-tune the * interpreter for different sources. */ *bf_ptr = -1; } break; case '[': /* Here the stack is used so interpreter can return to correct opening * bracket and a counter is used so interpreter returns from correct * closing bracket (and not from the first one it finds) */ if(!*bf_ptr){ int ctr = 0; while((*(++i) != ']') || (ctr != 0)) if(*i == '['){ ctr++; } else if (*i == ']'){ ctr--; } } else { *stack_ptr++ = i; } break; case ']': if(!*bf_ptr){ stack_ptr--; } else { /* No, this is not Python. This is pure awesomeness. */ i = stack_ptr[-1]; } break; default: puts("You should not see this. If you see this, the geese got loose " "(meaning, memory pointer is somewhere it's not supposed to be). " "Consider reporting a bug."); return; } i++; } }
/* FSCompiler.h Copyright (c) 1998-2009 Philippe Mougin. */ /* This software is open source. See the license. */ #import <Foundation/Foundation.h> #import "FSCompilationResult.h" @class FSSymbolTable, FSMethod; enum e_token_type { KW_FALSE, KW_TRUE, KW_NIL, KW_SUPER, OPEN_BRACKET, CLOSE_BRACKET, NAME, END, SNUMBER, SDATE, OPEN_PARENTHESE , CLOSE_PARENTHESE, COMMA, SEMICOLON, PERIOD, SSTRING, OPEN_BRACE, CLOSE_BRACE, OPERATOR, COLON , SASSIGNMENT, AT, COMPACT_BLOCK, PREDEFINED_OBJECT, CARET, DICTIONARY_BEGIN}; struct res_scan { enum e_token_type type; NSMutableString *value; }; @interface FSCompiler:NSObject { struct res_scan rs; // current result of the lexical parsing (scanning) __strong const char *string; // string to compile int32_t string_index; // in order to scan the string to compile int32_t token_first_char_index; // index in the string of the first character of the current token int32_t string_size; // size of the string to compile jmp_buf error_handler; NSString *errorStr; NSInteger errorFirstCharIndex; NSInteger errorLastCharIndex; } + compiler; + (FSMethod *)dummyDeallocMethodForClassNamed:(NSString *)className; + (BOOL)isValidIdentifier:(NSString *)str; + (NSString *)stringFromSelector:(SEL)selector; + (SEL)selectorFromString:(NSString *)selectorStr; - (void) dealloc; - init; - (FSCompilationResult *) compileCode:(const char *)utf8str withParentSymbolTable:(FSSymbolTable *)symbol_table; - (FSCompilationResult *) compileCodeForBlock:(const char *)utf8str withParentSymbolTable:(FSSymbolTable *)symbol_table; //- (CompilationResult *) compileCodeForMethod:(const char *)utf8strs; @end
/* ----------------------------------------------------------------------------- This source file is part of OGRE (Object-oriented Graphics Rendering Engine) For the latest info, see http://www.ogre3d.org/ Copyright (c) 2000-2014 Torus Knot Software Ltd 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 __NameGenerator_H__ #define __NameGenerator_H__ #include "OgreString.h" #if defined ( OGRE_GCC_VISIBILITY ) # pragma GCC visibility push(default) #endif #include <sstream> #if defined ( OGRE_GCC_VISIBILITY ) # pragma GCC visibility pop #endif #include "Threading/OgreThreadHeaders.h" namespace Ogre { /** \addtogroup Core * @{ */ /** \addtogroup General * @{ */ /// Utility class to generate a sequentially numbered series of names class _OgreExport NameGenerator { protected: String mPrefix; unsigned long long int mNext; OGRE_AUTO_MUTEX; public: NameGenerator(const NameGenerator& rhs) : mPrefix(rhs.mPrefix), mNext(rhs.mNext) {} NameGenerator(const String& prefix) : mPrefix(prefix), mNext(1) {} /// Generate a new name String generate() { OGRE_LOCK_AUTO_MUTEX; StringStream s; s << mPrefix << mNext++; return s.str(); } /// Reset the internal counter void reset() { OGRE_LOCK_AUTO_MUTEX; mNext = 1ULL; } /// Manually set the internal counter (use caution) void setNext(unsigned long long int val) { OGRE_LOCK_AUTO_MUTEX; mNext = val; } /// Get the internal counter unsigned long long int getNext() const { // lock even on get because 64-bit may not be atomic read OGRE_LOCK_AUTO_MUTEX; return mNext; } }; /** @} */ /** @} */ } #endif
/* ======================================================================== D O O M R e t r o The classic, refined DOOM source port. For Windows PC. ======================================================================== Copyright © 1993-2012 id Software LLC, a ZeniMax Media company. Copyright © 2013-2016 Brad Harding. DOOM Retro is a fork of Chocolate DOOM. For a list of credits, see the accompanying AUTHORS file. This file is part of DOOM Retro. DOOM Retro is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. DOOM Retro is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with DOOM Retro. If not, see <http://www.gnu.org/licenses/>. DOOM is a registered trademark of id Software LLC, a ZeniMax Media company, in the US and/or other countries and is used without permission. All other trademarks are the property of their respective holders. DOOM Retro is in no way affiliated with nor endorsed by id Software. ======================================================================== */ #if !defined(__V_VIDEO__) #define __V_VIDEO__ #include "r_data.h" // // VIDEO // fixed_t DX, DY, DXI, DYI; // Screen 0 is the screen updated by I_Update screen. // Screen 1 is an extra buffer. extern byte *screens[5]; extern byte redtoyellow[]; extern byte *tinttab20; extern byte *tinttab25; extern byte *tinttab33; extern byte *tinttab40; extern byte *tinttab50; extern byte *tinttab60; extern byte *tinttab66; extern byte *tinttab75; extern byte *tinttabred; // Allocates buffer screens, call before R_Init. void V_Init(void); void V_CopyRect(int srcx, int srcy, int srcscrn, int width, int height, int destx, int desty, int destscrn); void V_FillRect(int scrn, int x, int y, int width, int height, byte color); void V_FillTransRect(int x, int y, int width, int height, int color); void V_DrawPatch(int x, int y, int scrn, patch_t *patch); void V_DrawTranslucentPatch(int x, int y, int scrn, patch_t *patch); void V_DrawBigPatch(int x, int y, int scrn, patch_t *patch); void V_DrawConsoleChar(int x, int y, patch_t *patch, int color1, int color2, dboolean italics, byte *tinttab); void V_DrawShadowPatch(int x, int y, patch_t *patch); void V_DrawSolidShadowPatch(int x, int y, patch_t *patch); void V_DrawSpectreShadowPatch(int x, int y, patch_t *patch); dboolean V_EmptyPatch(patch_t *patch); void V_DrawPatchWithShadow(int x, int y, patch_t *patch, dboolean flag); void V_DrawFlippedPatch(int x, int y, patch_t *patch); void V_DrawFlippedShadowPatch(int x, int y, patch_t *patch); void V_DrawFlippedSolidShadowPatch(int x, int y, patch_t *patch); void V_DrawFlippedSpectreShadowPatch(int x, int y, patch_t *patch); void V_DrawCenteredPatch(int y, patch_t *patch); void V_DrawFuzzPatch(int x, int y, patch_t *patch); void V_DrawFlippedFuzzPatch(int x, int y, patch_t *patch); void V_DrawNoGreenPatchWithShadow(int x, int y, patch_t *patch); void V_DrawHUDPatch(int x, int y, patch_t *patch, byte *tinttab); void V_DrawYellowHUDPatch(int x, int y, patch_t *patch, byte *tinttab); void V_DrawHighlightedHUDNumberPatch(int x, int y, patch_t *patch, byte *tinttab); void V_DrawTranslucentHUDPatch(int x, int y, patch_t *patch, byte *tinttab); void V_DrawTranslucentHUDNumberPatch(int x, int y, patch_t *patch, byte *tinttab); void V_DrawTranslucentYellowHUDPatch(int x, int y, patch_t *patch, byte *tinttab); void V_DrawAltHUDPatch(int x, int y, patch_t *patch, int from, int to); void V_DrawTranslucentNoGreenPatch(int x, int y, patch_t *patch); void V_DrawTranslucentRedPatch(int x, int y, patch_t *patch); void V_DrawFlippedTranslucentRedPatch(int x, int y, patch_t *patch); void V_DrawPatchToTempScreen(int x, int y, patch_t *patch); void V_DrawPagePatch(patch_t *patch); void V_DrawPixel(int x, int y, byte color, dboolean shadow); void GetPixelSize(void); void V_LowGraphicDetail(int height); // Draw a linear block of pixels into the view buffer. void V_DrawBlock(int x, int y, int width, int height, byte *src); dboolean V_ScreenShot(void); void V_AverageColorInPatch(patch_t *patch, int *red, int *green, int *blue, int *total); #endif
#ifndef BUILTINLED_H #define BUILTINLED_H #include "Light.h" #define BUILTIN_LED_GPIO 2 template <const char* const name> class BuiltinLED : public Light<name, BUILTIN_LED_GPIO> { public: BuiltinLED(Device* device) : Light<name, BUILTIN_LED_GPIO>(device) { } }; #endif
/* * mainwindow.h * Copyright 2017 - ~, Apin <apin.klas@gmail.com> * * This file is part of Sultan. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation; either version 2 of the License, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License along with * this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef MAINWINDOW_H #define MAINWINDOW_H #include "messagehandler.h" #include "abstractsultangui.h" #include "gui_global.h" #include <QMainWindow> #include <QNetworkAccessManager> #include <QNetworkReply> namespace Ui { class MainWindow; } class QLabel; namespace LibG { class MessageBus; } namespace LibGUI { class StatusBarWidget; class Splash; class LoginDialog; class GUISHARED_EXPORT MainWindow : public QMainWindow, public LibG::MessageHandler, public LibG::AbstractSultanGUI { Q_OBJECT public: MainWindow(LibG::MessageBus *bus, QWidget *parent = nullptr); ~MainWindow(); void setup(); void showSplashScreen() override; void hideSplashScreen() override; void splashShowMessage(const QString &msg) override; void showSetting() override; void showMainWindow() override; void showRestartError(const QString &title, const QString &msg) override; void guiMessage(int id, const QString &str) override; void setSettingSocketOpenClose(std::function<void(const QString&, int)> openCon, std::function<void()> closeCon) override; protected: void closeEvent(QCloseEvent *event) override; void showEvent(QShowEvent *event) override; void messageReceived(LibG::Message *msg) override; private: Ui::MainWindow *ui; int mLastIdLogin = 0; StatusBarWidget *mStatusBar; Splash *mSplashUi; LoginDialog *mLoginDialog; QNetworkAccessManager mNam; void setupConnection(); private slots: void loginSuccess(); void logout(); void showWindowFullScreen(); void closeCurrentTab(); void nextTab(); void prevTab(); void openSetting(); void openUser(); void openSuplier(); void openCashier(); void openAbout(); void openCategory(); void openItem(); void openPurchase(); void openPurchaseItem(const QVariantMap &data); void openSalesReport(); void openItemReport(); void openChangePassword(); void openCustomer(); void openCustomerCredit(int id, const QString &number); void openCustomerReward(int id, const QString &number); void openMachine(); void openReward(); void openBank(); void openTransaction(); void openMoney(); void openAutoUpdate(); void openPurchaseReturn(); void openExportImport(); void openCheckStock(); void openInitialStock(); void openUnit(); void openDateSetting(); void resetDatabase(); void openStockCard(); void openSoldReturn(); void httpRequestDone(QNetworkReply *reply); }; } #endif // MAINWINDOW_H
/* # Copyright (C) 2005-2011 MaNGOS <http://www.getmangos.com/> * # Copyright (C) 2008-2011 Trinity <http://www.trinitycore.org/> * # Copyright (C) 2006-2011 ScriptDev2 <http://www.scriptdev2.com/> * # Copyright (C) 2010-2011 DarkmoonCore <http://www.darkmooncore.org/> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef DEF_CULLING_OF_STRATHOLME_H #define DEF_CULLING_OF_STRATHOLME_H enum Data { DATA_MEATHOOK_EVENT, DATA_SALRAMM_EVENT, DATA_EPOCH_EVENT, DATA_MAL_GANIS_EVENT, DATA_INFINITE_EVENT, DATA_ARTHAS_EVENT }; enum Data64 { DATA_ARTHAS, DATA_MEATHOOK, DATA_SALRAMM, DATA_EPOCH, DATA_MAL_GANIS, DATA_INFINITE, DATA_SHKAF_GATE, DATA_MAL_GANIS_GATE_1, DATA_MAL_GANIS_GATE_2, DATA_EXIT_GATE, DATA_MAL_GANIS_CHEST }; enum Creatures { NPC_MEATHOOK = 26529, NPC_SALRAMM = 26530, NPC_EPOCH = 26532, NPC_MAL_GANIS = 26533, NPC_INFINITE = 32273, NPC_ARTHAS = 26499, NPC_JAINA = 26497, NPC_UTHER = 26528 }; enum GameObjects { GO_SHKAF_GATE = 188686, GO_MALGANIS_GATE_1 = 187711, GO_MALGANIS_GATE_2 = 187723, GO_EXIT_GATE = 191788, GO_MALGANIS_CHEST_N = 190663, GO_MALGANIS_CHEST_H = 193597 }; #endif