text
stringlengths
4
6.14k
/* (c) 2009,2010,2011 Ian Clark This file is part of Yasst. Yasst 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. Yasst 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 Yasst. If not, see <http://www.gnu.org/licenses/>. */ /* $Id: UserGroupFollowingFetcher.h,v 1.1 2010/03/17 18:48:14 ian Exp $ File : UserGroupFollowingFetcher.h Create date: 22:56:21 10 Mar 2010 Project : yasst (c) 2010 Ian Clark */ #ifndef USERGROUPFOLLOWINGFETCHER_H_ #define USERGROUPFOLLOWINGFETCHER_H_ #include "UserGroupFetcher.h" class UserGroupFollowingFetcher: public UserGroupFetcher { Q_OBJECT public: UserGroupFollowingFetcher(); virtual ~UserGroupFollowingFetcher(); virtual void populate(); }; #endif /* USERGROUPFOLLOWINGFETCHER_H_ */
// // config.h // // Circle - A C++ bare metal environment for Raspberry Pi // Copyright (C) 2017 R. Stange <rsta2@o2online.de> // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // #ifndef _config_h #define _config_h #define SAMPLE_RATE 44100 // overall system clock #define WRITE_FORMAT 1 // 0: 8-bit unsigned, 1: 16-bit signed, 2: 24-bit signed #define WRITE_CHANNELS 2 // 1: Mono, 2: Stereo #define VOLUME 0.5 // [0.0, 1.0] #define QUEUE_SIZE_MSECS 100 // size of the sound queue in milliseconds duration #define CHUNK_SIZE 2000 // number of samples, written to sound device at once #endif
/**************************************************************************************** * * File: * CANArduinoNode.h * * Purpose: * Sends data to the Actuator unit with the rudder and wingsail angles over the CAN bus. * * Developer Notes: * The CAN frame ID nubmer that this node subscribe to are: * 700 * ***************************************************************************************/ #pragma once #include "../Hardwares/CAN_Services/CANService.h" #include "../Math/Utility.hpp" #include "../MessageBus/MessageBus.hpp" #include "../MessageBus/MessageTypes.hpp" #include "../Messages/RudderCommandMsg.hpp" #include "../Messages/WingSailCommandMsg.hpp" class ActuatorNodeASPire : public Node { public: ActuatorNodeASPire(MessageBus& msgBus, CANService& canService); ~ActuatorNodeASPire(); bool init(); void processMessage(const Message* message); void sendCommandMessage(); private: CANService* m_CANService; double m_rudderAngle; // degree in vessel reference frame (counter clockwise from top view) double m_wingsailAngle; // tail angle degree in wing sail reference frame (clockwise from top // view) bool m_windvaneSelfSteeringOn; };
/* * This file is part of DisOrder. * Copyright (C) 2004, 2005, 2007, 2008 Richard Kettlewell * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ /** @file lib/signame.c * @brief Signal names */ #include "common.h" #include <signal.h> #include <stddef.h> #include "table.h" #include "signame.h" /** @brief Mapping between signal names and numbers */ static const struct sigtable { /** @brief Signal number */ int signal; /* @brief Signal name ("SIGwhatever") */ const char *name; } signals[] = { #define S(sig) { sig, #sig } /* table must be kept in lexical order */ #ifdef SIGABRT S(SIGABRT), #endif #ifdef SIGALRM S(SIGALRM), #endif #ifdef SIGBUS S(SIGBUS), #endif #ifdef SIGCHLD S(SIGCHLD), #endif #ifdef SIGCONT S(SIGCONT), #endif #ifdef SIGFPE S(SIGFPE), #endif #ifdef SIGHUP S(SIGHUP), #endif #ifdef SIGILL S(SIGILL), #endif #ifdef SIGINT S(SIGINT), #endif #ifdef SIGIO S(SIGIO), #endif #ifdef SIGIOT S(SIGIOT), #endif #ifdef SIGKILL S(SIGKILL), #endif #ifdef SIGPIPE S(SIGPIPE), #endif #ifdef SIGPOLL S(SIGPOLL), #endif #ifdef SIGPROF S(SIGPROF), #endif #ifdef SIGPWR S(SIGPWR), #endif #ifdef SIGQUIT S(SIGQUIT), #endif #ifdef SIGSEGV S(SIGSEGV), #endif #ifdef SIGSTKFLT S(SIGSTKFLT), #endif #ifdef SIGSTOP S(SIGSTOP), #endif #ifdef SIGSYS S(SIGSYS), #endif #ifdef SIGTERM S(SIGTERM), #endif #ifdef SIGTRAP S(SIGTRAP), #endif #ifdef SIGTSTP S(SIGTSTP), #endif #ifdef SIGTTIN S(SIGTTIN), #endif #ifdef SIGTTOU S(SIGTTOU), #endif #ifdef SIGURG S(SIGURG), #endif #ifdef SIGUSR1 S(SIGUSR1), #endif #ifdef SIGUSR2 S(SIGUSR2), #endif #ifdef SIGVTALRM S(SIGVTALRM), #endif #ifdef SIGWINCH S(SIGWINCH), #endif #ifdef SIGXCPU S(SIGXCPU), #endif #ifdef SIGXFSZ S(SIGXFSZ), #endif #undef S }; /** @brief Map a signal name to its number * @param s Signal name e.g. "SIGINT" * @return Signal value or -1 if not found */ int find_signal(const char *s) { int n; if((n = TABLE_FIND(signals, name, s)) < 0) return -1; return signals[n].signal; } /* Local Variables: c-basic-offset:2 comment-column:40 fill-column:79 indent-tabs-mode:nil End: */
// // SopinetChat_Bridging_Header.h // Pods // // Created by David Moreno Lora on 30/3/16. // // #ifndef SopinetChat_Bridging_Header_h #define SopinetChat_Bridging_Header_h #import <Foundation/Foundation.h> #import <UIKit/UIKit.h> #endif /* SopinetChat_Bridging_Header_h */
/* Substitute for and wrapper around <langinfo.h>. Copyright (C) 2009-2012 Free Software Foundation, Inc. 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, 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /* * POSIX <langinfo.h> for platforms that lack it or have an incomplete one. * <http://www.opengroup.org/onlinepubs/9699919799/basedefs/langinfo.h.html> */ #ifndef _@GUARD_PREFIX@_LANGINFO_H #if __GNUC__ >= 3 @PRAGMA_SYSTEM_HEADER@ #endif @PRAGMA_COLUMNS@ /* The include_next requires a split double-inclusion guard. */ #if @HAVE_LANGINFO_H@ # @INCLUDE_NEXT@ @NEXT_LANGINFO_H@ #endif #ifndef _@GUARD_PREFIX@_LANGINFO_H #define _@GUARD_PREFIX@_LANGINFO_H #if !@HAVE_LANGINFO_H@ /* A platform that lacks <langinfo.h>. */ /* Assume that it also lacks <nl_types.h> and the nl_item type. */ # if !GNULIB_defined_nl_item typedef int nl_item; # define GNULIB_defined_nl_item 1 # endif /* nl_langinfo items of the LC_CTYPE category */ # define CODESET 10000 /* nl_langinfo items of the LC_NUMERIC category */ # define RADIXCHAR 10001 # define THOUSEP 10002 /* nl_langinfo items of the LC_TIME category */ # define D_T_FMT 10003 # define D_FMT 10004 # define T_FMT 10005 # define T_FMT_AMPM 10006 # define AM_STR 10007 # define PM_STR 10008 # define DAY_1 10009 # define DAY_2 (DAY_1 + 1) # define DAY_3 (DAY_1 + 2) # define DAY_4 (DAY_1 + 3) # define DAY_5 (DAY_1 + 4) # define DAY_6 (DAY_1 + 5) # define DAY_7 (DAY_1 + 6) # define ABDAY_1 10016 # define ABDAY_2 (ABDAY_1 + 1) # define ABDAY_3 (ABDAY_1 + 2) # define ABDAY_4 (ABDAY_1 + 3) # define ABDAY_5 (ABDAY_1 + 4) # define ABDAY_6 (ABDAY_1 + 5) # define ABDAY_7 (ABDAY_1 + 6) # define MON_1 10023 # define MON_2 (MON_1 + 1) # define MON_3 (MON_1 + 2) # define MON_4 (MON_1 + 3) # define MON_5 (MON_1 + 4) # define MON_6 (MON_1 + 5) # define MON_7 (MON_1 + 6) # define MON_8 (MON_1 + 7) # define MON_9 (MON_1 + 8) # define MON_10 (MON_1 + 9) # define MON_11 (MON_1 + 10) # define MON_12 (MON_1 + 11) # define ABMON_1 10035 # define ABMON_2 (ABMON_1 + 1) # define ABMON_3 (ABMON_1 + 2) # define ABMON_4 (ABMON_1 + 3) # define ABMON_5 (ABMON_1 + 4) # define ABMON_6 (ABMON_1 + 5) # define ABMON_7 (ABMON_1 + 6) # define ABMON_8 (ABMON_1 + 7) # define ABMON_9 (ABMON_1 + 8) # define ABMON_10 (ABMON_1 + 9) # define ABMON_11 (ABMON_1 + 10) # define ABMON_12 (ABMON_1 + 11) # define ERA 10047 # define ERA_D_FMT 10048 # define ERA_D_T_FMT 10049 # define ERA_T_FMT 10050 # define ALT_DIGITS 10051 /* nl_langinfo items of the LC_MONETARY category */ # define CRNCYSTR 10052 /* nl_langinfo items of the LC_MESSAGES category */ # define YESEXPR 10053 # define NOEXPR 10054 #else /* A platform that has <langinfo.h>. */ # if !@HAVE_LANGINFO_CODESET@ # define CODESET 10000 # define GNULIB_defined_CODESET 1 # endif # if !@HAVE_LANGINFO_T_FMT_AMPM@ # define T_FMT_AMPM 10006 # define GNULIB_defined_T_FMT_AMPM 1 # endif # if !@HAVE_LANGINFO_ERA@ # define ERA 10047 # define ERA_D_FMT 10048 # define ERA_D_T_FMT 10049 # define ERA_T_FMT 10050 # define ALT_DIGITS 10051 # define GNULIB_defined_ERA 1 # endif # if !@HAVE_LANGINFO_YESEXPR@ # define YESEXPR 10053 # define NOEXPR 10054 # define GNULIB_defined_YESEXPR 1 # endif #endif /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ /* The definition of _GL_WARN_ON_USE is copied here. */ /* Declare overridden functions. */ /* Return a piece of locale dependent information. Note: The difference between nl_langinfo (CODESET) and locale_charset () is that the latter normalizes the encoding names to GNU conventions. */ #if @GNULIB_NL_LANGINFO@ # if @REPLACE_NL_LANGINFO@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef nl_langinfo # define nl_langinfo rpl_nl_langinfo # endif _GL_FUNCDECL_RPL (nl_langinfo, char *, (nl_item item)); _GL_CXXALIAS_RPL (nl_langinfo, char *, (nl_item item)); # else # if !@HAVE_NL_LANGINFO@ _GL_FUNCDECL_SYS (nl_langinfo, char *, (nl_item item)); # endif _GL_CXXALIAS_SYS (nl_langinfo, char *, (nl_item item)); # endif _GL_CXXALIASWARN (nl_langinfo); #elif defined GNULIB_POSIXCHECK # undef nl_langinfo # if HAVE_RAW_DECL_NL_LANGINFO _GL_WARN_ON_USE (nl_langinfo, "nl_langinfo is not portable - " "use gnulib module nl_langinfo for portability"); # endif #endif #endif /* _@GUARD_PREFIX@_LANGINFO_H */ #endif /* _@GUARD_PREFIX@_LANGINFO_H */
/************************************************************************ c2circ.h ld-process-efm - EFM data decoder Copyright (C) 2019 Simon Inns This file is part of ld-decode-tools. ld-process-efm 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 C2CIRC_H #define C2CIRC_H #include <QCoreApplication> #include <QDebug> #include <ezpwd/rs_base> #include <ezpwd/rs> // CD-ROM specific CIRC configuration for Reed-Solomon forward error correction template < size_t SYMBOLS, size_t PAYLOAD > struct C2RS; template < size_t PAYLOAD > struct C2RS<255, PAYLOAD> : public __RS(C2RS, uint8_t, 255, PAYLOAD, 0x11d, 0, 1); class C2Circ { public: C2Circ(); // Statistics data structure struct Statistics { qint32 c2Passed; qint32 c2Corrected; qint32 c2Failed; qint32 c2flushed; }; void reset(); void resetStatistics(); Statistics getStatistics(); void reportStatistics(); void pushC1(uchar *dataSymbols, uchar *errorSymbols); uchar* getDataSymbols(); uchar* getErrorSymbols(); bool getDataValid(); void flush(); private: struct C1Element { uchar c1Data[28]; uchar c1Error[28]; }; QVector<C1Element> c1DelayBuffer; uchar interleavedC2Data[28]; uchar interleavedC2Errors[28]; uchar outputC2Data[28]; uchar outputC2Errors[28]; Statistics statistics; void interleave(); void errorCorrect(); }; #endif // C2CIRC_H
/* * Tremotesf * Copyright (C) 2015-2018 Alexey Rochev <equeim@gmail.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef TREMOTESF_TRACKERSMODEL_H #define TREMOTESF_TRACKERSMODEL_H #include <vector> #include <QAbstractTableModel> namespace libtremotesf { class Torrent; class Tracker; } namespace tremotesf { class TrackersModel : public QAbstractTableModel { Q_OBJECT Q_PROPERTY(libtremotesf::Torrent* torrent READ torrent WRITE setTorrent NOTIFY torrentChanged) public: enum Column { AnnounceColumn, StatusColumn, PeersColumn, NextUpdateColumn, ColumnCount }; static const int SortRole = Qt::UserRole; explicit TrackersModel(libtremotesf::Torrent* torrent = nullptr, QObject* parent = nullptr); inline int columnCount(const QModelIndex& = {}) const override { return ColumnCount; } QVariant data(const QModelIndex& index, int role) const override; QVariant headerData(int section, Qt::Orientation, int role) const override; int rowCount(const QModelIndex& = {}) const override; libtremotesf::Torrent* torrent() const; void setTorrent(libtremotesf::Torrent* torrent); Q_INVOKABLE QVariantList idsFromIndexes(const QModelIndexList& indexes) const; const libtremotesf::Tracker& trackerAtIndex(const QModelIndex& index) const; private: void update(); libtremotesf::Torrent* mTorrent; std::vector<libtremotesf::Tracker> mTrackers; template<typename, typename, typename, typename> friend class ModelListUpdater; friend class TrackersModelUpdater; signals: void torrentChanged(); }; } #endif // TREMOTESF_TRACKERSMODEL_H
#pragma once #include "cGlobals.h" class Bloodworks; class cRenderableContainer; class cTextRenderable; class cTexturedQuadRenderable; class CreditsWindow { Bloodworks *bloodworks; cRenderableContainer *window; cTextRenderable *credits; cTexturedQuadRenderable *bg; float textY; float visibleTime; public: CreditsWindow(Bloodworks* bloodworks); ~CreditsWindow(); void tick(); void setVisible(bool visible); bool isVisible() const; private: void resetTextPos(); };
/** * @file fprintf.c * * @author TacOS developers * * * @section LICENSE * * Copyright (C) 2010-2015 TacOS developers. * * 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 at * http://www.gnu.org/copyleft/gpl.html * * You should have received a copy of the GNU General Public License * along with this program; if not, see <http://www.gnu.org/licenses>. * * @section DESCRIPTION * * Description de ce que fait le fichier */ #include <stdio.h> #include <string.h> #include <stdlib.h> int fprintf(FILE *stream, const char *format, ...) { va_list arg; int result; va_start(arg, format); result = vfprintf(stream, format, arg); va_end(arg); return result; } int vfprintf(FILE *stream, const char *format, va_list ap) { int c; char buf[30]; int n = 0; while ((c = *format++) != 0) { if (c != '%') { if (fputc(c, stream) == EOF) { return -1; } n++; } else { int size = -1; char *p; c = *format++; if(c == '.') { char c2; size = 0; for(c2 = *format++; c2>='0' && c2<='9' ;c2 = *format++) size = size * 10 + (c2 - '0'); c = *(format-1); } int long_modifier = 0; while (c == 'l') { long_modifier++; c = *format++; } switch (c) { case 'f': if (size > -1) { dtoa(va_arg(ap, double), buf, size); } else { dtoa(va_arg(ap, double), buf, 6); } p = buf; goto string; break; case 'o': case 'd': case 'u': case 'x': if (long_modifier == 2) { itoa(buf, c, va_arg(ap, long long)); } else if (long_modifier == 1) { itoa(buf, c, va_arg(ap, long)); } else { itoa(buf, c, va_arg(ap, int)); } p = buf; if (size >= 0) { p[size] = '\0'; n += size; } goto string; break; case 'c': if (fputc(va_arg(ap, int), stream) == EOF) { return -1; } n++; break; case '%': if (fputc('%', stream) == EOF) { return -1; } n++; break; case 's': p = va_arg(ap, char *); if (p == NULL) p = "(null)"; string: n += strlen(p); if (fputs(p, stream) == EOF) { return -1; } break; default: if (fputc('%', stream) == EOF || fputc(c, stream) == EOF) { return -1; } n += 2; break; } } } return n; }
#ifndef HASHMAP_H #define HASHMAP_H #include <stdlib.h> // Why hashMap_uint no standard?? typedef unsigned int hashMap_uint; // A small struct to hold a hashed key, and a value pointer typedef struct hashMapItem { hashMap_uint key; void* value; } hashMapItem; // A struct to store a hashMap typedef struct hashMap { hashMap_uint size; hashMap_uint count; hashMapItem** items; hashMap_uint (*hash)(void*); } hashMap; // Generic function pointer types for user's hashing and destructor functions typedef hashMap_uint (*hash_func)(void*); typedef void (*destruct_func)(void*); // Reasonable hashMap sizes (primes) // Credit to: http://www.w3.org/2001/06/blindfold/api/hashMap_8c-source.html const hashMap_uint HASHMAP_SIZES[] = { 7, 13, 31, 61, 127, 251, 509, 1021, 2039, 4093, 8191, 16381, 32749, 65521, 131071, 262143, 524287, 1048575, 2097151, 4194303, 8388607, 16777211, 33554431, 67108863, 134217727, 268435455, 536870911, 1073741823, 2147483647 }; // Hashes a string into a uint // Credit to: http://www.cse.yorku.ca/~oz/hash.html - "djb2" algorithm hashMap_uint hashMap_hashString(void* v){ char* s = (char*) v; hashMap_uint h = 5381,c; while((c = *s++)){ h = ((h << 5) + h) + c; // h * 33 + c } return h; } // Chooses an appropriate size given the number of hashMap items hashMap_uint hashMap_chooseSize(hashMap_uint n){ hashMap_uint ret; short len = sizeof(HASHMAP_SIZES)/sizeof(hashMap_uint), i; for(i=0; i<len; ++i){ ret = HASHMAP_SIZES[i]; if(ret > n*2) break; } return ret; } // Create a map struct with a generic hashing function pointer // *** N.B. Hash should never return 0 as that denotes error *** hashMap* hashMap_create(hash_func f, hashMap_uint n){ hashMap* ret = (hashMap*) malloc(sizeof(hashMap)); ret->size = hashMap_chooseSize(n); ret->count = 0; ret->items = calloc(ret->size, sizeof(hashMapItem*)); ret->hash = f; return ret; } // Change the capacity of a hashMap void hashMap_resize(hashMap** hp){ // Return if already good size hashMap* oldMap = *hp; if(oldMap->size == hashMap_chooseSize(oldMap->count)) return; // Create a new hashMap hashMap* newMap = hashMap_create(oldMap->hash, oldMap->count); // Copy the items from h to the new hashMap if(oldMap->count){ hashMap_uint k; for(k=0; k<oldMap->size; ++k){ if(oldMap->items[k]){ hashMap_uint insert = oldMap->items[k]->key % newMap->size; hashMap_uint i, j; for(i=0; i<newMap->size; ++i){ j = (insert + i*i) % newMap->size; if(newMap->items[j]) continue; newMap->items[j] = oldMap->items[k]; ++newMap->count; break; } } } } // Free the old hashMap and have the pointer point to the new one free(oldMap->items); free(oldMap); *hp = newMap; } // Frees a map struct with a generic destructor function pointer void hashMap_destroy(hashMap* h, destruct_func f){ // Return if hashmap has not been created if(!h) return; // Iterate through the items array and free any that exist if(h->count){ hashMap_uint i; for(i=0; i<h->size; ++i){ if(h->items[i]){ // Call the supplied destructor function on each value f(h->items[i]->value); // Free the hashMap item wrapper free(h->items[i]); if(--h->count == 0) break; } } } // Free the item array free(h->items); // Free the hashMap struct itself free(h); } // Adds an item to a hashMap. Returns its key on successs else 0 hashMap_uint hashMap_add(hashMap** hp, void* v){ if((*hp)->count*2 > (*hp)->size){ hashMap_resize(hp); } hashMap* h = *hp; // Create a new hashMap item to be inserted into the map hashMapItem* item = malloc(sizeof(hashMapItem)); item->key = h->hash(v); item->value = v; // Find the correct index and insert (quadratic resolution) hashMap_uint insert = item->key % h->size, i, j; for(i=0; i<h->size; ++i){ j = (insert + i*i) % h->size; if(h->items[j]){ // Return 0 if an item with the same key exists if(h->items[j]->key == item->key) return 0; continue; } // Return the key once we insert successfully h->items[j] = item; ++h->count; return item->key; } return 0; // This case should not occur } // Retrieves an item from a hashMap by its key void* hashMap_retrieve(hashMap* h, hashMap_uint k){ // Find the correct index and fetch (quadratic resolution) hashMap_uint insert = k % h->size, i, j; for(i=0; i<h->size; ++i){ j = (insert + i*i) % h->size; if(h->items[j]){ // If an item with the same key exists, return it if(h->items[j]->key == k){ return h->items[j]->value; } }else{ return NULL; } } // Return null if the item was not found return NULL; } // Retrieves an item from a hashMap matching a new item void* hashMap_search(hashMap* h, void* v){ return hashMap_retrieve(h, h->hash(v)); } // Remove one element from the hashMap by its key void* hashMap_remove(hashMap* h, hashMap_uint k){ // Find the correct index and remove (quadratic resolution) hashMap_uint insert = k % h->size, i, j; for(i=0; i<h->size; ++i){ j = (insert + i*i) % h->size; if(h->items[j]){ // If an item with the same key exists, remove it if(h->items[j]->key == k){ void* ret = h->items[j]->value; free(h->items[j]); h->items[j] = 0; --h->count; return ret; } }else{ return NULL; } } // Return null if the item was not found return NULL; } #endif
/* Copyright (C) 2017-2019 Peter S. Zhigalov <peter.zhigalov@gmail.com> This file is part of the `ImageViewer' program. 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/>. */ #if !defined(ABOUTDIALOG_P_H_INCLUDED) #define ABOUTDIALOG_P_H_INCLUDED #include "AboutDialog.h" #include <QLabel> #include <QDialogButtonBox> #include <QTextBrowser> #include <QGridLayout> #include <QVBoxLayout> #include <QApplication> #include <QPixmap> #include <QStyle> #include "Utils/ObjectsUtils.h" #include "Widgets/AdjustableFrame.h" struct AboutDialog::UI { AdjustableFrame *centralWidget; QLabel *iconLabel; QLabel *textLabel; QTextBrowser *textBrowser; QDialogButtonBox *buttonBox; explicit UI(QWidget *parent) : CONSTRUCT_OBJECT(centralWidget, AdjustableFrame, (parent)) , CONSTRUCT_OBJECT(iconLabel, QLabel, (centralWidget)) , CONSTRUCT_OBJECT(textLabel, QLabel, (centralWidget)) , CONSTRUCT_OBJECT(textBrowser, QTextBrowser, (centralWidget)) , CONSTRUCT_OBJECT(buttonBox, QDialogButtonBox, (centralWidget)) { QPalette palette = textBrowser->palette(); palette.setColor(QPalette::Base, palette.color(QPalette::Window)); textBrowser->setPalette(palette); textBrowser->setOpenExternalLinks(true); textLabel->setOpenExternalLinks(true); buttonBox->setStandardButtons(QDialogButtonBox::Ok); textLabel->setTextInteractionFlags(Qt::TextInteractionFlags(textLabel->style()->styleHint(QStyle::SH_MessageBox_TextInteractionFlags, Q_NULLPTR, textLabel))); QGridLayout *centralLayout = new QGridLayout(centralWidget); centralLayout->addWidget(iconLabel, 0, 0, 2, 1, Qt::AlignTop | Qt::AlignCenter); centralLayout->addWidget(textLabel, 0, 1, 1, 1, Qt::AlignTop | Qt::AlignLeft); centralLayout->addWidget(textBrowser, 1, 0, 1, 2, Qt::AlignCenter); centralLayout->addWidget(buttonBox, 2, 0, 1, 2, Qt::AlignCenter); QVBoxLayout *dialogLayout = new QVBoxLayout(parent); dialogLayout->setContentsMargins(0, 0, 0, 0); dialogLayout->addWidget(centralWidget); } }; #endif // ABOUTDIALOG_P_H_INCLUDED
/* * This file is part of dmrshark. * * dmrshark 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. * * dmrshark 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 dmrshark. If not, see <http://www.gnu.org/licenses/>. **/ #include DEFAULTCONFIG #include "crc.h" // This algorithm uses the shift register logic to implement CRC calculation. // In the example we use the generator polynomial G(x)=x^16+x^12+x^5+1 // We create 16 shift registers, as this is a 16-bit CRC. // We put the bits in from the input 8-bit value to the first (rightmost) shift register, // then we take the bit which falls out from the last (leftmost) shift register, and // xor it with every bit which go into a shift register which has x on a power in the // generator polynomial. To simplify this operation, we calculate a hex CRC poly value // and xor all shift register values with it // // Here's how to calculate the CRC poly for a given generator polynomial: // Write 1 where there's an x coefficient and write 0 when there's no x for a given power: // 10001000000100001 // Cut the leftmost bit and convert it to a 16 bit hex number: 0x1021 // Algorithm source: http://srecord.sourceforge.net/crc16-ccitt.html // *crc initial value should be 0xffff. // // For other polynomials see: http://reveng.sourceforge.net/crc-catalogue/all.htm void crc_calc_crc16_ccitt(uint16_t *crc, uint8_t in) { uint8_t v; flag_t xor_flag; uint8_t i; v = 0x80; for (i = 0; i < 8; i++) { if ((*crc) & 0x8000) xor_flag = 1; else xor_flag = 0; (*crc) <<= 1; if (in & v) (*crc)++; if (xor_flag) (*crc) ^= 0x1021; v >>= 1; } } // Empties out the shift registers for the CRC calculation. Call this function when there's no more data left. void crc_calc_crc16_ccitt_finish(uint16_t *crc) { flag_t xor_flag; uint8_t i; for (i = 0; i < 16; i++) { if ((*crc) & 0x8000) xor_flag = 1; else xor_flag = 0; (*crc) <<= 1; if (xor_flag) (*crc) ^= 0x1021; } } // G(x) = x^9+x^6+x^4+x^3+1 -> poly = 0b001011001 = 0x59 void crc_calc_crc9(uint16_t *crc, uint8_t in, uint8_t in_bitscount) { uint8_t v; flag_t xor_flag; uint8_t i; v = 0x80; for (i = 0; i < 8-in_bitscount; i++) v >>= 1; for (i = 0; i < 8; i++) { if ((*crc) & 0x0100) xor_flag = 1; else xor_flag = 0; (*crc) <<= 1; // Limit the number of shift registers to 9. *crc &= 0x01ff; if (in & v) (*crc)++; if (xor_flag) (*crc) ^= 0x59; v >>= 1; } } void crc_calc_crc9_finish(uint16_t *crc, uint8_t out_bitscount) { flag_t xor_flag; uint8_t i; for (i = 0; i < out_bitscount; i++) { if ((*crc) & 0x0100) xor_flag = 1; else xor_flag = 0; (*crc) <<= 1; // Limit the number of shift registers to 9. *crc &= 0x01ff; if (xor_flag) (*crc) ^= 0x59; } } void crc_calc_crc32(uint32_t *crc, uint8_t in) { uint8_t v; flag_t xor_flag; uint8_t i; v = 0x80; for (i = 0; i < 8; i++) { if ((*crc) & 0x80000000) xor_flag = 1; else xor_flag = 0; (*crc) <<= 1; if (in & v) (*crc)++; if (xor_flag) (*crc) ^= 0x04c11db7; v >>= 1; } } void crc_calc_crc32_finish(uint32_t *crc) { flag_t xor_flag; uint8_t i; for (i = 0; i < 32; i++) { if ((*crc) & 0x80000000) xor_flag = 1; else xor_flag = 0; (*crc) <<= 1; if (xor_flag) (*crc) ^= 0x04c11db7; } }
#include <stdio.h> #define MAXLINE 1000 int myGetline(char line[], int maxline); main(int argc, char *argv[]) { int c, len; int i; char line[MAXLINE]; int tabstop; int spaceCount; if (argc == 1) tabstop = 8; else if (argc == 2) tabstop = atoi(*++argv); else { printf("Usage entab (8)(tabstop)\n"); return 1; } while ((len = myGetline(line, MAXLINE)) > 0) { spaceCount = 0; for (i = 0; i < len; ++i) { if (line[i] == ' ') spaceCount++; else spaceCount = 0; if (spaceCount == tabstop) { } } printf("%s", line); } } int myGetline(char s[], int lim) { int c, i; for (i = 0; i < lim - 1 && (c = getchar()) != EOF && c != '\n'; ++i) s[i] = c; if (c == '\n') { s[i] = c; ++i; } s[i] = '\0'; return i; }
//=========================================================================== /*! * * * \brief Multi-objective optimization benchmark function CIGTAB 2. * * The function is described in * * Christian Igel, Nikolaus Hansen, and Stefan Roth. * Covariance Matrix Adaptation for Multi-objective Optimization. * Evolutionary Computation 15(1), pp. 1-28, 2007 * * * * \author - * \date - * * * \par Copyright 1995-2015 Shark Development Team * * <BR><HR> * This file is part of Shark. * <http://image.diku.dk/shark/> * * Shark 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. * * Shark 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 Shark. If not, see <http://www.gnu.org/licenses/>. * */ //=========================================================================== #ifndef SHARK_OBJECTIVEFUNCTIONS_BENCHMARK_CIGTAB2_H #define SHARK_OBJECTIVEFUNCTIONS_BENCHMARK_CIGTAB2_H #include <shark/ObjectiveFunctions/AbstractObjectiveFunction.h> #include <shark/ObjectiveFunctions/BoxConstraintHandler.h> #include <shark/LinAlg/rotations.h> namespace shark { /*! \brief Multi-objective optimization benchmark function CIGTAB 2. * * The function is described in * * Christian Igel, Nikolaus Hansen, and Stefan Roth. * Covariance Matrix Adaptation for Multi-objective Optimization. * Evolutionary Computation 15(1), pp. 1-28, 2007 */ struct CIGTAB2 : public MultiObjectiveFunction { CIGTAB2(std::size_t numberOfVariables = 5) : m_a( 1E-6 ) { m_features |= CAN_PROPOSE_STARTING_POINT; m_numberOfVariables = numberOfVariables; } /// \brief From INameable: return the class name. std::string name() const { return "CIGTAB2"; } std::size_t numberOfObjectives()const{ return 2; } std::size_t numberOfVariables()const{ return m_numberOfVariables; } bool hasScalableDimensionality()const{ return true; } /// \brief Adjusts the number of variables if the function is scalable. /// \param [in] numberOfVariables The new dimension. void setNumberOfVariables( std::size_t numberOfVariables ){ m_numberOfVariables = numberOfVariables; } void init() { m_rotationMatrixY = blas::randomRotationMatrix(m_numberOfVariables); m_rotationMatrixZ = blas::randomRotationMatrix(m_numberOfVariables); } ResultType eval( const SearchPointType & x ) const { m_evaluationCounter++; ResultType value( 2 ); SearchPointType y = blas::prod( m_rotationMatrixY, x ); SearchPointType z = blas::prod( m_rotationMatrixZ, x ); double result_1 = y(0) * y(0) + m_a * m_a * y(numberOfVariables()-1) * y(numberOfVariables()-1); double result_2 = z(0) * z(0) + m_a * m_a * z(numberOfVariables()-1) * z(numberOfVariables()-1); for (unsigned i = 1; i < numberOfVariables() - 1; i++) { result_1 += m_a * y( i ) * y( i ); result_2 += m_a * (z( i ) - 2) * (z( i ) - 2); } value[0] = result_1 / (m_a * m_a * numberOfVariables()); value[1] = result_2 / (m_a * m_a * numberOfVariables()); return value; } void proposeStartingPoint( SearchPointType & x ) const { x.resize( m_numberOfVariables ); for( unsigned int i = 0; i < m_numberOfVariables; i++ ) x( i ) = Rng::uni( -10., 10. ); } private: double m_a; std::size_t m_numberOfVariables; RealMatrix m_rotationMatrixY; RealMatrix m_rotationMatrixZ; }; } #endif
#include <stdio.h> #include <unistd.h> #include <pthread.h> #include "futaux.h" #include "userlock.h" int A = 0, B = 0; volatile int invoke_futex_wait_requeue_pi = 0; volatile pid_t thread_tid = -1; void *thread(void *arg) { thread_tid = gettid(); printf("[2]\n"); userlock_wait(&invoke_futex_wait_requeue_pi); futex_wait_requeue_pi(&A, &B); printf("Someone woke me up\n"); while (1) { sleep(1); } } int main(int argc, char *argv[]) { pthread_t t; int context_switch_count = 0; printf("[1]\n"); futex_lock_pi(&B); userlock_lock(&invoke_futex_wait_requeue_pi); pthread_create(&t, NULL, thread, NULL); /* Wait for the thread to be in a system call */ while (thread_tid < 0) { usleep(10); } context_switch_count = get_voluntary_ctxt_switches(thread_tid); userlock_release(&invoke_futex_wait_requeue_pi); wait_for_thread_to_wait_in_kernel(thread_tid, context_switch_count); printf("[3]\n"); futex_requeue_pi(&A, &B, A); printf("[4]\n"); B = 0; printf("[5]\n"); futex_requeue_pi(&B, &B, B); while (1) { sleep(1); } return 0; }
// // UCEmailViewTo.h // AlmappUC // // Created by Patricio López on 28-02-15. // Copyright (c) 2015 almapp. All rights reserved. // #import <UIKit/UIKit.h> #import "UCEmailViewCell.h" @interface UCEmailViewTo : UCEmailViewCell @end
/* This file is part of Ruspma. * * Ruspma 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. * * Ruspma 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 Ruspma. If not, see <http://www.gnu.org/licenses/>. */ #ifndef RUSPMA_BASE_TYPES_H #define RUSPMA_BASE_TYPES_H /* Value types */ enum { RUSPMA_ATOM, RUSPMA_LIST }; /* Atom types */ enum { RUSPMA_SYMBOL, RUSPMA_KEYWORD, RUSPMA_STRING, RUSPMA_DOUBLE, RUSPMA_INT, RUSPMA_CLOSURE, RUSPMA_FUNCTION }; #endif
#include <stdio.h> #include <stdlib.h> int main() { int a,b,c,n,i=0; scanf("%d", &n); while(n--) { i++; scanf("%d %d %d", &a,&b,&c); if(a<=20 && b<=20 && c<=20) printf("Case %d: good\n", i); else printf("Case %d: bad\n", i); } return 0; }
// Copyright (c) 2017 LiuLang. All rights reserved. // Use of this source is governed by General Public License that can be found // in the LICENSE file. #ifndef TELEPORT_BASE_STRING_UTIL_H #define TELEPORT_BASE_STRING_UTIL_H #include <QString> namespace teleport { QString GenerateRandomString(int len); } // namespace teleport #endif // TELEPORT_BASE_STRING_UTIL_H
/* * ISA bus. */ #include <linux/device.h> #include <linux/kernel.h> #include <linux/slab.h> #include <linux/module.h> #include <linux/init.h> #include <linux/dma-mapping.h> #include <linux/isa.h> static struct device isa_bus = { .init_name = "isa" }; struct isa_dev { struct device dev; struct device *next; unsigned int id; }; #define to_isa_dev(x) container_of((x), struct isa_dev, dev) static int isa_bus_match(struct device *dev, struct device_driver *driver) { struct isa_driver *isa_driver = to_isa_driver(driver); if (dev->platform_data == isa_driver) { if (!isa_driver->match || isa_driver->match(dev, to_isa_dev(dev)->id)) { return 1; } dev->platform_data = NULL; } return 0; } static int isa_bus_probe(struct device *dev) { struct isa_driver *isa_driver = dev->platform_data; if (isa_driver->probe) { return isa_driver->probe(dev, to_isa_dev(dev)->id); } return 0; } static int isa_bus_remove(struct device *dev) { struct isa_driver *isa_driver = dev->platform_data; if (isa_driver->remove) { return isa_driver->remove(dev, to_isa_dev(dev)->id); } return 0; } static void isa_bus_shutdown(struct device *dev) { struct isa_driver *isa_driver = dev->platform_data; if (isa_driver->shutdown) { isa_driver->shutdown(dev, to_isa_dev(dev)->id); } } static int isa_bus_suspend(struct device *dev, pm_message_t state) { struct isa_driver *isa_driver = dev->platform_data; if (isa_driver->suspend) { return isa_driver->suspend(dev, to_isa_dev(dev)->id, state); } return 0; } static int isa_bus_resume(struct device *dev) { struct isa_driver *isa_driver = dev->platform_data; if (isa_driver->resume) { return isa_driver->resume(dev, to_isa_dev(dev)->id); } return 0; } static struct bus_type isa_bus_type = { .name = "isa", .match = isa_bus_match, .probe = isa_bus_probe, .remove = isa_bus_remove, .shutdown = isa_bus_shutdown, .suspend = isa_bus_suspend, .resume = isa_bus_resume }; static void isa_dev_release(struct device *dev) { kfree(to_isa_dev(dev)); } void isa_unregister_driver(struct isa_driver *isa_driver) { struct device *dev = isa_driver->devices; while (dev) { struct device *tmp = to_isa_dev(dev)->next; device_unregister(dev); dev = tmp; } driver_unregister(&isa_driver->driver); } EXPORT_SYMBOL_GPL(isa_unregister_driver); int isa_register_driver(struct isa_driver *isa_driver, unsigned int ndev) { int error; unsigned int id; isa_driver->driver.bus = &isa_bus_type; isa_driver->devices = NULL; error = driver_register(&isa_driver->driver); if (error) { return error; } for (id = 0; id < ndev; id++) { struct isa_dev *isa_dev; isa_dev = kzalloc(sizeof * isa_dev, GFP_KERNEL); if (!isa_dev) { error = -ENOMEM; break; } isa_dev->dev.parent = &isa_bus; isa_dev->dev.bus = &isa_bus_type; dev_set_name(&isa_dev->dev, "%s.%u", isa_driver->driver.name, id); isa_dev->dev.platform_data = isa_driver; isa_dev->dev.release = isa_dev_release; isa_dev->id = id; isa_dev->dev.coherent_dma_mask = DMA_BIT_MASK(24); isa_dev->dev.dma_mask = &isa_dev->dev.coherent_dma_mask; error = device_register(&isa_dev->dev); if (error) { put_device(&isa_dev->dev); break; } if (isa_dev->dev.platform_data) { isa_dev->next = isa_driver->devices; isa_driver->devices = &isa_dev->dev; } else { device_unregister(&isa_dev->dev); } } if (!error && !isa_driver->devices) { error = -ENODEV; } if (error) { isa_unregister_driver(isa_driver); } return error; } EXPORT_SYMBOL_GPL(isa_register_driver); static int __init isa_bus_init(void) { int error; error = bus_register(&isa_bus_type); if (!error) { error = device_register(&isa_bus); if (error) { bus_unregister(&isa_bus_type); } } return error; } postcore_initcall(isa_bus_init);
#include "unpipc.h" #include "square.h" int main(int argc, char **argv) { CLIENT *cl; square_in in; square_out *outp; if (argc != 4) err_quit("usage: client <hostname> <integer-value> <protocol>"); cl = Clnt_create(argv[1], SQUARE_PROG, SQUARE_VERS, argv[3]); in.arg1 = atol(argv[2]); if ( (outp = squareproc_1(&in, cl)) == NULL) err_quit("%s", clnt_sperror(cl, argv[1])); printf("result: %ld\n", outp->res1); exit(0); }
#include "shadylib.h" static t_class *triangulator_class; typedef struct _triangulator { t_object x_obj; t_float x_f; union shadylib_floatpoint invals[2]; int num; /* number of msg inlets: 0, 1, or 2 0 is all signals, 1 is an add inlet, 2 is a multiply inlet and an add inlet */ double x_phase; float x_conv; } t_triangulator; static t_int *op_perf0(t_int *w) { t_triangulator *x = (t_triangulator *)(w[1]); t_sample *in = (t_sample *)(w[2]); t_sample *out = (t_sample *)(w[3]); int n = (int)(w[4]); t_sample *mul = x->invals[0].vec; t_sample *add = x->invals[1].vec; t_sample inter; double dphase = x->x_phase + (double)SHADYLIB_UNITBIT32; union shadylib_tabfudge tf; uint32_t casto; float conv = x->x_conv; tf.tf_d = dphase; while (n--) { dphase += *in++ * conv; casto = (uint32_t)tf.tf_i[SHADYLIB_LOWOFFSET]; if(casto & 2147483648) /* bit 31 */ casto = ~casto; inter = (t_sample)casto/1073741823.5 - 1; #ifdef FP_FAST_FMAF *out++ = fmaf(inter, *mul++, *add++); #else *out++ = inter*(*mul++) + (*add++); #endif tf.tf_d = dphase; } tf.tf_i[SHADYLIB_HIOFFSET] = SHADYLIB_NORMHIPART; x->x_phase = tf.tf_d - SHADYLIB_UNITBIT32; return (w+5); } static t_int *op_perf1(t_int *w) { t_triangulator *x = (t_triangulator *)(w[1]); t_sample *in = (t_sample *)(w[2]); t_sample *out = (t_sample *)(w[3]); int n = (int)(w[4]); t_sample *mul = x->invals[0].vec; t_float add = x->invals[1].val; t_sample inter; double dphase = x->x_phase + (double)SHADYLIB_UNITBIT32; union shadylib_tabfudge tf; uint32_t casto; float conv = x->x_conv; tf.tf_d = dphase; while (n--) { dphase += *in++ * conv; casto = (uint32_t)tf.tf_i[SHADYLIB_LOWOFFSET]; if(casto & 2147483648) /* bit 31 */ casto = ~casto; inter = (t_sample)casto/1073741823.5 - 1; #ifdef FP_FAST_FMAF *out++ = fmaf(inter, *mul++, add); #else *out++ = inter*(*mul++) + add; #endif tf.tf_d = dphase; } tf.tf_i[SHADYLIB_HIOFFSET] = SHADYLIB_NORMHIPART; x->x_phase = tf.tf_d - SHADYLIB_UNITBIT32; return (w+5); } static t_int *op_perf2(t_int *w) { t_triangulator *x = (t_triangulator *)(w[1]); t_sample *in = (t_sample *)(w[2]); t_sample *out = (t_sample *)(w[3]); int n = (int)(w[4]); t_float mul = x->invals[0].val; t_float add = x->invals[1].val; t_sample inter; double dphase = x->x_phase + (double)SHADYLIB_UNITBIT32; union shadylib_tabfudge tf; uint32_t casto; float conv = x->x_conv; tf.tf_d = dphase; while (n--) { dphase += *in++ * conv; casto = (uint32_t)tf.tf_i[SHADYLIB_LOWOFFSET]; if(casto & 2147483648) /* bit 31 */ casto = ~casto; inter = (t_sample)casto/1073741823.5 - 1; #ifdef FP_FAST_FMAF *out++ = fmaf(inter, mul, add); #else *out++ = inter*mul + add; #endif tf.tf_d = dphase; } tf.tf_i[SHADYLIB_HIOFFSET] = SHADYLIB_NORMHIPART; x->x_phase = tf.tf_d - SHADYLIB_UNITBIT32; return (w+5); } static void triangulator_dsp(t_triangulator *x, t_signal **sp) { x->x_conv = 1/sp[0]->s_sr; switch(x->num) { case 0: x->invals[0].vec = sp[1]->s_vec; x->invals[1].vec = sp[2]->s_vec; dsp_add(op_perf0, 4, x, sp[0]->s_vec, sp[3]->s_vec, sp[0]->s_n); break; case 1: x->invals[0].vec = sp[1]->s_vec; dsp_add(op_perf1, 4, x, sp[0]->s_vec, sp[2]->s_vec, sp[0]->s_n); break; case 2: dsp_add(op_perf2, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); break; default:; } } static void triangulator_ft1(t_triangulator *x, t_float f) { x->x_phase = f + .25; } static void *triangulator_new(t_symbol* UNUSED(s), int argc, t_atom *argv) { t_triangulator *x = (t_triangulator *)pd_new(triangulator_class); x->x_phase = 0.25; outlet_new(&x->x_obj, &s_signal); switch(argc) { default:; case 3: x->x_f = atom_getfloatarg(2, argc, argv); case 2: floatinlet_new(&x->x_obj, &x->invals[0].val); x->invals[0].val = atom_getfloatarg(0, argc, argv); floatinlet_new(&x->x_obj, &x->invals[1].val); x->invals[1].val = atom_getfloatarg(1, argc, argv); x->num = 2; break; case 1: inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal); floatinlet_new(&x->x_obj, &x->invals[1].val); x->invals[1].val = atom_getfloatarg(0, argc, argv); x->num = 1; break; case 0: inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal); inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal); x->num = 0; } inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("ft1")); return(x); } void triangulator_tilde_setup(void) { triangulator_class = class_new(gensym("triangulator~"), (t_newmethod)triangulator_new, 0, sizeof(t_triangulator), 0, A_GIMME, 0); CLASS_MAINSIGNALIN(triangulator_class, t_triangulator, x_f); class_addmethod(triangulator_class, (t_method)triangulator_dsp, gensym("dsp"), A_CANT, 0); class_addmethod(triangulator_class, (t_method)triangulator_ft1, gensym("ft1"), A_FLOAT, 0); shadylib_checkalign(); }
/* * Copyright (c) 2014 Broadcom Corporation * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include <linux/vmalloc.h> #include <net/cfg80211.h> #include <net/netlink.h> #include <brcmu_wifi.h> #include "fwil_types.h" #include "core.h" #include "p2p.h" #include "debug.h" #include "cfg80211.h" #include "vendor.h" #include "fwil.h" static int brcmf_cfg80211_vndr_cmds_dcmd_handler(struct wiphy *wiphy, struct wireless_dev *wdev, const void *data, int len) { struct brcmf_cfg80211_vif *vif; struct brcmf_if *ifp; const struct brcmf_vndr_dcmd_hdr *cmdhdr = data; struct sk_buff *reply; int ret, payload, ret_len; void *dcmd_buf = NULL, *wr_pointer; u16 msglen, maxmsglen = PAGE_SIZE - 0x100; if (len < sizeof(*cmdhdr)) { brcmf_err("vendor command too short: %d\n", len); return -EINVAL; } vif = container_of(wdev, struct brcmf_cfg80211_vif, wdev); ifp = vif->ifp; brcmf_dbg(TRACE, "ifidx=%d, cmd=%d\n", ifp->ifidx, cmdhdr->cmd); if (cmdhdr->offset > len) { brcmf_err("bad buffer offset %d > %d\n", cmdhdr->offset, len); return -EINVAL; } len -= cmdhdr->offset; ret_len = cmdhdr->len; if (ret_len > 0 || len > 0) { if (len > BRCMF_DCMD_MAXLEN) { brcmf_err("oversize input buffer %d\n", len); len = BRCMF_DCMD_MAXLEN; } if (ret_len > BRCMF_DCMD_MAXLEN) { brcmf_err("oversize return buffer %d\n", ret_len); ret_len = BRCMF_DCMD_MAXLEN; } payload = max(ret_len, len) + 1; dcmd_buf = vzalloc(payload); if (NULL == dcmd_buf) { return -ENOMEM; } memcpy(dcmd_buf, (void *)cmdhdr + cmdhdr->offset, len); *(char *)(dcmd_buf + len) = '\0'; } if (cmdhdr->set) ret = brcmf_fil_cmd_data_set(ifp, cmdhdr->cmd, dcmd_buf, ret_len); else ret = brcmf_fil_cmd_data_get(ifp, cmdhdr->cmd, dcmd_buf, ret_len); if (ret != 0) { goto exit; } wr_pointer = dcmd_buf; while (ret_len > 0) { msglen = ret_len > maxmsglen ? maxmsglen : ret_len; ret_len -= msglen; payload = msglen + sizeof(msglen); reply = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, payload); if (NULL == reply) { ret = -ENOMEM; break; } if (nla_put(reply, BRCMF_NLATTR_DATA, msglen, wr_pointer) || nla_put_u16(reply, BRCMF_NLATTR_LEN, msglen)) { kfree_skb(reply); ret = -ENOBUFS; break; } ret = cfg80211_vendor_cmd_reply(reply); if (ret) { break; } wr_pointer += msglen; } exit: vfree(dcmd_buf); return ret; } const struct wiphy_vendor_command brcmf_vendor_cmds[] = { { { .vendor_id = BROADCOM_OUI, .subcmd = BRCMF_VNDR_CMDS_DCMD }, .flags = WIPHY_VENDOR_CMD_NEED_WDEV | WIPHY_VENDOR_CMD_NEED_NETDEV, .doit = brcmf_cfg80211_vndr_cmds_dcmd_handler }, };
/**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt3D module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms ** and conditions see https://www.qt.io/terms-conditions. For further ** information use the contact form at https://www.qt.io/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 3 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL3 included in the ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 3 requirements ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. ** ** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 2.0 or (at your option) the GNU General ** Public license version 3 or any later version approved by the KDE Free ** Qt Foundation. The licenses are as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 ** included in the packaging of this file. Please review the following ** information to ensure the GNU General Public License requirements will ** be met: https://www.gnu.org/licenses/gpl-2.0.html and ** https://www.gnu.org/licenses/gpl-3.0.html. ** ** $QT_END_LICENSE$ ** ****************************************************************************/ #ifndef QT3DCORE_QTHREADPOOLER_H #define QT3DCORE_QTHREADPOOLER_H // // W A R N I N G // ------------- // // This file is not part of the Qt API. It exists for the convenience // of other Qt classes. This header file may change from version to // version without notice, or even be removed. // // We mean it. // #include <QtCore/QFuture> #include <QtCore/QFutureInterface> #include <QtCore/QObject> #include <QtCore/QSharedPointer> #include <QtCore/QThreadPool> #include <Qt3DCore/private/dependencyhandler_p.h> #include <Qt3DCore/private/qaspectjob_p.h> #include <Qt3DCore/private/task_p.h> #ifdef QT3D_JOBS_RUN_STATS #include <QtCore/QElapsedTimer> #endif QT_BEGIN_NAMESPACE namespace Qt3DCore { class QT3DCORE_PRIVATE_EXPORT QThreadPooler : public QObject { Q_OBJECT public: explicit QThreadPooler(QObject *parent = 0); ~QThreadPooler(); QFuture<void> mapDependables(QVector<RunnableInterface *> &taskQueue); void taskFinished(RunnableInterface *task); QFuture<void> future(); void setDependencyHandler(DependencyHandler *handler); int maxThreadCount() const; #ifdef QT3D_JOBS_RUN_STATS static QElapsedTimer m_jobsStatTimer; // Aspects + Job threads static void addJobLogStatsEntry(JobRunStats &stats); static void writeFrameJobLogStats(); // Submission thread static void addSubmissionLogStatsEntry(JobRunStats &stats); #endif private: void enqueueTasks(const QVector<RunnableInterface *> &tasks); void acquire(int add); void release(); int currentCount() const; private: QFutureInterface<void> *m_futureInterface; QMutex m_mutex; DependencyHandler *m_dependencyHandler; QAtomicInt m_taskCount; QThreadPool m_threadPool; }; } // namespace Qt3DCore QT_END_NAMESPACE #endif // QT3DCORE_QTHREADPOOLER_H
/** * * This file is part of Tulip (www.tulip-software.org) * * Authors: David Auber and the Tulip development Team * from LaBRI, University of Bordeaux 1 and Inria Bordeaux - Sud Ouest * * Tulip 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. * * Tulip 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. * */ /** Author: Antoine Lambert 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. */ #ifndef Tulip_TABWIDGETHIDABLEMENUGRAPHICSPROXY_H_ #define Tulip_TABWIDGETHIDABLEMENUGRAPHICSPROXY_H_ #include <QtGui/QTabWidget> #include "tulip/GraphicsWidgetBase.h" namespace tlp { class TLP_QT_SCOPE TabWidgetHidableMenuGraphicsProxy : public GraphicsWidgetBase { Q_OBJECT public : TabWidgetHidableMenuGraphicsProxy(const unsigned int offsetWhenHiding); void addTab(QWidget *widget, const QString &tabName); void setOffsetWhenHiding(const unsigned int offsetWhenHiding) { this->offsetWhenHiding = offsetWhenHiding; } void hideTabWidget(); QTabWidget *getTabWidget() const { return tabWidget; } protected : void wheelEvent(QGraphicsSceneWheelEvent * event); void mouseDoubleClickEvent(QGraphicsSceneMouseEvent * event); private slots : void animateTranslationStep(int animStep); private : QTabWidget *tabWidget; bool hidden; double xStart, xEnd; unsigned int offsetWhenHiding; }; } #endif
#include <stdio.h> #include <stdlib.h> #include "queue.h" void queueInit(Queue * queue) { queue->front = NULL; queue->rear = NULL; queue->route = 0; } int qIsEmpty(Queue * queue) { if (queue->front == NULL) { return TRUE; } else { return FALSE; } } void enQueue(Queue * queue, int minRoute, int minIndex) { QueueNode *newNode = (QueueNode*)malloc(sizeof(QueueNode)); newNode->next = NULL; newNode->minRoute = minRoute; newNode->minIndex = minIndex; queue->route += minRoute; if (qIsEmpty(queue)) { queue->front = newNode; queue->rear = newNode; } else { queue->rear->next = newNode; queue->rear = newNode; } } int deQueue(Queue * queue) { QueueNode *delNode; int data; if (qIsEmpty(queue)) { printf("queue에 값이 없습니다.\n"); return NULL; } delNode = queue->front; data = delNode->minIndex; queue->front = queue->front->next; queue->route -= delNode->minRoute; free(delNode); return data; } int indexPeek(Queue * queue) { if (qIsEmpty(queue)) { printf("queue에 값이 없습니다.\n"); return NULL; } return queue->front->minIndex; } int routePeek(Queue * queue) { if (qIsEmpty(queue)) { printf("queue에 값이 없습니다.\n"); return NULL; } return queue->front->minRoute; }
#ifndef __SVR_TRANS_H__ #define __SVR_TRANS_H__ #include "spie.h" #define svr_request(func_name, req_struct, rsp_struct) \ extern int svr_request_##func_name##_routine(session_t *ses, req_struct##_t *req, \ rsp_struct##_t **rsp); \ int svr_request_##func_name(session_t *ses, struct evbuffer *in, \ struct evbuffer *out, spie_header_t *pro){ \ fixbuffer_t fb; \ struct evbuffer *evb; \ req_struct##_t *req; \ rsp_struct##_t *rsp = NULL; \ int rc; \ \ fb.buffer = (void *)pro; \ fb.len = sizeof(*pro) + pro->size; \ fb.start = sizeof(*pro); \ fb.end = fb.len; \ \ if(pro->size == 0){ \ trans_ack_fail(out,pro,SPIE_ECODE_INVAL); \ osapi_free(pro); \ return -1; \ } \ pro->errcode = 0; \ \ rc = req_struct##_unmash(&fb, fb_reader, fb_writer, &req); \ if(rc != 0){ \ trans_ack_fail(out,pro,SPIE_ECODE_INVAL); \ osapi_free(pro); \ return -1; \ } \ \ rc = svr_request_##func_name##_routine(ses,req,&rsp); \ if(rc != 0){ \ trans_ack_fail(out,pro, (uint8_t)-rc); \ osapi_free(pro); \ req_struct##_free(req); \ return -1; \ } \ req_struct##_free(req); \ \ if(rsp == NULL){ \ trans_ack_fail(out, pro, SPIE_ECODE_SUCCESS); \ osapi_free(pro); \ return 0; \ } \ \ evb = evbuffer_new(); \ if(evb == NULL){ \ trans_ack_fail(out,pro,SPIE_ECODE_NOMEM); \ osapi_free(pro); \ rsp_struct##_free(rsp); \ return -1; \ } \ \ rc = rsp_struct##_mashal(evb, evb_reader, evb_writer, rsp); \ if(rc != 0){ \ trans_ack_fail(out,pro,SPIE_ECODE_INVAL); \ osapi_free(pro); \ rsp_struct##_free(rsp); \ return -1; \ } \ \ trans_ack_data(out, pro, evb); \ \ evbuffer_free(evb); \ rsp_struct##_free(rsp); \ \ osapi_free(pro); \ return 0; \ } #endif // __SVR_TRANS_H__
/* * File: prefix.h * Author: Patrick Robinson * * Created on 28. April 2015, 12:35 */ #ifndef PREFIX_H #define PREFIX_H typedef double atype_t; void prefix(unsigned int p, unsigned int n, atype_t values[n], atype_t (*f)(atype_t, atype_t)); #endif /* PREFIX_H */
#include "removefile.h" #include "removefile_priv.h" #include <TargetConditionals.h> removefile_state_t removefile_state_alloc() { removefile_state_t state = (removefile_state_t)calloc(1, sizeof(struct _removefile_state)); if (state != NULL) state->urand_file = -1; return state; } int removefile_state_free(removefile_state_t state) { if (state != NULL) { if (state->urand_file != -1) { close(state->urand_file); state->urand_file = -1; } if (state->buffer != NULL) { free(state->buffer); state->buffer = NULL; } free(state); } return 0; } int removefile_state_get(removefile_state_t state, uint32_t key, void* dst) { switch(key) { case REMOVEFILE_STATE_CONFIRM_CALLBACK: *(removefile_callback_t*)dst = state->confirm_callback; break; case REMOVEFILE_STATE_CONFIRM_CONTEXT: *(void**)dst = state->confirm_context; break; case REMOVEFILE_STATE_ERROR_CALLBACK: *(removefile_callback_t*)dst = state->error_callback; break; case REMOVEFILE_STATE_ERROR_CONTEXT: *(void**)dst = state->error_context; break; case REMOVEFILE_STATE_ERRNO: *(int*)dst = state->error_num; break; case REMOVEFILE_STATE_STATUS_CALLBACK: *(removefile_callback_t*)dst = state->status_callback; break; case REMOVEFILE_STATE_STATUS_CONTEXT: *(void**)dst = state->status_context; break; default: errno = EINVAL; return -1; } return 0; } int removefile_state_set(removefile_state_t state, uint32_t key, const void* value) { switch(key) { case REMOVEFILE_STATE_CONFIRM_CALLBACK: state->confirm_callback = value; break; case REMOVEFILE_STATE_CONFIRM_CONTEXT: state->confirm_context = (void *) value; break; case REMOVEFILE_STATE_ERROR_CALLBACK: state->error_callback = value; break; case REMOVEFILE_STATE_ERROR_CONTEXT: state->error_context = (void *) value; break; case REMOVEFILE_STATE_ERRNO: state->error_num = *(int*)value; break; case REMOVEFILE_STATE_STATUS_CALLBACK: state->status_callback = value; break; case REMOVEFILE_STATE_STATUS_CONTEXT: state->status_context = (void *) value; break; default: errno = EINVAL; return -1; } return 0; } int removefile(const char* path, removefile_state_t state_param, removefile_flags_t flags) { int res = 0, error = 0; char* paths[] = { NULL, NULL }; removefile_state_t state = state_param; // allocate the state if it was not passed in if (state_param == NULL) { state = removefile_state_alloc(); if (state == NULL) { errno = ENOMEM; return -1; } } state->cancelled = 0; state->unlink_flags = flags; if (flags & (REMOVEFILE_SECURE_7_PASS | REMOVEFILE_SECURE_35_PASS | REMOVEFILE_SECURE_1_PASS | REMOVEFILE_SECURE_3_PASS)) { __removefile_init_random(getpid(), state); } paths[0] = strdup(path); if (paths[0]) { res = __removefile_tree_walker(paths, state); error = state->error_num; free(paths[0]); } else { error = ENOMEM; res = -1; } // deallocate if allocated locally if (state_param == NULL) { removefile_state_free(state); } if (res) { errno = error; } return res; } int removefile_cancel(removefile_state_t state) { if (state == NULL) { errno = EINVAL; return -1; } else { state->cancelled = 1; return 0; } }
/* * * Copyright (c) 2009 by Christian Dietrich <stettberger@dokucode.de> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * For more information on the GPL, please go to: * http://www.gnu.org/copyleft/gpl.html */ #include <avr/io.h> #include <avr/interrupt.h> #include <avr/pgmspace.h> #include <string.h> #include <stdio.h> #include "config.h" #include "serial_line_log.h" #include "protocols/ecmd/ecmd-base.h" #ifdef DEBUG_SERIAL_LINE_LOG # include "core/debug.h" # define SLL_DEBUG(a...) debug_printf("sll: " a) #else # define SLL_DEBUG(a...) #endif extern struct serial_line_log_data sll_data; extern struct serial_line_log_data sll_data_new; int16_t parse_cmd_sll_get(char *cmd, char *output, uint16_t len) { uint8_t sent_parts = 0; len = len - 1; if (*cmd == 23) { /* Magic Marker Byte for the next calls of this function */ sent_parts = cmd[1]; cmd[1] ++; } else { cmd[0] = 23; /* If the timeout is reached we sent first a packet which is saying, that our device is offline */ if (sll_data.timeout == 0) { cmd[1] = 0; len = sprintf_P(output, PSTR("offline - ")); output[len] = ECMD_NO_NEWLINE; return ECMD_AGAIN(len); } cmd[1] = 1; } /* Sensor data has timed out */ uint8_t rest_len = sll_data.len - sent_parts * len; if (rest_len < len) { /* This is the final packet */ memcpy(output, sll_data.data + sent_parts * len, rest_len); return ECMD_FINAL(rest_len); } else { memcpy(output, sll_data.data + sent_parts * len, len); output[len] = ECMD_NO_NEWLINE; return ECMD_AGAIN(len); } } /* -- Ethersex META -- block([[Serial Line Logging|SLL]]) ecmd_feature(sll_get, "sll get",,Request the logged data) */
/* * vdrive-command.h - Virtual disk-drive implementation. Command interpreter. * * 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. * */ #ifndef VICE_VDRIVE_COMMAND_H #define VICE_VDRIVE_COMMAND_H #include "types.h" struct vdrive_s; extern void vdrive_command_init(void); extern int vdrive_command_execute(struct vdrive_s *vdrive, const uint8_t *buf, unsigned int length); extern int vdrive_command_format(struct vdrive_s *vdrive, const char *disk_name); extern int vdrive_command_validate(struct vdrive_s *vdrive); extern int vdrive_command_set_error(struct vdrive_s *vdrive, int code, unsigned int track, unsigned int sector); extern int vdrive_command_memory_read(struct vdrive_s *vdrive, const uint8_t *buf, uint16_t addr, unsigned int length); extern int vdrive_command_memory_write(struct vdrive_s *vdrive, const uint8_t *buf, uint16_t addr, unsigned int length); extern int vdrive_command_memory_exec(struct vdrive_s *vdrive, const uint8_t *buf, uint16_t addr, unsigned int length); extern int vdrive_command_switch(struct vdrive_s *vdrive, int part); extern void vdrive_command_return(struct vdrive_s *vdrive, int origpart); extern int vdrive_command_switchtraverse(struct vdrive_s *vdrive, cbmdos_cmd_parse_plus_t *cmd); #endif
/** ** Hatchit Engine ** Copyright(c) 2015 Third-Degree ** ** GNU Lesser General Public License ** This file may be used under the terms of the GNU Lesser ** General Public License version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv3 included ** in the packaging of this file. Please review the following information ** to ensure the GNU Lesser General Public License requirements ** will be met: https://www.gnu.org/licenses/lgpl.html ** **/ /** * \class GLTessShader * \ingroup HatchitGraphics * * \brief A class that will compile and reflect a tesselation shader with OpenGL * * This should compile and reflect a GLSL tesselation shader with OpenGL from a blob of character data */ #pragma once #include <ht_glshader.h> namespace Hatchit { namespace Graphics { namespace OpenGL { class HT_API GLTessShader : public GLShader { public: GLTessShader(); virtual ~GLTessShader(); void VCompile() override; }; } } }
/**** DIAMOND protein aligner Copyright (C) 2016-2021 Max Planck Society for the Advancement of Science e.V. Benjamin Buchfink Code developed by Benjamin Buchfink <benjamin.buchfink@tue.mpg.de> This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. ****/ #pragma once #include <stdlib.h> #include <cstdlib> #include <utility> #include <algorithm> #include "../../basic/config.h" #include "radix_cluster.h" #include "../data_structures/hash_table.h" #include "../data_structures/double_array.h" #include "../math/integer.h" struct RelPtr { RelPtr() {} RelPtr(unsigned r): r(r), s(0) {} operator unsigned() const { return r; } unsigned r, s; }; template<typename _t> void hash_table_join( const Relation<_t> &R, const Relation<_t> &S, unsigned shift, DoubleArray<typename _t::Value> &dst_r, DoubleArray<typename _t::Value> &dst_s) { typedef HashTable<unsigned, RelPtr, ExtractBits<uint32_t>> Table; uint32_t N = (uint32_t)next_power_of_2(R.n * config.join_ht_factor); Table table(N, ExtractBits<uint32_t>(N, shift)); typename Table::Entry *p; for (_t *i = R.data; i < R.end(); ++i) { p = table.insert(i->key); ++p->r; i->key = unsigned(p - table.data()); } _t *hit_s = S.data; for (_t *i = S.data; i < S.end(); ++i) { if ((p = table.find_entry(i->key))) { ++p->s; hit_s->value = i->value; hit_s->key = unsigned(p - table.data()); ++hit_s; } } typename DoubleArray<typename _t::Value>::Iterator it_r = dst_r.begin(), it_s = dst_s.begin(); for (unsigned i = 0; i < table.size(); ++i) { p = &table.data()[i]; if (p->s) { unsigned r = p->r, s = p->s; it_r.count() = r; it_s.count() = s; p->r = dst_r.offset(it_r) + 4; p->s = dst_s.offset(it_s) + 4; it_r.next(); it_s.next(); } } dst_r.set_end(it_r); dst_s.set_end(it_s); for (const _t *i = R.data; i < R.end(); ++i) { p = &table.data()[i->key]; if (p->s) { dst_r[p->r] = i->value; p->r += sizeof(typename _t::Value); } } for (const _t *i = S.data; i < hit_s; ++i) { p = &table.data()[i->key]; dst_s[p->s] = i->value; p->s += sizeof(typename _t::Value); } } template<typename _t> void table_join( const Relation<_t> &R, const Relation<_t> &S, unsigned total_bits, unsigned shift, DoubleArray<typename _t::Value> &dst_r, DoubleArray<typename _t::Value> &dst_s) { const unsigned keys = 1 << (total_bits - shift); ExtractBits<uint32_t> key(keys, shift); RelPtr *table = (RelPtr*)calloc(keys, sizeof(RelPtr)); RelPtr *p; for (_t *i = R.data; i < R.end(); ++i) ++table[key(i->key)].r; _t *hit_s = S.data; for (_t *i = S.data; i < S.end(); ++i) { if ((p = &table[key(i->key)])->r) { ++p->s; std::copy(i, i + 1, hit_s++); } } typename DoubleArray<typename _t::Value>::Iterator it_r = dst_r.begin(), it_s = dst_s.begin(); for (unsigned i = 0; i < keys; ++i) { p = &table[i]; if (p->s) { unsigned r = p->r, s = p->s; it_r.count() = r; it_s.count() = s; p->r = dst_r.offset(it_r) + 4; p->s = dst_s.offset(it_s) + 4; it_r.next(); it_s.next(); } } dst_r.set_end(it_r); dst_s.set_end(it_s); for (const _t *i = R.data; i < R.end(); ++i) { p = &table[key(i->key)]; if (p->s) { dst_r[p->r] = i->value; p->r += sizeof(typename _t::Value); } } for (const _t *i = S.data; i < hit_s; ++i) { p = &table[key(i->key)]; dst_s[p->s] = i->value; p->s += sizeof(typename _t::Value); } free(table); } template<typename _t> void hash_join( Relation<_t> R, Relation<_t> S, _t *dst_r, _t *dst_s, DoubleArray<typename _t::Value> &out_r, DoubleArray<typename _t::Value> &out_s, unsigned total_bits = 32, unsigned shift = 0) { if (R.n == 0 || S.n == 0) return; const unsigned key_bits = total_bits - shift; if (R.n < config.join_split_size || key_bits < config.join_split_key_len) { DoubleArray<typename _t::Value> tmp_r((void*)dst_r), tmp_s((void*)dst_s); if (next_power_of_2(R.n * config.join_ht_factor) < 1llu << key_bits) hash_table_join(R, S, shift, tmp_r, tmp_s); else table_join(R, S, total_bits, shift, tmp_r, tmp_s); out_r.append(tmp_r); out_s.append(tmp_s); } else { const unsigned clusters = 1 << config.radix_bits; unsigned *hstR = new unsigned[clusters], *hstS = new unsigned[clusters]; radix_cluster<_t, typename _t::GetKey>(R, shift, dst_r, hstR); radix_cluster<_t, typename _t::GetKey>(S, shift, dst_s, hstS); shift += config.radix_bits; hash_join(Relation<_t>(dst_r, hstR[0]), Relation<_t>(dst_s, hstS[0]), R.data, S.data, out_r, out_s, total_bits, shift); for (unsigned i = 1; i < clusters; ++i) hash_join(Relation<_t>(dst_r + hstR[i - 1], hstR[i] - hstR[i - 1]), Relation<_t>(dst_s + hstS[i - 1], hstS[i] - hstS[i - 1]), R.data + hstR[i - 1], S.data + hstS[i - 1], out_r, out_s, total_bits, shift); delete[] hstR; delete[] hstS; } } template<typename _t> std::pair<DoubleArray<typename _t::Value>, DoubleArray<typename _t::Value>> hash_join(Relation<_t> R, Relation<_t> S, unsigned total_bits = 32) { const bool swap = config.hash_join_swap && R.n > S.n; if (swap) std::swap(R, S); _t *buf_r = (_t*)malloc(sizeof(_t) * R.n), *buf_s = (_t*)malloc(sizeof(_t) * S.n); DoubleArray<typename _t::Value> out_r((void*)R.data), out_s((void*)S.data); hash_join(R, S, buf_r, buf_s, out_r, out_s, total_bits); free(buf_r); free(buf_s); if (swap) std::swap(out_r, out_s); return { out_r, out_s }; }
/** * INDI driver for Point Grey Chameleon USB2 camera * * Copyright (C) 2017 Andy Nikolenko * 2013 Ben Gilsrud * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef DC1394_PGREY_H #define DC1394_PGREY_H #include <indiccd.h> #include <dc1394/dc1394.h> using namespace std; class DC1394_PGREY: public INDI::CCD { public: DC1394_PGREY(); bool ISNewNumber (const char *dev, const char *name, double values[], char *names[], int n); virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n); void ISGetProperties(const char *dev); protected: // General device functions bool Connect(); bool Disconnect(); const char *getDefaultName(); bool initProperties(); bool updateProperties(); // CCD specific functions bool StartExposure(float duration); bool AbortExposure(); void TimerHit(); void addFITSKeywords(fitsfile *fptr, CCDChip *targetChip); bool UpdateCCDBin(int binx, int biny); IPState GuideNorth(float ms); IPState GuideSouth(float ms); IPState GuideWest(float ms); IPState GuideEast(float ms); private: // Utility functions float CalcTimeLeft(); void setupParams(); void grabImage(); float GetTemperature(); // Are we exposing? bool InExposure; bool capturing; // Struct to keep timing struct timeval ExpStart; float ExposureRequest; float TemperatureRequest; int timerID; uint32_t width; uint32_t height; float gain_min; float gain_max; dc1394video_mode_t selected_mode; bool temperatureCanRead; INumberVectorProperty SettingsNP; INumber SettingsN[1]; // We declare the CCD temperature property INumber TemperatureN[1]; INumberVectorProperty TemperatureNP; dc1394_t *dc1394; dc1394camera_t *dcam; }; #endif // DC1394_PGREY_H
#include "inclino-sensors.h" #include <errno.h> #include "../libiio/iio.h" #include <stdio.h> #include <string.h> #include <signal.h> #define BUFFER_SIZE 10 #define MCP_68 "1-0068" #define MCP_69 "1-0069" static struct iio_context *ctx; void inclino_init(void) { /* Creation of an IIO context */ ctx = iio_create_local_context(); if (ctx == NULL) { perror("[ERROR ]: Failed to create local context"); } } void inclino_destroy(void) { /* Destroy the IIO context */ iio_context_destroy(ctx); } float inclino_getX_value(int channel) { struct iio_device *device_inclino; struct iio_channel *channel_inclino; int real_channel; char buffer[BUFFER_SIZE] = {0}; float a = 0.010416666666667; float b = -10.416666666667; float result = 0; if (channel > 4) { device_inclino = iio_context_find_device(ctx, MCP_69); if (device_inclino == NULL) printf("[ERROR ]: Failed to load %s device\n", MCP_69); real_channel = channel - 5; } else { device_inclino = iio_context_find_device(ctx, MCP_68); if (device_inclino == NULL) printf("[ERROR ]: Failed to load %s device\n", MCP_68); real_channel = channel - 1; } channel_inclino = iio_device_get_channel(device_inclino, real_channel); if (channel_inclino == NULL) { printf("[ERROR ]: Failed to load %d channel", channel); } if (iio_channel_attr_read(channel_inclino, "raw", buffer, BUFFER_SIZE) > 0) { result = a * (float)atoi(buffer) + b; //printf("x = %s\n", buffer); //printf("x = %.1f\n", result); } if (result > 10) result = 10; if (result < -10) result = -10; if (result > -1 && result < 1) result = 0; return result; } float inclino_getY_value(int channel) { struct iio_device *device_inclino; struct iio_channel *channel_inclino; int real_channel; char buffer[BUFFER_SIZE] = {0}; float a = 0.010416666666667; float b = -10.416666666667; float result = 0; if (channel > 4) { device_inclino = iio_context_find_device(ctx, MCP_69); if (device_inclino == NULL) printf("[ERROR ]: Failed to load %s device\n", MCP_69); real_channel = channel - 5; } else { device_inclino = iio_context_find_device(ctx, MCP_68); if (device_inclino == NULL) printf("[ERROR ]: Failed to load %s device\n", MCP_68); real_channel = channel - 1; } channel_inclino = iio_device_get_channel(device_inclino, real_channel); if (channel_inclino == NULL) { printf("[ERROR ]: Failed to load %d channel", channel); } if (iio_channel_attr_read(channel_inclino, "raw", buffer, BUFFER_SIZE) > 0) { result = a * (float)atoi(buffer) + b; //printf("x = %s\n", buffer); //printf("y = %.1f\n", result); } if (result > 10) result = 10; if (result < -10) result = -10; if (result > -1 && result < 1) result = 0; return result; }
/* * Multicast datagram - Client */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> struct sockaddr_in localSock; struct ip_mreq group; int sockfd, datalen; char databuf[1024]; int main() { // Create socket sockfd = socket(AF_INET, SOCK_DGRAM, 0); printf("[CLIENT] Opening datagram socket\n"); // Set socket option for Reuse address int reuse = 1; setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, (char *) &reuse, sizeof(reuse)); printf("[CLIENT] Setting SO_REUSEADDR\n"); // Bind to local Interface memset((char *)&localSock, 0, sizeof(localSock)); localSock.sin_family = AF_INET; localSock.sin_addr.s_addr = INADDR_ANY; localSock.sin_port = htons(5555); bind(sockfd, (struct sockaddr *)&localSock, sizeof(localSock)); printf("[CLIENT] Binding datagram socket\n"); // Join the multicast group group.imr_multiaddr.s_addr = inet_addr("225.1.1.1"); group.imr_interface.s_addr = inet_addr("127.0.0.1"); setsockopt(sockfd, IPPROTO_IP, IP_ADD_MEMBERSHIP, (char *)&group, sizeof(group)); printf("[CLIENT] Adding multicast group\n"); datalen = sizeof(databuf); read(sockfd, databuf, datalen); printf("[CLIENT] Message from multicast server:\n%s", databuf); close(sockfd); }
/* * Copyright (C) 2008 Canonical Ltd * Copyright (C) 2012-2021 MATE Developers * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * Authored by Neil Jagdish Patel <neil.patel@canonical.com> * */ #include "task-list.h" #include "task-item.h" #define WNCK_I_KNOW_THIS_IS_UNSTABLE #include <libwnck/libwnck.h> struct _TaskListPrivate { WnckScreen *screen; gboolean show_all_windows; }; enum { PROP_0, PROP_SHOW_ALL_WINDOWS }; G_DEFINE_TYPE_WITH_PRIVATE (TaskList, task_list, GTK_TYPE_BOX); static void task_list_set_show_all_windows (TaskList *list, gboolean show_all_windows) { TaskListPrivate *priv = list->priv; priv->show_all_windows = show_all_windows; g_debug ("Show all windows: %s", show_all_windows ? "true" : "false"); } static void on_task_item_closed (TaskItem *item, TaskList *list) { gtk_container_remove (GTK_CONTAINER (list), GTK_WIDGET (item)); gtk_widget_destroy (GTK_WIDGET (item)); } static void on_window_opened (WnckScreen *screen, WnckWindow *window, TaskList *list) { WnckWindowType type; g_return_if_fail (TASK_IS_LIST (list)); type = wnck_window_get_window_type (window); if (type == WNCK_WINDOW_DESKTOP || type == WNCK_WINDOW_DOCK || type == WNCK_WINDOW_SPLASHSCREEN || type == WNCK_WINDOW_MENU) return; GtkWidget *item = task_item_new (window); if (item) { gtk_box_pack_start (GTK_BOX (list), item, FALSE, FALSE, 0); g_signal_connect (TASK_ITEM (item), "task-item-closed", G_CALLBACK (on_task_item_closed), list); } } /* GObject stuff */ static void task_list_finalize (GObject *object) { G_OBJECT_CLASS (task_list_parent_class)->finalize (object); } static void task_list_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { TaskList *list = TASK_LIST (object); TaskListPrivate *priv; g_return_if_fail (TASK_IS_LIST (list)); priv = list->priv; switch (prop_id) { case PROP_SHOW_ALL_WINDOWS: g_value_set_boolean (value, priv->show_all_windows); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); } } static void task_list_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { TaskList *list = TASK_LIST (object); g_return_if_fail (TASK_IS_LIST (list)); switch (prop_id) { case PROP_SHOW_ALL_WINDOWS: task_list_set_show_all_windows (list, g_value_get_boolean (value)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); } } static void task_list_class_init (TaskListClass *klass) { GObjectClass *obj_class = G_OBJECT_CLASS (klass); obj_class->finalize = task_list_finalize; obj_class->set_property = task_list_set_property; obj_class->get_property = task_list_get_property; g_object_class_install_property (obj_class, PROP_SHOW_ALL_WINDOWS, g_param_spec_boolean ("show_all_windows", "Show All Windows", "Show windows from all workspaces", TRUE, G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); } static void task_list_init (TaskList *list) { TaskListPrivate *priv; priv = list->priv = task_list_get_instance_private (list); priv->screen = wnck_screen_get_default (); gtk_container_set_border_width (GTK_CONTAINER (list), 0); g_signal_connect (priv->screen, "window-opened", G_CALLBACK (on_window_opened), list); } GtkWidget * task_list_new (void) { GtkWidget *list = NULL; list = g_object_new (TASK_TYPE_LIST, "homogeneous", FALSE, "spacing", 0, NULL); return list; } GtkWidget * task_list_get_default (void) { static GtkWidget *list = NULL; if (!list) list = task_list_new (); return list; } gboolean task_list_get_desktop_visible (TaskList *list) { GList *windows, *w; gboolean all_minimised = TRUE; g_return_val_if_fail (TASK_IS_LIST (list), TRUE); windows = wnck_screen_get_windows (list->priv->screen); for (w = windows; w; w = w->next) { WnckWindow *window; window = w->data; if (WNCK_IS_WINDOW (window) && !wnck_window_is_minimized (window)) all_minimised = FALSE; } return all_minimised; } gboolean task_list_get_show_all_windows (TaskList *list) { return list->priv->show_all_windows; }
/* ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ /** * @file hal_st.h * @brief ST Driver macros and structures. * @details This header is designed to be include-able without having to * include other files from the HAL. * * @addtogroup ST * @{ */ #ifndef HAL_ST_H #define HAL_ST_H #include "hal_st_lld.h" /*===========================================================================*/ /* Driver constants. */ /*===========================================================================*/ /*===========================================================================*/ /* Driver pre-compile time settings. */ /*===========================================================================*/ /*===========================================================================*/ /* Derived constants and error checks. */ /*===========================================================================*/ /* Compatibility with old LLDS.*/ #if !defined(ST_LLD_NUM_ALARMS) #define ST_LLD_NUM_ALARMS 1 #endif /*===========================================================================*/ /* Driver data structures and types. */ /*===========================================================================*/ typedef void (*st_callback_t)(unsigned alarm); /*===========================================================================*/ /* Driver macros. */ /*===========================================================================*/ /*===========================================================================*/ /* External declarations. */ /*===========================================================================*/ #if (ST_LLD_NUM_ALARMS > 1) && !defined(__DOXYGEN__) extern st_callback_t st_callbacks[ST_LLD_NUM_ALARMS - 1]; #endif #ifdef __cplusplus extern "C" { #endif void stInit(void); void stStartAlarm(systime_t abstime); void stStopAlarm(void); void stSetAlarm(systime_t abstime); systime_t stGetAlarm(void); systime_t stGetCounter(void); bool stIsAlarmActive(void); #if ST_LLD_NUM_ALARMS > 1 bool stIsAlarmActiveN(unsigned alarm); void stStartAlarmN(unsigned alarm, systime_t abstime, st_callback_t cb); void stStopAlarmN(unsigned alarm); void stSetAlarmN(unsigned alarm, systime_t abstime); systime_t stGetAlarmN(unsigned alarm); #endif #ifdef __cplusplus } #endif #endif /* HAL_ST_H */ /** @} */
#ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> namespace Ui { class MainWindow; } class MainWindow : public QMainWindow { Q_OBJECT public: explicit MainWindow(QWidget *parent = 0); ~MainWindow(); private slots: void on_toolButton_clicked(); void mousePressEvent(QMouseEvent *event); void mouseMoveEvent(QMouseEvent *event); void mouseReleaseEvent(QMouseEvent *event); void enterEvent(QEvent *event); void leaveEvent(QEvent *event); void on_btfontm_clicked(); void on_btfontp_clicked(); signals: void close(); private: Ui::MainWindow *ui; void process_line(const QString &); void process_line(const QByteArray &); }; #endif // MAINWINDOW_H
/* * Copyright (C) 2011 Canonical Ltd * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * Authored by: Gordon Allott <gord.alott@canonical.com> */ #ifndef BGHASH_H #define BGHASH_H #include <NuxCore/Animation.h> #include <Nux/Nux.h> namespace unity { namespace colors { const nux::Color Aubergine(0x3E, 0x20, 0x60); }; }; namespace unity { class BGHash { public: BGHash(); nux::Color CurrentColor() const; uint64_t ColorAtomId() const; void RefreshColor(); void OverrideColor(nux::Color const& color); private: void OnTransitionUpdated(nux::Color const& new_color); void TransitionToNewColor(nux::Color const& new_color); nux::Color MatchColor(nux::Color const& base_color) const; private: nux::animation::AnimateValue<nux::Color> transition_animator_; nux::Color override_color_; }; }; #endif // BGHASH_H
#if !defined(RUNNER_H_INCLUDED) #define RUNNER_H_INCLUDED #include <set> // std::set #include <string> // std::string #include "phrqtype.h" #include "StorageBinList.h" #include "PHRQ_base.h" class CParser; class runner: public PHRQ_base { public: runner(PHRQ_io *io=NULL); runner(CParser & parser, PHRQ_io *io=NULL); virtual ~runner(void); bool Read(CParser & parser); StorageBinListItem & Get_cells(void) { return(this->cells); }; LDBLE Get_time_step() { return(this->time_step); }; LDBLE Get_start_time() { return(this->start_time); }; void Set_time_step(LDBLE ts) { this->time_step = ts; }; void Set_start_time(LDBLE st) { this->start_time = st; }; bool Get_run_cells() { return(this->run_cells); }; void Set_run_cells(bool tf) { this->run_cells = tf; }; protected: LDBLE time_step; LDBLE start_time; StorageBinListItem cells; bool run_cells; const static std::vector < std::string > vopts; }; #endif // !defined(RUNNER_H_INCLUDED)
#ifndef PULSE_BACKEND_H #define PULSE_BACKEND_H #include <pulse/pulseaudio.h> #include "synesthesia-app.h" typedef struct pa_devicelist { uint8_t initialized; char name[512]; uint32_t index; char description[256]; } pa_devicelist_t; int get_pulse_devices(pa_devicelist_t **sources); gpointer pulse_input(gpointer data); void pulse_disconnect(); pcmframe *pulse_getbuffer(int *count, int *clear); int pulse_connection_active(); #endif
#ifndef __GRIDDIVIDE_H_ #define __GRIDDIVIDE_H_ #include "matrix.h" #include "float.h" #include "math.h" #include "icpPointToPlane.h" #include <vector> #include <algorithm> #include <queue> using namespace std; struct Point_xyz { double x, y, z; int grid_x, grid_y, grid_z; int index; public: Point_xyz() : x(-1), y(-1), z(-1), grid_x(-1), grid_y(-1), grid_z(-1), index(-1) {} Point_xyz(double x, double y, double z, int grid_x, int grid_y, int grid_z, int index) : x(x), y(y), z(z), grid_x(grid_x), grid_y(grid_y), grid_z(grid_z), index(index) {} }; class griddivide{ public: griddivide(double *M, const int32_t M_num, const int32_t dim); void dividenum(int nx, int ny, int nz) { n_x = nx; n_y = ny; n_z = nz; point.resize(n_x*n_y*n_z); } double GetMax_z() { return max_z; } double GetMin_z() { return min_z; } void grid_point(double *M, const int32_t M_num, const int32_t dim); double* first_filter_grid(double* M, int& num_G, int dim, double threshold); int label_pointcloud(vector<vector<int>>& point, vector<int>& temp); void label_point(vector<vector<int>> point, vector<int>& temp, int x, int y, int z, queue<int>& point_temp); void grid_fitcurve(double * M, vector<int>& p, double threshold, int pos, const int dim); double GetInterval(); double* gridconvert(double* M, int& num, double* M_c); // ת»»³ÉͼÏñÊý¾Ý //double* griddivide::RotateImage(double* M, int num); // ÐýתͼÏñ private: double min_x, max_x; double min_y, max_y; double min_z, max_z; int n_x, n_y, n_z, dim, num; vector<vector<int>> point; vector<Point_xyz> Pointxyz; }; Matrix fit_plane(double* M, int dim, int num); double dot_product(vector<double> x, vector<double> y); vector<double> cross_product(vector<double> x, vector<double> y); vector<double> cross_product(vector<double> v, double n); vector<double> AddVector(vector<double> v, double num); vector<double> SubVector(vector<double> v1, vector<double> v2); vector<double> DivideVector(vector<double> v, double num); double SumVector(double *M, int i, int j, int k, int N, int dim); double norm_p(vector<double> v); void ClearArray(double *M, vector<int> p, int dim); int GetIndexOfKmeans(vector<vector<double>> Kmeans, double* M, int index, int dim); double* RotateImage(double* M, int num, int dim, int mode = 1); // ÐýתͼÏñ // 2017/04/20еÄÍø¸ñ·Ö¸îºÍ¾ÛÀà class griddivide_new { public: griddivide_new(double* M, const int32_t M_num, const int32_t dim); void gridpoint(double* M, double cubsize); double* grid_filter(double* M, int& count, int min_p, int mode = 1); vector<vector<double>> grid_kmeans(double* M, int k, int num); double GetMax_x() { return max_x - min_x; } private: double min_x, max_x; double min_y, max_y; double min_z, max_z; // ×î´óµãºÍ×îСµã×ø±ê int n_x, n_y, n_z; const int num, dim; vector<vector<int>> point; vector<vector<double>> P_new; // point¼ÇÂ¼Íø¸ñÄڵĵ㣬P_new¼Ç¼ÐµĵãÔÆµã£¨¸úÍø¸ñÊýÏàͬ£© }; #endif
/* * $Revision: 2299 $ * * last checkin: * $Author:klein $ * $Date:2007-10-18 17:23:28 +0200 (Thu, 18 Oct 2007) $ ***************************************************************/ /** \file * \brief Declaration of an abstract heap base class for * priority queue implementation. * * \author Karsten Klein * * \par License: * This file is part of the Open Graph Drawing Framework (OGDF). * * Copyright (C). All rights reserved. * See README.txt in the root directory of the OGDF installation for details. * * \par * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * Version 2 or 3 as published by the Free Software Foundation; * see the file LICENSE.txt included in the packaging of this file * for details. * * \par * 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. * * \par * You should have received a copy of the GNU General Public * License along with this program; if not, write to the Free * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. * * \see http://www.gnu.org/copyleft/gpl.html ***************************************************************/ #ifdef _MSC_VER #pragma once #endif #ifndef OREAS_HEAP_BASE_H #define OREAS_HEAP_BASE_H #include <ogdf/basic/GraphCopy.h> namespace ogdf { /** * \brief A data structure implementing the abstract data type * priority queue * A Heap is a data structure implementing the abstract data type * priority queue, maintaining a set of elements each with an associated key value * used for keeping the elements in a specific order. * It supports the following operations: * insert(element, key) insert element with key in set * min return element with minimum key * extractMin remove and return element with minimum key * decreaseKey decrease the key of a given element to a given value * delete remove a given element fromthe structure * Running times and space requirements are depending on the actual * implementation type (e.g., binary, binomial or fibonacci heaps) */ class HeapEntry; class HeapEntryPointer; template <class Priority, class HeapObject> class HeapBase { public: //! Constructor HeapBase() {}; virtual ~HeapBase() {} //! build a heap out of a given set of elements virtual void makeHeap() = 0; HeapObject minRet() {} //******************************************************* //Modification //! insert a new element with priority key virtual void insert(HeapObject, Priority /* key */) {}; //extractMin //derived classes should decide themselves if they have //a specific delete function //virtual void delete() = 0; //! update the data structure by decreasing the key of an object //TODO: Does not make much sense without an object parameter virtual void decreaseKey() {}; //******************************************************* //constant functions int size() const {return m_size;} bool empty() const {return m_size==0;} protected: int m_size; //number of elements stored in heap }; } //namespace oreas #endif /* //return and deletes the object with minimum priority objects extractMin() { objects theMin = minRet(); deleteMin(); return theMin; } //deletes the object with minimum priority void deleteMin() {deleteObject(minPointer); size--;} */
/* * Copyright (C) 2002 Anthony Lomax <anthony@alomax.net> * * 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. */ /* grad2layer.c Program to convert gradient model (NonLinLoc) to layered model (doubDiff) */ /*------------------------------------------------------------*/ /* Anthony Lomax | email: anthony@alomax.net */ /* Scientific Software | web: www.alomax.net */ /* Mouans-Sartoux, FRANCE | */ /*------------------------------------------------------------*/ /* history: ver 01 15FEB2002 AJL Original version .........1.........2.........3.........4.........5.........6.........7.........8 */ #define PNAME "grad2layer" /* defines */ /* globals */ /*** Program to convert gradient model to layered model */ main(int argc, char *argv[]) { int i, index; double depth; // ---------- describe model here ---------- double ratio = 1.73; int nSegments = 6; double grad_vel[][3] = { { 0.0, 3.45, 0.7100}, { 1.0, 4.16, 0.4000}, { 3.0, 4.96, 0.1933}, { 6.0, 5.54, 0.0538}, {14.0, 5.97, 0.0455}, {25.0, 7.98, 0.00 } }; double layer_thickness = 0.5; int num_layers = 21; // ---------- end - describe model here ---------- printf("* NLAY RATIO\n"); printf("%d %lf\n", num_layers, ratio); printf("* TOP\n"); for (i = 0; i < num_layers; i++) printf("%.1lf ", layer_thickness * (double) i); printf("\n* VEL\n"); index = 0; for (i = 0; i < num_layers; i++) { depth = layer_thickness * (double) i + 0.000001; while (index < nSegments - 1 && depth > grad_vel[index + 1][0]) index++; printf("%.2lf ", grad_vel[index][1] + grad_vel[index][2] * (depth - grad_vel[index ][0])); } printf("\n*\n"); } /*------------------------------------------------------------/ */ /* Anthony Lomax | email: lomax@faille.unice.fr / */ /* UMR Geosciences Azur | web: www-geoazur.unice.fr/~lomax / */ /* 250 Rue Albert Einstein | tel: 33 (0) 4 93 95 43 25 / */ /* 06560 Valbonne, FRANCE | fax: 33 (0) 4 93 65 27 17 / */ /*------------------------------------------------------------/ */
int max(int a, int b); int min(int a, int b); int mean(int *array, int size, int *result); #ifdef ENABLE_DEBUG #define DEBUG_INFO() fprintf(stderr, "\n ** Debug and test compiled: %s %s **\n\n ",__DATE__, __TIME__); #define DEBUG(a, ...) fprintf(stderr, "[%s:%s():%d] ",__FILE__,__func__, __LINE__ ); fprintf(stderr, a, __VA_ARGS__); #define DEBUG_INT_VAR(a) fprintf(stderr, "[%s:%s():%d] ",__FILE__,__func__, __LINE__ ); fprintf(stderr, "%s=%d\n", #a, a); #else #define DEBUG(a, ...) #define DEBUG_INFO() #define DEBUG_INT_VAR(a) #endif
#ifndef ORDENACAO_MARCA_ID_H #define ORDENACAO_MARCA_ID_H #include "template_ordenacao_marca.h" class ordenacao_marca_id : public Template_Ordenacao_Marca { // Template_Ordenacao_Marca interface public: ordenacao_marca_id(); bool criterio(VIMS::Marca m1, VIMS::Marca m2) const; }; #endif // ORDENACAO_MARCA_ID_H
/* * Copyright (C) 2015 Canonical, Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, 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/>. * * Author: Pete Woods <pete.woods@canonical.com> */ #pragma once #include <QHash> #include <memory> template <class T> Q_INLINE_TEMPLATE uint qHash(const std::shared_ptr<T> &ptr, uint seed = 0) { return QT_PREPEND_NAMESPACE(qHash)(ptr.get(), seed); }
/*! flashdemo -- demo for Flash memory access from firmware and host software for ZTEX USB-XMEGA Module 1.0 Copyright (C) 2009-2011 ZTEX GmbH. http://www.ztex.de This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 3 as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, see http://www.gnu.org/licenses/. !*/ #include[ztex-conf.h] // Loads the configuration macros, see ztex-conf.h for the available macros #include[ztex-utils.h] // include basic functions and variables // select ZTEX USB-XMEGA Module 1.0 as target IDENTITY_UXM_1_0(10.30.0.0,0); // enable Flash support ENABLE_FLASH; // this product string is also used for identification by the host software #define[PRODUCT_STRING]["Flash demo for UXM 1.0"] __code char flash_string[] = "Hello World!"; // include the main part of the firmware kit, define the descriptors, ... #include[ztex.h] void main(void) { __xdata DWORD sector; init_USB(); // init everything if ( flash_enabled ) { flash_read_init( 0 ); // prepare reading sector 0 flash_read((__xdata BYTE*) &sector, 4); // read the number of last sector flash_read_finish(flash_sector_size - 4); // dummy-read the rest of the sector + finish read operation sector++; if ( sector > flash_sectors || sector == 0 ) { sector = 1; } flash_write_init( 0 ); // prepare writing sector 0 flash_write((__xdata BYTE*) &sector, 4); // write the current sector number flash_write_finish_sector(flash_sector_size - 4); // dummy-write the rest of the sector + CRC flash_write_finish(); // finish write operation flash_write_init( sector ); // prepare writing sector sector flash_write((__xdata BYTE*) flash_string, sizeof(flash_string)); // write the string flash_write_finish_sector(flash_sector_size - sizeof(flash_string)); // dummy-write the rest of the sector + CRC flash_write_finish(); // finish write operation } while (1) { } // twiddle thumbs }
/****************************************************************************/ /// @file MSEventControl.h /// @author Christian Roessel /// @author Daniel Krajzewicz /// @author Michael Behrisch /// @author Matthias Heppner /// @date Mon, 12 Mar 2001 /// @version $Id: MSEventControl.h 13811 2013-05-01 20:31:43Z behrisch $ /// // Stores time-dependant events and executes them at the proper time /****************************************************************************/ // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/ // Copyright (C) 2001-2013 DLR (http://www.dlr.de/) and contributors /****************************************************************************/ // // This file is part of SUMO. // SUMO 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. // /****************************************************************************/ #ifndef MSEventControl_h #define MSEventControl_h // =========================================================================== // included modules // =========================================================================== #ifdef _MSC_VER #include <windows_config.h> #else #include <config.h> #endif #include <utility> #include <queue> #include <vector> #include <map> #include <utils/common/SUMOTime.h> #include <utils/common/UtilExceptions.h> // =========================================================================== // class declarations // =========================================================================== class Command; // =========================================================================== // class definitions // =========================================================================== /** * @class MSEventControl * @brief Stores time-dependant events and executes them at the proper time */ class MSEventControl { public: /// @brief Combination of an event and the time it shall be executed at typedef std::pair< Command*, SUMOTime > Event; /** * @enum AdaptType * @brief Defines what to do if the insertion time lies before the current simulation time */ enum AdaptType { /// @brief Patch the time in a way that it is at least as high as the simulation begin time ADAPT_AFTER_EXECUTION = 1, /// @brief Do nothing NO_CHANGE = 2 }; public: /// @brief Default constructor. MSEventControl(); /// @brief Destructor. virtual ~MSEventControl(); /** @brief Adds an Event. * * If the given execution time step lies before the current and ADAPT_AFTER_EXECUTION * is passed for adaptation type, the execution time step will be set to the * current time step. * * Returns the time the event will be executed, really. * * @param[in] operation The event to add * @param[in] execTimeStep The time the event shall be executed at * @param[in] type The adaptation type * @see Command * @see AdaptType */ virtual SUMOTime addEvent(Command* operation, SUMOTime execTimeStep, AdaptType type); /** @brief Executes time-dependant commands * * Loops over all stored events, continuing until the first event which * execution time lies beyond the given time + deltaT. If the event * had to be executed before the given time, a warning is generated and * the event deleted. Otherwise (the event is valid), the event is executed. * * Each executed event must return the time that has to pass until it shall * be executed again. If the returned time is 0, the event is deleted. * Otherwise it is readded, after the new execution time (returned + current) * is computed. * * ProcessErrors thrown by executed commands are rethrown. * * @param[in] time The current simulation time * @exception ProcessError From an executed Command */ virtual void execute(SUMOTime time); /** @brief Returns whether events are in the que. * * @return whether events are in the que */ bool isEmpty(); /** @brief Set the current Time. * * This method is only for Unit Testing. * Set the current TimeStep used in addEvent. * Normally the time is set automatically from an instance of MSNet. */ void setCurrentTimeStep(SUMOTime time); protected: /** @brief Sort-criterion for events. * * Sorts events by their execution time */ class EventSortCrit { public: /// @brief compares two events bool operator()(const Event& e1, const Event& e2) const { return e1.second > e2.second; } }; private: /// @brief Container for time-dependant events, e.g. traffic-light-change. typedef std::priority_queue< Event, std::vector< Event >, EventSortCrit > EventCont; /// The Current TimeStep SUMOTime currentTimeStep; /// @brief Event-container, holds executable events. EventCont myEvents; /// get the Current TimeStep used in addEvent. SUMOTime getCurrentTimeStep(); private: /// @brief invalid copy constructor. MSEventControl(const MSEventControl&); /// @brief invalid assignment operator. MSEventControl& operator=(const MSEventControl&); }; #endif /****************************************************************************/
/* This file is part of solidity. solidity 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. solidity 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 solidity. If not, see <http://www.gnu.org/licenses/>. */ // SPDX-License-Identifier: GPL-3.0 #pragma once namespace solidity::frontend { class VariableDeclaration; class Declaration; class Expression; /// Find the topmost referenced constant variable declaration when the given variable /// declaration value is an identifier. Works only for constant variable declarations. /// Returns nullptr if an identifier in the chain is not referencing a constant variable declaration. VariableDeclaration const* rootConstVariableDeclaration(VariableDeclaration const& _varDecl); /// Returns true if the constant variable declaration is recursive. bool isConstantVariableRecursive(VariableDeclaration const& _varDecl); }
/* Biblioteka JOSKIPI * Jêzyk Opisu Stanu Korpusu IPI * * (c) Instytut Informatyki Stosowanej Politechniki Wroc³awskiej * i Instytut Podstaw Informatyki PAN * Autorzy: Grzegorz Godlewski, Maciej Piasecki, Bartosz Broda, Adam Wardyñski * * Kod na licencji GPL. */ #ifndef JOSKIPI_RULEPARSER_H #define JOSKIPI_RULEPARSER_H #include "../joskipi_headers.h" #include "PatternParser.h" #include "../Rules/RuleSet.h" namespace JOSKIPI { namespace Parsers { /** DEPRECATED. Zalecany CAntlrParser. */ class JOSKIPI_API CRulesParser { public: CRulesParser(Rules::CRuleSet* rules); ~CRulesParser(void); // parsuje plik z regu³ami, które zapisuje do zbioru regu³ podawanego // w konstruktorze void Parse(std::ifstream& file); protected: void AddMacro(std::vector<std::string>& macroStr); void InsertMacros(std::vector<std::string>& patternLines); void ParseRule(std::vector<std::string>& ruleStrings); Rules::CRuleSet* rules; std::map<std::string,std::vector<std::string> >* preProcessor; CPatternParser* patPar; }; }//namespace JOSKIPI }//namespace Parsers #endif //JOSKIPI_RULEPARSER_H
/* * gen_functions.h * Converts md files for the Mental Health and Wellness Knowledge Base * https://github.com/andy5995/mhwkb * * Copyright 2017 Andy Alt <andy400-dev@yahoo.com> * With contributions from * * Daniel Kelly <myself@danielkelly.me> * * and others mentioned in * https://github.com/andy5995/mhwkb/blob/master/CONTRIBUTING.md * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. * * */ #ifndef GEN_FUNCTIONS_H #define GEN_FUNCTIONS_H #include "mhwkb.h" void del_char_shift_left (char *str, char c); void trim_char (char *str, char c); void buf_check (const char *str, const int len); int parse_tags_line (char *line, char tags[][TAG_MAX_LEN]); /* strip any code from the tags */ char* make_tags_real (const int tag_ctr, char tags[][TAG_MAX_LEN], char *article_links, struct p *page_calc); void create_tag_html_files (const int tag_ctr, const char *output_dir, char tags[][TAG_MAX_LEN], const char *link_href, const char *link_title); #endif
#ifndef QSIPGATERESTLIB_UICONTROL_H #define QSIPGATERESTLIB_UICONTROL_H #include <QObject> #include <QUrl> #include <QNetworkReply> #include <QNetworkRequest> #include <QNetworkAccessManager> #include "parsereply.h" namespace qsipgaterestlib { class UIControl : public QObject { Q_OBJECT public: explicit UIControl(QObject *qmlComponent, QObject *parent = 0); signals: public slots: void onRequest(); void onWrite(QString); private: QNetworkAccessManager *m_networkManager; QObject *m_qmlComponent; qsipgaterestlib::ParseReply *m_parseReply; }; } // namespace qsipgaterestlib #endif // QSIPGATERESTLIB_UICONTROL_H
/* * (C) Copyright 2010 * Stefan Roese, DENX Software Engineering, sr@denx.de. * * SPDX-License-Identifier: GPL-2.0+ */ #ifndef _PPC405EZ_H_ #define _PPC405EZ_H_ #define CONFIG_NAND_NDFC /* Memory mapped register */ #define CONFIG_SYS_PERIPHERAL_BASE 0xef600000 /* Internal Peripherals */ #define CONFIG_SYS_NS16550_COM1 (CONFIG_SYS_PERIPHERAL_BASE + 0x0300) #define CONFIG_SYS_NS16550_COM2 (CONFIG_SYS_PERIPHERAL_BASE + 0x0400) #define GPIO0_BASE (CONFIG_SYS_PERIPHERAL_BASE + 0x0700) #define GPIO1_BASE (CONFIG_SYS_PERIPHERAL_BASE + 0x0800) /* DCR register */ #define OCM0_PLBCR1 0x0020 /* OCM PLB3 Bank 1 Config */ #define OCM0_PLBCR2 0x0021 /* OCM PLB3 Bank 2 Config */ #define OCM0_PLBBEAR 0x0022 /* OCM PLB3 Bus Error Add */ #define OCM0_DSRC1 0x0028 /* OCM D-side Bank 1 Config */ #define OCM0_DSRC2 0x0029 /* OCM D-side Bank 2 Config */ #define OCM0_ISRC1 0x002A /* OCM I-side Bank 1Config */ #define OCM0_ISRC2 0x002B /* OCM I-side Bank 2 Config */ #define OCM0_DISDPC 0x002C /* OCM D-/I-side Data Par Chk */ /* SDR register */ #define SDR0_NAND0 0x4000 #define SDR0_ULTRA0 0x4040 #define SDR0_ULTRA1 0x4050 #define SDR0_ICINTSTAT 0x4510 /* CPR register */ #define CPR0_PRIMAD 0x0080 #define CPR0_PERD0 0x00e0 #define CPR0_PERD1 0x00e1 #define CPR0_PERC0 0x0180 #define MAL_DCR_BASE 0x380 #define SDR_NAND0_NDEN 0x80000000 #define SDR_NAND0_NDBTEN 0x40000000 #define SDR_NAND0_NDBADR_MASK 0x30000000 #define SDR_NAND0_NDBPG_MASK 0x0f000000 #define SDR_NAND0_NDAREN 0x00800000 #define SDR_NAND0_NDRBEN 0x00400000 #define SDR_ULTRA0_NDGPIOBP 0x80000000 #define SDR_ULTRA0_CSN_MASK 0x78000000 #define SDR_ULTRA0_CSNSEL0 0x40000000 #define SDR_ULTRA0_CSNSEL1 0x20000000 #define SDR_ULTRA0_CSNSEL2 0x10000000 #define SDR_ULTRA0_CSNSEL3 0x08000000 #define SDR_ULTRA0_EBCRDYEN 0x04000000 #define SDR_ULTRA0_SPISSINEN 0x02000000 #define SDR_ULTRA0_NFSRSTEN 0x01000000 #define SDR_ULTRA1_LEDNENABLE 0x40000000 #define SDR_ICRX_STAT 0x80000000 #define SDR_ICTX0_STAT 0x40000000 #define SDR_ICTX1_STAT 0x20000000 #define CPR_CLKUPD_ENPLLCH_EN 0x40000000 /* Enable CPR PLL Changes */ #define CPR_CLKUPD_ENDVCH_EN 0x20000000 /* Enable CPR Sys. Div. Changes */ #define CPR_PERD0_SPIDV_MASK 0x000F0000 /* SPI Clock Divider */ #define PLLC_SRC_MASK 0x20000000 /* PLL feedback source */ #define PLLD_FBDV_MASK 0x1F000000 /* PLL feedback divider value */ #define PLLD_FWDVA_MASK 0x000F0000 /* PLL forward divider A value */ #define PLLD_FWDVB_MASK 0x00000700 /* PLL forward divider B value */ #define PRIMAD_CPUDV_MASK 0x0F000000 /* CPU Clock Divisor Mask */ #define PRIMAD_PLBDV_MASK 0x000F0000 /* PLB Clock Divisor Mask */ #define PRIMAD_OPBDV_MASK 0x00000F00 /* OPB Clock Divisor Mask */ #define PRIMAD_EBCDV_MASK 0x0000000F /* EBC Clock Divisor Mask */ #define PERD0_PWMDV_MASK 0xFF000000 /* PWM Divider Mask */ #define PERD0_SPIDV_MASK 0x000F0000 /* SPI Divider Mask */ #define PERD0_U0DV_MASK 0x0000FF00 /* UART 0 Divider Mask */ #define PERD0_U1DV_MASK 0x000000FF /* UART 1 Divider Mask */ #endif /* _PPC405EZ_H_ */
/* * Generated by asn1c-0.9.29 (http://lionet.info/asn1c) * From ASN.1 module "NGAP-IEs" * found in "../support/ngap-r16.1.0/38413-g10.asn" * `asn1c -pdu=all -fcompound-names -findirect-choice -fno-include-deps` */ #include "NGAP_EmergencyAreaID.h" int NGAP_EmergencyAreaID_constraint(const asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { const OCTET_STRING_t *st = (const OCTET_STRING_t *)sptr; size_t size; if(!sptr) { ASN__CTFAIL(app_key, td, sptr, "%s: value not given (%s:%d)", td->name, __FILE__, __LINE__); return -1; } size = st->size; if((size == 3)) { /* Constraint check succeeded */ return 0; } else { ASN__CTFAIL(app_key, td, sptr, "%s: constraint failed (%s:%d)", td->name, __FILE__, __LINE__); return -1; } } /* * This type is implemented using OCTET_STRING, * so here we adjust the DEF accordingly. */ static asn_oer_constraints_t asn_OER_type_NGAP_EmergencyAreaID_constr_1 CC_NOTUSED = { { 0, 0 }, 3 /* (SIZE(3..3)) */}; asn_per_constraints_t asn_PER_type_NGAP_EmergencyAreaID_constr_1 CC_NOTUSED = { { APC_UNCONSTRAINED, -1, -1, 0, 0 }, { APC_CONSTRAINED, 0, 0, 3, 3 } /* (SIZE(3..3)) */, 0, 0 /* No PER value map */ }; static const ber_tlv_tag_t asn_DEF_NGAP_EmergencyAreaID_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (4 << 2)) }; asn_TYPE_descriptor_t asn_DEF_NGAP_EmergencyAreaID = { "EmergencyAreaID", "EmergencyAreaID", &asn_OP_OCTET_STRING, asn_DEF_NGAP_EmergencyAreaID_tags_1, sizeof(asn_DEF_NGAP_EmergencyAreaID_tags_1) /sizeof(asn_DEF_NGAP_EmergencyAreaID_tags_1[0]), /* 1 */ asn_DEF_NGAP_EmergencyAreaID_tags_1, /* Same as above */ sizeof(asn_DEF_NGAP_EmergencyAreaID_tags_1) /sizeof(asn_DEF_NGAP_EmergencyAreaID_tags_1[0]), /* 1 */ { &asn_OER_type_NGAP_EmergencyAreaID_constr_1, &asn_PER_type_NGAP_EmergencyAreaID_constr_1, NGAP_EmergencyAreaID_constraint }, 0, 0, /* No members */ &asn_SPC_OCTET_STRING_specs /* Additional specs */ };
#ifndef TSL1406_H #define TSL1406_H class TSLXX ; class TSL1406 : public TSLXX { public: TSL1406(uint8_t clkPin, uint8_t siPin, uint8_t analogPin); static volatile uint8_t pixels[ 768 ]; static uint8_t pixelBuffer[ 768 ]; const int L_ARRAY = 768; const int L_ARRAY_1 = 769; }; volatile uint8_t TSL1406::pixels[ 768 ] = {0}; uint8_t TSL1406::pixelBuffer[ 768 ] = {0}; TSL1406::TSL1406(uint8_t clkPin, uint8_t siPin, uint8_t analogPin) { TSLXX TSL; TSL.init(clkPin, siPin, analogPin); TSL.pixelBuffer = pixelBuffer; TSL.pixels = pixels; TSL._L_ARRAY = L_ARRAY; TSL._L_ARRAY_1 = L_ARRAY_1; } #endif // TSL1406_H
/** * @file integrator.c * @brief Integration schemes. * @author Hanno Rein <hanno@hanno-rein.de> * @details This file implements the leap-frog integration scheme. * This scheme is second order accurate, symplectic and well suited for * non-rotating coordinate systems. Note that the scheme is formally only * first order accurate when velocity dependent forces are present. * * @section LICENSE * Copyright (c) 2015 Hanno Rein * * This file is part of rebound. * * rebound 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. * * rebound 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 rebound. If not, see <http://www.gnu.org/licenses/>. * */ #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <math.h> #include <time.h> #include <string.h> #include "rebound.h" #include "gravity.h" #include "output.h" #include "integrator.h" #include "integrator_whfast.h" #include "integrator_ias15.h" #include "integrator_mercurius.h" #include "integrator_leapfrog.h" #include "integrator_sei.h" #include "integrator_janus.h" void reb_integrator_part1(struct reb_simulation* r){ switch(r->integrator){ case REB_INTEGRATOR_IAS15: reb_integrator_ias15_part1(r); break; case REB_INTEGRATOR_LEAPFROG: reb_integrator_leapfrog_part1(r); break; case REB_INTEGRATOR_SEI: reb_integrator_sei_part1(r); break; case REB_INTEGRATOR_WHFAST: reb_integrator_whfast_part1(r); break; case REB_INTEGRATOR_MERCURIUS: reb_integrator_mercurius_part1(r); break; case REB_INTEGRATOR_JANUS: reb_integrator_janus_part1(r); break; default: break; } } void reb_integrator_part2(struct reb_simulation* r){ switch(r->integrator){ case REB_INTEGRATOR_IAS15: reb_integrator_ias15_part2(r); break; case REB_INTEGRATOR_LEAPFROG: reb_integrator_leapfrog_part2(r); break; case REB_INTEGRATOR_SEI: reb_integrator_sei_part2(r); break; case REB_INTEGRATOR_WHFAST: reb_integrator_whfast_part2(r); break; case REB_INTEGRATOR_MERCURIUS: reb_integrator_mercurius_part2(r); break; case REB_INTEGRATOR_JANUS: reb_integrator_janus_part2(r); break; case REB_INTEGRATOR_NONE: r->t += r->dt; r->dt_last_done = r->dt; break; default: break; } } void reb_integrator_synchronize(struct reb_simulation* r){ switch(r->integrator){ case REB_INTEGRATOR_IAS15: reb_integrator_ias15_synchronize(r); break; case REB_INTEGRATOR_LEAPFROG: reb_integrator_leapfrog_synchronize(r); break; case REB_INTEGRATOR_SEI: reb_integrator_sei_synchronize(r); break; case REB_INTEGRATOR_WHFAST: reb_integrator_whfast_synchronize(r); break; case REB_INTEGRATOR_MERCURIUS: reb_integrator_mercurius_synchronize(r); break; case REB_INTEGRATOR_JANUS: reb_integrator_janus_synchronize(r); break; default: break; } } void reb_integrator_init(struct reb_simulation* r){ switch(r->integrator){ case REB_INTEGRATOR_SEI: reb_integrator_sei_init(r); break; default: break; } } void reb_integrator_reset(struct reb_simulation* r){ r->integrator = REB_INTEGRATOR_IAS15; r->gravity_ignore_terms = 0; reb_integrator_ias15_reset(r); reb_integrator_mercurius_reset(r); reb_integrator_leapfrog_reset(r); reb_integrator_sei_reset(r); reb_integrator_whfast_reset(r); reb_integrator_janus_reset(r); } void reb_update_acceleration(struct reb_simulation* r){ // This should probably go elsewhere PROFILING_STOP(PROFILING_CAT_INTEGRATOR) PROFILING_START() reb_calculate_acceleration(r); if (r->N_var){ reb_calculate_acceleration_var(r); } if (r->additional_forces && (r->integrator != REB_INTEGRATOR_MERCURIUS || r->ri_mercurius.mode==0)){ // For Mercurius: // Additional forces are only calculated in the kick step, not during close encounter if (r->integrator==REB_INTEGRATOR_MERCURIUS){ // shift pos and velocity so that external forces are calculated in inertial frame // Note: Copying avoids degrading floating point performance if(r->N>r->ri_mercurius.allocatedN_additionalforces){ r->ri_mercurius.particles_backup_additionalforces = realloc(r->ri_mercurius.particles_backup_additionalforces, r->N*sizeof(struct reb_particle)); r->ri_mercurius.allocatedN_additionalforces = r->N; } memcpy(r->ri_mercurius.particles_backup_additionalforces,r->particles,r->N*sizeof(struct reb_particle)); reb_integrator_mercurius_dh_to_inertial(r); } r->additional_forces(r); if (r->integrator==REB_INTEGRATOR_MERCURIUS){ struct reb_particle* restrict const particles = r->particles; struct reb_particle* restrict const backup = r->ri_mercurius.particles_backup_additionalforces; for (int i=0;i<r->N;i++){ particles[i].x = backup[i].x; particles[i].y = backup[i].y; particles[i].z = backup[i].z; particles[i].vx = backup[i].vx; particles[i].vy = backup[i].vy; particles[i].vz = backup[i].vz; } } } PROFILING_STOP(PROFILING_CAT_GRAVITY) PROFILING_START() }
/////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Table_Tools // // // //-------------------------------------------------------// // // // separate_by_direction.h // // // // Copyright (C) 2008 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA 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. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__separate_by_direction_H #define HEADER_INCLUDED__separate_by_direction_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CSeparate_by_Direction : public CSG_Module { public: CSeparate_by_Direction(void); protected: virtual bool On_Execute (void); private: int m_nSectors; double m_Tolerance, m_dSector; }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__separate_by_direction_H
#ifndef DAYTIME_SYSCLOCK_H #define DAYTIME_SYSCLOCK_H #include "common.h" int UpdateSystemClock(struct timeval *Time); int UpdateCMOSClock(struct tm *NewTimetm); #endif
/* * This file is protected by Copyright. Please refer to the COPYRIGHT file * distributed with this source distribution. * * This file is part of GNUHAWK. * * GNUHAWK is free software: you can redistribute it and/or modify is 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. * * GNUHAWK 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 FILE_SOURCE_F_IMPL_H #define FILE_SOURCE_F_IMPL_H #include "file_source_f_base.h" class file_source_f_i : public file_source_f_base { public: file_source_f_i(const char *uuid, const char *label); ~file_source_f_i(); // // createBlock // // Create the actual GNU Radio Block to that will perform the work method. The resulting // block object is assigned to gr_stpr // // Add property change callbacks for getter/setter methods // // void createBlock(); // // createOutputSRI // // Called by setupIOMappings when an output mapping is defined. For each output mapping // defined, a call to createOutputSRI will be issued with the associated output index. // This default SRI and StreamID will be saved to the mapping and pushed down stream via pushSRI. // The subclass is responsible for overriding behavior of this method. The index provide matches // the stream index number that will be use by the GR Block object // // @param idx : output stream index number to associate the returned SRI object with // @return sri : default SRI object passed down stream over a RedHawk port // BULKIO::StreamSRI createOutputSRI( int32_t oidx, int32_t &in_idx ); void changedSeek(const std::string &id); bool getSeek(); }; #endif
//test return 18 /** * Tests macros in macro parameters */ #define FOO(a, b) ((a) * (b)) #define BAR(a, b) ((a) + (b)) #define BAZ 2 int __test() { return FOO(3, BAR(BAZ, 4)); }
/********************************************************************* * * Copyright (C) Guus Bonnema, 2015 * * This file is part of the xmas-design tool. * * The xmas-design tool 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 xmas-design tool 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 xmas-design tool. If not, see * <http://www.gnu.org/licenses/>. * **********************************************************************/ #ifndef COMMONINTERFACE_H #define COMMONINTERFACE_H #include <set> #include <map> #include <chrono> #include "xmas.h" #include "simplestring.h" #include "xmasproject.h" typedef std::chrono::high_resolution_clock::time_point tpoint; typedef std::set<XMASComponent *> XSet; typedef std::map<bitpowder::lib::String, XMASComponent *> XMap; typedef XMASProject XProject; typedef XMASNetwork XNetwork; #endif // COMMONINTERFACE_H
//------------------------------------------------------------------------------------------------- // <copyright file="regutil.h" company="Microsoft"> // Copyright (c) Microsoft Corporation. All rights reserved. // // The use and distribution terms for this software are covered by the // Common Public License 1.0 (http://opensource.org/licenses/cpl1.0.php) // which can be found in the file CPL.TXT at the root of this distribution. // By using this software in any fashion, you are agreeing to be bound by // the terms of this license. // // You must not remove this notice, or any other, from this software. // </copyright> // // <summary> // Registry helper functions. // </summary> //------------------------------------------------------------------------------------------------- #pragma once #ifdef __cplusplus extern "C" { #endif #define ReleaseRegKey(h) if (h) { ::RegCloseKey(h); h = NULL; } #ifdef __cplusplus } #endif
/* * strutils.h * * Copyright (c) 2015, Diego F. Asanza. All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301 USA * * Created on August 27, 2015, 8:37 PM */ #ifndef STRUTILS_H #define STRUTILS_H #ifdef __cplusplus extern "C" { #endif #define DTOSTR_ALWAYS_SIGN 0x01 /* put '+' or ' ' for positives */ #define DTOSTR_PLUS_SIGN 0x02 /* put '+' rather than ' ' */ #define DTOSTR_UPPERCASE 0x04 /* put 'E' rather 'e' */ void utils_dtostr(char* buffer, int digits, double value); double utils_strtod(char* buffer); void utils_dtofixstr(char* buff, int digits, int dplaces, double value); char * dtostre (double val, char *sbeg, unsigned char prec, unsigned char flags); #ifdef __cplusplus } #endif #endif /* STRUTILS_H */
/************************************************************************ ** ** Copyright (C) 2015 Kevin B. Hendricks, John Schember ** ** This file is part of Sigil. ** ** Sigil 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. ** ** Sigil 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 Sigil. If not, see <http://www.gnu.org/licenses/>. ** *************************************************************************/ #pragma once #ifndef EMBEDDEDPYTHON_H #define EMBEDDEDPYTHON_H #include <Python.h> #include <QCoreApplication> #include <QString> #include <QVariant> #include <QMutex> #include "Misc/PyObjectPtr.h" /** * Singleton. */ class EmbeddedPython { Q_DECLARE_TR_FUNCTIONS(EmbeddedPython) public: static EmbeddedPython* instance(); ~EmbeddedPython(); QString embeddedRoot(); bool addToPythonSysPath(const QString& modulepath); QVariant runInPython(const QString &module_name, const QString &function_name, const QVariantList &args, int *pRV, QString &error_traceback, bool ret_python_object = false); QVariant callPyObjMethod(PyObjectPtr &pyobj, const QString &methname, const QVariantList &args, int *rv, QString &tb, bool ret_python_object = false); private: EmbeddedPython(); QVariant PyObjectToQVariant(PyObject *po, bool ret_python_object = false); PyObject *QVariantToPyObject(const QVariant &v); QString getPythonErrorTraceback(const QString& default_error = "Error: traceback report is missing", bool useMsgBox = true); static QMutex m_mutex; static EmbeddedPython *m_instance; static int m_pyobjmetaid; static PyThreadState *m_threadstate; static int m_listintmetaid; }; #endif // EMBEDDEDPYTHON_H
/* To use the the relay in active-low mode */ #define F_CPU 16000000UL #include <avr/io.h> #include <avr/interrupt.h> volatile unsigned char value; /* When receive data over USART */ ISR(USART_RX_vect) { value = UDR0; if(value == 'F') { /* Relay Mode ON */ PORTB |= 0b00000001; } else if(value == 'O') { /* Relay Mode OFF */ PORTB &= 0b11111110; } } /* If you want to reply. */ void usartSendByte(unsigned char response) { while (!( UCSR0A & (1<<UDRE0) )) ; UDR0 = response; } int main() { /* USART - Character Size - 8, Stop Bit - 1, Baud Rate 9600, No Parity. */ /* RX Complete Interrupt Enable */ UCSR0B |= ( 1 << RXEN0) | ( 1 << TXEN0) | (1 << RXCIE0) ; UCSR0C |= ( 1 << UCSZ01 ) | ( 1 << UCSZ00 ) | ( 1 << USBS0) ; /* Baud Rate Setting for f_osc = 16MHz */ unsigned int ubrr = 103; UBRR0H = ( unsigned char ) ( ubrr>>8) ; UBRR0L = ( unsigned char ) ubrr ; /* Set Global Interrupt Enable. */ sei(); /* Configure PB0 (8 on Arduino) to be output. */ /* This is the signal to control the relay */ DDRB |= 0b00000001; PORTB |= 0b00000001; while(1) { /* System Loop */ } return 0; }
#ifndef INTERNALDATABASEMODEL_H #define INTERNALDATABASEMODEL_H #include <QObject> #include <QVariant> #include <QVariantList> #include "ilwiscoreui_global.h" class ILWISCOREUISHARED_EXPORT InternalDatabaseModel : public QObject { Q_OBJECT public: explicit InternalDatabaseModel(QObject *parent = 0); Q_INVOKABLE QVariantList query(const QString& query); signals: public slots: }; #endif // INTERNALDATABASEMODEL_H
#ifndef __NVBIOS_CSTEP_H__ #define __NVBIOS_CSTEP_H__ u16 nvbios_cstepTe(struct nvkm_bios *, u8 *ver, u8 *hdr, u8 *cnt, u8 *len, u8 *xnr, u8 *xsz); struct nvbios_cstepE { u8 pstate; u8 index; }; u16 nvbios_cstepEe(struct nvkm_bios *, int idx, u8 *ver, u8 *hdr); u16 nvbios_cstepEp(struct nvkm_bios *, int idx, u8 *ver, u8 *hdr, struct nvbios_cstepE *); u16 nvbios_cstepEm(struct nvkm_bios *, u8 pstate, u8 *ver, u8 *hdr, struct nvbios_cstepE *); struct nvbios_cstepX { u32 freq; u8 unkn[2]; u8 voltage; }; u16 nvbios_cstepXe(struct nvkm_bios *, int idx, u8 *ver, u8 *hdr); u16 nvbios_cstepXp(struct nvkm_bios *, int idx, u8 *ver, u8 *hdr, struct nvbios_cstepX *); #endif
/* * (C) 2015, Aurel Wildfellner * * This file is part of CraftUI. * * Beholder 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. * * Beholder 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 CraftUI. If not, see <http://www.gnu.org/licenses/>. */ #ifndef __CRAFTUI_MATHUTILS_H__ #define __CRAFTUI_MATHUTILS_H__ #include <iostream> #include <string> #include <memory> #include <pcl/common/common_headers.h> #include <opencv2/core/core.hpp> Eigen::Vector4f planeCoefficientsToParameters(const pcl::ModelCoefficients& coef); #endif
/** ****************************************************************************** * File Name : ETH.h * Description : This file provides code for the configuration * of the ETH instances. ****************************************************************************** * * COPYRIGHT(c) 2016 STMicroelectronics * * 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 __eth_H #define __eth_H #ifdef __cplusplus extern "C" { #endif /* Includes ------------------------------------------------------------------*/ #include "stm32f7xx_hal.h" /* USER CODE BEGIN Includes */ /* USER CODE END Includes */ extern ETH_HandleTypeDef heth; /* USER CODE BEGIN Private defines */ /* USER CODE END Private defines */ void MX_ETH_Init(void); /* USER CODE BEGIN Prototypes */ /* USER CODE END Prototypes */ #ifdef __cplusplus } #endif #endif /*__ eth_H */ /** * @} */ /** * @} */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
/* This source file is part of Rigs of Rods Copyright 2005-2012 Pierre-Michel Ricordel Copyright 2007-2012 Thomas Fischer For more information, see http://www.rigsofrods.com/ Rigs of Rods is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License version 3, as published by the Free Software Foundation. Rigs of Rods 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 Rigs of Rods. If not, see <http://www.gnu.org/licenses/>. */ // created: 26th of March 201, thomas fischer thomas{AT}thomasfischer{DOT}biz #ifdef USE_MUMBLE #ifndef MUMBLEINTEGRATION #define MUMBLEINTEGRATION #include "RoRPrerequisites.h" #include "Singleton.h" #include <windows.h> class MumbleIntegration : public RoRSingleton<MumbleIntegration> { public: MumbleIntegration(); void update(Ogre::Vector3 cameraPos, Ogre::Vector3 avatarPos); protected: ~MumbleIntegration(); void initMumble(); struct LinkedMem { #ifdef WIN32 UINT32 uiVersion; DWORD uiTick; #else uint32_t uiVersion; uint32_t uiTick; #endif float fAvatarPosition[3]; float fAvatarFront[3]; float fAvatarTop[3]; wchar_t name[256]; float fCameraPosition[3]; float fCameraFront[3]; float fCameraTop[3]; wchar_t identity[256]; #ifdef WIN32 UINT32 context_len; #else uint32_t context_len; #endif unsigned char context[256]; wchar_t description[2048]; }; LinkedMem *lm; }; #endif //MUMBLEINTEGRATION #endif //USE_MUMBLE
#include "builtin_service.h" void builtin_service_manager_init(); service_method_t* builtin_service_manager_get_method(const char* service_class, const char* method_name); bool builtin_service_manager_is_class_exists(const char* service_class); builtin_service_t* builtin_service_manager_get_class(const char* service_class); void builtin_service_manager_for_each_class(void (*visitor)(builtin_service_t*, void*), void* arg); void builtin_service_manager_for_each_method(const char* service_class, void (*visitor)(service_method_t*, void*), void* arg);
// 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/>. #ifndef LAN_DISCOVERY_CFG_H_INCLUDED #define LAN_DISCOVERY_CFG_H_INCLUDED #include "s25util/LANDiscovery.h" extern const LANDiscoveryBase::Config LAN_DISCOVERY_CFG; #endif // !LAN_DISCOVERY_CFG_H_INCLUDED
#include <3ds.h> #include <stdio.h> #include "draw.h" #include "draw_font.h" #include "fonts.h" int main(int argc, char **argv) { gfxInitDefault(); u8* buffer; while (aptMainLoop()) { hidScanInput(); unsigned int key = hidKeysDown(); //ã‰æ–Ê buffer = gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL); SetClipping(0,0,400,240); SelectFrame(buffer); SetBrushColor(153, 214, 245); DrawRect(0,0,400,240); SetPenColor(0, 0, 0);//•¶ŽšF setFontId(F_MP_BITMAPFONTS);//ƒtƒHƒ“ƒgID•ύX(M+ BITMAP FONTS) drawFontS(0, 0, "M+ BITMAP FONTS/‚l{ƒrƒbƒgƒ}ƒbƒvƒtƒHƒ“ƒg"); setFontId(F_MISAKI);//ƒtƒHƒ“ƒgID•ύX(”üçƒtƒHƒ“ƒg) drawFontS(0, 20, "”üçƒtƒHƒ“ƒg"); setFontId(F_SINONOMEFONT);//ƒtƒHƒ“ƒgID•ύX(“Œ‰_ƒtƒHƒ“ƒg) drawFontS(0, 40, "“Œ‰_ƒtƒHƒ“ƒgƒtƒHƒ“ƒg"); setFontId(F_KAGURAZAKA16);//ƒtƒHƒ“ƒgID•ύX(KH_Šyâ16) drawFontS(0, 60, "_Šyâ16ƒtƒHƒ“ƒg"); setFontId(F_DOUGENZAKA12);//ƒtƒHƒ“ƒgID•ύX(KH“¹Œºâ12) drawFontS(0, 80, "“¹Œºâ12ƒtƒHƒ“ƒg"); setFontId(F_AKIHABARA16);//ƒtƒHƒ“ƒgID•ύX(KHH—tŒ´16) drawFontS(0, 100, "H—tŒ´16ƒtƒHƒ“ƒg"); setFontId(F_KAGURAZAKA16); drawFontS_Vert(300,0,"Ÿc‘‚«\n@ŒÃ’r‚â\n@@Š^”ò‚Ñ‚±‚Þ\n@@@…‚̉¹\n@@@@¼”ö”mÔ"); //‰º‰æ–Ê buffer = gfxGetFramebuffer(GFX_BOTTOM, GFX_LEFT, NULL, NULL); SetClipping(0,0,320,240); SelectFrame(buffer); SetBrushColor(235, 218, 211); DrawRect(0,0,320,240); SetPenColor(20, 20, 20);//•¶ŽšF setFontId(F_MP_BITMAPFONTS); drawFontS(0, 0, "Œá”y‚Í”L‚Å‚ ‚é@I am a Cat"); setFontId(F_MISAKI); drawFontS(0, 20, "Œá”y‚Í”L‚Å‚ ‚é@‚h@‚‚@‚@‚b‚‚”"); setFontId(F_SINONOMEFONT); drawFontS(0, 40, "Œá”y‚Í”L‚Å‚ ‚é@I am a Cat"); setFontId(F_KAGURAZAKA16); drawFontS(0, 60, "Œá”y‚Í”L‚Å‚ ‚é@I am a Cat"); setFontId(F_DOUGENZAKA12); drawFontS(0, 80, "Œá”y‚Í”L‚Å‚ ‚é@I am a Cat"); setFontId(F_AKIHABARA16); drawFontS(0, 100, "Œá”y‚Í”L‚Å‚ ‚é@I am a Cat"); if (key & KEY_START) break;//I—¹ gfxFlushBuffers(); gfxSwapBuffers(); gspWaitForVBlank(); }; gfxExit(); return 0; };
#include "global.h" void write_loaded_unit(int absolute_x, int absolute_y, interface_struct *p_inter_data, field_struct *p_field_data) { int x, y, l_x, l_y; int maxy = (*p_field_data).maxy; int maxx = (*p_field_data).maxx; int l_maxx = (*p_inter_data).lp_data.maxx; int l_maxy = (*p_inter_data).lp_data.maxy; if((*p_inter_data).lp_data.rotation == 0) { for (y = absolute_y, l_y = 0; y < maxy && l_y < l_maxy; y++, l_y++) for (x = absolute_x, l_x = 0; x < maxx && l_x < l_maxx; x++, l_x++) if((*p_inter_data).lp_data.loaded_pattern[l_y][l_x] == 1) { if((*p_field_data).current_field[y][x] == 0) lut_up(x, y, p_field_data); (*p_field_data).current_field[y][x] = 1; } } else if((*p_inter_data).lp_data.rotation == 1) { for(y = absolute_y, l_y = 0; y < maxy && l_y < (*p_inter_data).lp_data.maxx; ++y, ++l_y) { for(x = absolute_x, l_x = (*p_inter_data).lp_data.maxy -1; x < maxx && l_x >= 0; ++x, --l_x) { if((*p_inter_data).lp_data.loaded_pattern[l_x][l_y] == 1) { if((*p_field_data).current_field[y][x] == 0) lut_up(x, y, p_field_data); (*p_field_data).current_field[y][x] = 1; } } } } else if((*p_inter_data).lp_data.rotation == 2) { for(y = absolute_y, l_y = (*p_inter_data).lp_data.maxy - 1; y < maxy && l_y >= 0; ++y, --l_y) { for(x = absolute_x, l_x = (*p_inter_data).lp_data.maxx -1; x < maxx && l_x >= 0; ++x, --l_x) { if((*p_inter_data).lp_data.loaded_pattern[l_y][l_x] == 1) { if((*p_field_data).current_field[y][x] == 0) lut_up(x, y, p_field_data); (*p_field_data).current_field[y][x] = 1; } } } } else if((*p_inter_data).lp_data.rotation == 3) { for(y = absolute_y, l_y = (*p_inter_data).lp_data.maxx - 1; y < maxy && l_y >= 0; ++y, --l_y) { for(x = absolute_x, l_x = 0; x < maxx && l_x < (*p_inter_data).lp_data.maxy; ++x, ++l_x) { if((*p_inter_data).lp_data.loaded_pattern[l_x][l_y] == 1) { if((*p_field_data).current_field[y][x] == 0) lut_up(x, y, p_field_data); (*p_field_data).current_field[y][x] = 1; } } } } }
/** * Copyright (C) 2016 Martin Ubl <http://pivo.kennny.cz> * * This file is part of PIVO suite. * * PIVO 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. * * PIVO 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 PIVO. If not, see <http://www.gnu.org/licenses/>. **/ #ifndef PIVO_GENERAL_H #define PIVO_GENERAL_H #include <iostream> #include <stdint.h> #include <list> #include <map> #include <vector> #include <string> #include <set> #include <cstring> #include <limits.h> #ifdef _WIN32 #include <Windows.h> #define DLL_EXPORT_API __declspec(dllexport) #else #include <unistd.h> #include <dlfcn.h> #define DLL_EXPORT_API #endif #ifndef nmax #define nmax(a,b) (((a) > (b)) ? (a) : (b)) #endif #ifndef nmin #define nmin(a,b) (((a) < (b)) ? (a) : (b)) #endif #define UNDEFINED_STR "__undefined__" #define UNDEFINED_INT INT_MAX #endif
/* File: jagpjcswitch.h Project: jaguar-parser Author: Douwe Vos Date: May 13, 2017 e-mail: dmvos2000(at)yahoo.com Copyright (C) 2017 Douwe Vos. 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 TREE_JAGPJCSWITCH_H_ #define TREE_JAGPJCSWITCH_H_ #include "jagpjcexpression.h" #include "jagpjcstatement.h" #include <caterpillar.h> G_BEGIN_DECLS #define JAGP_TYPE_JCSWITCH (jagp_jcswitch_get_type()) #define JAGP_JCSWITCH(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), jagp_jcswitch_get_type(), JagPJCSwitch)) #define JAGP_JCSWITCH_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), JAGP_TYPE_JCSWITCH, JagPJCSwitchClass)) #define JAGP_IS_JCSWITCH(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), JAGP_TYPE_JCSWITCH)) #define JAGP_IS_JCSWITCH_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), JAGP_TYPE_JCSWITCH)) #define JAGP_JCSWITCH_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), JAGP_TYPE_JCSWITCH, JagPJCSwitchClass)) typedef struct _JagPJCSwitch JagPJCSwitch; typedef struct _JagPJCSwitchClass JagPJCSwitchClass; struct _JagPJCSwitch { JagPJCStatement parent; JagPJCExpression *selector; CatArrayWo /*<JagPJCCase>*/ *cases; }; struct _JagPJCSwitchClass { JagPJCStatementClass parent_class; }; GType jagp_jcswitch_get_type(); JagPJCSwitch *jagp_jcswitch_new(JagPJCExpression *selector, CatArrayWo /*<JagPJCCase>*/ *cases); G_END_DECLS #endif /* TREE_JAGPJCSWITCH_H_ */
/* * Copyright (C) 2013 Vadim Kochan <vadim4j@gmail.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef _UTILS_H_ #define _UTILS_H_ #define ARRAY_SIZE(array) (sizeof(array) / sizeof(array[0])) char *itoa(int val); char *str_clone(char *s); int str_is_empty(char *s); #endif /* _UTILS_H_ */
// Copyright 2014 eric schkufza // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #ifndef CPPUTIL_INCLUDE_COMMAND_LINE_ARG_GROUP_H #define CPPUTIL_INCLUDE_COMMAND_LINE_ARG_GROUP_H #include <string> #include <vector> namespace cpputil { class Arg; class ArgGroup { friend class ArgRegistry; friend class Args; public: const std::string& heading() const { return heading_; } typedef std::vector<Arg*>::const_iterator arg_iterator; arg_iterator arg_begin() const { return args_.begin(); } arg_iterator arg_end() const { return args_.end(); } private: ArgGroup(const std::string& heading) : heading_ {heading} { } std::string heading_; std::vector<Arg*> args_; }; } // namespace cpputil #endif
/* * Author: KK <thumbd03803@gmail.com> * * button.h * */ #ifndef BUTTON_H #define BUTTON_H #include <iostream> #include <cstdio> #include <string> #include <SDL.h> #include "global.h" #include "window.h" using namespace std; enum ButtonState { BUTTON_NORMAL = 0, BUTTON_HOVERED, BUTTON_PUSHED }; class Button { public: Button(); ~Button(); void Init( string buttonNormal, string buttonHovered, string buttonPushed, SDL_Rect* posAndSize ); void Render(); bool MouseHovered(int mousePosX, int mousePosY); void ChangeState(enum ButtonState buttonState); private: //Point out what button picture we should render SDL_Texture* m_CurrentButtonState; SDL_Texture* m_ButtonPicture[3]; SDL_Rect m_ButtonPos; void CleanUp(); }; #endif
#ifndef _CONTROLLER_H_ #define _CONTROLLER_H_ #include "servo.h" #define V_MAX 1000 // als define lösen!! #define sin_120 -0.5 #define cos_120 0.866028 void control_init(float t_i, float k_p, int delay); void control(struct MouseData *cur_delta_s); void omniwheelTransformation(struct Velocity * const velocity_mobot, float *rad0,float *rad1,float *rad2); void omniwheelTransformationReverse(float *v0,float *v1,float *v2,struct Velocity * const velocity_mobot); void omniwheelTransformationAlt(struct Velocity * const velocity, struct ServoSpeed * const servo_speed); void setSollV(struct Velocity *soll); void maxima_runterskalieren(struct Velocity *max); #endif
//==================================================================== // Copyright (c) 2015 Carsten Wulff Software, Norway // =================================================================== // Created : wulff at 2015-8-20 // =================================================================== // 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 CIC_CORE_TEXT #define CIC_CORE_TEXT #include <QObject> #include <QString> #include <QtCore> #include "rect.h" namespace cIcCore{ /*! Text is just a text */ class Text: public Rect { Q_OBJECT public: Text(); ~Text(); Text(QString name); //! Net name QString name(); void setName(QString name); virtual QJsonObject toJson(); virtual void fromJson(QJsonObject o); protected: QString name_; }; } Q_DECLARE_METATYPE(cIcCore::Text) #endif // Text
/* This file is part of lib_gif Copyright (C) 2015 Julien Thevenon ( julien_thevenon at yahoo.fr ) 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 GIF_LZW_ENCODER_H #define GIF_LZW_ENCODER_H #include "gif_lzw_base.h" #include <iostream> #include <map> namespace lib_gif { template<typename T> class gif_lzw_encoder: public gif_lzw_base<T> { public: inline gif_lzw_encoder(const unsigned int & p_minimum_code_size); inline bool encode(const T & p_value_to_code,unsigned int & p_coded_value,unsigned int & p_coded_value_size,unsigned int & p_current_code_size,bool & p_clean); inline void encode(unsigned int & p_coded_value); private: }; //---------------------------------------------------------------------------- template<typename T> gif_lzw_encoder<T>::gif_lzw_encoder(const unsigned int & p_minimum_code_size): gif_lzw_base<T>(p_minimum_code_size) { } //---------------------------------------------------------------------------- template<typename T> bool gif_lzw_encoder<T>::encode(const T & p_value_to_code,unsigned int & p_coded_value,unsigned int & p_coded_value_size,unsigned int & p_current_code_size, bool & p_clean) { bool l_result = false; gif_lzw_dictionnary_entry<T> l_new_entry(gif_lzw_base<T>::get_word()); l_new_entry = l_new_entry + p_value_to_code; if(gif_lzw_base<T>::get_dictionnary().contains(l_new_entry)) { gif_lzw_base<T>::set_word(l_new_entry); l_result = false; } else { unsigned int l_word_Code_size = p_current_code_size; p_coded_value_size = l_word_Code_size; gif_lzw_base<T>::get_dictionnary().add(l_new_entry,p_current_code_size); p_coded_value = gif_lzw_base<T>::get_dictionnary().get_code(gif_lzw_base<T>::get_word()); #ifdef DEBUG_GIF_LZW_ENCODER std::cout << "Proposed coded value " << p_coded_value << "\t" << p_current_code_size << "\t" << l_word_Code_size<< std::endl ; #endif //DEBUG_GIF_LZW_ENCODER gif_lzw_base<T>::set_word(p_value_to_code); l_result = true; } if(4097 == gif_lzw_base<T>::get_dictionnary().get_nb_entry()) { gif_lzw_base<T>::get_dictionnary().clear(); p_clean = true; } return l_result; } //---------------------------------------------------------------------------- template<typename T> void gif_lzw_encoder<T>::encode(unsigned int & p_coded_value) { p_coded_value = gif_lzw_base<T>::get_dictionnary().get_code(gif_lzw_base<T>::get_word()); } #if 0 lib_gif::gif_lzw_encoder<uint8_t> l_encoder(8); std::string l_text_to_encode = "TOBEORNOTTOBEORTOBEORNOT"; unsigned int l_current_code_size = 9; unsigned int l_coded_value; for(auto l_iter : l_text_to_encode) { if(l_encoder.encode(l_iter,l_coded_value,l_current_code_size)) { std::cout << "Coded value : " ; if(l_coded_value < 256) { std::cout << "'" << (uint8_t) l_coded_value << "'" ; } else { std::cout << l_coded_value ; } std::cout << " " << std::endl ; } } l_encoder.encode(l_coded_value); std::cout << "Coded value : " ; if(l_coded_value < 256) { std::cout << "'" << (uint8_t) l_coded_value << "'" ; } else { std::cout << l_coded_value ; } std::cout << std::endl ; #endif } #endif //EOF
/* Copyright 2010-2021 David "Alemarius Nexus" Lerch This file is part of electronicsdb. electronicsdb 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. electronicsdb 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 electronicsdb. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include "../../global.h" #include <QCheckBox> #include <QLabel> #include <QLineEdit> #include <QListWidget> #include <QPlainTextEdit> #include <QPushButton> #include <QWidget> #include "../../model/part/Part.h" #include "../../model/AbstractPartProperty.h" #include "../../model/PartCategory.h" #include "../../model/PartProperty.h" #include "PartLinkEditWidget.h" #include "PropertyComboBox.h" #include "PropertyDateTimeEdit.h" #include "PropertyFileWidget.h" #include "PropertyLineEdit.h" #include "PropertyTextEdit.h" namespace electronicsdb { class PropertyMultiValueWidget : public QWidget { Q_OBJECT public: PropertyMultiValueWidget(PartCategory* pcat, AbstractPartProperty* aprop, QWidget* parent = nullptr, QObject* keyEventFilter = nullptr); void display(const Part& part, QList<QVariant> rawVals); void setState(DisplayWidgetState state); void setFlags(flags_t flags); QList<QVariant> getValues(bool initialValueOnError = false) const; void focusValueWidget(); private: void applyState(); void updateLinkListItem(QListWidgetItem* item); private slots: void currentItemChanged(QListWidgetItem* newItem, QListWidgetItem* oldItem); void addRequested(); void removeRequested(); void boolFieldToggled(bool val); void valueFieldEdited(const QString&); void textEditEdited(); void linkWidgetChangedByUser(); void fileChanged(); void dateTimeEditedByUser(); signals: void changedByUser(); private: PartCategory* cat; AbstractPartProperty* aprop; DisplayWidgetState state; flags_t flags; Part currentPart; QListWidget* listWidget; QPushButton* listAddButton; QPushButton* listRemoveButton; QCheckBox* boolBox; PropertyTextEdit* textEdit; PropertyLineEdit* lineEdit; PartLinkEditWidget* linkWidget; PropertyComboBox* enumBox; PropertyFileWidget* fileWidget; PropertyDateTimeEdit* dateTimeEdit; }; }
#pragma once #include <vector> class Card; class Player; class SmithyCard { public: SmithyCard(); ~SmithyCard(); static int getPrice(Card *card, Player *owner, std::vector<Player*> *otherPlayers); static void playAction(Card *card, Player *owner, std::vector<Player*> &otherPlayers); };
/* * Copyright (C) 2014 by Volodymyr Kachurovskyi <Volodymyr.Kachurovskyi@gmail.com> * * This file is part of Skwarka. * * Skwarka 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. * * Skwarka 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 Skwarka. If not, see <http://www.gnu.org/licenses/>. */ #ifndef LTE_INTEGRATOR_H #define LTE_INTEGRATOR_H #include <Common/Common.h> #include <Common/MemoryPool.h> #include <Math/Geometry.h> #include "CoreCommon.h" #include "Spectrum.h" #include "Scene.h" #include "Sample.h" #include "Sampler.h" #include "Intersection.h" /** * An abstract class defining the contract for the Light Transport Equation (LTE) integrator implementations. * An LTE integrator is an algorithm for numerical evaluation of the light transport equation taking into account both the surface scattering and media scattering. */ class LTEIntegrator: public ReferenceCounted { public: /** * Computes radiance along the specified ray. * @param i_ray Ray for which the radiance is to be computed. The direction component of the ray should be normalized. * @param ip_sample Sample instance containing requested samples sequences. Can be NULL. * @param i_ts Thread specifics (memory pool, random number generator etc.). * @return Resulting radiance value. */ Spectrum_d Radiance(const RayDifferential &i_ray, const Sample *ip_sample, ThreadSpecifics i_ts) const; /** * Requests 1D and 2D samples sequences needed for the LTE integrator. * This method should be called before the Radiance() method is called. * * The method calls private virtual _RequestSamples() method for surface integration samples. */ void RequestSamples(intrusive_ptr<Sampler> ip_sampler); virtual ~LTEIntegrator(); protected: /** * Creates LTEIntegrator instance with the specified scene. * @param ip_scene Scene instance. Should not be NULL. */ LTEIntegrator(intrusive_ptr<const Scene> ip_scene); /** * The method for derived classes to compute radiance for the specularly reflected ray. * The method calls Radiance() method to compute the radiance which results in a recursive call. */ Spectrum_d _SpecularReflect(const RayDifferential &i_ray, const Intersection &i_intersection, const BSDF *ip_bsdf, const Sample *ip_sample, ThreadSpecifics i_ts) const; /** * The method for derived classes to compute radiance for the specularly transmitted ray. * The method calls Radiance() method to compute the radiance which results in a recursive call. */ Spectrum_d _SpecularTransmit(const RayDifferential &i_ray, const Intersection &i_intersection, const BSDF *ip_bsdf, const Sample *ip_sample, ThreadSpecifics i_ts) const; private: /** * Computes surface radiance along the specified ray. * The method will only be called when the ray does intersect some primitive in the scene. * This is a virtual private method that derived classes must implement. This method is called by non-virtual public Radiance() method (Template Method pattern). * @param i_ray Ray for which the radiance is to be computed. The direction component of the ray should be normalized. * @param i_intersection Intersection of the specified ray with the nearest primitive in the scene. * @param ip_sample Sample instance containing requested samples sequences. * Can be NULL, in this case this is up to the implementation how to generate sample values. * @param i_ts Thread specifics (memory pool, random number generator etc.). * @return Resulting radiance value. */ virtual Spectrum_d _SurfaceRadiance(const RayDifferential &i_ray, const Intersection &i_intersection, const Sample *ip_sample, ThreadSpecifics i_ts) const = 0; /** * Computes media radiance and transmittance for the specified ray. * This is a virtual private method that derived classes must implement. This method is called by non-virtual public Radiance() method (Template Method pattern). * @param i_ray Ray for which the radiance is to be computed. The direction component of the ray should be normalized. * @param ip_sample Sample instance containing requested samples sequences. * Can be NULL, in this case this is up to the implementation how to generate sample values. * @param o_transmittance Resulting transmittance value. All spectrum components will be in [0;1] range. * @param i_ts Thread specifics (memory pool, random number generator etc.). * @return Resulting radiance value. */ virtual Spectrum_d _MediaRadianceAndTranmsittance(const RayDifferential &i_ray, const Sample *ip_sample, SpectrumCoef_d &o_transmittance, ThreadSpecifics i_ts) const = 0; /** * Requests 1D and 2D samples sequences needed for the surface part of the LTE integration. * This is a virtual private method that derived classes can implement. This method is called by non-virtual public RequestSamples() method (NVI pattern). * Default implementation does nothing. */ virtual void _RequestSamples(intrusive_ptr<Sampler> ip_sampler); private: // Not implemented, not a value type. LTEIntegrator(const LTEIntegrator&); LTEIntegrator &operator=(const LTEIntegrator&); private: intrusive_ptr<const Scene> mp_scene; }; #endif // LTE_INTEGRATOR_H
/*************************************************************************** * The FreeMedForms project is a set of free, open source medical * * applications. * * (C) 2008-2016 by Eric MAEKER, MD (France) <eric.maeker@gmail.com> * * All rights reserved. * * * * The FreeAccount plugins are free, open source FreeMedForms' plugins. * * (C) 2010-2011 by Pierre-Marie Desombre, MD <pm.desombre@medsyn.fr> * * and Eric Maeker, MD <eric.maeker@gmail.com> * * 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 (COPYING.FREEMEDFORMS file). * * If not, see <http://www.gnu.org/licenses/>. * ***************************************************************************/ /*************************************************************************** * Main Developers: Pierre-Marie DESOMBRE <pm.desombre@medsyn.fr>, * * Eric MAEKER, <eric.maeker@gmail.com> * * Contributors: * * NAME <MAIL@ADDRESS.COM> * ***************************************************************************/ #ifndef LEDGEREDIT_H #define LEDGEREDIT_H #include "mythread.h" #include <QWidget> namespace Ui{ class LedgerEditWidget; } class LedgerEdit : public QWidget { Q_OBJECT public : LedgerEdit(QWidget * parent); ~LedgerEdit(); void resizeLedgerEdit(QWidget * parent); private slots : void showLedger(); void printLedger(); void chosenDate(const QString & dateText); void fillInfoLabel(const QString & textFromThread); void inThread(); void getDocument(); void slotDeleteThread(); signals : void deleteThread(); private : Ui::LedgerEditWidget * ui; ProduceDoc *m_myThread; QTextDocument *m_doc; int m_typeOfPaper; bool m_duplicata; QDate m_date; void changeEvent(QEvent * e); }; #endif
#ifndef _LIBSVM_H #define _LIBSVM_H #ifdef __cplusplus extern "C" { #endif struct svm_node { int index; double value; }; struct svm_problem { int l; double *y; struct svm_node **x; }; enum { C_SVC, NU_SVC, ONE_CLASS, EPSILON_SVR, NU_SVR }; /* svm_type */ enum { LINEAR, POLY, RBF, SIGMOID, MATRIX }; /* kernel_type */ struct svm_parameter { int svm_type; int kernel_type; double degree; /* for poly */ double gamma; /* for poly/rbf/sigmoid */ double coef0; /* for poly/sigmoid */ /* these are for training only */ double cache_size; /* in MB */ double eps; /* stopping criteria */ double C; /* for C_SVC, EPSILON_SVR and NU_SVR */ int nr_weight; /* for C_SVC */ int *weight_label; /* for C_SVC */ double* weight; /* for C_SVC */ double nu; /* for NU_SVC, ONE_CLASS, and NU_SVR */ double p; /* for EPSILON_SVR */ int shrinking; /* use the shrinking heuristics */ }; struct svm_model *svm_train(const struct svm_problem *prob, const struct svm_parameter *param); int svm_save_model(const char *model_file_name, const struct svm_model *model); void svm_copy_model(double *ALPHAY,double *SVs,double *BIAS,double *NSV,double *NLABEL, struct svm_model *model); int get_svm_model_l(struct svm_model* model); int get_svm_model_nrclass(struct svm_model* model); void svm_copy_model(double ALPHAY[],double SVs[],double BIAS[],double NSV[],double NLABEL[],struct svm_model* model); struct svm_model *svm_read_model(double ALPHAY[],double SVs[],double BIAS[],double NSV[],double NLABEL[], double params[], int n, int l); struct svm_model *svm_load_model(const char *model_file_name); double svm_predict(const struct svm_model *model, const struct svm_node *x); void svm_destroy_model(struct svm_model *model); const char *svm_check_parameter(const struct svm_problem *prob, const struct svm_parameter *param); int kernel_type_matrix(struct svm_model *model); #ifdef __cplusplus } #endif #endif /* _LIBSVM_H */
//========================================================================== // // include/netinet6/esp_twofish.h // //========================================================================== //####BSDCOPYRIGHTBEGIN#### // // ------------------------------------------- // // Portions of this software may have been derived from OpenBSD, // FreeBSD or other sources, and are covered by the appropriate // copyright disclaimers included herein. // // Portions created by Red Hat are // Copyright (C) 2002 Red Hat, Inc. All Rights Reserved. // // ------------------------------------------- // //####BSDCOPYRIGHTEND#### //========================================================================== /* $KAME: esp_twofish.h,v 1.1 2000/09/20 18:15:23 itojun Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * 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 the project 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 PROJECT 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 PROJECT 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. */ int esp_twofish_schedlen __P((const struct esp_algorithm *)); int esp_twofish_schedule __P((const struct esp_algorithm *, struct secasvar *)); int esp_twofish_blockdecrypt __P((const struct esp_algorithm *, struct secasvar *, u_int8_t *, u_int8_t *)); int esp_twofish_blockencrypt __P((const struct esp_algorithm *, struct secasvar *, u_int8_t *, u_int8_t *));
/* HCSR0X.h - Library for sensor HCSR0X */ #ifndef HCSR0X_h #define HCSR0X_h #include <Arduino.h> #include "_macro.h" class HCSR0X { public: HCSR0X(uint8_t Trigger,uint8_t Echo, int max_range_in_cm = DEFAULT_RANGE); /*! @method @abstract Sets all the pins of the device. @discussion This method sets all the pins of the device Trigger and Echo. @param Trigger[in] device pin to send pulses. Range (0..12). @param Echo[out] to set the pin of answer device (0..12). @param Time_out max waiting time in milliseconds. */ float ping(int type = CM); /*! @method @abstract Starts calculating a distance. @discussion This method use this Formula: delay in uS / 58 = centimeters. @param type[integer] centimeters or inch CM/INC @result distance in centimeters or inch */ private: long _Time_out; volatile uint8_t * _TriggerRegister; volatile uint8_t * _EchoRegister; uint8_t _TriggerBit; uint8_t _EchoBit; long _break_time; }; #endif
/* * Auto generated Run-Time-Environment Component Configuration File * *** Do not modify ! *** * * Project: 'ble_app_hrs_freertos_s130_pca10028' * Target: 'nrf51422_xxac_s130' */ #ifndef RTE_COMPONENTS_H #define RTE_COMPONENTS_H #endif /* RTE_COMPONENTS_H */
////////////////////////////////////////////////////////////////////////// // Copyright 2012 Peter Atechian (Retep998) // ////////////////////////////////////////////////////////////////////////// // This file is part of NoLifeStory. // // // // NoLifeStory 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. // // // // NoLifeStory 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 NoLifeStory. If not, see <http://www.gnu.org/licenses/>. // ////////////////////////////////////////////////////////////////////////// namespace NLS { class MapFile { public: void Open(string filename); void Map(uint32_t base, uint32_t len); MapFile() : off(0), data(0), delta(0), d(0) {} MapFile(const MapFile& other) : off(0), data(0), delta(0), d(other.d) {} void operator=(const MapFile& other); void Unmap(); uint32_t Tell(); void Seek(uint32_t); void Skip(uint32_t); template <class T> T Read() { return *(T*)ReadBin(sizeof(T)); } int32_t ReadCInt(); char* ReadEncString(); char* ReadString(); char* ReadString(int32_t len); char* ReadTypeString(); wchar_t* ReadWString(int32_t len); uint32_t ReadOffset(uint32_t fileStart); void* ReadBin(uint32_t size); private: struct Data; Data* d; uint32_t off; char* data; uint32_t delta; }; char* to_cstring(int); char* AllocString(size_t len); }
/* 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[3]; atomic_int atom_1_r1_1; atomic_int atom_1_r6_2; void *t0(void *arg){ label_1:; atomic_store_explicit(&vars[0], 2, memory_order_seq_cst); atomic_store_explicit(&vars[1], 1, memory_order_seq_cst); return NULL; } void *t1(void *arg){ label_2:; int v2_r1 = atomic_load_explicit(&vars[1], memory_order_seq_cst); int v3_cmpeq = (v2_r1 == v2_r1); if (v3_cmpeq) goto lbl_LC00; else goto lbl_LC00; lbl_LC00:; atomic_store_explicit(&vars[2], 1, memory_order_seq_cst); atomic_store_explicit(&vars[2], 2, memory_order_seq_cst); int v5_r6 = atomic_load_explicit(&vars[2], memory_order_seq_cst); int v6_cmpeq = (v5_r6 == v5_r6); if (v6_cmpeq) goto lbl_LC01; else goto lbl_LC01; lbl_LC01:; atomic_store_explicit(&vars[0], 1, memory_order_seq_cst); int v13 = (v2_r1 == 1); atomic_store_explicit(&atom_1_r1_1, v13, memory_order_seq_cst); int v14 = (v5_r6 == 2); atomic_store_explicit(&atom_1_r6_2, v14, memory_order_seq_cst); return NULL; } int main(int argc, char *argv[]){ pthread_t thr0; pthread_t thr1; atomic_init(&vars[2], 0); atomic_init(&vars[0], 0); atomic_init(&vars[1], 0); atomic_init(&atom_1_r1_1, 0); atomic_init(&atom_1_r6_2, 0); pthread_create(&thr0, NULL, t0, NULL); pthread_create(&thr1, NULL, t1, NULL); pthread_join(thr0, NULL); pthread_join(thr1, NULL); int v7 = atomic_load_explicit(&vars[0], memory_order_seq_cst); int v8 = (v7 == 2); int v9 = atomic_load_explicit(&atom_1_r1_1, memory_order_seq_cst); int v10 = atomic_load_explicit(&atom_1_r6_2, memory_order_seq_cst); int v11_conj = v9 & v10; int v12_conj = v8 & v11_conj; if (v12_conj == 1) assert(0); return 0; }
#include <gtk/gtk.h> int main(int argc, char *argv[]) { GtkWidget *window; GtkWidget *toggle; GtkWidget *label; GtkWidget *box; gtk_init(&argc, &argv); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); toggle = gtk_toggle_button_new(); label = gtk_label_new("TOGGLE"); box = gtk_vbox_new(TRUE, 5); gtk_container_add((GtkContainer *)toggle, label); gtk_box_pack_start((GtkBox *)box, toggle, TRUE, TRUE, 3); gtk_container_add((GtkContainer *)window, box); gtk_widget_show_all(window); gtk_main(); return 0; }
#ifndef COMPUTEHASH_H #define COMPUTEHASH_H #include <QObject> #include "CheckFile_global.h" #include "util/util.h" class Factory; class CheckFilePrivate; class CHECKFILESHARED_EXPORT CheckFile : public QObject { Q_OBJECT public: explicit CheckFile(QObject *parent = 0); ~CheckFile(); void setCheckType(int CheckType); bool setFilePath(QString filePath); void setUserFactore(Factory *userFacrory); bool getOperatingStatus(); signals: void signalFinalResult(util::ComputeResult result); void signalError(QString errStr); void signalCalculationComplete(); public slots: void onStart(); void onStopCheck(); void onRestore(); private: CheckFilePrivate *d_ptr; Q_DECLARE_PRIVATE(CheckFile) }; #endif // COMPUTEHASH_H
//API for the Qsys DMA Controller #include "fpga_dmac_api.h" //-----------------Generic functions--------------------// //(Addresses are multiplied by 4 because the peripheral has 32-bit (4byte) regs uint32_t fpga_dma_read_reg(void* addr, uint32_t reg) { return *((uint32_t*) (addr + 4*reg)); } void fpga_dma_write_reg(void* addr, uint32_t reg, uint32_t val) { *((uint32_t*) (addr + 4*reg)) = val; } uint32_t fpga_dma_read_bit(void* addr, uint32_t reg, uint32_t bit) { return (bit & fpga_dma_read_reg(addr, reg)); } void fpga_dma_write_bit(void* addr, uint32_t reg, uint32_t bit, uint32_t val) { uint32_t old = fpga_dma_read_reg(addr, reg); if(val == 0) { fpga_dma_write_reg(addr, reg, (old & (~bit))); } else if(val == 1) { fpga_dma_write_reg(addr, reg, (old | bit)); } return; } //------------Some specific functions-------------------// void fpga_dma_init(void* addr, uint32_t control_reg_val) { fpga_dma_write_reg( addr, FPGA_DMA_CONTROL, control_reg_val); } void fpga_dma_config_transfer(void* addr, void* src, void* dst, unsigned int size) { fpga_dma_write_bit( addr,//clean go bit FPGA_DMA_CONTROL, FPGA_DMA_GO, 0); fpga_dma_write_bit( addr, //clean the done bit FPGA_DMA_STATUS, FPGA_DMA_DONE, 0); fpga_dma_write_reg( addr, //set source address FPGA_DMA_READADDRESS, (uint32_t) src); fpga_dma_write_reg( addr, //set destiny address FPGA_DMA_WRITEADDRESS, (uint32_t) dst); fpga_dma_write_reg( addr, //set transfer size FPGA_DMA_LENGTH, (uint32_t) size); //Wait a small time. Needed for the read from HPS to work. int counter=0; for(int j=0; j<10; j++) counter++; } void fpga_dma_start_transfer(void* addr) { fpga_dma_write_bit( addr, FPGA_DMA_CONTROL, FPGA_DMA_GO, 1);//start transfer } //this function returns a 1 if the DMA transfer is finished, 0 otherwise uint32_t fpga_dma_transfer_done(void* addr) { return fpga_dma_read_bit(addr, FPGA_DMA_STATUS, FPGA_DMA_DONE); } //alligned allocation to the transfer size is needed for reading HPS from FPGA void* align_malloc (size_t size, void** unaligned_addr) { char* Buffer_8 = (char*) malloc(size*2); *unaligned_addr = (void*) Buffer_8; uint8_t* Buffer_8_ptr; Buffer_8_ptr = (uint8_t*)Buffer_8; for(int k=0; k<(size); k++) { if ((((unsigned long int)Buffer_8_ptr) % ((unsigned long int)size))==0) { return (void*)Buffer_8_ptr; } else { Buffer_8_ptr++; } } return 0; }
/* -*- buffer-read-only: t -*- vi: set ro: */ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ #line 1 /* Copyright (C) 1991,92,93,94,96,97,98,2000,2004,2007,2008 Free Software Foundation, Inc. This file is part of the GNU C Library. 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, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /* This particular implementation was written by Eric Blake, 2008. */ #ifndef _LIBC # include <config.h> #endif /* Specification of strstr. */ #include <string.h> #include <stdbool.h> #ifndef _LIBC # define __builtin_expect(expr, val) (expr) #endif #define RETURN_TYPE char * #define AVAILABLE(h, h_l, j, n_l) \ (!memchr ((h) + (h_l), '\0', (j) + (n_l) - (h_l)) \ && ((h_l) = (j) + (n_l))) #include "str-two-way.h" /* Return the first occurrence of NEEDLE in HAYSTACK. Return HAYSTACK if NEEDLE is empty, otherwise NULL if NEEDLE is not found in HAYSTACK. */ char * strstr (const char *haystack_start, const char *needle_start) { const char *haystack = haystack_start; const char *needle = needle_start; size_t needle_len; /* Length of NEEDLE. */ size_t haystack_len; /* Known minimum length of HAYSTACK. */ bool ok = true; /* True if NEEDLE is prefix of HAYSTACK. */ /* Determine length of NEEDLE, and in the process, make sure HAYSTACK is at least as long (no point processing all of a long NEEDLE if HAYSTACK is too short). */ while (*haystack && *needle) ok &= *haystack++ == *needle++; if (*needle) return NULL; if (ok) return (char *) haystack_start; /* Reduce the size of haystack using strchr, since it has a smaller linear coefficient than the Two-Way algorithm. */ needle_len = needle - needle_start; haystack = strchr (haystack_start + 1, *needle_start); if (!haystack || __builtin_expect (needle_len == 1, 0)) return (char *) haystack; needle -= needle_len; haystack_len = (haystack > haystack_start + needle_len ? 1 : needle_len + haystack_start - haystack); /* Perform the search. Abstract memory is considered to be an array of 'unsigned char' values, not an array of 'char' values. See ISO C 99 section 6.2.6.1. */ if (needle_len < LONG_NEEDLE_THRESHOLD) return two_way_short_needle ((const unsigned char *) haystack, haystack_len, (const unsigned char *) needle, needle_len); return two_way_long_needle ((const unsigned char *) haystack, haystack_len, (const unsigned char *) needle, needle_len); } #undef LONG_NEEDLE_THRESHOLD
/* * * A simple C program which taunts the user * */ #include <stdio.h> int main(void) { char message[] = "UCSC Contest Problem Two is too hard for you, give up!"; printf("%s\n", message); return 0; }