text
stringlengths
4
6.14k
/* * Copyright 2010-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. * A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file 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. */ #pragma once #include <aws/signer/Signer_EXPORTS.h> #include <aws/core/utils/memory/stl/AWSString.h> #include <utility> namespace Aws { namespace Utils { namespace Json { class JsonValue; class JsonView; } // namespace Json } // namespace Utils namespace signer { namespace Model { /** * <p>The ACM certificate that is used to sign your code.</p><p><h3>See Also:</h3> * <a * href="http://docs.aws.amazon.com/goto/WebAPI/signer-2017-08-25/SigningMaterial">AWS * API Reference</a></p> */ class AWS_SIGNER_API SigningMaterial { public: SigningMaterial(); SigningMaterial(Aws::Utils::Json::JsonView jsonValue); SigningMaterial& operator=(Aws::Utils::Json::JsonView jsonValue); Aws::Utils::Json::JsonValue Jsonize() const; /** * <p>The Amazon Resource Name (ARN) of the certificates that is used to sign your * code.</p> */ inline const Aws::String& GetCertificateArn() const{ return m_certificateArn; } /** * <p>The Amazon Resource Name (ARN) of the certificates that is used to sign your * code.</p> */ inline void SetCertificateArn(const Aws::String& value) { m_certificateArnHasBeenSet = true; m_certificateArn = value; } /** * <p>The Amazon Resource Name (ARN) of the certificates that is used to sign your * code.</p> */ inline void SetCertificateArn(Aws::String&& value) { m_certificateArnHasBeenSet = true; m_certificateArn = std::move(value); } /** * <p>The Amazon Resource Name (ARN) of the certificates that is used to sign your * code.</p> */ inline void SetCertificateArn(const char* value) { m_certificateArnHasBeenSet = true; m_certificateArn.assign(value); } /** * <p>The Amazon Resource Name (ARN) of the certificates that is used to sign your * code.</p> */ inline SigningMaterial& WithCertificateArn(const Aws::String& value) { SetCertificateArn(value); return *this;} /** * <p>The Amazon Resource Name (ARN) of the certificates that is used to sign your * code.</p> */ inline SigningMaterial& WithCertificateArn(Aws::String&& value) { SetCertificateArn(std::move(value)); return *this;} /** * <p>The Amazon Resource Name (ARN) of the certificates that is used to sign your * code.</p> */ inline SigningMaterial& WithCertificateArn(const char* value) { SetCertificateArn(value); return *this;} private: Aws::String m_certificateArn; bool m_certificateArnHasBeenSet; }; } // namespace Model } // namespace signer } // namespace Aws
#ifndef JME_Random_h__ #define JME_Random_h__ /******************************************************************** created: 2015/06/19 author: huangzhi purpose: ¼òµ¥µÄËæ»úÊý·â×°£¬ ¶ÔËæ»úÖÖ×Ó½øÐмòµ¥´¦Àí warning: *********************************************************************/ #include <assert.h> #include <time.h> #include <random> #include <algorithm> #include <vector> #include "boost/random.hpp" #include <boost/date_time/posix_time/posix_time.hpp> #define Rnd Random::getInstance class RandSeed { public: friend class Random; RandSeed(){} RandSeed(int prob, void* bind): _prob(prob), _bind(bind), _begin(0), _end(0) { } public: int _prob; //¸ÅÂÊ void* _bind; //°ó¶¨µÄ¶ÔÏó protected: int _begin; int _end; }; class Random { public: public: Random(void){ _random_seed = time(NULL); }; virtual ~Random(void){}; int randomInt() { boost::posix_time::ptime time = boost::posix_time::microsec_clock::local_time(); boost::posix_time::time_duration duration( time.time_of_day() ); boost::mt19937 gen(duration.total_nanoseconds() + _random_seed); boost::uniform_int<> dist(0, INT_MAX); boost::variate_generator<boost::mt19937, boost::uniform_int<> > die(gen, dist); return _random_seed = die(); } int randomInt(int start, int end) { assert(start <= end); boost::posix_time::ptime time = boost::posix_time::microsec_clock::local_time(); boost::posix_time::time_duration duration( time.time_of_day() ); boost::mt19937 gen(duration.total_nanoseconds() + _random_seed); boost::uniform_int<> dist(start, end); boost::variate_generator<boost::mt19937, boost::uniform_int<> > die(gen, dist); return _random_seed = die(); } bool randomGreater(int perc) { int ra = randomInt(1, 100); return ra >= perc; } void* randomBySeeds(std::vector<RandSeed>& seeds) { assert(!seeds.empty()); for (size_t i = 0; i < seeds.size(); ++i) { if (0 == i) seeds[i]._begin = 1; else seeds[i]._begin = seeds[i - 1]._end; seeds[i]._end = seeds[i]._begin + seeds[i]._prob; } int rmax = seeds.rbegin()->_end; int ra = randomInt(1, rmax - 1); for (auto it = seeds.begin(); it != seeds.end(); ++it) { if (ra >= it->_begin && ra < it->_end) return it->_bind; } return nullptr; } private: time_t _random_seed; }; #endif // JME_Random_h__
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. /** * @version $Id$ * @author Haakon Humberset * @date 2005-09-23 * * @brief String tokenizer with a C++ approach. * * Uses vespalib::string and common C++ functions. Gives a simple interface * to a string tokenizer, not necessarily the most efficient one. * * @class vespalib::StringTokenizer */ #pragma once #include <vector> #include <vespa/vespalib/stllike/string.h> namespace vespalib { class StringTokenizer { public: typedef vespalib::stringref Token; typedef std::vector<Token> TokenList; typedef TokenList::const_iterator Iterator; /** * @brief Split source on separators with optional trim. * * Take the source string and split on each occurrence * of a character contained in seperators. * From the resulting tokens, remove leading and * trailing sequences of characters in the strip set. * As a special case, if the input contains only one * token and that token is empty (or empty after * removal of strip characters) the result is an empty * token list. * * @param source The input string to be tokenized * @param separators The characters to be used as token separators * @param strip Characters to be stripped from both ends of each token **/ StringTokenizer(vespalib::stringref source, vespalib::stringref separators = ",", vespalib::stringref strip = " \t\f\r\n"); /** Remove any empty tokens from the token list */ void removeEmptyTokens(); /** How many tokens is in the current token list? */ unsigned int size() const { return _tokens.size(); } /** Access a token from the current token list */ const Token & operator[](unsigned int index) const { return _tokens[index]; } Iterator begin() const { return _tokens.begin(); } Iterator end() const { return _tokens.end(); } /** Access the entire token list */ const TokenList & getTokens() const { return _tokens; } private: TokenList _tokens; }; }
#ifndef INPUT_MENU_H #define INPUT_MENU_H #include <Mode.h> class InputsMenu : public Mode{ private: Button *backButton; Button *analogInput1Button; void Setup(); public: InputsMenu(); ~InputsMenu(); virtual void Draw(); virtual void Redraw(); virtual void Update(); }; #endif
/* * meego-handset-email - Meego Handset Email application * Copyright © 2010, Intel Corporation. * * This program is licensed under the terms and conditions of the * Apache License, version 2.0. The full text of the Apache License is at * http://www.apache.org/licenses/LICENSE-2.0 * */ #ifndef MESSAGELISTPAGE_H #define MESSAGELISTPAGE_H #include <MApplicationPage> #include <MList> #include <qmailfolder.h> #include <qmailmessage.h> #include "messageitemmodel.h" class MessageListPage : public MApplicationPage { Q_OBJECT public: MessageListPage(); MessageListPage(QMailFolderId folderId); virtual ~MessageListPage(); virtual void createContent(); signals: void showMessageBody(QMailMessageId); void composeMail(); void composeReply(QMailMessageId); void composeReplyAll(QMailMessageId); void composeForward(QMailMessageId); private slots: void composeActionTriggered(); void refreshActionTriggered(); void getMoreMessages(); void update(); void messageItemClicked(const QModelIndex &); void deleteMessages(const QMailMessageIdList &); void addMessages(const QMailMessageIdList &); private: void createActions(); private: QMailFolderId m_folderId; MessageItemModel *m_model; QModelIndex m_currentIndex; }; #endif // MESSAGELISTPAGE_H
/* * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved. */ #ifndef vnsw_agent_flow_stats_collector_h #define vnsw_agent_flow_stats_collector_h #include <sandesh/common/flow_types.h> #include <cmn/agent_cmn.h> #include <uve/stats_collector.h> #include <pkt/flow_table.h> #include <ksync/flowtable_ksync.h> //Defines the functionality to periodically read flow stats from //shared memory (between agent and Kernel) and export this stats info to //collector. Also responsible for aging of flow entries. Runs in the context //of "Agent::StatsCollector" which has exclusion with "db::DBTable", //"Agent::FlowHandler", "sandesh::RecvQueue", "bgp::Config" & "Agent::KSync" class FlowStatsCollector : public StatsCollector { public: static const uint64_t FlowAgeTime = 1000000 * 180; static const uint32_t FlowCountPerPass = 200; static const uint32_t FlowStatsMinInterval = (100); // time in milliseconds static const uint32_t MaxFlows= (256 * 1024); // time in milliseconds FlowStatsCollector(boost::asio::io_service &io, int intvl, uint32_t flow_cache_timeout, AgentUve *uve); virtual ~FlowStatsCollector(); uint64_t flow_age_time_intvl() { return flow_age_time_intvl_; } uint32_t flow_age_time_intvl_in_secs() { return flow_age_time_intvl_/(1000 * 1000); } void UpdateFlowMultiplier(); bool Run(); void UpdateFlowAgeTime(uint64_t usecs) { flow_age_time_intvl_ = usecs; UpdateFlowMultiplier(); } void UpdateFlowAgeTimeInSecs(uint32_t secs) { UpdateFlowAgeTime(secs * 1000 * 1000); } static void FlowExport(FlowEntry *flow, uint64_t diff_bytes, uint64_t diff_pkts); void UpdateFlowStats(FlowEntry *flow, uint64_t &diff_bytes, uint64_t &diff_pkts); void Shutdown(); private: uint64_t GetFlowStats(const uint16_t &oflow_data, const uint32_t &data); bool ShouldBeAged(FlowStats *stats, const vr_flow_entry *k_flow, uint64_t curr_time); static void SourceIpOverride(FlowEntry *flow, FlowDataIpv4 &s_flow); uint64_t GetUpdatedFlowPackets(const FlowStats *stats, uint64_t k_flow_pkts); uint64_t GetUpdatedFlowBytes(const FlowStats *stats, uint64_t k_flow_bytes); AgentUve *agent_uve_; FlowKey flow_iteration_key_; uint64_t flow_age_time_intvl_; uint32_t flow_count_per_pass_; uint32_t flow_multiplier_; uint32_t flow_default_interval_; DISALLOW_COPY_AND_ASSIGN(FlowStatsCollector); }; #endif //vnsw_agent_flow_stats_collector_h
/* * Generated by asn1c-0.9.29 (http://lionet.info/asn1c) * From ASN.1 module "PKIXqualified88" * found in "asn1/rfc3739-PKIXqualified88.asn1" * `asn1c -S asn1c/skeletons -pdu=all -pdu=Certificate -fwide-types` */ #ifndef _PredefinedBiometricType_H_ #define _PredefinedBiometricType_H_ #include <asn_application.h> /* Including external dependencies */ #include <NativeInteger.h> #ifdef __cplusplus extern "C" { #endif /* Dependencies */ typedef enum PredefinedBiometricType { PredefinedBiometricType_picture = 0, PredefinedBiometricType_handwritten_signature = 1 } e_PredefinedBiometricType; /* PredefinedBiometricType */ typedef long PredefinedBiometricType_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_PredefinedBiometricType; asn_struct_free_f PredefinedBiometricType_free; asn_struct_print_f PredefinedBiometricType_print; asn_constr_check_f PredefinedBiometricType_constraint; ber_type_decoder_f PredefinedBiometricType_decode_ber; der_type_encoder_f PredefinedBiometricType_encode_der; xer_type_decoder_f PredefinedBiometricType_decode_xer; xer_type_encoder_f PredefinedBiometricType_encode_xer; #ifdef __cplusplus } #endif #endif /* _PredefinedBiometricType_H_ */ #include <asn_internal.h>
/* * Copyright 2016 Hewlett Packard Enterprise Development LP * * 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 INTERFACE_INTERFACE_H_ #define INTERFACE_INTERFACE_H_ #include <json/json.h> #include <prim/prim.h> #include <string> #include <tuple> #include <vector> #include "architecture/PortedDevice.h" #include "event/Component.h" #include "types/CreditReceiver.h" #include "types/CreditSender.h" #include "types/FlitReceiver.h" #include "types/FlitSender.h" #include "types/Message.h" #include "types/MessageReceiver.h" #include "network/Channel.h" class PacketReassembler; class MessageReassembler; class Interface : public Component, public PortedDevice, public FlitSender, public FlitReceiver, public CreditSender, public CreditReceiver, public MessageReceiver { public: Interface(const std::string& _name, const Component* _parent, u32 _id, const std::vector<u32>& _address, u32 _numVcs, const std::vector<std::tuple<u32, u32> >& _trafficClassVcs, Json::Value _settings); virtual ~Interface(); void setMessageReceiver(MessageReceiver* _receiver); MessageReceiver* messageReceiver() const; protected: const std::vector<std::tuple<u32, u32> > trafficClassVcs_; private: MessageReceiver* messageReceiver_; std::vector<PacketReassembler*> packetReassemblers_; MessageReassembler* messageReassembler_; }; #endif // INTERFACE_INTERFACE_H_
// // ViewController.h // HelloDjinni // // Created by John on 16/5/7. // Copyright © 2016年 joinAero. All rights reserved. // #import <UIKit/UIKit.h> @interface ViewController : UIViewController @end
/* mmap_file.h -*- C++ -*- Jeremy Barnes, 16 December 2011 Copyright (c) 2011 Datacratic. All rights reserved. Overall file used at the root of an actual mmap file use case. */ #ifndef __mmap__mmap_file_h__ #define __mmap__mmap_file_h__ #include "mmap_const.h" #include "memory_allocator.h" #include <memory> namespace Datacratic { namespace MMap { struct PageTableAllocator; struct MemoryRegion; struct Trie; /*****************************************************************************/ /* COW REGION */ /*****************************************************************************/ /** A copy-on-write region within a memory mapped file. There is one of these for each independent data structure within the file. */ struct COWRegion { uint64_t version; ///< uint64_t magic; GcLock::Data gcData; ///< GC data for structure for CS detection struct { uint64_t type; ///< Type of structure at root uint64_t root; ///< Root of structure; opaque (depends on type) } JML_ALIGNED(16); char name[16]; ///< Symbolic name of structure } JML_ALIGNED(64); /*****************************************************************************/ /* THREAD REGION */ /*****************************************************************************/ /** A block of data for each thread that is active within the region. Allows each thread to see what the others are up to and for a stuck or crashed thread to have its operations backed out. */ struct ThreadRegion { }; /*****************************************************************************/ /* FILE METADATA */ /*****************************************************************************/ /** Metadata for a memory mapped file. This is what is mapped into the first page of a MMapFile. */ struct FileMetadata { COWRegion regions[32]; ///< Max of 32 data structures available }; /*****************************************************************************/ /* MMAP FILE */ /*****************************************************************************/ /** A memory allocator class that ties together a shared anonymous memory region, a page table allocator, and a memory allocator into a single class. The memory region can be shared amongst multiple processes, but cannot be accessed from outside processes. */ struct MMapFileBase { MMapFileBase(ResCreateOpen, const std::string & mapFile, Permissions perm, size_t initialAlloc); MMapFileBase(ResCreate, const std::string & mapFile, Permissions perm, size_t initialAlloc); MMapFileBase(ResOpen, const std::string & mapFile, Permissions perm); /** Permanently deletes all the resources associated with this mmap file */ void unlink(); /** Create a snapshot at the current point in time. This guarantees that, once the function returns, the backing file will be completely consistent and that any writes made by this process will be visible to other processes in a consistent manner. */ uint64_t snapshot(); /** The size of the datastore in bytes. */ size_t fileSize() { return mmapRegion_->length(); } protected: std::shared_ptr<MemoryRegion> mmapRegion_; bool createdMmap; // ugly hack for ResCreateOpen private: static MemoryRegion * getRegion( const std::string & mapFile, Permissions perm, size_t size); static MemoryRegion * getRegion( const std::string & mapFile, Permissions perm); }; /** Memory allocator that has an internal page table allocator. */ struct MMapFile : public MMapFileBase, public MemoryAllocator { MMapFile(ResCreateOpen, const std::string & mapFile = "PRIVATE", Permissions perm = PERM_READ_WRITE, size_t initialToAlloc = page_size * 64); MMapFile(ResCreate, const std::string & mapFile = "PRIVATE", Permissions perm = PERM_READ_WRITE, size_t initialToAlloc = page_size * 64); MMapFile(ResOpen, const std::string & mapFile = "PRIVATE", Permissions perm = PERM_READ_WRITE); /** Permanently deletes any ressources associated with file. */ void unlink(); }; /*****************************************************************************/ /* UTILITIES */ /*****************************************************************************/ /** Applies the journal and delete any auxiliary files associated with a given mmap file. To delete the mmap file itself, use the unlink() method of MMapFile. It should be called after a crash, before opening an mmap file. IMPORTANT: Don't call this function if there's an active process using the mmap file. Doing so could lead to a corrupted mmap file that can only be recovered using hopes and dreams. */ void cleanupMMapFile(const std::string& mapFile); } // namespace MMap } // namespace Datacratic #endif /* __mmap__mmap_file_h__ */
#include <stdio.h> #ifndef convex #include <string.h> #endif /* * VAX VMS includes etc.. */ #ifdef VMS #include <descrip.h> #include <ssdef.h> typedef struct dsc$descriptor_s VMS_string; #define VMS_STRING(dsc, string) \ dsc.dsc$w_length = strlen(string); \ dsc.dsc$b_dtype = DSC$K_DTYPE_T; \ dsc.dsc$b_class = DSC$K_CLASS_S; \ dsc.dsc$a_pointer = string; #endif /* * Allow tkdriv to be calleable by FORTRAN using the two commonest * calling conventions. Both conventions append length arguments for * each FORTRAN string at the end of the argument list, and convert the * name to lower-case, but one post-pends an underscore to the function * name (PG_PPU) while the other doesn't. Note the VMS is handled * separately below. For other calling conventions you must write a * C wrapper routine to call rvdriv() or rvdriv_(). */ #ifdef PG_PPU #define RVDRIV rvdriv_ #else #define RVDRIV rvdriv #endif /*....................................................................... * This is a stub version of the Rivet-Tk PGPLOT widget device driver to * be included in the main PGPLOT library. The real driver resides in a * dedicated library, which when cited before libpgplot on the link line, * overrides this stub. The rational behind this is that if the real * driver were included in the PGPLOT library all applications that are * currently linked with PGPLOT would have to be changed to link with the * Tcl/Tk libraries. */ #ifdef VMS void rvdriv(ifunc, rbuf, nbuf, chrdsc, lchr) int *ifunc; float rbuf[]; int *nbuf; struct dsc$descriptor_s *chrdsc; /* VMS FORTRAN string descriptor */ int *lchr; { int len = chrdsc->dsc$w_length; char *chr = chrdsc->dsc$a_pointer; #else void RVDRIV(ifunc, rbuf, nbuf, chr, lchr, len) int *ifunc, *nbuf, *lchr; int len; float rbuf[]; char *chr; { #endif int i; /* * Branch on the specified PGPLOT opcode. */ switch(*ifunc) { /*--- IFUNC=1, Return device name ---------------------------------------*/ case 1: for(i=0; i < len; i++) chr[i] = ' '; *lchr = 0; break; default: fprintf(stderr, "/XRV: Unexpected opcode=%d in stub driver.\n", *ifunc); *nbuf = -1; break; }; return; }
#ifndef _TRAITS_H #define _TRAITS_H class IObject; template <typename T> class TypeChecker { public: static bool check(uchar type) { return true; } }; template <> class TypeChecker<int8_t> { public: static bool check(uchar type) { if(type == INT8) { return true; } return false; } }; template<> class TypeChecker<string> { public: static bool check(uchar type) { if(type == STRING) return true; else return false; } }; // how to check pointer type template<> class TypeChecker<IObject> { public: static bool check(uchar type) { if(type == OBJECT) return true; else return false; } }; //.. add other check_type here template<typename T> class PointerTraits { static const bool isPointer = false; }; template<typename T> class PointerTraits<T*> { static const bool isPointer = true; }; #endif
/** * Copyright 2012 Batis Degryll Ludo * @file CommonFactories.h * @since 2019-02-20 * @date 2019-02-20 * @author Ludo Degryll Batis * @brief Daemon capable of load all common factories. */ #ifndef ZBE_FACTORIES_COMMONFACTORIES_H_ #define ZBE_FACTORIES_COMMONFACTORIES_H_ #include <string> #include "ZBE/core/daemons/Daemon.h" #include "ZBE/core/system/system.h" namespace zbe { /** \brief Define the interface of a Factory. */ class ZBEAPI CommonFactories : public Daemon { public: ~CommonFactories() {} /** \brief It will Load the factories calling the load method. */ void run() { load(); }; /** \brief It loads all factories. */ static void load(); }; } // namespace zbe #endif // ZBE_FACTORIES_COMMONFACTORIES_H_
//===----------------------------------------------------------------------===// // // Peloton // // timestamp_ordering_transaction_manager.h // // Identification: // src/include/concurrency/timestamp_ordering_transaction_manager.h // // Copyright (c) 2015-16, Carnegie Mellon University Database Group // //===----------------------------------------------------------------------===// #pragma once #include "concurrency/transaction_manager.h" #include "storage/tile_group.h" #include "statistics/stats_aggregator.h" namespace peloton { namespace concurrency { //===--------------------------------------------------------------------===// // timestamp ordering //===--------------------------------------------------------------------===// class TimestampOrderingTransactionManager : public TransactionManager { public: TimestampOrderingTransactionManager() {} virtual ~TimestampOrderingTransactionManager() {} static TimestampOrderingTransactionManager &GetInstance( const ProtocolType protocol, const IsolationLevelType isolation, const ConflictAvoidanceType conflict); // This method tests whether the current transaction is the owner of this version. virtual bool IsOwner( TransactionContext *const current_txn, const storage::TileGroupHeader *const tile_group_header, const oid_t &tuple_id); // This method tests whether any other transaction has owned this version. virtual bool IsOwned( TransactionContext *const current_txn, const storage::TileGroupHeader *const tile_group_header, const oid_t &tuple_id); // This method tests whether the current transaction has created this version of the tuple virtual bool IsWritten( TransactionContext *const current_txn, const storage::TileGroupHeader *const tile_group_header, const oid_t &tuple_id); // This method tests whether it is possible to obtain the ownership. virtual bool IsOwnable( TransactionContext *const current_txn, const storage::TileGroupHeader *const tile_group_header, const oid_t &tuple_id); // This method is used to acquire the ownership of a tuple for a transaction. virtual bool AcquireOwnership( TransactionContext *const current_txn, const storage::TileGroupHeader *const tile_group_header, const oid_t &tuple_id); // This method is used by executor to yield ownership after the acquired // ownership. virtual void YieldOwnership( TransactionContext *const current_txn, const storage::TileGroupHeader *const tile_group_header, const oid_t &tuple_id); // The index_entry_ptr is the address of the head node of the version chain, // which is directly pointed by the primary index. virtual void PerformInsert(TransactionContext *const current_txn, const ItemPointer &location, ItemPointer *index_entry_ptr = nullptr); virtual bool PerformRead(TransactionContext *const current_txn, const ItemPointer &location, bool acquire_ownership = false); virtual void PerformUpdate(TransactionContext *const current_txn, const ItemPointer &old_location, const ItemPointer &new_location); virtual void PerformDelete(TransactionContext *const current_txn, const ItemPointer &old_location, const ItemPointer &new_location); virtual void PerformUpdate(TransactionContext *const current_txn, const ItemPointer &location); virtual void PerformDelete(TransactionContext *const current_txn, const ItemPointer &location); virtual ResultType CommitTransaction(TransactionContext *const current_txn); virtual ResultType AbortTransaction(TransactionContext *const current_txn); private: static const int LOCK_OFFSET = 0; static const int LAST_READER_OFFSET = (LOCK_OFFSET + 8); Spinlock *GetSpinlockField( const storage::TileGroupHeader *const tile_group_header, const oid_t &tuple_id); cid_t GetLastReaderCommitId( const storage::TileGroupHeader *const tile_group_header, const oid_t &tuple_id); bool SetLastReaderCommitId( const storage::TileGroupHeader *const tile_group_header, const oid_t &tuple_id, const cid_t &current_cid, const bool is_owner); // Initiate reserved area of a tuple void InitTupleReserved( const storage::TileGroupHeader *const tile_group_header, const oid_t tuple_id); }; } }
// // Map.h // SimpleMap // // Created by masashi on 11/8/13. // // #import "GoogleMaps.h" #import "MyPlgunProtocol.h" //#import "NSData-Base64/NSData+Base64.h" #import "NSData+Base64.h" @interface Map : CDVPlugin<MyPlgunProtocol> @property (nonatomic, strong) GoogleMapsViewController* mapCtrl; - (void)setTilt:(CDVInvokedUrlCommand*)command; - (void)setCenter:(CDVInvokedUrlCommand*)command; - (void)setZoom:(CDVInvokedUrlCommand*)command; - (void)setMapTypeId:(CDVInvokedUrlCommand*)command; - (void)animateCamera:(CDVInvokedUrlCommand*)command; - (void)moveCamera:(CDVInvokedUrlCommand*)command; - (void)setMyLocationEnabled:(CDVInvokedUrlCommand*)command; - (void)setMyLocationButtonEnabled:(CDVInvokedUrlCommand*)command; - (void)setIndoorEnabled:(CDVInvokedUrlCommand*)command; - (void)setTrafficEnabled:(CDVInvokedUrlCommand*)command; - (void)setCompassEnabled:(CDVInvokedUrlCommand*)command; - (void)getCameraPosition:(CDVInvokedUrlCommand*)command; - (void)toDataURL:(CDVInvokedUrlCommand*)command; - (void)getVisibleRegion:(CDVInvokedUrlCommand*)command; - (void)setOptions:(CDVInvokedUrlCommand*)command; - (void)setAllGesturesEnabled:(CDVInvokedUrlCommand*)command; - (void)setPadding:(CDVInvokedUrlCommand*)command; - (void)panBy:(CDVInvokedUrlCommand*)command; - (void)getFocusedBuilding:(CDVInvokedUrlCommand*)command; @end
/* * Copyright (c) 2008, 2009, 2010, 2011, 2012 Nicira, Inc. * * 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 BITMAP_H #define BITMAP_H 1 #include <limits.h> #include <stdlib.h> #include "util.h" #define BITMAP_ULONG_BITS (sizeof(unsigned long) * CHAR_BIT) static inline unsigned long * bitmap_unit__(const unsigned long *bitmap, size_t offset) { return CONST_CAST(unsigned long *, &bitmap[offset / BITMAP_ULONG_BITS]); } static inline unsigned long bitmap_bit__(size_t offset) { return 1UL << (offset % BITMAP_ULONG_BITS); } static inline size_t bitmap_n_longs(size_t n_bits) { return DIV_ROUND_UP(n_bits, BITMAP_ULONG_BITS); } static inline size_t bitmap_n_bytes(size_t n_bits) { return bitmap_n_longs(n_bits) * sizeof(unsigned long int); } static inline unsigned long * bitmap_allocate(size_t n_bits) { return xzalloc(bitmap_n_bytes(n_bits)); } unsigned long *bitmap_allocate1(size_t n_bits); static inline unsigned long * bitmap_clone(const unsigned long *bitmap, size_t n_bits) { return xmemdup(bitmap, bitmap_n_bytes(n_bits)); } static inline void bitmap_free(unsigned long *bitmap) { free(bitmap); } static inline bool bitmap_is_set(const unsigned long *bitmap, size_t offset) { return (*bitmap_unit__(bitmap, offset) & bitmap_bit__(offset)) != 0; } static inline void bitmap_set1(unsigned long *bitmap, size_t offset) { *bitmap_unit__(bitmap, offset) |= bitmap_bit__(offset); } static inline void bitmap_set0(unsigned long *bitmap, size_t offset) { *bitmap_unit__(bitmap, offset) &= ~bitmap_bit__(offset); } static inline void bitmap_set(unsigned long *bitmap, size_t offset, bool value) { if (value) { bitmap_set1(bitmap, offset); } else { bitmap_set0(bitmap, offset); } } void bitmap_set_multiple(unsigned long *, size_t start, size_t count, bool value); bool bitmap_equal(const unsigned long *, const unsigned long *, size_t n); size_t bitmap_scan(const unsigned long int *, size_t start, size_t end); #define BITMAP_FOR_EACH_1(IDX, SIZE, BITMAP) \ for ((IDX) = bitmap_scan(BITMAP, 0, SIZE); (IDX) < (SIZE); \ (IDX) = bitmap_scan(BITMAP, (IDX) + 1, SIZE)) #endif /* bitmap.h */
/** * Copyright (C) 2013 kangliqiang ,kangliq@163.com * * 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 __SERVICESTATE_H__ #define __SERVICESTATE_H__ namespace rmq { /** * ·þÎñ¶ÔÏóµÄ״̬£¬Í¨³£ÐèÒªstart£¬shutdown * */ enum ServiceState { /** * ·þÎñ¶ÔÏó¸Õ¸Õ´´½¨£¬µ«ÊÇδÆô¶¯ */ CREATE_JUST, /** * ·þÎñÆô¶¯³É¹¦ */ RUNNING, /** * ·þÎñÒѾ­¹Ø±Õ */ SHUTDOWN_ALREADY, /** * ·þÎñÆô¶¯Ê§°Ü */ START_FAILED }; } #endif
#ifndef CPPSUMARRAY #define CPPSUMARRAY #include <stdio.h> #include <stdlib.h> #include <string.h> #include <iostream> #include <stdint.h> #include <jni.h> #include <mutex> class CPPSumArray { private: JNIEnv* env; jobject jniJavaClassRef; int jniCreated = 0; int* sum; jintArray sumArr; int sum_length; static std::mutex mtx; public: int* getsum(); int getsum_length(); jobject getJavaObject(); CPPSumArray(jclass replaceMeClassName, jobject replaceMeObjectName, JNIEnv* env); CPPSumArray(int* sumarg, int sum_lengtharg, jclass jClass, JNIEnv* jniEnv); CPPSumArray(); ~CPPSumArray(); }; #endif
// // ADVViewController.h // ADVProgressBar // // /* The MIT License Original work Copyright (c) 2011 Tope Abayomi http://www.appdesignvault.com/ Modified work Copyright (c) 2013 Corrado Ubezio https://github.com/corerd/ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*! ADVPercentProgressBar demo. Demonstrate how to create and instantiate a bunch of ADVPercentProgressBar custom views. They are added to the View Controller in the two ways: - programmatically; - from a nib or storyboard. */ #import <UIKit/UIKit.h> #import "ADVPercentProgressBar.h" @interface ADVViewController : UIViewController /// An ADVPercentProgressBar showing the integral value. //@property (strong, nonatomic) IBOutlet ADVPercentProgressBar *pbRangeValue; /// An ADVPercentProgressBar showing the percentage of the value. //@property (strong, nonatomic) IBOutlet ADVPercentProgressBar *pbRangePercent; //@property (retain, nonatomic) IBOutlet ADVPercentProgressBar *greenprogressBar; /*! Action on sliding. Get the value changed sliding along the track. The value is returned in the range 0.0 - 1.0 and is used to animate the ADVPercentProgressBar views. @param sender Slider that is sending the action message. */ @property (retain, nonatomic) IBOutlet ADVPercentProgressBar *pbRangePercent; - (IBAction)sliderValueChanged:(UISlider *)sender; - (void)updateProgressTo:(CGFloat)newProgress; @end
//===--- GenericEnvironment.h - Generic Environment AST ---------*- C++ -*-===// // // This source file is part of the Swift.org open source project // // Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See http://swift.org/LICENSE.txt for license information // See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// // // This file defines the GenericEnvironment class. // //===----------------------------------------------------------------------===// #ifndef SWIFT_AST_GENERIC_ENVIRONMENT_H #define SWIFT_AST_GENERIC_ENVIRONMENT_H #include "swift/AST/ProtocolConformance.h" #include "swift/AST/SubstitutionMap.h" namespace swift { class ASTContext; class GenericTypeParamType; /// Describes the mapping between archetypes and interface types for the /// generic parameters of a DeclContext. class GenericEnvironment final { TypeSubstitutionMap ArchetypeToInterfaceMap; TypeSubstitutionMap InterfaceToArchetypeMap; public: const TypeSubstitutionMap &getArchetypeToInterfaceMap() const { return ArchetypeToInterfaceMap; } const TypeSubstitutionMap &getInterfaceToArchetypeMap() const { return InterfaceToArchetypeMap; } explicit GenericEnvironment(TypeSubstitutionMap interfaceToArchetypeMap); static GenericEnvironment *get(ASTContext &ctx, TypeSubstitutionMap interfaceToArchetypeMap); /// Make vanilla new/delete illegal. void *operator new(size_t Bytes) = delete; void operator delete(void *Data) = delete; /// Only allow allocation of GenericEnvironments using the allocator /// in ASTContext. void *operator new(size_t bytes, const ASTContext &ctx); /// Map a contextual type to an interface type. Type mapTypeOutOfContext(ModuleDecl *M, Type type) const; /// Map an interface type to a contextual type. Type mapTypeIntoContext(ModuleDecl *M, Type type) const; /// Map a generic parameter type to a contextual type. Type mapTypeIntoContext(GenericTypeParamType *type) const; /// Derive a contextual type substitution map from a substitution array. /// This is just like GenericSignature::getSubstitutionMap(), except /// with contextual types instead of interface types. SubstitutionMap getSubstitutionMap(ModuleDecl *mod, GenericSignature *sig, ArrayRef<Substitution> subs) const; /// Same as above, but updates an existing map. void getSubstitutionMap(ModuleDecl *mod, GenericSignature *sig, ArrayRef<Substitution> subs, SubstitutionMap &subMap) const; ArrayRef<Substitution> getForwardingSubstitutions(ModuleDecl *M, GenericSignature *sig) const; void dump() const; }; } // end namespace swift #endif // SWIFT_AST_GENERIC_ENVIRONMENT_H
// // NSSet+PFObject.h // MyCQs // // Created by JAMES GUPTA on 07/06/2014. // Copyright (c) 2014 MyLabs. All rights reserved. // #import <Foundation/Foundation.h> @interface NSSet (PFObject) -(BOOL)containsParseObject:(PFObject*)object; @end
/* Copyright (C) 2001-2003, Parrot Foundation. $Id$ =head1 NAME examples/benchmarks/primes.c - Calculate prime numbers < 50000 =head1 SYNOPSIS % make examples/benchmarks/primes % time examples/benchmarks/primes =head1 DESCRIPTION Calculates all the prime numbers up to 50000 and prints out the number of primes and the last one found. =head2 Functions =over 4 =cut */ #include <stdio.h> /* =item C<int main(int argc, char *argv[])> Main function to run the example. =cut */ int main(int argc, char *argv[]) { int I1 = 1; int I2 = 50000; int I3; int I4; int I5; int I6 = 0; int I7; printf("N primes up to "); printf("%d", I2); printf(" is: "); REDO: I3 = 2; I4 = I1 / 2; LOOP: I5 = I1 % I3; if (I5) {goto OK;} goto NEXT; OK: I3++; if (I3 <= I4) {goto LOOP;} I6++; I7 = I1; NEXT: I1++; if (I1 <= I2) {goto REDO;} printf("%d\n", I6); printf("last is: %d\n", I7); return 0; } /* =back =head1 SEE ALSO F<examples/benchmarks/primes.c>, F<examples/benchmarks/primes.pasm>, F<examples/benchmarks/primes.pl>, F<examples/benchmarks/primes2_p.pasm>, F<examples/benchmarks/primes2.c>, F<examples/benchmarks/primes2.pir>, F<examples/benchmarks/primes2.py>. =cut */ /* * Local variables: * c-file-style: "parrot" * End: * vim: expandtab shiftwidth=4: */
#include "resh.h" int main(int argc, char *argv[]) { argv[0] = "ylc"; return(spawn(argc, argv)); }
/* * Copyright 2014, NICTA * * This software may be distributed and modified according to the terms of * the BSD 2-Clause license. Note that NO WARRANTY is provided. * See "LICENSE_BSD2.txt" for details. * * @TAG(NICTA_BSD) */ /* * DesignWare eMMC */ #include <stdlib.h> #include <string.h> #include "../../devices.h" #include "../../vm.h" #define DWEMMC_DBADDR_OFFSET 0x088 #define DWEMMC_DSCADDR_OFFSET 0x094 #define DWEMMC_BUFADDR_OFFSET 0x098 #if 0 #define dprintf(...) printf(__VA_ARGS__) #else #define dprintf(...) do { } while(0) #endif struct sdhc_priv { /// The VM associated with this device vm_t *vm; /// Physical registers of the SDHC void* regs; /// Residual for 64 bit atomic access to FIFO uint32_t a64; }; static int handle_sdhc_fault(struct device* d, vm_t* vm, fault_t* fault) { struct sdhc_priv* sdhc_data = (struct sdhc_priv*)d->priv; volatile uint32_t *reg; int offset; /* Gather fault information */ offset = fault_get_address(fault) - d->pstart; reg = (uint32_t*)(sdhc_data->regs + offset); /* Handle the fault */ reg = (volatile uint32_t*)(sdhc_data->regs + offset); if (fault_is_read(fault)) { if (fault_get_width(fault) == WIDTH_DOUBLEWORD) { if (offset & 0x4) { /* Unaligned access: report residual */ fault_set_data(fault, sdhc_data->a64); } else { /* Aligned access: Read in and store residual */ uint64_t v; v = *(volatile uint64_t*)reg; fault_set_data(fault, v); sdhc_data->a64 = v >> 32; } } else { assert(fault_get_width(fault) == WIDTH_WORD); fault_set_data(fault, *reg); } dprintf("[%s] pc0x%x| r0x%x:0x%x\n", d->name, fault_get_ctx(fault)->pc, fault_get_address(fault), fault_get_data(fault)); } else { switch (offset & ~0x3) { case DWEMMC_DBADDR_OFFSET: case DWEMMC_DSCADDR_OFFSET: case DWEMMC_BUFADDR_OFFSET: printf("[%s] Restricting DMA access offset 0x%x\n", d->name, offset); break; default: if (fault_get_width(fault) == WIDTH_DOUBLEWORD) { if (offset & 0x4) { /* Unaligned acces: store data and residual */ uint64_t v; v = ((uint64_t)fault_get_data(fault) << 32) | sdhc_data->a64; *(volatile uint64_t*)reg = v; } else { /* Aligned access: record residual */ sdhc_data->a64 = fault_get_data(fault); } } else { assert(fault_get_width(fault) == WIDTH_WORD); *reg = fault_get_data(fault); } } dprintf("[%s] pc0x%x| w0x%x:0x%x\n", d->name, fault_get_ctx(fault)->pc, fault_get_address(fault), fault_get_data(fault)); } return advance_fault(fault); } const struct device dev_msh0 = { .devid = DEV_CUSTOM, .name = "MSH0", .pstart = MSH0_PADDR, .size = 0x1000, .handle_page_fault = &handle_sdhc_fault, .priv = NULL }; const struct device dev_msh2 = { .devid = DEV_CUSTOM, .name = "MSH2", .pstart = MSH2_PADDR, .size = 0x1000, .handle_page_fault = &handle_sdhc_fault, .priv = NULL }; static int vm_install_nodma_sdhc(vm_t* vm, int idx) { struct sdhc_priv *sdhc_data; struct device d; vspace_t* vmm_vspace; int err; switch (idx) { case 0: d = dev_msh0; break; case 2: d = dev_msh2; break; default: assert(0); return -1; } vmm_vspace = vm->vmm_vspace; /* Initialise the virtual device */ sdhc_data = malloc(sizeof(struct sdhc_priv)); if (sdhc_data == NULL) { assert(sdhc_data); return -1; } memset(sdhc_data, 0, sizeof(*sdhc_data)); sdhc_data->vm = vm; sdhc_data->regs = map_device(vmm_vspace, vm->vka, vm->simple, d.pstart, 0, seL4_AllRights); if (sdhc_data->regs == NULL) { assert(sdhc_data->regs); return -1; } map_vm_device(vm, d.pstart, d.pstart, seL4_CanRead); d.priv = sdhc_data; err = vm_add_device(vm, &d); assert(!err); if (err) { free(sdhc_data); return -1; } return 0; } int vm_install_nodma_sdhc0(vm_t* vm) { return vm_install_nodma_sdhc(vm, 0); } int vm_install_nodma_sdhc2(vm_t* vm) { return vm_install_nodma_sdhc(vm, 2); }
/* * Copyright (c) 2007 Hypertriton, Inc. <http://hypertriton.com/> * 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. * * 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 AUTHOR OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include <config/version.h> #include <config/have_gethostname.h> #include <sys/types.h> #include <sys/time.h> #include <sys/socket.h> #include <sys/wait.h> #include <netinet/in.h> #include <netinet/in_systm.h> #include <netinet/ip.h> #include <stdlib.h> #include <stdio.h> #include <stdarg.h> #include <string.h> #include <unistd.h> #include <netdb.h> #include <errno.h> #include <fcntl.h> #include <signal.h> #include "agarrcsd.h" #include "pathnames.h" #include "protocol.h" #include "rcs.h" #include <agar/gui.h> #include <agar/dev.h> volatile int gothup = 0; AG_Object UserMgr; /* User manager object */ User *user; /* Current user (child context) */ NS_Server *serv; /* Server object (child context) */ static void sig_hup(int sigraised) { gothup++; } static int version(NS_Server *serv, NS_Command *cmd, void *p) { char hostname[128]; hostname[0] = '\0'; #ifdef HAVE_GETHOSTNAME gethostname(hostname, sizeof(hostname)); #endif NS_Message(serv, 0, "agarrcsd:%s:%s", VERSION, hostname); return (0); } static int auth_password(NS_Server *serv, void *p) { char buf[65], *pBuf = &buf[0]; char *name, *pass; User *u; size_t end; if (fgets(buf, sizeof(buf), stdin) == NULL) return (-1); if ((name = Strsep(&pBuf, ":")) == NULL || (pass = Strsep(&pBuf, ":")) == NULL) { return (-1); } end = strlen(pass)-1; if (pass[end] == '\n') pass[end] = '\0'; if ((u = UserLookup(name)) == NULL) { NS_Log(NS_INFO, "%s: no such user", name); goto fail; } if (strcmp(pass, u->pass) == 0) { user = u; NS_Log(NS_INFO, "%s: login successful", name); return (1); } NS_Log(NS_INFO, "%s: password mismatch", name); fail: AG_SetError("Unknown username or password mismatch"); return (0); } static int auth_pubkey(NS_Server *serv, void *p) { AG_SetError("Public key auth is not implemented"); return (0); } int main(int argc, char *argv[]) { char *host = NULL; char *port = "6785"; char *dir = _PATH_DATA; User *u; struct sigaction sa; int adminflag = 0; int i; if (AG_InitCore("agarrcsd", AG_CREATE_DATADIR) == -1) { fprintf(stderr, "%s\n", AG_GetError()); return (1); } while ((i = getopt(argc, argv, "ab:p:d:v?")) != -1) { extern char *__progname; switch (i) { case 'a': adminflag = 1; break; case 'b': host = optarg; break; case 'p': port = optarg; break; case 'd': dir = optarg; break; case 'v': printf("%s %s\n", __progname, VERSION); exit(0); case '?': default: printf("Usage: %s [-av] [-b host] [-p port] [-d dir]\n", __progname); exit(0); } } AG_RegisterClass(&UserClass); AG_ObjectInitStatic(&UserMgr, NULL); if (adminflag) { if (AG_InitVideo(640, 480, 32, AG_VIDEO_RESIZABLE) == -1) { fprintf(stderr, "%s\n", AG_GetError()); return (-1); } AG_InitInput(0); AG_SetRefreshRate(-1); AG_BindGlobalKey(AG_KEY_ESCAPE, AG_KEYMOD_ANY, AG_Quit); DEV_InitSubsystem(0); DEV_Browser(&UserMgr); } /* Load previously saved user data. */ AG_ObjectLoad(&UserMgr); AGOBJECT_FOREACH_CLASS(u, &UserMgr, user, "User:*") AG_ObjectLoad(u); /* Move to the data directory. */ if (chdir(dir) == -1) { fprintf(stderr, "%s: %s\n", dir, strerror(errno)); exit(1); } /* Initialize the server. */ serv = NS_ServerNew(NULL, 0, "_server", _PROTO_NAME, _PROTO_VER, port); NS_ServerBind(serv, host, port); /* Set up the SIGHUP handler. */ sa.sa_flags = 0; sa.sa_handler = sig_hup; sigaction(SIGHUP, &sa, NULL); /* Register our auth methods and error functions. */ NS_RegAuthMode(serv, "password", auth_password, NULL); NS_RegAuthMode(serv, "public-key", auth_pubkey, NULL); /* Register the daemon functions. */ NS_RegCmd(serv, "version", version, NULL); NS_RegCmd(serv, "rcs-commit", rcs_commit, NULL); NS_RegCmd(serv, "rcs-info", rcs_info, NULL); NS_RegCmd(serv, "rcs-update", rcs_update, NULL); NS_RegCmd(serv, "rcs-list", rcs_list, NULL); NS_RegCmd(serv, "rcs-log", rcs_log, NULL); if (adminflag) { AG_EventLoop(); goto out; } /* Server main loop. */ if (NS_ServerLoop(serv) == -1) { fprintf(stderr, "%s.%s: %s\n", host, port, strerror(errno)); exit(1); } out: AG_Destroy(); return (0); }
/* * Copyright (c) 2016,2021 Daichi GOTO * 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. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #define VERSION "20210911" #define CMDNAME "wait_filechanges" #define ALIAS "" #include "ttt.h"
#include <stdio.h> #include <string.h> #include <at/path.h> #define W 20 #define H 10 static int is_obstructed(void *v, int x, int y) { int *grid = (int *)v; return grid[y * W + x] != 0; } int main(int argc, char *argv[]) { unsigned x, y; char display[W * H]; int grid[W * H] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; int err; int xs[12]; int ys[12]; size_t sz = 12, i; memset(display, 0, sizeof(*display) * W * H); for (y = 0; y < H; ++y) for (x = 0; x < W; ++x) display[y * W + x] = grid[y * W + x] ? '#' : '.'; err = at_path_a_star(xs, ys, &sz, 0, 0, 6, 6, W, H, is_obstructed, (void *)grid); if (err != 0) { printf("at_path_a_star() failed, returning %d\n", err); return -1; } for (i = 0; i < sz; ++i) display[ys[i] * W + xs[i]] = '*'; for (y = 0; y < H; ++y) { for (x = 0; x < W; ++x) { printf("%c", display[y * W + x]); } printf("\n"); } return 0; }
/////////////////////////////////////////////////////////////////////////////// // This file is generated automatically using Prop (version 2.4.0), // last updated on Jul 1, 2011. // The original source file is "querygraph.ph". /////////////////////////////////////////////////////////////////////////////// #define PROP_REWRITING_USED #define PROP_STRCMP_USED #define PROP_QUARK_USED #define PROP_TUPLE2_USED #include <propdefs.h> #line 1 "querygraph.ph" #ifndef query_graph_h #define query_graph_h #include "paige.h" #include <AD/contain/varstack.h> /////////////////////////////////////////////////////////////////////////////// // // This class implements the query graph construction phase // /////////////////////////////////////////////////////////////////////////////// #line 12 "querygraph.ph" #line 22 "querygraph.ph" class QueryGraphConstruction : public BURS, virtual public PaigeGoyal { private: QueryGraphConstruction(const QueryGraphConstruction&); // no copy constructor void operator = (const QueryGraphConstruction&); // no assignment public: struct QueryGraphConstruction_StateRec * stack__, * stack_top__; public: void labeler(const char *, int&, int); void labeler(Quark, int&, int); void labeler(Exp & redex, int&, int); inline virtual void operator () (Exp & redex) { int s; labeler(redex,s,0); } void labeler(a_List<Exp> * & redex, int&, int); inline virtual void operator () (a_List<Exp> * & redex) { int s; labeler(redex,s,0); } void labeler(Literal & redex, int&, int); inline virtual void operator () (Literal & redex) { int s; labeler(redex,s,0); } private: #line 14 "querygraph.ph" Bool preceeds(Id x, Id y) const; // check if x preceeds y in the // quantifier ordering. public: QueryGraphConstruction(); virtual ~QueryGraphConstruction(); virtual Exp construct_query_graph(Exp); #line 22 "querygraph.ph" }; #line 22 "querygraph.ph" #line 22 "querygraph.ph" #endif #line 25 "querygraph.ph" /* ------------------------------- Statistics ------------------------------- Merge matching rules = yes Number of DFA nodes merged = 0 Number of ifs generated = 0 Number of switches generated = 0 Number of labels = 0 Number of gotos = 0 Adaptive matching = disabled Fast string matching = disabled Inline downcasts = disabled -------------------------------------------------------------------------- */
/**************************************************************************** ** Copyright (c) 2017, Fougue Ltd. <http://www.fougue.pro> ** 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. ** ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ****************************************************************************/ #include "utest_assert.h" #include "../src/gmio_core/memblock.h" #include "../src/gmio_core/endian.h" #include "../src/gmio_core/error.h" #include "../src/gmio_core/stream.h" #include <stdlib.h> #include <string.h> static struct gmio_memblock __tc__buffer_ctor() { return gmio_memblock_calloc(4, 256); } static const char* test_core__buffer() { /* gmio_memblock_calloc() */ { const size_t obj_count = 4; const size_t obj_size = 256; const size_t buff_size = obj_count * obj_size; const uint8_t zero_buff[4 * 256] = {0}; struct gmio_memblock buff = gmio_memblock_calloc(obj_count, obj_size); UTEST_ASSERT(buff.ptr != NULL); UTEST_ASSERT(buff.size == buff_size); UTEST_ASSERT(memcmp(buff.ptr, &zero_buff[0], buff_size) == 0); /* TODO: make assert succeed with mingw and gmio as a DLL * In this case free() has not the same address in libgmio.dll and * test_core.exe */ UTEST_ASSERT(buff.func_deallocate == &free); gmio_memblock_deallocate(&buff); } /* gmio_memblock_malloc() */ { const size_t buff_size = 2 * 1024; /* 2KB */ struct gmio_memblock buff = gmio_memblock_malloc(buff_size); UTEST_ASSERT(buff.ptr != NULL); UTEST_ASSERT(buff.size == buff_size); UTEST_ASSERT(buff.func_deallocate == &free); gmio_memblock_deallocate(&buff); } /* gmio_memblock_realloc() */ { const size_t buff_size = 1024; /* 1KB */ struct gmio_memblock buff = gmio_memblock_malloc(buff_size); buff = gmio_memblock_realloc(buff.ptr, 2 * buff_size); UTEST_ASSERT(buff.ptr != NULL); UTEST_ASSERT(buff.size == (2 * buff_size)); UTEST_ASSERT(buff.func_deallocate == &free); gmio_memblock_deallocate(&buff); } /* default ctor */ { UTEST_ASSERT(gmio_memblock_default_constructor() != NULL); gmio_memblock_set_default_constructor(&__tc__buffer_ctor); UTEST_ASSERT(gmio_memblock_default_constructor() == &__tc__buffer_ctor); } return NULL; } static const char* test_core__endian() { UTEST_ASSERT(gmio_host_endianness() == GMIO_ENDIANNESS_HOST); GMIO_PRAGMA_MSVC_WARNING_PUSH_AND_DISABLE(4127) UTEST_ASSERT(GMIO_ENDIANNESS_LITTLE != GMIO_ENDIANNESS_BIG); UTEST_ASSERT(GMIO_ENDIANNESS_HOST == GMIO_ENDIANNESS_LITTLE || GMIO_ENDIANNESS_HOST == GMIO_ENDIANNESS_BIG); GMIO_PRAGMA_MSVC_WARNING_POP() return NULL; } static const char* test_core__error() { UTEST_ASSERT(gmio_no_error(GMIO_ERROR_OK)); UTEST_ASSERT(!gmio_error(GMIO_ERROR_OK)); UTEST_ASSERT(!gmio_no_error(GMIO_ERROR_UNKNOWN)); UTEST_ASSERT(gmio_error(GMIO_ERROR_UNKNOWN)); return NULL; } static const char* test_core__stream() { const struct gmio_stream null_stream = gmio_stream_null(); const uint8_t null_bytes[sizeof(struct gmio_stream)] = {0}; UTEST_ASSERT(memcmp(&null_stream, &null_bytes, sizeof(struct gmio_stream)) == 0); return NULL; }
#ifndef __TCPCRYPT_CHECKSUM_H__ #define __TCPCRYPT_CHECKSUM_H__ extern void checksum_packet(struct tc *tc, struct ip *ip, struct tcphdr *tcp); extern void checksum_ip(struct ip *ip); extern void checksum_tcp(struct tc *tc, struct ip *ip, struct tcphdr *tcp); extern uint16_t checksum(void *data, int len); #endif /* __TCPCRYPT_CHECKSUM_H__ */
/* * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright notice, this * list of conditions and the following disclaimer in the documentation and/or * other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef SQLPP_TVIN_H #define SQLPP_TVIN_H // TVIN: Trivial value is NULL #include <sqlpp11/type_traits.h> #include <sqlpp11/serialize.h> #include <sqlpp11/serializer.h> #include <sqlpp11/wrap_operand.h> namespace sqlpp { template <typename Operand> struct tvin_arg_t { using _traits = make_traits<value_type_of<Operand>, tag::is_expression>; using _nodes = detail::type_vector<Operand>; using _operand_t = Operand; tvin_arg_t(_operand_t operand) : _value(operand) { } tvin_arg_t(const tvin_arg_t&) = default; tvin_arg_t(tvin_arg_t&&) = default; tvin_arg_t& operator=(const tvin_arg_t&) = default; tvin_arg_t& operator=(tvin_arg_t&&) = default; ~tvin_arg_t() = default; _operand_t _value; }; SQLPP_PORTABLE_STATIC_ASSERT(assert_tvin_with_correct_operator_t, "tvin may only be used with operators =, == and !="); template <typename Context, typename Operand> struct serializer_t<Context, tvin_arg_t<Operand>> { using _serialize_check = assert_tvin_with_correct_operator_t; using T = tvin_arg_t<Operand>; static Context& _(const T&, Context&) { _serialize_check::_(); } }; template <typename T> struct tvin_t; namespace detail { template <typename T> struct allow_tvin_impl { using type = T; }; template <typename T> struct allow_tvin_impl<tvin_arg_t<T>> { using type = tvin_t<T>; }; } template <typename T> using allow_tvin_t = typename detail::allow_tvin_impl<T>::type; template <typename Operand> struct tvin_t { using _traits = make_traits<value_type_of<Operand>, tag::is_expression>; using _nodes = detail::type_vector<Operand>; using _operand_t = Operand; tvin_t(tvin_arg_t<Operand> arg) : _value(arg._value) { } tvin_t(const tvin_t&) = default; tvin_t(tvin_t&&) = default; tvin_t& operator=(const tvin_t&) = default; tvin_t& operator=(tvin_t&&) = default; ~tvin_t() = default; bool _is_trivial() const { return _value._is_trivial(); } bool _is_null() const { return _value._is_trivial(); } _operand_t _value; }; namespace detail { template <typename T> struct is_tvin_impl { using type = std::false_type; }; template <typename T> struct is_tvin_impl<tvin_t<T>> { using type = std::true_type; }; } template <typename T> using is_tvin_t = typename detail::is_tvin_impl<T>::type; template <typename Context, typename Operand> struct serializer_t<Context, tvin_t<Operand>> { using _serialize_check = serialize_check_of<Context, Operand>; using T = tvin_t<Operand>; static Context& _(const T& t, Context& context) { if (t._is_trivial()) { context << "NULL"; } else { serialize(t._value, context); } return context; } }; template <typename Operand> auto tvin(Operand operand) -> tvin_arg_t<wrap_operand_t<Operand>> { using _operand_t = wrap_operand_t<Operand>; static_assert(not std::is_same<_operand_t, Operand>::value or is_result_field_t<Operand>::value, "tvin() used with invalid type (only string and primitive types allowed)"); return {{operand}}; } } #endif
/* * This file is part of synconv. * * © 2013 Fernando Tarlá Cardoso Lemos * * Refer to the LICENSE file for licensing information. * */ #import "SCVRenamingFilter.h" @interface SCVConservativeRenamingFilter : SCVRenamingFilter @end
/* * Copyright (C) Igor Sysoev * Copyright (C) Nginx, Inc. */ #ifndef _NGX_EVENT_PIPE_H_INCLUDED_ #define _NGX_EVENT_PIPE_H_INCLUDED_ #include <ngx_config.h> #include <ngx_core.h> #include <ngx_event.h> typedef struct ngx_event_pipe_s ngx_event_pipe_t; /* 处理接收自上游的包体的回调方法原型 */ typedef ngx_int_t (*ngx_event_pipe_input_filter_pt)(ngx_event_pipe_t *p, ngx_buf_t *buf); /* 向下游发送响应的回调的原型 */ typedef ngx_int_t (*ngx_event_pipe_output_filter_pt)(void *data, ngx_chain_t *chain); struct ngx_event_pipe_s { ngx_connection_t *upstream; ngx_connection_t *downstream; /* 直接接收自上游的缓冲区链表,这个链表的顺序是逆序的,也就是说,链表前端的ngx_buf_t是后 * 接收到的响应,仅在接收响应时使用。 */ ngx_chain_t *free_raw_bufs; /* 表示接收到的上游响应缓冲区,通常in链表是在input_filter方法中设置的 */ ngx_chain_t *in; /* 表示刚刚接收到的一个缓冲区 */ ngx_chain_t **last_in; /* 保存着将要发送给客户端的缓冲区链表,在写入临时文件成功时,会把in链表中写入文件的缓冲区添加到out链表 */ ngx_chain_t *out; /* 等待释放的缓冲区 */ ngx_chain_t *free; /* 上次调用ngx_http_output_fiter方法发送响应时没有发送完的缓冲区链表,这个链表中的 * 缓冲区已经保存到请求的output链表中,busy仅用于记录还有多大的响应正等待发送 */ ngx_chain_t *busy; /* * the input filter i.e. that moves HTTP/1.1 chunks * from the raw bufs to an incoming chain */ /* 一般使用upstream提供的默认ngx_event_pipe_copy_input_filter */ ngx_event_pipe_input_filter_pt input_filter; /* 一般设置为ngx_http_request_t的地址 */ void *input_ctx; ngx_event_pipe_output_filter_pt output_filter; /* 指向ngx_http_request_t结构体 */ void *output_ctx; unsigned read:1; unsigned cacheable:1; /* 为1时表示接收上游响应时一次只能接收一个bgx_bug_t缓冲区 */ unsigned single_buf:1; /* 为1时一旦不再接收上游 */ unsigned free_bufs:1; unsigned upstream_done:1; /* 与上游连接出错时,会被置为1 */ unsigned upstream_error:1; /* 表示与上游的连接状态,当nginx与上游的连接已经关闭是,该标志位为1 */ unsigned upstream_eof:1; /* 表示暂时阻塞读取上游响应的流程,期待通过向下游发送响应来清理出空闲的缓冲区,再用空闲的缓冲区接收 * 响应,也就是说,blocked为1时,,会在ngx_event_pipe_t方法循环中先向downstream发送响应,然后 * 再去上游读响应 */ unsigned upstream_blocked:1; unsigned downstream_done:1; unsigned downstream_error:1; /* 不建议置为1 */ unsigned cyclic_temp_file:1; /* 已经分配的缓冲区的数目,受bufs.num的限制 */ ngx_int_t allocated; /* 记录了接收上游响应的内存缓冲区大小,bufs.size表示每个缓冲区的大小,bufs.num表示最的的缓冲区数目 */ ngx_bufs_t bufs; /* 用于设置、比较缓冲区链表中ngx_buf_t结构体的tag标志位 */ ngx_buf_tag_t tag; /* busy缓冲区中待发送的响应长度触发值,但达到busy_size长度时,必须等待busy缓冲区发送了足够的内容, * 才能继续发送out和in缓冲区中的内容 */ ssize_t busy_size; /* 已经接收到上游响应的包体长度 */ off_t read_length; off_t length; off_t max_temp_file_size; ssize_t temp_file_write_size; ngx_msec_t read_timeout; ngx_msec_t send_timeout; /* 向下游发送时,TCP连接中设置的sent_lowat水位 */ ssize_t send_lowat; ngx_pool_t *pool; ngx_log_t *log; /* 表示在接收上游包头阶段已经读取到的响应包体 */ ngx_chain_t *preread_bufs; size_t preread_size; /* 仅用于缓存文件的场景 */ ngx_buf_t *buf_to_file; /* 存放上游响应的临时文件 */ ngx_temp_file_t *temp_file; /* 已经使用的buf_t缓冲区的数目 */ /* STUB */ int num; }; ngx_int_t ngx_event_pipe(ngx_event_pipe_t *p, ngx_int_t do_write); ngx_int_t ngx_event_pipe_copy_input_filter(ngx_event_pipe_t *p, ngx_buf_t *buf); ngx_int_t ngx_event_pipe_add_free_buf(ngx_event_pipe_t *p, ngx_buf_t *b); #endif /* _NGX_EVENT_PIPE_H_INCLUDED_ */
/* * POK header * * The following file is a part of the POK project. Any modification should * made according to the POK licence. You CANNOT use this file or a part of * this file is this part of a file for your own project * * For more information on the POK licence, please see our LICENCE FILE * * Please follow the coding guidelines described in doc/CODING_GUIDELINES * * Copyright (c) 2007-2009 POK team * * Created by julien on Thu Jan 15 23:34:13 2009 */ #if defined (POK_NEEDS_EVENTS) || defined (POK_NEEDS_BUFFERS) || defined (POK_NEEDS_BLACKBOARDS) #include <types.h> #include <errno.h> #include <core/time.h> #include <core/event.h> #include <core/syscall.h> #include <core/lockobj.h> pok_ret_t pok_event_wait (pok_event_id_t id, const uint64_t timeout) { pok_lockobj_lockattr_t lockattr; lockattr.operation = LOCKOBJ_OPERATION_WAIT; if (timeout > 0) { pok_time_gettick (&lockattr.time); lockattr.time += timeout; } lockattr.obj_kind = POK_LOCKOBJ_KIND_EVENT; return pok_syscall2 (POK_SYSCALL_LOCKOBJ_OPERATION, (uint32_t)id, (uint32_t)&lockattr); } #endif
#include <stdio.h> #include <stdlib.h> #include <stdint.h> #include <string.h> #include <sys/time.h> #include <sys/timerfd.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <netdb.h> #include <errno.h> #include <unistd.h> #include <getopt.h> #include <zmq.h> #include "metadata_exporter.h" #include "metadata_input_sysevent.h" #include "backend_event_loop.h" /* TODO - clean header list */ static uint8_t md_sysevent_reconnect(struct md_input_sysevent *mis) { void *context = zmq_ctx_new(); mis->responder = zmq_socket(context, ZMQ_REP); int rc = zmq_bind(mis->responder, "ipc:///tmp/sysevent"); if (rc != 0) return RETVAL_FAILURE; size_t len=-1; mis->zmq_fd = 0; if (zmq_getsockopt(mis->responder, ZMQ_FD, &(mis->zmq_fd), &len) != 0) { fprintf(stderr, "zmq_getsockopt failed to get file descriptor.\n"); return RETVAL_FAILURE; } return RETVAL_SUCCESS; } static void md_input_sysevent_handle_event(void *ptr, int32_t fd, uint32_t events) { struct md_input_sysevent *mis = ptr; char buffer[8192] = {0}; int zevents = 0; size_t zevents_len = sizeof(zevents); zmq_getsockopt(mis->responder, ZMQ_EVENTS, &zevents, &zevents_len); if (!(zevents & ZMQ_POLLIN)) return; json_tokener *tok = json_tokener_new(); do { int nbytes = zmq_recv(mis->responder, &buffer, 8192, ZMQ_NOBLOCK); if (nbytes>=sizeof(buffer)) break; struct md_sysevent sys_event = {0}; struct timeval tv; gettimeofday(&tv, NULL); sys_event.md_type = META_TYPE_SYSEVENT; sys_event.tstamp = tv.tv_sec; sys_event.sequence = mde_inc_seq(mis->parent); json_object *parsed = json_tokener_parse_ex(tok, buffer, strlen(buffer)); if (parsed == NULL) { enum json_tokener_error jerr = json_tokener_get_error(tok); fprintf(stderr, "%s (Message was %s)\n", json_tokener_error_desc(jerr), buffer); zmq_send(mis->responder, "That wasn't JSON.\n", 18, 0); break; } zmq_send(mis->responder, "Takk\n", 5, 0); sys_event.json_blob = parsed; mde_publish_event_obj(mis->parent, (struct md_event *) &sys_event); json_object_put(parsed); zmq_getsockopt(mis->responder, ZMQ_EVENTS, &zevents, &zevents_len); } while (zevents & ZMQ_POLLIN); json_tokener_free(tok); } static uint8_t md_sysevent_config(struct md_input_sysevent *mis) { if (md_sysevent_reconnect(mis) == RETVAL_SUCCESS) { if(!(mis->event_handle = backend_create_epoll_handle( mis, mis->zmq_fd , md_input_sysevent_handle_event))) return RETVAL_FAILURE; backend_event_loop_update( mis->parent->event_loop, EPOLLIN, EPOLL_CTL_ADD, mis->zmq_fd, mis->event_handle); return RETVAL_SUCCESS; } return RETVAL_FAILURE; } static uint8_t md_input_sysevent_init(void *ptr, json_object* config) { struct md_input_sysevent *mis = ptr; return md_sysevent_config(mis); } void md_sysevent_usage() { fprintf(stderr, "\"sysevent\": {},\t\tSysevent input (no parameters)\n"); } static void md_input_sysevent_destroy() { } void md_sysevent_setup(struct md_exporter *mde, struct md_input_sysevent *mis) { mis->parent = mde; mis->init = md_input_sysevent_init; mis->destroy = md_input_sysevent_destroy; }
/*** VT100 Display Control Escape Sequences ***/ #define ClearScreen "\x1b[2J" #define CursorToTopLeft "\x1b[H" #define TildeReturnNewline "~\r\n" #define ReturnNewline "\r\n" #define CursorUp "\x1b[1A" #define CursorDown "\x1b[1B" #define CursorForward "\x1b[1C" #define CursorBack "\x1b[1D" /* two sequences C is cursor foward, but don't exit the screen B is cursor down, but don't exit the screen 999 is a large enough maximum number of steps */ #define CursorToMaxForwardMaxDown "\x1b[999C\x1b[999B" #define CursorToMaxLeft "\x1b[999D" #define GetCursorPosition "\x1b[6n" /* the terminal reply to GetCursorPosition "24;80R" or similar */ #define CursorHide "\x1b[?25l" #define CursorDisplay "\x1b[?25h" #define ClearCurrentLine "\x1b[K" #define CursorToCenter "\x1b[12;30f" //Force Cursor Position <ESC>[{ROW};{COLUMN}f
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved. #pragma once #include "../GenericErrorReport.h" /** * Helper that works with Windows Error Reports */ class FWindowsErrorReport : public FGenericErrorReport { public: /** * Default constructor: creates a report with no files */ FWindowsErrorReport() { } /** * Load helper modules */ static void Init(); /** * Unload helper modules */ static void ShutDown(); /** * Discover all files in the crash report directory * @param Directory Full path to directory containing the report */ explicit FWindowsErrorReport(const FString& Directory); /** * Provide the exception and a call-stack as plain text if possible * @note This can take quite a long time */ FText DiagnoseReport() const; /** * Get the full path of the crashed app from the report */ FString FindCrashedAppPath() const; /** * Look for the most recent Windows Error Report * @return Full path to the most recent report, or an empty string if none found */ static FString FindMostRecentErrorReport(); };
#ifndef _GND_MULTI_PLATFORM_H #define _GND_MULTI_PLATFORM_H // visual studio secure function #if defined(_MSC_VER) // visual studio #pragma warning(disable:4996) #else #endif #endif // _GND_MULTI_PLATFORM_H
/********************************************************************************* * * Inviwo - Interactive Visualization Workshop * * Copyright (c) 2014-2016 Inviwo Foundation * 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. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * *********************************************************************************/ #ifndef IVW_ANGLEPROPERTYWIDGETQT_H #define IVW_ANGLEPROPERTYWIDGETQT_H #include <inviwo/qt/widgets/inviwoqtwidgetsdefine.h> #include <inviwo/qt/widgets/angleradiuswidget.h> #include <inviwo/qt/widgets/editablelabelqt.h> #include <inviwo/qt/widgets/properties/propertysettingswidgetqt.h> #include <inviwo/qt/widgets/properties/propertywidgetqt.h> #include <inviwo/core/properties/ordinalproperty.h> namespace inviwo { /** \class BaseAnglePropertyWidgetQt * Widget for Float and Double properties to edit an angle in [0 2pi). * * @see AngleWidget */ class IVW_QTWIDGETS_API BaseAnglePropertyWidgetQt : public PropertyWidgetQt { #include <warn/push> #include <warn/ignore/all> Q_OBJECT #include <warn/pop> public: BaseAnglePropertyWidgetQt(Property* prop); virtual ~BaseAnglePropertyWidgetQt() {}; virtual void updateFromProperty() = 0; public slots: virtual void onAngleChanged() = 0; virtual void onAngleMinMaxChanged() = 0; /** * Set current value as minimum value. */ virtual void setCurrentAsMin() = 0; /** * Set current value as maximum value. */ virtual void setCurrentAsMax() = 0; virtual void showSettings() = 0; protected: void generateWidget(); void generatesSettingsWidget(); // Actions for the context menu QAction* settingsAction_; QAction* minAction_; QAction* maxAction_; PropertySettingsWidgetQt* settingsWidget_; EditableLabelQt* displayName_; AngleRadiusWidget* angleWidget_; }; // Qt does not allow us to template class with Q_OBJECT so we inherit from it instead template <typename T> class AnglePropertyWidgetQt : public BaseAnglePropertyWidgetQt { public: AnglePropertyWidgetQt(OrdinalProperty<T>* property) : BaseAnglePropertyWidgetQt(property) { // Set values updateFromProperty(); } virtual ~AnglePropertyWidgetQt(){}; void updateFromProperty() { angleWidget_->blockSignals(true); angleWidget_->setMinMaxAngle(static_cast<double>(getProperty()->getMinValue()), static_cast<double>(getProperty()->getMaxValue())); angleWidget_->setAngle(static_cast<double>(getProperty()->get())); angleWidget_->blockSignals(false); } void onAngleChanged() { getProperty()->set(static_cast<T>(angleWidget_->getAngle())); } void onAngleMinMaxChanged() { getProperty()->setMinValue(static_cast<T>(angleWidget_->getMinAngle())); getProperty()->setMaxValue(static_cast<T>(angleWidget_->getMaxAngle())); } void setCurrentAsMin() { getProperty()->setMinValue(static_cast<T>(getProperty()->get())); } void setCurrentAsMax() { getProperty()->setMaxValue(static_cast<T>(getProperty()->get())); } void showSettings() { if (!this->settingsWidget_) { this->settingsWidget_ = new TemplatePropertySettingsWidgetQt<T, T>(getProperty(), this); } this->settingsWidget_->reload(); this->settingsWidget_->show(); } // Convenience function OrdinalProperty<T>* getProperty() { return static_cast<OrdinalProperty<T>*>(property_); } }; typedef AnglePropertyWidgetQt<float> FloatAnglePropertyWidgetQt; typedef AnglePropertyWidgetQt<double> DoubleAnglePropertyWidgetQt; } // namespace #endif // IVW_ANGLEPROPERTYWIDGETQT_H
/*! * \copy * Copyright (c) 2009-2013, Cisco Systems * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 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. * * * \file svc_set_mb_syn_cavlc.h * * \brief Seting all syntax elements of mb and decoding residual with cavlc * * \date 2009.8.12 Created * ************************************************************************************* */ #ifndef SVC_SET_MB_SYN_CAVLC_H_ #define SVC_SET_MB_SYN_CAVLC_H_ #include "typedefs.h" #include "wels_common_basis.h" #include "encoder_context.h" #include "md.h" #include "set_mb_syn_cavlc.h" namespace WelsEnc { int32_t WelsWriteMbResidual (SWelsFuncPtrList* pFuncList, SMbCache* sMbCacheInfo, SMB* pCurMb, SBitStringAux* pBs); void WelsSpatialWriteSubMbPred (sWelsEncCtx* pEncCtx, SSlice* pSlice, SMB* pCurMb); void WelsSpatialWriteMbPred (sWelsEncCtx* pEncCtx, SSlice* pSlice, SMB* pCurMb); //for Base Layer CAVLC writing int32_t WelsSpatialWriteMbSyn (sWelsEncCtx* pEncCtx, SSlice* pSlice, SMB* pCurMb); } #endif
#include <fatfs/fatfs.h> #include <base/kstd.h> #include <base/mem/alloc.h> unsigned fatfs_relclus_to_sect_fat32( fatfs_device_t *dev, unsigned cluster ){ //unsigned first_data_sector; unsigned first_sect; unsigned ret; // Return sector kprintf( "[%s] got here\n", __func__ ); first_sect = dev->bpb->reserved_sects + dev->bpb->fats * dev->fat32->sects_per_fat; //first_data_sector = (dev->fat32->root_clus - 2) * dev->bpb->sect_per_clus + first_sect; ret = (cluster - dev->fat32->root_clus) * dev->bpb->sect_per_clus + first_sect; /* ret = (cluster - root_cluster) * dev->bpb->sect_per_clus + first_data_sector; // Add sectors for the root directory ret += dev->bpb->dirents * 32 / dev->bpb->bytes_per_sect; */ return ret; } unsigned fatfs_relclus_to_sect_fat12_16( fatfs_device_t *dev, unsigned cluster ){ unsigned first_data_sector; unsigned root_cluster = 2; unsigned ret; // Return sector kprintf( "[%s] got here\n", __func__ ); first_data_sector = dev->bpb->reserved_sects + dev->bpb->fats * dev->bpb->sects_per_fat; if ( cluster > root_cluster ){ ret = (cluster - root_cluster) * dev->bpb->sect_per_clus + first_data_sector; // Add sectors for the root directory ret += dev->bpb->dirents * 32 / dev->bpb->bytes_per_sect; } else { // cluster given /is/ the root directory ret = first_data_sector; } return ret; } unsigned fatfs_relclus_to_sect( fatfs_device_t *dev, unsigned cluster ){ unsigned ret; switch ( dev->type ){ case FAT_TYPE_32: ret = fatfs_relclus_to_sect_fat32( dev, cluster ); break; default: ret = fatfs_relclus_to_sect_fat12_16( dev, cluster ); break; } return ret; } unsigned fatfs_get_next_cluster( fatfs_device_t *dev, unsigned cluster ){ //unsigned ret = FAT_CLUSTER_END; unsigned ret = 0xffffffff; kprintf( "[%s] got here, cluster: 0x%x\n", __func__, cluster ); switch( dev->type ){ case FAT_TYPE_12: ret = fatfs_get_next_cluster_fat12( dev, cluster ); break; case FAT_TYPE_16: ret = fatfs_get_next_cluster_fat16( dev, cluster ); break; case FAT_TYPE_32: ret = fatfs_get_next_cluster_fat32( dev, cluster ); break; default: break; } return ret; } unsigned fatfs_get_next_cluster_fat12( fatfs_device_t *dev, unsigned cluster ){ unsigned ret = 0; unsigned fat_offset; unsigned fat_sector; unsigned ent_offset; unsigned cluster_size; uint16_t table_value; uint8_t *fat_table; cluster_size = dev->bpb->bytes_per_sect * dev->bpb->sect_per_clus; fat_offset = cluster + (cluster / 2); fat_sector = dev->bpb->reserved_sects + (fat_offset / cluster_size); ent_offset = fat_offset % cluster_size; fat_table = knew( uint8_t[ cluster_size ]); VFS_FUNCTION(( &dev->device_node ), read, fat_table, cluster_size, fat_sector * dev->bpb->bytes_per_sect ); table_value = *(uint16_t *)(fat_table + ent_offset); if ( cluster & 1 ) ret = table_value >> 4; else ret = table_value & 0xfff; kfree( fat_table ); kprintf( "[%s] Have next cluster at 0x%x\n", __func__, ret ); return ret; } // TODO: unsigned fatfs_get_next_cluster_fat16( fatfs_device_t *dev, unsigned cluster ){ unsigned ret = 0; unsigned fat_offset; unsigned fat_sector; unsigned ent_offset; unsigned cluster_size; uint16_t table_value; uint8_t *fat_table; cluster_size = dev->bpb->bytes_per_sect * dev->bpb->sect_per_clus; fat_offset = cluster * 2; fat_sector = dev->bpb->reserved_sects + (fat_offset / cluster_size); ent_offset = fat_offset % cluster_size; fat_table = knew( uint8_t[ cluster_size ]); VFS_FUNCTION(( &dev->device_node ), read, fat_table, cluster_size, fat_sector * dev->bpb->bytes_per_sect ); table_value = *(uint16_t *)(fat_table + ent_offset); ret = table_value; kfree( fat_table ); kprintf( "[%s] Have next cluster at 0x%x\n", __func__, ret ); return ret; } // TODO: unsigned fatfs_get_next_cluster_fat32( fatfs_device_t *dev, unsigned cluster ){ unsigned ret = 0; unsigned fat_offset; unsigned fat_sector; unsigned ent_offset; unsigned cluster_size; uint16_t table_value; uint8_t *fat_table; cluster_size = dev->bpb->bytes_per_sect * dev->bpb->sect_per_clus; fat_offset = cluster * 4; fat_sector = dev->bpb->reserved_sects + (fat_offset / cluster_size); ent_offset = fat_offset % cluster_size; fat_table = knew( uint8_t[ cluster_size ]); VFS_FUNCTION(( &dev->device_node ), read, fat_table, cluster_size, fat_sector * dev->bpb->bytes_per_sect ); table_value = *(uint32_t *)(fat_table + ent_offset) & 0x0fffffff; ret = table_value; kfree( fat_table ); kprintf( "[%s] Have next cluster at 0x%x\n", __func__, ret ); return ret; /* kprintf( "[%s] Got here, probably an error\n", __func__ ); return ret; */ } bool is_last_cluster( fatfs_device_t *dev, unsigned cluster ){ kprintf( "[%s] fat type %d, cluster %d, got here\n", __func__, dev->type, cluster ); switch ( dev->type ){ case FAT_TYPE_12: return cluster >= FAT12_CLUSTER_BAD; break; case FAT_TYPE_16: return cluster >= FAT16_CLUSTER_BAD; break; case FAT_TYPE_32: return cluster >= FAT32_CLUSTER_BAD; break; default: kprintf( "[%s] unknown fatfs type %d, most definitely a bug\n", __func__, dev->type ); return true; } }
/* Copyright (c) 2014, x3x7apps(@gmail.com) 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. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _TR_H_ #define _TR_H_ #ifndef NDEBUG #include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <stdint.h> #include <stdarg.h> typedef struct { uint64_t _t0; uint32_t _khz; int _fd; int _on; } TR; static inline uint64_t rdtsc( void ) { uint32_t l, h; // return 0; asm volatile ( "cpuid\n rdtsc" // "rdtscp" : "=a"(l), "=d"(h) /* outputs */ : "a"(0) /* inputs */ : "%ebx", "%ecx"); /* clobbers*/ return ((uint64_t)l) | (((uint64_t)h) << 32); } static inline uint32_t tr_td( TR *t) { uint32_t v=(rdtsc()-t->_t0)/t->_khz; return v; } static inline void tr_init( TR *t, int fd, uint32_t mhz ) { t->_khz=mhz*1000; t->_fd=fd; t->_t0=rdtsc(); t->_on=1; } static inline void tr_t0( TR *t ){ t->_t0=rdtsc(); } static void tr_msg( TR *t, int ext, const char *file, int line, const char *fun, const char *fmt, ... ) __attribute__ ((__format__ (__printf__, 5, 0))); static inline void tr_msg( TR *t, int ext, const char *file, int line, const char *fun, const char *fmt, ... ) { if( t->_on ){ char buf[4*4096], *bufp=buf; bufp+=snprintf( bufp, sizeof(buf)-1, "[%c%5u %s:%d %s> ", ext?'!':'-', tr_td(t), file, line, fun ); va_list ap; va_start( ap, fmt ); bufp+=vsnprintf( bufp, sizeof(buf)-(bufp-buf)-1, fmt, ap ); va_end( ap ); bufp[0]='\n'; write( t->_fd, buf, bufp-buf+1 );// fsync( t->_fd ); } // if( ext ) abort(); if( ext ) exit(-1); } extern TR _tr; #define TR_INIT( fd, mhz ) __attribute__ ((__constructor__)) \ static void tr_setup(void) { tr_init(&_tr, fd, mhz);}\ TR _tr #define T0() tr_t0(&_tr) #define Toff() do{_tr._on=0;}while(0) #define Ton() do{_tr._on=1;}while(0) #ifndef __FUNCTION__ #define __FUNCTION__ __PRETTY_FUNCTION__ #endif #define T( ... ) tr_msg( &_tr, 0, __FILE__,__LINE__,__FUNCTION__, __VA_ARGS__ ) #define E( ... ) tr_msg( &_tr, 1, __FILE__,__LINE__,__FUNCTION__, __VA_ARGS__ ) #else #define T( ... ) #define E( ... ) exit(-1) #endif #endif
/*- * Copyright (c) 1988, 1993 * The Regents of the University of California. 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. * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. * * @(#)limits.h 8.3 (Berkeley) 1/4/94 * $FreeBSD: releng/10.2/sys/i386/include/limits.h 143063 2005-03-02 21:33:29Z joerg $ */ #ifndef _MACHINE_LIMITS_H_ #define _MACHINE_LIMITS_H_ #include <sys/cdefs.h> #ifdef __CC_SUPPORTS_WARNING #warning "machine/limits.h is deprecated. Include sys/limits.h instead." #endif #include <sys/limits.h> #endif /* !_MACHINE_LIMITS_H_ */
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved. #pragma once #include "IDocumentationModule.h" #include "IDocumentationPage.h" /** Invoked when someone clicks on a hyperlink. */ DECLARE_DELEGATE_OneParam( FOnNavigate, const FString& ) class FDocumentationStyle { public: FDocumentationStyle() : ContentStyleName(TEXT("Documentation.Content")) , BoldContentStyleName(TEXT("Documentation.BoldContent")) , NumberedContentStyleName(TEXT("Documentation.NumberedContent")) , Header1StyleName(TEXT("Documentation.Header1")) , Header2StyleName(TEXT("Documentation.Header2")) , HyperlinkStyleName(TEXT("Documentation.Hyperlink")) , HyperlinkButtonStyleName(TEXT("Documentation.Hyperlink.Button")) , HyperlinkTextStyleName(TEXT("Documentation.Hyperlink.Text")) , SeparatorStyleName(TEXT("Documentation.Separator")) { } /** Set the content style for this documentation */ FDocumentationStyle& ContentStyle(const FName& InName) { ContentStyleName = InName; return *this; } /** Set the bold content style for this documentation */ FDocumentationStyle& BoldContentStyle(const FName& InName) { BoldContentStyleName = InName; return *this; } /** Set the numbered content style for this documentation */ FDocumentationStyle& NumberedContentStyle(const FName& InName) { NumberedContentStyleName = InName; return *this; } /** Set the header 1 style for this documentation */ FDocumentationStyle& Header1Style(const FName& InName) { Header1StyleName = InName; return *this; } /** Set the header 2 style for this documentation */ FDocumentationStyle& Header2Style(const FName& InName) { Header2StyleName = InName; return *this; } /** Set the hyperlink button style for this documentation */ FDocumentationStyle& HyperlinkStyle(const FName& InName) { HyperlinkStyleName = InName; return *this; } /** Set the hyperlink button style for this documentation */ FDocumentationStyle& HyperlinkButtonStyle(const FName& InName) { HyperlinkButtonStyleName = InName; return *this; } /** Set the hyperlink text style for this documentation */ FDocumentationStyle& HyperlinkTextStyle(const FName& InName) { HyperlinkTextStyleName = InName; return *this; } /** Set the separator style for this documentation */ FDocumentationStyle& SeparatorStyle(const FName& InName) { SeparatorStyleName = InName; return *this; } /** Content text style */ FName ContentStyleName; /** Bold content text style */ FName BoldContentStyleName; /** Numbered content text style */ FName NumberedContentStyleName; /** Header1 text style */ FName Header1StyleName; /** Header2 text style */ FName Header2StyleName; /** Hyperlink style */ FName HyperlinkStyleName; /** Hyperlink button style */ FName HyperlinkButtonStyleName; /** Hyperlink text style */ FName HyperlinkTextStyleName; /** Separator style name */ FName SeparatorStyleName; }; class FParserConfiguration { public: static TSharedRef< FParserConfiguration > Create() { return MakeShareable( new FParserConfiguration() ); } public: ~FParserConfiguration() {} FOnNavigate OnNavigate; private: FParserConfiguration() {} }; struct FDocumentationSourceInfo { public: FString Source; FString Medium; FString Campaign; FDocumentationSourceInfo() {}; FDocumentationSourceInfo(FString const& InCampaign) : Source(TEXT("editor")), Medium(TEXT("docs")), Campaign(InCampaign) {}; FDocumentationSourceInfo(FString const& InSource, FString const& InMedium, FString const& InCampaign) : Source(InSource), Medium(InMedium), Campaign(InCampaign) {} /** Returns true if there is NO valid source info in the struct, false otherwise. */ bool IsEmpty() const { return Campaign.IsEmpty() && Source.IsEmpty() && Medium.IsEmpty(); } }; class IDocumentation { public: static inline TSharedRef< IDocumentation > Get() { IDocumentationModule& Module = FModuleManager::LoadModuleChecked< IDocumentationModule >( "Documentation" ); return Module.GetDocumentation(); } static inline bool IsAvailable() { return FModuleManager::Get().IsModuleLoaded( "Documentation" ); } public: virtual bool OpenHome(FDocumentationSourceInfo Source = FDocumentationSourceInfo()) const = 0; virtual bool OpenHome(const FCultureRef& Culture, FDocumentationSourceInfo Source = FDocumentationSourceInfo()) const = 0; virtual bool OpenAPIHome() const = 0; virtual bool CanOpenAPIHome() const = 0; virtual bool Open(const FString& Link, FDocumentationSourceInfo Source = FDocumentationSourceInfo()) const = 0; virtual bool Open(const FString& Link, const FCultureRef& Culture, FDocumentationSourceInfo Source = FDocumentationSourceInfo()) const = 0; virtual TSharedRef< class SWidget > CreateAnchor( const TAttribute<FString>& Link, const FString& PreviewLink = FString(), const FString& PreviewExcerptName = FString() ) const = 0; virtual TSharedRef< class IDocumentationPage > GetPage( const FString& Link, const TSharedPtr< FParserConfiguration >& Config, const FDocumentationStyle& Style = FDocumentationStyle() ) = 0; virtual bool PageExists(const FString& Link) const = 0; virtual bool PageExists(const FString& Link, const FCultureRef& Culture) const = 0; virtual TSharedRef< class SToolTip > CreateToolTip( const TAttribute<FText>& Text, const TSharedPtr<SWidget>& OverrideContent, const FString& Link, const FString& ExcerptName ) const = 0; virtual TSharedRef< class SToolTip > CreateToolTip(const TAttribute<FText>& Text, const TSharedRef<SWidget>& OverrideContent, const TSharedPtr<class SVerticalBox>& DocVerticalBox, const FString& Link, const FString& ExcerptName) const = 0; };
#pragma once #include "cinder/app/AppNative.h" #include "chronotext/cinder/CinderSketch.h" #include "chronotext/utils/accel/AccelEvent.h" class CinderApp : public ci::app::AppNative { int startCount; int updateCount; int ticks; double t0; double elapsed; void start(); void stop(); char needDraw; public: CinderSketch *sketch; CinderApp() : startCount(0), updateCount(0), needDraw(-1) {} void setup(); void shutdown(); void resize(); void update(); void draw(); void mouseDown(ci::app::MouseEvent event); void mouseUp(ci::app::MouseEvent event); void mouseDrag(ci::app::MouseEvent event); void touchesBegan(ci::app::TouchEvent event); void touchesMoved(ci::app::TouchEvent event); void touchesEnded(ci::app::TouchEvent event); void accelerated(AccelEvent event); #if defined(CINDER_ANDROID) void pause(); void resume(bool renewContext); #endif virtual void receiveMessageFromSketch(int what, const std::string &body) {} void sendMessageToSketch(int what, const std::string &body); void requestDraw() {needDraw = 1;} };
#import <UIKit/UIKit.h> #import "TTKeyboardphobia.h" #import "UIView+TTViewKeyboardAnimation.h" FOUNDATION_EXPORT double TTKeyboardphobiaVersionNumber; FOUNDATION_EXPORT const unsigned char TTKeyboardphobiaVersionString[];
/* $NetBSD: elf_machdep.h,v 1.1 2000/08/12 22:58:16 wdk Exp $ */ #include <mips/elf_machdep.h> #define ELF32_MACHDEP_ENDIANNESS ELFDATA2MSB #define ELF64_MACHDEP_ENDIANNESS XXX /* break compilation */
// © 2015 Massachusetts Institute of Technology #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <netdb.h> #include <errno.h> #include <math.h> #include <netax25/ax25.h> #include <netax25/axlib.h> #include <netax25/axconfig.h> #define BUFSIZE 512 #define HEADSIZE 5 //must match HEADFORMAT #define HEADFORMAT "%05u" void error(const char *msg) { perror(msg); exit(1); } int send_ax25_packet(char* port, char* dest_call, char* message) { struct full_sockaddr_ax25 sockaddr; int addrlen = sizeof(struct full_sockaddr_ax25); //create the AX25 socket int sockfd = socket(AF_AX25, SOCK_SEQPACKET, 0); if (sockfd < 0) { error("ERROR opening socket"); } //need to call ax25_config_load_ports() before any other config calls if (ax25_config_load_ports() == 0) { error("ERROR loading axports file"); } //get our own call sign assigned to the port char* src_call = ax25_config_get_addr(port); if (src_call == NULL) { error("Could not find address on specified port"); } //get the AX25 packet length set in /etc/ax25/axports int paclen = ax25_config_get_paclen(port); fprintf(stdout, " %s calling %s... ", src_call, dest_call); fflush(stdout); //specify the callsign to which we want to connect bzero((char *) &sockaddr, sizeof(sockaddr)); ax25_aton(dest_call, &sockaddr); //connect to the specified address, keep trying if busy int status; while (status = connect(sockfd,(struct sockaddr *) &sockaddr, sizeof(sockaddr)) < 0){ fprintf(stdout, " busy, waiting to connect..."); fflush(stdout); sleep(2); } printf(" connected... "); //printf("Sending %u byte message: %s...", (unsigned int) strlen(message), message); fflush(stdout); //generate header: the length of data in bytes is encoded as // a decimal number with HEADSIZE ASCII chars size_t bytes = strlen(message); int max_msg_size = (int) (pow(10, HEADSIZE)-1); if (bytes < max_msg_size) { char header[HEADSIZE+1]; snprintf(header, HEADSIZE+1, HEADFORMAT, (unsigned int) bytes); int head_written = write(sockfd, header, strlen(header)); //printf(" header: %s ", header); } else { error("Message to long"); } //fragment packet if necessary int offset = 0; while (offset != bytes) { int len = (bytes - offset > paclen) ? paclen : bytes - offset; int written = write(sockfd, message+offset, len); //printf(" %d bytes written...", written); if (written == 0) { printf(" no data written... "); break; } if (written == -1) { error("Error on write"); } offset += written; } printf(" data sent... "); fflush(stdout); char read_buf[HEADSIZE+1]; bzero(read_buf,HEADSIZE+1); int read_cnt = read(sockfd,read_buf,HEADSIZE); //Could block a while if (read_cnt < 0) { error("ERROR reading from socket in client"); } //test that the response shows the correct number of bytes were received if (bytes != atoi(read_buf) ) { error("ERROR: Data transfer incomplete"); } //printf("%s...",read_buf); printf("response received... "); fflush(stdout); close(sockfd); printf("connection closed\n"); return 0; } int main(int argc, char *argv[]) { //char* port = "radio"; if (argc < 4) { fprintf(stderr,"usage %s <port> <dest_callsign> <message>\n", argv[0]); exit(1); } char *port = argv[1]; char *dest_call = argv[2]; char *message = argv[3]; int result = send_ax25_packet(port, dest_call, message); return result; }
// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef ANDROID_WEBVIEW_BROWSER_AW_DOWNLOAD_MANAGER_DELEGATE_H_ #define ANDROID_WEBVIEW_BROWSER_AW_DOWNLOAD_MANAGER_DELEGATE_H_ #include <string> #include "base/macros.h" #include "base/supports_user_data.h" #include "content/public/browser/download_manager_delegate.h" namespace content { class WebContents; } // namespace content namespace android_webview { // Android WebView does not use Chromium downloads, so implement methods here to // unconditionally cancel the download. class AwDownloadManagerDelegate : public content::DownloadManagerDelegate, public base::SupportsUserData::Data { public: AwDownloadManagerDelegate(); ~AwDownloadManagerDelegate() override; // content::DownloadManagerDelegate implementation. bool InterceptDownloadIfApplicable( const GURL& url, const std::string& user_agent, const std::string& content_disposition, const std::string& mime_type, const std::string& request_origin, int64_t content_length, bool is_transient, content::WebContents* web_contents) override; private: DISALLOW_COPY_AND_ASSIGN(AwDownloadManagerDelegate); }; } // namespace android_webview #endif // ANDROID_WEBVIEW_BROWSER_AW_DOWNLOAD_MANAGER_DELEGATE_H_
/****************************************************************************** ** ** Copyright (C) 2009-2011 Kyle Lutz <kyle.r.lutz@gmail.com> ** All rights reserved. ** ** This file is a part of the chemkit project. For more information ** see <http://www.chemkit.org>. ** ** Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions ** are met: ** ** * Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** * Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in the ** documentation and/or other materials provided with the distribution. ** * Neither the name of the chemkit 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 COPYRIGHT HOLDERS AND CONTRIBUTORS ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ** ******************************************************************************/ #ifndef UFFCALCULATION_H #define UFFCALCULATION_H #include <chemkit/forcefieldcalculation.h> #include "uffparameters.h" class UffCalculation : public chemkit::ForceFieldCalculation { public: UffCalculation(int type, int atomCount, int parameterCount); virtual bool setup() = 0; protected: chemkit::Real bondOrder(size_t a, size_t b) const; chemkit::Real bondLength(const UffAtomParameters *a, const UffAtomParameters *b, chemkit::Real bondOrder) const; const UffAtomParameters* parameters(const std::string &type) const; }; class UffBondStrechCalculation : public UffCalculation { public: UffBondStrechCalculation(size_t a, size_t b); bool setup(); chemkit::Real energy(const chemkit::CartesianCoordinates *coordinates) const CHEMKIT_OVERRIDE; std::vector<chemkit::Vector3> gradient(const chemkit::CartesianCoordinates *coordinates) const CHEMKIT_OVERRIDE; }; class UffAngleBendCalculation : public UffCalculation { public: UffAngleBendCalculation(size_t a, size_t b, size_t c); bool setup(); chemkit::Real energy(const chemkit::CartesianCoordinates *coordinates) const CHEMKIT_OVERRIDE; std::vector<chemkit::Vector3> gradient(const chemkit::CartesianCoordinates *coordinates) const CHEMKIT_OVERRIDE; }; class UffTorsionCalculation : public UffCalculation { public: UffTorsionCalculation(size_t a, size_t b, size_t c, size_t d); bool setup(); chemkit::Real energy(const chemkit::CartesianCoordinates *coordinates) const CHEMKIT_OVERRIDE; std::vector<chemkit::Vector3> gradient(const chemkit::CartesianCoordinates *coordinates) const CHEMKIT_OVERRIDE; }; class UffInversionCalculation : public UffCalculation { public: UffInversionCalculation(size_t a, size_t b, size_t c, size_t d); bool setup(); chemkit::Real energy(const chemkit::CartesianCoordinates *coordinates) const CHEMKIT_OVERRIDE; std::vector<chemkit::Vector3> gradient(const chemkit::CartesianCoordinates *coordinates) const CHEMKIT_OVERRIDE; }; class UffVanDerWaalsCalculation : public UffCalculation { public: UffVanDerWaalsCalculation(size_t a, size_t b); bool setup(); chemkit::Real energy(const chemkit::CartesianCoordinates *coordinates) const CHEMKIT_OVERRIDE; std::vector<chemkit::Vector3> gradient(const chemkit::CartesianCoordinates *coordinates) const CHEMKIT_OVERRIDE; }; class UffElectrostaticCalculation : public UffCalculation { public: UffElectrostaticCalculation(size_t a, size_t b); bool setup(); chemkit::Real energy(const chemkit::CartesianCoordinates *coordinates) const CHEMKIT_OVERRIDE; }; #endif // UFFCALCULATION_H
/* * Copyright (C) 2010 Apple Inc. All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. * */ #ifndef HashChangeEvent_h #define HashChangeEvent_h #include "Event.h" #include "EventNames.h" namespace WebCore { struct HashChangeEventInit : public EventInit { HashChangeEventInit() { }; String oldURL; String newURL; }; class HashChangeEvent : public Event { public: static PassRefPtr<HashChangeEvent> create() { return adoptRef(new HashChangeEvent); } static PassRefPtr<HashChangeEvent> create(const String& oldURL, const String& newURL) { return adoptRef(new HashChangeEvent(oldURL, newURL)); } static PassRefPtr<HashChangeEvent> create(const AtomicString& type, const HashChangeEventInit& initializer) { return adoptRef(new HashChangeEvent(type, initializer)); } void initHashChangeEvent(const AtomicString& eventType, bool canBubble, bool cancelable, const String& oldURL, const String& newURL) { if (dispatched()) return; initEvent(eventType, canBubble, cancelable); m_oldURL = oldURL; m_newURL = newURL; } const String& oldURL() const { return m_oldURL; } const String& newURL() const { return m_newURL; } virtual EventInterface eventInterface() const { return HashChangeEventInterfaceType; } private: HashChangeEvent() { } HashChangeEvent(const String& oldURL, const String& newURL) : Event(eventNames().hashchangeEvent, false, false) , m_oldURL(oldURL) , m_newURL(newURL) { } HashChangeEvent(const AtomicString& type, const HashChangeEventInit& initializer) : Event(type, initializer) , m_oldURL(initializer.oldURL) , m_newURL(initializer.newURL) { } String m_oldURL; String m_newURL; }; } // namespace WebCore #endif // HashChangeEvent_h
/* * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ #pragma once #include <ABI41_0_0React/components/view/ConcreteViewShadowNode.h> #include <ABI41_0_0React/components/view/ViewProps.h> namespace ABI41_0_0facebook { namespace ABI41_0_0React { extern const char ViewComponentName[]; /* * `ShadowNode` for <View> component. */ class ViewShadowNode final : public ConcreteViewShadowNode< ViewComponentName, ViewProps, ViewEventEmitter> { public: ViewShadowNode( ShadowNodeFragment const &fragment, ShadowNodeFamily::Shared const &family, ShadowNodeTraits traits); ViewShadowNode( ShadowNode const &sourceShadowNode, ShadowNodeFragment const &fragment); private: void initialize() noexcept; }; } // namespace ABI41_0_0React } // namespace ABI41_0_0facebook
#import <ABI43_0_0React/ABI43_0_0UIView+React.h> #import <CoreText/CoreText.h> #import "ABI43_0_0RNSVGFontData.h" @class ABI43_0_0RNSVGText; @class ABI43_0_0RNSVGGroup; @class ABI43_0_0RNSVGGlyphContext; @interface ABI43_0_0RNSVGGlyphContext : NSObject - (CTFontRef)getGlyphFont; - (instancetype)initWithWidth:(CGFloat)width height:(CGFloat)height; - (ABI43_0_0RNSVGFontData *)getFont; - (CGFloat)getFontSize; - (CGFloat)getHeight; - (CGFloat)getWidth; - (CGFloat)nextDeltaX; - (CGFloat)nextDeltaY; - (CGFloat)nextRotation; - (CGFloat)nextXWithDouble:(CGFloat)advance; - (CGFloat)nextY; - (void)popContext; - (void)pushContext:(ABI43_0_0RNSVGText*)node font:(NSDictionary*)font x:(NSArray<ABI43_0_0RNSVGLength*>*)x y:(NSArray<ABI43_0_0RNSVGLength*>*)y deltaX:(NSArray<ABI43_0_0RNSVGLength*>*)deltaX deltaY:(NSArray<ABI43_0_0RNSVGLength*>*)deltaY rotate:(NSArray<ABI43_0_0RNSVGLength*>*)rotate; - (void)pushContext:(ABI43_0_0RNSVGGroup*)node font:(NSDictionary *)font; - (NSArray*)getFontContext; @end
/* * Written by J.T. Conklin, Apr 6, 1995 * Public domain. */ #ifndef _MACHINE_IEEEFP_H_ #define _MACHINE_IEEEFP_H_ typedef int fp_except; #define FP_X_IMP 0x01 /* imprecise (loss of precision) */ #define FP_X_DZ 0x02 /* divide-by-zero exception */ #define FP_X_UFL 0x04 /* underflow exception */ #define FP_X_OFL 0x08 /* overflow exception */ #define FP_X_INV 0x10 /* invalid operation exception */ typedef enum { FP_RN=0, /* round to nearest representable number */ FP_RZ=1, /* round to zero (truncate) */ FP_RM=2, /* round toward negative infinity */ FP_RP=3 /* round toward positive infinity */ } fp_rnd; #endif /* _MACHINE_IEEEFP_H_ */
/* Copyright (c) 2010-2016, Mathieu Labbe - IntRoLab - Universite de Sherbrooke All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the Universite de Sherbrooke nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef PREFERENCESDIALOGROS_H_ #define PREFERENCESDIALOGROS_H_ #include <ros/ros.h> #include <rtabmap/gui/PreferencesDialog.h> using namespace rtabmap; class PreferencesDialogROS : public PreferencesDialog { public: PreferencesDialogROS(const QString & configFile, const std::string & rtabmapNodeName); virtual ~PreferencesDialogROS(); virtual QString getIniFilePath() const; virtual QString getTmpIniFilePath() const; bool hasAllParameters(); public slots: void readRtabmapNodeParameters(); protected: virtual QString getParamMessage(); bool hasAllParameters(const ros::NodeHandle & nh, const rtabmap::ParametersMap & parameters); virtual void readCameraSettings(const QString & filePath); virtual bool readCoreSettings(const QString & filePath); virtual void writeCameraSettings(const QString & filePath) const {} virtual void writeCoreSettings(const QString & filePath) const; private: QString configFile_; std::string rtabmapNodeName_; }; #endif /* PREFERENCESDIALOGROS_H_ */
/* * Copyright (c) 2019, The OpenThread Authors. * 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 copyright holder nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #ifndef SAMR21_MBEDTLS_CONFIG_H #define SAMR21_MBEDTLS_CONFIG_H /** * \def MBEDTLS_AES_ALT * * Enable hardware acceleration for the AES block cipher * * Module: sl_crypto/src/sl_aes.c * or * sl_crypto/src/slcl_aes.c if MBEDTLS_SLCL_PLUGINS is defined. * * See MBEDTLS_AES_C for more information. */ #define MBEDTLS_AES_ALT #define MBEDTLS_CTR_DRBG_USE_128_BIT_KEY #endif // SAMR21_MBEDTLS_CONFIG_H
// // Created by Leland Richardson on 12/27/15. // Copyright (c) 2015 Facebook. All rights reserved. // #import <ABI41_0_0React/ABI41_0_0RCTViewManager.h> @interface ABI41_0_0AIRMapCircleManager : ABI41_0_0RCTViewManager @end
// ============================================================================ // // Copyright (c) 1999 The CGAL Consortium // // // // // // ---------------------------------------------------------------------------- // release : // release_date : // // file : ch__test.h // revision : $Id$ // revision_date : $Date$ // author(s) : Stefan Schirra // // coordinator : MPI, Saarbruecken // ============================================================================ #ifndef CGAL_CH__TEST_H #define CGAL_CH__TEST_H #include <CGAL/convex_hull_2.h> #include <CGAL/convexity_check_2.h> #include <CGAL/ch_akl_toussaint.h> #include <CGAL/ch_graham_andrew.h> #include <CGAL/ch_eddy.h> #include <CGAL/ch_bykat.h> #include <CGAL/ch_jarvis.h> namespace CGAL { enum ch_Algorithm{ ch_JARVIS, ch_GRAHAM_ANDREW, ch_EDDY, ch_BYKAT, ch_BYKAT_WITH_THRESHOLD, ch_LOWER_UPPER, ch_AKL_TOUSSAINT, ch_ALL, ch_DEFAULT }; enum ch_Check_status{ ch_CHECK_ALL, ch_CHECK_CONVEXITY, ch_CHECK_CONTAINEMENT, ch_NO_CHECK }; template <class InputIterator, class Traits> bool ch__test(InputIterator first, InputIterator last, const Traits& ch_traits, ch_Algorithm alg, ch_Check_status check_level); template <class InputIterator, class Traits> bool ch__test(InputIterator first, InputIterator last, const Traits& ch_traits, ch_Algorithm alg); template <class InputIterator, class Traits> bool ch__test(InputIterator first, InputIterator last, const Traits& ch_traits); } //namespace CGAL #include <CGAL/ch__test_impl.h> #endif // CGAL_CH__TEST_H
/* * Copyright © 2009 CNRS * Copyright © 2009-2010 INRIA. All rights reserved. * Copyright © 2009, 2011 Université Bordeaux 1 * Copyright © 2011 Cisco Systems, Inc. All rights reserved. * See COPYING in top-level directory. */ /* The configuration file */ #ifndef HWLOC_DEBUG_H #define HWLOC_DEBUG_H #include <private/autogen/config.h> #ifdef HWLOC_DEBUG #include <stdarg.h> #include <stdio.h> #endif static __hwloc_inline void hwloc_debug(const char *s __hwloc_attribute_unused, ...) { #ifdef HWLOC_DEBUG va_list ap; va_start(ap, s); vfprintf(stderr, s, ap); va_end(ap); #endif } #ifdef HWLOC_DEBUG #define hwloc_debug_bitmap(fmt, bitmap) do { \ char *s= hwloc_bitmap_printf_value(bitmap); \ fprintf(stderr, fmt, s); \ free(s); \ } while (0) #define hwloc_debug_1arg_bitmap(fmt, arg1, bitmap) do { \ char *s= hwloc_bitmap_printf_value(bitmap); \ fprintf(stderr, fmt, arg1, s); \ free(s); \ } while (0) #define hwloc_debug_2args_bitmap(fmt, arg1, arg2, bitmap) do { \ char *s= hwloc_bitmap_printf_value(bitmap); \ fprintf(stderr, fmt, arg1, arg2, s); \ free(s); \ } while (0) #else #define hwloc_debug_bitmap(s, bitmap) do { } while(0) #define hwloc_debug_1arg_bitmap(s, arg1, bitmap) do { } while(0) #define hwloc_debug_2args_bitmap(s, arg1, arg2, bitmap) do { } while(0) #endif #endif /* HWLOC_DEBUG_H */
#pragma once #include "core/node.h" // Dot Parametric Rectifier Unit class DeepFlowDllExport DPRelu : public Node { public: DPRelu(deepflow::NodeParam *param); int minNumInputs() override { return 2; } int minNumOutputs() override { return 1; } std::string op_name() const override { return "dprelu"; } void init() override; void forward() override; void backward() override; std::string to_cpp() const override; };
#include "espresso.h" #include <stdio.h> static void dump_irredundant(pset_family E, pset_family Rt, pset_family Rp, sm_matrix *table); static pcover do_minimize(pset_family F, pset_family D, pset_family R, int exact_cover, int weighted); /* * minimize_exact -- main entry point for exact minimization * * Global flags which affect this routine are: * * debug * skip_make_sparse */ pcover minimize_exact(pset_family F, pset_family D, pset_family R, int exact_cover) { return do_minimize(F, D, R, exact_cover, /*weighted*/ 0); } pcover minimize_exact_literals(pset_family F, pset_family D, pset_family R, int exact_cover) { return do_minimize(F, D, R, exact_cover, /*weighted*/ 1); } static pcover do_minimize(pset_family F, pset_family D, pset_family R, int exact_cover, int weighted) { pcover newF, E, Rt, Rp; pset p, last; int heur, level, *weights; sm_matrix *table; sm_row *cover; sm_element *pe; int debug_save = debug; if (debug & EXACT) { debug |= (IRRED | MINCOV); } #if defined(sun) || defined(bsd4_2) /* hack ... */ if (debug & MINCOV) { // setlinebuf(stdout); } #endif level = (debug & MINCOV) ? 4 : 0; heur = ! exact_cover; /* Generate all prime implicants */ EXEC(F = primes_consensus(cube2list(F, D)), "PRIMES ", F); /* Setup the prime implicant table */ EXEC(irred_split_cover(F, D, &E, &Rt, &Rp), "ESSENTIALS ", E); EXEC(table = irred_derive_table(D, E, Rp), "PI-TABLE ", Rp); /* Solve either a weighted or nonweighted covering problem */ if (weighted) { /* correct only for all 2-valued variables */ weights = ALLOC(int, F->count); foreach_set(Rp, last, p) { weights[ESIZE(p)] = cube.size - set_ord(p); } } else { weights = NIL(int); } EXEC(cover=sm_minimum_cover(table,weights,heur,level), "MINCOV ", F); if (weights != 0) { FREE(weights); } if (debug & EXACT) { dump_irredundant(E, Rt, Rp, table); } /* Form the result cover */ newF = new_cover(100); foreach_set(E, last, p) { newF = sf_addset(newF, p); } sm_foreach_row_element(cover, pe) { newF = sf_addset(newF, GETSET(F, pe->col_num)); } free_cover(E); free_cover(Rt); free_cover(Rp); sm_free(table); sm_row_free(cover); free_cover(F); /* Attempt to make the results more sparse */ debug &= ~ (IRRED | SHARP | MINCOV); if (! skip_make_sparse && R != 0) { newF = make_sparse(newF, D, R); } debug = debug_save; return newF; } static void dump_irredundant(pset_family E, pset_family Rt, pset_family Rp, sm_matrix *table) { FILE *fp_pi_table, *fp_primes; pPLA PLA; pset last, p; char *file; if (filename == 0 || strcmp(filename, "(stdin)") == 0) { fp_pi_table = fp_primes = stdout; } else { file = ALLOC(char, strlen(filename)+20); (void) sprintf(file, "%s.primes", filename); if ((fp_primes = fopen(file, "w")) == NULL) { fprintf(stderr, "espresso: Unable to open %s\n", file); fp_primes = stdout; } (void) sprintf(file, "%s.pi", filename); if ((fp_pi_table = fopen(file, "w")) == NULL) { fprintf(stderr, "espresso: Unable to open %s\n", file); fp_pi_table = stdout; } FREE(file); } PLA = new_PLA(); PLA_labels(PLA); fpr_header(fp_primes, PLA, F_type); free_PLA(PLA); (void) fprintf(fp_primes, "# Essential primes are\n"); foreach_set(E, last, p) { (void) fprintf(fp_primes, "%s\n", pc1(p)); } fprintf(fp_primes, "# Totally redundant primes are\n"); foreach_set(Rt, last, p) { (void) fprintf(fp_primes, "%s\n", pc1(p)); } fprintf(fp_primes, "# Partially redundant primes are\n"); foreach_set(Rp, last, p) { (void) fprintf(fp_primes, "%s\n", pc1(p)); } if (fp_primes != stdout) { (void) fclose(fp_primes); } sm_write(fp_pi_table, table); if (fp_pi_table != stdout) { (void) fclose(fp_pi_table); } }
/************************************************ ast.h - $Author: wzq $ $Date: 2014/04/08 $ Copyright (C) 2014 Zheqin Wang ************************************************/ #ifndef AST_H #define AST_H #include "daim.h" enum dm_node_type { nd_kAssign = 1, nd_KAddAssign, nd_kSubAssign, nd_kMulAssign, nd_kDivAssign, nd_kAnd, nd_kOr, nd_kEq, nd_kNe, nd_kGt, nd_kLt, nd_kGE, nd_kLE, nd_kPlus, nd_kMinus, nd_kMul, nd_kDiv, nd_kMod, nd_kNot, nd_kNext, nd_kBreak, nd_kReturn, nd_kTrue, nd_kFalse, nd_kNil, nd_kIf, nd_kElsif, nd_kLoop, nd_func_def, nd_func_call, nd_param_list, nd_sym_id, nd_stmt_list, nd_stmt, nd_expr_list, nd_expr, nd_str_val, nd_int_val, nd_double_val, nd_arg_list }; struct DmNode { DM_ULONG flag; DM_USHORT lineno; union { DM_ULONG ul_val; int int_val; char* str_val; struct DmNode* node; } m1; union { struct DmNode* node; struct DmNodeList* list; } m2; }; typedef struct DmNode DmNode; struct DmNodeList { DM_USHORT bin_num; DmNode** node_bin; }; typedef struct DmNodeList DmNodeList; //=========0x----xx--============== //These 8 bits flag determin the dm_node_type #define DM_TYPE_WIDTH 8 #define DM_NODE_TYPE_MASK 0xffff00ff #define DM_NODE_TYPE(nd) ((((DmNode*)(nd))->flag>>DM_INT_TYPE_WIDTH) & 0xff) #define m_nd_param_name m1.str_val #define m_nd_param_next m2.node #define m_nd_func_name m1.str_val #define m_nd_func_body m2.list #define m_nd_func_param_list node_bin[0] #define m_nd_func_stmt_list node_bin[1] #define m_nd_id_name m1.str_val #define m_nd_int_val m1.int_val #define m_nd_double_val m1.str_val #define m_nd_const_val m1.ul_val #define m_nd_arg_node m1.node #define m_nd_func_arg_list m1.node #define m_nd_unary_node m1.node #define m_nd_left_node m1.node #define m_nd_right_node m2.node #define m_nd_if_cond m1.node #define m_nd_if_block m2.list #define m_nd_if_node node_bin[0] #define m_nd_else_node node_bin[1] #define m_nd_elsif_node node_bin[2] #define m_nd_last_else_node node_bin[3] #define m_nd_elsif_cond m1.node #define m_nd_elsif_stmt m2.node #define m_nd_iter_cond m1.node #define m_nd_iter_stmt m2.node #define m_nd_assign_id m1.node #define m_nd_assign_expr m2.node #define m_nd_expr_node m1.node #define m_nd_link_list m1.node #define m_nd_link_next m2.node inline void set_node_type(DmNode*, enum dm_node_type); inline void set_node_lineno(DmNode*, DM_USHORT); inline DmNode* dm_create_node(enum dm_node_type, DM_USHORT ); DmNode* dm_create_param_node(char* str_val, DM_USHORT); DmNode* dm_link_param_node(DmNode* node_hd, char* str_val, DM_USHORT); DmNode* dm_create_func_def_node(char* func_name, DmNode* parm_list, DmNode* stmt_list, DM_USHORT); DmNode* dm_create_or_find_id_node(char* str_val, DM_USHORT); DmNode* dm_find_id_node(char* str_val); DmNode* dm_create_int_node(int val, DM_USHORT); DmNode* dm_create_double_node(char* double_val, DM_USHORT); DmNode* dm_const_node(enum dm_node_type, DM_USHORT); DmNode* dm_create_arg_list(DmNode* expr, DM_USHORT); DmNode* dm_link_node_list(DmNode* arg_list, DmNode* expr); DmNode* dm_create_func_call_node(char* func_name, DmNode* arg_list, DM_USHORT); DmNode* dm_create_unary_node(enum dm_node_type type, DmNode* unary_expr, DM_USHORT); DmNode* dm_create_binary_node(enum dm_node_type type, DmNode* left, DmNode* right, DM_USHORT); DmNode* dm_create_selection_node(DmNode* condition, DmNode* if_stmt, DmNode* else_stmt, DmNode* elsif_stmt, DmNode* last_else_stmt, DM_USHORT); DmNode* dm_create_elsif_node(DmNode* condition, DmNode* stmt, DM_USHORT); DmNode* dm_create_iter_node(DmNode* condition, DmNode* stmt_list, DM_USHORT); DmNode* dm_create_assign_node(char* id_name, DM_ULONG assign_op, DmNode* expr_node, DM_USHORT); #endif
#include <stdlib.h> #include <stdio.h> static void exit1() { exit(34); } int main() { atexit(exit1); abort(); }
// // SDLPhoneCapability.h // SmartDeviceLink-iOS // // Created by Joel Fischer on 7/11/17. // Copyright © 2017 smartdevicelink. All rights reserved. // #import "SDLRPCStruct.h" NS_ASSUME_NONNULL_BEGIN /** Extended capabilities of the module's phone feature */ @interface SDLPhoneCapability : SDLRPCStruct /// Convenience init for defining the phone capability /// /// @param dialNumberEnabled Whether or not the DialNumber RPC is enabled. /// @return An SDLPhoneCapability object - (instancetype)initWithDialNumber:(BOOL)dialNumberEnabled; /** Whether or not the DialNumber RPC is enabled. Boolean, optional */ @property (nullable, strong, nonatomic) NSNumber *dialNumberEnabled; @end NS_ASSUME_NONNULL_END
/* * Copyright (c) 2010,2011,2012,2014,2015 Apple Inc. All rights reserved. * * corecrypto Internal Use License Agreement * * IMPORTANT: This Apple corecrypto software is supplied to you by Apple Inc. ("Apple") * in consideration of your agreement to the following terms, and your download or use * of this Apple software constitutes acceptance of these terms. If you do not agree * with these terms, please do not download or use this Apple software. * * 1. As used in this Agreement, the term "Apple Software" collectively means and * includes all of the Apple corecrypto materials provided by Apple here, including * but not limited to the Apple corecrypto software, frameworks, libraries, documentation * and other Apple-created materials. In consideration of your agreement to abide by the * following terms, conditioned upon your compliance with these terms and subject to * these terms, Apple grants you, for a period of ninety (90) days from the date you * download the Apple Software, a limited, non-exclusive, non-sublicensable license * under Apple’s copyrights in the Apple Software to make a reasonable number of copies * of, compile, and run the Apple Software internally within your organization only on * devices and computers you own or control, for the sole purpose of verifying the * security characteristics and correct functioning of the Apple Software; provided * that you must retain this notice and the following text and disclaimers in all * copies of the Apple Software that you make. You may not, directly or indirectly, * redistribute the Apple Software or any portions thereof. The Apple Software is only * licensed and intended for use as expressly stated above and may not be used for other * purposes or in other contexts without Apple's prior written permission. Except as * expressly stated in this notice, no other rights or licenses, express or implied, are * granted by Apple herein. * * 2. The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO * WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES * OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING * THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS, * SYSTEMS, OR SERVICES. APPLE DOES NOT WARRANT THAT THE APPLE SOFTWARE WILL MEET YOUR * REQUIREMENTS, THAT THE OPERATION OF THE APPLE SOFTWARE WILL BE UNINTERRUPTED OR * ERROR-FREE, THAT DEFECTS IN THE APPLE SOFTWARE WILL BE CORRECTED, OR THAT THE APPLE * SOFTWARE WILL BE COMPATIBLE WITH FUTURE APPLE PRODUCTS, SOFTWARE OR SERVICES. NO ORAL * OR WRITTEN INFORMATION OR ADVICE GIVEN BY APPLE OR AN APPLE AUTHORIZED REPRESENTATIVE * WILL CREATE A WARRANTY. * * 3. IN NO EVENT SHALL APPLE BE LIABLE FOR ANY DIRECT, SPECIAL, INDIRECT, INCIDENTAL * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING * IN ANY WAY OUT OF THE USE, REPRODUCTION, COMPILATION OR OPERATION OF THE APPLE * SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING * NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * 4. This Agreement is effective until terminated. Your rights under this Agreement will * terminate automatically without notice from Apple if you fail to comply with any term(s) * of this Agreement. Upon termination, you agree to cease all use of the Apple Software * and destroy all copies, full or partial, of the Apple Software. This Agreement will be * governed and construed in accordance with the laws of the State of California, without * regard to its choice of law rules. * * You may report security issues about Apple products to product-security@apple.com, * as described here:  https://www.apple.com/support/security/. Non-security bugs and * enhancement requests can be made via https://bugreport.apple.com as described * here: https://developer.apple.com/bug-reporting/ * * EA1350 * 10/5/15 */ #include <corecrypto/ccn.h> #include <corecrypto/cc_debug.h> #if 0 void ccn_print_r(cc_size count, const cc_unit *s, cc_size radix) { cc_size bits = (count * sizeof(cc_unit) * 8); uint8_t buf[bits]; for (cc_size ix = 0; ix < count; ++ix) { cc_unit v = s[ix]; } } #endif void ccn_print(cc_size count, const cc_unit *s) { for (cc_size ix = count; ix--;) { cc_printf("%" CCPRIx_UNIT, s[ix]); } } void ccn_lprint(cc_size count, const char *label, const cc_unit *s) { cc_printf("%s", label); ccn_print(count, s); cc_printf("\n"); }
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE401_Memory_Leak__char_realloc_52a.c Label Definition File: CWE401_Memory_Leak.c.label.xml Template File: sources-sinks-52a.tmpl.c */ /* * @description * CWE: 401 Memory Leak * BadSource: realloc Allocate data using realloc() * GoodSource: Allocate data on the stack * Sinks: * GoodSink: call free() on data * BadSink : no deallocation of data * Flow Variant: 52 Data flow: data passed as an argument from one function to another to another in three different source files * * */ #include "std_testcase.h" #include <wchar.h> #ifndef OMITBAD /* bad function declaration */ void CWE401_Memory_Leak__char_realloc_52b_badSink(char * data); void CWE401_Memory_Leak__char_realloc_52_bad() { char * data; data = NULL; /* POTENTIAL FLAW: Allocate memory on the heap */ data = (char *)realloc(data, 100*sizeof(char)); if (data == NULL) {exit(-1);} /* Initialize and make use of data */ strcpy(data, "A String"); printLine(data); CWE401_Memory_Leak__char_realloc_52b_badSink(data); } #endif /* OMITBAD */ #ifndef OMITGOOD /* goodG2B uses the GoodSource with the BadSink */ void CWE401_Memory_Leak__char_realloc_52b_goodG2BSink(char * data); static void goodG2B() { char * data; data = NULL; /* FIX: Use memory allocated on the stack with ALLOCA */ data = (char *)ALLOCA(100*sizeof(char)); /* Initialize and make use of data */ strcpy(data, "A String"); printLine(data); CWE401_Memory_Leak__char_realloc_52b_goodG2BSink(data); } /* goodB2G uses the BadSource with the GoodSink */ void CWE401_Memory_Leak__char_realloc_52b_goodB2GSink(char * data); static void goodB2G() { char * data; data = NULL; /* POTENTIAL FLAW: Allocate memory on the heap */ data = (char *)realloc(data, 100*sizeof(char)); if (data == NULL) {exit(-1);} /* Initialize and make use of data */ strcpy(data, "A String"); printLine(data); CWE401_Memory_Leak__char_realloc_52b_goodB2GSink(data); } void CWE401_Memory_Leak__char_realloc_52_good() { goodG2B(); goodB2G(); } #endif /* OMITGOOD */ /* Below is the main(). It is only used when building this testcase on its own for testing or for building a binary to use in testing binary analysis tools. It is not used when compiling all the testcases as one application, which is how source code analysis tools are tested. */ #ifdef INCLUDEMAIN int main(int argc, char * argv[]) { /* seed randomness */ srand( (unsigned)time(NULL) ); #ifndef OMITGOOD printLine("Calling good()..."); CWE401_Memory_Leak__char_realloc_52_good(); printLine("Finished good()"); #endif /* OMITGOOD */ #ifndef OMITBAD printLine("Calling bad()..."); CWE401_Memory_Leak__char_realloc_52_bad(); printLine("Finished bad()"); #endif /* OMITBAD */ return 0; } #endif
// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef UI_GL_GL_CONTEXT_EGL_H_ #define UI_GL_GL_CONTEXT_EGL_H_ #include <map> #include "base/compiler_specific.h" #include "ui/gl/gl_context.h" #include "ui/gl/gl_export.h" typedef void* EGLContext; typedef void* EGLDisplay; typedef void* EGLConfig; namespace gl { class GLSurface; // Encapsulates an EGL OpenGL ES context. class GL_EXPORT GLContextEGL : public GLContextReal { public: explicit GLContextEGL(GLShareGroup* share_group); GLContextEGL(const GLContextEGL&) = delete; GLContextEGL& operator=(const GLContextEGL&) = delete; // Implement GLContext. bool Initialize(GLSurface* compatible_surface, const GLContextAttribs& attribs) override; bool MakeCurrentImpl(GLSurface* surface) override; void ReleaseCurrent(GLSurface* surface) override; bool IsCurrent(GLSurface* surface) override; void* GetHandle() override; unsigned int CheckStickyGraphicsResetStatusImpl() override; void SetUnbindFboOnMakeCurrent() override; YUVToRGBConverter* GetYUVToRGBConverter( const gfx::ColorSpace& color_space) override; void SetVisibility(bool visibility) override; protected: ~GLContextEGL() override; private: void Destroy(); void ReleaseYUVToRGBConvertersAndBackpressureFences(); EGLContext context_ = nullptr; EGLDisplay display_ = nullptr; EGLConfig config_ = nullptr; unsigned int graphics_reset_status_ = 0; // GL_NO_ERROR; bool unbind_fbo_on_makecurrent_ = false; bool lost_ = false; std::map<gfx::ColorSpace, std::unique_ptr<YUVToRGBConverter>> yuv_to_rgb_converters_; }; } // namespace gl #endif // UI_GL_GL_CONTEXT_EGL_H_
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE467_Use_of_sizeof_on_Pointer_Type__short_01.c Label Definition File: CWE467_Use_of_sizeof_on_Pointer_Type.label.xml Template File: point-flaw-01.tmpl.c */ /* * @description * CWE: 467 Use of sizeof() on a Pointer Type * Sinks: short * GoodSink: Use sizeof() the data type * BadSink : Use sizeof() the pointer and not the data type * Flow Variant: 01 Baseline * * */ #include "std_testcase.h" #ifndef OMITBAD void CWE467_Use_of_sizeof_on_Pointer_Type__short_01_bad() { { short * badShort = NULL; /* FLAW: Using sizeof the pointer and not the data type in malloc() */ badShort = (short *)malloc(sizeof(badShort)); if (badShort == NULL) {exit(-1);} *badShort = 5; printShortLine(*badShort); free(badShort); } } #endif /* OMITBAD */ #ifndef OMITGOOD static void good1() { { short * goodShort = NULL; /* FIX: Using sizeof the data type in malloc() */ goodShort = (short *)malloc(sizeof(*goodShort)); if (goodShort == NULL) {exit(-1);} *goodShort = 6; printShortLine(*goodShort); free(goodShort); } } void CWE467_Use_of_sizeof_on_Pointer_Type__short_01_good() { good1(); } #endif /* OMITGOOD */ /* Below is the main(). It is only used when building this testcase on its own for testing or for building a binary to use in testing binary analysis tools. It is not used when compiling all the testcases as one application, which is how source code analysis tools are tested. */ #ifdef INCLUDEMAIN int main(int argc, char * argv[]) { /* seed randomness */ srand( (unsigned)time(NULL) ); #ifndef OMITGOOD printLine("Calling good()..."); CWE467_Use_of_sizeof_on_Pointer_Type__short_01_good(); printLine("Finished good()"); #endif /* OMITGOOD */ #ifndef OMITBAD printLine("Calling bad()..."); CWE467_Use_of_sizeof_on_Pointer_Type__short_01_bad(); printLine("Finished bad()"); #endif /* OMITBAD */ return 0; } #endif
/******************************************************************************* * * Copyright (c) 2010-2011 Michael Schulze <mschulze@ivs.cs.uni-magdeburg.de> * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holders nor the names of * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * * $Id: VectorTable.h 755 2011-12-06 23:14:21Z mschulze $ * ******************************************************************************/ #ifndef __VECT_TAB_HPP_0859D507E24FCE__ #define __VECT_TAB_HPP_0859D507E24FCE__ #include "avr-halib/avr/InterruptManager/VectorTableEntry.h" #include "linker_stubs.h" namespace Interrupt { /*! \brief Within the vector_table function the vector table is generated by * the help of the vector table entry (iterator). */ template <typename SlotConfig, typename _DefaultSlot, uint16_t Size> void vector_table() __attribute__((section(".vectortable"), naked, used)); template <typename SlotConfig, typename _DefaultSlot, uint16_t Size> void vector_table() { VectorTableEntry<SlotConfig, _DefaultSlot, 1, Size>::iterate(); } // primary template /*! \brief The VectorTable is calculate and aranged in dependence of the given * SlotConfig that hold the users interrupt vector configuration * * \tparam SlotConfig is a sequence containing slots * \tparam _DefaultSlot is used for this slot if it is not given within * the SlotConfig, meaning the slot is not configured by the user * \tparam Size is the size of the vector table in entries */ template <typename SlotConfig, typename _DefaultSlot, uint16_t Size> struct VectorTable { typedef VectorTable type; /*! \brief The Generator class template is a helper used for the * instantiation of the vector_table function template. This is the * reason why it is defined locally. */ template< void (*T)()> struct Generator { typedef Generator type; }; /*! \brief The VectorTable is generated by instantiating the vector_table * function template. At this point calling this function is not an * option. As the name states, it is a vector_table and not really * a function because that function consists of a kind of lookup * table having a series of jmps, refering to vector service * routines for each supported vector. However, instantiation is * needed to enable the creation of the vector table. The taking of * the address of the vector_table function template by giving it * to a respective class template does the trick. */ static void generate() __attribute__((always_inline)) { typedef Generator<vector_table<SlotConfig, _DefaultSlot, Size> > __t; } }; /*! \brief specializations of VectorTable without entries * * \copydoc VectorTableEntry */ template <typename SlotConfig, typename _DefaultSlot> struct VectorTable<SlotConfig, _DefaultSlot, 0> { typedef VectorTable type; static void generate() __attribute__((always_inline)) {} }; } /* namespace Interrupt */ #endif
#ifndef _NETWINDER_CONF_H #define _NETWINDER_CONF_H #include <sys/conf.h> /* * NETWINDER specific device includes go in here */ #define CONF_HAVE_PCI #define CONF_HAVE_SCSIPI #define CONF_HAVE_WSCONS #endif /* _NETWINDER_CONF_H */
/***************************************************************************** Copyright (c) 2011, Intel Corp. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of Intel Corporation nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***************************************************************************** * Contents: Native middle-level C interface to LAPACK function zlanhe * Author: Intel Corporation * Generated November, 2011 *****************************************************************************/ #include "lapacke.h" #include "lapacke_utils.h" double LAPACKE_zlanhe_work( int matrix_order, char norm, char uplo, lapack_int n, const lapack_complex_double* a, lapack_int lda, double* work ) { lapack_int info = 0; double res = 0.; if( matrix_order == LAPACK_COL_MAJOR ) { /* Call LAPACK function and adjust info */ res = LAPACK_zlanhe( &norm, &uplo, &n, a, &lda, work ); if( info < 0 ) { info = info - 1; } } else if( matrix_order == LAPACK_ROW_MAJOR ) { lapack_int lda_t = MAX(1,n); lapack_complex_double* a_t = NULL; /* Check leading dimension(s) */ if( lda < n ) { info = -6; LAPACKE_xerbla( "LAPACKE_zlanhe_work", info ); return info; } /* Allocate memory for temporary array(s) */ a_t = (lapack_complex_double*) LAPACKE_malloc( sizeof(lapack_complex_double) * lda_t * MAX(1,n) ); if( a_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_0; } /* Transpose input matrices */ LAPACKE_zhe_trans( matrix_order, uplo, n, a, lda, a_t, lda_t ); /* Call LAPACK function and adjust info */ res = LAPACK_zlanhe( &norm, &uplo, &n, a_t, &lda_t, work ); info = 0; /* LAPACK call is ok! */ /* Release memory and exit */ LAPACKE_free( a_t ); exit_level_0: if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) { LAPACKE_xerbla( "LAPACKE_zlanhe_work", info ); } } else { info = -1; LAPACKE_xerbla( "LAPACKE_zlanhe_work", info ); } return res; }
/* inet/mq.c Created: Jan 3, 1992 by Philip Homburg */ #include "inet.h" #include "mq.h" #define MQ_SIZE 64 PRIVATE mq_t mq_list[MQ_SIZE]; PRIVATE mq_t *mq_freelist; void mq_init() { int i; mq_freelist= NULL; for (i= 0; i<MQ_SIZE; i++) { mq_list[i].mq_next= mq_freelist; mq_freelist= &mq_list[i]; } } mq_t *mq_get() { mq_t *mq; mq= mq_freelist; if (mq) { mq_freelist= mq->mq_next; mq->mq_next= NULL; } return mq; } void mq_free(mq) mq_t *mq; { mq->mq_next= mq_freelist; mq_freelist= mq; }
/* $NetBSD: linux_blkio.h,v 1.2.4.1 2001/03/30 21:37:26 he Exp $ */ /* * Copyright (c) 2001 Wasabi Systems, Inc. * All rights reserved. * * Written by Frank van der Linden for Wasabi Systems, Inc. * * 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. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed for the NetBSD Project by * Wasabi Systems, Inc. * 4. The name of Wasabi Systems, Inc. may not be used to endorse * or promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``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 WASABI SYSTEMS, INC * 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. */ /* * Definitions for ioctl calls that work on filesystems, as defined * in <linux/fs.h> */ #ifndef _LINUX_BLKIO_H #define _LINUX_BLKIO_H #define LINUX_BLKROSET _LINUX_IO(0x12, 93) #define LINUX_BLKROGET _LINUX_IO(0x12, 94) #define LINUX_BLKRRPART _LINUX_IO(0x12, 95) #define LINUX_BLKGETSIZE _LINUX_IO(0x12, 96) #define LINUX_BLKFLSBUF _LINUX_IO(0x12, 97) #define LINUX_BLKRASET _LINUX_IO(0x12, 98) #define LINUX_BLKRAGET _LINUX_IO(0x12, 99) #define LINUX_BLKFRASET _LINUX_IO(0x12, 100) #define LINUX_BLKFRAGET _LINUX_IO(0x12, 101) #define LINUX_BLKSECTSET _LINUX_IO(0x12, 102) #define LINUX_BLKSECTGET _LINUX_IO(0x12, 103) #define LINUX_BLKSSZGET _LINUX_IO(0x12, 104) #define LINUX_BLKPG _LINUX_IO(0x12, 105) #endif /* _LINUX_BLKIO_H */
/* Copyright 1998-1999, Brian J. Swetland. All rights reserved. ** Distributed under the terms of the OpenBLT License */ #include "blt/error.h" #include "kernel.h" #include "resource.h" #include "rights.h" int right_create(uint32 rsrc_id, uint32 flags) { return ERR_NONE; } int right_destroy(uint32 right_id) { return ERR_NONE; } int right_revoke(uint32 right_id, uint32 thread_id) { return ERR_NONE; } int right_grant(uint32 right_id, uint32 thread_id) { return ERR_NONE; }
/* * Copyright (c) 2015, Xilinx Inc. and Contributors. 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 Xilinx 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. */ /* * @file cpu.h * @brief CPU specific primatives */ #ifndef __METAL_AARCH64_CPU__H__ #define __METAL_AARCH64_CPU__H__ #define metal_cpu_yield() asm volatile("yield") #endif /* __METAL_AARCH64_CPU__H__ */
// SDLListFilesResponse.h // // Copyright (c) 2014 Ford Motor Company. All rights reserved. #import <Foundation/Foundation.h> #import <SmartDeviceLink/SDLRPCResponse.h> @interface SDLListFilesResponse : SDLRPCResponse {} -(id) init; -(id) initWithDictionary:(NSMutableDictionary*) dict; @property(strong) NSMutableArray* filenames; @property(strong) NSNumber* spaceAvailable; @end
/* Copyright (c) nasser-sh 2016 * * Distributed under BSD-style license. See accompanying LICENSE.txt in project * directory. */ #pragma once #ifdef _WIN32 #include <afxwin.h> #include "WindowsGL.h" #endif
// // kfsfileid.h // KFS // // Copyright (c) 2012, FadingRed LLC // All rights reserved. // // Redistribution and use in source and binary forms, with or without modification, are permitted provided that the // following conditions are met: // // - Redistributions of source code must retain the above copyright notice, this list of conditions and the // following disclaimer. // - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the // following disclaimer in the documentation and/or other materials provided with the distribution. // - Neither the name of the FadingRed LLC 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. // #import "kfslib.h" /*! \brief Get a fileid from a path \details Gets a unique file id from the given path. */ uint64_t kfs_fileid(kfsid_t filesystem, const char *path); /*! \brief Swap file ids \details Swap the paths that the ids map to. */ void kfs_idswap(kfsid_t filesystem, uint64_t id_one, uint64_t id_two); /*! \brief Gets a path from a file id \details Gets a path given a file id. The path needs to have been registered with the system via the kfs_fileid call before this will return anything. Returns NULL when a path can't be found. */ const char *path_fromid(kfsid_t filesystem, uint64_t fileid); /*! \brief Clear all ids for the filesystem \details Remove all ids for the filesystem (useful to reclaim memory on unmount of a filesystem) */ void kfs_idclear(kfsid_t filesystem);
#include <stdio.h> #include <curses.h> int cmd_example_test(int argc, char* argv[]) { printw("Example test command\n"); return 0; }
#ifndef __CRYPTO_H__ #define __CRYPTO_H__ #include "stdafx.h" #ifndef keybits #define ebits 48 #define keybits 528 #endif unsigned int CrpB(char* crp, char* p, int len, const unsigned short * e, const unsigned short *n, short KeyBits=keybits); unsigned int DCrpB(char* dcrp, int* dlen, char* c, int len, const unsigned short * d, const unsigned short *n, short KeyBits=keybits); unsigned int GetCLenB(int len, const unsigned short *n, short KeyBits=keybits); unsigned int GetKeyBaseB(const unsigned short *n); unsigned int GetKeyBase(const unsigned short *n); #endif //---
/*****************************************************************************/ /** * @file ResultData.h * @author Guo Jiazhen */ /*****************************************************************************/ #ifndef KVS__FSTR__RESULT_DATA_H_INCLUDE #define KVS__FSTR__RESULT_DATA_H_INCLUDE #include <iostream> #include <vector> #include <string> #include <fstream> #include <kvs/ValueArray> #include <kvs/Type> #include <kvs/Indent> namespace kvs { namespace fstr { /*===========================================================================*/ /** * @brief Result data class. */ /*===========================================================================*/ class ResultData { public: typedef kvs::ValueArray<kvs::Real32> Values; protected: size_t m_nnodes; ///< number of nodes size_t m_ncells; ///< number of cells size_t m_ncomponents_per_node; ///< number of components per node size_t m_ncomponents_per_cell; ///< number of components per cell std::vector<size_t> m_veclens; ///< vector length of components std::vector<std::string> m_labels; ///< label of components std::vector<Values> m_values; ///< values of components public: ResultData(); size_t numberOfNodes() const; size_t numberOfCells() const; size_t numberOfComponentsPerNode() const; size_t numberOfComponentsPerCell() const; const std::vector<size_t>& veclens() const; const std::vector<std::string>& labels() const; const std::vector<Values>& values() const; void print( std::ostream& os, const kvs::Indent& indent = kvs::Indent(0) ) const; bool readData( const std::string& filename ); bool readDividedData( const std::string& filename ); private: bool read_nnodes_and_ncells( std::string& line, std::ifstream& ifs ); bool read_veclens( std::string& line, std::ifstream& ifs ); bool read_labels( std::string& line, std::ifstream& ifs ); }; } // end of namespace fstr } // end of namespace kvs #endif // KVS__FSTR__RESULT_DATA_H_INCLUDE
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE122_Heap_Based_Buffer_Overflow__c_CWE806_char_ncpy_53a.c Label Definition File: CWE122_Heap_Based_Buffer_Overflow__c_CWE806.label.xml Template File: sources-sink-53a.tmpl.c */ /* * @description * CWE: 122 Heap Based Buffer Overflow * BadSource: Initialize data as a large string * GoodSource: Initialize data as a small string * Sink: ncpy * BadSink : Copy data to string using strncpy * Flow Variant: 53 Data flow: data passed as an argument from one function through two others to a fourth; all four functions are in different source files * * */ #include "std_testcase.h" #include <wchar.h> #ifndef OMITBAD /* bad function declaration */ void CWE122_Heap_Based_Buffer_Overflow__c_CWE806_char_ncpy_53b_badSink(char * data); void CWE122_Heap_Based_Buffer_Overflow__c_CWE806_char_ncpy_53_bad() { char * data; data = (char *)malloc(100*sizeof(char)); if (data == NULL) {exit(-1);} /* FLAW: Initialize data as a large buffer that is larger than the small buffer used in the sink */ memset(data, 'A', 100-1); /* fill with 'A's */ data[100-1] = '\0'; /* null terminate */ CWE122_Heap_Based_Buffer_Overflow__c_CWE806_char_ncpy_53b_badSink(data); } #endif /* OMITBAD */ #ifndef OMITGOOD /* good function declaration */ void CWE122_Heap_Based_Buffer_Overflow__c_CWE806_char_ncpy_53b_goodG2BSink(char * data); /* goodG2B uses the GoodSource with the BadSink */ static void goodG2B() { char * data; data = (char *)malloc(100*sizeof(char)); if (data == NULL) {exit(-1);} /* FIX: Initialize data as a small buffer that as small or smaller than the small buffer used in the sink */ memset(data, 'A', 50-1); /* fill with 'A's */ data[50-1] = '\0'; /* null terminate */ CWE122_Heap_Based_Buffer_Overflow__c_CWE806_char_ncpy_53b_goodG2BSink(data); } void CWE122_Heap_Based_Buffer_Overflow__c_CWE806_char_ncpy_53_good() { goodG2B(); } #endif /* OMITGOOD */ /* Below is the main(). It is only used when building this testcase on * its own for testing or for building a binary to use in testing binary * analysis tools. It is not used when compiling all the testcases as one * application, which is how source code analysis tools are tested. */ #ifdef INCLUDEMAIN int main(int argc, char * argv[]) { /* seed randomness */ srand( (unsigned)time(NULL) ); #ifndef OMITGOOD printLine("Calling good()..."); CWE122_Heap_Based_Buffer_Overflow__c_CWE806_char_ncpy_53_good(); printLine("Finished good()"); #endif /* OMITGOOD */ #ifndef OMITBAD printLine("Calling bad()..."); CWE122_Heap_Based_Buffer_Overflow__c_CWE806_char_ncpy_53_bad(); printLine("Finished bad()"); #endif /* OMITBAD */ return 0; } #endif
#ifndef _FBUFFER_H_ #define _FBUFFER_H_ #include "ruby.h" #ifndef RHASH_SIZE #define RHASH_SIZE(hsh) (RHASH(hsh)->tbl->num_entries) #endif #ifndef RFLOAT_VALUE #define RFLOAT_VALUE(val) (RFLOAT(val)->value) #endif #ifndef RARRAY_PTR #define RARRAY_PTR(ARRAY) RARRAY(ARRAY)->ptr #endif #ifndef RARRAY_LEN #define RARRAY_LEN(ARRAY) RARRAY(ARRAY)->len #endif #ifndef RSTRING_PTR #define RSTRING_PTR(string) RSTRING(string)->ptr #endif #ifndef RSTRING_LEN #define RSTRING_LEN(string) RSTRING(string)->len #endif #ifdef HAVE_RUBY_ENCODING_H #include "ruby/encoding.h" #define FORCE_UTF8(obj) rb_enc_associate((obj), rb_utf8_encoding()) #else #define FORCE_UTF8(obj) #endif /* We don't need to guard objects for rbx, so let's do nothing at all. */ #ifndef RB_GC_GUARD #define RB_GC_GUARD(object) #endif typedef struct FBufferStruct { unsigned long initial_length; char *ptr; unsigned long len; unsigned long capa; } FBuffer; #define FBUFFER_INITIAL_LENGTH_DEFAULT 1024 #define FBUFFER_PTR(fb) (fb->ptr) #define FBUFFER_LEN(fb) (fb->len) #define FBUFFER_CAPA(fb) (fb->capa) #define FBUFFER_PAIR(fb) FBUFFER_PTR(fb), FBUFFER_LEN(fb) static FBuffer *fbuffer_alloc(unsigned long initial_length); static void fbuffer_free(FBuffer *fb); static void fbuffer_clear(FBuffer *fb); static void fbuffer_append(FBuffer *fb, const char *newstr, unsigned long len); #ifdef JSON_GENERATOR static void fbuffer_append_long(FBuffer *fb, long number); #endif static void fbuffer_append_char(FBuffer *fb, char newchr); #ifdef JSON_GENERATOR static FBuffer *fbuffer_dup(FBuffer *fb); static VALUE fbuffer_to_s(FBuffer *fb); #endif static FBuffer *fbuffer_alloc(unsigned long initial_length) { FBuffer *fb; if (initial_length == 0) initial_length = FBUFFER_INITIAL_LENGTH_DEFAULT; fb = ALLOC(FBuffer); memset((void *) fb, 0, sizeof(FBuffer)); fb->initial_length = initial_length; return fb; } static void fbuffer_free(FBuffer *fb) { if (fb->ptr) ruby_xfree(fb->ptr); ruby_xfree(fb); } static void fbuffer_clear(FBuffer *fb) { fb->len = 0; } static void fbuffer_inc_capa(FBuffer *fb, unsigned long requested) { unsigned long required; if (!fb->ptr) { fb->ptr = ALLOC_N(char, fb->initial_length); fb->capa = fb->initial_length; } for (required = fb->capa; requested > required - fb->len; required <<= 1); if (required > fb->capa) { REALLOC_N(fb->ptr, char, required); fb->capa = required; } } static void fbuffer_append(FBuffer *fb, const char *newstr, unsigned long len) { if (len > 0) { fbuffer_inc_capa(fb, len); MEMCPY(fb->ptr + fb->len, newstr, char, len); fb->len += len; } } #ifdef JSON_GENERATOR static void fbuffer_append_str(FBuffer *fb, VALUE str) { const char *newstr = StringValuePtr(str); unsigned long len = RSTRING_LEN(str); fbuffer_append(fb, newstr, len); RB_GC_GUARD(str); } #endif static void fbuffer_append_char(FBuffer *fb, char newchr) { fbuffer_inc_capa(fb, 1); *(fb->ptr + fb->len) = newchr; fb->len++; } #ifdef JSON_GENERATOR static void freverse(char *start, char *end) { char c; while (end > start) { c = *end, *end-- = *start, *start++ = c; } } static long fltoa(long number, char *buf) { static char digits[] = "0123456789"; long sign = number; char* tmp = buf; if (sign < 0) number = -number; do *tmp++ = digits[number % 10]; while (number /= 10); if (sign < 0) *tmp++ = '-'; freverse(buf, tmp - 1); return tmp - buf; } static void fbuffer_append_long(FBuffer *fb, long number) { char buf[20]; unsigned long len = fltoa(number, buf); fbuffer_append(fb, buf, len); } static FBuffer *fbuffer_dup(FBuffer *fb) { unsigned long len = fb->len; FBuffer *result; result = fbuffer_alloc(len); fbuffer_append(result, FBUFFER_PAIR(fb)); return result; } static VALUE fbuffer_to_s(FBuffer *fb) { VALUE result = rb_str_new(FBUFFER_PAIR(fb)); fbuffer_free(fb); FORCE_UTF8(result); return result; } #endif #endif
// Copyright 2019 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CONTENT_PUBLIC_TEST_MEDIA_START_STOP_OBSERVER_H_ #define CONTENT_PUBLIC_TEST_MEDIA_START_STOP_OBSERVER_H_ #include "base/macros.h" #include "base/run_loop.h" #include "content/public/browser/web_contents_observer.h" namespace content { class WebContents; // Used in tests to wait for media in a WebContents to start or stop playing. class MediaStartStopObserver : public WebContentsObserver { public: enum class Type { kStart, kStop, kEnterPictureInPicture, kExitPictureInPicture }; MediaStartStopObserver(WebContents* web_contents, Type type); ~MediaStartStopObserver() override; // WebContentsObserver implementation. void MediaStartedPlaying(const MediaPlayerInfo& info, const MediaPlayerId& id) override; void MediaStoppedPlaying( const MediaPlayerInfo& info, const MediaPlayerId& id, WebContentsObserver::MediaStoppedReason reason) override; void MediaPictureInPictureChanged(bool is_picture_in_picture) override; void Wait(); private: base::RunLoop run_loop_; const Type type_; DISALLOW_COPY_AND_ASSIGN(MediaStartStopObserver); }; } // namespace content #endif // CONTENT_PUBLIC_TEST_MEDIA_START_STOP_OBSERVER_H_
// Copyright 2016-present 650 Industries. All rights reserved. #import <ABI39_0_0UMCore/ABI39_0_0UMViewManager.h> #import <ABI39_0_0UMCore/ABI39_0_0UMModuleRegistryConsumer.h> @interface ABI39_0_0EXModuleTemplateViewManager : ABI39_0_0UMViewManager <ABI39_0_0UMModuleRegistryConsumer> @end
// // SplitterChannel.h // // $Id$ // // Library: Foundation // Package: Logging // Module: SplitterChannel // // Definition of the SplitterChannel class. // // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. // and Contributors. // // Permission is hereby granted, free of charge, to any person or organization // obtaining a copy of the software and accompanying documentation covered by // this license (the "Software") to use, reproduce, display, distribute, // execute, and transmit the Software, and to prepare derivative works of the // Software, and to permit third-parties to whom the Software is furnished to // do so, all subject to the following: // // The copyright notices in the Software and this entire statement, including // the above license grant, this restriction and the following disclaimer, // must be included in all copies of the Software, in whole or in part, and // all derivative works of the Software, unless such copies or derivative // works are solely in the form of machine-executable object code generated by // a source language processor. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. // #ifndef Foundation_SplitterChannel_INCLUDED #define Foundation_SplitterChannel_INCLUDED #include "Poco/Foundation.h" #include "Poco/Channel.h" #include "Poco/Mutex.h" #include <vector> namespace Poco { class Foundation_API SplitterChannel: public Channel /// This channel sends a message to multiple /// channels simultaneously. { public: SplitterChannel(); /// Creates the SplitterChannel. void addChannel(Channel* pChannel); /// Attaches a channel, which may not be null. void removeChannel(Channel* pChannel); /// Removes a channel. void log(const Message& msg); /// Sends the given Message to all /// attaches channels. void setProperty(const std::string& name, const std::string& value); /// Sets or changes a configuration property. /// /// Only the "channel" property is supported, which allows /// adding a comma-separated list of channels via the LoggingRegistry. /// The "channel" property is set-only. /// To simplify file-based configuration, all property /// names starting with "channel" are treated as "channel". void close(); /// Removes all channels. int count() const; /// Returns the number of channels in the SplitterChannel. protected: ~SplitterChannel(); private: typedef std::vector<Channel*> ChannelVec; ChannelVec _channels; mutable FastMutex _mutex; }; } // namespace Poco #endif // Foundation_SplitterChannel_INCLUDED
/*- * Copyright (c) 1997, Stefan Esser <se@FreeBSD.ORG> * Copyright (c) 1997, 1998, 1999, Kenneth D. Merry <ken@FreeBSD.ORG> * 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 unmodified, 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD$ * */ #ifndef _SYS_PCIIO_H_ #define _SYS_PCIIO_H_ #include <sys/ioccom.h> #define PCI_MAXNAMELEN 16 typedef enum { PCI_GETCONF_LAST_DEVICE, PCI_GETCONF_LIST_CHANGED, PCI_GETCONF_MORE_DEVS, PCI_GETCONF_ERROR } pci_getconf_status; typedef enum { PCI_GETCONF_NO_MATCH = 0x0000, PCI_GETCONF_MATCH_DOMAIN = 0x0001, PCI_GETCONF_MATCH_BUS = 0x0002, PCI_GETCONF_MATCH_DEV = 0x0004, PCI_GETCONF_MATCH_FUNC = 0x0008, PCI_GETCONF_MATCH_NAME = 0x0010, PCI_GETCONF_MATCH_UNIT = 0x0020, PCI_GETCONF_MATCH_VENDOR = 0x0040, PCI_GETCONF_MATCH_DEVICE = 0x0080, PCI_GETCONF_MATCH_CLASS = 0x0100 } pci_getconf_flags; struct pcisel { u_int32_t pc_domain; /* domain number */ u_int8_t pc_bus; /* bus number */ u_int8_t pc_dev; /* device on this bus */ u_int8_t pc_func; /* function on this device */ }; struct pci_conf { struct pcisel pc_sel; /* domain+bus+slot+function */ u_int8_t pc_hdr; /* PCI header type */ u_int16_t pc_subvendor; /* card vendor ID */ u_int16_t pc_subdevice; /* card device ID, assigned by card vendor */ u_int16_t pc_vendor; /* chip vendor ID */ u_int16_t pc_device; /* chip device ID, assigned by chip vendor */ u_int8_t pc_class; /* chip PCI class */ u_int8_t pc_subclass; /* chip PCI subclass */ u_int8_t pc_progif; /* chip PCI programming interface */ u_int8_t pc_revid; /* chip revision ID */ char pd_name[PCI_MAXNAMELEN + 1]; /* device name */ u_long pd_unit; /* device unit number */ }; struct pci_match_conf { struct pcisel pc_sel; /* domain+bus+slot+function */ char pd_name[PCI_MAXNAMELEN + 1]; /* device name */ u_long pd_unit; /* Unit number */ u_int16_t pc_vendor; /* PCI Vendor ID */ u_int16_t pc_device; /* PCI Device ID */ u_int8_t pc_class; /* PCI class */ pci_getconf_flags flags; /* Matching expression */ }; struct pci_conf_io { u_int32_t pat_buf_len; /* pattern buffer length */ u_int32_t num_patterns; /* number of patterns */ struct pci_match_conf *patterns; /* pattern buffer */ u_int32_t match_buf_len; /* match buffer length */ u_int32_t num_matches; /* number of matches returned */ struct pci_conf *matches; /* match buffer */ u_int32_t offset; /* offset into device list */ u_int32_t generation; /* device list generation */ pci_getconf_status status; /* request status */ }; struct pci_io { struct pcisel pi_sel; /* device to operate on */ int pi_reg; /* configuration register to examine */ int pi_width; /* width (in bytes) of read or write */ u_int32_t pi_data; /* data to write or result of read */ }; struct pci_bar_io { struct pcisel pbi_sel; /* device to operate on */ int pbi_reg; /* starting address of BAR */ int pbi_enabled; /* decoding enabled */ uint64_t pbi_base; /* current value of BAR */ uint64_t pbi_length; /* length of BAR */ }; #define PCIOCGETCONF _IOWR('p', 5, struct pci_conf_io) #define PCIOCREAD _IOWR('p', 2, struct pci_io) #define PCIOCWRITE _IOWR('p', 3, struct pci_io) #define PCIOCATTACHED _IOWR('p', 4, struct pci_io) #define PCIOCGETBAR _IOWR('p', 6, struct pci_bar_io) #endif /* !_SYS_PCIIO_H_ */
// Copyright 2020 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef THIRD_PARTY_BLINK_PUBLIC_PLATFORM_WEB_ISOLATE_H_ #define THIRD_PARTY_BLINK_PUBLIC_PLATFORM_WEB_ISOLATE_H_ #include <memory> #include "third_party/blink/public/platform/web_common.h" namespace blink { // WebIsolate is an interface to expose blink::BlinkIsolate to content/. class WebIsolate { public: BLINK_EXPORT static std::unique_ptr<WebIsolate> Create(); virtual ~WebIsolate() = default; }; } // namespace blink #endif // THIRD_PARTY_BLINK_PUBLIC_PLATFORM_WEB_ISOLATE_H_
/* * Copyright © 2018, VideoLAN and dav1d authors * Copyright © 2018, Two Orioles, LLC * 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. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef DAV1D_SRC_LOOPRESTORATION_H #define DAV1D_SRC_LOOPRESTORATION_H #include <stdint.h> #include <stddef.h> #include "common/bitdepth.h" enum LrEdgeFlags { LR_HAVE_LEFT = 1 << 0, LR_HAVE_RIGHT = 1 << 1, LR_HAVE_TOP = 1 << 2, LR_HAVE_BOTTOM = 1 << 3, }; #ifdef BITDEPTH typedef const pixel (*const_left_pixel_row)[4]; #else typedef const void *const_left_pixel_row; #endif // Although the spec applies restoration filters over 4x4 blocks, the wiener // filter can be applied to a bigger surface. // * w is constrained by the restoration unit size (w <= 256) // * h is constrained by the stripe height (h <= 64) #define decl_wiener_filter_fn(name) \ void (name)(pixel *dst, ptrdiff_t dst_stride, \ const_left_pixel_row left, \ const pixel *lpf, ptrdiff_t lpf_stride, \ int w, int h, const int16_t filterh[7], \ const int16_t filterv[7], enum LrEdgeFlags edges \ HIGHBD_DECL_SUFFIX) typedef decl_wiener_filter_fn(*wienerfilter_fn); #define decl_selfguided_filter_fn(name) \ void (name)(pixel *dst, ptrdiff_t dst_stride, \ const_left_pixel_row left, \ const pixel *lpf, ptrdiff_t lpf_stride, \ int w, int h, int sgr_idx, const int16_t sgr_w[2], \ const enum LrEdgeFlags edges HIGHBD_DECL_SUFFIX) typedef decl_selfguided_filter_fn(*selfguided_fn); typedef struct Dav1dLoopRestorationDSPContext { wienerfilter_fn wiener; selfguided_fn selfguided; } Dav1dLoopRestorationDSPContext; bitfn_decls(void dav1d_loop_restoration_dsp_init, Dav1dLoopRestorationDSPContext *c); bitfn_decls(void dav1d_loop_restoration_dsp_init_arm, Dav1dLoopRestorationDSPContext *c); bitfn_decls(void dav1d_loop_restoration_dsp_init_x86, Dav1dLoopRestorationDSPContext *c); bitfn_decls(void dav1d_loop_restoration_dsp_init_ppc, Dav1dLoopRestorationDSPContext *c); #endif /* DAV1D_SRC_LOOPRESTORATION_H */
// -*- c++ -*- /*========================================================================= Program: Visualization Toolkit Module: vtkSubCommunicator.h Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen All rights reserved. See Copyright.txt or http://www.kitware.com/Copyright.htm for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notice for more information. =========================================================================*/ /*---------------------------------------------------------------------------- Copyright (c) Sandia Corporation See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details. ----------------------------------------------------------------------------*/ // .NAME vtkSubCommunicator - Provides communication on a process group. // // .SECTION Description // // This class provides an implementation for communicating on process groups. // In general, you should never use this class directly. Instead, use the // vtkMultiProcessController::CreateSubController method. // // .SECTION BUGS // // Because all communication is delegated to the original communicator, // any error will report process ids with respect to the original // communicator, not this communicator that was actually used. // // .SECTION See Also // vtkCommunicator, vtkMultiProcessController // // .SECTION Thanks // This class was originally written by Kenneth Moreland (kmorel@sandia.gov) // from Sandia National Laboratories. // #ifndef __vtkSubCommunicator_h #define __vtkSubCommunicator_h #include "vtkParallelCoreExport.h" // For export macro #include "vtkCommunicator.h" class vtkProcessGroup; class VTKPARALLELCORE_EXPORT vtkSubCommunicator : public vtkCommunicator { public: vtkTypeMacro(vtkSubCommunicator, vtkCommunicator); static vtkSubCommunicator *New(); virtual void PrintSelf(ostream &os, vtkIndent indent); // Description: // Set/get the group on which communication will happen. vtkGetObjectMacro(Group, vtkProcessGroup); virtual void SetGroup(vtkProcessGroup *group); // Description: // Implementation for abstract supercalss. virtual int SendVoidArray(const void *data, vtkIdType length, int type, int remoteHandle, int tag); virtual int ReceiveVoidArray(void *data, vtkIdType length, int type, int remoteHandle, int tag); protected: vtkSubCommunicator(); virtual ~vtkSubCommunicator(); vtkProcessGroup *Group; private: vtkSubCommunicator(const vtkSubCommunicator &); // Not implemented void operator=(const vtkSubCommunicator &); // Not implemented }; #endif //__vtkSubCommunicator_h
/* -*- Mode: C; c-basic-offset:4 ; -*- */ /* * * Copyright (C) 1997 University of Chicago. * See COPYRIGHT notice in top-level directory. */ #include "mpioimpl.h" #ifdef HAVE_WEAK_SYMBOLS #if defined(HAVE_PRAGMA_WEAK) #pragma weak MPI_File_read_all_begin = PMPI_File_read_all_begin #elif defined(HAVE_PRAGMA_HP_SEC_DEF) #pragma _HP_SECONDARY_DEF PMPI_File_read_all_begin MPI_File_read_all_begin #elif defined(HAVE_PRAGMA_CRI_DUP) #pragma _CRI duplicate MPI_File_read_all_begin as PMPI_File_read_all_begin /* end of weak pragmas */ #endif /* Include mapping from MPI->PMPI */ #define MPIO_BUILD_PROFILING #include "mpioprof.h" #endif /*@ MPI_File_read_all_begin - Begin a split collective read using individual file pointer Input Parameters: . fh - file handle (handle) . count - number of elements in buffer (nonnegative integer) . datatype - datatype of each buffer element (handle) Output Parameters: . buf - initial address of buffer (choice) .N fortran @*/ int MPI_File_read_all_begin(MPI_File mpi_fh, void *buf, int count, MPI_Datatype datatype) { int error_code; static char myname[] = "MPI_FILE_READ_ALL_BEGIN"; error_code = MPIOI_File_read_all_begin(mpi_fh, (MPI_Offset) 0, ADIO_INDIVIDUAL, buf, count, datatype, myname); return error_code; } /* prevent multiple definitions of this routine */ #ifdef MPIO_BUILD_PROFILING int MPIOI_File_read_all_begin(MPI_File mpi_fh, MPI_Offset offset, int file_ptr_type, void *buf, int count, MPI_Datatype datatype, char *myname) { int error_code, datatype_size; ADIO_File fh; MPIU_THREAD_CS_ENTER(ALLFUNC,); fh = MPIO_File_resolve(mpi_fh); /* --BEGIN ERROR HANDLING-- */ MPIO_CHECK_FILE_HANDLE(fh, myname, error_code); MPIO_CHECK_COUNT(fh, count, myname, error_code); MPIO_CHECK_DATATYPE(fh, datatype, myname, error_code); if (file_ptr_type == ADIO_EXPLICIT_OFFSET && offset < 0) { error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_ARG, "**iobadoffset", 0); error_code = MPIO_Err_return_file(fh, error_code); goto fn_exit; } /* --END ERROR HANDLING-- */ MPI_Type_size(datatype, &datatype_size); /* --BEGIN ERROR HANDLING-- */ MPIO_CHECK_INTEGRAL_ETYPE(fh, count, datatype_size, myname, error_code); MPIO_CHECK_READABLE(fh, myname, error_code); MPIO_CHECK_NOT_SEQUENTIAL_MODE(fh, myname, error_code); if (fh->split_coll_count) { error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_IO, "**iosplitcoll", 0); error_code = MPIO_Err_return_file(fh, error_code); goto fn_exit; } MPIO_CHECK_COUNT_SIZE(fh, count, datatype_size, myname, error_code); /* --END ERROR HANDLING-- */ fh->split_coll_count = 1; ADIO_ReadStridedColl(fh, buf, count, datatype, file_ptr_type, offset, &fh->split_status, &error_code); /* --BEGIN ERROR HANDLING-- */ if (error_code != MPI_SUCCESS) error_code = MPIO_Err_return_file(fh, error_code); /* --END ERROR HANDLING-- */ fn_exit: MPIU_THREAD_CS_EXIT(ALLFUNC,); return error_code; } #endif
/* * (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. * See the copyright notice in the ACK home directory, in the file "Copyright". * * Author: Ceriel J.H. Jacobs */ /* $Id$ */ double fabs(double x) { return x < 0 ? -x : x; }
/////////////////////////////////////////////////////////////////////////////// // BSD 3-Clause License // // Copyright (c) 2018, The Regents of the University of California // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // // * Redistributions of source code must retain the above copyright notice, this // list of conditions and the following disclaimer. // // * Redistributions in binary form must reproduce the above copyright notice, // this list of conditions and the following disclaimer in the documentation // and/or other materials provided with the distribution. // // * Neither the name of the copyright holder 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. /////////////////////////////////////////////////////////////////////////////// #include <vector> #include "SteinerTreeBuilder.h" namespace utl { class Logger; } namespace gui { class Gui; } namespace pdr { using utl::Logger; using stt::Tree; Tree primDijkstra(std::vector<int>& x, std::vector<int>& y, int drvr_index, float alpha, Logger* logger); Tree primDijkstraRevII(std::vector<int>& x, std::vector<int>& y, int drvr_index, float alpha, Logger* logger); } // namespace PD
/* Arbitrary precision integer * * Copyright (C) 2015 Yibo Cai */ #pragma once #ifdef _TT_LP64_ /* 64 bit */ typedef uint64_t _tt_word; typedef __uint128_t _tt_word_double; #define _tt_word_sz 8 #define _tt_word_bits 63 #define _tt_word_top_bit (1ULL << 63) #else /* 32 bit */ typedef uint _tt_word; typedef uint64_t _tt_word_double; #define _tt_word_sz 4 #define _tt_word_bits 31 #define _tt_word_top_bit (1U << 31) #endif struct tt_int { int sign; /* Sign: 0/+, 1/- */ #define TT_INT_DEF 34 /* Larger than 1024/2048 bits */ int _max; /* Size of _int[] buffer in words */ int msb; /* Valid integers in buf[], 1 ~ _max */ _tt_word *buf; /* Each word is of 31/63 bits. * Top bit reserved for carry guard. */ }; #define _TT_INT_DECL(msb, i) { 0, msb, msb, (_tt_word *)i } int _tt_int_realloc(struct tt_int *ti, int msb); int _tt_int_copy(struct tt_int *dst, const struct tt_int *src); void _tt_int_zero(struct tt_int *ti); static inline bool _tt_int_is_zero(const struct tt_int *ti) { return ti->msb == 1 && ti->buf[0] == 0; } int _tt_int_word_bits(_tt_word w); int _tt_int_word_ctz(_tt_word w); int _tt_int_sanity(const struct tt_int *ti); void _tt_int_print(const struct tt_int *ti); void _tt_int_print_buf(const _tt_word *ui, int msb); int _tt_int_add_buf(_tt_word *int1, int msb1, const _tt_word *int2, int msb2); int _tt_int_sub_buf(_tt_word *int1, int msb1, const _tt_word *int2, int msb2); int _tt_int_mul_buf(_tt_word *intr, const _tt_word *int1, int msb1, const _tt_word *int2, int msb2); int _tt_int_div_buf(_tt_word *qt, int *msb_qt, _tt_word *rm, int *msb_rm, const _tt_word *dd, int msb_dd, const _tt_word *ds, int msb_ds); int _tt_int_shift_buf(_tt_word *buf, int msb, int shift); int _tt_int_cmp_buf(const _tt_word *int1, int msb1, const _tt_word *int2, int msb2); int _tt_int_get_msb(const _tt_word *ui, int len); bool _tt_int_isprime_buf(const _tt_word *ui, int msb); int _tt_int_mont_reduce(_tt_word *r, int *msbr, const _tt_word *c, int msbc, const _tt_word *u, int msbu, const _tt_word *n, int msbn, _tt_word *t);
/***************************************************************************\ * * PROGRAMMNAME: WPDCF77 * ------------- * * VERSION: 6.0 * -------- * * MODULNAME: LOCALE.H * ---------- * * BESCHREIBUNG: * ------------- * Header-Datei mit allgemeinen Definitionen fr die Uhr * * Ver. Date Comment * ---- -------- ------- * 1.00 10-23-94 First release * 4.40 01-31-00 Multimedia-Untersttzung, Bugfixing * 5.10 02-10-01 Fehlerkorrektur Positionsspeicherung Iconview * 5.20 06-09-01 Fehlerkorrektur Audiodaten * 5.30 01-16-02 Implementierung der Erinnerungsfunktion * 5.40 11-22-03 Fehlerkorrektur Erinnerungsfunktion * 6.00 02-15-04 USB Untersttzung * * Copyright (C) noller & breining software 1995...2004 * \******************************************************************************/ #ifndef LOCALE_H #define LOCALE_H MRESULT EXPENTRY TimezoneDlgProc (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2); USHORT DaysInMonth (PDATETIME pDT); VOID InitGPSDriver (VOID); #endif /* LOCALE_H */
/* ///////////////////////////////////////////////////////////////////////// * File: pantheios/implicit_link/ber.WindowsEventLog.h * * Purpose: Implicitly links in the Pantheios Windows Event Log Remote Back-End Library * * Created: 4th January 2006 * Updated: 29th June 2016 * * Home: http://pantheios.org/ * * Copyright (c) 2006-2016, Matthew Wilson and Synesis Software * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - Neither the name(s) of Matthew Wilson and Synesis Software nor the * names of any contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * ////////////////////////////////////////////////////////////////////// */ /** \file pantheios/implicit_link/ber.WindowsEventLog.h * * [C, C++] Implicitly links in the * \ref group__backend__stock_backends__WindowsEventLog "Pantheios Windows Event Log Remote Back-End Library" * as the remote back-end for the given link-unit. */ #ifndef PANTHEIOS_INCL_PANTHEIOS_IMPLICIT_LINK_H_BER_WINDOWSEVENTLOG #define PANTHEIOS_INCL_PANTHEIOS_IMPLICIT_LINK_H_BER_WINDOWSEVENTLOG /* ///////////////////////////////////////////////////////////////////////// * version information */ #ifndef PANTHEIOS_DOCUMENTATION_SKIP_SECTION # define PANTHEIOS_VER_PANTHEIOS_IMPLICIT_LINK_H_BER_WINDOWSEVENTLOG_MAJOR 1 # define PANTHEIOS_VER_PANTHEIOS_IMPLICIT_LINK_H_BER_WINDOWSEVENTLOG_MINOR 0 # define PANTHEIOS_VER_PANTHEIOS_IMPLICIT_LINK_H_BER_WINDOWSEVENTLOG_REVISION 2 # define PANTHEIOS_VER_PANTHEIOS_IMPLICIT_LINK_H_BER_WINDOWSEVENTLOG_EDIT 7 #endif /* !PANTHEIOS_DOCUMENTATION_SKIP_SECTION */ /* ///////////////////////////////////////////////////////////////////////// * includes */ #ifndef PANTHEIOS_INCL_PANTHEIOS_H_PANTHEIOS # include <pantheios/pantheios.h> #endif /* !PANTHEIOS_INCL_PANTHEIOS_H_PANTHEIOS */ #ifndef PANTHEIOS_INCL_PANTHEIOS_IMPLICIT_LINK_H_IMPLICIT_LINK_BASE_ # include <pantheios/implicit_link/implicit_link_base_.h> #endif /* !PANTHEIOS_INCL_PANTHEIOS_IMPLICIT_LINK_H_IMPLICIT_LINK_BASE_ */ #ifndef PANTHEIOS_INCL_PANTHEIOS_IMPLICIT_LINK_H_BEC_WINDOWSEVENTLOG # include <pantheios/implicit_link/bec.WindowsEventLog.h> #endif /* !PANTHEIOS_INCL_PANTHEIOS_IMPLICIT_LINK_H_BEC_WINDOWSEVENTLOG */ /* ///////////////////////////////////////////////////////////////////////// * implicit-linking directives */ #ifdef PANTHEIOS_IMPLICIT_LINK_SUPPORT # if defined(__BORLANDC__) # elif defined(__COMO__) # elif defined(__DMC__) # elif defined(__GNUC__) # elif defined(__INTEL_COMPILER) # pragma comment(lib, PANTHEIOS_IMPL_LINK_LIBRARY_NAME_("ber.WindowsEventLog")) # pragma message(" " PANTHEIOS_IMPL_LINK_LIBRARY_NAME_("ber.WindowsEventLog")) # elif defined(__MWERKS__) # elif defined(__WATCOMC__) # elif defined(_MSC_VER) # pragma comment(lib, PANTHEIOS_IMPL_LINK_LIBRARY_NAME_("ber.WindowsEventLog")) # pragma message(" " PANTHEIOS_IMPL_LINK_LIBRARY_NAME_("ber.WindowsEventLog")) # else /* ? compiler */ # error Compiler not recognised # endif /* compiler */ #endif /* PANTHEIOS_IMPLICIT_LINK_SUPPORT */ /* ////////////////////////////////////////////////////////////////////// */ #endif /* !PANTHEIOS_INCL_PANTHEIOS_IMPLICIT_LINK_H_BER_WINDOWSEVENTLOG */ /* ///////////////////////////// end of file //////////////////////////// */
/******************************************************************************* * * Filename: main.c * * Basic entry points for top-level functions * * Revision information: * * 20AUG2004 kb_admin initial creation * 12JAN2005 kb_admin cosmetic changes * 29APR2005 kb_admin modified boot delay * * BEGIN_KBDD_BLOCK * No warranty, expressed or implied, is included with this software. It is * provided "AS IS" and no warranty of any kind including statutory or aspects * relating to merchantability or fitness for any purpose is provided. All * intellectual property rights of others is maintained with the respective * owners. This software is not copyrighted and is intended for reference * only. * END_BLOCK * * $FreeBSD: releng/9.3/sys/boot/arm/at91/bootiic/main.c 161202 2006-08-10 19:55:52Z imp $ ******************************************************************************/ #include "env_vars.h" #include "at91rm9200_lowlevel.h" #include "loader_prompt.h" #include "emac.h" #include "lib.h" /* * .KB_C_FN_DEFINITION_START * int main(void) * This global function waits at least one second, but not more than two * seconds, for input from the serial port. If no response is recognized, * it acts according to the parameters specified by the environment. For * example, the function might boot an operating system. Do not return * from this function. * .KB_C_FN_DEFINITION_END */ int main(void) { InitEEPROM(); EMAC_Init(); LoadBootCommands(); printf("\n\rKB9202(www.kwikbyte.com)\n\rAuto boot..\n\r"); if (getc(1) == -1) ExecuteEnvironmentFunctions(); Bootloader(0); return (1); }
/* * Copyright (c) 2012,2015 Apple Inc. All rights reserved. * * corecrypto Internal Use License Agreement * * IMPORTANT: This Apple corecrypto software is supplied to you by Apple Inc. ("Apple") * in consideration of your agreement to the following terms, and your download or use * of this Apple software constitutes acceptance of these terms. If you do not agree * with these terms, please do not download or use this Apple software. * * 1. As used in this Agreement, the term "Apple Software" collectively means and * includes all of the Apple corecrypto materials provided by Apple here, including * but not limited to the Apple corecrypto software, frameworks, libraries, documentation * and other Apple-created materials. In consideration of your agreement to abide by the * following terms, conditioned upon your compliance with these terms and subject to * these terms, Apple grants you, for a period of ninety (90) days from the date you * download the Apple Software, a limited, non-exclusive, non-sublicensable license * under Apple’s copyrights in the Apple Software to make a reasonable number of copies * of, compile, and run the Apple Software internally within your organization only on * devices and computers you own or control, for the sole purpose of verifying the * security characteristics and correct functioning of the Apple Software; provided * that you must retain this notice and the following text and disclaimers in all * copies of the Apple Software that you make. You may not, directly or indirectly, * redistribute the Apple Software or any portions thereof. The Apple Software is only * licensed and intended for use as expressly stated above and may not be used for other * purposes or in other contexts without Apple's prior written permission. Except as * expressly stated in this notice, no other rights or licenses, express or implied, are * granted by Apple herein. * * 2. The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO * WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES * OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING * THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS, * SYSTEMS, OR SERVICES. APPLE DOES NOT WARRANT THAT THE APPLE SOFTWARE WILL MEET YOUR * REQUIREMENTS, THAT THE OPERATION OF THE APPLE SOFTWARE WILL BE UNINTERRUPTED OR * ERROR-FREE, THAT DEFECTS IN THE APPLE SOFTWARE WILL BE CORRECTED, OR THAT THE APPLE * SOFTWARE WILL BE COMPATIBLE WITH FUTURE APPLE PRODUCTS, SOFTWARE OR SERVICES. NO ORAL * OR WRITTEN INFORMATION OR ADVICE GIVEN BY APPLE OR AN APPLE AUTHORIZED REPRESENTATIVE * WILL CREATE A WARRANTY. * * 3. IN NO EVENT SHALL APPLE BE LIABLE FOR ANY DIRECT, SPECIAL, INDIRECT, INCIDENTAL * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING * IN ANY WAY OUT OF THE USE, REPRODUCTION, COMPILATION OR OPERATION OF THE APPLE * SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING * NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * 4. This Agreement is effective until terminated. Your rights under this Agreement will * terminate automatically without notice from Apple if you fail to comply with any term(s) * of this Agreement. Upon termination, you agree to cease all use of the Apple Software * and destroy all copies, full or partial, of the Apple Software. This Agreement will be * governed and construed in accordance with the laws of the State of California, without * regard to its choice of law rules. * * You may report security issues about Apple products to product-security@apple.com, * as described here:  https://www.apple.com/support/security/. Non-security bugs and * enhancement requests can be made via https://bugreport.apple.com as described * here: https://developer.apple.com/bug-reporting/ * * EA1350 * 10/5/15 */ #include <corecrypto/ccz_priv.h> bool ccz_is_one(const ccz *s) { return ccn_is_one(ccz_n(s), s->u); }
/* * Copyright (c) 2011-2014, Intel Corporation * 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 copyright holder 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. */ #pragma once #include "ParameterType.h" class CFixedPointParameterType : public CParameterType { public: CFixedPointParameterType(const string& strName); // From IXmlSink virtual bool fromXml(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext); // From IXmlSource virtual void toXml(CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) const; // XML Serialization value space handling // Value space handling for configuration import virtual void handleValueSpaceAttribute(CXmlElement& xmlConfigurableElementSettingsElement, CConfigurationAccessContext& configurationAccessContext) const; /// Conversion // String virtual bool toBlackboard(const string& strValue, uint32_t& uiValue, CParameterAccessContext& parameterAccessContext) const; virtual bool fromBlackboard(string& strValue, const uint32_t& uiValue, CParameterAccessContext& parameterAccessContext) const; // Double virtual bool toBlackboard(double dUserValue, uint32_t& uiValue, CParameterAccessContext& parameterAccessContext) const; virtual bool fromBlackboard(double& dUserValue, uint32_t uiValue, CParameterAccessContext& parameterAccessContext) const; // Element properties virtual void showProperties(string& strResult) const; // CElement virtual string getKind() const; private: // Util size uint32_t getUtilSizeInBits() const; // Range computation void getRange(double& dMin, double& dMax) const; // Out of range error string getOutOfRangeError(const string& strValue, bool bRawValueSpace, bool bHexaValue) const; // Check if data is encodable bool checkValueAgainstRange(double dValue) const; // Data conversion int32_t asInteger(double dValue) const; double asDouble(int32_t iValue) const; // Integral part in Q notation uint32_t _uiIntegral; // Fractional part in Q notation uint32_t _uiFractional; };
/* Copyright (C) 2005 Commonwealth Scientific and Industrial Research Organisation (CSIRO) Australia Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - Neither the name of CSIRO Australia 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 ORGANISATION OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef __OGGZ_TOOLS_H__ #define __OGGZ_TOOLS_H__ #include "config.h" #include <getopt.h> const char * ot_page_identify (OGGZ *oggz, const ogg_page * og, char ** info); /* * Print a number of bytes to 3 significant figures * using standard abbreviations (GB, MB, kB, byte[s]) */ int ot_fprint_bytes (FILE * stream, long nr_bytes); /* * Print a bitrate to 3 significant figures * using quasi-standard abbreviations (Gbps, Mbps, kbps, bps) */ int ot_print_bitrate (long bps); int ot_fprint_time (FILE * stream, double seconds); int ot_fprint_granulepos (FILE * stream, OGGZ * oggz, long serialno, ogg_int64_t granulepos); /* * Tool initialization function. Sets stdin, stdio to binary on windows etc. * Call this at the beginning of main(). */ void ot_init (void); /* * Print options. Must use these in response to -? for each command, * for bash completion. */ void ot_print_short_options (char * optstring); #ifdef HAVE_GETOPT_LONG void ot_print_options (struct option long_options[], char * optstring); #endif #endif /* __OGGZ_TOOLS_H__ */