text
stringlengths
4
6.14k
/* 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[2]; atomic_int atom_0_r1_1; atomic_int atom_1_r1_1; atomic_int atom_1_r4_3; atomic_int atom_2_r1_1; void *t0(void *arg){ label_1:; int v2_r1 = atomic_load_explicit(&vars[0], memory_order_seq_cst); int v3_r3 = v2_r1 ^ v2_r1; int v4_r3 = v3_r3 + 1; atomic_store_explicit(&vars[1], v4_r3, memory_order_seq_cst); int v22 = (v2_r1 == 1); atomic_store_explicit(&atom_0_r1_1, v22, memory_order_seq_cst); return NULL; } void *t1(void *arg){ label_2:; int v6_r1 = atomic_load_explicit(&vars[1], memory_order_seq_cst); atomic_store_explicit(&vars[1], 3, memory_order_seq_cst); int v8_r4 = atomic_load_explicit(&vars[1], memory_order_seq_cst); int v9_r5 = v8_r4 ^ v8_r4; atomic_store_explicit(&vars[0+v9_r5], 1, memory_order_seq_cst); int v23 = (v6_r1 == 1); atomic_store_explicit(&atom_1_r1_1, v23, memory_order_seq_cst); int v24 = (v8_r4 == 3); atomic_store_explicit(&atom_1_r4_3, v24, memory_order_seq_cst); return NULL; } void *t2(void *arg){ label_3:; int v11_r1 = atomic_load_explicit(&vars[1], memory_order_seq_cst); atomic_store_explicit(&vars[1], 2, memory_order_seq_cst); int v25 = (v11_r1 == 1); atomic_store_explicit(&atom_2_r1_1, v25, memory_order_seq_cst); return NULL; } int main(int argc, char *argv[]){ pthread_t thr0; pthread_t thr1; pthread_t thr2; atomic_init(&vars[1], 0); atomic_init(&vars[0], 0); atomic_init(&atom_0_r1_1, 0); atomic_init(&atom_1_r1_1, 0); atomic_init(&atom_1_r4_3, 0); atomic_init(&atom_2_r1_1, 0); pthread_create(&thr0, NULL, t0, NULL); pthread_create(&thr1, NULL, t1, NULL); pthread_create(&thr2, NULL, t2, NULL); pthread_join(thr0, NULL); pthread_join(thr1, NULL); pthread_join(thr2, NULL); int v12 = atomic_load_explicit(&atom_0_r1_1, memory_order_seq_cst); int v13 = atomic_load_explicit(&atom_1_r1_1, memory_order_seq_cst); int v14 = atomic_load_explicit(&atom_1_r4_3, memory_order_seq_cst); int v15 = atomic_load_explicit(&vars[1], memory_order_seq_cst); int v16 = (v15 == 3); int v17 = atomic_load_explicit(&atom_2_r1_1, memory_order_seq_cst); int v18_conj = v16 & v17; int v19_conj = v14 & v18_conj; int v20_conj = v13 & v19_conj; int v21_conj = v12 & v20_conj; if (v21_conj == 1) assert(0); return 0; }
/** rmqo: Range Minimum Queries Offline Copyright (C) 2016 Mai Alzamel and Solon P. Pissis 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/>. **/ #include "rmq-offline.h" #define flog2(X) ((unsigned) (8*sizeof (unsigned long long) - __builtin_clzll((X)) - 1)) struct Tuples { INT a, p; }; struct List{ List * next; INT pos; }; INT answer_rmqs ( INT * A, INT n, Query * Q, INT q, Query * Q_Prime, INT * Af ); INT contract( INT * A, INT n, Query * Q, INT q, INT * AQ, INT * s, INT * Af, Query * Q_Prime ); INT recover ( INT * A, INT n, INT * AQ, INT s, INT * Af ); INT create ( INT * A, INT n, INT max, Query * Q, INT q, INT * l_0, List ** l_1, INT * AQ, INT * s, INT * Af, Query * Q_Prime); INT marking( INT * A, INT max, Query * Q, INT q, INT * l_0, List ** l_1 );
/* * link.h * * */ #ifndef _OpenAPI_link_H_ #define _OpenAPI_link_H_ #include <string.h> #include "../external/cJSON.h" #include "../include/list.h" #include "../include/keyValuePair.h" #include "../include/binary.h" #ifdef __cplusplus extern "C" { #endif typedef struct OpenAPI_link_s OpenAPI_link_t; typedef struct OpenAPI_link_s { char *href; } OpenAPI_link_t; OpenAPI_link_t *OpenAPI_link_create( char *href ); void OpenAPI_link_free(OpenAPI_link_t *link); OpenAPI_link_t *OpenAPI_link_parseFromJSON(cJSON *linkJSON); cJSON *OpenAPI_link_convertToJSON(OpenAPI_link_t *link); OpenAPI_link_t *OpenAPI_link_copy(OpenAPI_link_t *dst, OpenAPI_link_t *src); #ifdef __cplusplus } #endif #endif /* _OpenAPI_link_H_ */
#ifndef BottomUpPositiveAlphaShape_h #define BottomUpPositiveAlphaShape_h #include<cmath> #include"CircumcircleRadiusPredicate.h" #include "ConvexHullHelpers.h" /** * Class implementing an on-line and ouput-sensitive algorithm * that retrieves the vertices of the alpha-shape of all digital * points lying inside an implicit shape, which is 'ray-intersectable', * ie. the intersection between the shape boundary and * a ray emanating from a given point along a given direction * is computable. * * @tparam TShape a model of ray-intersectable shape. * @tparam TPredicate a model of ternary predicate: * given three points, the operator() returns a bool. */ template <typename TShape, typename TPredicate> class BottomUpPositiveAlphaShape { public: /////////////////////// inner types ///////////////// typedef TShape Shape; typedef typename Shape::Point Point; typedef typename Shape::Vector Vector; //type redefinition typedef TPredicate Predicate; typedef std::deque<Point> Container; private: /////////////////////// members ///////////////////// /** * const reference on a shape */ const Shape& myShape; /** * Predicate that returns 'true' if the radius * of the circumcircle of three given points * is greater than 1/alpha, 'false' otherwise. * * NB. alpha is implicitely defined by the predicate. */ const Predicate& myPredicate; public: ///////////////////// standard services ///////////// /** * Standard constructor * @param aShape any 'ray-intersectable' shape * @param aPredicate any predicate */ BottomUpPositiveAlphaShape(const Shape& aShape, const Predicate& aPredicate) : myShape(aShape), myPredicate(aPredicate) {} private: /** * Copy constructor * @param other other object to copy */ BottomUpPositiveAlphaShape(const BottomUpPositiveAlphaShape& other) {} /** * Assignement operator * @param other other object to copy * @return reference on *this */ BottomUpPositiveAlphaShape& operator=(const BottomUpPositiveAlphaShape& other) { return *this; } public: /** * Get Circle Predicate * @param aShape any 'ray-intersectable' shape * @return aPredicate any predicate */ Predicate getPredicate() { return ((*this).myPredicate); } /** * Default destructor */ ~BottomUpPositiveAlphaShape() {} ///////////////////// main methods /////////////////// public: /** * Given a vertex of the alpha-shape, find the next * vertex in a counter-clockwise order * @param aPoint any vertex of the alpha-shape * @param res which contained the alpha-shape vertices * @return */ void next(const Point& aPoint, Container& res) { //we hav not enough vertices to test predicate with a triangle if(res.size() < 2) { res.push_back( aPoint ); } else { //maintaining convexity with the new point updateConvexHull(res, aPoint, myPredicate); //add new point res.push_back( aPoint ); } } /** * Retrieves all the vertices of the alpha-shape * in a counter-clockwise order from a given vertex * * @param aStartingPoint a vertex of the alpha-shape * @param res output iterator that stores the sequence of vertices */ template <typename Container, typename Point> void all(Container& res, Point aStartingPoint) { // Retrieve the convex hull vertices OutputSensitiveConvexHull<TShape> ch(myShape); std::vector<Point> resCH; ch.all(aStartingPoint, std::back_inserter(resCH), false); typename std::vector<Point>::iterator it = resCH.begin(); //auto it = resCH.begin(); // c++ 11 Point tmp = *it; do{ // add the next alpha-shape vertices next(tmp, res); tmp = *it; //while it is not the first one }while (it++ != resCH.end()); //maintaining convexity with the starting point updateConvexHull(res, aStartingPoint, myPredicate); }//end proc }; #endif
#include "../../../../../src/charts/animations/pieanimation_p.h"
// e.g. https://www.aliexpress.com/item/Free-shipping-LCD-Display-Module-TFT-3-5-inch-TFT-LCD-screen-for-Arduino-UNO-R3/32579880571.html #include "../GxIO/GxIO_UNO_P8_SHIELD/GxIO_UNO_P8_SHIELD.h" #include "../GxCTRL/GxCTRL_ILI9481/GxCTRL_ILI9481.h" // HVGA 320x480 GxIO_Class io; // #define GxIO_Class is in the selected header file GxCTRL_Class controller(io); // #define GxCTRL_Class is in the selected header file TFT_Class tft(io, controller, 480, 320); // landscape HVGA 320x480 or 3.5inch RPI Display
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* * Copyright (C) 2009 Debarshi Ray <rishi@gnu.org> * * Solang 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. * * Solang 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 SOLANG_THUMBNAILER_PROXY_H #define SOLANG_THUMBNAILER_PROXY_H #include <string> #include <dbus/dbus-glib.h> #include <sigc++/sigc++.h> #include "types.h" namespace Solang { class ThumbnailerProxy { public: typedef sigc::slot<void> SlotAsyncDequeue; typedef sigc::slot<void, guint> SlotAsyncQueue; typedef sigc::slot<void, guint, UStringList &, guint, Glib::ustring &> SlotSignalError; typedef sigc::slot<void, guint, UStringList &> SlotSignalReady; typedef sigc::slot<void, guint> SlotSignalStarted; ThumbnailerProxy() throw(); ~ThumbnailerProxy() throw(); guint queue(const UStringList & uris, const UStringList & mime_types, const std::string & flavour, const std::string & scheduler, guint handle_to_dequeue) throw(Glib::Error); void queue_async(const UStringList & uris, const UStringList & mime_types, const std::string & flavour, const std::string & scheduler, guint handle_to_dequeue, const SlotAsyncQueue & slot) throw(); void dequeue(guint handle) throw(Glib::Error); void dequeue_async(guint handle, const SlotAsyncDequeue & slot) throw(); void error_connect(const SlotSignalError & slot) throw(); void ready_connect(const SlotSignalReady & slot) throw(); void started_connect(const SlotSignalStarted & slot) throw(); operator bool() const throw(); private: static const std::string INTERFACE; static const std::string NAME; static const std::string PATH; bool serviceAvailable_; DBusGProxy * thumbnailerProxy_; }; } // namespace Solang #endif // SOLANG_THUMBNAILER_PROXY_H
/* * ========================================================= * Copyright 2012-2015, Nuno A. Fonseca (nuno dot fonseca at gmail dot com) * * This file is part of iRAP. * * 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 of the License, or * (at your option) any later version. * * This 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 iRAP. If not, see <http://www.gnu.org/licenses/>. * * * $Id: src/bamutils/bam_pe_insert.c 0.1.1 Nuno Fonseca Fri Dec 21 01:07:37 2012$ * ========================================================= */ #include <stdio.h> #include <math.h> #include <bam.h> #include <sam.h> #include <kstring.h> #define VERSION "0.6.2p1" #define MAX_INSERT_SIZE 1000 #define BIN_SIZE 10 int main(int argc, char *argv[]) { bamFile in; if (argc == 1) { fprintf(stderr, "Usage: bam_pe_insert <in.bam>\n"); return 1; } int k; long num_negative_vals=0; long num_alns=0; long num_alns_pe=0; unsigned int bins[MAX_INSERT_SIZE/BIN_SIZE+1]; for (k=0;k<=MAX_INSERT_SIZE/BIN_SIZE;++k) bins[k]=0; in = bam_open(argv[1], "rb"); if (in == 0) { fprintf(stderr, "Fail to open BAM file %s\n", argv[1]); return 1; } int ref; bam_header_t *header; header = bam_header_read(in); bam1_t *aln=bam_init1(); while(bam_read1(in,aln)>=0) { ++num_alns; if (aln->core.tid < 0) continue; if (aln->core.flag & BAM_FSECONDARY) continue; // skip secondary alignments if (aln->core.flag & ! BAM_FPAIRED) continue; // not paired if (aln->core.flag & ! BAM_FPROPER_PAIR) continue; // not a proper pair if (aln->core.flag & ! BAM_FMUNMAP) continue; // the mate is mapped if (aln->core.flag & BAM_FSECONDARY) continue; // secundary read if (aln->core.flag & BAM_FREAD2) continue; // only count each pair once if (aln->core.isize<=0) ++num_negative_vals; else { //printf("%d %d bin=%d pos=%lu matepos=%lu\n",aln->core.flag,aln->core.isize,aln->core.isize/BIN_SIZE, aln->core.pos,aln->core.mpos); if (aln->core.isize>MAX_INSERT_SIZE) { ++bins[MAX_INSERT_SIZE/BIN_SIZE]; } else ++bins[aln->core.isize/BIN_SIZE]; ++num_alns_pe; } } // printf("#Alignments: %lu #PE alignments: %lu\n",num_alns,num_alns_pe*2); printf("#Insert size<0: %lu\n",num_negative_vals); if ( !num_alns_pe ) { exit(1); } unsigned long long tot=0; for (k=0;k<=MAX_INSERT_SIZE/BIN_SIZE;++k) { printf("%d\t%d\n",k*BIN_SIZE,bins[k]); tot+=k*BIN_SIZE*bins[k]; } unsigned int avg=tot/num_alns_pe; tot=0; for (k=0;k<=MAX_INSERT_SIZE/BIN_SIZE;++k) { tot+=((k*BIN_SIZE)-avg)*((k*BIN_SIZE)-avg)*bins[k]; //if (bins[k]) printf("%ld %lu %lu %lu %ld\n",k*BIN_SIZE,avg,(k*BIN_SIZE),((k*BIN_SIZE)-avg)*((k*BIN_SIZE)-avg),bins[k]); } unsigned long var=tot/(num_alns_pe-1); long int stdev=sqrt(var); printf("Avg. insert size: %lu stdev:%ld\n",avg,stdev); bam_destroy1(aln); bam_close(in); return 0; }
// © Copyright 2010 - 2020 BlackTopp Studios Inc. /* This file is part of The Mezzanine Engine. The Mezzanine Engine 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. The Mezzanine Engine 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 Mezzanine Engine. If not, see <http://www.gnu.org/licenses/>. */ /* The original authors have included a copy of the license specified above in the 'Docs' folder. See 'gpl.txt' */ /* We welcome the use of the Mezzanine engine to anyone, including companies who wish to Build professional software and charge for their product. However there are some practical restrictions, so if your project involves any of the following you should contact us and we will try to work something out: - DRM or Copy Protection of any kind(except Copyrights) - Software Patents You Do Not Wish to Freely License - Any Kind of Linking to Non-GPL licensed Works - Are Currently In Violation of Another Copyright Holder's GPL License - If You want to change our code and not add a few hundred MB of stuff to your distribution These and other limitations could cause serious legal problems if you ignore them, so it is best to simply contact us or the Free Software Foundation, if you have any questions. Joseph Toppi - toppij@gmail.com John Blackwood - makoenergy02@gmail.com */ #ifndef Mezz_StaticFoundation_runtime_statics_h #define Mezz_StaticFoundation_runtime_statics_h /// @file /// @brief This file is deeply confused, it tries to provide runtime versions of various compile time constants. /// @details This might seem useless, but languages like Lua and Ruby have no concept of compile time at all and /// languages like Like Java and C# do not have a robust equivelant to the C preprocessor. These and languages like /// these could use the Mezzanine via SWIG bindings. /// @n @n /// This might also be useful in situations where the absence of a preprocessor value needs to be stored in a /// C++ container. #include "DataTypes.h" namespace Mezzanine { /// @brief A class for aggregating all the methods related to the Mezzanine preprocessor directives. /// @details This is required because some SWIG languages cannot handle free functions. class RuntimeStatic { public: /// @return If MEZZ_BuildDoxygen is defined true, false otherwise. static Boole BuildDoxygen(); /// @return If MEZZ_BuildStaticLibraries is defined true, false otherwise. static Boole BuildStaticLibraries(); /// @return If MEZZ_CodeCoverage is defined true, false otherwise. static Boole CodeCoverage(); /// @return If MEZZ_ForceGcc32Bit is defined true, false otherwise. static Boole ForceGcc32Bit(); /// @return If MEZZ_Trace is defined true, false otherwise. static Boole TroubleshootingTracing(); /// @return If CpuIsKnown is defined true, false otherwise. /// @details If the CPU is detected this will return true. If false no other CPU method will return true. static Boole CpuKnown(); /// @return If CpuIsX86 is defined true, false otherwise. /// @details True if known to be on Intel/Amd/Cyrix/Via/whatever x86 compatible including Amd64/Emt64. static Boole CpuX86(); /// @return If CpuIsAmd64 is defined true, false otherwise. /// @details True if known to be on Amd64 or Emt64, x86 comptible 64 bit compatible systems. static Boole CpuAmd64(); /// @return If CpuIsArm is defined true, false otherwise. /// @details True if known to be on any flavor of Arm. static Boole CpuArm(); /// @return If MEZZ_Linux is defined true, false otherwise. static Boole Linux(); /// @return If MEZZ_Windows is defined true, false otherwise. static Boole Windows(); /// @return If MEZZ_MacOSX is defined true, false otherwise. static Boole MacOSX(); /// @return If MEZZ_Ios is defined true, false otherwise. static Boole Ios(); /// @return If MEZZ_CompilerDetected is defined true (it almost always will be), false otherwise. static Boole CompilerDetected(); /// @return If MEZZ_CompilerIsClang is defined true, false otherwise. static Boole CompilerIsClang(); /// @return If MEZZ_CompilerIsEmscripten is defined true, false otherwise. static Boole CompilerIsEmscripten(); /// @return If MEZZ_CompilerIsGCC is defined true, false otherwise. static Boole CompilerIsGCC(); /// @return If MEZZ_CompilerIsIntel is definde true, false otherwise. static Boole CompilerIsIntel(); /// @return If MEZZ_CompilerIsMsvc is defined true, false otherwise. static Boole CompilerIsMsvc(); /// @return If MEZZ_CompilerDesignNix is defined true, false otherwise. static Boole CompilerDesignNix(); /// @return If MEZZ_CompilerDesignMS is defined true, false otherwise. static Boole CompilerDesignMS(); /// @return If MEZZ_Arch64 is defined true, false otherwise. static Boole Arch64(); /// @return If MEZZ_Arch32 is defined true, false otherwise. static Boole Arch32(); /// @return If MEZZ_Debug is defined true, false otherwise. static Boole Debug(); }; } #endif
/* * Copyright(C) 2011-2017 Pedro H. Penna <pedrohenriquepenna@gmail.com> * * This file is part of Nanvix. * * Nanvix 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. * * Nanvix 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 Nanvix. If not, see <http://www.gnu.org/licenses/>. */ #include <limits.h> #ifndef SEMAPHORE_H_ #define SEMAPHORE_H_ #ifndef _ASM_FILE_ /** * @brief User-land semaphore * */ typedef struct sem_t { int semid; /**< Semaphore ID. */ } sem_t; extern sem_t *usem[OPEN_MAX]; /* Forward definitions. */ extern sem_t *sem_open(const char *, int, ...); extern int sem_close(sem_t *); extern int sem_unlink(const char *); extern int sem_post(sem_t *); extern int sem_wait(sem_t *); #endif #endif /* SEMAPHORE_H_ */
#ifndef MENU_PRINCIPAL_H #define MENU_PRINCIPAL_H /** @file menu_principal.h * @author Jéremy Anger * @author Denis Migdal * @date 08/02/2014 * @ingroup cli */ /** @ingroup cli * @brief Affiche le menu principal. * * Demande à l'utilisateur de faire un choix parmis les options proposées : * * Créer une nouvelle partie * * Charger une partie * * Voir les crédits * * Quitter * * @warning ne retourne pas tant que l'utilisateur ne quitte pas le menu. */ void afficher_menu_principal(void); #endif // MENU_PRINCIPAL_H
/* This file is part of cpp-ethereum. cpp-ethereum 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. cpp-ethereum 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 cpp-ethereum. If not, see <http://www.gnu.org/licenses/>. */ /** @file RLPXperimental.h * @author Alex Leverington <nessence@gmail.com> * @date 2015 */ #pragma once #include <deque> #include <libdevcore/Guards.h> #include "RLPXFrameCoder.h" #include "RLPXPacket.h" namespace ba = boost::asio; namespace bi = boost::asio::ip; namespace dev { namespace p2p { /** * @brief Multiplex packets into encrypted RLPX frames. * @todo throw when enqueued packet is invalid * @todo use RLPXFrameInfo */ class RLPXFrameWriter { /** * @brief Queue and state for Writer * Properties are used independently; * only valid packets should be added to q * @todo implement as class */ struct WriterState { std::deque<RLPXPacket> q; mutable Mutex x; RLPXPacket* writing = nullptr; size_t remaining = 0; bool multiFrame = false; uint16_t sequence = -1; }; public: enum PacketPriority { PriorityLow = 0, PriorityHigh }; static const uint16_t EmptyFrameLength; static const uint16_t MinFrameDequeLength; RLPXFrameWriter(uint16_t _protocolType): m_protocolId(_protocolType) {} RLPXFrameWriter(RLPXFrameWriter const& _s): m_protocolId(_s.m_protocolId) {} /// Returns total number of queued packets. Thread-safe. size_t size() const { size_t l = 0; size_t h = 0; DEV_GUARDED(m_q.first.x) h = m_q.first.q.size(); DEV_GUARDED(m_q.second.x) l = m_q.second.q.size(); return l + h; } /// Moves @_payload output to queue, to be muxed into frames by mux() when network buffer is ready for writing. Thread-safe. void enque(uint8_t _packetType, RLPStream& _payload, PacketPriority _priority = PriorityLow); /// Returns number of packets framed and outputs frames to o_bytes. Not thread-safe. size_t mux(RLPXFrameCoder& _coder, unsigned _size, std::deque<bytes>& o_toWrite); /// Moves @_p to queue, to be muxed into frames by mux() when network buffer is ready for writing. Thread-safe. void enque(RLPXPacket&& _p, PacketPriority _priority = PriorityLow); uint16_t protocolId() const { return m_protocolId; } private: uint16_t const m_protocolId; std::pair<WriterState, WriterState> m_q; // High, Low frame queues uint16_t m_sequenceId = 0; // Sequence ID }; } }
// nearly empty file to be compatible with unmodified avr-crypto-lib sources // re-defined in standard avr-crypto-lib sha1.c #ifdef LITTLE_ENDIAN #undef LITTLE_ENDIAN #endif #define DEBUG_S(a) ((void)0)
/******************************************************************************* * * This file is part of the General Hidden Markov Model Library, * GHMM version __VERSION__, see http://ghmm.org * * Filename: ghmm/ghmm/rng.c * Authors: Alexander Schliep * * Copyright (C) 1998-2004 Alexander Schliep * Copyright (C) 1998-2001 ZAIK/ZPR, Universitaet zu Koeln * Copyright (C) 2002-2004 Max-Planck-Institut fuer Molekulare Genetik, * Berlin * * Contact: schliep@ghmm.org * * 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; if not, write to the Free * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * * This file is version $Revision: 2267 $ * from $Date: 2009-04-24 11:01:58 -0400 (Fri, 24 Apr 2009) $ * last change by $Author: grunau $. * *******************************************************************************/ #ifdef HAVE_CONFIG_H # include "../config.h" #endif #include <stdlib.h> #include <stdio.h> #include "rng.h" #include "math.h" #include "time.h" /* The global RNG */ GHMM_RNG *RNG; /* ----- Mersenne Twister -------------------------------------------------- */ #ifdef GHMM_RNG_MERSENNE_TWISTER #include "mt19937ar.c" static ghmm_rng_state_t *ighmm_rng_state; static char ighmm_rng_name[] = "Mersenne Twister"; void ghmm_rng_set(GHMM_RNG * r, unsigned long int seed) { init_genrand(seed); } double ghmm_rng_uniform(GHMM_RNG * r) { return genrand_real2(); } const char *ghmm_rng_name(GHMM_RNG * r) { return ighmm_rng_name; } void ghmm_rng_init(void) { initstate(1, ighmm_rng_state, sizeof(ghmm_rng_state_t)); RNG = ighmm_rng_state; } #endif /* GHMM_RNG_MERSENNE_TWISTER */ /* ----- BSD --------------------------------------------------------------- */ #ifdef GHMM_RNG_BSD static ghmm_rng_state_t ighmm_rng_state; static char ighmm_rng_name[] = "random"; void ghmm_rng_set(GHMM_RNG * r, unsigned long int seed) { srandom(seed); } double ghmm_rng_uniform(GHMM_RNG * r) { return ((double)random()) / (RAND_MAX + 1.0); } const char *ghmm_rng_name(GHMM_RNG * r) { return ighmm_rng_name; } void ghmm_rng_init(void) { initstate(1, ighmm_rng_state, sizeof(ghmm_rng_state_t)); RNG = &ighmm_rng_state; } #endif /* "GHMM_RNG_BSD */ /* ----- GSL --------------------------------------------------------------- */ #ifdef GHMM_RNG_GSL void ghmm_rng_init(void) { gsl_rng_env_setup(); RNG = gsl_rng_alloc(gsl_rng_default); } #endif /* GHMM_RNG_GSL */ void ghmm_rng_timeseed(GHMM_RNG * r) { unsigned long tm; /* Time seed */ unsigned int timeseed; timeseed = time(NULL); srand(timeseed); tm = rand(); GHMM_RNG_SET(r, tm); /*printf("# using rng '%s' seed=%ld\n", GHMM_RNG_NAME(r), tm); */ fflush(stdout); }
/* xoreos-tools - Tools to help with xoreos development * * xoreos-tools is the legal property of its developers, whose names * can be found in the AUTHORS file distributed with this source * distribution. * * xoreos-tools 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. * * xoreos-tools 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 xoreos-tools. If not, see <http://www.gnu.org/licenses/>. */ /** @file * Handling BioWare's GFF'd talk tables. */ #ifndef AURORA_TALKTABLE_GFF_H #define AURORA_TALKTABLE_GFF_H #include <map> #include "src/common/types.h" #include "src/common/scopedptr.h" #include "src/common/ptrmap.h" #include "src/common/ustring.h" #include "src/aurora/types.h" #include "src/aurora/talktable.h" namespace Common { class SeekableReadStream; class SeekableSubReadStreamEndian; } namespace Aurora { /** Loading BioWare's GFF'd talk tables. * * See class TalkTable for a general overview how talk tables work. * * Unlike TalkTable_TLK, a GFF talk table stores the string data * within a V4.0 GFF. It does not store any language ID (the language * is implicit in the talk tables file name), nor any other data * besides the raw strings. getSoundResRef() always returns an empty * string. * * There are three versions of GFF'd talk tables known and supported * - V0.2, used by Sonic Chronicles and Dragon Age: Origins (PC) * - V0.4, used by Dragon Age: Origins (Xbox 360) * - V0.5, used by Dragon Age II */ class TalkTable_GFF : public TalkTable { public: /** Take over this stream and read a GFF'd TLK out of it. */ TalkTable_GFF(Common::SeekableReadStream *tlk, Common::Encoding encoding); ~TalkTable_GFF(); const std::list<uint32> &getStrRefs() const; bool getString(uint32 strRef, Common::UString &string, Common::UString &soundResRef) const; bool getEntry(uint32 strRef, Common::UString &string, Common::UString &soundResRef, uint32 &volumeVariance, uint32 &pitchVariance, float &soundLength, uint32 &soundID) const; void setEntry(uint32 strRef, const Common::UString &string, const Common::UString &soundResRef, uint32 volumeVariance, uint32 pitchVariance, float soundLength, uint32 soundID); private: struct Entry { Common::UString text; const GFF4Struct *strct; Entry(const GFF4Struct *s = 0) : strct(s) { } }; typedef Common::PtrMap<uint32, Entry> Entries; Common::ScopedPtr<GFF4File> _gff; std::list<uint32> _strRefs; Entries _entries; void load(Common::SeekableReadStream *tlk); void load02(const GFF4Struct &top); void load05(const GFF4Struct &top); Common::UString readString(const Entry &entry) const; Common::UString readString02(const Entry &entry) const; Common::UString readString05(const Entry &entry, bool bigEndian) const; Common::UString readString05(Common::SeekableSubReadStreamEndian &huffTree, Common::SeekableSubReadStreamEndian &bitStream, const Entry &entry) const; }; } // End of namespace Aurora #endif // AURORA_TALKTABLE_GFF_H
/** ****************************************************************************** * @file ADC/ADC_InjectedConversion_Interrupt/Inc/stm32f4xx_it.h * @author MCD Application Team * @version V1.1.0 * @date 17-February-2017 * @brief This file contains the headers of the interrupt handlers. ****************************************************************************** * @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 __STM32F4xx_IT_H #define __STM32F4xx_IT_H #ifdef __cplusplus extern "C" { #endif /* Includes ------------------------------------------------------------------*/ /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ /* Exported macro ------------------------------------------------------------*/ /* Exported functions ------------------------------------------------------- */ void NMI_Handler(void); void HardFault_Handler(void); void MemManage_Handler(void); void BusFault_Handler(void); void UsageFault_Handler(void); void SVC_Handler(void); void DebugMon_Handler(void); void PendSV_Handler(void); void SysTick_Handler(void); void ADC_IRQHandler(void); #ifdef __cplusplus } #endif #endif /* __STM32F4xx_IT_H */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
#ifndef _PH_KPHUSER_H #define _PH_KPHUSER_H #include <kphapi.h> #ifdef __cplusplus extern "C" { #endif typedef struct _KPH_PARAMETERS { KPH_SECURITY_LEVEL SecurityLevel; BOOLEAN CreateDynamicConfiguration; } KPH_PARAMETERS, *PKPH_PARAMETERS; PHLIBAPI NTSTATUS NTAPI KphConnect( _In_opt_ PWSTR DeviceName ); PHLIBAPI NTSTATUS NTAPI KphConnect2( _In_opt_ PWSTR DeviceName, _In_ PWSTR FileName ); PHLIBAPI NTSTATUS NTAPI KphConnect2Ex( _In_opt_ PWSTR DeviceName, _In_ PWSTR FileName, _In_opt_ PKPH_PARAMETERS Parameters ); PHLIBAPI NTSTATUS NTAPI KphDisconnect( VOID ); PHLIBAPI BOOLEAN NTAPI KphIsConnected( VOID ); PHLIBAPI BOOLEAN NTAPI KphIsVerified( VOID ); PHLIBAPI NTSTATUS NTAPI KphSetParameters( _In_opt_ PWSTR DeviceName, _In_ PKPH_PARAMETERS Parameters ); PHLIBAPI NTSTATUS NTAPI KphInstall( _In_opt_ PWSTR DeviceName, _In_ PWSTR FileName ); PHLIBAPI NTSTATUS NTAPI KphInstallEx( _In_opt_ PWSTR DeviceName, _In_ PWSTR FileName, _In_opt_ PKPH_PARAMETERS Parameters ); PHLIBAPI NTSTATUS NTAPI KphUninstall( _In_opt_ PWSTR DeviceName ); PHLIBAPI NTSTATUS NTAPI KphGetFeatures( _Out_ PULONG Features ); PHLIBAPI NTSTATUS NTAPI KphVerifyClient( _In_reads_bytes_(SignatureSize) PUCHAR Signature, _In_ ULONG SignatureSize ); PHLIBAPI NTSTATUS NTAPI KphOpenProcess( _Out_ PHANDLE ProcessHandle, _In_ ACCESS_MASK DesiredAccess, _In_ PCLIENT_ID ClientId ); PHLIBAPI NTSTATUS NTAPI KphOpenProcessToken( _In_ HANDLE ProcessHandle, _In_ ACCESS_MASK DesiredAccess, _Out_ PHANDLE TokenHandle ); PHLIBAPI NTSTATUS NTAPI KphOpenProcessJob( _In_ HANDLE ProcessHandle, _In_ ACCESS_MASK DesiredAccess, _Out_ PHANDLE JobHandle ); PHLIBAPI NTSTATUS NTAPI KphTerminateProcess( _In_ HANDLE ProcessHandle, _In_ NTSTATUS ExitStatus ); PHLIBAPI NTSTATUS NTAPI KphReadVirtualMemoryUnsafe( _In_opt_ HANDLE ProcessHandle, _In_ PVOID BaseAddress, _Out_writes_bytes_(BufferSize) PVOID Buffer, _In_ SIZE_T BufferSize, _Out_opt_ PSIZE_T NumberOfBytesRead ); PHLIBAPI NTSTATUS NTAPI KphQueryInformationProcess( _In_ HANDLE ProcessHandle, _In_ KPH_PROCESS_INFORMATION_CLASS ProcessInformationClass, _Out_writes_bytes_(ProcessInformationLength) PVOID ProcessInformation, _In_ ULONG ProcessInformationLength, _Out_opt_ PULONG ReturnLength ); PHLIBAPI NTSTATUS NTAPI KphSetInformationProcess( _In_ HANDLE ProcessHandle, _In_ KPH_PROCESS_INFORMATION_CLASS ProcessInformationClass, _In_reads_bytes_(ProcessInformationLength) PVOID ProcessInformation, _In_ ULONG ProcessInformationLength ); PHLIBAPI NTSTATUS NTAPI KphOpenThread( _Out_ PHANDLE ThreadHandle, _In_ ACCESS_MASK DesiredAccess, _In_ PCLIENT_ID ClientId ); PHLIBAPI NTSTATUS NTAPI KphOpenThreadProcess( _In_ HANDLE ThreadHandle, _In_ ACCESS_MASK DesiredAccess, _Out_ PHANDLE ProcessHandle ); PHLIBAPI NTSTATUS NTAPI KphCaptureStackBackTraceThread( _In_ HANDLE ThreadHandle, _In_ ULONG FramesToSkip, _In_ ULONG FramesToCapture, _Out_writes_(FramesToCapture) PVOID *BackTrace, _Out_opt_ PULONG CapturedFrames, _Out_opt_ PULONG BackTraceHash ); PHLIBAPI NTSTATUS NTAPI KphQueryInformationThread( _In_ HANDLE ThreadHandle, _In_ KPH_THREAD_INFORMATION_CLASS ThreadInformationClass, _Out_writes_bytes_(ThreadInformationLength) PVOID ThreadInformation, _In_ ULONG ThreadInformationLength, _Out_opt_ PULONG ReturnLength ); PHLIBAPI NTSTATUS NTAPI KphSetInformationThread( _In_ HANDLE ThreadHandle, _In_ KPH_THREAD_INFORMATION_CLASS ThreadInformationClass, _In_reads_bytes_(ThreadInformationLength) PVOID ThreadInformation, _In_ ULONG ThreadInformationLength ); PHLIBAPI NTSTATUS NTAPI KphEnumerateProcessHandles( _In_ HANDLE ProcessHandle, _Out_writes_bytes_(BufferLength) PVOID Buffer, _In_opt_ ULONG BufferLength, _Out_opt_ PULONG ReturnLength ); PHLIBAPI NTSTATUS NTAPI KphEnumerateProcessHandles2( _In_ HANDLE ProcessHandle, _Out_ PKPH_PROCESS_HANDLE_INFORMATION *Handles ); PHLIBAPI NTSTATUS NTAPI KphQueryInformationObject( _In_ HANDLE ProcessHandle, _In_ HANDLE Handle, _In_ KPH_OBJECT_INFORMATION_CLASS ObjectInformationClass, _Out_writes_bytes_(ObjectInformationLength) PVOID ObjectInformation, _In_ ULONG ObjectInformationLength, _Out_opt_ PULONG ReturnLength ); PHLIBAPI NTSTATUS NTAPI KphSetInformationObject( _In_ HANDLE ProcessHandle, _In_ HANDLE Handle, _In_ KPH_OBJECT_INFORMATION_CLASS ObjectInformationClass, _In_reads_bytes_(ObjectInformationLength) PVOID ObjectInformation, _In_ ULONG ObjectInformationLength ); PHLIBAPI NTSTATUS NTAPI KphOpenDriver( _Out_ PHANDLE DriverHandle, _In_ ACCESS_MASK DesiredAccess, _In_ POBJECT_ATTRIBUTES ObjectAttributes ); PHLIBAPI NTSTATUS NTAPI KphQueryInformationDriver( _In_ HANDLE DriverHandle, _In_ DRIVER_INFORMATION_CLASS DriverInformationClass, _Out_writes_bytes_(DriverInformationLength) PVOID DriverInformation, _In_ ULONG DriverInformationLength, _Out_opt_ PULONG ReturnLength ); // kphdata PHLIBAPI NTSTATUS NTAPI KphInitializeDynamicPackage( _Out_ PKPH_DYN_PACKAGE Package ); #ifdef __cplusplus } #endif #endif
#ifndef BACKGROUNDSUBTRACTION_C_CODEBOOK_AAC_3_1_AACSEG_H_ #define BACKGROUNDSUBTRACTION_C_CODEBOOK_AAC_3_1_AACSEG_H_ #include "CodeBook.h" #include "SeedFill.h" class cAACSEG { public: Mat mImage; Mat mRaw; Mat mResult; Mat mCst; Mat mRMOD; cCodeBook *mModel; public: int mH; int mW; int mMAX; bool mInitialized = false; int mFrame = 0; RNG rng; public: // Parameters int mTraining = 250; public: cAACSEG(); ~cAACSEG(); public: void fInitialize(const Mat &BGR); void fSeedfill(Mat &Gray, int filterSize, bool removePos); void fPostProc(Mat &Mask); public: void fProcess(const Mat &BGR, Mat &BIN); }; #endif
/* * File: M51CN128EVB.h * Purpose: Evaluation board definitions and memory map information * * Notes: */ #ifndef _M51CN128EVB_H #define _M51CN128EVB_H /********************************************************************/ #include "mcf5xxx.h" #include "derivative.h" /* include peripheral declarations */ /********************************************************************/ /* * Debug prints ON (#undef) or OFF (#define) */ #undef DEBUG /*****************************************************************************/ /*Warning: only define one of them*/ //#define M51CN128RD /*pins moved to reference design hardware*/ #define V1_TOWER /*pins moved to reference design hardware*/ #ifdef M51CN128RD /*only defined for reference design*/ /*FSL: using external clock*/ #define EXTERNAL_CLOCK /*MCU feeds PHY clock*/ #ifndef MCU_FED_PHY_CLK #define MCU_FED_PHY_CLK 1 #endif #define UART_PORT 0/*First Port*/ #endif #ifdef V1_TOWER #undef EXTERNAL_CLOCK #define UART_PORT 1/*Second Port*/ #endif /* * System Bus Clock Info */ #ifndef EXTERNAL_CLOCK #define SYSTEM_CLOCK 50331648UL/* system bus frequency in Hz */ #else #define SYSTEM_CLOCK 50000000UL/* system bus frequency in Hz */ #endif #define UART_BAUD 115200 /* 19200 */ #define ADC_CHANNEL 3//ADP3 #define SPI_PORT 1/*Second Port*/ /* * ColdFire Port specific */ /*internal or external PHY*/ #ifndef PHY_ON_CHIP #define PHY_ON_CHIP 0 #endif /*100Mbps configuration*/ #ifndef SPEED_10BASET #define SPEED_10BASET 0 #endif /*MAC address for this device*/ #define COLDFIRE_MAC_ADDRESS {0x00, 0xCF, 0x52, 0x35, 0x00, 0x07} #define CF_IP_ADDRESS {192,168,1,3} #define CF_MASK_ADDRESS {255,255,255,0} #define CF_GATEWAY_ADDRESS {192,168,1,1} #define CF_SERVER_ADDRESS {192,168,1,81}/*cant be the same as IP address!!*/ /*Default Port for Bridge*/ #define TCP_PORT 1234 /* * Ethernet Port Info */ #define FEC_PHY0 (0x01) /*Byte Reversing*/ #define BYTE_REVERSE_ON_HARDWARE 1//0 /*****************************************************************************/ /*Handy*/ #define LED0_TOG PTDD^=PTDD_PTDD1_MASK #define LED1_TOG PTDD^=PTDD_PTDD2_MASK #define LED2_TOG PTDD^=PTDD_PTDD3_MASK #define LED0_ON PTDD_PTDD1=0 #define LED0_OFF PTDD_PTDD1=1 #define LED1_ON PTDD_PTDD2=0 #define LED1_OFF PTDD_PTDD2=1 #define LED2_ON PTDD_PTDD3=0 #define LED2_OFF PTDD_PTDD3=1 #endif /* _M51CN128EVB_H_ */
/* * list.h * The names of functions callable from within lists ***************************************************************************** * This file is part of Fågelmataren, an embedded project created to learn * Linux and C. See <https://github.com/Linkaan/Fagelmatare> * Copyright (C) 2015-2017 Linus Styrén * * Fågelmataren 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 Licence, or * (at your option) any later version. * * Fågelmataren 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 Licence for more details. * * You should have received a copy of the GNU General Public Licence * along with Fågelmataren. If not, see <http://www.gnu.org/licenses/>. ***************************************************************************** */ #ifndef _LIST_H_ #define _LIST_H_ struct node { struct node *next; void *value; }; typedef struct node* llist; extern int list_insert (llist *, void *); extern int list_remove (llist *, void *); extern int list_pop (llist *, void **); #endif /* _LIST_H_ */
/** * flightpanel - A Cortex-M4 based USB flight panel for flight simulators. * Copyright (C) 2017-2017 Johannes Bauer * * This file is part of flightpanel. * * flightpanel 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; this program is ONLY licensed under * version 3 of the License, later versions are explicitly excluded. * * flightpanel 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 flightpanel; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Johannes Bauer <JohannesBauer@gmx.de> **/ #ifndef __ROTARY_H__ #define __ROTARY_H__ #include <stdint.h> #include <stdbool.h> struct linear_mapping_t { int32_t offset; int32_t multiplier; }; struct rotary_encoder_t { /* These are configuration variables */ uint16_t value; uint16_t detent_cnt; bool wrap_around; const struct linear_mapping_t *mapping; /* These are output/input */ bool changed; /* These are internal */ uint8_t time_since_last_change; bool origin; bool armed; bool direction; }; /*************** AUTO GENERATED SECTION FOLLOWS ***************/ bool rotary_encoder_update(struct rotary_encoder_t *rotary, bool value1, bool value2); int32_t rotary_getvalue(const struct rotary_encoder_t *rotary); void rotary_setvalue(struct rotary_encoder_t *rotary, int32_t value); /*************** AUTO GENERATED SECTION ENDS ***************/ #endif
/* * iEvil.h */ #ifndef __QUANTUM_IEVIL_H #define __QUANTUM_IEVIL_H #include <memory> #include "qubit.h" namespace Quantum { class iEvil { public: virtual void doEvil(shared_ptr<Qubit> q) = 0; }; } #endif
/* * Copyright 2010-2013 OpenXcom Developers. * * This file is part of OpenXcom. * * OpenXcom 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. * * OpenXcom 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 OpenXcom. If not, see <http://www.gnu.org/licenses/>. */ #ifndef OPENXCOM_CRAFT_H #define OPENXCOM_CRAFT_H #include "MovingTarget.h" #include <vector> #include <string> namespace OpenXcom { class RuleCraft; class Base; class Soldier; class CraftWeapon; class ItemContainer; class Ruleset; class SavedGame; class Vehicle; /** * Represents a craft stored in a base. * Contains variable info about a craft like * position, fuel, damage, etc. * @sa RuleCraft */ class Craft : public MovingTarget { private: RuleCraft *_rules; Base *_base; int _id, _fuel, _damage, _interceptionOrder; std::vector<CraftWeapon*> _weapons; ItemContainer *_items; std::vector<Vehicle*> _vehicles; std::string _status; bool _lowFuel; bool _inBattlescape; bool _inDogfight; std::wstring _name; public: /// Creates a craft of the specified type. Craft(RuleCraft *rules, Base *base, int id = 0); /// Cleans up the craft. ~Craft(); /// Loads the craft from YAML. void load(const YAML::Node& node, const Ruleset *rule, SavedGame *save); /// Saves the craft to YAML. void save(YAML::Emitter& out) const; /// Saves the craft's ID to YAML. void saveId(YAML::Emitter& out) const; /// Gets the craft's ruleset. RuleCraft *getRules() const; /// Sets the craft's ruleset. void setRules(RuleCraft *rules); /// Gets the craft's ID. int getId() const; /// Gets the craft's name. std::wstring getName(Language *lang) const; /// Sets the craft's name. void setName(const std::wstring &newName); /// Gets the craft's base. Base *getBase() const; /// Sets the craft's base. void setBase(Base *base); /// Sets the craft's base. (without setting the craft's coordinates) void setBaseOnly(Base *base); /// Gets the craft's status. std::string getStatus() const; /// Sets the craft's status. void setStatus(const std::string &status); /// Gets the craft's altitude. std::string getAltitude() const; /// Sets the craft's destination. void setDestination(Target *dest); /// Gets the craft's amount of weapons. int getNumWeapons() const; /// Gets the craft's amount of soldiers. int getNumSoldiers() const; /// Gets the craft's amount of equipment. int getNumEquipment() const; /// Gets the craft's amount of vehicles. int getNumVehicles() const; /// Gets the craft's weapons. std::vector<CraftWeapon*> *getWeapons(); /// Gets the craft's items. ItemContainer *getItems(); /// Gets the craft's vehicles. std::vector<Vehicle*> *getVehicles(); /// Gets the craft's amount of fuel. int getFuel() const; /// Sets the craft's amount of fuel. void setFuel(int fuel); /// Gets the craft's percentage of fuel. int getFuelPercentage() const; /// Gets the craft's amount of damage. int getDamage() const; /// Sets the craft's amount of damage. void setDamage(int damage); /// Gets the craft's percentage of damage. int getDamagePercentage() const; /// Gets whether the craft is running out of fuel. bool getLowFuel() const; /// Sets whether the craft is running out of fuel. void setLowFuel(bool low); /// Gets the craft's distance from its base. double getDistanceFromBase() const; /// Gets the craft's fuel consumption. int getFuelConsumption() const; /// Gets the craft's minimum fuel limit. int getFuelLimit() const; /// Gets the craft's minimum fuel limit to go to a base. int getFuelLimit(Base *base) const; /// Returns the craft to its base. void returnToBase(); /// Checks if a target is detected by the craft's radar. bool detect(Target *target) const; /// Handles craft logic. void think(); /// Does a craft full checkup. void checkup(); /// Consumes the craft's fuel. void consumeFuel(); /// Repairs the craft. void repair(); /// Refuels the craft. void refuel(); /// Rearms the craft. std::string rearm(); /// Sets the craft's battlescape status. void setInBattlescape(bool inbattle); /// Gets if the craft is in battlescape. bool isInBattlescape() const; /// Gets if craft is destroyed during dogfights. bool isDestroyed() const; /// Gets the amount of space available inside a craft. int getSpaceAvailable() const; /// Gets the amount of space used inside a craft. int getSpaceUsed() const; /// Gets the craft's vehicles of a certain type. int getVehicleCount(const std::string &vehicle) const; /// Sets the craft's dogfight status. void setInDogfight(const bool inDogfight); /// Gets if the craft is in dogfight. bool isInDogfight() const; /// Sets interception order (first craft to leave the base gets 1, second 2, etc.). void setInterceptionOrder(const int order); /// Gets interception number. int getInterceptionOrder() const; }; } #endif
#include "precision-clock.h" #include "tim.h" volatile uint32_t constant = 0; volatile uint16_t lastValue = 0; /* extern __IO uint32_t uwTick; uint32_t ticksHiRes = 0;*/ void prec_clock_init() { HAL_TIM_Base_Start(&htim17); } /* void HAL_IncTick(void) { ticksHiRes++; if (ticksHiRes%10 == 0) uwTick++; }*/ uint32_t prec_clock_ticks() { volatile uint16_t v = htim17.Instance->CNT; if (v < lastValue) { // Timer was restarted between calls, so increment constant constant += 0xFFFF; } lastValue = v; return (constant + v); //return HAL_GetTick(); } /* void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) { if (htim == &htim17) { //HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_0); ticksCount++; } } */
/* * Copyright (C) 2006-2010 by RoboLab - University of Extremadura * * This file is part of RoboComp * * RoboComp 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. * * RoboComp 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 RoboComp. If not, see <http://www.gnu.org/licenses/>. */ #ifndef GENERICBASEI_H #define GENERICBASEI_H // QT includes #include <QtCore/QObject> // Ice includes #include <Ice/Ice.h> #include <GenericBase.h> #include <config.h> #include "worker.h" using namespace RoboCompGenericBase; class GenericBaseI : public QObject , public virtual RoboCompGenericBase::GenericBase { Q_OBJECT public: GenericBaseI( Worker *_worker, QObject *parent = 0 ); ~GenericBaseI(); void getBaseState(RoboCompGenericBase::TBaseState& state, const Ice::Current& = Ice::Current()); void getBasePose(Ice::Int& x, Ice::Int& z, Ice::Float& alpha, const Ice::Current& = Ice::Current()); QMutex *mutex; private: void throwException(std::string msg); Worker *worker; }; #endif
#include<stdio.h> #include<io.h> #include<fcntl.h> #include<sys\stat.h> main() { int handle,old_mode; char buf[128]="Hello the world \n",*temp,c='\0'; if((handle=creat("\\tc\\ExNtemp.txt",S_IWRITE))==-1) { printf("\n Error open the file ExNtemp.txt!"); } else { printf("\nThe file ExNtemp.txt has created!"); if((old_mode=setmode(handle,O_TEXT))==-1) { printf("\nError change file mode!"); } else { printf("\nThe file mode has changed to O_TEXT!"); } } getch(); }
/** **************************************************************************************** * * @file hrp_common.h * * @brief Header File - Heart Rate Profile common types. * * Copyright (C) RivieraWaves 2009-2013 * * $Rev$ * **************************************************************************************** */ #ifndef _HRP_COMMON_H_ #define _HRP_COMMON_H_ /** **************************************************************************************** * @addtogroup HRP Heart Rate Profile * @ingroup PROFILE * @brief Heart Rate Profile * * The HRP module is the responsible block for implementing the Heart Rate Profile * functionalities in the BLE Host. * * The Heart Rate Profile defines the functionality required in a device that allows * the user (Collector device) to configure and recover Heart Rate measurements from * a Heart Rate device. ***************************************************************************************** */ /* * INCLUDE FILES **************************************************************************************** */ #if (BLE_HR_COLLECTOR || BLE_HR_SENSOR) #include "prf_types.h" #include <stdint.h> /* * DEFINES **************************************************************************************** */ /// maximum number of RR-Interval supported #define HRS_MAX_RR_INTERVAL (4) /// Heart Rate Control Point Not Supported error code #define HRS_ERR_HR_CNTL_POINT_NOT_SUPPORTED (0x80) ///HRS codes for the 2 possible client configuration characteristic descriptors determination enum { /// Heart Rate Measurement HRS_HR_MEAS_CODE = 0x01, /// Energy Expended - Heart Rate Control Point HRS_HR_CNTL_POINT_CODE, }; /// Heart Rate Measurement Flags field bit values enum { /// Heart Rate Value Format bit /// Heart Rate Value Format is set to UINT8. Units: beats per minute (bpm) HRS_FLAG_HR_8BITS_VALUE = 0x00, /// Heart Rate Value Format is set to UINT16. Units: beats per minute (bpm) HRS_FLAG_HR_16BITS_VALUE = 0x01, /// Sensor Contact Status bits /// Sensor Contact feature is not supported in the current connection HRS_FLAG_SENSOR_CCT_FET_NOT_SUPPORTED = 0x00, /// Sensor Contact feature supported in the current connection HRS_FLAG_SENSOR_CCT_FET_SUPPORTED = 0x04, /// Contact is not detected HRS_FLAG_SENSOR_CCT_NOT_DETECTED = 0x00, /// Contact is detected HRS_FLAG_SENSOR_CCT_DETECTED = 0x02, /// Energy Expended Status bit /// Energy Expended field is not present HRS_FLAG_ENERGY_EXPENDED_NOT_PRESENT = 0x00, /// Energy Expended field is present. Units: kilo Joules HRS_FLAG_ENERGY_EXPENDED_PRESENT = 0x08, /// RR-Interval bit /// RR-Interval values are not present. HRS_FLAG_RR_INTERVAL_NOT_PRESENT = 0x00, /// One or more RR-Interval values are present. Units: 1/1024 seconds HRS_FLAG_RR_INTERVAL_PRESENT = 0x10, }; /// Heart Rate Feature Flags field bit values enum { /// Body Sensor Location support bit /// Body Sensor Location feature Not Supported HRS_F_BODY_SENSOR_LOCATION_NOT_SUPPORTED = 0x00, /// Body Sensor Location feature Supported HRS_F_BODY_SENSOR_LOCATION_SUPPORTED = 0x01, /// Energy Expended support bit /// Energy Expended feature Not Supported HRS_F_ENERGY_EXPENDED_NOT_SUPPORTED = 0x00, /// Energy Expended feature Supported HRS_F_ENERGY_EXPENDED_SUPPORTED = 0x02, }; /// Body Sensor Location enum { HRS_LOC_OTHER, HRS_LOC_CHEST, HRS_LOC_WRIST, HRS_LOC_FINGER, HRS_LOC_HAND, HRS_LOC_EAR_LOBE, HRS_LOC_FOOT, HRS_LOC_MAX = HRS_LOC_FOOT, }; /* * TYPE DEFINITIONS **************************************************************************************** */ /// Heart Rate measurement structure struct hrs_hr_meas { /// Flag uint8_t flags; /// RR-Interval numbers (max 4) uint8_t nb_rr_interval; /// RR-Intervals uint16_t rr_intervals[HRS_MAX_RR_INTERVAL]; /// Heart Rate Measurement Value uint16_t heart_rate; /// Energy Expended uint16_t energy_expended; }; #endif /* #if (BLE_HR_COLLECTOR || BLE_HR_SENSOR) */ /// @} hrp_common #endif /* _HRP_COMMON_H_ */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* */ /* This file is part of the class library */ /* SoPlex --- the Sequential object-oriented simPlex. */ /* */ /* Copyright (C) 1996-2018 Konrad-Zuse-Zentrum */ /* fuer Informationstechnik Berlin */ /* */ /* SoPlex is distributed under the terms of the ZIB Academic Licence. */ /* */ /* You should have received a copy of the ZIB Academic License */ /* along with SoPlex; see the file COPYING. If not email to soplex@zib.de. */ /* */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /**@file spxharrisrt.h * @brief Harris pricing with shifting. */ #ifndef _SPXHARRISRT_H_ #define _SPXHARRISRT_H_ #include <assert.h> #include "spxdefines.h" #include "spxratiotester.h" namespace soplex { /**@brief Harris pricing with shifting. @ingroup Algo Class SPxHarrisRT is a stable implementation of a SPxRatioTester class along the lines of Harris' two phase algorithm. Additionally it uses shifting of bounds in order to avoid cycling. See SPxRatioTester for a class documentation. */ /**@todo HarrisRT leads to cycling in dcmulti.sub.lp */ class SPxHarrisRT : public SPxRatioTester { private: //------------------------------------- /**@name Private helpers */ //@{ /// Real degenerateEps() const; /// int maxDelta( Real* /*max*/, ///< max abs value in \p upd Real* val, ///< initial and chosen value int num, ///< number of indices in \p idx const int* idx, ///< nonzero indices in \p upd const Real* upd, ///< update vector for \p vec const Real* vec, ///< current vector const Real* low, ///< lower bounds for \p vec const Real* up, ///< upper bounds for \p vec Real epsilon ///< what is 0? ) const; /// int minDelta( Real* /*max*/, ///< max abs value in \p upd Real* val, ///< initial and chosen value int num, ///< of indices in \p idx const int* idx, ///< nonzero indices in \p upd const Real* upd, ///< update vector for \p vec const Real* vec, ///< current vector const Real* low, ///< lower bounds for \p vec const Real* up, ///< upper bounds for \p vec Real epsilon ///< what is 0? ) const; //@} public: //------------------------------------- /**@name Construction / destruction */ //@{ /// default constructor SPxHarrisRT() : SPxRatioTester("Harris") {} /// copy constructor SPxHarrisRT(const SPxHarrisRT& old) : SPxRatioTester(old) {} /// assignment operator SPxHarrisRT& operator=( const SPxHarrisRT& rhs) { if(this != &rhs) { SPxRatioTester::operator=(rhs); } return *this; } /// destructor virtual ~SPxHarrisRT() {} /// clone function for polymorphism inline virtual SPxRatioTester* clone() const { return new SPxHarrisRT(*this); } //@} //------------------------------------- /**@name Leave / enter */ //@{ /// virtual int selectLeave(Real& val, Real, bool); /// virtual SPxId selectEnter(Real& val, int, bool); //@} }; } // namespace soplex #endif // _SPXHARRISRT_H_
// // Copyright (c) 2017 Open Whisper Systems. All rights reserved. // #import "OWSViewController.h" NS_ASSUME_NONNULL_BEGIN extern const CGFloat kOWSTable_DefaultCellHeight; @class OWSTableItem; @class OWSTableSection; @interface OWSTableContents : NSObject @property (nonatomic) NSString *title; @property (nonatomic, nullable) NSInteger (^sectionForSectionIndexTitleBlock)(NSString *title, NSInteger index); @property (nonatomic, nullable) NSArray<NSString *> * (^sectionIndexTitlesForTableViewBlock)(void); @property (nonatomic, readonly) NSArray<OWSTableSection *> *sections; - (void)addSection:(OWSTableSection *)section; @end #pragma mark - @interface OWSTableSection : NSObject @property (nonatomic, nullable) NSString *headerTitle; @property (nonatomic, nullable) NSString *footerTitle; @property (nonatomic, nullable) UIView *customHeaderView; @property (nonatomic, nullable) UIView *customFooterView; @property (nonatomic, nullable) NSNumber *customHeaderHeight; @property (nonatomic, nullable) NSNumber *customFooterHeight; + (OWSTableSection *)sectionWithTitle:(nullable NSString *)title items:(NSArray<OWSTableItem *> *)items; - (void)addItem:(OWSTableItem *)item; - (NSUInteger)itemCount; @end #pragma mark - typedef NS_ENUM(NSInteger, OWSTableItemType) { OWSTableItemTypeDefault, OWSTableItemTypeAction, }; typedef void (^OWSTableActionBlock)(void); typedef UITableViewCell *_Nonnull (^OWSTableCustomCellBlock)(void); @interface OWSTableItem : NSObject + (OWSTableItem *)itemWithTitle:(NSString *)title actionBlock:(nullable OWSTableActionBlock)actionBlock; + (OWSTableItem *)itemWithCustomCell:(UITableViewCell *)customCell customRowHeight:(CGFloat)customRowHeight actionBlock:(nullable OWSTableActionBlock)actionBlock; + (OWSTableItem *)itemWithCustomCellBlock:(OWSTableCustomCellBlock)customCellBlock customRowHeight:(CGFloat)customRowHeight actionBlock:(nullable OWSTableActionBlock)actionBlock; + (OWSTableItem *)itemWithCustomCellBlock:(OWSTableCustomCellBlock)customCellBlock actionBlock:(nullable OWSTableActionBlock)actionBlock; + (OWSTableItem *)disclosureItemWithText:(NSString *)text actionBlock:(nullable OWSTableActionBlock)actionBlock; + (OWSTableItem *)disclosureItemWithText:(NSString *)text customRowHeight:(CGFloat)customRowHeight actionBlock:(nullable OWSTableActionBlock)actionBlock; + (OWSTableItem *)actionItemWithText:(NSString *)text actionBlock:(nullable OWSTableActionBlock)actionBlock; + (OWSTableItem *)softCenterLabelItemWithText:(NSString *)text; + (OWSTableItem *)softCenterLabelItemWithText:(NSString *)text customRowHeight:(CGFloat)customRowHeight; + (OWSTableItem *)labelItemWithText:(NSString *)text; + (OWSTableItem *)labelItemWithText:(NSString *)text accessoryText:(NSString *)accessoryText; + (OWSTableItem *)switchItemWithText:(NSString *)text isOn:(BOOL)isOn target:(id)target selector:(SEL)selector; + (OWSTableItem *)switchItemWithText:(NSString *)text isOn:(BOOL)isOn isEnabled:(BOOL)isEnabled target:(id)target selector:(SEL)selector; - (nullable UITableViewCell *)customCell; - (NSNumber *)customRowHeight; @end #pragma mark - @protocol OWSTableViewControllerDelegate <NSObject> - (void)tableViewWillBeginDragging; @end #pragma mark - @interface OWSTableViewController : OWSViewController @property (nonatomic, weak) id<OWSTableViewControllerDelegate> delegate; @property (nonatomic) OWSTableContents *contents; @property (nonatomic, readonly) UITableView *tableView; @property (nonatomic) UITableViewStyle tableViewStyle; #pragma mark - Presentation - (void)presentFromViewController:(UIViewController *)fromViewController; @end NS_ASSUME_NONNULL_END
// // StandardDefinitions.h // iSEPTA // // Created by septa on 11/16/12. // Copyright (c) 2012 SEPTA. All rights reserved. // #ifndef iSEPTA_StandardDefinitions_h #define iSEPTA_StandardDefinitions_h typedef NS_ENUM(NSInteger, ShowTimesButtonPressed) { kLeftButtonIsStart, kLeftButtonIsEnd, kLeftButtonIsUndefined, }; typedef NS_ENUM(NSInteger, ShowTimesLocationType) { kLocationOnlyHasStart, kLocationOnlyHasEnd, kLocationHasBoth, kLocationUndefined, }; #endif
/****************************************************************************** ** Copyright (c) 2006-2018, Calaos. All Rights Reserved. ** ** This file is part of Calaos. ** ** Calaos 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. ** ** Calaos 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, write to the Free Software ** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ** ******************************************************************************/ #ifndef S_INPUTTIMER_H #define S_INPUTTIMER_H #include "Calaos.h" #include "IOBase.h" #include "Timer.h" namespace Calaos { class InputTimer : public IOBase { protected: int hour, minute, second, ms; Timer *timer; string value; bool start; void StartTimer(); void StopTimer(); void TimerDone(); public: InputTimer(Params &prm); ~InputTimer(); //Input virtual DATA_TYPE get_type() { return TSTRING; } virtual string get_value_string() { return value; } //Output virtual bool set_value(string val); virtual void hasChanged(); }; } #endif
/* * uefi-ntfs: UEFI → NTFS/exFAT chain loader - System Information * Copyright © 2014-2021 Pete Batard <pete@akeo.ie> * With parts from EDK © 1998 Intel Corporation * * 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/>. */ #include "boot.h" /* * Read a system configuration table from a TableGuid. */ static EFI_STATUS GetSystemConfigurationTable(EFI_GUID* TableGuid, VOID** Table) { UINTN Index; V_ASSERT(Table != NULL); for (Index = 0; Index < gST->NumberOfTableEntries; Index++) { if (COMPARE_GUID(TableGuid, &(gST->ConfigurationTable[Index].VendorGuid))) { *Table = gST->ConfigurationTable[Index].VendorTable; return EFI_SUCCESS; } } return EFI_NOT_FOUND; } /* * Return SMBIOS string given the string number. * Arguments: * Smbios - Pointer to SMBIOS structure * StringNumber - String number to return. 0xFFFF can be used to skip all * strings and point to the next SMBIOS structure. * Returns: * Pointer to string, or pointer to next SMBIOS structure if StringNumber == 0xFFFF. */ static CHAR8* GetSmbiosString(SMBIOS_STRUCTURE_POINTER* Smbios, UINT16 StringNumber) { UINT16 Index; CHAR8* String; // Skip over formatted section String = (CHAR8*)(Smbios->Raw + Smbios->Hdr->Length); // Look through unformated section for (Index = 1; Index <= StringNumber; Index++) { if (StringNumber == Index) return String; // Skip string for (; *String != 0; String++); String++; if (*String == 0) { // If double NUL then we are done. // Return pointer to next structure in Smbios. // If you pass 0xFFFF for StringNumber you always get here. Smbios->Raw = (UINT8*)++String; return NULL; } } return NULL; } /* * Query SMBIOS to display some info about the system hardware and UEFI firmware. */ EFI_STATUS PrintSystemInfo(VOID) { EFI_STATUS Status; SMBIOS_STRUCTURE_POINTER Smbios; SMBIOS_TABLE_ENTRY_POINT* SmbiosTable; SMBIOS_TABLE_3_0_ENTRY_POINT* Smbios3Table; UINT8 Found = 0, *Raw; UINTN MaximumSize, ProcessedSize = 0; PrintInfo(L"UEFI v%d.%d (%s, 0x%08X)", gST->Hdr.Revision >> 16, gST->Hdr.Revision & 0xFFFF, gST->FirmwareVendor, gST->FirmwareRevision); Status = GetSystemConfigurationTable(&gEfiSmbios3TableGuid, (VOID**)&Smbios3Table); if (Status == EFI_SUCCESS) { Smbios.Hdr = (SMBIOS_STRUCTURE*)(UINTN)Smbios3Table->TableAddress; MaximumSize = (UINTN)Smbios3Table->TableMaximumSize; } else { Status = GetSystemConfigurationTable(&gEfiSmbiosTableGuid, (VOID**)&SmbiosTable); if (EFI_ERROR(Status)) return EFI_NOT_FOUND; Smbios.Hdr = (SMBIOS_STRUCTURE*)(UINTN)SmbiosTable->TableAddress; MaximumSize = (UINTN)SmbiosTable->TableLength; } // Sanity check if (MaximumSize > 1024 * 1024) { PrintWarning(L"Aborting system report due to unexpected SMBIOS table length (0x%08X)", MaximumSize); return EFI_ABORTED; } while ((Smbios.Hdr->Type != 0x7F) && (Found < 2)) { Raw = Smbios.Raw; if (Smbios.Hdr->Type == 0) { PrintInfo(L"%a %a", GetSmbiosString(&Smbios, Smbios.Type0->Vendor), GetSmbiosString(&Smbios, Smbios.Type0->BiosVersion)); Found++; } if (Smbios.Hdr->Type == 1) { PrintInfo(L"%a %a", GetSmbiosString(&Smbios, Smbios.Type1->Manufacturer), GetSmbiosString(&Smbios, Smbios.Type1->ProductName)); Found++; } GetSmbiosString(&Smbios, 0xFFFF); ProcessedSize += (UINTN)Smbios.Raw - (UINTN)Raw; if (ProcessedSize > MaximumSize) { PrintWarning(L"Aborting system report due to noncompliant SMBIOS"); return EFI_ABORTED; } } return EFI_SUCCESS; } /* * Query the Secure Boot related firmware variables. * Returns: * >0 if Secure Boot is enabled * 0 if Secure Boot is disabled * <0 if the system is in Setup Mode */ INTN GetSecureBootStatus(VOID) { UINT8 SecureBoot = 0, SetupMode = 0; UINTN Size; /* Tri-state status for Secure Boot: -1 = Setup, 0 = Disabled, 1 = Enabled */ INTN SecureBootStatus = 0; // Check if the SecureBoot variable exists Size = sizeof(SecureBoot); if (gRT->GetVariable(L"SecureBoot", &gEfiGlobalVariableGuid, NULL, &Size, &SecureBoot) == EFI_SUCCESS) { // The "SecureBoot" variable indicates whether the platform firmware // is operating in Secure Boot mode (1) or not (0). SecureBootStatus = (INTN)SecureBoot; // The "SetupMode" variable indicates whether the platform firmware // is operating in Secure Boot Setup Mode (1) or not (0). Size = sizeof(SetupMode); if ((gRT->GetVariable(L"SetupMode", &gEfiGlobalVariableGuid, NULL, &Size, &SetupMode) == EFI_SUCCESS) && (SetupMode != 0)) SecureBootStatus = -1; } return SecureBootStatus; }
/* ISO C9x 7.18 Integer types <stdint.h> * Based on ISO/IEC SC22/WG14 9899 Committee draft (SC22 N2794) * * THIS SOFTWARE IS NOT COPYRIGHTED * * Contributor: Danny Smith <danny_r_smith_2001@yahoo.co.nz> * * This source code is offered for use in the public domain. You may * use, modify or distribute it freely. * * This code is distributed in the hope that it will be useful but * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY * DISCLAIMED. This includes but is not limited to warranties of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * Date: 2000-12-02 */ #ifdef __GNUC__ # include <stdint.h> #else #ifndef MYSTDINT_H #define MYSTDINT_H #define __need_wint_t #define __need_wchar_t #include <stddef.h> /* 7.18.1.1 Exact-width integer types */ typedef signed char int8_t; typedef unsigned char uint8_t; typedef short int16_t; typedef unsigned short uint16_t; typedef int int32_t; typedef unsigned uint32_t; typedef long long int64_t; typedef unsigned long long uint64_t; /* 7.18.1.2 Minimum-width integer types */ typedef signed char int_least8_t; typedef unsigned char uint_least8_t; typedef short int_least16_t; typedef unsigned short uint_least16_t; typedef int int_least32_t; typedef unsigned uint_least32_t; typedef long long int_least64_t; typedef unsigned long long uint_least64_t; /* 7.18.1.3 Fastest minimum-width integer types * Not actually guaranteed to be fastest for all purposes * Here we use the exact-width types for 8 and 16-bit ints. */ typedef char int_fast8_t; typedef unsigned char uint_fast8_t; typedef short int_fast16_t; typedef unsigned short uint_fast16_t; typedef int int_fast32_t; typedef unsigned int uint_fast32_t; typedef long long int_fast64_t; typedef unsigned long long uint_fast64_t; /* 7.18.1.4 Integer types capable of holding object pointers */ typedef int intptr_t; typedef unsigned uintptr_t; /* 7.18.1.5 Greatest-width integer types */ typedef long long intmax_t; typedef unsigned long long uintmax_t; /* 7.18.2 Limits of specified-width integer types */ #if !defined ( __cplusplus) || defined (__STDC_LIMIT_MACROS) /* 7.18.2.1 Limits of exact-width integer types */ #define INT8_MIN (-128) #define INT16_MIN (-32768) #define INT32_MIN (-2147483647 - 1) #define INT64_MIN (-9223372036854775807LL - 1) #define INT8_MAX 127 #define INT16_MAX 32767 #define INT32_MAX 2147483647 #define INT64_MAX 9223372036854775807LL #define UINT8_MAX 0xff /* 255U */ #define UINT16_MAX 0xffff /* 65535U */ #define UINT32_MAX 0xffffffff /* 4294967295U */ #define UINT64_MAX 0xffffffffffffffffULL /* 18446744073709551615ULL */ /* 7.18.2.2 Limits of minimum-width integer types */ #define INT_LEAST8_MIN INT8_MIN #define INT_LEAST16_MIN INT16_MIN #define INT_LEAST32_MIN INT32_MIN #define INT_LEAST64_MIN INT64_MIN #define INT_LEAST8_MAX INT8_MAX #define INT_LEAST16_MAX INT16_MAX #define INT_LEAST32_MAX INT32_MAX #define INT_LEAST64_MAX INT64_MAX #define UINT_LEAST8_MAX UINT8_MAX #define UINT_LEAST16_MAX UINT16_MAX #define UINT_LEAST32_MAX UINT32_MAX #define UINT_LEAST64_MAX UINT64_MAX /* 7.18.2.3 Limits of fastest minimum-width integer types */ #define INT_FAST8_MIN INT8_MIN #define INT_FAST16_MIN INT16_MIN #define INT_FAST32_MIN INT32_MIN #define INT_FAST64_MIN INT64_MIN #define INT_FAST8_MAX INT8_MAX #define INT_FAST16_MAX INT16_MAX #define INT_FAST32_MAX INT32_MAX #define INT_FAST64_MAX INT64_MAX #define UINT_FAST8_MAX UINT8_MAX #define UINT_FAST16_MAX UINT16_MAX #define UINT_FAST32_MAX UINT32_MAX #define UINT_FAST64_MAX UINT64_MAX /* 7.18.2.4 Limits of integer types capable of holding object pointers */ #define INTPTR_MIN INT32_MIN #define INTPTR_MAX INT32_MAX #define UINTPTR_MAX UINT32_MAX /* 7.18.2.5 Limits of greatest-width integer types */ #define INTMAX_MIN INT64_MIN #define INTMAX_MAX INT64_MAX #define UINTMAX_MAX UINT64_MAX /* 7.18.3 Limits of other integer types */ #define PTRDIFF_MIN INT32_MIN #define PTRDIFF_MAX INT32_MAX #define SIG_ATOMIC_MIN INT32_MIN #define SIG_ATOMIC_MAX INT32_MAX #define SIZE_MAX UINT32_MAX #ifndef WCHAR_MIN /* also in wchar.h */ #define WCHAR_MIN 0 #define WCHAR_MAX 0xffff /* UINT16_MAX */ #endif /* * wint_t is unsigned short for compatibility with MS runtime */ #define WINT_MIN 0 #define WINT_MAX 0xffff /* UINT16_MAX */ #endif /* !defined ( __cplusplus) || defined __STDC_LIMIT_MACROS */ /* 7.18.4 Macros for integer constants */ #if !defined ( __cplusplus) || defined (__STDC_CONSTANT_MACROS) /* 7.18.4.1 Macros for minimum-width integer constants Accoding to Douglas Gwyn <gwyn@arl.mil>: "This spec was changed in ISO/IEC 9899:1999 TC1; in ISO/IEC 9899:1999 as initially published, the expansion was required to be an integer constant of precisely matching type, which is impossible to accomplish for the shorter types on most platforms, because C99 provides no standard way to designate an integer constant with width less than that of type int. TC1 changed this to require just an integer constant *expression* with *promoted* type." */ #define INT8_C(val) ((int8_t) + (val)) #define UINT8_C(val) ((uint8_t) + (val##U)) #define INT16_C(val) ((int16_t) + (val)) #define UINT16_C(val) ((uint16_t) + (val##U)) #define INT32_C(val) val##L #define UINT32_C(val) val##UL #define INT64_C(val) val##LL #define UINT64_C(val) val##ULL /* 7.18.4.2 Macros for greatest-width integer constants */ #define INTMAX_C(val) INT64_C(val) #define UINTMAX_C(val) UINT64_C(val) #endif /* !defined ( __cplusplus) || defined __STDC_CONSTANT_MACROS */ #endif #endif /* !__GNUC__ */
// ************************************************************************* // This file is part of Life, Death, and the Objective ("LDO") // a simple squad-tactics strategy game by Steaphan Greene // // Copyright 2005-2008 Steaphan Greene <stea@cs.binghamton.edu> // // LDO 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. // // LDO 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 LDO (see the file named "COPYING"); // If not, see <http://www.gnu.org/licenses/>. // // ************************************************************************* #ifndef UNIT_H #define UNIT_H enum Attrib { // List of Attributes ATTRIB_B = 0, // Body ATTRIB_Q, // Quickness ATTRIB_S, // Strength ATTRIB_C, // Charisma ATTRIB_I, // Intelligence ATTRIB_W, // Willpower ATTRIB_MAX }; enum Skill { // List of Skills SKILL_RIFLE = 0, SKILL_PISTOL, SKILL_SMG, SKILL_ASSAULT, // Assault Rifles SKILL_THROW, SKILL_HEAVY, // Heavy Weapons SKILL_LEADERSHIP, SKILL_PERCEPTION, SKILL_FIRSTAID, SKILL_STEALTH, SKILL_MAX, SKILL_COMBAT_MAX = SKILL_LEADERSHIP }; enum Item { // List of Items ITEM_NONE = -1, ITEM_LIGHTA, // Light Armor ITEM_MEDIUMA, // Medium Armor ITEM_HEAVYA, // Heavy Armor ITEM_PISTOL, ITEM_SMG, ITEM_RIFLE, ITEM_ASSAULT, // Assault Rifle ITEM_HEAVYW, // Heavy Weapon ITEM_GRENADE, ITEM_MEDKIT, ITEM_STREASURE, // Small Treasure ITEM_TREASURE, // Treasure ITEM_LTREASURE, // Large Treasure ITEM_MAX, ITEM_ARMOR_MAX = ITEM_PISTOL, ITEM_WEAPON_MAX = ITEM_GRENADE }; enum Locations { // List of Locations on Unit for Equipment LOC_NONE = -1, LOC_RSHOULD, // Right Shoulder LOC_LSHOULD, // Left Shoulder LOC_RHAND, // Right Hand LOC_LHAND, // Left Hand LOC_RLEG, // Right Leg LOC_LLEG, // Left Leg LOC_BELT, LOC_PACK, // Backpack LOC_MAX }; #include <cstdio> #include <string> #include <vector> using namespace std; class Unit { public: Unit(); int Load(FILE *f, unsigned int ver); int Save(FILE *f); int id; int troop; string name; char attribs[ATTRIB_MAX]; char skills[SKILL_MAX]; vector<Item> items[LOC_MAX]; }; #endif // UNIT_H
#ifndef __AT_COMMON_H #include <modem/types.h> #include "queue.h" /*------------------------------------------------------------------------*/ modem_cpin_state_t at_cpin_state(modem_t* modem); /*------------------------------------------------------------------------*/ int at_cpin_pin(modem_t* modem, const char* pin); /*------------------------------------------------------------------------*/ int at_cpin_puk(modem_t* modem, const char* puk, const char* pin); /*------------------------------------------------------------------------*/ /** * @brief execute AT command on modem * @param modem modem that support AT queue * @param cmd AT command * @return zero if no errors */ int at_raw_ok(modem_t* modem, const char* cmd); /*------------------------------------------------------------------------*/ char* at_get_imsi(modem_t* modem, char* imsi, size_t len); /*------------------------------------------------------------------------*/ char* at_get_imei(modem_t* modem, char* imsi, size_t len); /*------------------------------------------------------------------------*/ int at_operator_scan(modem_t* modem, modem_oper_t** opers); /*------------------------------------------------------------------------*/ modem_network_reg_t at_network_registration(modem_t* modem); /*------------------------------------------------------------------------*/ modem_cops_mode_t at_cops_mode(modem_t* modem); /*------------------------------------------------------------------------*/ int at_get_signal_quality(modem_t* modem, modem_signal_quality_t* sq); /*------------------------------------------------------------------------*/ modem_fw_ver_t* at_get_fw_version(modem_t* modem, modem_fw_ver_t* fw_info); /*------------------------------------------------------------------------*/ char* mc77x0_at_get_network_type(modem_t* modem, char* network, size_t len); /*------------------------------------------------------------------------*/ char* at_get_operator_name(modem_t* modem, char* oper, size_t len); /*------------------------------------------------------------------------*/ char* at_get_operator_number(modem_t* modem, char* oper_number, size_t len); /*------------------------------------------------------------------------*/ int at_change_pin(modem_t* modem, const char* old_pin, const char* new_pin); /*------------------------------------------------------------------------*/ int at_operator_select(modem_t* modem, int hni, modem_oper_act_t act); /*------------------------------------------------------------------------*/ int at_set_wwan_profile(modem_t* modem, modem_data_profile_t* profile); /*------------------------------------------------------------------------*/ char* at_ussd_cmd(modem_t* modem, const char* query); #endif /* __AT_COMMON_H */
/* Copyright (C) 2005-2012 by George Williams */ /* * 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. * The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _GROUPS_H #define _GROUPS_H typedef struct ffgroup { char *name; /* The name of this group (utf8) */ struct ffgroup *parent; /* parent of this group (NULL for group root) */ int kid_cnt; /* Number of sub-groups */ struct ffgroup **kids; /* The sub-groups */ char *glyphs; /* Or, if a terminal node, a list of glyph names/Unicodes */ unsigned int unique: 1; /* If set => set in all kids & a glyph name may only appear once in all terminal groups */ /* Used by the dialog */ unsigned int open: 1; unsigned int selected : 1; int lpos; } Group; extern Group *group_root; struct fontview; void SaveGroupList(void); void LoadGroupList(void); Group *GroupCopy(Group *g); void GroupFree(Group *g); #endif
/******************************************************************************* * XLineRenderer.h * * Copyright (c) Moreno Seri (moreno.seri@gmail.com) * * This file is part of XLib. * * XLib 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. * * XLib 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 XLineRenderer_h #define XLineRenderer_h #include "XRenderer.h" /// Bresenham line coordinates helper class XLineRenderer : public XRenderer { public: /// Constructor /// @param a First location /// @param b Second location XLineRenderer(XPoint a = XPoint(), XPoint b = XPoint()); /// Inits the helper with new locations /// @param a First location /// @param b Second location void Init(XPoint a, XPoint b); /// Calculates next quadrant point virtual bool Next() override; private: /// X change int16_t m_dx; /// Y change int16_t m_dy; /// Slope error int16_t m_e; /// X increment int16_t m_xi; /// Y increment int16_t m_yi; /// First location XPoint m_a; /// Second location XPoint m_b; // Delete copy constructor and assignment operator XLineRenderer(const XLineRenderer&) = delete; XLineRenderer& operator=(const XLineRenderer&) = delete; }; #endif
#ifndef BBOX_H #define BBOX_H // bbox.h // Bounding box implementation. #include "util.h" #include "vector.h" /************** * Structures * **************/ // A bounding box: struct bbox_s; typedef struct bbox_s bbox; /************************* * Structure Definitions * *************************/ struct bbox_s { vector min; vector max; }; /******************** * Inline Functions * ********************/ // Computes a bounding box centered at the given origin with x/y/z sizes given // as the size vector. Stores the results in the given bounding box. static inline void compute_bbox(vector origin, vector size, bbox *box) { box->min.x = origin.x - (size.x/2.0); box->min.y = origin.y - (size.y/2.0); box->min.z = origin.z - (size.z/2.0); box->max.x = origin.x + (size.x/2.0); box->max.y = origin.y + (size.y/2.0); box->max.z = origin.z + (size.z/2.0); } // Returns 1 if boxes b1 and b2 intersect, and 0 otherwise: static inline int intersects(bbox b1, bbox b2) { return ( (b1.min.x <= b2.max.x) && (b2.min.x <= b1.max.x) && (b1.min.y <= b2.max.y) && (b2.min.y <= b1.max.y) && (b1.min.z <= b2.max.z) && (b2.min.z <= b1.max.z) ); } // Integer min/max coordinates of the box: static inline int b_i_min_x(bbox b) { return fastfloor(b.min.x); } static inline int b_i_max_x(bbox b) { return fastfloor(b.max.x); } static inline int b_i_min_y(bbox b) { return fastfloor(b.min.y); } static inline int b_i_max_y(bbox b) { return fastfloor(b.max.y); } static inline int b_i_min_z(bbox b) { return fastfloor(b.min.z); } static inline int b_i_max_z(bbox b) { return fastfloor(b.max.z); } #endif //ifndef BBOX_H
/* * Copyright (C) 2003-2020 Sébastien Helleu <flashcode@flashtux.org> * * This file is part of WeeChat, the extensible chat client. * * WeeChat 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. * * WeeChat 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 WeeChat. If not, see <https://www.gnu.org/licenses/>. */ #ifndef WEECHAT_DEBUG_H #define WEECHAT_DEBUG_H struct t_gui_window_tree; extern void debug_sigsegv (); extern void debug_windows_tree (); extern void debug_memory (); extern void debug_hdata (); extern void debug_hooks (); extern void debug_infolists (); extern void debug_directories (); extern void debug_display_time_elapsed (struct timeval *time1, struct timeval *time2, const char *message, int display); extern void debug_init (); extern void debug_end (); #endif /* WEECHAT_DEBUG_H */
// Check that we run dsymutil properly with multiple -arch options. // // RUN: %clang -ccc-host-triple x86_64-apple-darwin10 -ccc-print-phases \ // RUN: -arch i386 -arch x86_64 %s -g 2> %t // RUN: FileCheck -check-prefix=CHECK-MULTIARCH-ACTIONS < %t %s // // CHECK-MULTIARCH-ACTIONS: 0: input, "{{.*}}darwin-dsymutil.c", c // CHECK-MULTIARCH-ACTIONS: 1: preprocessor, {0}, cpp-output // CHECK-MULTIARCH-ACTIONS: 2: compiler, {1}, assembler // CHECK-MULTIARCH-ACTIONS: 3: assembler, {2}, object // CHECK-MULTIARCH-ACTIONS: 4: linker, {3}, image // CHECK-MULTIARCH-ACTIONS: 5: bind-arch, "i386", {4}, image // CHECK-MULTIARCH-ACTIONS: 6: bind-arch, "x86_64", {4}, image // CHECK-MULTIARCH-ACTIONS: 7: lipo, {5, 6}, image // CHECK-MULTIARCH-ACTIONS: 8: dsymutil, {7}, dSYM // // RUN: %clang -ccc-host-triple x86_64-apple-darwin10 -ccc-print-bindings \ // RUN: -arch i386 -arch x86_64 %s -g 2> %t // RUN: FileCheck -check-prefix=CHECK-MULTIARCH-BINDINGS < %t %s // // CHECK-MULTIARCH-BINDINGS: "x86_64-apple-darwin10" - "darwin::Lipo", inputs: [{{.*}}, {{.*}}], output: "a.out" // CHECK-MULTIARCH-BINDINGS: # "x86_64-apple-darwin10" - "darwin::Dsymutil", inputs: ["a.out"], output: "a.out.dSYM" // Check output name derivation. // // RUN: %clang -ccc-host-triple x86_64-apple-darwin10 -ccc-print-bindings \ // RUN: -o foo %s -g 2> %t // RUN: FileCheck -check-prefix=CHECK-OUTPUT-NAME < %t %s // // CHECK-OUTPUT-NAME: "x86_64-apple-darwin10" - "darwin::Link", inputs: [{{.*}}], output: "foo" // CHECK-OUTPUT-NAME: "x86_64-apple-darwin10" - "darwin::Dsymutil", inputs: ["foo"], output: "foo.dSYM" // Check that we only use dsymutil when needed. // // RUN: touch %t.o // RUN: %clang -ccc-host-triple x86_64-apple-darwin10 -ccc-print-bindings \ // RUN: -o foo %t.o -g 2> %t // RUN: grep "Dsymutil" %t | count 0
#ifndef __DUMMYARM_CALIBRATION_H #define __DUMMYARM_CALIBRATION_H extern "C" { #define SERIAL_BAUDRATE 115200 #define PWM_DRIVER_I2C_ADDRESS 0x40 #define PWM_DRIVER_FREQ 60 struct arm_segment_config { const char *name; struct servo_config *servo; double length; /*!< millimeters */ }; struct servo_config { /*! * \brief servo name * 'A', 'B', ... ; '\0' for end of list. * Used mostly for debugging */ const char name; int pin; /*!< pin number on the Adafruit PWM shield */ struct { double min; /*!< unit is radian */ double max; /*!< unit is radian */ } angle; struct { int min; /*!< see Adafruit_PWMServoDriver.h for unit */ int max; /*!< see Adafruit_PWMServoDriver.h for unit */ } pwm; }; enum servo_idx { /*! * \brief base servo, controlling rotation of the whole arm * Usually a MG995. */ SERVO_A = 0, /*! * \brief servo controlling angle of the first arm segment * min = arm flat to the ground. * Usually a MG995. */ SERVO_B, /*! * \brief servo controlling angle of the second arm segment depending on the first segment * min = arm flat to the ground. * Usually a MG995. */ SERVO_C, /*! * \brief servo controlling grip * min = closed ; max = fully opened. * Usually a SG90. */ SERVO_G, SERVO_END = SERVO_G, }; enum arm_segment_idx { ARM_SEGMENT_AB = 0, ARM_SEGMENT_BC = 1, ARM_SEGMENT_END = ARM_SEGMENT_BC, }; extern struct arm_segment_config g_arm_segment_config[]; extern struct servo_config g_servo_config[]; } #endif
/** * Orthanc - A Lightweight, RESTful DICOM Store * Copyright (C) 2012-2015 Sebastien Jodogne, Medical Physics * Department, University Hospital of Liege, Belgium * * 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. * * In addition, as a special exception, the copyright holders of this * program give permission to link the code of its release with the * OpenSSL project's "OpenSSL" library (or with modified versions of it * that use the same license as the "OpenSSL" library), and distribute * the linked executables. You must obey the GNU General Public License * in all respects for all of the code used other than "OpenSSL". If you * modify file(s) with this exception, you may extend this exception to * your version of the file(s), but you are not obligated to do so. If * you do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source files * in the program, then also delete it here. * * 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 <iostream> namespace Orthanc { namespace Logging { void Initialize(); void Finalize(); void EnableInfoLevel(bool enabled); void EnableTraceLevel(bool enabled); void SetTargetFolder(const std::string& path); struct NullStream : public std::ostream { NullStream() : std::ios(0), std::ostream(0) { } std::ostream& operator<< (const std::string& message) { return *this; } }; } } #if ORTHANC_ENABLE_LOGGING != 1 # define LOG(level) ::Orthanc::Logging::NullStream() # define VLOG(level) ::Orthanc::Logging::NullStream() #else /* ORTHANC_ENABLE_LOGGING == 1 */ #if ORTHANC_ENABLE_GOOGLE_LOG == 1 # include <stdlib.h> // Including this fixes a problem in glog for recent releases of MinGW # include <glog/logging.h> #else # include <boost/thread/mutex.hpp> # define LOG(level) ::Orthanc::Logging::InternalLogger(#level, __FILE__, __LINE__) # define VLOG(level) ::Orthanc::Logging::InternalLogger("TRACE", __FILE__, __LINE__) #endif #if ORTHANC_ENABLE_GOOGLE_LOG != 1 namespace Orthanc { namespace Logging { class InternalLogger { private: boost::mutex::scoped_lock lock_; NullStream null_; std::ostream* stream_; public: InternalLogger(const char* level, const char* file, int line); ~InternalLogger(); std::ostream& operator<< (const std::string& message) { return (*stream_) << message; } }; } } #endif #endif // ORTHANC_ENABLE_LOGGING
/* Copyright (C) 1994-2012 John W. Eaton This file is part of Octave. Octave 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. Octave 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 Octave; see the file COPYING. If not, see <http://www.gnu.org/licenses/>. */ #if !defined (octave_FloatComplexDiagMatrix_h) #define octave_FloatComplexDiagMatrix_h 1 #include "MDiagArray2.h" #include "fRowVector.h" #include "fCRowVector.h" #include "fColVector.h" #include "fCColVector.h" #include "DET.h" #include "mx-defs.h" class OCTAVE_API FloatComplexDiagMatrix : public MDiagArray2<FloatComplex> { public: FloatComplexDiagMatrix (void) : MDiagArray2<FloatComplex> () { } FloatComplexDiagMatrix (octave_idx_type r, octave_idx_type c) : MDiagArray2<FloatComplex> (r, c) { } FloatComplexDiagMatrix (octave_idx_type r, octave_idx_type c, const FloatComplex& val) : MDiagArray2<FloatComplex> (r, c, val) { } explicit FloatComplexDiagMatrix (const Array<FloatComplex>& a) : MDiagArray2<FloatComplex> (a) { } FloatComplexDiagMatrix (const Array<FloatComplex>& a, octave_idx_type r, octave_idx_type c) : MDiagArray2<FloatComplex> (a, r, c) { } explicit FloatComplexDiagMatrix (const Array<float>& a) : MDiagArray2<FloatComplex> (Array<FloatComplex> (a)) { } explicit FloatComplexDiagMatrix (const FloatDiagMatrix& a); FloatComplexDiagMatrix (const MDiagArray2<FloatComplex>& a) : MDiagArray2<FloatComplex> (a) { } FloatComplexDiagMatrix (const FloatComplexDiagMatrix& a) : MDiagArray2<FloatComplex> (a) { } template <class U> FloatComplexDiagMatrix (const DiagArray2<U>& a) : MDiagArray2<FloatComplex> (a) { } FloatComplexDiagMatrix& operator = (const FloatComplexDiagMatrix& a) { MDiagArray2<FloatComplex>::operator = (a); return *this; } bool operator == (const FloatComplexDiagMatrix& a) const; bool operator != (const FloatComplexDiagMatrix& a) const; FloatComplexDiagMatrix& fill (float val); FloatComplexDiagMatrix& fill (const FloatComplex& val); FloatComplexDiagMatrix& fill (float val, octave_idx_type beg, octave_idx_type end); FloatComplexDiagMatrix& fill (const FloatComplex& val, octave_idx_type beg, octave_idx_type end); FloatComplexDiagMatrix& fill (const FloatColumnVector& a); FloatComplexDiagMatrix& fill (const FloatComplexColumnVector& a); FloatComplexDiagMatrix& fill (const FloatRowVector& a); FloatComplexDiagMatrix& fill (const FloatComplexRowVector& a); FloatComplexDiagMatrix& fill (const FloatColumnVector& a, octave_idx_type beg); FloatComplexDiagMatrix& fill (const FloatComplexColumnVector& a, octave_idx_type beg); FloatComplexDiagMatrix& fill (const FloatRowVector& a, octave_idx_type beg); FloatComplexDiagMatrix& fill (const FloatComplexRowVector& a, octave_idx_type beg); FloatComplexDiagMatrix hermitian (void) const { return MDiagArray2<FloatComplex>::hermitian (std::conj); } FloatComplexDiagMatrix transpose (void) const { return MDiagArray2<FloatComplex>::transpose (); } FloatDiagMatrix abs (void) const; friend OCTAVE_API FloatComplexDiagMatrix conj (const FloatComplexDiagMatrix& a); // resize is the destructive analog for this one FloatComplexMatrix extract (octave_idx_type r1, octave_idx_type c1, octave_idx_type r2, octave_idx_type c2) const; // extract row or column i FloatComplexRowVector row (octave_idx_type i) const; FloatComplexRowVector row (char *s) const; FloatComplexColumnVector column (octave_idx_type i) const; FloatComplexColumnVector column (char *s) const; FloatComplexDiagMatrix inverse (octave_idx_type& info) const; FloatComplexDiagMatrix inverse (void) const; FloatComplexDiagMatrix pseudo_inverse (void) const; bool all_elements_are_real (void) const; // diagonal matrix by diagonal matrix -> diagonal matrix operations FloatComplexDiagMatrix& operator += (const FloatDiagMatrix& a); FloatComplexDiagMatrix& operator -= (const FloatDiagMatrix& a); // other operations FloatComplexColumnVector extract_diag (octave_idx_type k = 0) const { return MDiagArray2<FloatComplex>::extract_diag (k); } FloatComplexDET determinant (void) const; float rcond (void) const; // i/o friend std::ostream& operator << (std::ostream& os, const FloatComplexDiagMatrix& a); }; OCTAVE_API FloatComplexDiagMatrix conj (const FloatComplexDiagMatrix& a); // diagonal matrix by diagonal matrix -> diagonal matrix operations OCTAVE_API FloatComplexDiagMatrix operator * (const FloatComplexDiagMatrix& a, const FloatComplexDiagMatrix& b); OCTAVE_API FloatComplexDiagMatrix operator * (const FloatComplexDiagMatrix& a, const FloatDiagMatrix& b); OCTAVE_API FloatComplexDiagMatrix operator * (const FloatDiagMatrix& a, const FloatComplexDiagMatrix& b); MDIAGARRAY2_FORWARD_DEFS (MDiagArray2, FloatComplexDiagMatrix, FloatComplex) #endif
#pragma once #include <mutex> #include "cluster.h" #ifdef BOOST #include <boost/container/vector.hpp> #else #include <vector> using namespace std; #endif class ccbc_context { public: ccbc_context(uint32_t p_SMin, TCluster & p_Cluster, const vector<uint32_t> & m_IdxList, double p_Threshold); ~ccbc_context(void); // multithreading indexes and mutex std::mutex m_IdxMutex; // lock access // members set from ctor parameters uint32_t m_NextIdx; // the next sequence index to process TCluster & m_Cluster; // the cluster to compute double m_Threshold; const vector<uint32_t> & m_IdxList; // the index of the sequences to process // computed in OperatorCcbc1 : nothing, it is just calling ref->InitRef() for each sequence // computed by OperatorCcbc2 : double_matrix m_Sims; // the similarities // computed by the main thread : vector<uint32_t> m_GroupIndexes; // use a vector to keep in mind the group of each sequence void ReadBLastResult(std::string p_filename); private: explicit ccbc_context(const ccbc_context & srce) = delete; ccbc_context & operator=(const ccbc_context &) = delete; // avoid implicit assignement operator };
/** * Wrapping PB CodedOutputStream, so that it is simply usable by both native and * SWIG modules. */ #ifndef _LIB_PROCESSING_ENGINE_RESOURCE_OUTPUT_STREAM_TEXT_H_ #define _LIB_PROCESSING_ENGINE_RESOURCE_OUTPUT_STREAM_TEXT_H_ #include <config.h> #include <limits> #include <string> #include <google/protobuf/text_format.h> #include <log4cxx/logger.h> #include "Resource.h" #include "ResourceOutputStream.h" class ResourceOutputStreamText : public ResourceOutputStream { public: ResourceOutputStreamText(std::ostream *os); ~ResourceOutputStreamText() {}; void WriteString(const std::string &buffer); void WriteLittleEndian32(uint32_t value); void WriteVarint32(uint32_t value); void WriteLittleEndian64(uint64_t value); void WriteVarint64(uint64_t value); void WriteRaw(const char *data, int size); void SerializeMessage(google::protobuf::Message &msg, bool saveSize = true); private: std::ostream *os; google::protobuf::TextFormat::Printer printer; }; inline ResourceOutputStreamText::ResourceOutputStreamText(std::ostream *os) { this->os = os; printer.SetSingleLineMode(true); printer.SetUseShortRepeatedPrimitives(true); } inline void ResourceOutputStreamText::WriteString(const std::string &buffer) { std::string s(buffer); // replace all backslashes by double-backslashes replace_all(s, "\\", "\\\\"); // replace newlines by \n replace_all(s, "\n", "\\n"); *os << s << "\n"; } inline void ResourceOutputStreamText::WriteLittleEndian32(uint32_t value) { *os << value << "\n"; } inline void ResourceOutputStreamText::WriteVarint32(uint32_t value) { *os << value << "\n"; } inline void ResourceOutputStreamText::WriteLittleEndian64(uint64_t value) { *os << value << "\n"; } inline void ResourceOutputStreamText::WriteVarint64(uint64_t value) { *os << value << "\n"; } inline void ResourceOutputStreamText::WriteRaw(const char *data, int size) { os->write(data, size); *os << "\n"; } inline void ResourceOutputStreamText::SerializeMessage(google::protobuf::Message &msg, bool saveSize) { std::string s; printer.PrintToString(msg, &s); *os << s << "\n"; } #endif
/* This file is part of GNUnet (C) 2008--2012 Christian Grothoff (and other contributing authors) GNUnet 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. GNUnet 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 GNUnet; see the file COPYING. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /** * @file testbed/testbed_api_operations.h * @brief internal API to access the 'operations' subsystem * @author Christian Grothoff */ #ifndef NEW_TESTING_API_OPERATIONS_H #define NEW_TESTING_API_OPERATIONS_H #include "gnunet_testbed_service.h" #include "gnunet_helper_lib.h" /** * Queue of operations where we can only support a certain * number of concurrent operations of a particular type. */ struct OperationQueue; /** * Create an operation queue. * * @param max_active maximum number of operations in this * queue that can be active in parallel at the same time * @return handle to the queue */ struct OperationQueue * GNUNET_TESTBED_operation_queue_create_ (unsigned int max_active); /** * Destroy an operation queue. The queue MUST be empty * at this time. * * @param queue queue to destroy */ void GNUNET_TESTBED_operation_queue_destroy_ (struct OperationQueue *queue); /** * Add an operation to a queue. An operation can be in multiple * queues at once. Once all queues permit the operation to become * active, the operation will be activated. The actual activation * will occur in a separate task (thus allowing multiple queue * insertions to be made without having the first one instantly * trigger the operation if the first queue has sufficient * resources). * * @param queue queue to add the operation to * @param operation operation to add to the queue */ void GNUNET_TESTBED_operation_queue_insert_ (struct OperationQueue *queue, struct GNUNET_TESTBED_Operation *operation); /** * Remove an operation from a queue. This can be because the * oeration was active and has completed (and the resources have * been released), or because the operation was cancelled and * thus scheduling the operation is no longer required. * * @param queue queue to add the operation to * @param operation operation to add to the queue */ void GNUNET_TESTBED_operation_queue_remove_ (struct OperationQueue *queue, struct GNUNET_TESTBED_Operation *operation); /** * Function to call to start an operation once all * queues the operation is part of declare that the * operation can be activated. */ typedef void (*OperationStart)(void *cls); /** * Function to call to cancel an operation (release all associated * resources). This can be because of a call to * "GNUNET_TESTBED_operation_cancel" (before the operation generated * an event) or AFTER the operation generated an event due to a call * to "GNUNET_TESTBED_operation_done". Thus it is not guaranteed that * a callback to the 'OperationStart' preceeds the call to * 'OperationRelease'. Implementations of this function are expected * to clean up whatever state is in 'cls' and release all resources * associated with the operation. */ typedef void (*OperationRelease)(void *cls); /** * Create an 'operation' to be performed. * * @param cls closure for the callbacks * @param start function to call to start the operation * @param release function to call to close down the operation * @param ... FIXME * @return handle to the operation */ struct GNUNET_TESTBED_Operation * GNUNET_TESTBED_operation_create_ (void *cls, OperationStart start, OperationRelease release, ...); #endif /* end of testbed_api_operations.h */
// // CHNNotFoundError.h // // Auther: // ned rihine <ned.rihine@gmail.com> // // Copyright (c) 2012 rihine All rights reserved. // // 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 coreHezelnut_CHNNotFoundError_h #define coreHezelnut_CHNNotFoundError_h #include "coreHezelnut/classes/CHNError.h" CHN_EXTERN_C_BEGIN /*! * */ CHN_EXPORT id CHNNotFoundError_signalOn(id sender); /*! * */ CHN_EXPORT id CHNNotFoundError_signalOn_what(id sender, CHNString_ref message); CHN_EXTERN_C_END #endif /* coreHezelnut_CHNNotFoundError_h */
// // CCS3BlockingConnection.h // Replicate // // Created by Alex Zepeda on 8/7/14. // Copyright (c) 2014 Inferior Human Organs, Inc. All rights reserved. // #import <Foundation/Foundation.h> #import "CCS3Semaphore.h" @interface CCS3BlockingConnection : NSObject<NSURLConnectionDelegate> @property CCS3Semaphore *lock; @property NSInteger responseStatusCode; - (id)initWithRequest:(NSURLRequest *)aUrl andCallback:(void(^)(NSData* data))aCallback; + (NSInteger) connectionWithURL:(NSURL*) url callback:(void(^)(NSData* data)) callback; + (NSInteger) connectionWithRequest:(NSURLRequest *)aRequest callback:(void(^)(NSData* data))aCallback; @end
/* Exciting Licence Info..... This file is part of FingerprinTLS. FingerprinTLS 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. FingerprinTLS 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 FingerprinTLS. If not, see <http://www.gnu.org/licenses/>. Exciting Licence Info Addendum..... FingerprinTLS is additionally released under the "don't judge me" program whereby it is forbidden to rip into me too harshly for programming mistakes, kthnxbai. */ /* This File Is To Cope With Signal Handling Routines */ void sig_handler (int signo); /* Function registers all the signals to the sig_handler function */ int register_signals() { if (signal(SIGUSR1, sig_handler) == SIG_ERR) return 0; if (signal(SIGUSR2, sig_handler) == SIG_ERR) return 0; if (signal(SIGINT, sig_handler) == SIG_ERR) return 0; return 1; } /* Handles a variety of signals being received */ void sig_handler (int signo) { struct pcap_stat pstats; extern FILE *json_fd; extern pcap_t *handle; /* packet capture handle */ extern pcap_dumper_t *output_handle; extern struct bpf_program fp; /* compiled filter program (expression) */ switch (signo) { /* Placeholder, will use this for some debugging */ case SIGUSR1: // This is where code goes :) break; /* Someone has ctrl-c'd the process.... deal */ case SIGINT: // Get some stats on the session if(!(pcap_stats(handle, &pstats))) { printf("Processed %i%% Of Packets\n", (int) (( (float)((float)pstats.ps_recv - (float)pstats.ps_drop) / (float) pstats.ps_recv) * 100) ); printf("Received: %i\n", pstats.ps_recv); printf("Dropped: %i\n", pstats.ps_drop); } /* Stop the pcap loop */ pcap_breakloop(handle); // Close File Pointers fclose(json_fd); // No checking because accoring to the man page, they don't return anything useful o_O pcap_freecode(&fp); pcap_close(handle); if(output_handle != NULL) { pcap_dump_close(output_handle); } exit(1); break; default: printf("Caught signal: %i\n", signo); exit(0); } }
#ifndef DATASTRUCTS_H #define DATASTRUCTS_H #include "AST.h" #include <string> #include <map> #include <vector> using std::string; using std::map; using std::vector; using std::pair; class VariableSymbols { public: VariableSymbols() : symbols() {} int addVariable(string name, int type); bool containsVariable(string name); int getID(string name); private: map<string, pair<int, int> > symbols; }; class FunctionSymbols { public: FunctionSymbols() : symbols(), ambiguous() {} int addFunction(string name, int rettype, vector<int> paramtype); bool containsFunction(string name, vector<int> &params); int getID(string name, vector<int> &params); vector<int> getFuncIDs(string name); private: map<pair<string, vector<int> >, pair<int,int> > symbols; map<string, vector<int> > ambiguous; }; class SymbolTable { public: SymbolTable(map<string, long> *consts) : varTypes(), funcTypes(), astToID(), funcParams(), constants(consts) {} int getVarType(int varID); int getFuncType(int funcID) { return funcTypes[funcID]; } void putVar(int ID, int type) { varTypes[ID]=type; } void putFunc(int ID, int type); void putFuncDecl(int ID, vector<int> params) { funcParams[ID]=params; } void putAST(AST *obj, int ID); void putAmbiguousFunc(AST *func, vector<int> possibleIDs) { astToAmbiguousFuncIDs[func]=possibleIDs; } int getVarType(AST *obj); int getFuncType(AST *obj); vector<int> getFuncParams(int funcID) { return funcParams[funcID]; } vector<int> getAmbiguousFuncs(AST *func) { return astToAmbiguousFuncIDs[func]; } int getID(AST *obj) { return astToID[obj]; } void printDiagnostics(); vector<int> &getGlobalPointers(void) { return globalPointers; } void addGlobalPointer(int vid) { globalPointers.push_back(vid); } bool isConstant(string name); long getConstantVal(string name); private: map<int, int> varTypes; map<int, int> funcTypes; map<AST *, int> astToID; map<AST *, vector<int> > astToAmbiguousFuncIDs; map<int, vector<int> > funcParams; vector<int> globalPointers; map<string, long> *constants; }; class Scope { public: Scope(Scope *Parent) : namedChildren(), parent(Parent), vars(), funcs() {} ~Scope(); VariableSymbols &getVarSymbols() { return vars; } FunctionSymbols &getFuncSymbols() { return funcs; } bool addNamedChild(string name, Scope *child); int getVarInScope(string nspace, string name); vector<int> getFuncsInScope(string nspace, string name); Scope *getNamedChild(string name); private: map<string, Scope *> namedChildren; Scope *parent; VariableSymbols vars; FunctionSymbols funcs; }; struct SymbolData { SymbolTable *symbols; vector<ASTFuncDecl *> globalFuncs; vector<ASTVarDecl *> globalVars; vector<ASTArrayDecl *> globalArrays; vector<ASTScript *> scripts; map<ASTScript *, int> runsymbols; map<ASTScript *, int> numParams; map<ASTScript *, int> scriptTypes; map<ASTScript *, int> thisPtr; }; struct FunctionData { SymbolTable *symbols; vector<ASTFuncDecl *> functions; vector<ASTVarDecl *> globalVars; vector<ASTVarDecl *> newGlobalVars; vector<ASTArrayDecl *> globalArrays; vector<ASTArrayDecl *> newGlobalArrays; map<string, int> scriptRunSymbols; map<string, int> numParams; map<string, int> scriptTypes; map<string, int> thisPtr; }; struct IntermediateData { map<int, vector<Opcode *> > funcs; vector<Opcode *> globalsInit; vector<Opcode *> globalasInit; map<string, int> scriptRunLabels; map<string, int> numParams; map<string, int> scriptTypes; map<string, int> thisPtr; }; class LinkTable { public: int functionToLabel(int fid); int getGlobalID(int vid); int addGlobalVar(int vid); void addGlobalPointer(int vid) { globalIDs[vid]=0; } private: map<int, int> funcLabels; map<int, int> globalIDs; }; class StackFrame { public: void addToFrame(int vid, int offset) { stackoffset[vid] = offset; } int getOffset(int vid); private: map<int, int> stackoffset; }; struct OpcodeContext { StackFrame *stackframe; LinkTable *linktable; SymbolTable *symbols; }; struct BFSParam { Scope *scope; SymbolTable *table; int type; }; #endif
void esput_otb_mqtt_publish(MQTT_Client *mqtt_client, char *subtopic, char *extra_subtopic, char *message, char *extra_message, uint8_t qos, bool retain, char *buf, uint16_t buf_len); void esput_otb_cmd_mqtt_receive(uint32_t *client, const char* topic, uint32_t topic_len, const char *msg, uint32_t msg_len, char *buf, uint16_t buf_len); uint8 esput_otb_wifi_set_station_config(char *ssid, char *password, bool commit); void esput_otb_wifi_ap_mode_done_fn(void); uint8 esput_otb_mqtt_set_svr(char *svr, char *port, bool commit); uint8 esput_otb_mqtt_set_user(char *user, char *pass, bool commit); bool esput_otb_conf_verify_manual_ip(otb_conf_struct *conf); bool esput_otb_conf_update(otb_conf_struct *conf); bool esput_otb_util_parse_ipv4_str(char *ip_in, uint8_t *ip_out); bool esput_otb_util_ip_is_all_val(uint8_t *ip, uint8_t val); bool esput_otb_util_ip_is_subnet_valid(uint8_t *subnet); #define otb_mqtt_publish(...) esput_otb_mqtt_publish(__VA_ARGS__) #define otb_cmd_mqtt_receive(...) esput_otb_cmd_mqtt_receive(__VA_ARGS__) #define otb_wifi_set_station_config(...) esput_otb_wifi_set_station_config(__VA_ARGS__) #define otb_mqtt_set_svr(...) esput_otb_mqtt_set_svr(__VA_ARGS__) #define otb_mqtt_set_user(...) esput_otb_mqtt_set_user(__VA_ARGS__) #define otb_util_parse_ipv4_str(...) esput_otb_util_parse_ipv4_str(__VA_ARGS__) #define otb_util_ip_is_all_val(...) esput_otb_util_ip_is_all_val(__VA_ARGS__) #define otb_util_ip_is_subnet_valid(...) esput_otb_util_ip_is_subnet_valid(__VA_ARGS__) #define otb_conf_verify_manual_ip(...) esput_otb_conf_verify_manual_ip(__VA_ARGS__) #define otb_conf_update(...) esput_otb_conf_update(__VA_ARGS__) #define otb_wifi_ap_mode_done_fn(...) esput_otb_wifi_ap_mode_done_fn(__VA_ARGS__) char *otb_mqtt_root; void *otb_mqtt_client; #define OTB_MAIN_CHIPID "chipid" #define OTB_MAIN_DEVICE_ID "deviceid" #define OTB_MQTT_STATUS_HTTP "status" extern bool otb_mqtt_connected; #ifndef OTB_HTTPD_C extern struct espconn *otb_httpd_espconn; extern espconn_connect_callback otb_httpd_connect_cb; extern espconn_recv_callback otb_httpd_recv_cb; extern espconn_reconnect_callback otb_httpd_recon_cb; extern espconn_connect_callback otb_httpd_discon_cb; extern espconn_sent_callback otb_httpd_sent_cb; extern uint8 *esput_sent_msg; #endif // OTB_HTTPD_C typedef struct test_httpd_data { char *data; uint16 len; uint8 method; uint16 status_code; char *status_str; } test_httpd_data;
/* Copyright © 2010 par Marc Sibert This file is part of LIBOSM LIBOSM 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. LIBOSM 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 LIBOSM. If not, see <http://www.gnu.org/licenses/>. */ /** * \file * \author Marc Sibert */ // Class automatically generated by Dev-C++ New Class wizard #ifndef CHANGESET_H #define CHANGESET_H #include "top.h" // inheriting class's header file #include <ctime> #include <string> #include "datetimeiso8601.h" using namespace std; /** * Classe définissant un Changset tel que le décrit l'Api OSM. */ class Changeset : public Top { protected: /// Date de création du changeset. DateTimeISO8601 fCreatedAt; /// Nombre de modifications successives. unsigned fNumChanges; /// Date de cloture du changset si clos, NULL sinon. DateTimeISO8601 fClosedAt; /// État du Changeset (ouvert ou clos). bool fOpen; /// Longitude minimum (BBOX). double fMinLon; /// Latitude minimum (BBOX). double fMinLat; /// Longitude maximum (BBOX). double fMaxLon; /// Latitude maximum (BBOX). double fMaxLat; public: /** * Constructeur de l'instance faisant aussi office de constructeur par * défaut. */ Changeset() : Top(0, "", 0), fCreatedAt(), fNumChanges(0), fClosedAt(), fOpen(false), fMinLon(0), fMinLat(0), fMaxLon(0), fMaxLat(0) {} /** * Destructeur de l'instance, sans action. */ virtual ~Changeset() {} /** * \brief Ajoute un attribut à l'instance Changeset. * * L'attribut doit faire partie de la liste accepté par les ELements de * l'Api osm. * \param aKey Le nom de l'attribut. * \param aValue La valeur de l'attribut sous la forme d'une chaîne de * caractères. */ virtual void setAttribut(const string& aKey, const string& aValue); /// Nom de la classe utilisée par certaines méthodes templates de la /// classe ApiOsm. static const string NOM; /** * Injecte une description du Changeset au format XML de l'API Osm dans * un flux de sortie. * \param aStream Un flux de sortie. * \return Le flux de sortie après injection de la description de l'Element. */ ostream& afficher(ostream& aStream) const; /** * Test et retourne l'égalité des différents champs de l'instance. * \param aChangeset Une référence sur le Changeset comparé à l'instance. * \return true si les 2 Elements sont égaux, false sinon. */ bool operator==(const Changeset& aChangeset) const; /** * Retourne la date de création du Changeset. * \return Une relation sur le champ date. */ const DateTimeISO8601& createdAt() const { return fCreatedAt; } /** * Retourne le nombre de changements successifs attributé à ce Changeset. * \return Un entier représentant le nombre de changements. */ const unsigned& numChanges() const { return fNumChanges; } /** * Retourne la date de cloture du Changeset. * \return Une relation sur le champ date. */ const DateTimeISO8601& closedAt() const { return fClosedAt; } /** * Retourne un indicateur sur l'état du Changeset. * \return Un booléen contenant <code>true</code> si le changeset est * ouvert et <code>false</code> s'il est clos. */ bool open() const { return fOpen; } /** * Retourne la Longitude minimum de la BBOX du changeset. * \return Un réel à double précision. */ const double& minLon() const { return fMinLon; } /** * Retourne la Latitude minimum de la BBOX du changeset. * \return Un réel à double précision. */ const double& minLat() const { return fMinLat; } /** * Retourne la Longitude maximum de la BBOX du changeset. * \return Un réel à double précision. */ const double& maxLon() const { return fMaxLon; } /** * Retourne la Latitude maximum de la BBOX du changeset. * \return Un réel à double précision. */ const double& maxLat() const { return fMaxLat; } }; /** * Permet l'injection de la description d'une instance de Changeset dans un flux * de sortie. La présentation correspond à un flux XML. * \param aStream Un flux de sortie recevant la description. * \param aChangeset L'instance dont la description est produite. * \return Le flux de sortie après injection de la description. */ ostream& operator<<(ostream& aStream, const Changeset& aChangeset); #endif // CHANGESET_H
/* * gnome-keyring * * Copyright (C) 2010 Stefan Walter * * This program 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 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA * 02111-1307, USA. */ #include "config.h" #include "gkm/gkm-mock.h" #include "gkm/gkm-test.h" #include "egg/egg-testing.h" #include "wrap-layer/gkm-wrap-layer.h" #include "ui/gku-prompt.h" #include <string.h> typedef struct { CK_FUNCTION_LIST functions; CK_FUNCTION_LIST_PTR module; CK_SESSION_HANDLE session; CK_OBJECT_HANDLE object; } Test; static void setup (Test *test, gconstpointer unused) { CK_FUNCTION_LIST_PTR funcs; CK_SLOT_ID slot_id; CK_ULONG n_slots = 1; CK_ULONG count; CK_RV rv; CK_BBOOL always = TRUE; CK_ATTRIBUTE attrs[] = { { CKA_ALWAYS_AUTHENTICATE, &always, sizeof (always) } }; /* Always start off with test functions */ rv = gkm_mock_C_GetFunctionList (&funcs); gkm_assert_cmprv (rv, ==, CKR_OK); memcpy (&test->functions, funcs, sizeof (test->functions)); gkm_wrap_layer_reset_modules (); gkm_wrap_layer_add_module (&test->functions); test->module = gkm_wrap_layer_get_functions (); gku_prompt_dummy_prepare_response (); /* Open a test->session */ rv = (test->module->C_Initialize) (NULL); gkm_assert_cmprv (rv, ==, CKR_OK); rv = (test->module->C_GetSlotList) (CK_TRUE, &slot_id, &n_slots); gkm_assert_cmprv (rv, ==, CKR_OK); rv = (test->module->C_OpenSession) (slot_id, CKF_SERIAL_SESSION, NULL, NULL, &test->session); gkm_assert_cmprv (rv, ==, CKR_OK); /* Find the always authenticate test->object */ rv = (test->module->C_FindObjectsInit) (test->session, attrs, 1); gkm_assert_cmprv (rv, ==, CKR_OK); rv = (test->module->C_FindObjects) (test->session, &test->object, 1, &count); gkm_assert_cmprv (rv, ==, CKR_OK); gkm_assert_cmpulong (count, ==, 1); gkm_assert_cmpulong (test->object, !=, 0); rv = (test->module->C_FindObjectsFinal) (test->session); gkm_assert_cmprv (rv, ==, CKR_OK); } static void teardown (Test *test, gconstpointer unused) { CK_RV rv; g_assert (!gku_prompt_dummy_have_response ()); rv = (test->module->C_CloseSession) (test->session); gkm_assert_cmprv (rv, ==, CKR_OK); rv = (test->module->C_Finalize) (NULL); gkm_assert_cmprv (rv, ==, CKR_OK); } static void test_ok_password (Test *test, gconstpointer unused) { CK_OBJECT_CLASS klass = CKO_G_CREDENTIAL; CK_ATTRIBUTE attrs[] = { { CKA_CLASS, &klass, sizeof (klass) }, { CKA_G_OBJECT, &test->object, sizeof (test->object) }, { CKA_VALUE, NULL, 0 } }; CK_OBJECT_HANDLE cred = 0; CK_RV rv; gku_prompt_dummy_queue_ok_password ("booo"); rv = (test->module->C_CreateObject) (test->session, attrs, G_N_ELEMENTS (attrs), &cred); gkm_assert_cmprv (rv, ==, CKR_OK); gkm_assert_cmpulong (cred, !=, 0); } static void test_bad_password_then_cancel (Test *test, gconstpointer unused) { CK_OBJECT_CLASS klass = CKO_G_CREDENTIAL; CK_ATTRIBUTE attrs[] = { { CKA_CLASS, &klass, sizeof (klass) }, { CKA_G_OBJECT, &test->object, sizeof (test->object) }, { CKA_VALUE, NULL, 0 } }; CK_OBJECT_HANDLE cred = 0; CK_RV rv; gku_prompt_dummy_queue_ok_password ("bad password"); gku_prompt_dummy_queue_no (); rv = (test->module->C_CreateObject) (test->session, attrs, G_N_ELEMENTS (attrs), &cred); gkm_assert_cmprv (rv, ==, CKR_PIN_INCORRECT); } static void test_cancel_immediately (Test *test, gconstpointer unused) { CK_OBJECT_CLASS klass = CKO_G_CREDENTIAL; CK_ATTRIBUTE attrs[] = { { CKA_CLASS, &klass, sizeof (klass) }, { CKA_G_OBJECT, &test->object, sizeof (test->object) }, { CKA_VALUE, NULL, 0 } }; CK_OBJECT_HANDLE cred = 0; CK_RV rv; gku_prompt_dummy_queue_no (); rv = (test->module->C_CreateObject) (test->session, attrs, G_N_ELEMENTS (attrs), &cred); gkm_assert_cmprv (rv, ==, CKR_PIN_INCORRECT); } int main (int argc, char **argv) { g_type_init (); g_test_init (&argc, &argv, NULL); g_test_add ("/wrap-layer/create-credential/ok_password", Test, NULL, setup, test_ok_password, teardown); g_test_add ("/wrap-layer/create-credential/bad_password_then_cancel", Test, NULL, setup, test_bad_password_then_cancel, teardown); g_test_add ("/wrap-layer/create-credential/cancel_immediately", Test, NULL, setup, test_cancel_immediately, teardown); return egg_tests_run_in_thread_with_loop (); }
// Copyright 2008, Google Inc. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // // 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 Google Inc. nor the names of its contributors may be // used to endorse or promote products derived from this software without // specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO // EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // This file contains the definition of the SharedStyleParserObserver class. #ifndef KML_ENGINE_SHARED_STYLE_PARSER_OBSERVER_H__ #define KML_ENGINE_SHARED_STYLE_PARSER_OBSERVER_H__ #include <map> #include <string> #include "kml/dom.h" #include "kml/dom/parser_observer.h" #include "kml/engine/engine_types.h" namespace kmlengine { // The SharedStyleParserObserver is a kmldom::ParserObserver which gathers all // all shared StyleSelectors into the supplied SharedStyleMap. If strict_parse // is true AddChild() returns false on any id collision causing the parse to // terminate when this is used with kmldom::Parse::AddObserver(). If // strict_parse is false the "last one wins" on any duplicate. // TODO: provide an error log for this latter case. class SharedStyleParserObserver : public kmldom::ParserObserver { public: // A SharedStyleMap must be supplied. SharedStyleParserObserver(SharedStyleMap* shared_style_map, bool strict_parse) : shared_style_map_(shared_style_map), strict_parse_(strict_parse) {} virtual ~SharedStyleParserObserver() {} // ParserObserver::AddChild() virtual bool AddChild(const kmldom::ElementPtr& parent, const kmldom::ElementPtr& child) { // A shared style is defined to be a StyleSelector with an id that is // a child of a Document. If this id already has a mapping return false // to terminate the parse. if (kmldom::DocumentPtr document = kmldom::AsDocument(parent)) { if (kmldom::StyleSelectorPtr ss = kmldom::AsStyleSelector(child)) { if (ss->has_id()) { if (strict_parse_ && shared_style_map_->find(ss->get_id()) != shared_style_map_->end()) { // TODO: provide means to send back an and error string with id return false; // Duplicate id, fail parse. } } // No such mapping so save it, and "last one wins" on non-strict parse. (*shared_style_map_)[ss->get_id()] = ss; } } return true; // Not a duplicate id, keep parsing. } private: SharedStyleMap* shared_style_map_; bool strict_parse_; }; } // end namespace kmlengine #endif // KML_ENGINE_SHARED_STYLE_PARSER_OBSERVER_H__
/***************************************************************************** * * Copyright (c) 2000 - 2013, Lawrence Livermore National Security, LLC * Produced at the Lawrence Livermore National Laboratory * LLNL-CODE-442911 * All rights reserved. * * This file is part of VisIt. For details, see https://visit.llnl.gov/. The * full copyright notice is contained in the file COPYRIGHT located at the root * of the VisIt distribution or at http://www.llnl.gov/visit/copyright.html. * * 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 disclaimer below. * - Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the disclaimer (as noted below) in the * documentation and/or other materials provided with the distribution. * - Neither the name of the LLNS/LLNL 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 LAWRENCE LIVERMORE NATIONAL SECURITY, * LLC, THE U.S. DEPARTMENT OF ENERGY 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 GRAMMAR_H #define GRAMMAR_H #include <parser_exports.h> #include "Symbol.h" #include "Rule.h" #include "ConfiguratingSet.h" #include "State.h" #include "Dictionary.h" // **************************************************************************** // Class: Grammar // // Purpose: // Class implementing a generic LR(1) grammar. Rules, symbols, and // associativities and precedences are added. After this, the grammar // may be used several ways: // 1) Call Configure, then use the grammar in a parser // 2) Call Configure, then write out the initalization code to a file // 3) Link this initalization code with the project and call it // instead of Configure before using it in a parser. // // Programmer: Jeremy Meredith // Creation: April 5, 2002 // // Modifications: // Jeremy Meredith, Wed Jun 8 17:07:55 PDT 2005 // Added a symbol dictionary. // // **************************************************************************** class PARSER_API Grammar { public: enum Associativity { Left, Right, NonAssoc }; Grammar(Dictionary&); virtual ~Grammar(); void Print(ostream&); void SetAssoc(const Symbol&, Associativity); void SetPrec(const Symbol&, int); void AddRule(const Rule&, int prec=-1); void SetStartSymbol(const Symbol&); bool Configure(); virtual bool Initialize() = 0; Dictionary &GetDictionary(); const Symbol *GetStartSymbol(); const Rule *GetRule(int i); State &GetState(int i); void SetPrinter(ostream *o); void WriteStateInitialization(const std::string&, ostream&); protected: Dictionary &dictionary; ostream *out; Symbol eof; Symbol start; Rule startrule; std::vector<const Rule*> rules; std::map<const Symbol*, int> prec; std::map<const Symbol*, Associativity> assoc; std::vector<ConfiguratingSet> sets; std::vector<State> states; }; #endif
/***************************************************************************** * Copyright (c) 2014-2020 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. *****************************************************************************/ #pragma once #include "../common.h" #include "../interface/Window.h" #include "../windows/Intent.h" #include <string> class Formatter; namespace OpenRCT2::Ui { /** * Manager of in-game windows and widgets. */ struct IWindowManager { virtual ~IWindowManager() = default; virtual void Init() abstract; virtual rct_window* OpenWindow(rct_windowclass wc) abstract; virtual rct_window* OpenView(uint8_t view) abstract; virtual rct_window* OpenDetails(uint8_t type, int32_t id) abstract; virtual rct_window* OpenIntent(Intent* intent) abstract; virtual void BroadcastIntent(const Intent& intent) abstract; virtual rct_window* ShowError(rct_string_id title, rct_string_id message, const Formatter& formatter) abstract; virtual rct_window* ShowError(const std::string_view& title, const std::string_view& message) abstract; virtual void ForceClose(rct_windowclass windowClass) abstract; virtual void UpdateMapTooltip() abstract; virtual void HandleInput() abstract; virtual void HandleKeyboard(bool isTitle) abstract; virtual std::string GetKeyboardShortcutString(int32_t shortcut) abstract; virtual void SetMainView(const ScreenCoordsXY& viewPos, ZoomLevel zoom, int32_t rotation) abstract; virtual void UpdateMouseWheel() abstract; virtual rct_window* GetOwner(const rct_viewport* viewport) abstract; }; IWindowManager* CreateDummyWindowManager(); } // namespace OpenRCT2::Ui
/* * 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 "cursorTest.h" const bool expectedToPass = false; /* --+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+-- */ int main() { #if defined(USE_DBC) psonCursor * pCursor; psonSessionContext context; bool ok; pCursor = initCursorTest( expectedToPass, &context ); ok = psonCursorInit( pCursor, 12345, 1, &context ); if ( ok != true ) { ERROR_EXIT( expectedToPass, &context.errorHandler, ; ); } ok = psonCursorInsertFirst( NULL, (unsigned char *)&context, // any pointer is ok PSON_HASH_ITEM, &context ); ERROR_EXIT( expectedToPass, NULL, ; ); #else return 1; #endif } /* --+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+-- */
#include "tests/ctrl-interface.h" #include "constants.h" #include <math.h> #include "debug.h" /* Global Variables */ int motor_speeds[10] = {0}; float netVelocityX = 0; float netVelocityY = 0; #define motorA motor_speeds[1] #define motorB motor_speeds[2] #define motorC motor_speeds[3] #define motorD motor_speeds[4] /* Private Prototypes */ void calcNetVelocity(); short angle(); short speed(); short quad(); /* Emulation Functions */ void motorSet(unsigned char channel, int speed) { if (channel > 10) { msg_error("Expected channel < 10; Got [%d] with speed [%d]\n", channel, speed); } msg_debug("Channel: [%d] with speed [%d]\n", channel, speed); motor_speeds[channel - 1] = speed; } /* Utility Functions */ /* Prints all motors in a hard to read format */ void printMotors() { int i = 0; calcNetVelocity(); msg("Motor Speeds. quad = %d speed = %d angle = %d\n", quad(), speed(), angle()); while (i < 10) { printf(" [%02d] %+4d [%02d] %+4d\n", i + 1, motor_speeds[i], i + 2, motor_speeds[i + 1]); i += 2; } } /* Prints the motors you car about in a easy to read format */ void pprintMotors() { calcNetVelocity(); msg("Motor Speeds. quad = %d speed = %d angle = %d\n", quad(), speed(), angle()); printf(" [%+04d] MOTOR_A\n", motorA); printf(" MOTOR_B [%+04d]\n", motorB); printf(" MOTOR_C [%+04d]\n", motorC); printf(" [%+04d] MOTOR_D\n", motorD); } /* Verification Functions */ /* Calculates angle of the robot based on the current speeds */ void calcNetVelocity() { netVelocityX = (-motorA + -motorB + motorC + motorD) / sqrt(2); netVelocityY = (motorA + -motorB + -motorC + motorD) / sqrt(2); } /* determines what quadrant the velocity is in */ short quad() { if (netVelocityY >= 0) { return (netVelocityX > 0 ? 1 : 2); } else { return (netVelocityX > 0 ? 4 : 3); } } /* Calculates angle that the robot would be based on the current speeds */ short angle() { return (short)(atan2(netVelocityY, netVelocityX) * 57.2958); } /* Calculate the current net speed based on the motor speeds */ short speed() { return (short)(sqrt(netVelocityX * netVelocityX + netVelocityY * netVelocityY)); }
/* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <netware.h> #include <library.h> #include <nks/synch.h> #include "novsock2.h" #include "apr_pools.h" #include "apr_private.h" /* library-private data...*/ int gLibId = -1; void *gLibHandle = (void *) NULL; NXMutex_t *gLibLock = (NXMutex_t *) NULL; /* internal library function prototypes...*/ int DisposeLibraryData(void *); int _NonAppStart ( void *NLMHandle, void *errorScreen, const char *cmdLine, const char *loadDirPath, size_t uninitializedDataLength, void *NLMFileHandle, int (*readRoutineP)( int conn, void *fileHandle, size_t offset, size_t nbytes, size_t *bytesRead, void *buffer ), size_t customDataOffset, size_t customDataSize, int messageCount, const char **messages ) { WSADATA wsaData; apr_status_t status; NX_LOCK_INFO_ALLOC(liblock, "Per-Application Data Lock", 0); #pragma unused(cmdLine) #pragma unused(loadDirPath) #pragma unused(uninitializedDataLength) #pragma unused(NLMFileHandle) #pragma unused(readRoutineP) #pragma unused(customDataOffset) #pragma unused(customDataSize) #pragma unused(messageCount) #pragma unused(messages) gLibId = register_library(DisposeLibraryData); if (gLibId < -1) { OutputToScreen(errorScreen, "Unable to register library with kernel.\n"); return -1; } gLibHandle = NLMHandle; gLibLock = NXMutexAlloc(0, 0, &liblock); if (!gLibLock) { OutputToScreen(errorScreen, "Unable to allocate library data lock.\n"); return -1; } apr_netware_setup_time(); if ((status = apr_pool_initialize()) != APR_SUCCESS) return status; return WSAStartup((WORD) MAKEWORD(2, 0), &wsaData); } void _NonAppStop( void ) { apr_pool_terminate(); WSACleanup(); unregister_library(gLibId); NXMutexFree(gLibLock); } int _NonAppCheckUnload( void ) { return 0; } int register_NLM(void *NLMHandle) { APP_DATA *app_data = (APP_DATA*) get_app_data(gLibId); NXLock(gLibLock); if (!app_data) { app_data = (APP_DATA*)library_malloc(gLibHandle, sizeof(APP_DATA)); if (app_data) { memset (app_data, 0, sizeof(APP_DATA)); set_app_data(gLibId, app_data); app_data->gs_nlmhandle = NLMHandle; } } if (app_data && (!app_data->initialized)) { app_data->initialized = 1; NXUnlock(gLibLock); return 0; } NXUnlock(gLibLock); return 1; } int unregister_NLM(void *NLMHandle) { APP_DATA *app_data = (APP_DATA*) get_app_data(gLibId); NXLock(gLibLock); if (app_data) { app_data->initialized = 0; NXUnlock(gLibLock); return 0; } NXUnlock(gLibLock); return 1; } int DisposeLibraryData(void *data) { if (data) { library_free(data); } return 0; } int setGlobalPool(void *data) { APP_DATA *app_data = (APP_DATA*) get_app_data(gLibId); NXLock(gLibLock); if (app_data && !app_data->gPool) { app_data->gPool = data; } NXUnlock(gLibLock); return 1; } void* getGlobalPool() { APP_DATA *app_data = (APP_DATA*) get_app_data(gLibId); if (app_data) { return app_data->gPool; } return NULL; }
/* Free Download Manager Copyright (c) 2003-2016 FreeDownloadManager.ORG */ #if !defined(AFX_VMSZLIBHELPER_H__2A49F334_B108_4A46_A57E_295BB822879A__INCLUDED_) #define AFX_VMSZLIBHELPER_H__2A49F334_B108_4A46_A57E_295BB822879A__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif class vmsZlibHelper { public: static BOOL DecompressDeflate(LPBYTE pbData, UINT nSize, LPBYTE *ppUncompressed, UINT *puUncompressedSize); static BOOL DecompressGzip(LPBYTE pbData, UINT nSize, LPBYTE *ppUncompressed, UINT *puUncompressedSize); vmsZlibHelper(); virtual ~vmsZlibHelper(); protected: enum { FTEXT = 0x01, FHCRC = 0x02, FEXTRA = 0x04, FNAME = 0x08, FCOMMENT = 0x10, FRESERVED = 0xe0, GZIP_MAGIC0 = 0x1f, GZIP_MAGIC1 = 0x8b, }; protected: static int GetGzipHeaderSize (LPBYTE pbData, UINT nSize); }; #endif
/* Protect against multiple inclusion */ #ifndef STAR_CMP_H_INCLUDED #define STAR_CMP_H_INCLUDED void cmpLen( HDSLoc *struc, const char *comp, size_t *len, int *status ); void cmpMapN(HDSLoc* struc, const char *name, const char *type, const char *mode, int ndim, void **pntr, hdsdim dims[], int *status); void cmpMapV(HDSLoc* struc, const char *name, const char *type, const char *mode, void **pntr, size_t *actval, int *status); void cmpMod( HDSLoc *struc, const char *comp, const char *type, int ndim, const hdsdim *dims, int *status ); void cmpModC( HDSLoc *struc, const char *comp, size_t len, int ndim, const hdsdim *dims, int *status ); void cmpPrim( HDSLoc *struc, const char *comp, hdsbool_t *prim, int *status ); void cmpPut0C( HDSLoc *struc, const char *comp, const char *value, int *status ); void cmpPut0D( HDSLoc *struc, const char *comp, double value, int *status ); void cmpPut0I( HDSLoc *struc, const char *comp, int value, int *status ); void cmpPut0L( HDSLoc *struc, const char *comp, int value, int *status ); void cmpPut0R( HDSLoc *struc, const char *comp, float value, int *status ); void cmpGet0C( HDSLoc *struc, const char *comp, char *value, size_t value_length, int *status ); void cmpGet0D( HDSLoc *struc, const char *comp, double *value, int *status ); void cmpGet0I( HDSLoc *struc, const char *comp, int *value, int *status ); void cmpGet0L( HDSLoc *struc, const char *comp, int *value, int *status ); void cmpGet0R( HDSLoc *struc, const char *comp, float *value, int *status ); void cmpPut1C( HDSLoc *struc, const char *comp, size_t nval, const char *values[], int *status ); void cmpPut1D( HDSLoc *struc, const char *comp, size_t nval, const double values[], int *status ); void cmpPut1I( HDSLoc *struc, const char *comp, size_t nval, const int values[], int *status ); void cmpPut1L( HDSLoc *struc, const char *comp, size_t nval, const hdsbool_t values[], int *status ); void cmpPut1R( HDSLoc *struc, const char *comp, size_t nval, const float values[], int *status ); void cmpPutVC( HDSLoc *struc, const char *comp, size_t nval, const char *values[], int *status ); void cmpPutVD( HDSLoc *struc, const char *comp, size_t nval, const double values[], int *status ); void cmpPutVI( HDSLoc *struc, const char *comp, size_t nval, const int values[], int *status ); void cmpPutVL( HDSLoc *struc, const char *comp, size_t nval, const hdsbool_t values[], int *status ); void cmpPutVR( HDSLoc *struc, const char *comp, size_t nval, const float values[], int *status ); void cmpGet1C( HDSLoc *struc, const char *comp, size_t maxval, size_t bufsize, char *buffer, char *pntrs[], size_t *actval, int *status ); void cmpGet1D( HDSLoc *struc, const char *comp, size_t maxval, double values[], size_t *actval, int *status ); void cmpGet1I( HDSLoc *struc, const char *comp, size_t maxval, int values[], size_t *actval, int *status ); void cmpGet1L( HDSLoc *struc, const char *comp, size_t maxval, int values[], size_t *actval, int *status ); void cmpGet1R( HDSLoc *struc, const char *comp, size_t maxval, float values[], size_t *actval, int *status ); void cmpGetVC( HDSLoc *struc, const char *comp, size_t maxval, size_t bufsize, char *buffer, char *pntrs[], size_t *actval, int *status); void cmpGetVD( HDSLoc *struc, const char *comp, size_t maxval, double values[], size_t *actval, int *status ); void cmpGetVI( HDSLoc *struc, const char *comp, size_t maxval, int values[], size_t *actval, int *status ); void cmpGetVL( HDSLoc *struc, const char *comp, size_t maxval, int values[], size_t *actval, int *status ); void cmpGetVR( HDSLoc *struc, const char *comp, size_t maxval, float values[], size_t *actval, int *status ); void cmpShape( HDSLoc *struc, const char *comp, int maxdim, hdsdim dims[], int *actdim, int *status ); void cmpSize( HDSLoc *struc, const char *comp, size_t *size, int *status ); void cmpStruc( HDSLoc *strucloc, const char *comp, hdsbool_t *struc, int *status ); void cmpType( HDSLoc *struc, const char *comp, char type[DAT__SZTYP+1], int *status ); void cmpUnmap(HDSLoc* struc, const char *name, int *status); /* STAR_CMP_H_INCLUDED */ #endif
#ifndef VKSEARCHDIALOG_H #define VKSEARCHDIALOG_H #include <QDialog> #include <QTreeWidget> #include <QTimer> #include "vkservice.h" namespace Ui { class VkSearchDialog; } class VkSearchDialog : public QDialog { Q_OBJECT public: explicit VkSearchDialog(VkService *service, QWidget *parent = 0); ~VkSearchDialog(); MusicOwner found() const; signals: void Find(const QString &query); public slots: void ReciveResults(RequestID id, const MusicOwnerList &owners); protected: void showEvent(QShowEvent *); private slots: void selectionChanged(); void suggest(); void selected(); private: bool eventFilter(QObject *obj, QEvent *ev); QTreeWidgetItem *createItem(const MusicOwner &own); Ui::VkSearchDialog *ui; MusicOwner selected_; VkService *service_; RequestID last_search_; QTreeWidget *popup; QTimer *timer; }; #endif // VKSEARCHDIALOG_H
/* Copyright (c) 2002-2003 krzYszcz and others. * For information on usage and redistribution, and for a DISCLAIMER OF ALL * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ #include <math.h> #include "m_pd.h" #include "shared.h" #include "sickle/sic.h" typedef struct _phasewrap { t_sic x_sic; int x_algo; } t_phasewrap; static t_class *phasewrap_class; static t_int *phasewrap_perform(t_int *w) { int nblock = (int)(w[1]); t_float *in = (t_float *)(w[2]); t_float *out = (t_float *)(w[3]); t_shared_wrappy wrappy; while (nblock--) { /* FIXME here we have pi -> pi, 3pi -> -pi, -pi -> -pi, -3pi -> pi, while in msp it is pi -> -pi, 3pi -> -pi, -pi -> pi, -3pi -> pi */ double dnorm = *in++ * (1. / SHARED_2PI); wrappy.w_d = dnorm + SHARED_UNITBIT0; /* Speeding up the int-to-double conversion below would be nice, but all attempts failed. Even this is slower (which works only for nonnegative input): wrappy.w_i[SHARED_HIOFFSET] = SHARED_UNITBIT0_HIPART; *out++ = (dnorm - (wrappy.w_d - SHARED_UNITBIT0)) * SHARED_2PI; */ dnorm -= wrappy.w_i[SHARED_LOWOFFSET]; *out++ = dnorm * SHARED_2PI; } return (w + 4); } /* This is the slowest algo. It is slower than fmod in all cases, except for input being zero. */ static t_int *phasewrap_perform1(t_int *w) { int nblock = (int)(w[1]); t_float *in = (t_float *)(w[2]); t_float *out = (t_float *)(w[3]); while (nblock--) { float f = *in++; double dnorm; if (f < -SHARED_PI) { dnorm = (double)f * (1. / SHARED_2PI) + .5; *out++ = (dnorm - (int)dnorm) * SHARED_2PI + SHARED_PI; } else if (f > SHARED_PI) { dnorm = (double)f * (1. / SHARED_2PI) + .5; *out++ = (dnorm - (int)dnorm) * SHARED_2PI - SHARED_PI; } else *out++ = f; } return (w + 4); } static t_int *phasewrap_perform2(t_int *w) { int nblock = (int)(w[1]); t_float *in = (t_float *)(w[2]); t_float *out = (t_float *)(w[3]); while (nblock--) { double dnorm = *in++ + SHARED_PI; if (dnorm < 0) *out++ = SHARED_PI - fmod(-dnorm, SHARED_2PI); else *out++ = fmod(dnorm, SHARED_2PI) - SHARED_PI; } return (w + 4); } static void phasewrap_dsp(t_phasewrap *x, t_signal **sp) { switch (x->x_algo) { case 1: dsp_add(phasewrap_perform1, 3, sp[0]->s_n, sp[0]->s_vec, sp[1]->s_vec); break; case 2: dsp_add(phasewrap_perform2, 3, sp[0]->s_n, sp[0]->s_vec, sp[1]->s_vec); break; default: dsp_add(phasewrap_perform, 3, sp[0]->s_n, sp[0]->s_vec, sp[1]->s_vec); } } static void phasewrap__algo(t_phasewrap *x, t_floatarg f) { x->x_algo = f; } static void *phasewrap_new(t_symbol *s, int ac, t_atom *av) { t_phasewrap *x = (t_phasewrap *)pd_new(phasewrap_class); if (s == gensym("_phasewrap1~")) x->x_algo = 1; else if (s == gensym("_phasewrap2~")) x->x_algo = 2; else x->x_algo = 0; outlet_new((t_object *)x, &s_signal); return (x); } void phasewrap_tilde_setup(void) { phasewrap_class = class_new(gensym("phasewrap~"), (t_newmethod)phasewrap_new, 0, sizeof(t_phasewrap), 0, A_GIMME, 0); class_addcreator((t_newmethod)phasewrap_new, gensym("_phasewrap1~"), A_GIMME, 0); class_addcreator((t_newmethod)phasewrap_new, gensym("_phasewrap2~"), A_GIMME, 0); sic_setup(phasewrap_class, phasewrap_dsp, SIC_FLOATTOSIGNAL); class_addmethod(phasewrap_class, (t_method)phasewrap__algo, gensym("_algo"), A_FLOAT, 0); }
/*************************************************************************** Copyright (C) 2008 by the Tonatiuh Software Development Team. This file is part of Tonatiuh. Tonatiuh 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/>. Acknowledgments: The development of Tonatiuh was started on 2004 by Dr. Manuel J. Blanco, then Chair of the Department of Engineering of the University of Texas at Brownsville. From May 2004 to July 2008, it was supported by the Department of Energy (DOE) and the National Renewable Energy Laboratory (NREL) under the Minority Research Associate (MURA) Program Subcontract ACQ-4-33623-06. During 2007, NREL also contributed to the validation of Tonatiuh under the framework of the Memorandum of Understanding signed with the Spanish National Renewable Energy Centre (CENER) on February, 20, 2007 (MOU#NREL-07-117). Since June 2006, the development of Tonatiuh is being led by the CENER, under the direction of Dr. Blanco, now Director of CENER Solar Thermal Energy Department. Developers: Manuel J. Blanco (mblanco@cener.com), Amaia Mutuberria, Victor Martin. Contributors: Javier Garcia-Barberena, Inaki Perez, Inigo Pagola, Gilda Jimenez, Juana Amieva, Azael Mancillas, Cesar Cantu. ***************************************************************************/ #ifndef TRT_H_ #define TRT_H_ #include <Inventor/fields/SoSFBool.h> #include <Inventor/fields/SoMFVec3f.h> #include <Inventor/fields/SoMFVec3d.h> #include <Inventor/fields/SoSFDouble.h> #include <Inventor/fields/SoSFFloat.h> #include <Inventor/fields/SoSFVec2d.h> #include <Inventor/fields/SoSFVec2f.h> #include <Inventor/fields/SoSFVec3d.h> #include <Inventor/fields/SoSFVec3f.h> #include <Inventor/fields/SoSubField.h> namespace trt { #if unix//( defined(Q_WS_X11) || defined(Q_WS_MAC) ) typedef SoSFDouble TONATIUH_REAL; typedef SoMFVec3d TONATIUH_CONTAINERREALVECTOR3; typedef SoSFVec3d TONATIUH_REALVECTOR3; typedef SoSFVec2d TONATIUH_REALVECTOR2; #else typedef SoSFFloat TONATIUH_REAL; typedef SoMFVec3f TONATIUH_CONTAINERREALVECTOR3; typedef SoSFVec3f TONATIUH_REALVECTOR3; typedef SoSFVec2f TONATIUH_REALVECTOR2; #endif typedef SoSFBool TONATIUH_BOOL; }; #endif /* trt_H_ */
/* * writer.h -- Example program which writes to SimpleExchangeDevice * * Copyright (C) 2014 Nemanja Hirsl * * 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/>. */ #include <string> #define EVENT_SIZE ( sizeof (struct inotify_event) ) #define BUF_LEN ( 1024 * ( EVENT_SIZE + 16 ) ) class SEDWriter { public: SEDWriter(std::string device); ~SEDWriter(); bool Watch(std::string folder); private: int watchFd; char buffer[BUF_LEN]; int watch; int sedFd; bool copyFileToDevice(const char *source); };
#include <htc.h> #include "ladder.h" #include "PwmLib.h" int PWM_Prediv(long fmcu, long fpwm) { long q = (fmcu / 4) / fpwm; // theoriquement egal a (PR2+1) * prediv if(q <= 256) return (1); // predivision = 1 if(q <= 1024) return (4); // predivision = 4 if(q <= 4096) return (16); // predivision = 16 return (0); // predivision hors limites } void PWM_Init(int canal, long fmcu, long fpwm, int resol) { long q = (fmcu / 4) / fpwm; int cs = PWM_Prediv(fmcu, fpwm); char prescal = 0; char pr2 = 0; if(cs == 0) // fpwm trop petite { prescal = 0x02; pr2 = 255; } if(cs == 1) { prescal = 0x01; if(q > 2) pr2 = q - 1; else pr2 = 1; } if(cs == 4) { prescal = 0x01; pr2 = (q / 4) - 1; } if(cs == 16) { prescal = 0x02; pr2 = (q / 16) - 1; } #if defined(LDTARGET_pic18f4XX0) if(canal == 1) { TRISCbits.TRISC2 = 0; // configure RC2 as output(RC2= PWM1 output) CCP1CON = 0x0C; // select PWM mode. CCPR1L = 0; // set duty to 0 PR2 = pr2; // set PWM period T2CON &= ~0x03; T2CON |= prescal; // set precaler TMR2ON = 1; // start Timer 2 for PWM generation } if(canal == 2) { /// if (CFG_WORD3 & (1 << 8)) // Bit CCP2MX TRISCbits.TRISC1 = 0; // configure RC1 as output(RC1= PWM2 output) /// else /// TRISBbits.TRISB3 = 0; // PWM output on RB3 CCP2CON = 0x0C; // select PWM mode. CCPR2L = 0; // set duty to 0 PR2 = pr2; // set PWM period T2CON &= ~0x03; T2CON |= prescal; // set precaler TMR2ON = 1; // start Timer 2 for PWM generation } #endif } void PWM_Set(int canal, unsigned percent, int resol) { unsigned value = ((PR2 + 1) * percent) / 25; // 10 bit value #if defined(LDTARGET_pic18f4XX0) if(canal == 1) { TMR2ON = 0; CCPR1L = value >> 2; CCP1CON = ((value & 0x0003) << 4) + 0x0C; TMR2ON = 1; } if(canal == 2) { TMR2ON = 0; CCPR2L = value >> 2; CCP2CON = ((value & 0x0003) << 4) + 0x0C; TMR2ON = 1; } #endif } void PWM_Stop(int canal) { #if defined(LDTARGET_pic18f4XX0) if(canal == 1) { CCP1CON = 0; CCPR1L = 0; PR2 = 0; TMR2ON = 0; // stop Timer 2 and PWM generation } if(canal == 2) { CCP2CON = 0; CCPR2L = 0; PR2 = 0; TMR2ON = 0; // stop Timer 2 and PWM generation } #endif }
#include "teclado.h" #include "interrupcoes.h" #include "terminal.h" #define FILTRO_ADDR 0x2700 unsigned char __far __at (@FILTRO_ADDR) filtro; unsigned int flag; void init_timer0() { /* Rotina de configuracao do timer 0*/ IE |= 0x82; // modo 8 bit TMOD |= 0x01; TH0 = 0xFC; TL0 = 0x66; flag = 1; filtro = 0x00; // run TR0 = 1; } unsigned char __far __at 0xFFF3 vetor[] = {0x02,0xA0,0x0B}; void timer0_int (void) __interrupt (1) __using (1) { if (flag) { filtro = 0x00; flag = 0; } else { filtro = 0xFF; flag = 1; } TH0 = 0xFC; TL0 = 0x66; } void main(void) { unsigned char opcao = 0; IE = 0; init_timer0(); while(1) { } }
#ifndef MQML_H #define MQML_H #include <QObject> #include <QtQml> class TreeItem; class MQML : public QObject { Q_OBJECT Q_DISABLE_COPY( MQML ) public: explicit MQML(QObject *parent = 0); Q_INVOKABLE QString className( QObject *obj ) const; Q_INVOKABLE TreeItem * createTreeItem( QVariant value = QVariant() ) const; Q_INVOKABLE QDate invalidDate() const; Q_INVOKABLE bool isValidDate( QDate date ) const; Q_INVOKABLE int daysInMonth( QDate date ) const; Q_INVOKABLE int daysInMonth( int year, int month ) const; Q_INVOKABLE int daysBetween( QDate arg1, QDate arg2 ) const; Q_INVOKABLE qint64 millisecondsBetween( QDateTime arg1, QDateTime arg2 ) const; Q_INVOKABLE QDateTime addMSecs( QDateTime arg1, int msecs ); }; QML_DECLARE_TYPE(MQML) #endif // MQML_H
/* glpk.h */ /****************************************************************************** * Copyright (C) 2017 Alexis Janon * * This code is part of a program computing task lists for * heterogeneous scheduling problems. * * 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 __GLPK_H__ #define __GLPK_H__ #include <glpk.h> #include <time.h> #include <math.h> #include "io.h" struct task { int p_a; int p_b; int q_a; int q_b; int g; }; extern int rand_int(int min, int max); extern int generate_values(struct task *tasks, struct cli_args parsed_args); extern int dichotomy(glp_prob *lp, int *ia, int *ja, double *ar, struct task *tasks, struct cli_args parsed_args, int lb, int ub); #endif
#ifndef COLORMAPRENDERER_H #define COLORMAPRENDERER_H #include "AbstractRenderer.h" class ColorMapModel; class ColorMapRenderer : public AbstractRenderer { public: irisITKObjectMacro(ColorMapRenderer, AbstractRenderer) void SetModel(ColorMapModel *model); void resizeGL(int w, int h); void paintGL(); protected: ColorMapRenderer(); virtual ~ColorMapRenderer(); ColorMapModel *m_Model; unsigned int m_TextureId; unsigned int m_Width, m_Height; }; #endif // COLORMAPRENDERER_H
#include <math.h> #include <stdio.h> #include "../include/libseno.h" double seno (double angulo) { double prox = angulo; long double condition; int i = 1; double soma = angulo; while(1) { prox = (prox * power((double) (-1), (double) (2 * i - 1)) * angulo * angulo) / (2 * i * (2 * i + 1)) ; soma = soma + prox; condition = prox; if (condition < 0) condition*= -1; if (condition < 0.0000001) return soma; i++; } } double arc_seno (double val_seno) { double prox = val_seno; int i = 1; double soma = val_seno; double condition = 0; if (val_seno == 0) return 0; while(i < 10000) { prox = prox * ((power(val_seno,2) * (2*i - 1) * (2*i - 1)) / ((2 * i) * (2 * i + 1))); soma = soma + prox; i++; } return soma; } double power (double x, int y) { if (y <= 1) return x; return x * power (x, y - 1); }
/* -*- c++ -*- */ /* * Copyright 2004 Free Software Foundation, Inc. * * This file is part of GNU Radio * * GNU Radio 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. * * GNU Radio 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 GNU Radio; see the file COPYING. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, * Boston, MA 02110-1301, USA. */ #ifndef INCLUDED_TRELLIS_SISO_F_H #define INCLUDED_TRELLIS_SISO_F_H #include "fsm.h" #include "trellis_siso_type.h" #include <gr_block.h> class trellis_siso_f; typedef boost::shared_ptr<trellis_siso_f> trellis_siso_f_sptr; trellis_siso_f_sptr trellis_make_siso_f ( const fsm &FSM, // underlying FSM int K, // block size in trellis steps int S0, // initial state (put -1 if not specified) int SK, // final state (put -1 if not specified) bool POSTI, // true if you want a-posteriori info about the input symbols to be mux-ed in the output bool POSTO, // true if you want a-posteriori info about the output symbols to be mux-ed in the output trellis_siso_type_t d_SISO_TYPE // perform "min-sum" or "sum-product" combining ); class trellis_siso_f : public gr_block { fsm d_FSM; int d_K; int d_S0; int d_SK; bool d_POSTI; bool d_POSTO; trellis_siso_type_t d_SISO_TYPE; //std::vector<float> d_alpha; //std::vector<float> d_beta; friend trellis_siso_f_sptr trellis_make_siso_f ( const fsm &FSM, int K, int S0, int SK, bool POSTI, bool POSTO, trellis_siso_type_t d_SISO_TYPE); trellis_siso_f ( const fsm &FSM, int K, int S0, int SK, bool POSTI, bool POSTO, trellis_siso_type_t d_SISO_TYPE); public: fsm FSM () const { return d_FSM; } int K () const { return d_K; } int S0 () const { return d_S0; } int SK () const { return d_SK; } bool POSTI () const { return d_POSTI; } bool POSTO () const { return d_POSTO; } trellis_siso_type_t SISO_TYPE () const { return d_SISO_TYPE; } void forecast (int noutput_items, gr_vector_int &ninput_items_required); int general_work (int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items); }; #endif
/* * (C) 2003-2006 Gabest * (C) 2006-2014 see Authors.txt * * This file is part of WinnerMediaPlayer. * * WinnerMediaPlayer 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. * * WinnerMediaPlayer 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 <afxwin.h> // CAuthDlg dialog class CAuthDlg : public CDialog { DECLARE_DYNAMIC(CAuthDlg) private: CString DEncrypt(CString pw); CMapStringToString m_logins; public: CAuthDlg(CWnd* pParent = NULL); virtual ~CAuthDlg(); enum { IDD = IDD_AUTH_DLG }; CComboBox m_usernamectrl; CString m_username; CString m_password; BOOL m_remember; protected: virtual void DoDataExchange(CDataExchange* pDX); virtual BOOL OnInitDialog(); DECLARE_MESSAGE_MAP() public: afx_msg void OnBnClickedOk(); afx_msg void OnCbnSelchangeCombo1(); afx_msg void OnEnSetfocusEdit3(); };
// This file is part of Eigen, a lightweight C++ template library // for linear algebra. // // Copyright (C) 2014 Gael Guennebaud <gael.guennebaud@inria.fr> // // This Source Code Form is subject to the terms of the Mozilla // Public License v. 2.0. If a copy of the MPL was not distributed // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. #ifndef STORMEIGEN_SPARSESOLVERBASE_H #define STORMEIGEN_SPARSESOLVERBASE_H namespace StormEigen { namespace internal { /** \internal * Helper functions to solve with a sparse right-hand-side and result. * The rhs is decomposed into small vertical panels which are solved through dense temporaries. */ template<typename Decomposition, typename Rhs, typename Dest> void solve_sparse_through_dense_panels(const Decomposition &dec, const Rhs& rhs, Dest &dest) { STORMEIGEN_STATIC_ASSERT((Dest::Flags&RowMajorBit)==0,THIS_METHOD_IS_ONLY_FOR_COLUMN_MAJOR_MATRICES); typedef typename Dest::Scalar DestScalar; // we process the sparse rhs per block of NbColsAtOnce columns temporarily stored into a dense matrix. static const Index NbColsAtOnce = 4; Index rhsCols = rhs.cols(); Index size = rhs.rows(); // the temporary matrices do not need more columns than NbColsAtOnce: Index tmpCols = (std::min)(rhsCols, NbColsAtOnce); StormEigen::Matrix<DestScalar,Dynamic,Dynamic> tmp(size,tmpCols); StormEigen::Matrix<DestScalar,Dynamic,Dynamic> tmpX(size,tmpCols); for(Index k=0; k<rhsCols; k+=NbColsAtOnce) { Index actualCols = std::min<Index>(rhsCols-k, NbColsAtOnce); tmp.leftCols(actualCols) = rhs.middleCols(k,actualCols); tmpX.leftCols(actualCols) = dec.solve(tmp.leftCols(actualCols)); dest.middleCols(k,actualCols) = tmpX.leftCols(actualCols).sparseView(); } } } // end namespace internal /** \class SparseSolverBase * \ingroup SparseCore_Module * \brief A base class for sparse solvers * * \tparam Derived the actual type of the solver. * */ template<typename Derived> class SparseSolverBase : internal::noncopyable { public: /** Default constructor */ SparseSolverBase() : m_isInitialized(false) {} ~SparseSolverBase() {} Derived& derived() { return *static_cast<Derived*>(this); } const Derived& derived() const { return *static_cast<const Derived*>(this); } /** \returns an expression of the solution x of \f$ A x = b \f$ using the current decomposition of A. * * \sa compute() */ template<typename Rhs> inline const Solve<Derived, Rhs> solve(const MatrixBase<Rhs>& b) const { eigen_assert(m_isInitialized && "Solver is not initialized."); eigen_assert(derived().rows()==b.rows() && "solve(): invalid number of rows of the right hand side matrix b"); return Solve<Derived, Rhs>(derived(), b.derived()); } /** \returns an expression of the solution x of \f$ A x = b \f$ using the current decomposition of A. * * \sa compute() */ template<typename Rhs> inline const Solve<Derived, Rhs> solve(const SparseMatrixBase<Rhs>& b) const { eigen_assert(m_isInitialized && "Solver is not initialized."); eigen_assert(derived().rows()==b.rows() && "solve(): invalid number of rows of the right hand side matrix b"); return Solve<Derived, Rhs>(derived(), b.derived()); } #ifndef STORMEIGEN_PARSED_BY_DOXYGEN /** \internal default implementation of solving with a sparse rhs */ template<typename Rhs,typename Dest> void _solve_impl(const SparseMatrixBase<Rhs> &b, SparseMatrixBase<Dest> &dest) const { internal::solve_sparse_through_dense_panels(derived(), b.derived(), dest.derived()); } #endif // STORMEIGEN_PARSED_BY_DOXYGEN protected: mutable bool m_isInitialized; }; } // end namespace StormEigen #endif // STORMEIGEN_SPARSESOLVERBASE_H
/****************************************************************************** ** Copyright (c) Raoul Hecky. All Rights Reserved. ** ** Moolticute 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. ** ** Moolticute 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, write to the Free Software ** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ** ******************************************************************************/ #ifndef WSCLIENT_H #define WSCLIENT_H #include <QtCore> #include <QWebSocket> #include <QJsonDocument> #include "Common.h" #include "QtHelper.h" class WSClient: public QObject { Q_OBJECT QT_WRITABLE_PROPERTY(bool, connected, false) QT_WRITABLE_PROPERTY(Common::MPStatus, status, Common::UnknownStatus) QT_WRITABLE_PROPERTY(int, keyboardLayout, 0) QT_WRITABLE_PROPERTY(bool, lockTimeoutEnabled, false) QT_WRITABLE_PROPERTY(int, lockTimeout, 0) QT_WRITABLE_PROPERTY(bool, screensaver, false) QT_WRITABLE_PROPERTY(bool, userRequestCancel, false) QT_WRITABLE_PROPERTY(int, userInteractionTimeout, 0) QT_WRITABLE_PROPERTY(bool, flashScreen, false) QT_WRITABLE_PROPERTY(bool, offlineMode, false) QT_WRITABLE_PROPERTY(bool, tutorialEnabled, false) QT_WRITABLE_PROPERTY(int, screenBrightness, 0) QT_WRITABLE_PROPERTY(bool, knockEnabled, false) QT_WRITABLE_PROPERTY(int, knockSensitivity, 0) QT_WRITABLE_PROPERTY(bool, memMgmtMode, false) QT_WRITABLE_PROPERTY(Common::MPHwVersion, mpHwVersion, Common::MP_Classic) QT_WRITABLE_PROPERTY(QString, fwVersion, QString()) QT_WRITABLE_PROPERTY(quint32, hwSerial, 0) QT_WRITABLE_PROPERTY(int, hwMemory, 0) QT_WRITABLE_PROPERTY(bool, keyAfterLoginSendEnable, false) QT_WRITABLE_PROPERTY(int, keyAfterLoginSend, 0) QT_WRITABLE_PROPERTY(bool, keyAfterPassSendEnable, false) QT_WRITABLE_PROPERTY(int, keyAfterPassSend, 0) QT_WRITABLE_PROPERTY(bool, delayAfterKeyEntryEnable, false) QT_WRITABLE_PROPERTY(int, delayAfterKeyEntry, 0) QT_WRITABLE_PROPERTY(bool, randomStartingPin, false) QT_WRITABLE_PROPERTY(bool, displayHash, false) QT_WRITABLE_PROPERTY(int, lockUnlockMode, false) QT_WRITABLE_PROPERTY(qint64, uid, -1) public: explicit WSClient(QObject *parent = nullptr); ~WSClient(); void closeWebsocket(); QJsonObject &getMemoryData() { return memData; } QJsonArray &getFilesCache() { return filesCache; } bool isMPMini() const; bool isConnected() const; bool requestDeviceUID(const QByteArray &key); void sendEnterMMRequest(bool wantData = false); void sendLeaveMMRequest(); void addOrUpdateCredential(const QString &service, const QString &login, const QString &password, const QString &description = {}); void requestPassword(const QString &service, const QString &login); void requestDataFile(const QString &service); void sendDataFile(const QString &service, const QByteArray &data); void deleteDataFilesAndLeave(const QStringList &services); void serviceExists(bool isDatanode, const QString &service); void sendCredentialsMM(const QJsonArray &creds); void exportDbFile(const QString &encryption); void importDbFile(const QByteArray &fileData, bool noDelete); void sendListFilesCacheRequest(); void sendRefreshFilesCacheRequest(); signals: void wsConnected(); void wsDisconnected(); void memoryDataChanged(); void passwordUnlocked(const QString & service, const QString & login, const QString & password, bool success); void credentialsUpdated(const QString & service, const QString & login, const QString & description, bool success); void showAppRequested(); void progressChanged(int total, int current, QString statusMsg); void memcheckFinished(bool success); void dataFileRequested(const QString &service, const QByteArray &data, bool success); void dataFileSent(const QString &service, bool success); void dataFileDeleted(const QString &service, bool success); void credentialsExists(const QString &service, bool exists); void dataNodeExists(const QString &service, bool exists); void dbExported(const QByteArray &fileData, bool success); void dbImported(bool success, QString message); void memMgmtModeFailed(int errCode, QString errMsg); void filesCacheChanged(); public slots: void sendJsonData(const QJsonObject &data); void queryRandomNumbers(); private slots: void onWsConnected(); void onWsDisconnected(); void onWsError(); void onTextMessageReceived(const QString &message); private: void openWebsocket(); void udateParameters(const QJsonObject &data); QWebSocket *wsocket = nullptr; QJsonObject memData; QJsonArray filesCache; QTimer *randomNumTimer = nullptr; }; #endif // WSCLIENT_H
/*===========================================================================*\ RCBase.h - reference counted object base class Copyright (C) 2005 Michael A. Muller This file is part of spug++. spug++ 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. spug++ 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 spug++. If not, see <http://www.gnu.org/licenses/>. \*===========================================================================*/ #ifndef SPUG_RCBASE_H #define SPUG_RCBASE_H namespace spug { /** * Reference counting base class. This class is not thread-safe. */ class RCBase { private: int refCount; public: RCBase() : refCount(0) {} virtual ~RCBase() {} /** increment the reference count */ void incref() { ++refCount; } /** decrement the reference count */ void decref() { if (!--refCount) delete this; } /** return the reference count */ int refcnt() const { return refCount; } }; } #endif
#ifndef FLOATINGVALUEDELEGATE_H #define FLOATINGVALUEDELEGATE_H #include <QLocale> #include <QItemDelegate> class FloatingValueDelegate : public QItemDelegate { Q_OBJECT public: FloatingValueDelegate(QObject *parent = nullptr); QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const; void setEditorData(QWidget *editor, const QModelIndex &index) const; void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const; void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const; private: private slots: void onTextChanged(const QString); }; #endif // FLOATINGVALUEDELEGATE_H
/**************************************************************************** * Copyright (c) 2014 - 2015 Frédéric Bourgeois <bourgeoislab@gmail.com> * * * * This file is part of OSC-webgate. * * * * OSC-webgate 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. * * * * OSC-webgate 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 OSC-webgate. If not, see <http://www.gnu.org/licenses/>. * ****************************************************************************/ #include <stdio.h> #include <stdlib.h> #include <string.h> #include "datapool.h" #if defined(LINUX) #include <unistd.h> #include <sys/ioctl.h> #include <net/if.h> #include <arpa/inet.h> #elif defined(WIN32) #include <WinSock2.h> #endif /****************************************************************************/ static const char* getServerIpAddress(void); static const char* getServerPort(void); static const char* getOSCPort(void); /****************************************************************************/ typedef const char* (*getValueFnc)(void); typedef void (*setValueFnc)(const char*); /** Structure for a system data */ typedef struct SystemData_t { const char* pVariable; /**< Name of system variable */ const char* pConstValue; /**< Value if constant, else NULL */ getValueFnc getValue; /**< Function pointer to get a value */ setValueFnc setValue; /**< Function pointer to set a value */ }SystemData_type; static const SystemData_type systemData[] = { { "APP_NAME", APP_NAME, NULL, NULL }, { "APP_VERSION", APP_VERSION, NULL, NULL }, { "SERVER_IP", NULL, getServerIpAddress, NULL }, { "SERVER_PORT", NULL, getServerPort, NULL }, { "USER_PREFIX", app.user_prefix, NULL, NULL }, { "OSC_HOST", app.osc_host, NULL, NULL }, { "OSC_PORT", NULL, getOSCPort, NULL }, { "OSC_PREFIX", app.osc_prefix, NULL, NULL }, { NULL, NULL, NULL, NULL } }; /****************************************************************************/ /** */ void DPSYSTEM_init(void) { // nothing to do } /** */ void DPSYSTEM_deinit(void) { // nothing to do } /** */ void DPSYSTEM_refresh(void) { // nothing to do } /** */ const char* DPSYSTEM_getValue(const char *pVariable) { const SystemData_type *ptr = systemData; while (ptr->pVariable) { if (strcmp(ptr->pVariable, pVariable) == 0) { if (ptr->pConstValue) return ptr->pConstValue; else return ptr->getValue(); } ++ptr; } return NULL; } /** */ int DPSYSTEM_setValue(const char *pVariable, const char *pValue) { const SystemData_type *ptr = systemData; while (ptr->pVariable) { if (strcmp(ptr->pVariable, pVariable) == 0) { if (ptr->setValue) ptr->setValue(pValue); return 1; } ++ptr; } return 0; } /****************************************************************************/ /** */ static const char* getServerIpAddress(void) { #if defined(LINUX) const char *ret = ""; int fd = socket(AF_INET, SOCK_DGRAM, 0); if (fd != -1) { struct ifreq ifr; ifr.ifr_addr.sa_family = AF_INET; strncpy(ifr.ifr_name, "eth0", IFNAMSIZ - 1); if (ioctl(fd, SIOCGIFADDR, &ifr) != -1) ret = inet_ntoa(((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr); close(fd); } return ret; #elif defined(WIN32) char name[256]; PHOSTENT hostinfo; if (gethostname(name, sizeof(name)) == 0) { if ((hostinfo = gethostbyname(name)) != NULL) { return inet_ntoa(*(struct in_addr *)*hostinfo->h_addr_list); } } #endif return ""; } /** */ static const char* getServerPort(void) { static char port[8]; sprintf(port, "%d", app.port); return port; } /** */ static const char* getOSCPort(void) { static char port[8]; sprintf(port, "%d", app.osc_port); return port; }
/* * cbmfile.c - CBM file handling. * * Written by * Andreas Boose <viceteam@t-online.de> * * This file is part of VICE, the Versatile Commodore Emulator. * See README for copyright notice. * * 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. * */ #include "vice.h" #include <stdio.h> #include <string.h> #include "cbmdos.h" #include "cbmfile.h" #include "charset.h" #include "fileio.h" #include "ioutil.h" #include "lib.h" #include "rawfile.h" #include "types.h" static char *cbmfile_find_file(const char *fsname, const char *path) { struct ioutil_dir_s *ioutil_dir; uint8_t *name1, *name2; char *name, *retname = NULL; const char *open_path; open_path = path; if (path == NULL) { open_path = ""; } ioutil_dir = ioutil_opendir(open_path, IOUTIL_OPENDIR_ALL_FILES); if (ioutil_dir == NULL) { return NULL; } name1 = cbmdos_dir_slot_create(fsname, (unsigned int)strlen(fsname)); while (1) { unsigned int equal; name = ioutil_readdir(ioutil_dir); if (name == NULL) { break; } name2 = cbmdos_dir_slot_create(name, (unsigned int)strlen(name)); equal = cbmdos_parse_wildcard_compare(name1, name2); lib_free(name2); if (equal > 0) { retname = lib_strdup(name); break; } } lib_free(name1); ioutil_closedir(ioutil_dir); return retname; } fileio_info_t *cbmfile_open(const char *file_name, const char *path, unsigned int command, unsigned int type) { uint8_t *cbm_name; fileio_info_t *info; struct rawfile_info_s *rawfile; char *fsname, *rname; fsname = lib_strdup(file_name); if (!(command & FILEIO_COMMAND_FSNAME)) { charset_petconvstring((uint8_t *)fsname, 1); } if (cbmdos_parse_wildcard_check(fsname, (unsigned int)strlen(fsname))) { rname = cbmfile_find_file(fsname, path); lib_free(fsname); if (rname == NULL) { return NULL; } } else { rname = fsname; } rawfile = rawfile_open(rname, path, command & FILEIO_COMMAND_MASK); lib_free(rname); if (rawfile == NULL) { return NULL; } cbm_name = (uint8_t *)lib_strdup(file_name); if (command & FILEIO_COMMAND_FSNAME) { charset_petconvstring(cbm_name, 0); } info = lib_malloc(sizeof(fileio_info_t)); info->name = cbm_name; info->length = (unsigned int)strlen((char *)cbm_name); info->type = type; info->format = FILEIO_FORMAT_RAW; info->rawfile = rawfile; return info; } void cbmfile_close(fileio_info_t *info) { rawfile_destroy(info->rawfile); } unsigned int cbmfile_read(fileio_info_t *info, uint8_t *buf, unsigned int len) { return rawfile_read(info->rawfile, buf, len); } unsigned int cbmfile_write(fileio_info_t *info, uint8_t *buf, unsigned int len) { return rawfile_write(info->rawfile, buf, len); } unsigned int cbmfile_ferror(fileio_info_t *info) { return rawfile_ferror(info->rawfile); } unsigned int cbmfile_rename(const char *src_name, const char *dst_name, const char *path) { char *src_cbm, *dst_cbm; unsigned int rc; src_cbm = lib_strdup(src_name); dst_cbm = lib_strdup(dst_name); charset_petconvstring((uint8_t *)src_cbm, 1); charset_petconvstring((uint8_t *)dst_cbm, 1); rc = rawfile_rename(src_cbm, dst_cbm, path); lib_free(src_cbm); lib_free(dst_cbm); return rc; } unsigned int cbmfile_scratch(const char *file_name, const char *path) { char *src_cbm; unsigned int rc; src_cbm = lib_strdup(file_name); charset_petconvstring((uint8_t *)src_cbm, 1); rc = rawfile_remove(src_cbm, path); lib_free(src_cbm); return rc; } unsigned int cbmfile_get_bytes_left(struct fileio_info_s *info) { return rawfile_get_bytes_left(info->rawfile); }
/** ****************************************************************************** * @file PWR/PWR_CurrentConsumption/stm32f4xx_lp_modes.h * @author MCD Application Team * @version V1.1.5 * @date 17-February-2017 * @brief Header for stm32f4xx_lp_modes.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 __STM32F4xx_LP_MODES_H #define __STM32F4xx_LP_MODES_H /* Includes ------------------------------------------------------------------*/ #include "main.h" /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ #if !defined (SLEEP_MODE) && !defined (STOP_MODE) && !defined (STANDBY_MODE)\ && !defined (STANDBY_RTC_MODE) && !defined (STANDBY_RTC_BKPSRAM_MODE) /* Uncomment the corresponding line to select the STM32F4xx Low Power mode */ /*#define SLEEP_MODE*/ /*#define STOP_MODE*/ /*#define STANDBY_MODE*/ #define STANDBY_RTC_MODE /*#define STANDBY_RTC_BKPSRAM_MODE*/ #endif #if !defined (SLEEP_MODE) && !defined (STOP_MODE) && !defined (STANDBY_MODE)\ && !defined (STANDBY_RTC_MODE) && !defined (STANDBY_RTC_BKPSRAM_MODE) #error "Please select first the target STM32F4xx Low Power mode to be measured (in stm32f4xx_lp_modes.h file)" #endif /* Exported macro ------------------------------------------------------------*/ /* Exported functions ------------------------------------------------------- */ void SleepMode_Measure(void); void StopMode_Measure(void); void StandbyMode_Measure(void); void StandbyRTCMode_Measure(void); void StandbyRTCBKPSRAMMode_Measure(void); #endif /* __STM32F4xx_LP_MODES_H */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
/* * Infrared-Multiprotokoll-Decoder * * for additional information please * see http://www.mikrocontroller.net/articles/IRMP * * Copyright (c) 2010 by Erik Kunze <ethersex@erik-kunze.de> * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License (either version 2 or * 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, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * For more information on the GPL, please go to: * http://www.gnu.org/copyleft/gpl.html */ #ifndef IRMP_H #define IRMP_H #include <stdint.h> #include <stdio.h> #include <avr/pgmspace.h> #ifdef IRMP_SUPPORT typedef enum { IRMP_PROTO_NONE, /* None */ IRMP_PROTO_SIRCS, /* Sony */ IRMP_PROTO_NEC, /* NEC, Pioneer, JVC, Toshiba, NoName etc. */ IRMP_PROTO_SAMSUNG, /* Samsung */ IRMP_PROTO_MATSUSHITA, /* Matsushita */ IRMP_PROTO_KASEIKYO, /* Kaseikyo (Panasonic etc) */ IRMP_PROTO_RECS80, /* Thomson, Nordmende, Telefunken, Saba */ IRMP_PROTO_RC5, /* Philips RC5 */ IRMP_PROTO_DENON, /* Denon */ IRMP_PROTO_RC6, /* Philips RC6 */ IRMP_PROTO_SAMSUNG32, /* Samsung 32 */ IRMP_PROTO_APPLE, /* Apple */ IRMP_PROTO_RECS80EXT, /* Philips, Technisat, Thomson, Nordmende, * Telefunken, Saba */ IRMP_PROTO_NUBERT, /* Nubert */ IRMP_PROTO_BANGOLUFSEN, /* Bang & Olufsen */ IRMP_PROTO_GRUNDIG, /* Grundig */ IRMP_PROTO_NOKIA, /* Nokia */ IRMP_PROTO_SIEMENS, /* Siemens */ IRMP_PROTO_FDC, /* FDC Keyboard */ IRMP_PROTO_JVC, /* JVC */ IRMP_PROTO_RC6A, /* RC6A, e.g. Kathrein, XBOX */ IRMP_PROTO_NIKON, /* Nikon */ IRMP_PROTO_RUWIDO, /* Ruwido, e.g. T-Home Mediareceiver */ IRMP_PROTO_IR60, /* IR60 (SAB2008) */ IRMP_PROTO_KATHREIN, /* Kathrein */ IRMP_PROTO_NETBOX, /* Netbox keyboard (bitserial) */ IRMP_PROTO_NEC16, /* NEC with 16 bits */ IRMP_PROTO_NEC42, /* NEC with 42 bits */ IRMP_PROTO_LEGO, /* LEGO Power Functions RC */ IRMP_PROTO_THOMSON, /* Thomson */ } irmp_prot_e; typedef struct { irmp_prot_e protocol; /* protocol */ uint16_t address; /* address */ uint16_t command; /* command */ uint8_t flags; /* repeated key */ } irmp_data_t; #ifdef DEBUG_IRMP extern const PGM_P const irmp_proto_names[] PROGMEM; #endif /* prototypes */ void irmp_init(void); uint8_t irmp_read(irmp_data_t *); void irmp_write(irmp_data_t *); void irmp_process(void); #endif /* IRMP_SUPPORT */ #endif /* IRMP_H */
/* =================================================================== # Copyright (C) 2015-2015 # Anderson Tavares <nocturne.pe at gmail.com> PK 0x38e7bfc5c2def8ff # Lucy Mansilla <lucyacm at gmail.com> # Caio de Braz <caiobraz at gmail.com> # Hans Harley <hansbecc at gmail.com> # Paulo Miranda <pavmbr at yahoo.com.br> # # Institute of Mathematics and Statistics - IME # University of Sao Paulo - USP # # This file is part of Grafeo. # # Grafeo 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. # # Grafeo 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 Grafeo. If not, see # <http://www.gnu.org/licenses/>. # ===================================================================*/ #ifndef GRF_DISPLAYWINDOW_H #define GRF_DISPLAYWINDOW_H #include <grafeo/array.h> #include <grafeo/queue.h> #include <grafeo/imagewidget.h> #include <grafeo/trackbar.h> BEGIN_DECLS #include <grafeo/config.h> typedef enum{ GRF_MOUSE_EVENT_MOVE = 1, GRF_MOUSE_EVENT_PRESS = 2, GRF_MOUSE_EVENT_RELEASE = 4, GRF_MOUSE_EVENT_DBLCLK = 8, GRF_MOUSE_EVENT_WHEEL = 16 } GrfMouseEventType; #define GRF_MOUSE_FLAG_MASK 3 typedef enum{ // Mouse Buttons GRF_MOUSE_FLAG_LBUTTON = 0, GRF_MOUSE_FLAG_RBUTTON = 1, GRF_MOUSE_FLAG_MBUTTON = 2, // Modifiers GRF_MOUSE_FLAG_CTRLKEY = 4, GRF_MOUSE_FLAG_SHIFTKEY = 8, GRF_MOUSE_FLAG_ALTKEY = 16, } GrfMouseEventFlags; typedef enum{ GRF_KEY_EVENT_PRESS, GRF_KEY_EVENT_RELEASE, } GrfKeyEventType; typedef void (*GrfMouseCallback)(GrfMouseEventType event, int x, int y, GrfMouseEventFlags flags, void* user_data); typedef void (*GrfKeyCallback)(GrfKeyEventType event, int key_val, void* user_data); #define GRF_TYPE_DISPLAYWINDOW grf_displaywindow_get_type() G_DECLARE_DERIVABLE_TYPE(GrfDisplayWindow, grf_displaywindow, GRF, DISPLAYWINDOW, GObject) typedef struct _GrfDisplayWindowClass{ GObjectClass parent_class; }GrfDisplayWindowClass; /** * @brief grf_displaywindow_new * @return */ GrfDisplayWindow* grf_displaywindow_new(); /** * @brief grf_displaywindow_new_with_name * @param name * @return */ GrfDisplayWindow* grf_displaywindow_new_with_name(char* name); /** * @brief grf_displaywindow_set_image * @param display * @param image */ void grf_displaywindow_set_image(GrfDisplayWindow* display, GrfArray* image, gboolean invalidate); /** * @brief grf_displaywindow_get_image * @param display * @return */ GrfArray* grf_displaywindow_get_image(GrfDisplayWindow* display); /** * @brief grf_displaywindow_show * @param display */ void grf_displaywindow_show(GrfDisplayWindow* display); /** * @brief grf_displaywindow_hide * @param display */ void grf_displaywindow_hide(GrfDisplayWindow* display); /** * @brief grf_displaywindow_connect_mouse_callback * @param window * @param mouse_callback * @param user_data */ void grf_displaywindow_connect_mouse_callback(GrfDisplayWindow* window, GrfMouseCallback mouse_callback, void* user_data); /** * @brief grf_displaywindow_disconnect_mouse_callback * @param window */ void grf_displaywindow_disconnect_mouse_callback(GrfDisplayWindow* window); /** * @brief grf_displaywindow_connect_key_callback * @param display * @param key_callback * @param user_data */ void grf_displaywindow_connect_key_callback(GrfDisplayWindow* display, GrfKeyCallback key_callback, void* user_data); /** * @brief grf_displaywindow_disconnect_key_callback * @param display */ void grf_displaywindow_disconnect_key_callback(GrfDisplayWindow* display); /** * @brief grf_displaywindow_set_name * @param display * @param name */ void grf_displaywindow_set_name(GrfDisplayWindow* display, char* name); /** * @brief grf_displaywindow_get_name * @param display * @return */ char* grf_displaywindow_get_name(GrfDisplayWindow* display); /** * @brief grf_displaywindow_add_trackbar * @param display * @param trackbar */ void grf_displaywindow_add_trackbar(GrfDisplayWindow* display, GrfTrackbar* trackbar); /** * @brief grf_displaywindow_remove_trackbar * @param display * @param trackbar */ void grf_displaywindow_remove_trackbar(GrfDisplayWindow* display, GrfTrackbar* trackbar); /** * @brief grf_displaywindow_get_trackbar_by_name * @param display * @param name * @return */ GrfTrackbar* grf_displaywindow_get_trackbar_by_name(GrfDisplayWindow* display, char* name); /** * @brief grf_displaywindow_quit_on_destroy * @param display * @param value */ void grf_displaywindow_quit_on_destroy(GrfDisplayWindow* display, gboolean value); END_DECLS #endif
#ifndef BITMAP_H #define BITMAP_H #ifdef _WIN32 #pragma once #endif #include <vgui/IImage.h> #include <Color.h> namespace vgui { typedef unsigned long HTexture; class Bitmap : public IImage { public: Bitmap(const char *filename, bool hardwareFiltered); ~Bitmap(void); public: virtual void Paint(void); virtual void GetSize(int &wide, int &tall); virtual void GetContentSize(int &wide, int &tall); virtual void SetSize(int x, int y); virtual void SetPos(int x, int y); virtual void SetColor(Color col); public: void ForceUpload(void); HTexture GetID(void); const char *GetName(void); bool IsValid(void) { return _valid; } private: HTexture _id; bool _uploaded; bool _valid; char *_filename; int _pos[2]; Color _color; bool _filtered; int _wide,_tall; bool _bProcedural; }; } #endif
#ifndef CAPITALISM_VIEWMANAGER_H #define CAPITALISM_VIEWMANAGER_H #include "Base/ManagerWorld.h" class ViewManager: public ManagerWorld { public: static ViewManager* getInstance(); private: ViewManager(); static ViewManager* viewManager; }; #endif //CAPITALISM_VIEWMANAGER_H
#pragma once #include "ofMain.h" #include "Scene.h" #include "ofxSyphon.h" /* requires Syphon Framework added to build phases of app */ class Syphon : public Scene { public: void setup(); void setClient(string serverName, string appName); void update(); void draw(); private: ofxSyphonClient client; };
/* * caiman.h * * Created on: Jun 30, 2015 * Author: andy */ //#ifdef _INCLUDED_CAYMAN_PRIVATE_H_ //#error "Can not incude internal private header file in or before a public header" //#endif #ifndef _INCLUDED_CAYMAN_H_ #define _INCLUDED_CAYMAN_H_ #include <ca_object.h> #include <ca_module.h> #include <ca_number.h> #include <ca_runtime.h> #include <ca_string.h> #include <ca_import.h> #include <ca_tupleobject.h> #include <ca_abstract.h> #include <ca_float.h> #include <ca_int.h> #include <ca_type.h> #include <ca_callable.h> #include <ca_function.h> #include <ca_eval.h> #endif /* _INCLUDE_CAIMAN_H_ */
/* * Copyright (c) 2000-2001 Vojtech Pavlik <vojtech@ucw.cz> * Copyright (c) 2001, 2007 Johann Deneux <johann.deneux@gmail.com> * * USB/RS232 I-Force joysticks and wheels. */ /* * 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 * * Should you need to contact me, the author, you can do so either by * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail: * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic */ #include "iforce.h" void iforce_serial_xmit(struct iforce *iforce) { unsigned char cs; int i; unsigned long flags; if (test_and_set_bit(IFORCE_XMIT_RUNNING, iforce->xmit_flags)) { set_bit(IFORCE_XMIT_AGAIN, iforce->xmit_flags); return; } spin_lock_irqsave(&iforce->xmit_lock, flags); again: if (iforce->xmit.head == iforce->xmit.tail) { clear_bit(IFORCE_XMIT_RUNNING, iforce->xmit_flags); spin_unlock_irqrestore(&iforce->xmit_lock, flags); return; } cs = 0x2b; serio_write(iforce->serio, 0x2b); serio_write(iforce->serio, iforce->xmit.buf[iforce->xmit.tail]); cs ^= iforce->xmit.buf[iforce->xmit.tail]; XMIT_INC(iforce->xmit.tail, 1); for (i = iforce->xmit.buf[iforce->xmit.tail]; i >= 0; --i) { serio_write(iforce->serio, iforce->xmit.buf[iforce->xmit.tail]); cs ^= iforce->xmit.buf[iforce->xmit.tail]; XMIT_INC(iforce->xmit.tail, 1); } serio_write(iforce->serio, cs); if (test_and_clear_bit(IFORCE_XMIT_AGAIN, iforce->xmit_flags)) { goto again; } clear_bit(IFORCE_XMIT_RUNNING, iforce->xmit_flags); spin_unlock_irqrestore(&iforce->xmit_lock, flags); } static void iforce_serio_write_wakeup(struct serio *serio) { struct iforce *iforce = serio_get_drvdata(serio); iforce_serial_xmit(iforce); } static irqreturn_t iforce_serio_irq(struct serio *serio, unsigned char data, unsigned int flags) { struct iforce *iforce = serio_get_drvdata(serio); if (!iforce->pkt) { if (data == 0x2b) { iforce->pkt = 1; } goto out; } if (!iforce->id) { if (data > 3 && data != 0xff) { iforce->pkt = 0; } else { iforce->id = data; } goto out; } if (!iforce->len) { if (data > IFORCE_MAX_LENGTH) { iforce->pkt = 0; iforce->id = 0; } else { iforce->len = data; } goto out; } if (iforce->idx < iforce->len) { iforce->csum += iforce->data[iforce->idx++] = data; goto out; } if (iforce->idx == iforce->len) { iforce_process_packet(iforce, (iforce->id << 8) | iforce->idx, iforce->data); iforce->pkt = 0; iforce->id = 0; iforce->len = 0; iforce->idx = 0; iforce->csum = 0; } out: return IRQ_HANDLED; } static int iforce_serio_connect(struct serio *serio, struct serio_driver *drv) { struct iforce *iforce; int err; iforce = kzalloc(sizeof(struct iforce), GFP_KERNEL); if (!iforce) { return -ENOMEM; } iforce->bus = IFORCE_232; iforce->serio = serio; serio_set_drvdata(serio, iforce); err = serio_open(serio, drv); if (err) { goto fail1; } err = iforce_init_device(iforce); if (err) { goto fail2; } return 0; fail2: serio_close(serio); fail1: serio_set_drvdata(serio, NULL); kfree(iforce); return err; } static void iforce_serio_disconnect(struct serio *serio) { struct iforce *iforce = serio_get_drvdata(serio); input_unregister_device(iforce->dev); serio_close(serio); serio_set_drvdata(serio, NULL); kfree(iforce); } static struct serio_device_id iforce_serio_ids[] = { { .type = SERIO_RS232, .proto = SERIO_IFORCE, .id = SERIO_ANY, .extra = SERIO_ANY, }, { 0 } }; MODULE_DEVICE_TABLE(serio, iforce_serio_ids); struct serio_driver iforce_serio_drv = { .driver = { .name = "iforce", }, .description = "RS232 I-Force joysticks and wheels driver", .id_table = iforce_serio_ids, .write_wakeup = iforce_serio_write_wakeup, .interrupt = iforce_serio_irq, .connect = iforce_serio_connect, .disconnect = iforce_serio_disconnect, };
/* SSDV - Slow Scan Digital Video */ /*=======================================================================*/ /* Copyright 2011-2016 Philip Heron <phil@sanslogic.co.uk> */ /* */ /* 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/>. */ #include <stdio.h> #include <stdint.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include "ssdv.h" void exit_usage() { fprintf(stderr, "Usage: ssdv [-e|-d] [-n] [-t <percentage>] [-c <callsign>] [-i <id>] [-q <level>] [<in file>] [<out file>]\n" "\n" " -e Encode JPEG to SSDV packets.\n" " -d Decode SSDV packets to JPEG.\n" "\n" " -n Encode packets with no FEC.\n" " -t For testing, drops the specified percentage of packets while decoding.\n" " -c Set the callign. Accepts A-Z 0-9 and space, up to 6 characters.\n" " -i Set the image ID (0-255).\n" " -q Set the JPEG quality level (0 to 7, defaults to 4).\n" " -v Print data for each packet decoded.\n" "\n"); exit(-1); } int main(int argc, char *argv[]) { int c, i; FILE *fin = stdin; FILE *fout = stdout; char encode = -1; char type = SSDV_TYPE_NORMAL; int droptest = 0; int verbose = 0; int errors; char callsign[7]; uint8_t image_id = 0; int8_t quality = 4; ssdv_t ssdv; uint8_t pkt[SSDV_PKT_SIZE], b[128], *jpeg; size_t jpeg_length; callsign[0] = '\0'; opterr = 0; while((c = getopt(argc, argv, "ednc:i:q:t:v")) != -1) { switch(c) { case 'e': encode = 1; break; case 'd': encode = 0; break; case 'n': type = SSDV_TYPE_NOFEC; break; case 'c': if(strlen(optarg) > 6) fprintf(stderr, "Warning: callsign is longer than 6 characters.\n"); strncpy(callsign, optarg, 7); break; case 'i': image_id = atoi(optarg); break; case 'q': quality = atoi(optarg); break; case 't': droptest = atoi(optarg); break; case 'v': verbose = 1; break; case '?': exit_usage(); } } c = argc - optind; if(c > 2) exit_usage(); for(i = 0; i < c; i++) { if(!strcmp(argv[optind + i], "-")) continue; switch(i) { case 0: fin = fopen(argv[optind + i], "rb"); if(!fin) { fprintf(stderr, "Error opening '%s' for input:\n", argv[optind + i]); perror("fopen"); return(-1); } break; case 1: fout = fopen(argv[optind + i], "wb"); if(!fout) { fprintf(stderr, "Error opening '%s' for output:\n", argv[optind + i]); perror("fopen"); return(-1); } break; } } switch(encode) { case 0: /* Decode */ if(droptest > 0) fprintf(stderr, "*** NOTE: Drop test enabled: %i ***\n", droptest); ssdv_dec_init(&ssdv); jpeg_length = 1024 * 1024 * 4; jpeg = malloc(jpeg_length); ssdv_dec_set_buffer(&ssdv, jpeg, jpeg_length); i = 0; while(fread(pkt, 1, SSDV_PKT_SIZE, fin) > 0) { /* Drop % of packets */ if(droptest && (rand() / (RAND_MAX / 100) < droptest)) continue; /* Test the packet is valid */ if(ssdv_dec_is_packet(pkt, &errors) != 0) continue; if(verbose) { ssdv_packet_info_t p; ssdv_dec_header(&p, pkt); fprintf(stderr, "Decoded image packet. Callsign: %s, Image ID: %d, Resolution: %dx%d, Packet ID: %d (%d errors corrected)\n" ">> Type: %d, Quality: %d, EOI: %d, MCU Mode: %d, MCU Offset: %d, MCU ID: %d/%d\n", p.callsign_s, p.image_id, p.width, p.height, p.packet_id, errors, p.type, p.quality, p.eoi, p.mcu_mode, p.mcu_offset, p.mcu_id, p.mcu_count ); } /* Feed it to the decoder */ ssdv_dec_feed(&ssdv, pkt); i++; } ssdv_dec_get_jpeg(&ssdv, &jpeg, &jpeg_length); fwrite(jpeg, 1, jpeg_length, fout); free(jpeg); fprintf(stderr, "Read %i packets\n", i); break; case 1: /* Encode */ ssdv_enc_init(&ssdv, type, callsign, image_id, quality); ssdv_enc_set_buffer(&ssdv, pkt); i = 0; while(1) { while((c = ssdv_enc_get_packet(&ssdv)) == SSDV_FEED_ME) { size_t r = fread(b, 1, 128, fin); if(r <= 0) { fprintf(stderr, "Premature end of file\n"); break; } ssdv_enc_feed(&ssdv, b, r); } if(c == SSDV_EOI) { fprintf(stderr, "ssdv_enc_get_packet said EOI\n"); break; } else if(c != SSDV_OK) { fprintf(stderr, "ssdv_enc_get_packet failed: %i\n", c); return(-1); } fwrite(pkt, 1, SSDV_PKT_SIZE, fout); i++; } fprintf(stderr, "Wrote %i packets\n", i); break; default: fprintf(stderr, "No mode specified.\n"); break; } if(fin != stdin) fclose(fin); if(fout != stdout) fclose(fout); return(0); }
#include <stdio.h> // Pointers can point to functions int fun(int x, int *p) { return x + *p; } int main() { int (*fp)(int, int *); fp = fun; int y = 1; int result = fp(3, &y); printf("result: %d\n", result); }
/* * This file is part of easyFPGA. * Copyright 2013-2015 os-cillation GmbH * * Author: Johannes Hein <support@os-cillation.de> * * easyFPGA 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. * * easyFPGA 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 easyFPGA. If not, see <http://www.gnu.org/licenses/>. * */ #ifndef SDK_COMMUNICATOR_PROTOCOL_SOCEXCHANGES_INTERRUPTENABLE_H_ #define SDK_COMMUNICATOR_PROTOCOL_SOCEXCHANGES_INTERRUPTENABLE_H_ #include "communication/protocol/calculator.h" #include "communication/protocol/exchange.h" #include "communication/protocol/frame_ptr.h" #include "easycores/callback_ptr.h" #include "utils/hardwaretypes.h" /** * \brief Defines an soc operation for a global release of all interrupts. * (An soc context is neccessary.) * * This class can be used in combination with a specific execution environment * derived from Task. * * The fpga can only trigger interrupts after execution of this InterruptEnable * exchange. All interrupt sources of all cores will be activated at the * same time. Maybe there will be more fine-grained interrupt settings at * the corresponding easyCore. * * After each interrupt tripping the fpga disables all interrupt sources. * (So, they have to be activated agian in an interrupt service routine.) * * <b>IMPORTANT: There are interrupt priorities in the order how an easyCore * was added to the the EasyFpga.</b> */ class InterruptEnable : public Exchange { public: /** * \brief Creates an InterruptEnable exchange * * \param callback */ InterruptEnable(callback_ptr callback) : Exchange(3, 1000000, 3, 4, Exchange::SHARED_REPLY_CODES::ACK, callback) { } ~InterruptEnable() { } /** * \brief Gets a pre-defined request frame for this exchange * * \return A pointer to the request frame */ frame_ptr getRequest(void) { if (_request == NULL) { byte requestBuffer[_REQUEST_LENGTH]; requestBuffer[0] = (byte)0xAA; requestBuffer[1] = (byte)_id; requestBuffer[2] = Calculator::calculateXorParity(requestBuffer, 2); this->setRequest(requestBuffer); } return _request; } /** * \brief Checks if no parity error occured in case of a successful * exchange execution. * * \return true if the transmitted parity equals the calculated one,\n * false otherwise */ bool successChecksumIsCorrect(byte* data) { return true; } /** * \brief Checks if no parity error occured in case of a faulty * exchange execution. * * \return true if the transmitted parity equals the calculated one,\n * false otherwise */ bool errorChecksumIsCorrect(byte* data) { return true; } /** * \brief Write the reply from the easyFPGA board from this frame * back into the user's memory (if a reply will be expected). */ void writeResults(void) { } }; #endif // SDK_COMMUNICATOR_PROTOCOL_SOCEXCHANGES_INTERRUPTENABLE_H_
#include<stdio.h> #include<stdlib.h> #define MAX 1000 int prefixsum[MAX];//array to store prefixsums /*function that calculates prefix sum by forming the prefixsum array */ void calculate_prefix_sum (int arr[], int n) { prefixsum[0] = arr[0]; //starts with the first element for (int i = 1; i < n; i++) { /*calculates prefixsum by adding the new element with the previous element in the prefixsum array */ prefixsum[i] = prefixsum[i-1] + arr[i]; } } //main function int main() { int n; scanf("%d", &n); int arr[n]; for (int i = 0; i < n; i++) { scanf("%d", &arr[i]); } calculate_prefix_sum(arr, n); for (int i = 0; i < n; i++) printf ("%d ",prefixsum[i]); printf("\n"); } /* OUTPUT 1 3 6 10 15 */
/* ----------------------------------------------------------------------------------------------- This source file is part of the Particle Universe product. Copyright (c) 2010 Henry van Merode Usage of this program is licensed under the terms of the Particle Universe Commercial License. You can find a copy of the Commercial License in the Particle Universe package. ----------------------------------------------------------------------------------------------- */ #ifndef __PU_TEXTURE_ROTATOR_TOKENS_H__ #define __PU_TEXTURE_ROTATOR_TOKENS_H__ #include "ParticleUniversePrerequisites.h" #include "ParticleUniverseAffectorTokens.h" namespace ParticleUniverse { /** The TextureRotatorTranslator parses 'TextureRotator' tokens */ class _ParticleUniverseExport TextureRotatorTranslator : public ScriptTranslator { public: TextureRotatorTranslator(void){}; ~TextureRotatorTranslator(void){}; virtual bool translateChildProperty(ScriptCompiler* compiler, const AbstractNodePtr &node); virtual bool translateChildObject(ScriptCompiler* compiler, const AbstractNodePtr &node); }; //------------------------------------------------------------------------- //------------------------------------------------------------------------- //------------------------------------------------------------------------- /** */ class _ParticleUniverseExport TextureRotatorWriter : public ParticleAffectorWriter { public: TextureRotatorWriter(void) {}; virtual ~TextureRotatorWriter(void) {}; /** @see ScriptWriter::write */ virtual void write(ParticleScriptSerializer* serializer , const IElement* element); }; } #endif
// Copyright (c) 2005 - 2017 Settlers Freaks (sf-team at siedler25.org) // // This file is part of Return To The Roots. // // Return To The Roots 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. // // Return To The Roots 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 Return To The Roots. If not, see <http://www.gnu.org/licenses/>. #pragma once #include "noBuilding.h" #include "gameTypes/GoodTypes.h" #include <array> #include <list> #include <vector> class Ware; class nofBuildingWorker; class SerializedGameData; class noFigure; class noRoadNode; class GameEvent; // Gewöhnliches Gebäude mit einem Arbeiter und Waren class nobUsual : public noBuilding { /// Der Typ, der hier arbeitet nofBuildingWorker* worker; /// Produktivität unsigned short productivity; /// Produktion eingestellt? (letzteres nur visuell, um Netzwerk-Latenzen zu verstecken) bool disable_production, disable_production_virtual; /// Warentyp, den er zuletzt bestellt hatte (bei >1 Waren) unsigned char last_ordered_ware; /// Rohstoffe, die zur Produktion benötigt werden std::array<unsigned char, 3> numWares; /// Bestellte Waren std::vector<std::list<Ware*>> ordered_wares; /// Bestell-Ware-Event const GameEvent* orderware_ev; /// Rechne-Produktivität-aus-Event const GameEvent* productivity_ev; /// Letzte Produktivitäten (Durchschnitt = Gesamt produktivität), vorne das neuste ! std::array<unsigned short, 6> last_productivities; /// How many GFs he did not work since the last productivity calculation unsigned short numGfNotWorking; /// Since which GF he did not work (0xFFFFFFFF = currently working) unsigned since_not_working; /// Did we notify the player that we are out of resources? bool outOfRessourcesMsgSent; protected: friend class SerializedGameData; friend class BuildingFactory; nobUsual(BuildingType type, MapPoint pos, unsigned char player, Nation nation); nobUsual(SerializedGameData& sgd, unsigned obj_id); public: /// Wird gerade gearbeitet oder nicht? bool is_working; ~nobUsual() override; protected: void DestroyBuilding() override; void Serialize_nobUsual(SerializedGameData& sgd) const; public: void Serialize(SerializedGameData& sgd) const override { Serialize_nobUsual(sgd); } GO_Type GetGOT() const override { return GOT_NOB_USUAL; } unsigned GetMilitaryRadius() const override { return 0; } void Draw(DrawPoint drawPt) override; bool HasWorker() const; /// Event-Handler void HandleEvent(unsigned id) override; /// Legt eine Ware am Objekt ab (an allen Straßenknoten (Gebäude, Baustellen und Flaggen) kann man Waren ablegen void AddWare(Ware*& ware) override; /// Wird aufgerufen, wenn von der Fahne vor dem Gebäude ein Rohstoff aufgenommen wurde bool FreePlaceAtFlag() override; /// Eine bestellte Ware konnte doch nicht kommen void WareLost(Ware* ware) override; /// Wird aufgerufen, wenn ein Arbeiter für das Gebäude gefunden werden konnte void GotWorker(Job job, noFigure* worker) override; /// Wird vom Arbeiter aufgerufen, wenn er im Gebäude angekommen ist void WorkerArrived(); /// Wird vom Arbeiter aufgerufen, wenn er nicht (mehr) zur Arbeit kommen kann void WorkerLost(); /// Gibt den Warenbestand (eingehende Waren - Rohstoffe) zurück unsigned char GetNumWares(unsigned id) const { return numWares[id]; } /// Prüft, ob Waren für einen Arbeitsschritt vorhanden sind bool WaresAvailable(); /// Verbraucht Waren void ConsumeWares(); /// Berechnet Punktewertung für Ware type, start ist der Produzent, von dem die Ware kommt unsigned CalcDistributionPoints(noRoadNode* start, GoodType type); /// Wird aufgerufen, wenn eine neue Ware zum dem Gebäude geliefert wird (nicht wenn sie bestellt wurde vom Gebäude!) void TakeWare(Ware* ware) override; /// Bestellte Waren bool AreThereAnyOrderedWares() const { for(const auto& ordered_ware : ordered_wares) if(!ordered_ware.empty()) return true; return false; } /// Gibt Pointer auf Produktivität zurück const unsigned short* GetProductivityPointer() const { return &productivity; } unsigned short GetProductivity() const { return productivity; } const nofBuildingWorker* GetWorker() const { return worker; } /// Stoppt/Erlaubt Produktion (visuell) void ToggleProductionVirtual() { disable_production_virtual = !disable_production_virtual; } /// Stoppt/Erlaubt Produktion (real) void SetProductionEnabled(bool enabled); /// Fragt ab, ob Produktion ausgeschaltet ist (visuell) bool IsProductionDisabledVirtual() const { return disable_production_virtual; } /// Fragt ab, ob Produktion ausgeschaltet ist (real) bool IsProductionDisabled() const { return disable_production; } /// Called when there are no more resources void OnOutOfResources(); /// Fängt an NICHT zu arbeiten (wird gemessen fürs Ausrechnen der Produktivität) void StartNotWorking(); /// Hört auf, nicht zu arbeiten, sprich fängt an zu arbeiten (fürs Ausrechnen der Produktivität) void StopNotWorking(); private: /// Calculates the productivity and resets the counter unsigned short CalcProductivity(); };
/* Process handling for Windows Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. This file is part of GNU Make. GNU Make 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. GNU Make 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 <stddef.h> #include <stdlib.h> #include <string.h> #include <windows.h> #include "proc.h" /* * Description: Convert a NULL string terminated UNIX environment block to * an environment block suitable for a windows32 system call * * Returns: TRUE= success, FALSE=fail * * Notes/Dependencies: the environment block is sorted in case-insensitive * order, is double-null terminated, and is a char *, not a char ** */ int _cdecl compare(const void *a1, const void *a2) { return _stricoll(*((char**)a1),*((char**)a2)); } bool_t arr2envblk(char **arr, char **envblk_out) { char **tmp; int size_needed; int arrcnt; char *ptr; arrcnt = 0; while (arr[arrcnt]) { arrcnt++; } tmp = (char**) calloc(arrcnt + 1, sizeof(char *)); if (!tmp) { return FALSE; } arrcnt = 0; size_needed = 0; while (arr[arrcnt]) { tmp[arrcnt] = arr[arrcnt]; size_needed += strlen(arr[arrcnt]) + 1; arrcnt++; } size_needed++; qsort((void *) tmp, (size_t) arrcnt, sizeof (char*), compare); ptr = *envblk_out = calloc(size_needed, 1); if (!ptr) { free(tmp); return FALSE; } arrcnt = 0; while (tmp[arrcnt]) { strcpy(ptr, tmp[arrcnt]); ptr += strlen(tmp[arrcnt]) + 1; arrcnt++; } free(tmp); return TRUE; }
/* * copyright (c) 2003 Fabrice Bellard * * This file is part of FFmpeg. * * FFmpeg 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. * * FFmpeg 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 FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file * @ingroup lavu * Libavutil version macros */ #ifndef AVUTIL_VERSION_H #define AVUTIL_VERSION_H #include "macros.h" /** * @addtogroup version_utils * * Useful to check and match library version in order to maintain * backward compatibility. * * The FFmpeg libraries follow a versioning sheme very similar to * Semantic Versioning (http://semver.org/) * The difference is that the component called PATCH is called MICRO in FFmpeg * and its value is reset to 100 instead of 0 to keep it above or equal to 100. * Also we do not increase MICRO for every bugfix or change in git master. * * Prior to FFmpeg 3.2 point releases did not change any lib version number to * avoid aliassing different git master checkouts. * Starting with FFmpeg 3.2, the released library versions will occupy * a separate MAJOR.MINOR that is not used on the master development branch. * That is if we branch a release of master 55.10.123 we will bump to 55.11.100 * for the release and master will continue at 55.12.100 after it. Each new * point release will then bump the MICRO improving the usefulness of the lib * versions. * * @{ */ #define AV_VERSION_INT(a, b, c) ((a)<<16 | (b)<<8 | (c)) #define AV_VERSION_DOT(a, b, c) a ##.## b ##.## c #define AV_VERSION(a, b, c) AV_VERSION_DOT(a, b, c) /** * Extract version components from the full ::AV_VERSION_INT int as returned * by functions like ::avformat_version() and ::avcodec_version() */ #define AV_VERSION_MAJOR(a) ((a) >> 16) #define AV_VERSION_MINOR(a) (((a) & 0x00FF00) >> 8) #define AV_VERSION_MICRO(a) ((a) & 0xFF) /** * @} */ /** * @defgroup lavu_ver Version and Build diagnostics * * Macros and function useful to check at compiletime and at runtime * which version of libavutil is in use. * * @{ */ #define LIBAVUTIL_VERSION_MAJOR 55 #define LIBAVUTIL_VERSION_MINOR 73 #define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ LIBAVUTIL_VERSION_MINOR, \ LIBAVUTIL_VERSION_MICRO) #define LIBAVUTIL_VERSION AV_VERSION(LIBAVUTIL_VERSION_MAJOR, \ LIBAVUTIL_VERSION_MINOR, \ LIBAVUTIL_VERSION_MICRO) #define LIBAVUTIL_BUILD LIBAVUTIL_VERSION_INT #define LIBAVUTIL_IDENT "Lavu" AV_STRINGIFY(LIBAVUTIL_VERSION) /** * @defgroup lavu_depr_guards Deprecation Guards * FF_API_* defines may be placed below to indicate public API that will be * dropped at a future version bump. The defines themselves are not part of * the public API and may change, break or disappear at any time. * * @note, when bumping the major version it is recommended to manually * disable each FF_API_* in its own commit instead of disabling them all * at once through the bump. This improves the git bisect-ability of the change. * * @{ */ #ifndef FF_API_VDPAU #define FF_API_VDPAU (LIBAVUTIL_VERSION_MAJOR < 56) #endif #ifndef FF_API_XVMC #define FF_API_XVMC (LIBAVUTIL_VERSION_MAJOR < 56) #endif #ifndef FF_API_OPT_TYPE_METADATA #define FF_API_OPT_TYPE_METADATA (LIBAVUTIL_VERSION_MAJOR < 56) #endif #ifndef FF_API_DLOG #define FF_API_DLOG (LIBAVUTIL_VERSION_MAJOR < 56) #endif #ifndef FF_API_VAAPI #define FF_API_VAAPI (LIBAVUTIL_VERSION_MAJOR < 56) #endif #ifndef FF_API_FRAME_QP #define FF_API_FRAME_QP (LIBAVUTIL_VERSION_MAJOR < 56) #endif #ifndef FF_API_PLUS1_MINUS1 #define FF_API_PLUS1_MINUS1 (LIBAVUTIL_VERSION_MAJOR < 56) #endif #ifndef FF_API_ERROR_FRAME #define FF_API_ERROR_FRAME (LIBAVUTIL_VERSION_MAJOR < 56) #endif #ifndef FF_API_CRC_BIG_TABLE #define FF_API_CRC_BIG_TABLE (LIBAVUTIL_VERSION_MAJOR < 56) #endif #ifndef FF_API_PKT_PTS #define FF_API_PKT_PTS (LIBAVUTIL_VERSION_MAJOR < 56) #endif #ifndef FF_API_CRYPTO_SIZE_T #define FF_API_CRYPTO_SIZE_T (LIBAVUTIL_VERSION_MAJOR < 56) #endif /** * @} * @} */ #endif /* AVUTIL_VERSION_H */
// Copyright (C) 1999-2021 // Smithsonian Astrophysical Observatory, Cambridge, MA, USA // For conditions of distribution and use, see copyright notice in "copyright" #include <string.h> #include <iostream> #include <sstream> #include <iomanip> using namespace std; #ifndef __colorscale_h__ #define __colorscale_h__ // 0 background (white) // 1-200 data, 1 lowerlimit 200 upperlimit // 201 cursor color (white) // 202-217 colors #define IISMIN 1 #define IISMAX 200 #define IISCOLORS 201 #define IISSIZE 218 class ColorScale { public: int size_; unsigned char* psColors_; // rgb for ps unsigned char* colors_; // for render public: ColorScale(int); virtual ~ColorScale(); int size() {return size_;} const unsigned char* psColors() {return psColors_;} const unsigned char* colors() {return colors_;} }; class LinearScale : public virtual ColorScale { public: LinearScale(int, unsigned char*, int); }; class LogScale : public virtual ColorScale { public: LogScale(int, unsigned char*, int, double); }; class PowScale : public virtual ColorScale { public: PowScale(int, unsigned char*, int, double); }; class SqrtScale : public virtual ColorScale { public: SqrtScale(int, unsigned char*, int); }; class SquaredScale : public virtual ColorScale { public: SquaredScale(int, unsigned char*, int); }; class AsinhScale : public virtual ColorScale { public: AsinhScale(int, unsigned char*, int); }; class SinhScale : public virtual ColorScale { public: SinhScale(int, unsigned char*, int); }; class IISScale : public virtual ColorScale { public: IISScale(unsigned char*, int); }; class HistEquScale : public virtual ColorScale { public: HistEquScale(int, unsigned char*, int, double*, int); }; #endif
/* gpakeyexpireop.h - The GpaKeyExpireOperation object. * Copyright (C) 2003, Miguel Coca. * * This file is part of GPA * * GPA 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. * * GPA 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 GPA_KEY_EXPIRE_OP_H #define GPA_KEY_EXPIRE_OP_H #include <glib.h> #include <glib-object.h> #include "gpa.h" #include "gpakeyop.h" /* GObject stuff */ #define GPA_KEY_EXPIRE_OPERATION_TYPE (gpa_key_expire_operation_get_type ()) #define GPA_KEY_EXPIRE_OPERATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GPA_KEY_EXPIRE_OPERATION_TYPE, GpaKeyExpireOperation)) #define GPA_KEY_EXPIRE_OPERATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GPA_KEY_EXPIRE_OPERATION_TYPE, GpaKeyExpireOperationClass)) #define GPA_IS_KEY_EXPIRE_ENCRYPT_OPERATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GPA_KEY_EXPIRE_OPERATION_TYPE)) #define GPA_IS_KEY_EXPIRE_OPERATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GPA_KEY_EXPIRE_OPERATION_TYPE)) #define GPA_KEY_EXPIRE_OPERATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GPA_KEY_EXPIRE_OPERATION_TYPE, GpaKeyExpireOperationClass)) typedef struct _GpaKeyExpireOperation GpaKeyExpireOperation; typedef struct _GpaKeyExpireOperationClass GpaKeyExpireOperationClass; struct _GpaKeyExpireOperation { GpaKeyOperation parent; int modified_keys; GDate *date; }; struct _GpaKeyExpireOperationClass { GpaKeyOperationClass parent_class; /* Signals the new expiration date for a key */ void (*new_expiration) (GpaKeyExpireOperation *op, gpgme_key_t key, GDate *date); }; GType gpa_key_expire_operation_get_type (void) G_GNUC_CONST; /* API */ /* Creates a new key deletion operation. */ GpaKeyExpireOperation* gpa_key_expire_operation_new (GtkWidget *window, GList *keys); #endif
/* Licenced under GPL version 2 */ #include <stdio.h> int main(int argc, char *argv[] ) { //print the statement printf ("hello_world\n") ; printf ("okay_bye"); return 0; }
#include <hw_config.h> #include <user_interface.h> #include <debug.h> struct hw_config HwConfig __attribute__((aligned(4))); void ICACHE_FLASH_ATTR hw_config_load(bool reset) { INFO("Loading hardware config."); ets_memset(&HwConfig, 0, sizeof(HwConfig)); system_param_load(HW_CONFIG_SECTOR, 0, (uint32*)&HwConfig, sizeof(HwConfig)); if(HwConfig.magic != HW_CONFIG_MAGIC || reset) { WARN("Initializing hardware config."); ets_memset(&HwConfig, 0, sizeof(HwConfig)); ets_sprintf(HwConfig.Type, "Default"); HwConfig.Rev = 1; hw_config_save(); } INFO("Hardware: %s rev. %d", HwConfig.Type, HwConfig.Rev); } void ICACHE_FLASH_ATTR hw_config_save() { INFO("Saving hardware config."); HwConfig.magic = HW_CONFIG_MAGIC; system_param_save_with_protect(HW_CONFIG_SECTOR, (uint32*)&HwConfig, sizeof(HwConfig)); }
/* This file is an image processing operation for GEGL * * GEGL 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. * * GEGL 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 GEGL; if not, see <http://www.gnu.org/licenses/>. * * Color To Alpha plug-in v1.0 by Seth Burgess, sjburges@gimp.org 1999/05/14 * with algorithm by clahey * Copyright (C) 1995 Spencer Kimball and Peter Mattis * Copyright (C) 2011 Robert Sasu <sasu.robert@gmail.com> * Copyright (C) 2012 Øyvind Kolås <pippin@gimp.org> */ #include "config.h" #include <glib/gi18n-lib.h> #ifdef GEGL_CHANT_PROPERTIES gegl_chant_color (color, _("Color"), "white", _("The color to render (defaults to 'white')")) #else #define GEGL_CHANT_TYPE_POINT_FILTER #define GEGL_CHANT_C_FILE "color-to-alpha.c" #include "gegl-chant.h" #include <stdio.h> #include <math.h> static void prepare (GeglOperation *operation) { gegl_operation_set_format (operation, "input", babl_format ("R'G'B'A double")); gegl_operation_set_format (operation, "output", babl_format ("R'G'B'A double")); } /* * An excerpt from a discussion on #gimp that sheds some light on the ideas * behind the algorithm that is being used here. * <clahey> so if a1 > c1, a2 > c2, and a3 > c2 and a1 - c1 > a2-c2, a3-c3, then a1 = b1 * alpha + c1 * (1-alpha) So, maximizing alpha without taking b1 above 1 gives a1 = alpha + c1(1-alpha) and therefore alpha = (a1-c1) / (1-c1). <sjburges> clahey: btw, the ordering of that a2, a3 in the white->alpha didn't matter <clahey> sjburges: You mean that it could be either a1, a2, a3 or a1, a3, a2? <sjburges> yeah <sjburges> because neither one uses the other <clahey> sjburges: That's exactly as it should be. They are both just getting reduced to the same amount, limited by the the darkest color. <clahey> Then a2 = b2 * alpha + c2 * (1- alpha). Solving for b2 gives b2 = (a1-c2)/alpha + c2. <sjburges> yeah <clahey> That gives us are formula for if the background is darker than the foreground? Yep. <clahey> Next if a1 < c1, a2 < c2, a3 < c3, and c1-a1 > c2-a2, c3-a3, and by our desired result a1 = b1 * alpha + c1 * (1-alpha), we maximize alpha without taking b1 negative gives alpha = 1 - a1 / c1. <clahey> And then again, b2 = (a2-c2) / alpha + c2 by the same formula. (Actually, I think we can use that formula for all cases, though it may possibly introduce rounding error. <clahey> sjburges: I like the idea of using floats to avoid rounding error. Good call. */ static void color_to_alpha (const gdouble *color, const gdouble *src, gdouble *dst) { gint i; gdouble alpha[4]; for (i=0; i<4; i++) dst[i] = src[i]; alpha[3] = dst[3]; for (i=0; i<3; i++) { if (color[i] < 0.0001) alpha[i] = dst[i]; else if (dst[i] > color[i]) alpha[i] = (dst[i] - color[i]) / (1.0f - color[i]); else if (dst[i] < color[i]) alpha[i] = (color[i] - dst[i]) / (color[i]); else alpha[i] = 0.0f; } if (alpha[0] > alpha[1]) { if (alpha[0] > alpha[2]) dst[3] = alpha[0]; else dst[3] = alpha[2]; } else if (alpha[1] > alpha[2]) { dst[3] = alpha[1]; } else { dst[3] = alpha[2]; } if (dst[3] < 0.0001) return; for (i=0; i<3; i++) dst[i] = (dst[i] - color[i]) / dst[3] + color[i]; dst[3] *= alpha[3]; } static gboolean process (GeglOperation *operation, void *in_buf, void *out_buf, glong n_pixels, const GeglRectangle *roi, gint level) { GeglChantO *o = GEGL_CHANT_PROPERTIES (operation); const Babl *format = babl_format ("R'G'B'A double"); gdouble color[4]; gint x; gdouble *in_buff = in_buf; gdouble *out_buff = out_buf; gegl_color_get_pixel (o->color, format, color); for (x = 0; x < n_pixels; x++) { color_to_alpha (color, in_buff, out_buff); in_buff += 4; out_buff += 4; } return TRUE; } static void gegl_chant_class_init (GeglChantClass *klass) { GeglOperationClass *operation_class; GeglOperationPointFilterClass *filter_class; gchar *composition = "<?xml version='1.0' encoding='UTF-8'?>" "<gegl>" "<node operation='svg:dst-over'>" " <node operation='gegl:crop'>" " <params>" " <param name='width'>200.0</param>" " <param name='height'>200.0</param>" " </params>" " </node>" " <node operation='gegl:checkerboard'>" " <params><param name='color1'>rgb(0.5, 0.5, 0.5)</param></params>" " </node>" "</node>" "<node operation='gegl:color-to-alpha'>" "</node>" "<node operation='gegl:load'>" " <params>" " <param name='path'>standard-input.png</param>" " </params>" "</node>" "</gegl>"; operation_class = GEGL_OPERATION_CLASS (klass); filter_class = GEGL_OPERATION_POINT_FILTER_CLASS (klass); filter_class->process = process; operation_class->prepare = prepare; gegl_operation_class_set_keys (operation_class, "name" , "gegl:color-to-alpha", "categories" , "color", "description", _("Performs color-to-alpha on the image."), "reference-composition", composition, NULL); } #endif