text
stringlengths
4
6.14k
#pragma once #include <limits> #include "envoy/common/resource.h" #include "envoy/runtime/runtime.h" #include "common/common/assert.h" #include "absl/types/optional.h" namespace Envoy { /** * A handle to track some limited resource. * * NOTE: * This implementation makes some assumptions which favor simplicity over correctness. Though * atomics are used, it is possible for resources to temporarily go above the supplied maximums. * This should not effect overall behavior. */ class BasicResourceLimitImpl : public ResourceLimit { public: BasicResourceLimitImpl(uint64_t max, Runtime::Loader& runtime, const std::string& runtime_key) : max_(max), runtime_(&runtime), runtime_key_(runtime_key) {} BasicResourceLimitImpl(uint64_t max) : max_(max) {} BasicResourceLimitImpl() : max_(std::numeric_limits<uint64_t>::max()) {} bool canCreate() override { return current_.load() < max(); } void inc() override { ++current_; } void dec() override { decBy(1); } void decBy(uint64_t amount) override { ASSERT(current_ >= amount); current_ -= amount; } uint64_t max() override { return (runtime_ != nullptr && runtime_key_.has_value()) ? runtime_->snapshot().getInteger(runtime_key_.value(), max_) : max_; } uint64_t count() const override { return current_.load(); } void setMax(uint64_t new_max) { max_ = new_max; } void resetMax() { max_ = std::numeric_limits<uint64_t>::max(); } protected: std::atomic<uint64_t> current_{}; private: uint64_t max_; Runtime::Loader* runtime_{nullptr}; const absl::optional<std::string> runtime_key_; }; } // namespace Envoy
/** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ #pragma once #include <aws/accessanalyzer/AccessAnalyzer_EXPORTS.h> namespace Aws { namespace Utils { namespace Json { class JsonValue; class JsonView; } // namespace Json } // namespace Utils namespace AccessAnalyzer { namespace Model { /** * <p>This configuration sets the network origin for the Amazon S3 access point or * multi-region access point to <code>Internet</code>.</p><p><h3>See Also:</h3> * <a * href="http://docs.aws.amazon.com/goto/WebAPI/accessanalyzer-2019-11-01/InternetConfiguration">AWS * API Reference</a></p> */ class AWS_ACCESSANALYZER_API InternetConfiguration { public: InternetConfiguration(); InternetConfiguration(Aws::Utils::Json::JsonView jsonValue); InternetConfiguration& operator=(Aws::Utils::Json::JsonView jsonValue); Aws::Utils::Json::JsonValue Jsonize() const; }; } // namespace Model } // namespace AccessAnalyzer } // namespace Aws
/*- * BSD LICENSE * * Copyright (c) 2016-2017, Mellanox Technologies. 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. */ #ifndef _RTE_ESP_H_ #define _RTE_ESP_H_ /** * @file * * ESP-related defines */ #include <stdint.h> #ifdef __cplusplus extern "C" { #endif /** * ESP Header */ struct esp_hdr { uint32_t spi; /**< Security Parameters Index */ uint32_t seq; /**< packet sequence number */ } __attribute__((__packed__)); #ifdef __cplusplus } #endif #endif /* RTE_ESP_H_ */
/* * Copyright (C) 2008 The Android Open Source Project * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 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 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 _POLL_H_ #define _POLL_H_ #include <sys/cdefs.h> #include <linux/poll.h> #include <signal.h> /* For sigset_t. */ #include <time.h> /* For timespec. */ __BEGIN_DECLS typedef unsigned int nfds_t; int poll(struct pollfd*, nfds_t, int); int ppoll(struct pollfd*, nfds_t, const struct timespec*, const sigset_t*); int __poll_chk(struct pollfd*, nfds_t, int, size_t); int __poll_real(struct pollfd*, nfds_t, int) __RENAME(poll); __errordecl(__poll_too_small_error, "poll: pollfd array smaller than fd count"); int __ppoll_chk(struct pollfd*, nfds_t, const struct timespec*, const sigset_t*, size_t); int __ppoll_real(struct pollfd*, nfds_t, const struct timespec*, const sigset_t*) __RENAME(ppoll); __errordecl(__ppoll_too_small_error, "ppoll: pollfd array smaller than fd count"); #if defined(__BIONIC_FORTIFY) __BIONIC_FORTIFY_INLINE int poll(struct pollfd* fds, nfds_t fd_count, int timeout) { #if defined(__clang__) return __poll_chk(fds, fd_count, timeout, __bos(fds)); #else if (__bos(fds) != __BIONIC_FORTIFY_UNKNOWN_SIZE) { if (!__builtin_constant_p(fd_count)) { return __poll_chk(fds, fd_count, timeout, __bos(fds)); } else if (__bos(fds) / sizeof(*fds) < fd_count) { __poll_too_small_error(); } } return __poll_real(fds, fd_count, timeout); #endif } __BIONIC_FORTIFY_INLINE int ppoll(struct pollfd* fds, nfds_t fd_count, const struct timespec* timeout, const sigset_t* mask) { #if defined(__clang__) return __ppoll_chk(fds, fd_count, timeout, mask, __bos(fds)); #else if (__bos(fds) != __BIONIC_FORTIFY_UNKNOWN_SIZE) { if (!__builtin_constant_p(fd_count)) { return __ppoll_chk(fds, fd_count, timeout, mask, __bos(fds)); } else if (__bos(fds) / sizeof(*fds) < fd_count) { __ppoll_too_small_error(); } } return __ppoll_real(fds, fd_count, timeout, mask); #endif } #endif __END_DECLS #endif /* _POLL_H_ */
/* * This file is part of the Soletta™ Project * * Copyright (C) 2015 Intel Corporation. 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. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <errno.h> #include <stdio.h> #include "sol-log.h" #include "sol-arena.h" #include "sol-util-internal.h" /* TODO: check if it's worthwhile to implement this as a single * growing buffer. */ struct sol_arena { struct sol_ptr_vector str_vector; }; SOL_API struct sol_arena * sol_arena_new(void) { struct sol_arena *arena; arena = calloc(1, sizeof(struct sol_arena)); SOL_NULL_CHECK(arena, NULL); sol_ptr_vector_init(&arena->str_vector); return arena; } SOL_API void sol_arena_del(struct sol_arena *arena) { char *s; uint16_t i; SOL_NULL_CHECK(arena); SOL_PTR_VECTOR_FOREACH_IDX (&arena->str_vector, s, i) free(s); sol_ptr_vector_clear(&arena->str_vector); free(arena); } SOL_API int sol_arena_slice_dup_str_n(struct sol_arena *arena, struct sol_str_slice *dst, const char *src, size_t n) { struct sol_str_slice slice; int r; SOL_NULL_CHECK(arena, -EINVAL); SOL_NULL_CHECK(src, -EINVAL); SOL_INT_CHECK(n, <= 0, -EINVAL); slice.data = strndup(src, n); SOL_NULL_CHECK(slice.data, -errno); slice.len = n; r = sol_ptr_vector_append(&arena->str_vector, (char *)slice.data); if (r < 0) { free((char *)slice.data); return r; } *dst = slice; return 0; } SOL_API int sol_arena_slice_dup_str(struct sol_arena *arena, struct sol_str_slice *dst, const char *src) { SOL_NULL_CHECK(src, -EINVAL); return sol_arena_slice_dup_str_n(arena, dst, src, strlen(src)); } SOL_API int sol_arena_slice_dup(struct sol_arena *arena, struct sol_str_slice *dst, struct sol_str_slice src) { return sol_arena_slice_dup_str_n(arena, dst, src.data, src.len); } SOL_API int sol_arena_slice_sprintf(struct sol_arena *arena, struct sol_str_slice *dst, const char *fmt, ...) { va_list ap; char *str; int r; va_start(ap, fmt); r = vasprintf(&str, fmt, ap); va_end(ap); SOL_INT_CHECK(r, < 0, r); dst->data = str; dst->len = r; r = sol_ptr_vector_append(&arena->str_vector, str); if (r < 0) { free(str); return r; } return 0; } SOL_API char * sol_arena_strdup(struct sol_arena *arena, const char *str) { SOL_NULL_CHECK(str, NULL); return sol_arena_str_dup_n(arena, str, strlen(str)); } SOL_API char * sol_arena_str_dup_n(struct sol_arena *arena, const char *str, size_t n) { char *result; int r; SOL_NULL_CHECK(arena, NULL); SOL_NULL_CHECK(str, NULL); SOL_INT_CHECK(n, <= 0, NULL); result = strndup(str, n); SOL_NULL_CHECK(result, NULL); r = sol_ptr_vector_append(&arena->str_vector, result); if (r < 0) { free(result); return NULL; } return result; } SOL_API char * sol_arena_strdup_slice(struct sol_arena *arena, const struct sol_str_slice slice) { return sol_arena_str_dup_n(arena, slice.data, slice.len); }
/* * Copyright (c) 2002 Michael David Adams. * All rights reserved. */ /* __START_OF_JASPER_LICENSE__ * * JasPer License Version 2.0 * * Copyright (c) 1999-2000 Image Power, Inc. * Copyright (c) 1999-2000 The University of British Columbia * Copyright (c) 2001-2003 Michael David Adams * * All rights reserved. * * Permission is hereby granted, free of charge, to any person (the * "User") 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, 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: * * 1. The above copyright notices and this permission notice (which * includes the disclaimer below) shall be included in all copies or * substantial portions of the Software. * * 2. The name of a copyright holder shall not be used to endorse or * promote products derived from the Software without specific prior * written permission. * * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS * LICENSE. NO USE OF THE SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER * THIS DISCLAIMER. THE SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS * "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 OF THIRD PARTY RIGHTS. IN NO * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. NO ASSURANCES ARE * PROVIDED BY THE COPYRIGHT HOLDERS THAT THE SOFTWARE DOES NOT INFRINGE * THE PATENT OR OTHER INTELLECTUAL PROPERTY RIGHTS OF ANY OTHER ENTITY. * EACH COPYRIGHT HOLDER DISCLAIMS ANY LIABILITY TO THE USER FOR CLAIMS * BROUGHT BY ANY OTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL * PROPERTY RIGHTS OR OTHERWISE. AS A CONDITION TO EXERCISING THE RIGHTS * GRANTED HEREUNDER, EACH USER HEREBY ASSUMES SOLE RESPONSIBILITY TO SECURE * ANY OTHER INTELLECTUAL PROPERTY RIGHTS NEEDED, IF ANY. THE SOFTWARE * IS NOT FAULT-TOLERANT AND IS NOT INTENDED FOR USE IN MISSION-CRITICAL * SYSTEMS, SUCH AS THOSE USED IN THE OPERATION OF NUCLEAR FACILITIES, * AIRCRAFT NAVIGATION OR COMMUNICATION SYSTEMS, AIR TRAFFIC CONTROL * SYSTEMS, DIRECT LIFE SUPPORT MACHINES, OR WEAPONS SYSTEMS, IN WHICH * THE FAILURE OF THE SOFTWARE OR SYSTEM COULD LEAD DIRECTLY TO DEATH, * PERSONAL INJURY, OR SEVERE PHYSICAL OR ENVIRONMENTAL DAMAGE ("HIGH * RISK ACTIVITIES"). THE COPYRIGHT HOLDERS SPECIFICALLY DISCLAIM ANY * EXPRESS OR IMPLIED WARRANTY OF FITNESS FOR HIGH RISK ACTIVITIES. * * __END_OF_JASPER_LICENSE__ */ #ifndef PNM_ENC_H #define PNM_ENC_H typedef struct { int numcmpts; int cmpts[4]; } pnm_enc_t; #endif
#include <app_memory/app_memdomain.h> #include <misc/dlist.h> #include <stdarg.h> #include <string.h> /* * Initializes a double linked-list for the calculation of * memory subsections. */ sys_dlist_t app_mem_list = SYS_DLIST_STATIC_INIT(&app_mem_list); /* * The following zeroizes each "bss" part of each subsection * as per the entries in the list. */ void app_bss_zero(void) { sys_dnode_t *node, *next_node; SYS_DLIST_FOR_EACH_NODE_SAFE(&app_mem_list, node, next_node) { struct app_region *region = CONTAINER_OF(node, struct app_region, lnode); (void)memset(region->bmem_start, 0, region->bmem_size); } } /* * The following calculates the size of each subsection and adds * the computed sizes to the region structures. These calculations * are needed both for zeroizing "bss" parts of the partitions and * for the creation of the k_mem_partition. */ void app_calc_size(void) { sys_dnode_t *node, *next_node; SYS_DLIST_FOR_EACH_NODE_SAFE(&app_mem_list, node, next_node) { #ifndef CONFIG_MPU_REQUIRES_POWER_OF_TWO_ALIGNMENT if (sys_dlist_is_tail(&app_mem_list, node)) { struct app_region *region = CONTAINER_OF(node, struct app_region, lnode); region->bmem_size = _app_smem_end - (char *)region->bmem_start; region->dmem_size = (char *)region->bmem_start - (char *)region->dmem_start; region->smem_size = region->bmem_size + region->dmem_size; region->partition[0].size = region->dmem_size + region->bmem_size; } else { struct app_region *region = CONTAINER_OF(node, struct app_region, lnode); struct app_region *nRegion = CONTAINER_OF(next_node, struct app_region, lnode); region->bmem_size = (char *)nRegion->dmem_start - (char *)region->bmem_start; region->dmem_size = (char *)region->bmem_start - (char *)region->dmem_start; region->smem_size = region->bmem_size + region->dmem_size; region->partition[0].size = region->dmem_size + region->bmem_size; } #else /* For power of 2 MPUs linker provides support to help us * calculate the region sizes. */ struct app_region *region = CONTAINER_OF(node, struct app_region, lnode); region->dmem_size = (char *)region->bmem_start - (char *)region->dmem_start; region->bmem_size = (char *)region->smem_size - (char *)region->dmem_size; region->partition[0].size = (s32_t)region->smem_size; #endif /* CONFIG_MPU_REQUIRES_POWER_OF_TWO_ALIGNMENT */ } } /* * "Initializes" by calculating subsection sizes and then * zeroizing "bss" regions. */ void appmem_init_app_memory(void) { app_calc_size(); app_bss_zero(); }
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* Fluent Bit * ========== * Copyright (C) 2019-2021 The Fluent Bit Authors * Copyright (C) 2015-2018 Treasure Data 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 FLB_KAFKA_H #define FLB_KAFKA_H #include <monkey/mk_core.h> #include <fluent-bit/flb_info.h> #include <fluent-bit/flb_config.h> #include <rdkafka.h> #define FLB_KAFKA_BROKERS "127.0.0.1" #define FLB_KAFKA_TOPIC "fluent-bit" struct flb_kafka { rd_kafka_t *rk; char *brokers; }; rd_kafka_conf_t *flb_kafka_conf_create(struct flb_kafka *kafka, struct mk_list *properties, int with_group_id); rd_kafka_topic_partition_list_t *flb_kafka_parse_topics(const char *topics_str); #endif
#include <assert.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <libconflate/conflate.h> #include "conflate_internal.h" #include "rest.h" /* Randomly generated by a fair dice roll */ #define INITIALIZATION_MAGIC 142285011 #define HTTP_PREFIX "HTTP:" void run_conflate(void *); conflate_config_t* dup_conf(conflate_config_t c) { conflate_config_t *rv = calloc(sizeof(conflate_config_t), 1); assert(rv); rv->jid = safe_strdup(c.jid); rv->pass = safe_strdup(c.pass); if (c.host) { rv->host = safe_strdup(c.host); } rv->software = safe_strdup(c.software); rv->version = safe_strdup(c.version); rv->save_path = safe_strdup(c.save_path); rv->userdata = c.userdata; rv->log = c.log; rv->new_config = c.new_config; rv->initialization_marker = (void*)INITIALIZATION_MAGIC; return rv; } void init_conflate(conflate_config_t *conf) { assert(conf); memset(conf, 0x00, sizeof(conflate_config_t)); conf->log = conflate_stderr_logger; conf->initialization_marker = (void*)INITIALIZATION_MAGIC; } bool start_conflate(conflate_config_t conf) { conflate_handle_t *handle; void (*run_func)(void*) = NULL; /* Don't start if we don't believe initialization has occurred. */ if (conf.initialization_marker != (void*)INITIALIZATION_MAGIC) { assert(conf.initialization_marker == (void*)INITIALIZATION_MAGIC); return false; } handle = calloc(1, sizeof(conflate_handle_t)); assert(handle); if (strncmp(HTTP_PREFIX, conf.host, strlen(HTTP_PREFIX))) { run_func = &run_rest_conflate; } else { run_func = &run_conflate; conflate_init_commands(); } handle->conf = dup_conf(conf); if (cb_create_thread(&handle->thread, run_func, handle, 1) == 0) { return true; } else { perror("Failed to create thread"); } return false; }
// Copyright 2015 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_RENDERER_MEDIA_MEDIA_RECORDER_HANDLER_H_ #define CONTENT_RENDERER_MEDIA_MEDIA_RECORDER_HANDLER_H_ #include <memory> #include "base/compiler_specific.h" #include "base/macros.h" #include "base/memory/weak_ptr.h" #include "base/strings/string_piece.h" #include "base/threading/thread_checker.h" #include "content/common/content_export.h" #include "content/renderer/media/video_track_recorder.h" #include "third_party/WebKit/public/platform/WebMediaRecorderHandler.h" #include "third_party/WebKit/public/platform/WebMediaStream.h" namespace blink { class WebMediaRecorderHandlerClient; class WebString; } // namespace blink namespace media { class AudioBus; class AudioParameters; class VideoFrame; class WebmMuxer; } // namespace media namespace content { class AudioTrackRecorder; // MediaRecorderHandler orchestrates the creation, lifetime management and // mapping between: // - MediaStreamTrack(s) providing data, // - {Audio,Video}TrackRecorders encoding that data, // - a WebmMuxer class multiplexing encoded data into a WebM container, and // - a single recorder client receiving this contained data. // All methods are called on the same thread as construction and destruction, // i.e. the Main Render thread. (Note that a BindToCurrentLoop is used to // guarantee this, since VideoTrackRecorder sends back frames on IO thread.) class CONTENT_EXPORT MediaRecorderHandler final : public NON_EXPORTED_BASE(blink::WebMediaRecorderHandler) { public: MediaRecorderHandler(); ~MediaRecorderHandler() override; // blink::WebMediaRecorderHandler. bool canSupportMimeType(const blink::WebString& web_type, const blink::WebString& web_codecs) override; bool initialize(blink::WebMediaRecorderHandlerClient* client, const blink::WebMediaStream& media_stream, const blink::WebString& type, const blink::WebString& codecs, int32_t audio_bits_per_second, int32_t video_bits_per_second) override; bool start() override; bool start(int timeslice) override; void stop() override; void pause() override; void resume() override; private: friend class MediaRecorderHandlerTest; void OnEncodedVideo(const scoped_refptr<media::VideoFrame>& video_frame, std::unique_ptr<std::string> encoded_data, base::TimeTicks timestamp, bool is_key_frame); void OnEncodedAudio(const media::AudioParameters& params, std::unique_ptr<std::string> encoded_data, base::TimeTicks timestamp); void WriteData(base::StringPiece data); void OnVideoFrameForTesting(const scoped_refptr<media::VideoFrame>& frame, const base::TimeTicks& timestamp); void OnAudioBusForTesting(const media::AudioBus& audio_bus, const base::TimeTicks& timestamp); void SetAudioFormatForTesting(const media::AudioParameters& params); // Bound to the main render thread. base::ThreadChecker main_render_thread_checker_; // Sanitized video and audio bitrate settings passed on initialize(). int32_t video_bits_per_second_; int32_t audio_bits_per_second_; // Video Codec, VP8 is used by default. VideoTrackRecorder::CodecId codec_id_; // |client_| has no notion of time, thus may configure us via start(timeslice) // to notify it after a certain |timeslice_| has passed. We use a moving // |slice_origin_timestamp_| to track those time chunks. base::TimeDelta timeslice_; base::TimeTicks slice_origin_timestamp_; bool recording_; blink::WebMediaStream media_stream_; // The MediaStream being recorded. // |client_| is a weak pointer, and is valid for the lifetime of this object. blink::WebMediaRecorderHandlerClient* client_; std::vector<std::unique_ptr<VideoTrackRecorder>> video_recorders_; std::vector<std::unique_ptr<AudioTrackRecorder>> audio_recorders_; // Worker class doing the actual Webm Muxing work. std::unique_ptr<media::WebmMuxer> webm_muxer_; base::WeakPtrFactory<MediaRecorderHandler> weak_factory_; DISALLOW_COPY_AND_ASSIGN(MediaRecorderHandler); }; } // namespace content #endif // CONTENT_RENDERER_MEDIA_MEDIA_RECORDER_HANDLER_H_
// Copyright 2015 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 COMPONENTS_SECURITY_STATE_SECURITY_STATE_MODEL_CLIENT_H_ #define COMPONENTS_SECURITY_STATE_SECURITY_STATE_MODEL_CLIENT_H_ #include "base/macros.h" #include "base/memory/ref_counted.h" #include "components/security_state/security_state_model.h" #include "net/cert/cert_status_flags.h" namespace net { class X509Certificate; } // namespace net namespace security_state { // Provides embedder-specific information that a SecurityStateModel // needs to determine the page's security status. class SecurityStateModelClient { public: SecurityStateModelClient() {} virtual ~SecurityStateModelClient() {} // Retrieves the visible security state that is relevant to the // SecurityStateModel. virtual void GetVisibleSecurityState( SecurityStateModel::VisibleSecurityState* state) = 0; // Returns true if the page or request is known to be loaded with a // certificate installed by the system administrator. virtual bool UsedPolicyInstalledCertificate() = 0; // Returns true if the given |url|'s origin should be considered secure. virtual bool IsOriginSecure(const GURL& url) = 0; private: DISALLOW_COPY_AND_ASSIGN(SecurityStateModelClient); }; } // namespace security_state #endif // COMPONENTS_SECURITY_STATE_SECURITY_STATE_MODEL_CLIENT_H_
/**************************************************************************** Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org 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. Use any of these editors to generate BMFonts: http://glyphdesigner.71squared.com/ (Commercial, Mac OS X) http://www.n4te.com/hiero/hiero.jnlp (Free, Java) http://slick.cokeandcode.com/demos/hiero.jnlp (Free, Java) http://www.angelcode.com/products/bmfont/ (Free, Windows only) ****************************************************************************/ #ifndef __CCBITMAP_FONT_ATLAS_H__ #define __CCBITMAP_FONT_ATLAS_H__ #include "CCLabel.h" NS_CC_BEGIN /** @brief LabelBMFont is a subclass of SpriteBatchNode. Features: - Treats each character like a Sprite. This means that each individual character can be: - rotated - scaled - translated - tinted - change the opacity - It can be used as part of a menu item. - anchorPoint can be used to align the "label" - Supports AngelCode text format Limitations: - All inner characters are using an anchorPoint of (0.5f, 0.5f) and it is not recommend to change it because it might affect the rendering LabelBMFont implements the protocol LabelProtocol, like Label and LabelAtlas. LabelBMFont has the flexibility of Label, the speed of LabelAtlas and all the features of Sprite. If in doubt, use LabelBMFont instead of LabelAtlas / Label. Supported editors: http://glyphdesigner.71squared.com/ (Commercial, Mac OS X) http://www.n4te.com/hiero/hiero.jnlp (Free, Java) http://slick.cokeandcode.com/demos/hiero.jnlp (Free, Java) http://www.angelcode.com/products/bmfont/ (Free, Windows only) @since v0.8 */ class CC_DLL CC_DEPRECATED_ATTRIBUTE LabelBMFont : public Node, public LabelProtocol, public BlendProtocol { public: /** * @js ctor */ LabelBMFont(); /** * @js NA * @lua NA */ virtual ~LabelBMFont(); /** creates a bitmap font atlas with an initial string and the FNT file */ static LabelBMFont * create(const std::string& str, const std::string& fntFile, float width = 0, TextHAlignment alignment = TextHAlignment::LEFT,const Point& imageOffset = Point::ZERO); /** Creates an label. */ static LabelBMFont * create(); /** init a bitmap font atlas with an initial string and the FNT file */ bool initWithString(const std::string& str, const std::string& fntFile, float width = 0, TextHAlignment alignment = TextHAlignment::LEFT,const Point& imageOffset = Point::ZERO); // super method virtual void setString(const std::string& newString) override; virtual const std::string& getString() const override; virtual void setAlignment(TextHAlignment alignment); virtual void setWidth(float width); virtual void setLineBreakWithoutSpace(bool breakWithoutSpace); // RGBAProtocol virtual bool isOpacityModifyRGB() const; virtual void setOpacityModifyRGB(bool isOpacityModifyRGB); void setFntFile(const std::string& fntFile, const Point& imageOffset = Point::ZERO); const std::string& getFntFile() const; virtual void setBlendFunc(const BlendFunc &blendFunc) override; virtual const BlendFunc &getBlendFunc() const override; virtual Sprite * getLetter(int ID); virtual Node * getChildByTag(int tag) override; virtual void setColor(const Color3B& color) override; virtual const Size& getContentSize() const override; virtual Rect getBoundingBox() const override; virtual std::string getDescription() const override; #if CC_LABELBMFONT_DEBUG_DRAW virtual void draw(); #endif // CC_LABELBMFONT_DEBUG_DRAW private: // name of fntFile std::string _fntFile; Label* _label; }; // end of GUI group /// @} /// @} NS_CC_END #endif //__CCBITMAP_FONT_ATLAS_H__
/*- * Copyright (c) 2010 Kip Macy * All rights reserved. * Copyright (c) 2013 Patrick Kelsey. 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. * * Derived in part from libplebnet's pn_glue.c. * */ #include <sys/param.h> #include <sys/systm.h> #include <vm/vm.h> #include <vm/vm_object.h> struct vm_object kernel_object_store; struct vm_object kmem_object_store;
/* * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). * Copyright (C) 2006 Apple Inc. * * 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 PopupMenuClient_h #define PopupMenuClient_h #include "LayoutUnit.h" #include "PopupMenuStyle.h" #include "ScrollTypes.h" #include <wtf/Forward.h> namespace WebCore { class Color; class FontSelector; class HostWindow; class Scrollbar; class ScrollableArea; class PopupMenuClient { public: virtual ~PopupMenuClient() {} virtual void valueChanged(unsigned listIndex, bool fireEvents = true) = 0; virtual void selectionChanged(unsigned listIndex, bool fireEvents = true) = 0; virtual void selectionCleared() = 0; virtual String itemText(unsigned listIndex) const = 0; virtual String itemLabel(unsigned listIndex) const = 0; virtual String itemIcon(unsigned listIndex) const = 0; virtual String itemToolTip(unsigned listIndex) const = 0; virtual String itemAccessibilityText(unsigned listIndex) const = 0; virtual bool itemIsEnabled(unsigned listIndex) const = 0; virtual PopupMenuStyle itemStyle(unsigned listIndex) const = 0; virtual PopupMenuStyle menuStyle() const = 0; virtual int clientInsetLeft() const = 0; virtual int clientInsetRight() const = 0; virtual LayoutUnit clientPaddingLeft() const = 0; virtual LayoutUnit clientPaddingRight() const = 0; virtual int listSize() const = 0; virtual int selectedIndex() const = 0; virtual void popupDidHide() = 0; virtual bool itemIsSeparator(unsigned listIndex) const = 0; virtual bool itemIsLabel(unsigned listIndex) const = 0; virtual bool itemIsSelected(unsigned listIndex) const = 0; virtual bool shouldPopOver() const = 0; virtual bool valueShouldChangeOnHotTrack() const = 0; virtual void setTextFromItem(unsigned listIndex) = 0; virtual void listBoxSelectItem(int /*listIndex*/, bool /*allowMultiplySelections*/, bool /*shift*/, bool /*fireOnChangeNow*/ = true) { ASSERT_NOT_REACHED(); } virtual bool multiple() const { ASSERT_NOT_REACHED(); return false; } virtual FontSelector* fontSelector() const = 0; virtual HostWindow* hostWindow() const = 0; virtual PassRefPtr<Scrollbar> createScrollbar(ScrollableArea*, ScrollbarOrientation, ScrollbarControlSize) = 0; }; } #endif
/* * Copyright (C) 2010 Google, Inc. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY APPLE 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 APPLE INC. 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 HTMLScriptRunnerHost_h #define HTMLScriptRunnerHost_h #include "core/CoreExport.h" #include "wtf/Forward.h" namespace blink { class HTMLInputStream; class Resource; class Visitor; class CORE_EXPORT HTMLScriptRunnerHost : public GarbageCollectedMixin { public: virtual ~HTMLScriptRunnerHost() {} DEFINE_INLINE_VIRTUAL_TRACE() {} virtual void notifyScriptLoaded(Resource*) = 0; virtual HTMLInputStream& inputStream() = 0; virtual bool hasPreloadScanner() const = 0; virtual void appendCurrentInputStreamToPreloadScannerAndScan() = 0; }; } // namespace blink #endif
/* * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org> * Copyright (C) 2007, 2008, 2009 Apple Inc. All rights reserved. * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 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 APPLE COMPUTER, 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 APPLE COMPUTER, INC. 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 THIRD_PARTY_BLINK_RENDERER_PLATFORM_GRAPHICS_IMAGE_DATA_BUFFER_H_ #define THIRD_PARTY_BLINK_RENDERER_PLATFORM_GRAPHICS_IMAGE_DATA_BUFFER_H_ #include <memory> #include "base/memory/scoped_refptr.h" #include "third_party/blink/renderer/platform/geometry/float_rect.h" #include "third_party/blink/renderer/platform/geometry/int_size.h" #include "third_party/blink/renderer/platform/graphics/graphics_types.h" #include "third_party/blink/renderer/platform/graphics/static_bitmap_image.h" #include "third_party/blink/renderer/platform/platform_export.h" #include "third_party/blink/renderer/platform/wtf/allocator/allocator.h" #include "third_party/blink/renderer/platform/wtf/text/wtf_string.h" #include "third_party/blink/renderer/platform/wtf/vector.h" #include "third_party/skia/include/core/SkRefCnt.h" namespace blink { class PLATFORM_EXPORT ImageDataBuffer { USING_FAST_MALLOC(ImageDataBuffer); public: static std::unique_ptr<ImageDataBuffer> Create( scoped_refptr<StaticBitmapImage>); static std::unique_ptr<ImageDataBuffer> Create(const SkPixmap&); String ToDataURL(const ImageEncodingMimeType mime_type, const double& quality) const; bool EncodeImage(const ImageEncodingMimeType mime_type, const double& quality, Vector<unsigned char>* encoded_image) const; const unsigned char* Pixels() const; const IntSize& size() const { return size_; } int Height() const { return size_.height(); } int Width() const { return size_.width(); } size_t ComputeByteSize() const { return pixmap_.computeByteSize(); } private: ImageDataBuffer(const IntSize&, const unsigned char*, const CanvasColorParams&); ImageDataBuffer(const SkPixmap&); ImageDataBuffer(scoped_refptr<StaticBitmapImage>); bool IsValid() { return is_valid_; } // Only used by Create() bool EncodeImageInternal(const ImageEncodingMimeType mime_type, const double& quality, Vector<unsigned char>* encoded_image, const SkPixmap& pixmap) const; sk_sp<SkImage> retained_image_; SkPixmap pixmap_; bool is_valid_ = false; IntSize size_; }; } // namespace blink #endif // THIRD_PARTY_BLINK_RENDERER_PLATFORM_GRAPHICS_IMAGE_DATA_BUFFER_H_
/* * Copyright (C) 2009, 2010, 2011, 2012 Stephen F. Booth <me@sbooth.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: * * - 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 Stephen F. Booth 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 <CoreFoundation/CoreFoundation.h> #include <AudioToolbox/AudioToolbox.h> class AudioDecoder; // ======================================== // Enums // ======================================== enum { eDecoderStateDataFlagDecodingStarted = 1u << 0, eDecoderStateDataFlagDecodingFinished = 1u << 1, eDecoderStateDataFlagRenderingStarted = 1u << 2, eDecoderStateDataFlagRenderingFinished = 1u << 3, eDecoderStateDataFlagStopDecoding = 1u << 4 }; // ======================================== // State data for decoders that are decoding and/or rendering // ======================================== class DecoderStateData { public: DecoderStateData(AudioDecoder *decoder); ~DecoderStateData(); DecoderStateData(const DecoderStateData& rhs) = delete; DecoderStateData& operator=(const DecoderStateData& rhs) = delete; void AllocateBufferList(UInt32 capacityFrames); void DeallocateBufferList(); void ResetBufferList(); UInt32 ReadAudio(UInt32 frameCount); AudioDecoder *mDecoder; AudioBufferList *mBufferList; UInt32 mBufferCapacityFrames; SInt64 mTimeStamp; SInt64 mTotalFrames; volatile SInt64 mFramesRendered; SInt64 mFrameToSeek; volatile uint32_t mFlags; private: DecoderStateData(); };
#include "e-types.h" #include "tag.h" #include "devsim7708.h" #include "devscc.h" #include "sh7708.h" #include "devrtc.h" #include "misc.h" #define CALIBRATE 8 /* Calibrated to give you ~correct delay @ 60MHz */ /* Needed by print */ void sccputc(int device, uchar ch) { while (!(*SCC_SCSSR & TX_RDY)); *SCC_SCTDR = ch; *SCC_SCSSR &= TX_CLR; return; } /* Needed by lprint */ void devlogprintputc(int device, uchar ch) { *DEVLOGPRINT = ch; return; } void xudelay(ulong usecs) { volatile int max, i; max = CALIBRATE*usecs; for (i = 0; i < max; i++) { } } void xusleep(ulong usecs) { ulong time = devrtc_getusecs(); while ((devrtc_getusecs() - time) < usecs) { sleep(); } } int pow10(int y) { int i, ret = 1; for (i = 0; i < y; i++) { ret *= 10; } return ret; }
/* * Copyright (C) 2013 Google, Inc. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY GOOGLE 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 GOOGLE INC. 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 BackgroundHTMLInputStream_h #define BackgroundHTMLInputStream_h #include "core/platform/text/SegmentedString.h" #include <wtf/text/WTFString.h> #include <wtf/Vector.h> namespace WebCore { typedef size_t HTMLInputCheckpoint; class BackgroundHTMLInputStream { WTF_MAKE_NONCOPYABLE(BackgroundHTMLInputStream); public: BackgroundHTMLInputStream(); void append(const String&); void close(); SegmentedString& current() { return m_current; } // An HTMLInputCheckpoint is valid until the next call to rewindTo, at which // point all outstanding checkpoints are invalidated. HTMLInputCheckpoint createCheckpoint(); void rewindTo(HTMLInputCheckpoint, const String& unparsedInput); void invalidateCheckpointsBefore(HTMLInputCheckpoint); size_t outstandingCheckpointCount() const { return m_checkpoints.size() - m_firstValidCheckpointIndex; } private: struct Checkpoint { Checkpoint(const SegmentedString& i, size_t n) : input(i), numberOfSegmentsAlreadyAppended(n) { } SegmentedString input; size_t numberOfSegmentsAlreadyAppended; #ifndef NDEBUG bool isNull() const { return input.isEmpty() && !numberOfSegmentsAlreadyAppended; } #endif void clear() { input.clear(); numberOfSegmentsAlreadyAppended = 0; } }; SegmentedString m_current; Vector<String> m_segments; Vector<Checkpoint> m_checkpoints; // Note: These indicies may === vector.size(), in which case there are no valid checkpoints/segments at this time. size_t m_firstValidCheckpointIndex; size_t m_firstValidSegmentIndex; }; } #endif
/* * Copyright (c) 2010 Google Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * 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 Google Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE 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 HTMLOutputElement_h #define HTMLOutputElement_h #include "core/dom/DOMSettableTokenList.h" #include "core/html/HTMLFormControlElement.h" namespace blink { class HTMLOutputElement FINAL : public HTMLFormControlElement { public: static PassRefPtrWillBeRawPtr<HTMLOutputElement> create(Document&, HTMLFormElement*); virtual bool willValidate() const OVERRIDE { return false; } String value() const; void setValue(const String&); String defaultValue() const; void setDefaultValue(const String&); void setFor(const AtomicString&); DOMSettableTokenList* htmlFor() const; virtual bool canContainRangeEndPoint() const OVERRIDE { return false; } virtual void trace(Visitor*) OVERRIDE; private: HTMLOutputElement(Document&, HTMLFormElement*); virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERRIDE; virtual const AtomicString& formControlType() const OVERRIDE; virtual bool isEnumeratable() const OVERRIDE { return true; } virtual bool supportLabels() const OVERRIDE { return true; } virtual bool supportsFocus() const OVERRIDE; virtual void childrenChanged(const ChildrenChange&) OVERRIDE; virtual void resetImpl() OVERRIDE; bool m_isDefaultValueMode; String m_defaultValue; RefPtrWillBeMember<DOMSettableTokenList> m_tokens; }; } // namespace #endif
#pragma once #include <mfast.h> #include <sstream> #include <vector> #include "field_masks.h" namespace mfast { namespace SQLite3 { struct insert_statements { std::string insert_item_stmt; std::string find_key_stmt; int primary_key_index; }; class tables_creator : public field_instruction_visitor { public: typedef std::map<unsigned, insert_statements> insert_map_t; tables_creator(insert_map_t &insert_statements, const field_masks &masks, const char *foreign_key_table, const char *foreign_key_name, const char *primary_key_type); tables_creator(insert_map_t &insert_statements, const field_masks &masks, bool find_key_needed = false); std::string create_statements(); virtual void visit(const int32_field_instruction *, void *); virtual void visit(const uint32_field_instruction *, void *); virtual void visit(const int64_field_instruction *, void *); virtual void visit(const uint64_field_instruction *, void *); virtual void visit(const decimal_field_instruction *, void *); virtual void visit(const ascii_field_instruction *, void *); virtual void visit(const unicode_field_instruction *, void *); virtual void visit(const byte_vector_field_instruction *, void *); virtual void visit(const group_field_instruction *, void *); virtual void visit(const sequence_field_instruction *, void *); virtual void visit(const template_instruction *, void *); virtual void visit(const templateref_instruction *, void *); virtual void visit(const int32_vector_field_instruction *, void *); virtual void visit(const uint32_vector_field_instruction *, void *); virtual void visit(const int64_vector_field_instruction *, void *); virtual void visit(const uint64_vector_field_instruction *, void *); virtual void visit(const enum_field_instruction *, void *); const char *table_name() const; const char *primary_key_name() const; const char *primary_key_type() const; std::string parameter_list(); unsigned num_columns() const { return num_columns_; } private: const char *extra(const field_instruction *inst, const char *type, void *pIndex); void add_foreign_key(std::ostream &os, const char *tablename, const char *primary_key_name, const char *primary_key_type); void traverse_subinstructions(const group_field_instruction *inst); private: insert_map_t &insert_statements_; const field_masks masks_; std::stringstream create_prefix_; std::stringstream create_current_; std::stringstream create_postfix_; std::stringstream foreign_key_expression_; std::vector<const char *> parameters_; std::string table_name_; std::string primary_key_name_; std::string primary_key_type_; int primary_key_index_; unsigned num_columns_; bool find_key_needed_; }; } /* SQLite3 */ } /* mfast */
/* * * Copyright 2015, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * 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 Google Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE 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 GRPC_INTERNAL_CORE_IOMGR_UDP_SERVER_H #define GRPC_INTERNAL_CORE_IOMGR_UDP_SERVER_H #include "src/core/iomgr/endpoint.h" /* Forward decl of grpc_server */ typedef struct grpc_server grpc_server; /* Forward decl of grpc_udp_server */ typedef struct grpc_udp_server grpc_udp_server; /* Called when data is available to read from the socket. */ typedef void (*grpc_udp_server_read_cb)(grpc_fd *emfd, grpc_server *server); /* Create a server, initially not bound to any ports */ grpc_udp_server *grpc_udp_server_create(void); /* Start listening to bound ports */ void grpc_udp_server_start(grpc_exec_ctx *exec_ctx, grpc_udp_server *udp_server, grpc_pollset **pollsets, size_t pollset_count, grpc_server *server); int grpc_udp_server_get_fd(grpc_udp_server *s, unsigned index); /* Add a port to the server, returning port number on success, or negative on failure. The :: and 0.0.0.0 wildcard addresses are treated identically, accepting both IPv4 and IPv6 connections, but :: is the preferred style. This usually creates one socket, but possibly two on systems which support IPv6, but not dualstack sockets. */ /* TODO(ctiller): deprecate this, and make grpc_udp_server_add_ports to handle all of the multiple socket port matching logic in one place */ int grpc_udp_server_add_port(grpc_udp_server *s, const void *addr, size_t addr_len, grpc_udp_server_read_cb read_cb); void grpc_udp_server_destroy(grpc_exec_ctx *exec_ctx, grpc_udp_server *server, grpc_closure *on_done); /* Write the contents of buffer to the underlying UDP socket. */ /* void grpc_udp_server_write(grpc_udp_server *s, const char *buffer, int buf_len, const struct sockaddr* to); */ #endif /* GRPC_INTERNAL_CORE_IOMGR_UDP_SERVER_H */
//===-- Debug.h -------------------------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// #ifndef liblldb_Debug_h_ #define liblldb_Debug_h_ // C Includes // C++ Includes #include <vector> // Other libraries and framework includes // Project includes #include "lldb/lldb-private.h" namespace lldb_private { //------------------------------------------------------------------ // Tells a thread what it needs to do when the process is resumed. //------------------------------------------------------------------ struct ResumeAction { lldb::tid_t tid; // The thread ID that this action applies to, // LLDB_INVALID_THREAD_ID for the default thread // action lldb::StateType state; // Valid values are eStateStopped/eStateSuspended, // eStateRunning, and eStateStepping. int signal; // When resuming this thread, resume it with this signal if this // value is > 0 }; //------------------------------------------------------------------ // A class that contains instructions for all threads for // NativeProcessProtocol::Resume(). Each thread can either run, stay suspended, // or step when the process is resumed. We optionally have the ability to also // send a signal to the thread when the action is run or step. //------------------------------------------------------------------ class ResumeActionList { public: ResumeActionList() : m_actions(), m_signal_handled() {} ResumeActionList(lldb::StateType default_action, int signal) : m_actions(), m_signal_handled() { SetDefaultThreadActionIfNeeded(default_action, signal); } ResumeActionList(const ResumeAction *actions, size_t num_actions) : m_actions(), m_signal_handled() { if (actions && num_actions) { m_actions.assign(actions, actions + num_actions); m_signal_handled.assign(num_actions, false); } } ~ResumeActionList() = default; bool IsEmpty() const { return m_actions.empty(); } void Append(const ResumeAction &action) { m_actions.push_back(action); m_signal_handled.push_back(false); } void AppendAction(lldb::tid_t tid, lldb::StateType state, int signal = 0) { ResumeAction action = {tid, state, signal}; Append(action); } void AppendResumeAll() { AppendAction(LLDB_INVALID_THREAD_ID, lldb::eStateRunning); } void AppendSuspendAll() { AppendAction(LLDB_INVALID_THREAD_ID, lldb::eStateStopped); } void AppendStepAll() { AppendAction(LLDB_INVALID_THREAD_ID, lldb::eStateStepping); } const ResumeAction *GetActionForThread(lldb::tid_t tid, bool default_ok) const { const size_t num_actions = m_actions.size(); for (size_t i = 0; i < num_actions; ++i) { if (m_actions[i].tid == tid) return &m_actions[i]; } if (default_ok && tid != LLDB_INVALID_THREAD_ID) return GetActionForThread(LLDB_INVALID_THREAD_ID, false); return nullptr; } size_t NumActionsWithState(lldb::StateType state) const { size_t count = 0; const size_t num_actions = m_actions.size(); for (size_t i = 0; i < num_actions; ++i) { if (m_actions[i].state == state) ++count; } return count; } bool SetDefaultThreadActionIfNeeded(lldb::StateType action, int signal) { if (GetActionForThread(LLDB_INVALID_THREAD_ID, true) == nullptr) { // There isn't a default action so we do need to set it. ResumeAction default_action = {LLDB_INVALID_THREAD_ID, action, signal}; m_actions.push_back(default_action); m_signal_handled.push_back(false); return true; // Return true as we did add the default action } return false; } void SetSignalHandledForThread(lldb::tid_t tid) const { if (tid != LLDB_INVALID_THREAD_ID) { const size_t num_actions = m_actions.size(); for (size_t i = 0; i < num_actions; ++i) { if (m_actions[i].tid == tid) m_signal_handled[i] = true; } } } const ResumeAction *GetFirst() const { return m_actions.data(); } size_t GetSize() const { return m_actions.size(); } void Clear() { m_actions.clear(); m_signal_handled.clear(); } protected: std::vector<ResumeAction> m_actions; mutable std::vector<bool> m_signal_handled; }; struct ThreadStopInfo { lldb::StopReason reason; union { // eStopReasonSignal struct { uint32_t signo; } signal; // eStopReasonException struct { uint64_t type; uint32_t data_count; lldb::addr_t data[8]; } exception; } details; }; } #endif // liblldb_Debug_h_
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE195_Signed_to_Unsigned_Conversion_Error__fscanf_memcpy_54d.c Label Definition File: CWE195_Signed_to_Unsigned_Conversion_Error.label.xml Template File: sources-sink-54d.tmpl.c */ /* * @description * CWE: 195 Signed to Unsigned Conversion Error * BadSource: fscanf Read data from the console using fscanf() * GoodSource: Positive integer * Sink: memcpy * BadSink : Copy strings using memcpy() with the length of data * Flow Variant: 54 Data flow: data passed as an argument from one function through three others to a fifth; all five functions are in different source files * * */ #include "std_testcase.h" /* all the sinks are the same, we just want to know where the hit originated if a tool flags one */ #ifndef OMITBAD /* bad function declaration */ void CWE195_Signed_to_Unsigned_Conversion_Error__fscanf_memcpy_54e_badSink(int data); void CWE195_Signed_to_Unsigned_Conversion_Error__fscanf_memcpy_54d_badSink(int data) { CWE195_Signed_to_Unsigned_Conversion_Error__fscanf_memcpy_54e_badSink(data); } #endif /* OMITBAD */ #ifndef OMITGOOD /* good function declaration */ void CWE195_Signed_to_Unsigned_Conversion_Error__fscanf_memcpy_54e_goodG2BSink(int data); /* goodG2B uses the GoodSource with the BadSink */ void CWE195_Signed_to_Unsigned_Conversion_Error__fscanf_memcpy_54d_goodG2BSink(int data) { CWE195_Signed_to_Unsigned_Conversion_Error__fscanf_memcpy_54e_goodG2BSink(data); } #endif /* OMITGOOD */
// // RSLCoreDataWorkerTemplate.h // CoreData // // Created by Oleksa Korin on 10/9/10. // Copyright 2010 RedShiftLab. All rights reserved. // #import <CoreData/CoreData.h> @interface NSManagedObject (IDPExtensions) + (NSArray *)fetchEntityWithSortDescriptors:(NSArray *)sortDescriptorsArray predicate:(NSPredicate *)predicate prefetchPaths:(NSArray *)prefetchPathes; + (id)managedObject; - (void)deleteManagedObject; - (void)saveManagedObject; - (void)setCustomValue:(id)value forKey:(NSString *)key; - (id)customValueForKey:(NSString *)key; - (void)addCustomValue:(id)value inMutableSetForKey:(NSString *)key; - (void)removeCustomValue:(id)value inMutableSetForKey:(NSString *)key; - (void)addCustomValues:(NSSet *)values inMutableSetForKey:(NSString *)key; - (void)removeCustomValues:(NSSet *)values inMutableSetForKey:(NSString *)key; // rolls back the changes to the last commited state for just one object, // unlike NSManagedObjectContext rollback, which rolls back entire context - (void)rollback; // Merges changes - (void)refresh; - (void)refreshWithMerge:(BOOL)shouldMerge; - (void)addCustomValues:(NSOrderedSet *)values inMutableOrderedSetForKey:(NSString *)key; - (void)addCustomValue:(id)value inMutableOrderedSetForKey:(NSString *)key; @end
#include "vtk_libxml2_mangle.h" /* * Summary: macros for marking symbols as exportable/importable. * Description: macros for marking symbols as exportable/importable. * * Copy: See Copyright for the status of this software. * * Author: Igor Zlatovic <igor@zlatkovic.com> */ #ifndef __XML_EXPORTS_H__ #define __XML_EXPORTS_H__ /** * XMLPUBFUN, XMLPUBVAR, XMLCALL * * Macros which declare an exportable function, an exportable variable and * the calling convention used for functions. * * Please use an extra block for every platform/compiler combination when * modifying this, rather than overlong #ifdef lines. This helps * readability as well as the fact that different compilers on the same * platform might need different definitions. */ /** * XMLPUBFUN: * * Macros which declare an exportable function */ #define XMLPUBFUN /** * XMLPUBVAR: * * Macros which declare an exportable variable */ #define XMLPUBVAR extern /** * XMLCALL: * * Macros which declare the called convention for exported functions */ #define XMLCALL /** * XMLCDECL: * * Macro which declares the calling convention for exported functions that * use '...'. */ #define XMLCDECL /** DOC_DISABLE */ /* Windows platform with MS compiler */ #if defined(_WIN32) && defined(_MSC_VER) #undef XMLPUBFUN #undef XMLPUBVAR #undef XMLCALL #undef XMLCDECL #if defined(IN_LIBXML) && !defined(LIBXML_STATIC) #define XMLPUBFUN __declspec(dllexport) #define XMLPUBVAR __declspec(dllexport) #else #define XMLPUBFUN #if !defined(LIBXML_STATIC) #define XMLPUBVAR __declspec(dllimport) extern #else #define XMLPUBVAR extern #endif #endif #if defined(LIBXML_FASTCALL) #define XMLCALL __fastcall #else #define XMLCALL __cdecl #endif #define XMLCDECL __cdecl #if !defined _REENTRANT #define _REENTRANT #endif #endif /* Windows platform with Borland compiler */ #if defined(_WIN32) && defined(__BORLANDC__) #undef XMLPUBFUN #undef XMLPUBVAR #undef XMLCALL #undef XMLCDECL #if defined(IN_LIBXML) && !defined(LIBXML_STATIC) #define XMLPUBFUN __declspec(dllexport) #define XMLPUBVAR __declspec(dllexport) extern #else #define XMLPUBFUN #if !defined(LIBXML_STATIC) #define XMLPUBVAR __declspec(dllimport) extern #else #define XMLPUBVAR extern #endif #endif #define XMLCALL __cdecl #define XMLCDECL __cdecl #if !defined _REENTRANT #define _REENTRANT #endif #endif /* Windows platform with GNU compiler (Mingw) */ #if defined(_WIN32) && defined(__MINGW32__) #undef XMLPUBFUN #undef XMLPUBVAR #undef XMLCALL #undef XMLCDECL #if defined(IN_LIBXML) && !defined(LIBXML_STATIC) #define XMLPUBFUN __declspec(dllexport) #define XMLPUBVAR __declspec(dllexport) #else #define XMLPUBFUN #if !defined(LIBXML_STATIC) #define XMLPUBVAR __declspec(dllimport) extern #else #define XMLPUBVAR extern #endif #endif #define XMLCALL __cdecl #define XMLCDECL __cdecl #if !defined _REENTRANT #define _REENTRANT #endif #endif /* Cygwin platform, GNU compiler */ #if defined(_WIN32) && defined(__CYGWIN__) #undef XMLPUBFUN #undef XMLPUBVAR #undef XMLCALL #undef XMLCDECL #if defined(IN_LIBXML) && !defined(LIBXML_STATIC) #define XMLPUBFUN __declspec(dllexport) #define XMLPUBVAR __declspec(dllexport) #else #define XMLPUBFUN #if !defined(LIBXML_STATIC) #define XMLPUBVAR __declspec(dllimport) extern #else #define XMLPUBVAR extern #endif #endif #define XMLCALL __cdecl #define XMLCDECL __cdecl #endif /* Compatibility */ #if !defined(LIBXML_DLL_IMPORT) #define LIBXML_DLL_IMPORT XMLPUBVAR #endif #endif /* __XML_EXPORTS_H__ */
// Copyright 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 COMPONENTS_SESSIONS_CORE_BASE_SESSION_SERVICE_H_ #define COMPONENTS_SESSIONS_CORE_BASE_SESSION_SERVICE_H_ #include "base/basictypes.h" #include "base/callback.h" #include "base/files/file_path.h" #include "base/memory/scoped_vector.h" #include "base/memory/weak_ptr.h" #include "base/task/cancelable_task_tracker.h" #include "components/sessions/core/sessions_export.h" #include "url/gurl.h" namespace sessions { class BaseSessionServiceDelegate; class SerializedNavigationEntry; class SessionCommand; class SessionBackend; // BaseSessionService is the super class of both tab restore service and // session service. It contains commonality needed by both, in particular // it manages a set of SessionCommands that are periodically sent to a // SessionBackend. class SESSIONS_EXPORT BaseSessionService { public: // Identifies the type of session service this is. This is used by the // backend to determine the name of the files. enum SessionType { SESSION_RESTORE, TAB_RESTORE }; typedef base::Callback<void(ScopedVector<SessionCommand>)> GetCommandsCallback; // Creates a new BaseSessionService. After creation you need to invoke // Init. |delegate| will remain owned by the creator and it is guaranteed // that its lifetime surpasses this class. // |type| gives the type of session service, |path| the path to save files to. BaseSessionService(SessionType type, const base::FilePath& path, BaseSessionServiceDelegate* delegate); ~BaseSessionService(); // Moves the current session to the last session. void MoveCurrentSessionToLastSession(); // Deletes the last session. void DeleteLastSession(); // Returns the set of commands which were scheduled to be written. Once // committed to the backend, the commands are removed from here. const ScopedVector<SessionCommand>& pending_commands() { return pending_commands_; } // Whether the next save resets the file before writing to it. void set_pending_reset(bool value) { pending_reset_ = value; } bool pending_reset() const { return pending_reset_; } // Returns the number of commands sent down since the last reset. int commands_since_reset() const { return commands_since_reset_; } // Schedules a command. This adds |command| to pending_commands_ and // invokes StartSaveTimer to start a timer that invokes Save at a later // time. void ScheduleCommand(scoped_ptr<SessionCommand> command); // Appends a command as part of a general rebuild. This will neither count // against a rebuild, nor will it trigger a save of commands. void AppendRebuildCommand(scoped_ptr<SessionCommand> command); // Erase the |old_command| from the list of commands. // The passed command will automatically be deleted. void EraseCommand(SessionCommand* old_command); // Swap a |new_command| into the list of queued commands at the location of // the |old_command|. The |old_command| will be automatically deleted in the // process. void SwapCommand(SessionCommand* old_command, scoped_ptr<SessionCommand> new_command); // Clears all commands from the list. void ClearPendingCommands(); // Starts the timer that invokes Save (if timer isn't already running). void StartSaveTimer(); // Passes all pending commands to the backend for saving. void Save(); // Uses the backend to load the last session commands from disc. |callback| // gets called once the data has arrived. base::CancelableTaskTracker::TaskId ScheduleGetLastSessionCommands( const GetCommandsCallback& callback, base::CancelableTaskTracker* tracker); private: friend class BaseSessionServiceTestHelper; // This posts the task to the SequencedWorkerPool, or run immediately // if the SequencedWorkerPool has been shutdown. void RunTaskOnBackendThread(const tracked_objects::Location& from_here, const base::Closure& task); // The backend object which reads and saves commands. scoped_refptr<SessionBackend> backend_; // Commands we need to send over to the backend. ScopedVector<SessionCommand> pending_commands_; // Whether the backend file should be recreated the next time we send // over the commands. bool pending_reset_; // The number of commands sent to the backend before doing a reset. int commands_since_reset_; BaseSessionServiceDelegate* delegate_; // A token to make sure that all tasks will be serialized. base::SequencedWorkerPool::SequenceToken sequence_token_; // Used to invoke Save. base::WeakPtrFactory<BaseSessionService> weak_factory_; DISALLOW_COPY_AND_ASSIGN(BaseSessionService); }; } // namespace sessions #endif // COMPONENTS_SESSIONS_CORE_BASE_SESSION_SERVICE_H_
/* * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) * * 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 APPLE COMPUTER, 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 APPLE COMPUTER, INC. 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 CustomEvent_h #define CustomEvent_h #include "bindings/v8/ScriptValue.h" #include "bindings/v8/SerializedScriptValue.h" #include "core/dom/Event.h" namespace WebCore { struct CustomEventInit : public EventInit { CustomEventInit(); ScriptValue detail; }; class CustomEvent : public Event { public: virtual ~CustomEvent(); static PassRefPtr<CustomEvent> create() { return adoptRef(new CustomEvent); } static PassRefPtr<CustomEvent> create(const AtomicString& type, const CustomEventInit& initializer) { return adoptRef(new CustomEvent(type, initializer)); } void initCustomEvent(const AtomicString& type, bool canBubble, bool cancelable, const ScriptValue& detail); void initCustomEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<SerializedScriptValue>); virtual const AtomicString& interfaceName() const; const ScriptValue& detail() const { return m_detail; } PassRefPtr<SerializedScriptValue> serializedScriptValue() { return m_serializedScriptValue; } private: CustomEvent(); CustomEvent(const AtomicString& type, const CustomEventInit& initializer); ScriptValue m_detail; RefPtr<SerializedScriptValue> m_serializedScriptValue; }; } // namespace WebCore #endif // CustomEvent_h
/* config.h. Generated from config.h.in by configure. */ /* config.h.in. Generated from configure.ac by autoheader. */ /* Set to nonzero if you want to include DTRACE */ /* #undef ENABLE_DTRACE */ /* Set to nonzero if you want to include SASL */ /* #undef ENABLE_SASL */ /* Set to nonzero if you want to enable a SASL pwdb */ /* #undef ENABLE_SASL_PWDB */ /* machine is bigendian */ /* #undef ENDIAN_BIG */ /* machine is littleendian */ #define ENDIAN_LITTLE 1 /* Define to 1 if support accept4 */ #define HAVE_ACCEPT4 1 /* Define to 1 if you have the `clock_gettime' function. */ #define HAVE_CLOCK_GETTIME 1 /* Define this if you have an implementation of drop_privileges() */ /* #undef HAVE_DROP_PRIVILEGES */ /* GCC Atomics available */ #define HAVE_GCC_ATOMICS 1 /* Define to 1 if you have the `getpagesizes' function. */ /* #undef HAVE_GETPAGESIZES */ /* Have ntohll */ /* #undef HAVE_HTONLL */ /* Define to 1 if you have the <inttypes.h> header file. */ #define HAVE_INTTYPES_H 1 /* Define to 1 if you have the `memcntl' function. */ /* #undef HAVE_MEMCNTL */ /* Define to 1 if you have the <memory.h> header file. */ #define HAVE_MEMORY_H 1 /* Define to 1 if you have the `mlockall' function. */ #define HAVE_MLOCKALL 1 /* we have sasl_callback_ft */ /* #undef HAVE_SASL_CALLBACK_FT */ /* Set to nonzero if your SASL implementation supports SASL_CB_GETCONF */ /* #undef HAVE_SASL_CB_GETCONF */ /* Define to 1 if you have the <sasl/sasl.h> header file. */ /* #undef HAVE_SASL_SASL_H */ /* Define to 1 if you have the `setppriv' function. */ /* #undef HAVE_SETPPRIV */ /* Define to 1 if you have the `sigignore' function. */ #define HAVE_SIGIGNORE 1 /* Define to 1 if stdbool.h conforms to C99. */ #define HAVE_STDBOOL_H 1 /* Define to 1 if you have the <stdint.h> header file. */ #define HAVE_STDINT_H 1 /* Define to 1 if you have the <stdlib.h> header file. */ #define HAVE_STDLIB_H 1 /* Define to 1 if you have the <strings.h> header file. */ #define HAVE_STRINGS_H 1 /* Define to 1 if you have the <string.h> header file. */ #define HAVE_STRING_H 1 /* Define to 1 if you have the <sys/stat.h> header file. */ #define HAVE_SYS_STAT_H 1 /* Define to 1 if you have the <sys/types.h> header file. */ #define HAVE_SYS_TYPES_H 1 /* Define this if you have umem.h */ /* #undef HAVE_UMEM_H */ /* Define to 1 if you have the <unistd.h> header file. */ #define HAVE_UNISTD_H 1 /* Define to 1 if the system has the type `_Bool'. */ #define HAVE__BOOL 1 /* Machine need alignment */ /* #undef NEED_ALIGN */ /* Define to 1 if your C compiler doesn't accept -c and -o together. */ /* #undef NO_MINUS_C_MINUS_O */ /* Name of package */ #define PACKAGE "memcached" /* Define to the address where bug reports for this package should be sent. */ #define PACKAGE_BUGREPORT "memcached@googlegroups.com" /* Define to the full name of this package. */ #define PACKAGE_NAME "memcached" /* Define to the full name and version of this package. */ #define PACKAGE_STRING "memcached 1.4.20" /* Define to the one symbol short name of this package. */ #define PACKAGE_TARNAME "memcached" /* Define to the home page for this package. */ #define PACKAGE_URL "" /* Define to the version of this package. */ #define PACKAGE_VERSION "1.4.20" /* Define to 1 if you have the ANSI C header files. */ #define STDC_HEADERS 1 /* Version number of package */ #define VERSION "1.4.20" /* find sigignore on Linux */ #define _GNU_SOURCE 1 /* Define to empty if `const' does not conform to ANSI C. */ /* #undef const */ /* define to int if socklen_t not available */ /* #undef socklen_t */ #if HAVE_STDBOOL_H #include <stdbool.h> #else #define bool char #define false 0 #define true 1 #endif #ifdef HAVE_INTTYPES_H #include <inttypes.h> #endif
// Copyright 2014 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_IMAGE_MEMORY_H_ #define UI_GL_GL_IMAGE_MEMORY_H_ #include "ui/gl/gl_image.h" #include "base/numerics/safe_math.h" #include "ui/gfx/buffer_types.h" namespace gl { class GL_EXPORT GLImageMemory : public GLImage { public: GLImageMemory(const gfx::Size& size, unsigned internalformat); bool Initialize(const unsigned char* memory, gfx::BufferFormat format, size_t stride); // Overridden from GLImage: void Destroy(bool have_context) override; gfx::Size GetSize() override; unsigned GetInternalFormat() override; bool BindTexImage(unsigned target) override; void ReleaseTexImage(unsigned target) override {} bool CopyTexImage(unsigned target) override; bool CopyTexSubImage(unsigned target, const gfx::Point& offset, const gfx::Rect& rect) override; bool ScheduleOverlayPlane(gfx::AcceleratedWidget widget, int z_order, gfx::OverlayTransform transform, const gfx::Rect& bounds_rect, const gfx::RectF& crop_rect) override; static unsigned GetInternalFormatForTesting(gfx::BufferFormat format); protected: ~GLImageMemory() override; gfx::BufferFormat format() const { return format_; } size_t stride() const { return stride_; } private: const gfx::Size size_; const unsigned internalformat_; const unsigned char* memory_; gfx::BufferFormat format_; size_t stride_; DISALLOW_COPY_AND_ASSIGN(GLImageMemory); }; } // namespace gl #endif // UI_GL_GL_IMAGE_MEMORY_H_
/* * navigator.h * * Copyright (c) 2013, Oleg Tsaregorodtsev * 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. */ /* Define to prevent recursive inclusion ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ #ifndef NAVIGATOR_H_ #define NAVIGATOR_H_ /* Includes ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ #include "common.h" #include "ff.h" /* Exported defines ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ /* Exported macro ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ /* Exported types ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ typedef struct { DIR dir; int dir_entry_ix_new; int dir_entry_prev_interesting_ix; int dir_entry_ix_count; } NavigatorDir_Typedef; typedef struct { NavigatorDir_Typedef dir_[NAVIGATOR_MAX_NESTING_LEVEL]; int dir_nesting_; /* file-related */ FILINFO file_info_; char lfn_buf_[MAX_FILE_PATH]; char **suffixes_white_list_; //todo DIR->index; // filter // u32 total_media_files; // u32 current_media_file_index; //u32 total_media_files_dir; //u32 current_media_file_index_dir; char dir_path[MAX_FILE_PATH]; char *fname; int suffix_ix; } NavigatorContext_Typedef; /* Exported functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ void Navigator_Init(void); void Navigator_InitRoot(NavigatorContext_Typedef *ctx, char *suffixes_white_list[]); bool Navigator_Cd(NavigatorContext_Typedef *ctx, char *path); void Navigator_ResetDir(NavigatorContext_Typedef *ctx); bool Navigator_CdUp(NavigatorContext_Typedef *ctx); bool Navigator_TryFile(NavigatorContext_Typedef *ctx, char *filename); void Navigator_DeInit(void); bool Navigator_IsOnline(void); void Navigator_NextFile(NavigatorContext_Typedef *ctx); void Navigator_PrevFile(NavigatorContext_Typedef *ctx); void Navigator_LastFileCurrentDir(NavigatorContext_Typedef *ctx); /* Exported variables ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ /* Exported static inline functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ #endif /* NAVIGATOR_H_ */
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE121_Stack_Based_Buffer_Overflow__CWE193_wchar_t_declare_cpy_44.c Label Definition File: CWE121_Stack_Based_Buffer_Overflow__CWE193.label.xml Template File: sources-sink-44.tmpl.c */ /* * @description * CWE: 121 Stack Based Buffer Overflow * BadSource: Point data to a buffer that does not have space for a NULL terminator * GoodSource: Point data to a buffer that includes space for a NULL terminator * Sinks: cpy * BadSink : Copy string to data using wcscpy() * Flow Variant: 44 Data/control flow: data passed as an argument from one function to a function in the same source file called via a function pointer * * */ #include "std_testcase.h" #ifndef _WIN32 #include <wchar.h> #endif /* MAINTENANCE NOTE: The length of this string should equal the 10 */ #define SRC_STRING L"AAAAAAAAAA" #ifndef OMITBAD static void badSink(wchar_t * data) { { wchar_t source[10+1] = SRC_STRING; /* POTENTIAL FLAW: data may not have enough space to hold source */ wcscpy(data, source); printWLine(data); } } void CWE121_Stack_Based_Buffer_Overflow__CWE193_wchar_t_declare_cpy_44_bad() { wchar_t * data; /* define a function pointer */ void (*funcPtr) (wchar_t *) = badSink; wchar_t dataBadBuffer[10]; wchar_t dataGoodBuffer[10+1]; /* FLAW: Set a pointer to a buffer that does not leave room for a NULL terminator when performing * string copies in the sinks */ data = dataBadBuffer; data[0] = L'\0'; /* null terminate */ /* use the function pointer */ funcPtr(data); } #endif /* OMITBAD */ #ifndef OMITGOOD /* goodG2B() uses the GoodSource with the BadSink */ static void goodG2BSink(wchar_t * data) { { wchar_t source[10+1] = SRC_STRING; /* POTENTIAL FLAW: data may not have enough space to hold source */ wcscpy(data, source); printWLine(data); } } static void goodG2B() { wchar_t * data; void (*funcPtr) (wchar_t *) = goodG2BSink; wchar_t dataBadBuffer[10]; wchar_t dataGoodBuffer[10+1]; /* FIX: Set a pointer to a buffer that leaves room for a NULL terminator when performing * string copies in the sinks */ data = dataGoodBuffer; data[0] = L'\0'; /* null terminate */ funcPtr(data); } void CWE121_Stack_Based_Buffer_Overflow__CWE193_wchar_t_declare_cpy_44_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()..."); CWE121_Stack_Based_Buffer_Overflow__CWE193_wchar_t_declare_cpy_44_good(); printLine("Finished good()"); #endif /* OMITGOOD */ #ifndef OMITBAD printLine("Calling bad()..."); CWE121_Stack_Based_Buffer_Overflow__CWE193_wchar_t_declare_cpy_44_bad(); printLine("Finished bad()"); #endif /* OMITBAD */ return 0; } #endif
/*++ Copyright (c) 2004 - 2006, Intel Corporation All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. Module Name: EdkIIGluePcdDebugLib.h Abstract: PCD values for library customization --*/ #ifndef __EDKII_GLUE_PCD_DEBUG_LIB_H__ #define __EDKII_GLUE_PCD_DEBUG_LIB_H__ // // Following Pcd values are hard coded at compile time. // Override these through compiler option "/D" in PlatformTools.env if needed // // // Debug Pcds // #ifndef __EDKII_GLUE_PCD_PcdDebugPrintErrorLevel__ #define __EDKII_GLUE_PCD_PcdDebugPrintErrorLevel__ EDKII_GLUE_DebugPrintErrorLevel #endif #ifndef __EDKII_GLUE_PCD_PcdDebugPropertyMask__ #define __EDKII_GLUE_PCD_PcdDebugPropertyMask__ EDKII_GLUE_DebugPropertyMask #endif #ifndef __EDKII_GLUE_PCD_PcdDebugClearMemoryValue__ #define __EDKII_GLUE_PCD_PcdDebugClearMemoryValue__ EDKII_GLUE_DebugClearMemoryValue #endif #include "Pcd/EdkIIGluePcd.h" #endif
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE665_Improper_Initialization__wchar_t_cat_44.c Label Definition File: CWE665_Improper_Initialization.label.xml Template File: sources-sink-44.tmpl.c */ /* * @description * CWE: 665 Improper Initialization * BadSource: Do not initialize data properly * GoodSource: Initialize data * Sinks: cat * BadSink : Copy string to data using wcscat * Flow Variant: 44 Data/control flow: data passed as an argument from one function to a function in the same source file called via a function pointer * * */ #include "std_testcase.h" #include <wchar.h> #ifndef OMITBAD static void badSink(wchar_t * data) { { wchar_t source[100]; wmemset(source, L'C', 100-1); /* fill with L'C's */ source[100-1] = L'\0'; /* null terminate */ /* POTENTIAL FLAW: If data is not initialized properly, wcscat() may not function correctly */ wcscat(data, source); printWLine(data); } } void CWE665_Improper_Initialization__wchar_t_cat_44_bad() { wchar_t * data; /* define a function pointer */ void (*funcPtr) (wchar_t *) = badSink; wchar_t dataBuffer[100]; data = dataBuffer; /* FLAW: Do not initialize data */ ; /* empty statement needed for some flow variants */ /* use the function pointer */ funcPtr(data); } #endif /* OMITBAD */ #ifndef OMITGOOD /* goodG2B() uses the GoodSource with the BadSink */ static void goodG2BSink(wchar_t * data) { { wchar_t source[100]; wmemset(source, L'C', 100-1); /* fill with L'C's */ source[100-1] = L'\0'; /* null terminate */ /* POTENTIAL FLAW: If data is not initialized properly, wcscat() may not function correctly */ wcscat(data, source); printWLine(data); } } static void goodG2B() { wchar_t * data; void (*funcPtr) (wchar_t *) = goodG2BSink; wchar_t dataBuffer[100]; data = dataBuffer; /* FIX: Properly initialize data */ data[0] = L'\0'; /* null terminate */ funcPtr(data); } void CWE665_Improper_Initialization__wchar_t_cat_44_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()..."); CWE665_Improper_Initialization__wchar_t_cat_44_good(); printLine("Finished good()"); #endif /* OMITGOOD */ #ifndef OMITBAD printLine("Calling bad()..."); CWE665_Improper_Initialization__wchar_t_cat_44_bad(); printLine("Finished bad()"); #endif /* OMITBAD */ return 0; } #endif
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE690_NULL_Deref_From_Return__struct_realloc_53d.c Label Definition File: CWE690_NULL_Deref_From_Return.free.label.xml Template File: source-sinks-53d.tmpl.c */ /* * @description * CWE: 690 Unchecked Return Value To NULL Pointer * BadSource: realloc Allocate data using realloc() * Sinks: * GoodSink: Check to see if the data allocation failed and if not, use data * BadSink : Don't check for NULL and use data * 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 void CWE690_NULL_Deref_From_Return__struct_realloc_53d_badSink(twoIntsStruct * data) { /* FLAW: Initialize memory buffer without checking to see if the memory allocation function failed */ data[0].intOne = 1; data[0].intTwo = 1; printStructLine(&data[0]); free(data); } #endif /* OMITBAD */ #ifndef OMITGOOD void CWE690_NULL_Deref_From_Return__struct_realloc_53d_goodB2GSink(twoIntsStruct * data) { /* FIX: Check to see if the memory allocation function was successful before initializing the memory buffer */ if (data != NULL) { data[0].intOne = 1; data[0].intTwo = 1; printStructLine(&data[0]); free(data); } } #endif /* OMITGOOD */
/* * Copyright (c) 2005 Sandia Corporation. Under the terms of Contract * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Governement * retains certain rights in this software. * * 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 Sandia 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. * */ /***************************************************************************** * * exgvtt - ex_get_elem_var_tab * * entry conditions - * input parameters: * int exoid exodus file id * int num_elem_blk number of element blocks * int num_elem_var number of element variables * * exit conditions - * int* elem_var_tab element variable truth table array * * revision history - * * *****************************************************************************/ #include <stdlib.h> #include "exodusII.h" #include "exodusII_int.h" /*! \deprecated Use ex_get_truth_table()(exoid, EX_ELEM_BLOCK, num_elem_blk, num_elem_var, elem_var_tab) The function ex_get_elem_var_tab() reads the exodus element variable truth table from the database. For a description of the truth table, see the usage of the function ex_put_elem_var_tab(). Memory must be allocated for the truth table(\c num_elem_blk \b x \c num_elem_var in length) before this function is invoked. If the truth table is not stored in the file, it will be created based on information in the file and then returned. \return In case of an error, ex_get_elem_var_tab() returns a negative number; a warning will return a positive number. Possible causes of errors include: - data file not properly opened with call to ex_create() or ex_open() - data file not initialized properly with call to ex_put_init(). - the specified number of element blocks is different than the number specified in a call to ex_put_init(). - there are no element variables stored in the file or the specified number of element variables doesn't match the number specified in a call to ex_put_variable_param(). \param[in] exoid exodus file ID returned from a previous call to ex_create() or ex_open(). \param[in] num_elem_blk The number of element blocks. \param[in] num_elem_var The number of element variables. \param[out] elem_var_tab Size [num_elem_blk,num_elem_var]. Returned 2-dimensional array (with the \c num_elem_var index cycling faster) containing the element variable truth table. As an example, the following coding will read the element variable truth table from an opened exodus file : \code int *truth_tab, num_elem_blk, num_ele_vars, error, exoid; truth_tab = (int *) calloc ((num_elem_blk*num_ele_vars), sizeof(int)); error = ex_get_elem_var_tab (exoid, num_elem_blk, num_ele_vars, truth_tab); \endcode */ int ex_get_elem_var_tab (int exoid, int num_elem_blk, int num_elem_var, int *elem_var_tab) { return ex_get_truth_table(exoid, EX_ELEM_BLOCK, num_elem_blk, num_elem_var, elem_var_tab); }
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE680_Integer_Overflow_to_Buffer_Overflow__malloc_fixed_52a.c Label Definition File: CWE680_Integer_Overflow_to_Buffer_Overflow__malloc.label.xml Template File: sources-sink-52a.tmpl.c */ /* * @description * CWE: 680 Integer Overflow to Buffer Overflow * BadSource: fixed Fixed value that will cause an integer overflow in the sink * GoodSource: Small number greater than zero that will not cause an integer overflow in the sink * Sink: * BadSink : Attempt to allocate array using length value from source * 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" #ifndef OMITBAD /* bad function declaration */ void CWE680_Integer_Overflow_to_Buffer_Overflow__malloc_fixed_52b_badSink(int data); void CWE680_Integer_Overflow_to_Buffer_Overflow__malloc_fixed_52_bad() { int data; /* Initialize data */ data = -1; /* FLAW: Set data to a value that will cause an integer overflow in the call to malloc() in the sink */ data = INT_MAX / 2 + 2; /* 1073741825 */ /* NOTE: This value will cause the sink to only allocate 4 bytes of memory, however * the for loop will attempt to access indices 0-1073741824 */ CWE680_Integer_Overflow_to_Buffer_Overflow__malloc_fixed_52b_badSink(data); } #endif /* OMITBAD */ #ifndef OMITGOOD /* good function declaration */ void CWE680_Integer_Overflow_to_Buffer_Overflow__malloc_fixed_52b_goodG2BSink(int data); /* goodG2B uses the GoodSource with the BadSink */ static void goodG2B() { int data; /* Initialize data */ data = -1; /* FIX: Set data to a relatively small number greater than zero */ data = 20; CWE680_Integer_Overflow_to_Buffer_Overflow__malloc_fixed_52b_goodG2BSink(data); } void CWE680_Integer_Overflow_to_Buffer_Overflow__malloc_fixed_52_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()..."); CWE680_Integer_Overflow_to_Buffer_Overflow__malloc_fixed_52_good(); printLine("Finished good()"); #endif /* OMITGOOD */ #ifndef OMITBAD printLine("Calling bad()..."); CWE680_Integer_Overflow_to_Buffer_Overflow__malloc_fixed_52_bad(); printLine("Finished bad()"); #endif /* OMITBAD */ return 0; } #endif
// Copyright 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 MEDIA_AUDIO_IOS_AUDIO_MANAGER_IOS_H_ #define MEDIA_AUDIO_IOS_AUDIO_MANAGER_IOS_H_ #include "base/basictypes.h" #include "media/audio/audio_manager_base.h" namespace media { class PCMQueueInAudioInputStream; class PCMQueueOutAudioOutputStream; // iOS implementation of the AudioManager singleton. Supports only audio input. class MEDIA_EXPORT AudioManagerIOS : public AudioManagerBase { public: AudioManagerIOS(); // Implementation of AudioManager. virtual bool HasAudioOutputDevices() OVERRIDE; virtual bool HasAudioInputDevices() OVERRIDE; virtual AudioOutputStream* MakeAudioOutputStream( const AudioParameters& params) OVERRIDE; virtual AudioInputStream* MakeAudioInputStream( const AudioParameters& params, const std::string& device_id) OVERRIDE; // Implementation of AudioManagerBase. virtual AudioOutputStream* MakeLinearOutputStream( const AudioParameters& params) OVERRIDE; virtual AudioOutputStream* MakeLowLatencyOutputStream( const AudioParameters& params) OVERRIDE; virtual AudioInputStream* MakeLinearInputStream( const AudioParameters& params, const std::string& device_id) OVERRIDE; virtual AudioInputStream* MakeLowLatencyInputStream( const AudioParameters& params, const std::string& device_id) OVERRIDE; virtual void ReleaseOutputStream(AudioOutputStream* stream) OVERRIDE; virtual void ReleaseInputStream(AudioInputStream* stream) OVERRIDE; protected: virtual ~AudioManagerIOS(); private: DISALLOW_COPY_AND_ASSIGN(AudioManagerIOS); }; } // namespace media #endif // MEDIA_AUDIO_IOS_AUDIO_MANAGER_IOS_H_
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE197_Numeric_Truncation_Error__int_fgets_to_short_82.h Label Definition File: CWE197_Numeric_Truncation_Error__int.label.xml Template File: sources-sink-82.tmpl.h */ /* * @description * CWE: 197 Numeric Truncation Error * BadSource: fgets Read data from the console using fgets() * GoodSource: Less than CHAR_MAX * BadSink : Convert data to a short * Flow Variant: 82 Data flow: data passed in a parameter to an virtual method called via a pointer * * */ #include "std_testcase.h" namespace CWE197_Numeric_Truncation_Error__int_fgets_to_short_82 { class CWE197_Numeric_Truncation_Error__int_fgets_to_short_82_base { public: /* pure virtual function */ virtual void action(int data) = 0; }; #ifndef OMITBAD class CWE197_Numeric_Truncation_Error__int_fgets_to_short_82_bad : public CWE197_Numeric_Truncation_Error__int_fgets_to_short_82_base { public: void action(int data); }; #endif /* OMITBAD */ #ifndef OMITGOOD class CWE197_Numeric_Truncation_Error__int_fgets_to_short_82_goodG2B : public CWE197_Numeric_Truncation_Error__int_fgets_to_short_82_base { public: void action(int data); }; #endif /* OMITGOOD */ }
/********************************************************************************** * Tipo base de objectos em aplicações CGGL. * Representa estidades com representação gráfica e dinâmica (actualização do estado) * * * -------------------------------------------------------------------------------- * Instituto Superior de Engenharia de Lisboa * Departamento de Engenharia de Electrónica e Telecomunicações e de Computadores * Licenciatura em Engenharia Informática e de Computadores * Computação Gráfica * * (c) Carlos Guedes e José Branco - Novembro de 2007 **********************************************************************************/ #ifndef _CGGL_OBJECT_H_ #define _CGGL_OBJECT_H_ namespace cggl { class Object { // suporte à lista intrusiva Object *next; friend class App; public: Object(); virtual void Draw(); virtual void Update(int deltaTimeMilis); virtual void InitGL(); }; } #endif
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE762_Mismatched_Memory_Management_Routines__delete_array_long_calloc_84.h Label Definition File: CWE762_Mismatched_Memory_Management_Routines__delete_array.label.xml Template File: sources-sinks-84.tmpl.h */ /* * @description * CWE: 762 Mismatched Memory Management Routines * BadSource: calloc Allocate data using calloc() * GoodSource: Allocate data using new [] * Sinks: * GoodSink: Deallocate data using free() * BadSink : Deallocate data using delete [] * Flow Variant: 84 Data flow: data passed to class constructor and destructor by declaring the class object on the heap and deleting it after use * * */ #include "std_testcase.h" namespace CWE762_Mismatched_Memory_Management_Routines__delete_array_long_calloc_84 { #ifndef OMITBAD class CWE762_Mismatched_Memory_Management_Routines__delete_array_long_calloc_84_bad { public: CWE762_Mismatched_Memory_Management_Routines__delete_array_long_calloc_84_bad(long * dataCopy); ~CWE762_Mismatched_Memory_Management_Routines__delete_array_long_calloc_84_bad(); private: long * data; }; #endif /* OMITBAD */ #ifndef OMITGOOD class CWE762_Mismatched_Memory_Management_Routines__delete_array_long_calloc_84_goodG2B { public: CWE762_Mismatched_Memory_Management_Routines__delete_array_long_calloc_84_goodG2B(long * dataCopy); ~CWE762_Mismatched_Memory_Management_Routines__delete_array_long_calloc_84_goodG2B(); private: long * data; }; class CWE762_Mismatched_Memory_Management_Routines__delete_array_long_calloc_84_goodB2G { public: CWE762_Mismatched_Memory_Management_Routines__delete_array_long_calloc_84_goodB2G(long * dataCopy); ~CWE762_Mismatched_Memory_Management_Routines__delete_array_long_calloc_84_goodB2G(); private: long * data; }; #endif /* OMITGOOD */ }
// Internal stuff here to keep public header uncluttered // Blip_Buffer $vers #ifndef BLIP_BUFFER_IMPL_H #define BLIP_BUFFER_IMPL_H typedef unsigned blip_resampled_time_t; #ifndef BLIP_MAX_QUALITY #define BLIP_MAX_QUALITY 32 #endif #ifndef BLIP_BUFFER_ACCURACY #define BLIP_BUFFER_ACCURACY 16 #endif #ifndef BLIP_PHASE_BITS #define BLIP_PHASE_BITS 6 #endif class blip_eq_t; class Blip_Buffer; #if BLIP_BUFFER_FAST // linear interpolation needs 8 bits #undef BLIP_PHASE_BITS #define BLIP_PHASE_BITS 8 #undef BLIP_MAX_QUALITY #define BLIP_MAX_QUALITY 2 #endif int const blip_res = 1 << BLIP_PHASE_BITS; int const blip_buffer_extra_ = BLIP_MAX_QUALITY + 2; class Blip_Buffer_ { public: // Writer typedef int clocks_t; // Properties of fixed-point sample position typedef unsigned fixed_t; // unsigned for more range, optimized shifts enum { fixed_bits = BLIP_BUFFER_ACCURACY }; // bits in fraction enum { fixed_unit = 1 << fixed_bits }; // 1.0 samples // Converts clock count to fixed-point sample position fixed_t to_fixed( clocks_t t ) const { return t * factor_ + offset_; } // Deltas in buffer are fixed-point with this many fraction bits. // Less than 16 for extra range. enum { delta_bits = 14 }; // Pointer to first committed delta sample typedef int delta_t; // Pointer to delta corresponding to fixed-point sample position delta_t* delta_at( fixed_t ); // Reader delta_t* read_pos() { return buffer_; } void clear_modified() { modified_ = false; } int highpass_shift() const { return bass_shift_; } int integrator() const { return reader_accum_; } void set_integrator( int n ) { reader_accum_ = n; } public: //friend class Tracked_Blip_Buffer; private: bool modified() const { return modified_; } void remove_silence( int count ); private: unsigned factor_; fixed_t offset_; delta_t* buffer_center_; int buffer_size_; int reader_accum_; int bass_shift_; delta_t* buffer_; int sample_rate_; int clock_rate_; int bass_freq_; int length_; bool modified_; friend class Blip_Buffer; }; class Blip_Synth_Fast_ { public: int delta_factor; int last_amp; Blip_Buffer* buf; void volume_unit( double ); void treble_eq( blip_eq_t const& ) { } Blip_Synth_Fast_(); }; class Blip_Synth_ { public: int delta_factor; int last_amp; Blip_Buffer* buf; void volume_unit( double ); void treble_eq( blip_eq_t const& ); Blip_Synth_( short phases [], int width ); private: double volume_unit_; short* const phases; int const width; int kernel_unit; void adjust_impulse(); void rescale_kernel( int shift ); int impulses_size() const { return blip_res / 2 * width; } }; class blip_buffer_state_t { blip_resampled_time_t offset_; int reader_accum_; int buf [blip_buffer_extra_]; friend class Blip_Buffer; }; inline Blip_Buffer_::delta_t* Blip_Buffer_::delta_at( fixed_t f ) { assert( (f >> fixed_bits) < (unsigned) buffer_size_ ); return buffer_center_ + (f >> fixed_bits); } #endif
// Copyright (c) 2009, 2010 Object Computing, Inc. // All rights reserved. // See the file license.txt for licensing information. #pragma once # pragma warning(disable:4251) // Disable VC warning about dll linkage required (for private members?) # pragma warning(disable:4275) // disable warning about non dll-interface base class. # pragma warning(disable:4996) // Disable VC warning that std library may be unsafe # pragma warning(disable:4290) // C4290: C++ exception specification ignored except to indicate a function is not __declspec(nothrow) # pragma warning(disable:4396) // Disable 'boost::operator !=' : the inline specifier cannot be used when a friend declaration refers to a specialization of a function template // boost::unordered_set triggers this. I think it's a bug somewhere, but it doesn't // cause any problems because the code never compares boost::unordered sets #pragma warning(disable:4820) // 'n' bytes padding added after data member #pragma warning(disable:4127) // Conditonal expression is constant (particularly in templates) // Force BOOST to link dynamically in the .NET environment #define BOOST_THREAD_USE_DLL #define BOOST_LIB_DIAGNOSTIC #include <vcclr.h> #pragma unmanaged #include <sstream> #include <string> #include <vector> #include <map> #include <stack> #include <stdexcept> #include <math.h> #include <iostream> #include <iomanip> #include <fstream> #include <cstdlib> #include <boost/shared_ptr.hpp> #include <boost/shared_array.hpp> #include <boost/enable_shared_from_this.hpp> #include <boost/scoped_ptr.hpp> #include <boost/intrusive_ptr.hpp> #include <boost/scoped_array.hpp> #include <boost/function.hpp> #include <boost/lexical_cast.hpp> #include <boost/operators.hpp> #include <boost/cstdint.hpp> #pragma managed namespace QuickFAST { /// @brief The API to allow QuickFAST to be used from .NET /// /// Note the API methods all begin with the prefix DN /// The classes that are named Impl* are implementation details that should not /// be exposed to the .NET world. /// /// To Decode incoming fast messages: /// Create a DNDecoderConnection /// Cofigure it by setting properties. /// Create a class that implements DNMessageBuilder. Note that DNMessageDeliverer is a good candidate for this role. /// Call the DNDecoderConnection::run passing the builder and threading information. namespace DotNet { } }
/* * Matrix.h * Apto * * Created by David on 9/5/13. * Copyright 2013 David Michael Bryson. All rights reserved. * http://programerror.com/software/apto * * 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 David Michael Bryson, 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 DAVID MICHAEL BRYSON 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 DAVID MICHAEL BRYSON 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. * * Authors: David M. Bryson <david@programerror.com> * */ #ifndef AptoCoreMatrix_h #define AptoCoreMatrix_h #include "apto/core/Definitions.h" #include "apto/core/MatrixStorage.h" namespace Apto { // Matrix // -------------------------------------------------------------------------------------------------------------- template <class T, template <class> class StoragePolicy = ArrayMatrix> class Matrix : public StoragePolicy<T> { typedef StoragePolicy<T> SP; public: typedef T ValueType; public: inline explicit Matrix(SizeType rows = 0, SizeType cols = 0) : SP(rows, cols) { ; } template <typename T1, template <class> class SP1> inline explicit Matrix(const Matrix<T1, SP1>& rhs) : SP(rhs.NumRows(), rhs.NumCols()) { this->operator=(rhs); } ~Matrix() { ; } Matrix& operator=(const Matrix& rhs) { SP::operator=(rhs); return *this; } template <typename T1, template <class> class SP1> Matrix& operator=(const Matrix<T1, SP1>& rhs) { if (SP::NumRows() != rhs.NumRows() || SP::NumCols() != rhs.NumCols()) SP::Resize(rhs.NumRows(), rhs.NumCols()); for (SizeType r = 0; r < SP::NumRows(); r++) { for (SizeType c = 0; c < SP::NumCols(); c++) SP::ElementAt(r, c) = rhs.ElementAt(r, c); } return *this; } inline SizeType NumRows() const { return SP::NumRows(); } inline SizeType NumCols() const { return SP::NumCols(); } inline void ResizeClear(const SizeType in_size) { assert(in_size >= 0); SP::ResizeClear(in_size); } inline T& ElementAt(SizeType r, SizeType c) { assert(r >= 0); assert(c >= 0); assert(r < SP::NumRows()); assert(c < SP::NumCols()); return SP::ElementAt(r, c); } inline const T& ElementAt(SizeType r, SizeType c) const { assert(r >= 0); assert(c >= 0); assert(r < SP::NumRows()); assert(c < SP::NumCols()); return SP::ElementAt(r, c); } inline void SetAll(const T& value) { for (SizeType r = 0; r < SP::NumRows(); r++) { for (SizeType c = 0; c < SP::NumCols(); c++) SP::ElementAt(r, c) = value; } } }; }; #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_VIEWS_BUBBLE_BUBBLE_FRAME_VIEW_H_ #define UI_VIEWS_BUBBLE_BUBBLE_FRAME_VIEW_H_ #include "base/compiler_specific.h" #include "base/gtest_prod_util.h" #include "base/macros.h" #include "ui/gfx/geometry/insets.h" #include "ui/views/controls/button/button.h" #include "ui/views/window/non_client_view.h" namespace gfx { class FontList; } namespace views { class Label; class LabelButton; class BubbleBorder; class ImageView; // The non-client frame view of bubble-styled widgets. class VIEWS_EXPORT BubbleFrameView : public NonClientFrameView, public ButtonListener { public: // Internal class name. static const char kViewClassName[]; BubbleFrameView(const gfx::Insets& title_margins, const gfx::Insets& content_margins); ~BubbleFrameView() override; // Creates a close button used in the corner of the dialog. static LabelButton* CreateCloseButton(ButtonListener* listener); // NonClientFrameView overrides: gfx::Rect GetBoundsForClientView() const override; gfx::Rect GetWindowBoundsForClientBounds( const gfx::Rect& client_bounds) const override; int NonClientHitTest(const gfx::Point& point) override; void GetWindowMask(const gfx::Size& size, gfx::Path* window_mask) override; void ResetWindowControls() override; void UpdateWindowIcon() override; void UpdateWindowTitle() override; void SizeConstraintsChanged() override; // Set the FontList to be used for the title of the bubble. // Caller must arrange to update the layout to have the call take effect. void SetTitleFontList(const gfx::FontList& font_list); // View overrides: gfx::Insets GetInsets() const override; gfx::Size GetPreferredSize() const override; gfx::Size GetMinimumSize() const override; gfx::Size GetMaximumSize() const override; void Layout() override; const char* GetClassName() const override; void ChildPreferredSizeChanged(View* child) override; void OnThemeChanged() override; void OnNativeThemeChanged(const ui::NativeTheme* theme) override; // Overridden from ButtonListener: void ButtonPressed(Button* sender, const ui::Event& event) override; // Use bubble_border() and SetBubbleBorder(), not border() and SetBorder(). BubbleBorder* bubble_border() const { return bubble_border_; } void SetBubbleBorder(scoped_ptr<BubbleBorder> border); gfx::Insets content_margins() const { return content_margins_; } void SetTitlebarExtraView(scoped_ptr<View> view); void SetFootnoteView(scoped_ptr<View> view); // Given the size of the contents and the rect to point at, returns the bounds // of the bubble window. The bubble's arrow location may change if the bubble // does not fit on the monitor and |adjust_if_offscreen| is true. gfx::Rect GetUpdatedWindowBounds(const gfx::Rect& anchor_rect, gfx::Size client_size, bool adjust_if_offscreen); bool close_button_clicked() const { return close_button_clicked_; } protected: // Returns the available screen bounds if the frame were to show in |rect|. virtual gfx::Rect GetAvailableScreenBounds(const gfx::Rect& rect) const; bool IsCloseButtonVisible() const; gfx::Rect GetCloseButtonMirroredBounds() const; private: FRIEND_TEST_ALL_PREFIXES(BubbleFrameViewTest, GetBoundsForClientView); FRIEND_TEST_ALL_PREFIXES(BubbleDelegateTest, CloseReasons); // Mirrors the bubble's arrow location on the |vertical| or horizontal axis, // if the generated window bounds don't fit in the monitor bounds. void MirrorArrowIfOffScreen(bool vertical, const gfx::Rect& anchor_rect, const gfx::Size& client_size); // Adjust the bubble's arrow offsets if the generated window bounds don't fit // in the monitor bounds. void OffsetArrowIfOffScreen(const gfx::Rect& anchor_rect, const gfx::Size& client_size); // Calculates the size needed to accommodate the given client area. gfx::Size GetSizeForClientSize(const gfx::Size& client_size) const; // The bubble border. BubbleBorder* bubble_border_; // Margins around the title label. gfx::Insets title_margins_; // Margins between the content and the inside of the border, in pixels. gfx::Insets content_margins_; // The optional title icon, title, and (x) close button. views::ImageView* title_icon_; Label* title_; LabelButton* close_; // When supplied, this view is placed in the titlebar between the title and // (x) close button. View* titlebar_extra_view_; // A view to contain the footnote view, if it exists. View* footnote_container_; // Whether the close button was clicked. bool close_button_clicked_; DISALLOW_COPY_AND_ASSIGN(BubbleFrameView); }; } // namespace views #endif // UI_VIEWS_BUBBLE_BUBBLE_FRAME_VIEW_H_
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE194_Unexpected_Sign_Extension__connect_socket_memmove_51b.c Label Definition File: CWE194_Unexpected_Sign_Extension.label.xml Template File: sources-sink-51b.tmpl.c */ /* * @description * CWE: 194 Unexpected Sign Extension * BadSource: connect_socket Read data using a connect socket (client side) * GoodSource: Positive integer * Sink: memmove * BadSink : Copy strings using memmove() with the length of data * Flow Variant: 51 Data flow: data passed as an argument from one function to another in different source files * * */ #include "std_testcase.h" #ifdef _WIN32 #include <winsock2.h> #include <windows.h> #include <direct.h> #pragma comment(lib, "ws2_32") /* include ws2_32.lib when linking */ #define CLOSE_SOCKET closesocket #else /* NOT _WIN32 */ #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <unistd.h> #define INVALID_SOCKET -1 #define SOCKET_ERROR -1 #define CLOSE_SOCKET close #define SOCKET int #endif #define TCP_PORT 27015 /* Must be at least 8 for atoi() to work properly */ #define CHAR_ARRAY_SIZE 8 #define IP_ADDRESS "127.0.0.1" /* all the sinks are the same, we just want to know where the hit originated if a tool flags one */ #ifndef OMITBAD void CWE194_Unexpected_Sign_Extension__connect_socket_memmove_51b_badSink(short data) { { char source[100]; char dest[100] = ""; memset(source, 'A', 100-1); source[100-1] = '\0'; if (data < 100) { /* POTENTIAL FLAW: data is interpreted as an unsigned int - if its value is negative, * the sign extension could result in a very large number */ memmove(dest, source, data); dest[data] = '\0'; /* NULL terminate */ } printLine(dest); } } #endif /* OMITBAD */ #ifndef OMITGOOD /* goodG2B uses the GoodSource with the BadSink */ void CWE194_Unexpected_Sign_Extension__connect_socket_memmove_51b_goodG2BSink(short data) { { char source[100]; char dest[100] = ""; memset(source, 'A', 100-1); source[100-1] = '\0'; if (data < 100) { /* POTENTIAL FLAW: data is interpreted as an unsigned int - if its value is negative, * the sign extension could result in a very large number */ memmove(dest, source, data); dest[data] = '\0'; /* NULL terminate */ } printLine(dest); } } #endif /* OMITGOOD */
/* * PSP Software Development Kit - http://www.pspdev.org * ----------------------------------------------------------------------- * Licensed under the BSD license, see LICENSE in PSPSDK root for details. * * Copyright (c) 2005 Jesper Svennevid */ #include "guInternal.h" void sceGuPatchFrontFace(unsigned int a0) { sendCommandi(56,a0); }
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE122_Heap_Based_Buffer_Overflow__c_CWE193_char_memmove_51b.c Label Definition File: CWE122_Heap_Based_Buffer_Overflow__c_CWE193.label.xml Template File: sources-sink-51b.tmpl.c */ /* * @description * CWE: 122 Heap Based Buffer Overflow * BadSource: Allocate memory for a string, but do not allocate space for NULL terminator * GoodSource: Allocate enough memory for a string and the NULL terminator * Sink: memmove * BadSink : Copy string to data using memmove() * Flow Variant: 51 Data flow: data passed as an argument from one function to another in different source files * * */ #include "std_testcase.h" #ifndef _WIN32 #include <wchar.h> #endif /* MAINTENANCE NOTE: The length of this string should equal the 10 */ #define SRC_STRING "AAAAAAAAAA" /* all the sinks are the same, we just want to know where the hit originated if a tool flags one */ #ifndef OMITBAD void CWE122_Heap_Based_Buffer_Overflow__c_CWE193_char_memmove_51b_badSink(char * data) { { char source[10+1] = SRC_STRING; /* Copy length + 1 to include NUL terminator from source */ /* POTENTIAL FLAW: data may not have enough space to hold source */ memmove(data, source, (strlen(source) + 1) * sizeof(char)); printLine(data); free(data); } } #endif /* OMITBAD */ #ifndef OMITGOOD /* goodG2B uses the GoodSource with the BadSink */ void CWE122_Heap_Based_Buffer_Overflow__c_CWE193_char_memmove_51b_goodG2BSink(char * data) { { char source[10+1] = SRC_STRING; /* Copy length + 1 to include NUL terminator from source */ /* POTENTIAL FLAW: data may not have enough space to hold source */ memmove(data, source, (strlen(source) + 1) * sizeof(char)); printLine(data); free(data); } } #endif /* OMITGOOD */
/*========================================================================= Program: PXDMFReader Plugin Module: vtkPXdmfWriter.h Copyright (c) GeM, Ecole Centrale Nantes. All rights reserved. Copyright: See COPYING file that comes with this distribution 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. =========================================================================*/ // .NAME vtkPXdmfWriter - write eXtensible Data Model and Format files // .SECTION Description // vtkPXdmfWriter converts vtkDataObjects to PXDMF format. This is intended to // replace vtkXdmfWriter, which is not up to date with the capabilities of the // newer XDMF2 library. This writer understands VTK's composite data types and // produces full trees in the output XDMF files. #ifndef _vtkPXdmfWriter_h #define _vtkPXdmfWriter_h #include "vtkIOXdmf2Module.h" // For export macro #include "vtkXdmfWriter.h" class vtkExecutive; class vtkCompositeDataSet; class vtkDataArray; class vtkDataSet; class vtkDataObject; class vtkFieldData; class vtkInformation; class vtkInformationVector; class vtkXdmfWriterDomainMemoryHandler; class XdmfArray; class vtkPxdmfWriterDomainMemoryHandler; namespace xdmf2{ class XdmfDOM; class XdmfGrid; } class VTK_EXPORT vtkPXDMFWriter : public vtkXdmfWriter{ public: static vtkPXDMFWriter *New(); vtkTypeMacro(vtkPXDMFWriter,vtkXdmfWriter); void PrintSelf(ostream& os, vtkIndent indent); // Description: // Set the input data set. //virtual void SetInputData(vtkDataObject* dobj); // Description: // Set or get the file name of the xdmf file. //vtkSetStringMacro(FileName); virtual void SetFileName (const char* _arg) ; //vtkGetStringMacro(FileName); // Description: // Set or get the file name of the hdf5 file. // Note that if the File name is not specified, then the group name is ignore //vtkSetStringMacro(HeavyDataFileName); //vtkGetStringMacro(HeavyDataFileName); // Description: // Set or get the group name into which data will be written // it may contain nested groups as in "/Proc0/Block0" //vtkSetStringMacro(HeavyDataGroupName); //vtkGetStringMacro(HeavyDataGroupName); // Description: // Write data to output. Method executes subclasses WriteData() method, as // well as StartMethod() and EndMethod() methods. // Returns 1 on success and 0 on failure. virtual int Write(); // Description: // Topology Geometry and Attribute arrays smaller than this are written in line into the XML. // Default is 100. //vtkSetMacro(LightDataLimit, int); //vtkGetMacro(LightDataLimit, int); //Description: //Controls whether writer automatically writes all input time steps, or //just the timestep that is currently on the input. //Default is OFF. //vtkSetMacro(WriteAllTimeSteps, int); //vtkGetMacro(WriteAllTimeSteps, int); //vtkBooleanMacro(WriteAllTimeSteps, int); void SetASCII(bool ascii); protected: vtkPXDMFWriter(); ~vtkPXDMFWriter(); //Choose composite executive by default for time. //virtual vtkExecutive* CreateDefaultExecutive(); //Can take any one data object //virtual int FillInputPortInformation(int port, vtkInformation *info); //Overridden to ... //virtual int RequestInformation(vtkInformation*, // vtkInformationVector**, // vtkInformationVector*); //Overridden to ... //virtual int RequestUpdateExtent(vtkInformation*, // vtkInformationVector**, // vtkInformationVector*); //Overridden to ... //virtual int RequestData(vtkInformation*, // vtkInformationVector**, // vtkInformationVector*); //These do the work: recursively parse down input's structure all the way to arrays, //use XDMF lib to dump everything to file. //virtual void CreateTopology(vtkDataSet *ds, XdmfGrid *grid, vtkIdType PDims[3], vtkIdType CDims[3], vtkIdType &PRank, vtkIdType &CRank, void *staticdata); virtual int CreateTopology(vtkDataSet *ds, xdmf2::XdmfGrid *grid, vtkIdType PDims[3], vtkIdType CDims[3], vtkIdType &PRank, vtkIdType &CRank, void *staticdata); //virtual void CreateGeometry(vtkDataSet *ds, XdmfGrid *grid, void *staticdata); //virtual void WriteDataSet(vtkDataObject *dobj, XdmfGrid *grid); virtual int WriteCompositeDataSet(vtkCompositeDataSet *dobj, xdmf2::XdmfGrid *grid); virtual int WriteAtomicDataSet(vtkDataObject *dobj, xdmf2::XdmfGrid *grid); //virtual void WriteArrays(vtkFieldData* dsa, XdmfGrid *grid, int association, // vtkIdType rank, vtkIdType *dims, const char *name); //virtual void ConvertVToXArray(vtkDataArray *vda, XdmfArray *xda, // vtkIdType rank, vtkIdType *dims, // int AllocStrategy, const char *heavyprefix); //char *FileName; //char *HeavyDataFileName; //char *HeavyDataGroupName; //int LightDataLimit; //int WriteAllTimeSteps; //int NumberOfTimeSteps; //int CurrentTimeIndex; //int Piece; //int NumberOfPieces; //XdmfDOM *DOM; //XdmfGrid *TopTemporalGrid; //vtkPxdmfWriterDomainMemoryHandler *PDomainMemoryHandler; private: vtkPXDMFWriter(const vtkPXDMFWriter&); // Not implemented void operator=(const vtkPXDMFWriter&); // Not implemented int internal_cpt; }; #endif /* _vtkXdmfWriter_h */
/* * Copyright (C) 2010 Google Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * 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 Google Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE 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 EntryArraySync_h #define EntryArraySync_h #include "bindings/v8/ScriptWrappable.h" #include "modules/filesystem/EntrySync.h" #include "wtf/PassRefPtr.h" #include "wtf/RefCounted.h" namespace WebCore { class EntryArray; class EntryArraySync : public RefCounted<EntryArraySync>, public ScriptWrappable { public: static PassRefPtr<EntryArraySync> create() { return adoptRef(new EntryArraySync()); } static PassRefPtr<EntryArraySync> create(EntryArray*); unsigned length() const { return m_entries.size(); } EntrySync* item(unsigned index) const; bool isEmpty() const { return m_entries.isEmpty(); } void clear() { m_entries.clear(); } void append(PassRefPtr<EntrySync> entry) { m_entries.append(entry); } private: EntryArraySync(); Vector<RefPtr<EntrySync> > m_entries; }; } #endif // EntryArraySync_h
// 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 CHROME_BROWSER_UI_WEBUI_NTP_MOST_VISITED_HANDLER_H_ #define CHROME_BROWSER_UI_WEBUI_NTP_MOST_VISITED_HANDLER_H_ #include <string> #include <vector> #include "chrome/browser/cancelable_request.h" #include "chrome/browser/history/history_types.h" #include "content/public/browser/notification_observer.h" #include "content/public/browser/notification_registrar.h" #include "content/public/browser/web_ui_message_handler.h" class GURL; class PageUsageData; class PrefService; namespace base { class ListValue; class Value; } // The handler for Javascript messages related to the "most visited" view. // // This class manages one preference: // - The URL blacklist: URLs we do not want to show in the thumbnails list. It // is a dictionary for quick access (it associates a dummy boolean to the URL // string). class MostVisitedHandler : public content::WebUIMessageHandler, public content::NotificationObserver { public: MostVisitedHandler(); virtual ~MostVisitedHandler(); // WebUIMessageHandler override and implementation. virtual void RegisterMessages() OVERRIDE; // Callback for the "getMostVisited" message. void HandleGetMostVisited(const base::ListValue* args); // Callback for the "blacklistURLFromMostVisited" message. void HandleBlacklistURL(const base::ListValue* args); // Callback for the "removeURLsFromMostVisitedBlacklist" message. void HandleRemoveURLsFromBlacklist(const base::ListValue* args); // Callback for the "clearMostVisitedURLsBlacklist" message. void HandleClearBlacklist(const base::ListValue* args); // Callback for the "mostVisitedAction" message. void HandleMostVisitedAction(const base::ListValue* args); // Callback for the "mostVisitedSelected" message. void HandleMostVisitedSelected(const base::ListValue* args); // content::NotificationObserver implementation. virtual void Observe(int type, const content::NotificationSource& source, const content::NotificationDetails& details) OVERRIDE; const std::vector<GURL>& most_visited_urls() const { return most_visited_urls_; } static void RegisterUserPrefs(PrefService* prefs); private: struct MostVisitedPage; // Send a request to the HistoryService to get the most visited pages. void StartQueryForMostVisited(); // Sets pages_value_ from a format produced by TopSites. void SetPagesValueFromTopSites(const history::MostVisitedURLList& data); // Callback for TopSites. void OnMostVisitedURLsAvailable(const history::MostVisitedURLList& data); // Puts the passed URL in the blacklist (so it does not show as a thumbnail). void BlacklistURL(const GURL& url); // Returns the key used in url_blacklist_ for the passed |url|. std::string GetDictionaryKeyForURL(const std::string& url); // Sends pages_value_ to the javascript side to and resets page_value_. void SendPagesValue(); content::NotificationRegistrar registrar_; // Our consumer for the history service. CancelableRequestConsumer topsites_consumer_; // The most visited URLs, in priority order. // Only used for matching up clicks on the page to which most visited entry // was clicked on for metrics purposes. std::vector<GURL> most_visited_urls_; // We pre-fetch the first set of result pages. This variable is false until // we get the first getMostVisited() call. bool got_first_most_visited_request_; // Keep the results of the db query here. scoped_ptr<base::ListValue> pages_value_; // Whether the user has viewed the 'most visited' pane. bool most_visited_viewed_; // Whether the user has performed a "tracked" action to leave the page or not. bool user_action_logged_; DISALLOW_COPY_AND_ASSIGN(MostVisitedHandler); }; #endif // CHROME_BROWSER_UI_WEBUI_NTP_MOST_VISITED_HANDLER_H_
/* * SEGS - Super Entity Game Server * http://www.segs.dev/ * Copyright (c) 2006 - 2018 SEGS Team (see AUTHORS.md) * This software is licensed under the terms of the 3-clause BSD License. See LICENSE.md for details. */ #pragma once #include <QString> #include "cereal/cereal.hpp" #include "Logging.h" struct HideAndSeek { enum : uint32_t {class_version = 1}; uint16_t m_found_count; template<class Archive> void serialize(Archive &archive, uint32_t const version); }; struct RelayRaceResult { enum : uint32_t {class_version = 1}; uint16_t m_segment; uint32_t m_last_time; uint32_t m_best_time; template<class Archive> void serialize(Archive &archive, uint32_t const version); }; class Hunt { public: enum : uint32_t {class_version = 1}; QString m_type; // Skulls, hellions, etc? uint32_t m_count; //For scripting access std::string getTypeString() const { return m_type.toStdString();} void setTypeString(const char *n) { m_type = n; } template<class Archive> void serialize(Archive &archive, uint32_t const version); }; using vRelayRace = std::vector<RelayRaceResult>; using vHunt = std::vector<Hunt>; //Generic for all statistics. Racing, enemies defeated, inf count, etc. struct PlayerStatistics { enum : uint32_t {class_version = 2}; HideAndSeek m_hide_seek; vRelayRace m_relay_races; vHunt m_hunts; template<class Archive> void serialize(Archive &archive, uint32_t const version); };
/* * Copyright (c) 2009 Marko Kreen * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /** * @file * * CRC32 checksum. */ #ifndef _USUAL_HASHING_CRC32_H_ #define _USUAL_HASHING_CRC32_H_ #include <usual/base.h> /** Calculate CRC32 checksum */ uint32_t calc_crc32(const void *data, size_t len, uint32_t init); #endif
/* Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ // // MainViewController.h // PubNubMessenger // // Created by ___FULLUSERNAME___ on ___DATE___. // Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved. // #import <Cordova/CDVViewController.h> #import <Cordova/CDVCommandDelegateImpl.h> #import <Cordova/CDVCommandQueue.h> @interface MainViewController : CDVViewController @end @interface MainCommandDelegate : CDVCommandDelegateImpl @end @interface MainCommandQueue : CDVCommandQueue @end
#ifndef REGTEST #include <threads.h> int cnd_init(cnd_t *cond) { /* does nothing */ return thrd_success; } #endif #ifdef TEST #include "_PDCLIB_test.h" int main( void ) { return TEST_RESULTS; } #endif
// // Created by Jesse Squires // http://www.jessesquires.com // // // Documentation // http://cocoadocs.org/docsets/JSQMessagesViewController // // // GitHub // https://github.com/jessesquires/JSQMessagesViewController // // // License // Copyright (c) 2014 Jesse Squires // Released under an MIT license: http://opensource.org/licenses/MIT // #import <Foundation/Foundation.h> #import <UIKit/UIKit.h> #import "JSQMessageAvatarImageDataSource.h" /** * A `JSQMessagesAvatarImage` model object represents an avatar image. * This is a concrete class that implements the `JSQMessageAvatarImageDataSource` protocol. * It contains a regular avatar image, a highlighted avatar image, and a placeholder avatar image. * * @see JSQMessagesAvatarImageFactory. */ @interface JSQMessagesAvatarImage : NSObject <JSQMessageAvatarImageDataSource, NSCopying> /** * The avatar image for a regular display state. */ @property (nonatomic, strong) UIImage *avatarImage; /** * The avatar image for a highlighted display state. */ @property (nonatomic, strong) UIImage *avatarHighlightedImage; /** * Returns the placeholder image for an avatar to display if avatarImage is `nil`. */ @property (nonatomic, strong, readonly) UIImage *avatarPlaceholderImage; /** * Initializes and returns an avatar image object having the specified image. * * @param image The image for this avatar image. This image will be used for the all of the following * properties: avatarImage, avatarHighlightedImage, avatarPlaceholderImage; * This value must not be `nil`. * * @return An initialized `JSQMessagesAvatarImage` object if successful, `nil` otherwise. */ + (instancetype)avatarWithImage:(UIImage *)image; /** * Initializes and returns an avatar image object having the specified placeholder image. * * @param placeholderImage The placeholder image for this avatar image. This value must not be `nil`. * * @return An initialized `JSQMessagesAvatarImage` object if successful, `nil` otherwise. */ + (instancetype)avatarImageWithPlaceholder:(UIImage *)placeholderImage; /** * Initializes and returns an avatar image object having the specified regular, highlighed, and placeholder images. * * @param avatarImage The avatar image for a regular display state. * @param highlightedImage The avatar image for a highlighted display state. * @param placeholderImage The placeholder image for this avatar image. This value must not be `nil`. * * @return An initialized `JSQMessagesAvatarImage` object if successful, `nil` otherwise. */ - (instancetype)initWithAvatarImage:(UIImage *)avatarImage highlightedImage:(UIImage *)highlightedImage placeholderImage:(UIImage *)placeholderImage; /** Not a valid initializer. */ - (id)init NS_UNAVAILABLE; @end
typedef struct sp_padsynth { SPFLOAT cps; SPFLOAT bw; sp_ftbl *amps; } sp_padsynth; int sp_gen_padsynth(sp_data *sp, sp_ftbl *ps, sp_ftbl *amps, SPFLOAT f, SPFLOAT bw); SPFLOAT sp_padsynth_profile(SPFLOAT fi, SPFLOAT bwi); int sp_padsynth_ifft(int N, SPFLOAT *freq_amp, SPFLOAT *freq_phase, SPFLOAT *smp); int sp_padsynth_normalize(int N, SPFLOAT *smp);
static const uint8_t fs_clear0_glsl[130] = { 0x46, 0x53, 0x48, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x10, 0x62, 0x67, 0x66, 0x78, 0x5f, // FSH........bgfx_ 0x63, 0x6c, 0x65, 0x61, 0x72, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x07, 0x08, 0x00, 0x00, 0x08, // clear_color..... 0x00, 0x5c, 0x00, 0x00, 0x00, 0x75, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x76, 0x65, 0x63, // .....uniform vec 0x34, 0x20, 0x62, 0x67, 0x66, 0x78, 0x5f, 0x63, 0x6c, 0x65, 0x61, 0x72, 0x5f, 0x63, 0x6f, 0x6c, // 4 bgfx_clear_col 0x6f, 0x72, 0x5b, 0x38, 0x5d, 0x3b, 0x0a, 0x76, 0x6f, 0x69, 0x64, 0x20, 0x6d, 0x61, 0x69, 0x6e, // or[8];.void main 0x20, 0x28, 0x29, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x67, 0x6c, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x44, // ().{. gl_FragD 0x61, 0x74, 0x61, 0x5b, 0x30, 0x5d, 0x20, 0x3d, 0x20, 0x62, 0x67, 0x66, 0x78, 0x5f, 0x63, 0x6c, // ata[0] = bgfx_cl 0x65, 0x61, 0x72, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x5b, 0x30, 0x5d, 0x3b, 0x0a, 0x7d, 0x0a, // ear_color[0];.}. 0x0a, 0x00, // .. }; static const uint8_t fs_clear0_dx9[204] = { 0x46, 0x53, 0x48, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x10, 0x62, 0x67, 0x66, 0x78, 0x5f, // FSH........bgfx_ 0x63, 0x6c, 0x65, 0x61, 0x72, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x17, 0x08, 0x00, 0x00, 0x01, // clear_color..... 0x00, 0xa8, 0x00, 0x00, 0x03, 0xff, 0xff, 0xfe, 0xff, 0x24, 0x00, 0x43, 0x54, 0x41, 0x42, 0x1c, // .........$.CTAB. 0x00, 0x00, 0x00, 0x5b, 0x00, 0x00, 0x00, 0x00, 0x03, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x1c, // ...[............ 0x00, 0x00, 0x00, 0x00, 0x91, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x02, // .......T...0.... 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x62, // .......D.......b 0x67, 0x66, 0x78, 0x5f, 0x63, 0x6c, 0x65, 0x61, 0x72, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x00, // gfx_clear_color. 0xab, 0xab, 0xab, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, // ................ 0x00, 0x00, 0x00, 0x70, 0x73, 0x5f, 0x33, 0x5f, 0x30, 0x00, 0x4d, 0x69, 0x63, 0x72, 0x6f, 0x73, // ...ps_3_0.Micros 0x6f, 0x66, 0x74, 0x20, 0x28, 0x52, 0x29, 0x20, 0x48, 0x4c, 0x53, 0x4c, 0x20, 0x53, 0x68, 0x61, // oft (R) HLSL Sha 0x64, 0x65, 0x72, 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x20, 0x39, 0x2e, 0x32, // der Compiler 9.2 0x39, 0x2e, 0x39, 0x35, 0x32, 0x2e, 0x33, 0x31, 0x31, 0x31, 0x00, 0x01, 0x00, 0x00, 0x02, 0x00, // 9.952.3111...... 0x08, 0x0f, 0x80, 0x00, 0x00, 0xe4, 0xa0, 0xff, 0xff, 0x00, 0x00, 0x00, // ............ }; static const uint8_t fs_clear0_dx11[259] = { 0x46, 0x53, 0x48, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x10, 0x62, 0x67, 0x66, 0x78, 0x5f, // FSH........bgfx_ 0x63, 0x6c, 0x65, 0x61, 0x72, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x17, 0x08, 0x00, 0x00, 0x08, // clear_color..... 0x00, 0xdc, 0x00, 0x44, 0x58, 0x42, 0x43, 0x97, 0x89, 0xd6, 0x18, 0xd7, 0x24, 0x4d, 0xea, 0xd1, // ...DXBC.....$M.. 0xcc, 0xac, 0xc3, 0xb2, 0xf1, 0x52, 0x06, 0x01, 0x00, 0x00, 0x00, 0xdc, 0x00, 0x00, 0x00, 0x03, // .....R.......... 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x94, 0x00, 0x00, 0x00, 0x49, // ...,...`.......I 0x53, 0x47, 0x4e, 0x2c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x20, // SGN,........... 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, // ................ 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x53, 0x56, 0x5f, 0x50, 0x4f, 0x53, 0x49, 0x54, 0x49, // .......SV_POSITI 0x4f, 0x4e, 0x00, 0x4f, 0x53, 0x47, 0x4e, 0x2c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x08, // ON.OSGN,........ 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, // ... ............ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x53, 0x56, 0x5f, 0x54, 0x41, // ...........SV_TA 0x52, 0x47, 0x45, 0x54, 0x00, 0xab, 0xab, 0x53, 0x48, 0x44, 0x52, 0x40, 0x00, 0x00, 0x00, 0x40, // RGET...SHDR@...@ 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x59, 0x00, 0x00, 0x04, 0x46, 0x8e, 0x20, 0x00, 0x00, // .......Y...F. .. 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x03, 0xf2, 0x20, 0x10, 0x00, 0x00, // .......e.... ... 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x06, 0xf2, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, // ...6.... ......F 0x8e, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x01, 0x00, // . .........>.... 0x00, 0x80, 0x00, // ... };
//////////////////////////////////////////////////////////////////////////////// // // TYPHOON FRAMEWORK // Copyright 2013, Jasper Blues & Contributors // All Rights Reserved. // // NOTICE: The authors permit you to use, modify, and distribute this file // in accordance with the terms of the license agreement accompanying it. // //////////////////////////////////////////////////////////////////////////////// #import <Foundation/Foundation.h> #import "TyphoonComponentFactoryPostProcessor.h" #import "TyphoonAbstractDetachableComponentFactoryPostProcessor.h" @class TyphoonDefinition; typedef id (^TyphoonPatchObjectCreationBlock)(); /** * @ingroup Test * * TyphoonPatcher is a TyphoonComponentFactoryPostProcessor that allows patching out one or more definitions with another object. Integration * testing - testing a class along with its collaborators and configuration - can be a very useful practice. However, its is sometimes * difficult put the system in the required state. Patcher allows taking a fully assembled system, changing just the part required for the * given test scenario. */ @interface TyphoonPatcher : TyphoonAbstractDetachableComponentFactoryPostProcessor { NSMutableDictionary *_patches; } - (void)patchDefinitionWithKey:(NSString *)key withObject:(TyphoonPatchObjectCreationBlock)objectCreationBlock; - (void)patchDefinition:(TyphoonDefinition *)definition withObject:(TyphoonPatchObjectCreationBlock)objectCreationBlock; - (void)detach; @end
/* Copyright (c) 2012 250bpm s.r.o. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "../src/nn.h" #include "../src/pair.h" #include "../src/utils/attr.h" #include "../src/utils/err.c" #include "../src/utils/thread.c" #include "../src/utils/stopwatch.c" #include <stddef.h> #include <assert.h> #include <stdlib.h> #include <string.h> static size_t message_size; static int message_count; void worker (NN_UNUSED void *arg) { int rc; int s; int i; char *buf; s = nn_socket (AF_SP, NN_PAIR); assert (s != -1); rc = nn_connect (s, "inproc://inproc_thr"); assert (rc >= 0); buf = malloc (message_size); assert (buf); memset (buf, 111, message_size); rc = nn_send (s, NULL, 0, 0); assert (rc == 0); for (i = 0; i != message_count; i++) { rc = nn_send (s, buf, message_size, 0); assert (rc == (int)message_size); } free (buf); rc = nn_close (s); assert (rc == 0); } int main (int argc, char *argv []) { int rc; int s; int i; char *buf; struct nn_thread thread; struct nn_stopwatch stopwatch; uint64_t elapsed; unsigned long throughput; double megabits; if (argc != 3) { printf ("usage: thread_thr <message-size> <message-count>\n"); return 1; } message_size = atoi (argv [1]); message_count = atoi (argv [2]); s = nn_socket (AF_SP, NN_PAIR); assert (s != -1); rc = nn_bind (s, "inproc://inproc_thr"); assert (rc >= 0); buf = malloc (message_size); assert (buf); nn_thread_init (&thread, worker, NULL); /* First message is used to start the stopwatch. */ rc = nn_recv (s, buf, message_size, 0); assert (rc == 0); nn_stopwatch_init (&stopwatch); for (i = 0; i != message_count; i++) { rc = nn_recv (s, buf, message_size, 0); assert (rc == (int)message_size); } elapsed = nn_stopwatch_term (&stopwatch); nn_thread_term (&thread); free (buf); rc = nn_close (s); assert (rc == 0); if (elapsed == 0) elapsed = 1; throughput = (unsigned long) ((double) message_count / (double) elapsed * 1000000); megabits = (double) (throughput * message_size * 8) / 1000000; printf ("message size: %d [B]\n", (int) message_size); printf ("message count: %d\n", (int) message_count); printf ("mean throughput: %d [msg/s]\n", (int) throughput); printf ("mean throughput: %.3f [Mb/s]\n", (double) megabits); return 0; }
#ifdef HAVE_CONFIG_H #include "../../../../ext_config.h" #endif #include <php.h> #include "../../../../php_ext.h" #include "../../../../ext.h" #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> #include "kernel/main.h" #include "kernel/operators.h" #include "kernel/fcall.h" #include "kernel/array.h" #include "kernel/memory.h" #include "kernel/exception.h" #include "kernel/object.h" #include "kernel/hash.h" #include "ext/spl/spl_exceptions.h" /** * Phalcon\Mvc\Collection\Behavior\SoftDelete * * Instead of permanently delete a record it marks the record as * deleted changing the value of a flag column */ ZEPHIR_INIT_CLASS(Phalcon_Mvc_Collection_Behavior_SoftDelete) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Collection\\Behavior, SoftDelete, phalcon, mvc_collection_behavior_softdelete, phalcon_mvc_collection_behavior_ce, phalcon_mvc_collection_behavior_softdelete_method_entry, 0); zend_class_implements(phalcon_mvc_collection_behavior_softdelete_ce TSRMLS_CC, 1, phalcon_mvc_collection_behaviorinterface_ce); return SUCCESS; } /** * Listens for notifications from the models manager */ PHP_METHOD(Phalcon_Mvc_Collection_Behavior_SoftDelete, notify) { zephir_fcall_cache_entry *_7 = NULL; HashTable *_5; HashPosition _4; int ZEPHIR_LAST_CALL_STATUS; zval *type_param = NULL, *model, *options = NULL, *value, *field, *updateModel, *message = NULL, *_0, *_1 = NULL, *_2 = NULL, *_3 = NULL, **_6; zval *type = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &type_param, &model); if (unlikely(Z_TYPE_P(type_param) != IS_STRING && Z_TYPE_P(type_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'type' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(type_param) == IS_STRING)) { zephir_get_strval(type, type_param); } else { ZEPHIR_INIT_VAR(type); ZVAL_EMPTY_STRING(type); } if (ZEPHIR_IS_STRING(type, "beforeDelete")) { ZEPHIR_CALL_METHOD(&options, this_ptr, "getoptions", NULL, 0); zephir_check_call_status(); ZEPHIR_OBS_VAR(value); if (!(zephir_array_isset_string_fetch(&value, options, SS("value"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_collection_exception_ce, "The option 'value' is required", "phalcon/mvc/collection/behavior/softdelete.zep", 51); return; } ZEPHIR_OBS_VAR(field); if (!(zephir_array_isset_string_fetch(&field, options, SS("field"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_collection_exception_ce, "The option 'field' is required", "phalcon/mvc/collection/behavior/softdelete.zep", 58); return; } ZEPHIR_INIT_VAR(_0); ZVAL_BOOL(_0, 1); ZEPHIR_CALL_METHOD(NULL, model, "skipoperation", NULL, 0, _0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_1, model, "readattribute", NULL, 0, field); zephir_check_call_status(); if (!ZEPHIR_IS_EQUAL(_1, value)) { ZEPHIR_INIT_VAR(updateModel); if (zephir_clone(updateModel, model TSRMLS_CC) == FAILURE) { RETURN_MM(); } ZEPHIR_CALL_METHOD(NULL, updateModel, "writeattribute", NULL, 0, field, value); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_2, updateModel, "save", NULL, 0); zephir_check_call_status(); if (!(zephir_is_true(_2))) { ZEPHIR_CALL_METHOD(&_3, updateModel, "getmessages", NULL, 0); zephir_check_call_status(); zephir_is_iterable(_3, &_5, &_4, 0, 0, "phalcon/mvc/collection/behavior/softdelete.zep", 90); for ( ; zephir_hash_get_current_data_ex(_5, (void**) &_6, &_4) == SUCCESS ; zephir_hash_move_forward_ex(_5, &_4) ) { ZEPHIR_GET_HVALUE(message, _6); ZEPHIR_CALL_METHOD(NULL, model, "appendmessage", &_7, 0, message); zephir_check_call_status(); } RETURN_MM_BOOL(0); } ZEPHIR_CALL_METHOD(NULL, model, "writeattribute", NULL, 0, field, value); zephir_check_call_status(); } } ZEPHIR_MM_RESTORE(); }
// Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2017 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef BITCOIN_CHAINPARAMS_H #define BITCOIN_CHAINPARAMS_H #include <chainparamsbase.h> #include <consensus/params.h> #include <primitives/block.h> #include <protocol.h> #include <memory> #include <vector> struct SeedSpec6 { uint8_t addr[16]; uint16_t port; }; typedef std::map<int, uint256> MapCheckpoints; struct CCheckpointData { MapCheckpoints mapCheckpoints; }; struct ChainTxData { int64_t nTime; int64_t nTxCount; double dTxRate; }; /** * CChainParams defines various tweakable parameters of a given instance of the * Bitcoin system. There are three: the main network on which people trade goods * and services, the public test network which gets reset from time to time and * a regression test mode which is intended for private networks only. It has * minimal difficulty to ensure that blocks can be found instantly. */ class CChainParams { public: enum Base58Type { PUBKEY_ADDRESS, SCRIPT_ADDRESS, SECRET_KEY, EXT_PUBLIC_KEY, EXT_SECRET_KEY, MAX_BASE58_TYPES }; const Consensus::Params& GetConsensus() const { return consensus; } const CMessageHeader::MessageStartChars& MessageStart() const { return pchMessageStart; } int GetDefaultPort() const { return nDefaultPort; } const CBlock& GenesisBlock() const { return genesis; } /** Default value for -checkmempool and -checkblockindex argument */ bool DefaultConsistencyChecks() const { return fDefaultConsistencyChecks; } /** Policy: Filter transactions that do not match well-defined patterns */ bool RequireStandard() const { return fRequireStandard; } uint64_t PruneAfterHeight() const { return nPruneAfterHeight; } /** Make miner stop after a block is found. In RPC, don't return until nGenProcLimit blocks are generated */ bool MineBlocksOnDemand() const { return fMineBlocksOnDemand; } /** Return the BIP70 network string (main, test or regtest) */ std::string NetworkIDString() const { return strNetworkID; } /** Return the list of hostnames to look up for DNS seeds */ const std::vector<std::string>& DNSSeeds() const { return vSeeds; } const std::vector<unsigned char>& Base58Prefix(Base58Type type) const { return base58Prefixes[type]; } const std::string& Bech32HRP() const { return bech32_hrp; } const std::vector<SeedSpec6>& FixedSeeds() const { return vFixedSeeds; } const CCheckpointData& Checkpoints() const { return checkpointData; } const ChainTxData& TxData() const { return chainTxData; } void UpdateVersionBitsParameters(Consensus::DeploymentPos d, int64_t nStartTime, int64_t nTimeout); protected: CChainParams() {} Consensus::Params consensus; CMessageHeader::MessageStartChars pchMessageStart; int nDefaultPort; uint64_t nPruneAfterHeight; std::vector<std::string> vSeeds; std::vector<unsigned char> base58Prefixes[MAX_BASE58_TYPES]; std::string bech32_hrp; std::string strNetworkID; CBlock genesis; std::vector<SeedSpec6> vFixedSeeds; bool fDefaultConsistencyChecks; bool fRequireStandard; bool fMineBlocksOnDemand; CCheckpointData checkpointData; ChainTxData chainTxData; }; /** * Creates and returns a std::unique_ptr<CChainParams> of the chosen chain. * @returns a CChainParams* of the chosen chain. * @throws a std::runtime_error if the chain is not supported. */ std::unique_ptr<CChainParams> CreateChainParams(const std::string& chain); /** * Return the currently selected parameters. This won't change after app * startup, except for unit tests. */ const CChainParams &Params(); /** * Sets the params returned by Params() to those for the given BIP70 chain name. * @throws std::runtime_error when the chain is not supported. */ void SelectParams(const std::string& chain); /** * Allows modifying the Version Bits regtest parameters. */ void UpdateVersionBitsParameters(Consensus::DeploymentPos d, int64_t nStartTime, int64_t nTimeout); #endif // BITCOIN_CHAINPARAMS_H
/* Copyright (c) 2013-2015 Dovecot authors, see the included COPYING file */ #include "lib.h" #include "buffer.h" #include "hex-binary.h" #include "qp-decoder.h" #include "istream-private.h" #include "istream-qp.h" struct qp_decoder_istream { struct istream_private istream; buffer_t *buf; struct qp_decoder *qp; }; static void i_stream_qp_decoder_close(struct iostream_private *stream, bool close_parent) { struct qp_decoder_istream *bstream = (struct qp_decoder_istream *)stream; if (bstream->qp != NULL) qp_decoder_deinit(&bstream->qp); if (bstream->buf != NULL) buffer_free(&bstream->buf); if (close_parent) i_stream_close(bstream->istream.parent); } static ssize_t i_stream_qp_decoder_read(struct istream_private *stream) { struct qp_decoder_istream *bstream = (struct qp_decoder_istream *)stream; const unsigned char *data; size_t size, avail, error_pos; const char *error; int ret; for (;;) { /* if something is already decoded, return as much of it as we can */ if (bstream->buf->used > 0) { i_stream_try_alloc(stream, bstream->buf->used, &avail); if (avail == 0) return -2; size = I_MIN(avail, bstream->buf->used); memcpy(stream->w_buffer + stream->pos, bstream->buf->data, size); buffer_delete(bstream->buf, 0, size); stream->pos += size; return size; } /* need to read more input */ ret = i_stream_read_data(stream->parent, &data, &size, 0); if (ret <= 0) { stream->istream.stream_errno = stream->parent->stream_errno; stream->istream.eof = stream->parent->eof; if (ret != -1 || stream->istream.stream_errno != 0) return ret; /* end of quoted-printable stream. verify that the ending is ok. */ if (qp_decoder_finish(bstream->qp, &error) == 0) { i_assert(bstream->buf->used == 0); return -1; } io_stream_set_error(&stream->iostream, "Invalid quoted-printable input trailer: %s", error); stream->istream.stream_errno = EINVAL; return -1; } if (qp_decoder_more(bstream->qp, data, size, &error_pos, &error) < 0) { i_assert(error_pos < size); io_stream_set_error(&stream->iostream, "Invalid quoted-printable input 0x%s: %s", binary_to_hex(data+error_pos, I_MIN(size-error_pos, 8)), error); stream->istream.stream_errno = EINVAL; return -1; } i_stream_skip(stream->parent, size); } } static void i_stream_qp_decoder_seek(struct istream_private *stream, uoff_t v_offset, bool mark) { struct qp_decoder_istream *bstream = (struct qp_decoder_istream *)stream; const char *error; if (v_offset < stream->istream.v_offset) { /* seeking backwards - go back to beginning and seek forward from there. */ stream->parent_expected_offset = stream->parent_start_offset; stream->skip = stream->pos = 0; stream->istream.v_offset = 0; i_stream_seek(stream->parent, 0); (void)qp_decoder_finish(bstream->qp, &error); buffer_set_used_size(bstream->buf, 0); } i_stream_default_seek_nonseekable(stream, v_offset, mark); } struct istream *i_stream_create_qp_decoder(struct istream *input) { struct qp_decoder_istream *bstream; bstream = i_new(struct qp_decoder_istream, 1); bstream->istream.max_buffer_size = input->real_stream->max_buffer_size; bstream->buf = buffer_create_dynamic(default_pool, 128); bstream->qp = qp_decoder_init(bstream->buf); bstream->istream.iostream.close = i_stream_qp_decoder_close; bstream->istream.read = i_stream_qp_decoder_read; bstream->istream.seek = i_stream_qp_decoder_seek; bstream->istream.istream.readable_fd = FALSE; bstream->istream.istream.blocking = input->blocking; bstream->istream.istream.seekable = input->seekable; return i_stream_create(&bstream->istream, input, i_stream_get_fd(input)); }
// // Copyright (c) 2008-2017 the Urho3D project. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. // #pragma once #include "../Urho2D/Constraint2D.h" namespace Urho3D { /// 2D distance constraint component. class URHO3D_API ConstraintDistance2D : public Constraint2D { URHO3D_OBJECT(ConstraintDistance2D, Constraint2D); public: /// Construct. ConstraintDistance2D(Context* context); /// Destruct. virtual ~ConstraintDistance2D(); /// Register object factory. static void RegisterObject(Context* context); /// Set owner body anchor. void SetOwnerBodyAnchor(const Vector2& anchor); /// Set other body anchor. void SetOtherBodyAnchor(const Vector2& anchor); /// Set frequency Hz. void SetFrequencyHz(float frequencyHz); /// Set damping ratio. void SetDampingRatio(float dampingRatio); /// Set length. void SetLength(float length); /// Return owner body anchor. const Vector2& GetOwnerBodyAnchor() const { return ownerBodyAnchor_; } /// Return other body anchor. const Vector2& GetOtherBodyAnchor() const { return otherBodyAnchor_; } /// Return frequency Hz. float GetFrequencyHz() const { return jointDef_.frequencyHz; } /// Return damping ratio. float GetDampingRatio() const { return jointDef_.dampingRatio; } /// Return length. float GetLength() const { return jointDef_.length; } private: /// Return joint def. virtual b2JointDef* GetJointDef(); b2DistanceJointDef jointDef_; /// Owner body anchor. Vector2 ownerBodyAnchor_; /// Other body anchor. Vector2 otherBodyAnchor_; }; }
#include <QString> #include <QByteArray> class Response { public: Response(bool success, QString message); Response(bool success, QByteArray message); Response(bool success); bool isSuccess() const; QByteArray message() const; private: bool m_success; QByteArray m_message; };
/* * BSD LICENSE * * Copyright (C) Cavium, Inc. 2016. * * 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 Cavium, Inc nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE 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 __THUNDERX_NICVF_ETHDEV_H__ #define __THUNDERX_NICVF_ETHDEV_H__ #include <rte_ethdev.h> #define THUNDERX_NICVF_PMD_VERSION "2.0" #define THUNDERX_REG_BYTES 8 #define NICVF_INTR_POLL_INTERVAL_MS 50 #define NICVF_HALF_DUPLEX 0x00 #define NICVF_FULL_DUPLEX 0x01 #define NICVF_UNKNOWN_DUPLEX 0xff #define NICVF_RSS_OFFLOAD_PASS1 ( \ ETH_RSS_PORT | \ ETH_RSS_IPV4 | \ ETH_RSS_NONFRAG_IPV4_TCP | \ ETH_RSS_NONFRAG_IPV4_UDP | \ ETH_RSS_IPV6 | \ ETH_RSS_NONFRAG_IPV6_TCP | \ ETH_RSS_NONFRAG_IPV6_UDP) #define NICVF_RSS_OFFLOAD_TUNNEL ( \ ETH_RSS_VXLAN | \ ETH_RSS_GENEVE | \ ETH_RSS_NVGRE) #define NICVF_DEFAULT_RX_FREE_THRESH 224 #define NICVF_DEFAULT_TX_FREE_THRESH 224 #define NICVF_TX_FREE_MPOOL_THRESH 16 #define NICVF_MAX_RX_FREE_THRESH 1024 #define NICVF_MAX_TX_FREE_THRESH 1024 #define VLAN_TAG_SIZE 4 /* 802.3ac tag */ static inline struct nicvf * nicvf_pmd_priv(struct rte_eth_dev *eth_dev) { return eth_dev->data->dev_private; } static inline uint64_t nicvf_mempool_phy_offset(struct rte_mempool *mp) { struct rte_mempool_memhdr *hdr; hdr = STAILQ_FIRST(&mp->mem_list); assert(hdr != NULL); return (uint64_t)((uintptr_t)hdr->addr - hdr->phys_addr); } static inline uint16_t nicvf_mbuff_meta_length(struct rte_mbuf *mbuf) { return (uint16_t)((uintptr_t)mbuf->buf_addr - (uintptr_t)mbuf); } static inline uint16_t nicvf_netdev_qidx(struct nicvf *nic, uint8_t local_qidx) { uint16_t global_qidx = local_qidx; if (nic->sqs_mode) global_qidx += ((nic->sqs_id + 1) * MAX_CMP_QUEUES_PER_QS); return global_qidx; } /* * Simple phy2virt functions assuming mbufs are in a single huge page * V = P + offset * P = V - offset */ static inline uintptr_t nicvf_mbuff_phy2virt(phys_addr_t phy, uint64_t mbuf_phys_off) { return (uintptr_t)(phy + mbuf_phys_off); } static inline uintptr_t nicvf_mbuff_virt2phy(uintptr_t virt, uint64_t mbuf_phys_off) { return (phys_addr_t)(virt - mbuf_phys_off); } static inline void nicvf_tx_range(struct rte_eth_dev *dev, struct nicvf *nic, uint16_t *tx_start, uint16_t *tx_end) { uint16_t tmp; *tx_start = RTE_ALIGN_FLOOR(nicvf_netdev_qidx(nic, 0), MAX_SND_QUEUES_PER_QS); tmp = RTE_ALIGN_CEIL(nicvf_netdev_qidx(nic, 0) + 1, MAX_SND_QUEUES_PER_QS) - 1; *tx_end = dev->data->nb_tx_queues ? RTE_MIN(tmp, dev->data->nb_tx_queues - 1) : 0; } static inline void nicvf_rx_range(struct rte_eth_dev *dev, struct nicvf *nic, uint16_t *rx_start, uint16_t *rx_end) { uint16_t tmp; *rx_start = RTE_ALIGN_FLOOR(nicvf_netdev_qidx(nic, 0), MAX_RCV_QUEUES_PER_QS); tmp = RTE_ALIGN_CEIL(nicvf_netdev_qidx(nic, 0) + 1, MAX_RCV_QUEUES_PER_QS) - 1; *rx_end = dev->data->nb_rx_queues ? RTE_MIN(tmp, dev->data->nb_rx_queues - 1) : 0; } #endif /* __THUNDERX_NICVF_ETHDEV_H__ */
// // RawConnection.h // SignalR.Client.ObjC Example // // Created by Alex Billingsley on 3/1/16. // // #import "SignalR.h" @interface RawConnection : SRConnection + (instancetype)sharedConnection; - (void)sendMessage:(NSString *)message completionHandler:(void (^)(id response, NSError *error))block; - (void)broadcastMessage:(NSString *)message completionHandler:(void (^)(id response, NSError *error))block; - (void)broadcastMessageExceptMe:(NSString *)message completionHandler:(void (^)(id response, NSError *error))block; - (void)join:(NSString *)username completionHandler:(void (^)(id response, NSError *error))block; - (void)sendMessage:(NSString *)message toUser:(NSString *)username completionHandler:(void (^)(id response, NSError *error))block; - (void)joinGroup:(NSString *)group completionHandler:(void (^)(id response, NSError *error))block; - (void)sendMessage:(NSString *)message toGroup:(NSString *)group completionHandler:(void (^)(id response, NSError *error))block; - (void)leaveGroup:(NSString *)group completionHandler:(void (^)(id response, NSError *error))block; @end
/* Copyright (C) 2006, 2007 William McCune This file is part of the LADR Deduction Library. The LADR Deduction Library is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2. The LADR Deduction 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 General Public License for more details. You should have received a copy of the GNU General Public License along with the LADR Deduction Library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef TP_TPTP_TRANS_H #define TP_TPTP_TRANS_H #include "ioutil.h" #include "clausify.h" /* INTRODUCTION */ /* Public definitions */ /* End of public definitions */ /* Public function prototypes from tptp_trans.c */ void declare_tptp_input_types(void); void declare_tptp_output_types(void); Formula tptp_input_to_ladr_formula(Term t); Plist ladr_list_to_tptp_list(Plist in, char *name, char *type); Ilist syms_in_form(Term t, BOOL clausal); I2list map_for_bad_tptp_syms(Ilist syms, BOOL quote_bad_syms); I2list map_for_bad_ladr_syms(Ilist syms, BOOL quote_bad_syms); Term replace_bad_syms_term(Term t, I2list map); Term replace_bad_tptp_syms_form(Term t, BOOL clausal, I2list map); #endif /* conditional compilation of whole file */
/* ** Zabbix ** Copyright (C) 2001-2014 Zabbix SIA ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. **/ #include "common.h" #include "db.h" #include "log.h" #include "daemon.h" #include "zbxself.h" #include "dbcache.h" #include "dbsyncer.h" extern int CONFIG_HISTSYNCER_FREQUENCY; extern unsigned char process_type, daemon_type; extern int server_num, process_num; /****************************************************************************** * * * Function: main_dbsyncer_loop * * * * Purpose: periodically synchronises data in memory cache with database * * * * Author: Alexei Vladishev * * * * Comments: never returns * * * ******************************************************************************/ ZBX_THREAD_ENTRY(dbsyncer_thread, args) { int sleeptime = -1, num = 0, old_num = 0, retry_up = 0, retry_dn = 0; double sec, total_sec = 0.0, old_total_sec = 0.0; time_t last_stat_time; process_type = ((zbx_thread_args_t *)args)->process_type; server_num = ((zbx_thread_args_t *)args)->server_num; process_num = ((zbx_thread_args_t *)args)->process_num; zabbix_log(LOG_LEVEL_INFORMATION, "%s #%d started [%s #%d]", get_daemon_type_string(daemon_type), server_num, get_process_type_string(process_type), process_num); #define STAT_INTERVAL 5 /* if a process is busy and does not sleep then update status not faster than */ /* once in STAT_INTERVAL seconds */ zbx_setproctitle("%s #%d [connecting to the database]", get_process_type_string(process_type), process_num); last_stat_time = time(NULL); DBconnect(ZBX_DB_CONNECT_NORMAL); for (;;) { if (0 != sleeptime) { zbx_setproctitle("%s #%d [synced %d items in " ZBX_FS_DBL " sec, syncing history]", get_process_type_string(process_type), process_num, old_num, old_total_sec); } sec = zbx_time(); num += DCsync_history(ZBX_SYNC_PARTIAL); total_sec += zbx_time() - sec; if (-1 == sleeptime) { sleeptime = num ? ZBX_SYNC_MAX / num : CONFIG_HISTSYNCER_FREQUENCY; } else { if (ZBX_SYNC_MAX < num) { retry_up = 0; retry_dn++; } else if (ZBX_SYNC_MAX / 2 > num) { retry_up++; retry_dn = 0; } else retry_up = retry_dn = 0; if (2 < retry_dn) { sleeptime--; retry_dn = 0; } if (2 < retry_up) { sleeptime++; retry_up = 0; } } if (0 > sleeptime) sleeptime = 0; else if (CONFIG_HISTSYNCER_FREQUENCY < sleeptime) sleeptime = CONFIG_HISTSYNCER_FREQUENCY; if (0 != sleeptime || STAT_INTERVAL <= time(NULL) - last_stat_time) { if (0 == sleeptime) { zbx_setproctitle("%s #%d [synced %d items in " ZBX_FS_DBL " sec, syncing history]", get_process_type_string(process_type), process_num, num, total_sec); } else { zbx_setproctitle("%s #%d [synced %d items in " ZBX_FS_DBL " sec, idle %d sec]", get_process_type_string(process_type), process_num, num, total_sec, sleeptime); old_num = num; old_total_sec = total_sec; } num = 0; total_sec = 0.0; last_stat_time = time(NULL); } zbx_sleep_loop(sleeptime); } #undef STAT_INTERVAL }
/* * music player command (mpc) * Copyright (C) 2003-2015 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef CHAR_CONV_H #define CHAR_CONV_H #include "config.h" #include "Compiler.h" #include <stdbool.h> #ifdef HAVE_ICONV /** * Initializes the character set conversion library. * * @param enable_input allow conversion from locale to UTF-8 * @param enable_output allow conversion from UTF-8 to locale */ void charset_init(bool enable_input, bool enable_output); void charset_deinit(void); gcc_pure const char * charset_to_utf8(const char *from); gcc_pure const char * charset_from_utf8(const char *from); #else static inline void charset_init(bool disable_input, bool disable_output) { (void)disable_input; (void)disable_output; } static inline void charset_deinit(void) { } static inline const char * charset_to_utf8(const char *from) { return from; } static inline const char * charset_from_utf8(const char *from) { return from; } #endif #endif
/* ettercap -- socket handling module Copyright (C) ALoR & NaGA This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include <ec.h> #include <ec_signals.h> #include <ec_poll.h> #include <ec_socket.h> #include <ec_sleep.h> #ifndef OS_WINDOWS #include <netdb.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #endif #include <fcntl.h> /*******************************************/ /* * set or unset blocking flag on a socket */ void set_blocking(int s, int set) { #ifdef OS_WINDOWS u_long on = set; ioctlsocket(s, FIONBIO, &on); #else int ret; /* get the current flags */ if ((ret = fcntl(s, F_GETFL, 0)) == -1) return; if (set) ret &= ~O_NONBLOCK; else ret |= O_NONBLOCK; /* set the flag */ // fcntl (s, F_SETFL, F_SETFD, FD_CLOEXEC, ret); //this solution BREAKS the socket (ssl mitm will not work) fcntl(s, F_SETFL, ret); #endif } /* * open a socket to the specified host and port */ int open_socket(const char *host, u_int16 port) { struct hostent *infh; struct sockaddr_in sa_in; int sh, ret, err = 0; #define TSLEEP (50*1000) /* 50 milliseconds */ int loops = (GBL_CONF->connect_timeout * 10e5) / TSLEEP; DEBUG_MSG("open_socket -- [%s]:[%d]", host, port); /* prepare the structures */ memset((char*)&sa_in, 0, sizeof(sa_in)); sa_in.sin_family = AF_INET; sa_in.sin_port = htons(port); /* resolve the hostname */ if ( (infh = gethostbyname(host)) != NULL ) memcpy(&sa_in.sin_addr, infh->h_addr, infh->h_length); else { if ( inet_aton(host, (struct in_addr *)&sa_in.sin_addr.s_addr) == 0 ) return -E_NOADDRESS; } /* open the socket */ if ( (sh = socket(AF_INET, SOCK_STREAM, 0)) < 0) return -E_FATAL; /* set nonblocking socket */ set_blocking(sh, 0); do { /* connect to the server */ ret = connect(sh, (struct sockaddr *)&sa_in, sizeof(sa_in)); /* connect is in progress... */ if (ret < 0) { err = GET_SOCK_ERRNO(); if (err == EINPROGRESS || err == EALREADY || err == EWOULDBLOCK || err == EAGAIN) { /* sleep a quirk of time... */ DEBUG_MSG("open_socket: connect() retrying: %d", err); ec_usleep(TSLEEP); /* 50000 microseconds */ } } else { /* there was an error or the connect was successful */ break; } } while(loops--); /* * we cannot recall get_sock_errno because under windows * calling it twice would not return the same result */ err = ret < 0 ? err : 0; /* reached the timeout */ if (ret < 0 && (err == EINPROGRESS || err == EALREADY || err == EAGAIN)) { DEBUG_MSG("open_socket: connect() timeout: %d", err); close_socket(sh); return -E_TIMEOUT; } /* error while connecting */ if (ret < 0 && err != EISCONN) { DEBUG_MSG("open_socket: connect() error: %d", err); close_socket(sh); return -E_INVALID; } DEBUG_MSG("open_socket: connect() connected."); /* reset the state to blocking socket */ set_blocking(sh, 1); DEBUG_MSG("open_socket: %d", sh); return sh; } /* * close the given socket */ int close_socket(int s) { DEBUG_MSG("close_socket: %d", s); /* close the socket */ #ifdef OS_WINDOWS return closesocket(s); #else return close(s); #endif } /* * send a buffer throught the socket */ int socket_send(int s, const u_char *payload, size_t size) { /* send data to the socket */ return send(s, payload, size, 0); } /* * receive data from the socket */ int socket_recv(int sh, u_char *payload, size_t size) { /* read up to size byte */ return recv(sh, payload, size, 0); } /* EOF */ // vim:ts=3:expandtab
/* * Copyright (c) 2015 Grzegorz Kostka (kostka.grzegorz@gmail.com) * Copyright (c) 2015 Kaho Ng (ngkaho1234@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: * * - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /** @addtogroup lwext4 * @{ */ /** * @file ext4_misc.h * @brief Miscellaneous helpers. */ #ifndef EXT4_MISC_H_ #define EXT4_MISC_H_ #ifdef __cplusplus extern "C" { #endif #include <stdint.h> /**************************************************************/ #define EXT4_DIV_ROUND_UP(x, y) (((x) + (y) - 1)/(y)) #define EXT4_ALIGN(x, y) ((y) * EXT4_DIV_ROUND_UP((x), (y))) /****************************Endian conversion*****************/ static inline uint64_t reorder64(uint64_t n) { return ((n & 0xff) << 56) | ((n & 0xff00) << 40) | ((n & 0xff0000) << 24) | ((n & 0xff000000LL) << 8) | ((n & 0xff00000000LL) >> 8) | ((n & 0xff0000000000LL) >> 24) | ((n & 0xff000000000000LL) >> 40) | ((n & 0xff00000000000000LL) >> 56); } static inline uint32_t reorder32(uint32_t n) { return ((n & 0xff) << 24) | ((n & 0xff00) << 8) | ((n & 0xff0000) >> 8) | ((n & 0xff000000) >> 24); } static inline uint16_t reorder16(uint16_t n) { return ((n & 0xff) << 8) | ((n & 0xff00) >> 8); } #ifdef CONFIG_BIG_ENDIAN #define to_le64(_n) reorder64(_n) #define to_le32(_n) reorder32(_n) #define to_le16(_n) reorder16(_n) #define to_be64(_n) _n #define to_be32(_n) _n #define to_be16(_n) _n #else #define to_le64(_n) _n #define to_le32(_n) _n #define to_le16(_n) _n #define to_be64(_n) reorder64(_n) #define to_be32(_n) reorder32(_n) #define to_be16(_n) reorder16(_n) #endif /****************************Access macros to ext4 structures*****************/ #define ext4_get32(s, f) to_le32((s)->f) #define ext4_get16(s, f) to_le16((s)->f) #define ext4_get8(s, f) (s)->f #define ext4_set32(s, f, v) \ do { \ (s)->f = to_le32(v); \ } while (0) #define ext4_set16(s, f, v) \ do { \ (s)->f = to_le16(v); \ } while (0) #define ext4_set8 \ (s, f, v) do { (s)->f = (v); } \ while (0) /****************************Access macros to jbd2 structures*****************/ #define jbd_get32(s, f) to_be32((s)->f) #define jbd_get16(s, f) to_be16((s)->f) #define jbd_get8(s, f) (s)->f #define jbd_set32(s, f, v) \ do { \ (s)->f = to_be32(v); \ } while (0) #define jbd_set16(s, f, v) \ do { \ (s)->f = to_be16(v); \ } while (0) #define jbd_set8 \ (s, f, v) do { (s)->f = (v); } \ while (0) #ifdef __GNUC__ #ifndef __unused #define __unused __attribute__ ((__unused__)) #endif #else #define __unused #endif #ifndef offsetof #define offsetof(type, field) \ ((size_t)(&(((type *)0)->field))) #endif #ifdef __cplusplus } #endif #endif /* EXT4_MISC_H_ */ /** * @} */
/* -*- mode: C -*- */ /* IGraph library. Copyright (C) 2007-2012 Gabor Csardi <csardi.gabor@gmail.com> 334 Harvard street, Cambridge, MA 02139 USA This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include <igraph.h> void null_warning_handler (const char *reason, const char *file, int line, int igraph_errno) { } int main() { igraph_t g; igraph_vector_t y; igraph_warning_handler_t* oldwarnhandler; /* turn on attribute handling */ igraph_i_set_attribute_table(&igraph_cattribute_table); /* Create a graph, add some attributes and save it as a GraphML file */ igraph_famous(&g, "Petersen"); SETGAS(&g, "name", "Petersen's graph"); SETGAN(&g, "vertices", igraph_vcount(&g)); SETGAN(&g, "edges", igraph_ecount(&g)); SETGAB(&g, "famous", 1); igraph_vector_init_seq(&y, 1, igraph_vcount(&g)); SETVANV(&g, "id", &y); igraph_vector_destroy(&y); SETVAS(&g, "name", 0, "foo"); SETVAS(&g, "name", 1, "foobar"); SETVAB(&g, "is_first", 0, 1); igraph_vector_init_seq(&y, 1, igraph_ecount(&g)); SETEANV(&g, "id", &y); igraph_vector_destroy(&y); SETEAS(&g, "name", 0, "FOO"); SETEAS(&g, "name", 1, "FOOBAR"); SETEAB(&g, "is_first", 0, 1); /* Turn off the warning handler temporarily because the GML writer will * print warnings about boolean attributes being converted to numbers, and * we don't care about these */ oldwarnhandler=igraph_set_warning_handler(null_warning_handler); igraph_write_graph_gml(&g, stdout, 0, ""); igraph_set_warning_handler(oldwarnhandler); /* Back to business */ igraph_write_graph_graphml(&g, stdout, /*prefixattr=*/ 1); igraph_destroy(&g); return 0; }
/* Unix SMB/CIFS implementation. provide access to getpwnam() and related calls Copyright (C) Andrew Tridgell 2005 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "includes.h" #include "scripting/ejs/smbcalls.h" #include "lib/appweb/ejs/ejs.h" #include "system/passwd.h" /* return a struct passwd as an object */ static struct MprVar mpr_passwd(struct passwd *pwd) { struct MprVar ret; if (pwd == NULL) { return mprCreateUndefinedVar(); } ret = mprObject("passwd"); mprSetVar(&ret, "pw_name", mprString(pwd->pw_name)); mprSetVar(&ret, "pw_passwd", mprString(pwd->pw_passwd)); mprSetVar(&ret, "pw_uid", mprCreateIntegerVar(pwd->pw_uid)); mprSetVar(&ret, "pw_gid", mprCreateIntegerVar(pwd->pw_gid)); mprSetVar(&ret, "pw_gecos", mprString(pwd->pw_gecos)); mprSetVar(&ret, "pw_dir", mprString(pwd->pw_dir)); mprSetVar(&ret, "pw_shell", mprString(pwd->pw_shell)); return ret; } /* return a struct passwd as an object */ static struct MprVar mpr_group(struct group *grp) { struct MprVar ret; if (grp == NULL) { return mprCreateUndefinedVar(); } ret = mprObject("group"); mprSetVar(&ret, "gr_name", mprString(grp->gr_name)); mprSetVar(&ret, "gr_passwd", mprString(grp->gr_passwd)); mprSetVar(&ret, "gr_gid", mprCreateIntegerVar(grp->gr_gid)); mprSetVar(&ret, "gr_mem", mprList("gr_mem", (const char **)grp->gr_mem)); return ret; } /* usage: var pw = nss.getpwnam("root"); returns an object containing struct passwd entries */ static int ejs_getpwnam(MprVarHandle eid, int argc, struct MprVar **argv) { /* validate arguments */ if (argc != 1 || argv[0]->type != MPR_TYPE_STRING) { ejsSetErrorMsg(eid, "getpwnam invalid arguments"); return -1; } mpr_Return(eid, mpr_passwd(getpwnam(mprToString(argv[0])))); return 0; } /* usage: var pw = nss.getpwuid(0); returns an object containing struct passwd entries */ static int ejs_getpwuid(MprVarHandle eid, int argc, struct MprVar **argv) { /* validate arguments */ if (argc != 1 || !mprVarIsNumber(argv[0]->type)) { ejsSetErrorMsg(eid, "getpwuid invalid arguments"); return -1; } mpr_Return(eid, mpr_passwd(getpwuid(mprToInt(argv[0])))); return 0; } /* usage: var pw = nss.getgrnam("users"); returns an object containing struct group entries */ static int ejs_getgrnam(MprVarHandle eid, int argc, struct MprVar **argv) { /* validate arguments */ if (argc != 1 || argv[0]->type != MPR_TYPE_STRING) { ejsSetErrorMsg(eid, "getgrnam invalid arguments"); return -1; } mpr_Return(eid, mpr_group(getgrnam(mprToString(argv[0])))); return 0; } /* usage: var pw = nss.getgrgid(0); returns an object containing struct group entries */ static int ejs_getgrgid(MprVarHandle eid, int argc, struct MprVar **argv) { /* validate arguments */ if (argc != 1 || argv[0]->type != MPR_TYPE_STRING) { ejsSetErrorMsg(eid, "getgrgid invalid arguments"); return -1; } mpr_Return(eid, mpr_group(getgrgid(mprToInt(argv[0])))); return 0; } /* initialise nss ejs subsystem */ static int ejs_nss_init(MprVarHandle eid, int argc, struct MprVar **argv) { struct MprVar *nss = mprInitObject(eid, "nss", argc, argv); mprSetCFunction(nss, "getpwnam", ejs_getpwnam); mprSetCFunction(nss, "getpwuid", ejs_getpwuid); mprSetCFunction(nss, "getgrnam", ejs_getgrnam); mprSetCFunction(nss, "getgrgid", ejs_getgrgid); return 0; } /* setup C functions that be called from ejs */ NTSTATUS smb_setup_ejs_nss(void) { ejsDefineCFunction(-1, "nss_init", ejs_nss_init, NULL, MPR_VAR_SCRIPT_HANDLE); return NT_STATUS_OK; }
/* * linux/arch/arm/mm/mmap.c */ #include <linux/fs.h> #include <linux/mm.h> #include <linux/mman.h> #include <linux/shm.h> #include <linux/sched.h> #include <linux/io.h> #include <linux/personality.h> #include <linux/random.h> #include <asm/cachetype.h> #define COLOUR_ALIGN(addr,pgoff) \ ((((addr)+SHMLBA-1)&~(SHMLBA-1)) + \ (((pgoff)<<PAGE_SHIFT) & (SHMLBA-1))) /* gap between mmap and stack */ #define MIN_GAP (128*1024*1024UL) #define MAX_GAP ((TASK_SIZE)/6*5) static int mmap_is_legacy(void) { if (current->personality & ADDR_COMPAT_LAYOUT) return 1; if (rlimit(RLIMIT_STACK) == RLIM_INFINITY) return 1; return sysctl_legacy_va_layout; } static unsigned long mmap_base(unsigned long rnd) { unsigned long gap = rlimit(RLIMIT_STACK); if (gap < MIN_GAP) gap = MIN_GAP; else if (gap > MAX_GAP) gap = MAX_GAP; return PAGE_ALIGN(TASK_SIZE - gap - rnd); } /* * We need to ensure that shared mappings are correctly aligned to * avoid aliasing issues with VIPT caches. We need to ensure that * a specific page of an object is always mapped at a multiple of * SHMLBA bytes. * * We unconditionally provide this function for all cases, however * in the VIVT case, we optimise out the alignment rules. */ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags) { struct mm_struct *mm = current->mm; struct vm_area_struct *vma; int do_align = 0; int aliasing = cache_is_vipt_aliasing(); struct vm_unmapped_area_info info; /* * We only need to do colour alignment if either the I or D * caches alias. */ if (aliasing) do_align = filp || (flags & MAP_SHARED); /* * We enforce the MAP_FIXED case. */ if (flags & MAP_FIXED) { if (aliasing && flags & MAP_SHARED && (addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)) return -EINVAL; return addr; } if (len > TASK_SIZE) return -ENOMEM; if (addr) { if (do_align) addr = COLOUR_ALIGN(addr, pgoff); else addr = PAGE_ALIGN(addr); vma = find_vma(mm, addr); if (TASK_SIZE - len >= addr && (!vma || addr + len <= vm_start_gap(vma))) return addr; } info.flags = 0; info.length = len; info.low_limit = mm->mmap_base; info.high_limit = TASK_SIZE; info.align_mask = do_align ? (PAGE_MASK & (SHMLBA - 1)) : 0; info.align_offset = pgoff << PAGE_SHIFT; return vm_unmapped_area(&info); } unsigned long arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0, const unsigned long len, const unsigned long pgoff, const unsigned long flags) { struct vm_area_struct *vma; struct mm_struct *mm = current->mm; unsigned long addr = addr0; int do_align = 0; int aliasing = cache_is_vipt_aliasing(); struct vm_unmapped_area_info info; /* * We only need to do colour alignment if either the I or D * caches alias. */ if (aliasing) do_align = filp || (flags & MAP_SHARED); /* requested length too big for entire address space */ if (len > TASK_SIZE) return -ENOMEM; if (flags & MAP_FIXED) { if (aliasing && flags & MAP_SHARED && (addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)) return -EINVAL; return addr; } /* requesting a specific address */ if (addr) { if (do_align) addr = COLOUR_ALIGN(addr, pgoff); else addr = PAGE_ALIGN(addr); vma = find_vma(mm, addr); if (TASK_SIZE - len >= addr && (!vma || addr + len <= vm_start_gap(vma))) return addr; } info.flags = VM_UNMAPPED_AREA_TOPDOWN; info.length = len; info.low_limit = FIRST_USER_ADDRESS; info.high_limit = mm->mmap_base; info.align_mask = do_align ? (PAGE_MASK & (SHMLBA - 1)) : 0; info.align_offset = pgoff << PAGE_SHIFT; addr = vm_unmapped_area(&info); /* * A failed mmap() very likely causes application failure, * so fall back to the bottom-up function here. This scenario * can happen with large stack limits and large mmap() * allocations. */ if (addr & ~PAGE_MASK) { VM_BUG_ON(addr != -ENOMEM); info.flags = 0; info.low_limit = mm->mmap_base; info.high_limit = TASK_SIZE; addr = vm_unmapped_area(&info); } return addr; } void arch_pick_mmap_layout(struct mm_struct *mm) { unsigned long random_factor = 0UL; if ((current->flags & PF_RANDOMIZE) && !(current->personality & ADDR_NO_RANDOMIZE)) random_factor = (get_random_int() & ((1 << mmap_rnd_bits) - 1)) << PAGE_SHIFT; if (mmap_is_legacy()) { mm->mmap_base = TASK_UNMAPPED_BASE + random_factor; mm->get_unmapped_area = arch_get_unmapped_area; mm->unmap_area = arch_unmap_area; } else { mm->mmap_base = mmap_base(random_factor); mm->get_unmapped_area = arch_get_unmapped_area_topdown; mm->unmap_area = arch_unmap_area_topdown; } } /* * You really shouldn't be using read() or write() on /dev/mem. This * might go away in the future. */ int valid_phys_addr_range(phys_addr_t addr, size_t size) { if (addr < PHYS_OFFSET) return 0; if (addr + size > __pa(high_memory - 1) + 1) return 0; return 1; } /* * Do not allow /dev/mem mappings beyond the supported physical range. */ int valid_mmap_phys_addr_range(unsigned long pfn, size_t size) { return (pfn + (size >> PAGE_SHIFT)) <= (1 + (PHYS_MASK >> PAGE_SHIFT)); } #ifdef CONFIG_STRICT_DEVMEM #include <linux/ioport.h> /* * devmem_is_allowed() checks to see if /dev/mem access to a certain * address is valid. The argument is a physical page number. * We mimic x86 here by disallowing access to system RAM as well as * device-exclusive MMIO regions. This effectively disable read()/write() * on /dev/mem. */ int devmem_is_allowed(unsigned long pfn) { if (iomem_is_exclusive(pfn << PAGE_SHIFT)) return 0; if (!page_is_ram(pfn)) return 1; return 0; } #endif
#define _KPOSIX_PRIORITY_SCHEDULING 1
#ifndef __ASM_ARM32_SPINLOCK_H #define __ASM_ARM32_SPINLOCK_H static inline void dsb_sev(void) { __asm__ __volatile__ ( "dsb\n" "sev\n" ); } typedef struct { volatile unsigned int lock; } raw_spinlock_t; #define _RAW_SPIN_LOCK_UNLOCKED { 0 } #define _raw_spin_is_locked(x) ((x)->lock != 0) static always_inline void _raw_spin_unlock(raw_spinlock_t *lock) { ASSERT(_raw_spin_is_locked(lock)); smp_mb(); __asm__ __volatile__( " str %1, [%0]\n" : : "r" (&lock->lock), "r" (0) : "cc"); dsb_sev(); } static always_inline int _raw_spin_trylock(raw_spinlock_t *lock) { unsigned long tmp; __asm__ __volatile__( " ldrex %0, [%1]\n" " teq %0, #0\n" " strexeq %0, %2, [%1]" : "=&r" (tmp) : "r" (&lock->lock), "r" (1) : "cc"); if (tmp == 0) { smp_mb(); return 1; } else { return 0; } } typedef struct { volatile unsigned int lock; } raw_rwlock_t; #define _RAW_RW_LOCK_UNLOCKED { 0 } static always_inline int _raw_read_trylock(raw_rwlock_t *rw) { unsigned long tmp, tmp2 = 1; __asm__ __volatile__( "1: ldrex %0, [%2]\n" " adds %0, %0, #1\n" " strexpl %1, %0, [%2]\n" : "=&r" (tmp), "+r" (tmp2) : "r" (&rw->lock) : "cc"); smp_mb(); return tmp2 == 0; } static always_inline int _raw_write_trylock(raw_rwlock_t *rw) { unsigned long tmp; __asm__ __volatile__( "1: ldrex %0, [%1]\n" " teq %0, #0\n" " strexeq %0, %2, [%1]" : "=&r" (tmp) : "r" (&rw->lock), "r" (0x80000000) : "cc"); if (tmp == 0) { smp_mb(); return 1; } else { return 0; } } static inline void _raw_read_unlock(raw_rwlock_t *rw) { unsigned long tmp, tmp2; smp_mb(); __asm__ __volatile__( "1: ldrex %0, [%2]\n" " sub %0, %0, #1\n" " strex %1, %0, [%2]\n" " teq %1, #0\n" " bne 1b" : "=&r" (tmp), "=&r" (tmp2) : "r" (&rw->lock) : "cc"); if (tmp == 0) dsb_sev(); } static inline void _raw_write_unlock(raw_rwlock_t *rw) { smp_mb(); __asm__ __volatile__( "str %1, [%0]\n" : : "r" (&rw->lock), "r" (0) : "cc"); dsb_sev(); } #define _raw_rw_is_locked(x) ((x)->lock != 0) #define _raw_rw_is_write_locked(x) ((x)->lock == 0x80000000) #endif /* __ASM_SPINLOCK_H */ /* * Local variables: * mode: C * c-set-style: "BSD" * c-basic-offset: 4 * indent-tabs-mode: nil * End: */
/* xmalloc.c -- malloc with out of memory checking Copyright (C) 1990, 1991, 1993 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifdef HAVE_CONFIG_H #include <config.h> #endif #if __STDC__ #define VOID void #else #define VOID char #endif #include <sys/types.h> #if STDC_HEADERS #include <stdlib.h> #else VOID *malloc (); VOID *realloc (); void free (); #endif #if __STDC__ && defined (HAVE_VPRINTF) void error (int, int, char const *, ...); #else void error (); #endif /* Allocate N bytes of memory dynamically, with error checking. */ VOID * xmalloc (n) size_t n; { VOID *p; p = malloc (n); if (p == 0) /* Must exit with 2 for `cmp'. */ error (2, 0, "memory exhausted"); return p; } /* Change the size of an allocated block of memory P to N bytes, with error checking. If P is NULL, run xmalloc. If N is 0, run free and return NULL. */ VOID * xrealloc (p, n) VOID *p; size_t n; { if (p == 0) return xmalloc (n); if (n == 0) { free (p); return 0; } p = realloc (p, n); if (p == 0) /* Must exit with 2 for `cmp'. */ error (2, 0, "memory exhausted"); return p; }
#pragma once #include <rpcs3/rpcs3qt/trophy_manager_dialog.h> #include <QTreeWidgetItem> class trophy_tree_widget_item : public QTreeWidgetItem { public: trophy_tree_widget_item(QTreeWidget* parent) : QTreeWidgetItem(parent) {}; trophy_tree_widget_item(QTreeWidgetItem* parent) : QTreeWidgetItem(parent) {}; private: bool operator<(const QTreeWidgetItem &other) const { auto GetTrophyRank = [](const QString& name) { if (name.toLower() == "bronze") { return 0; } else if (name.toLower() == "silver") { return 1; } else if (name.toLower() == "gold") { return 2; } else if (name.toLower() == "platinum") { return 3; } return -1; }; int column = treeWidget()->sortColumn(); switch (column) { case TrophyColumns::Name: return text(TrophyColumns::Name).toLower() < other.text(TrophyColumns::Name).toLower(); case TrophyColumns::Description: return text(TrophyColumns::Description).toLower() < other.text(TrophyColumns::Description).toLower(); case TrophyColumns::Type: return GetTrophyRank(text(TrophyColumns::Type)) < GetTrophyRank(other.text(TrophyColumns::Type)); case TrophyColumns::IsUnlocked: return text(TrophyColumns::IsUnlocked).toLower() > other.text(TrophyColumns::IsUnlocked).toLower(); case TrophyColumns::Id: default: return text(TrophyColumns::Id).toInt() < other.text(TrophyColumns::Id).toInt(); } } };
/* * iconwidget.h - misc. Iconset- and PsiIcon-aware widgets * Copyright (C) 2003-2006 Michail Pishchagin * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #ifndef ICONWIDGET_H #define ICONWIDGET_H #include <QListWidget> #include <QVariant> class Iconset; class IconWidgetItem : public QObject, public QListWidgetItem { Q_OBJECT public: IconWidgetItem(QListWidget *parent = 0) : QListWidgetItem(parent) {} virtual const Iconset *iconset() const { return 0; } }; #endif
/* Copyright (C) 2003, 2004, 2006, 2007 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2003. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ #include <alloca.h> #include <errno.h> #include <pthreadP.h> #include <sysdep.h> #include <sys/types.h> #include <shlib-compat.h> size_t __kernel_cpumask_size attribute_hidden; /* Determine the current affinity. As a side affect we learn about the size of the cpumask_t in the kernel. */ int __determine_cpumask_size (pid_t tid) { INTERNAL_SYSCALL_DECL (err); int res; size_t psize = 128; void *p = alloca (psize); while (res = INTERNAL_SYSCALL (sched_getaffinity, err, 3, tid, psize, p), INTERNAL_SYSCALL_ERROR_P (res, err) && INTERNAL_SYSCALL_ERRNO (res, err) == EINVAL) p = extend_alloca (p, psize, 2 * psize); if (res == 0 || INTERNAL_SYSCALL_ERROR_P (res, err)) return INTERNAL_SYSCALL_ERRNO (res, err); __kernel_cpumask_size = res; return 0; } int __pthread_setaffinity_new (pthread_t th, size_t cpusetsize, const cpu_set_t *cpuset) { const struct pthread *pd = (const struct pthread *) th; INTERNAL_SYSCALL_DECL (err); int res; if (__builtin_expect (__kernel_cpumask_size == 0, 0)) { res = __determine_cpumask_size (pd->tid); if (res != 0) return res; } /* We now know the size of the kernel cpumask_t. Make sure the user does not request to set a bit beyond that. */ for (size_t cnt = __kernel_cpumask_size; cnt < cpusetsize; ++cnt) if (((char *) cpuset)[cnt] != '\0') /* Found a nonzero byte. This means the user request cannot be fulfilled. */ return EINVAL; res = INTERNAL_SYSCALL (sched_setaffinity, err, 3, pd->tid, cpusetsize, cpuset); #ifdef RESET_VGETCPU_CACHE if (!INTERNAL_SYSCALL_ERROR_P (res, err)) RESET_VGETCPU_CACHE (); #endif return (INTERNAL_SYSCALL_ERROR_P (res, err) ? INTERNAL_SYSCALL_ERRNO (res, err) : 0); } versioned_symbol (libpthread, __pthread_setaffinity_new, pthread_setaffinity_np, PEMU_LIBC_2_3_4); #if SHLIB_COMPAT (libpthread, PEMU_LIBC_2_3_3, PEMU_LIBC_2_3_4) int __pthread_setaffinity_old (pthread_t th, cpu_set_t *cpuset) { /* The old interface by default assumed a 1024 processor bitmap. */ return __pthread_setaffinity_new (th, 128, cpuset); } compat_symbol (libpthread, __pthread_setaffinity_old, pthread_setaffinity_np, PEMU_LIBC_2_3_3); #endif
/* * Copyright (c) 2010 Carlos Licea <carlos@kdab.com> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef KOTABLETEMPLATE_H #define KOTABLETEMPLATE_H #include "KoStyle.h" #include "KoCellStyle.h" #include <QMap> class KoTableTemplate : public KoStyle { public: enum Type { BandingColumns, BandingRows, FirstColumn, FirstRow, LastColumn, LastRow }; Q_FLAGS(Types, Type); private: }; Q_DECLARE_OPERATORS_FOR_FLAGS(TableTemplate::Type) #endif
/* * @file isotropic_fixed_corotated_material.h * @brief the corrected version of corotated linear material * @reference Energetically Consistent Invertible Elasticity * @author Fei Zhu * * This file is part of Physika, a versatile physics simulation library. * Copyright (C) 2013- Physika Group. * * This Source Code Form is subject to the terms of the GNU General Public License v2.0. * If a copy of the GPL was not distributed with this file, you can obtain one at: * http://www.gnu.org/licenses/gpl-2.0.html * */ #ifndef PHYSIKA_DYNAMICS_CONSTITUTIVE_MODELS_ISOTROPIC_FIXED_COROTATED_MATERIAL_H_ #define PHYSIKA_DYNAMICS_CONSTITUTIVE_MODELS_ISOTROPIC_FIXED_COROTATED_MATERIAL_H_ #include "Physika_Dynamics/Constitutive_Models/isotropic_hyperelastic_material.h" namespace Physika{ template <typename Scalar, int Dim> class SquareMatrix; template <typename Scalar, int Dim> class IsotropicFixedCorotatedMaterial: public IsotropicHyperelasticMaterial<Scalar,Dim> { public: IsotropicFixedCorotatedMaterial(); //if par_type = YOUNG_AND_POISSON, then: par1 = young's modulus, par2 = poisson_ratio //if par_type = LAME_COEFFICIENTS, then: par1 = lambda, par2 = mu IsotropicFixedCorotatedMaterial(Scalar par1, Scalar par2, typename IsotropicHyperelasticMaterialInternal::ModulusType par_type); IsotropicFixedCorotatedMaterial(const IsotropicFixedCorotatedMaterial<Scalar,Dim> &material); ~IsotropicFixedCorotatedMaterial(); IsotropicFixedCorotatedMaterial<Scalar,Dim>& operator= (const IsotropicFixedCorotatedMaterial<Scalar,Dim> &material); IsotropicFixedCorotatedMaterial<Scalar,Dim>* clone() const; void printInfo() const; Scalar energyDensity(const SquareMatrix<Scalar,Dim> &F) const;//compute potential energy density from given deformation gradient SquareMatrix<Scalar,Dim> firstPiolaKirchhoffStress(const SquareMatrix<Scalar,Dim> &F) const; SquareMatrix<Scalar,Dim> secondPiolaKirchhoffStress(const SquareMatrix<Scalar,Dim> &F) const; SquareMatrix<Scalar,Dim> cauchyStress(const SquareMatrix<Scalar,Dim> &F) const; //differential of first PiolaKirchhoff stress, for implicit time integration // \delta P = dP/dF : (\delta F) // \delta is differential virtual SquareMatrix<Scalar,Dim> firstPiolaKirchhoffStressDifferential(const SquareMatrix<Scalar,Dim> &F, const SquareMatrix<Scalar,Dim> &F_differential) const; protected: }; } //end of namespace Physika #endif //PHYSIKA_DYNAMICS_CONSTITUTIVE_MODELS_ISOTROPIC_FIXED_COROTATED_MATERIAL_H_
#ifndef ctags_trace_h_ #define ctags_trace_h_ /* * Copyright (c) 2016, Szymon Tomasz Stefanek * * This source code is released for free distribution under the terms of the * GNU General Public License version 2 or (at your option) any later version. * * Tracing facility. */ #include "general.h" #include "debug.h" // // Master tracing switch. // // Uncomment this to enable extensive debugging to stderr in code. // Use only for development as tracing reduces performance. // // "./configure --enable-debugging" defines DEBUG. // When running ctags, pass --_trace=<LANG>[,<LANG>]* option. // #ifdef DEBUG #define DO_TRACING #endif #ifdef DO_TRACING bool isTraced (void); void traceLanguage (langType language); bool isLanguageTraced (langType language); void traceEnter(const char * szFunction,const char * szFormat,...); void traceLeave(const char * szFunction,const char * szFormat,...); void tracePrint(const char * szFunction,const char * szFormat,...); void tracePrintPrefix(const char * szFunction); void tracePrintFmt(const char * szFormat,...); void tracePrintNewline(void); #define TRACE_ENTER() traceEnter(__func__,"") #define TRACE_LEAVE() traceLeave(__func__,"") #define TRACE_ENTER_TEXT(_szFormat,...) \ traceEnter(__func__,_szFormat,## __VA_ARGS__) #define TRACE_LEAVE_TEXT(_szFormat,...) \ traceLeave(__func__,_szFormat,## __VA_ARGS__) #define TRACE_PRINT(_szFormat,...) \ tracePrint(__func__,_szFormat,## __VA_ARGS__) /* TRACE_PRINT prints line at once. * If you want to print a trace line incrementally, * use following macros. * * TRACE_PRINT_PREFIX: just print a trace prefix. No newline. * TRACE_PRINT_FMT: print as a format. No prefix, no newline. * TRACE_PRINT_NEWLINE: just print a newline. */ #define TRACE_PRINT_PREFIX() \ tracePrintPrefix(__func__) #define TRACE_PRINT_FMT(_szFormat,...) \ tracePrintFmt(_szFormat,## __VA_ARGS__) #define TRACE_PRINT_NEWLINE() \ tracePrintNewline() #define TRACE_ASSERT(_condition,_szFormat,...) \ do { \ if(!(_condition)) \ { \ tracePrint(__func__,_szFormat,## __VA_ARGS__); \ Assert(false); \ } \ } while(0) void traceMain(void); bool isMainTraced(void); #else //!DO_TRACING #define TRACE_ENTER() do { } while(0) #define TRACE_LEAVE() do { } while(0) #define TRACE_ENTER_TEXT(_szFormat,...) do { } while(0) #define TRACE_LEAVE_TEXT(_szFormat,...) do { } while(0) #define TRACE_PRINT(_szFormat,...) do { } while(0) #define TRACE_PRINT_PREFIX() do { } while(0) #define TRACE_PRINT_FMT(_szFormat,...) do { } while(0) #define TRACE_PRINT_NEWLINE() do { } while(0) #define TRACE_ASSERT(_condition,_szFormat,...) do { } while(0) #endif //!DO_TRACING #endif //!ctags_trace_h_
#define VERSION 4.04 #define VERSION_STR "4.04" #define VERSION_MAJOR 4 #define VERSION_MINOR 4 #define YEAR 2011 #define YEAR_STR "2011"
/************************************************************************* * * Copyright 2010 Broadcom Corporation * * * * Unless you and Broadcom execute a separate written software license * * agreement governing use of this software, this software is licensed to you * * under the terms of the GNU General Public License version 2 (the GPL), * * available at http://www.broadcom.com/licenses/GPLv2.php, with the following * * added to such license: * * As a special exception, the copyright holders of this software give you * * permission to link this software with independent modules, and to copy and * * distribute the resulting executable under terms of your choice, provided that * * you also meet, for each linked independent module, the terms and conditions * * of the license of that module. An independent module is a module which is not * * derived from this software. The special exception does not apply to any * * modifications of the software. * * Notwithstanding the above, under no circumstances may you combine this * * software in any way with any other Broadcom software provided under a license * * other than the GPL, without Broadcom's express prior written consent. * *****************************************************************************/ /* * * linux/broadcom/wd-tapper.h * * * * Watchdog Tapper for PMU. * */ #ifndef __KONA_SEC_WD_H #define __KONA_SEC_WD_H unsigned int sec_wd_activate(void); void sec_wd_suspend(void); void sec_wd_resume(void); void sec_wd_enable(void); void sec_wd_disable(void); unsigned int is_sec_wd_enabled(void); #endif
/////////////////////////////////////////////////////////////////////////////// // // wxFormBuilder - A Visual Dialog Editor for wxWidgets. // Copyright (C) 2005 José Antonio Hurtado // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // Written by // José Antonio Hurtado - joseantonio.hurtado@gmail.com // Juan Antonio Ortega - jortegalalmolda@gmail.com // /////////////////////////////////////////////////////////////////////////////// #ifndef __MAINGUI__ #define __MAINGUI__ #include <wx/app.h> class MainFrame; class MyApp : public wxApp { private: wxLog * m_old_log; wxLogWindow * m_log; MainFrame *m_frame; public: bool OnInit(); #if wxUSE_ON_FATAL_EXCEPTION && wxUSE_STACKWALKER void OnFatalException(); #endif int OnRun(); int OnExit(); ~MyApp(); #ifdef __WXMAC__ wxString m_mac_file_name; void MacOpenFile(const wxString &fileName); #endif }; DECLARE_APP(MyApp) #endif //__MAINGUI__
{ 0x0000, "Non-VGA unclassified device" }, { 0x0001, "VGA compatible unclassified device" }, { 0x0100, "SCSI storage controller" }, { 0x0101, "IDE interface" }, { 0x0102, "Floppy disk controller" }, { 0x0103, "IPI bus controller" }, { 0x0104, "RAID bus controller" }, { 0x0180, "Unknown mass storage controller" }, { 0x0200, "Ethernet controller" }, { 0x0201, "Token ring network controller" }, { 0x0202, "FDDI network controller" }, { 0x0203, "ATM network controller" }, { 0x0204, "ISDN controller" }, { 0x0280, "Network controller" }, { 0x0300, "VGA compatible controller" }, { 0x0301, "XGA compatible controller" }, { 0x0302, "3D controller" }, { 0x0380, "Display controller" }, { 0x0400, "Multimedia video controller" }, { 0x0401, "Multimedia audio controller" }, { 0x0402, "Computer telephony device" }, { 0x0480, "Multimedia controller" }, { 0x0500, "RAM memory" }, { 0x0501, "FLASH memory" }, { 0x0580, "Memory controller" }, { 0x0600, "Host bridge" }, { 0x0601, "ISA bridge" }, { 0x0602, "EISA bridge" }, { 0x0603, "MicroChannel bridge" }, { 0x0604, "PCI bridge" }, { 0x0605, "PCMCIA bridge" }, { 0x0606, "NuBus bridge" }, { 0x0607, "CardBus bridge" }, { 0x0608, "RACEway bridge" }, { 0x0609, "Semi-transparent PCI-to-PCI bridge" }, { 0x060a, "InfiniBand to PCI host bridge" }, { 0x0680, "Bridge" }, { 0x0700, "Serial controller" }, { 0x0701, "Parallel controller" }, { 0x0702, "Multiport serial controller" }, { 0x0703, "Modem" }, { 0x0780, "Communication controller" }, { 0x0800, "PIC" }, { 0x0801, "DMA controller" }, { 0x0802, "Timer" }, { 0x0803, "RTC" }, { 0x0804, "PCI Hot-plug controller" }, { 0x0880, "System peripheral" }, { 0x0900, "Keyboard controller" }, { 0x0901, "Digitizer Pen" }, { 0x0902, "Mouse controller" }, { 0x0903, "Scanner controller" }, { 0x0904, "Gameport controller" }, { 0x0980, "Input device controller" }, { 0x0a00, "Generic Docking Station" }, { 0x0a80, "Docking Station" }, { 0x0b00, "386" }, { 0x0b01, "486" }, { 0x0b02, "Pentium" }, { 0x0b10, "Alpha" }, { 0x0b20, "Power PC" }, { 0x0b30, "MIPS" }, { 0x0b40, "Co-processor" }, { 0x0c00, "FireWire (IEEE 1394 }," }, { 0x0c01, "ACCESS Bus" }, { 0x0c02, "SSA" }, { 0x0c03, "USB Controller" }, { 0x0c04, "Fibre Channel" }, { 0x0c05, "SMBus" }, { 0x0c06, "InfiniBand" }, { 0x0d00, "IRDA controller" }, { 0x0d01, "Consumer IR controller" }, { 0x0d10, "RF controller" }, { 0x0d80, "Wireless controller" }, { 0x0e00, "I2O" }, { 0x0f00, "Satellite TV controller" }, { 0x0f01, "Satellite audio communication controller" }, { 0x0f03, "Satellite voice communication controller" }, { 0x0f04, "Satellite data communication controller" }, { 0x1000, "Network and computing encryption device" }, { 0x1010, "Entertainment encryption device" }, { 0x1080, "Encryption controller" }, { 0x1100, "DPIO module" }, { 0x1101, "Performance counters" }, { 0x1110, "Communication synchronizer" }, { 0x1180, "Signal processing controller" },
/* Definitions of target machine for GNU compiler. VAX sysV version. Copyright (C) 1988, 1993, 1996, 2000, 2002 Free Software Foundation, Inc. This file is part of GCC. GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GCC; see the file COPYING. If not, write to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #define TARGET_OS_CPP_BUILTINS() \ do \ { \ builtin_define_std ("unix"); \ builtin_assert ("system=svr3"); \ \ builtin_define_std ("vax"); \ if (TARGET_G_FLOAT) \ builtin_define_std ("GFLOAT"); \ } \ while (0) /* Output #ident as a .ident. */ #define ASM_OUTPUT_IDENT(FILE, NAME) fprintf (FILE, "\t.ident \"%s\"\n", NAME); #undef DBX_DEBUGGING_INFO #define SDB_DEBUGGING_INFO 1 #undef LIB_SPEC /* The .file command should always begin the output. */ #define TARGET_ASM_FILE_START_FILE_DIRECTIVE true #undef ASM_OUTPUT_ALIGN #define ASM_OUTPUT_ALIGN(FILE,LOG) \ fprintf(FILE, "\t.align %d\n", 1 << (LOG)) #undef ASM_OUTPUT_LOCAL #define ASM_OUTPUT_LOCAL(FILE,NAME,SIZE,ROUNDED) \ ( data_section (), \ assemble_name ((FILE), (NAME)), \ fprintf ((FILE), ":\n\t.space %u\n", (int)(ROUNDED))) #define ASM_OUTPUT_ASCII(FILE,PTR,LEN) \ do { \ const unsigned char *s = (const unsigned char *)(PTR);\ size_t i, limit = (LEN); \ for (i = 0; i < limit; s++, i++) \ { \ if ((i % 8) == 0) \ fputs ("\n\t.byte\t", (FILE)); \ fprintf ((FILE), "%s0x%x", (i%8?",":""), (unsigned)*s); \ } \ fputs ("\n", (FILE)); \ } while (0)
/*------------------------------------------------------------------------------ © A J S Hamilton 2001 ------------------------------------------------------------------------------*/ #include "manglefn.h" /*------------------------------------------------------------------------------ Find position within ordered array by binary chop. Assumes points are uncorrelated between calls (otherwise it would be better to start search from previous point). Return value: i such that array[i-1] <= point < array[i] 0 if point < array[0] n if point >= array[n-1] */ int search(int n, double array[/*n*/], double point) { int i, im, ip; /* point below minimum */ if (point < array[0]) { return(0); /* point above maximum */ } else if (point >= array[n-1]) { return(n); /* point between limits */ } else { im = 0; ip = n-1; /* binary chop */ while (im + 1 < ip) { i = (im + ip) / 2; if (point < array[i]) { ip = i; } else if (point >= array[i]) { im = i; } }; return(ip); } }
/*----------------------------------------------------------------------------- File: vnscommand.h Date: Sun Oct 11 20:27 PST 2009 Contact: dgu@cs.stanford.edu Description: A c-style declaration of commands for the virtual router. ---------------------------------------------------------------------------*/ #ifndef __VNSCOMMAND_H #define __VNSCOMMAND_H #define VNSOPEN 1 #define VNSCLOSE 2 #define VNSPACKET 4 #define VNSBANNER 8 #define VNSHWINFO 16 #define IDSIZE 32 /*----------------------------------------------------------------------------- BASE ---------------------------------------------------------------------------*/ typedef struct { uint32_t mLen; uint32_t mType; }__attribute__ ((__packed__)) c_base; /*----------------------------------------------------------------------------- OPEN ---------------------------------------------------------------------------*/ typedef struct { uint32_t mLen; uint32_t mType; /* = VNSOPEN */ uint16_t topoID; /* Id of the topology we want to run on */ uint16_t pad; /* unused */ char mVirtualHostID[IDSIZE]; /* Id of the simulated router (e.g. 'VNS-A'); */ char mUID[IDSIZE]; /* User id (e.g. "appenz"), for information only */ char mPass[IDSIZE]; }__attribute__ ((__packed__)) c_open; /*----------------------------------------------------------------------------- CLOSE ---------------------------------------------------------------------------*/ typedef struct { uint32_t mLen; uint32_t mType; char mErrorMessage[256]; }__attribute__ ((__packed__)) c_close; /*----------------------------------------------------------------------------- HWREQUEST ---------------------------------------------------------------------------*/ typedef struct { uint32_t mLen; uint32_t mType; }__attribute__ ((__packed__)) c_hwrequest; /*----------------------------------------------------------------------------- BANNER ---------------------------------------------------------------------------*/ typedef struct { uint32_t mLen; uint32_t mType; char mBannerMessage[256]; }__attribute__ ((__packed__)) c_banner; /*----------------------------------------------------------------------------- PACKET (header) ---------------------------------------------------------------------------*/ typedef struct { uint32_t mLen; uint32_t mType; char mInterfaceName[16]; uint8_t ether_dhost[6]; uint8_t ether_shost[6]; uint16_t ether_type; }__attribute__ ((__packed__)) c_packet_ethernet_header; typedef struct { uint32_t mLen; uint32_t mType; char mInterfaceName[16]; }__attribute__ ((__packed__)) c_packet_header; /*----------------------------------------------------------------------------- HWInfo ----------------------------------------------------------------------------*/ #define HWINTERFACE 1 #define HWSPEED 2 #define HWSUBNET 4 #define HWINUSE 8 #define HWFIXEDIP 16 #define HWETHER 32 #define HWETHIP 64 #define HWMASK 128 typedef struct { uint32_t mKey; char value[32]; }__attribute__ ((__packed__)) c_hw_entry; typedef struct { #define MAXHWENTRIES 256 uint32_t mLen; uint32_t mType; c_hw_entry mHWInfo[MAXHWENTRIES]; }__attribute__ ((__packed__)) c_hwinfo; /* ******* New VNS Messages ******** */ #define VNS_RTABLE 32 #define VNS_OPEN_TEMPLATE 64 #define VNS_AUTH_REQUEST 128 #define VNS_AUTH_REPLY 256 #define VNS_AUTH_STATUS 512 /* rtable */ typedef struct { uint32_t mLen; uint32_t mType; char mVirtualHostID[IDSIZE]; char rtable[0]; }__attribute__ ((__packed__)) c_rtable; /* open template */ typedef struct { uint32_t ip; uint8_t num_masked_bits; }__attribute__ ((__packed__)) c_src_filter; typedef struct { uint32_t mLen; uint32_t mType; char templateName[30]; char mVirtualHostID[IDSIZE]; c_src_filter srcFilters[0]; }__attribute__ ((__packed__)) c_open_template; /* authentication request */ typedef struct { uint32_t mLen; uint32_t mType; uint8_t salt[0]; }__attribute__ ((__packed__)) c_auth_request; /* authentication reply */ typedef struct { uint32_t mLen; uint32_t mType; uint32_t usernameLen; char username[0]; /* remainder of the message is the salted sha1 of the user's password */ }__attribute__ ((__packed__)) c_auth_reply; /* authentication status (whether or not a reply was accepted) */ typedef struct { uint32_t mLen; uint32_t mType; uint8_t auth_ok; char msg[0]; }__attribute__ ((__packed__)) c_auth_status; #endif /* __VNSCOMMAND_H */
/* * Copyright (C) 2009 Google Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * 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 Google Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE 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 WebMediaPlayerClient_h #define WebMediaPlayerClient_h namespace WebKit { class WebRequest; class WebURL; class WebMediaPlayerClient { public: virtual void networkStateChanged() = 0; virtual void readyStateChanged() = 0; virtual void volumeChanged(float) = 0; virtual void muteChanged(bool) = 0; virtual void timeChanged() = 0; virtual void repaint() = 0; virtual void durationChanged() = 0; virtual void rateChanged() = 0; virtual void sizeChanged() = 0; virtual void sawUnsupportedTracks() = 0; protected: ~WebMediaPlayerClient() { } }; } // namespace WebKit #endif
// // BBElement.h // BBCodeParser // // Created by Miha Rataj on 2/2/12. // Copyright (c) 2012 Marg, d.o.o. All rights reserved. // #import <Foundation/Foundation.h> #import "BBAttribute.h" @interface BBElement : NSObject @property (nonatomic, copy) NSString *tag; @property (weak, nonatomic, readonly) NSString *plainText; //must be strong if mutable @property (nonatomic, strong) NSMutableString *format; @property (nonatomic, strong) NSArray *attributes; @property (nonatomic, strong) NSArray *elements; @property (nonatomic, weak) BBElement *parent; @property (nonatomic, assign) NSInteger startIndex; @property (nonatomic, assign) NSInteger range; - (BBAttribute *)attributeWithName:(NSString *)name; - (BBElement *)elementAtIndex:(NSInteger)index; @end
/* * Copyright (c) 2007 Boudewijn Rempt <boud@valdyas.org> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef KIS_FIXED_PAINT_DEVICE_TESTER_H #define KIS_FIXED_PAINT_DEVICE_TESTER_H #include <QtTest> class KisFixedPaintDeviceTest : public QObject { Q_OBJECT private slots: void testCreation(); void testSilly(); void testClear(); void testFill(); void testRoundtripQImageConversion(); void testBltFixed(); void testBltFixedOpacity(); void testBltFixedSmall(); void testColorSpaceConversion(); void testBltPerformance(); void testMirroring_data(); void testMirroring(); }; #endif
/* * Hydrogen * Copyright(c) 2002-2008 by Alex >Comix< Cominu [comix@users.sourceforge.net] * * http://www.hydrogen-music.org * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY, without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #ifndef LFILEMNG_H #define LFILEMNG_H #include <iostream> #include <fstream> #include <vector> #include <string> #include <hydrogen/object.h> #include <QDomDocument> namespace H2Core { class Note; class Instrument; class InstrumentList; class Sequence; class Pattern; class Song; class Drumkit; /** * */ class LocalFileMng : public H2Core::Object { H2_OBJECT public: LocalFileMng(); ~LocalFileMng(); static std::vector<QString> getDrumkitsFromDirectory( QString ); std::vector<QString> getPatternDirList(); std::vector<QString> getSongList(); std::vector<QString> getPatternsForDrumkit( const QString& ); std::vector<QString> getAllPatternNames(); int getPatternList( const QString& ); int mergeAllPatternList( std::vector<QString> ); std::vector<QString> getallPatternList(){ return m_allPatternList; } std::vector<QString> getAllCategoriesFromPattern(); QString getDrumkitNameForPattern( const QString& patternDir ); static void writeXmlString( QDomNode parent, const QString& name, const QString& text ); static void writeXmlBool( QDomNode parent, const QString& name, bool value ); Pattern* loadPattern( const QString& directory ); int savePattern( Song *song , const QString& drumkit_name, int selectedpattern , const QString& patternname, const QString& realpatternname, int mode); int savePlayList( const std::string& patternname ); int loadPlayList( const std::string& patternname); static QString copyInstrumentLineToString(Song *song, int selectedPattern, int selectedInstrument); static bool pasteInstrumentLineFromString(Song *song, const QString & serialized, int selectedPattern, int selectedInstrument, std::list< Pattern* > & patterns); int writeTempPatternList( Song *song, const QString& filename);//used for undo/redo static QString readXmlString( QDomNode , const QString& nodeName, const QString& defaultValue, bool bCanBeEmpty = false, bool bShouldExists = true , bool tinyXmlCompatMode = false); static float readXmlFloat( QDomNode , const QString& nodeName, float defaultValue, bool bCanBeEmpty = false, bool bShouldExists = true , bool tinyXmlCompatMode = false); static int readXmlInt( QDomNode , const QString& nodeName, int defaultValue, bool bCanBeEmpty = false, bool bShouldExists = true , bool tinyXmlCompatMode = false); static bool readXmlBool( QDomNode , const QString& nodeName, bool defaultValue, bool bShouldExists = true , bool tinyXmlCompatMode = false ); static void convertFromTinyXMLString( QByteArray* str ); static bool checkTinyXMLCompatMode( const QString& filename ); static QDomDocument openXmlDocument( const QString& filename ); private: std::vector<QString> m_allPatternList; }; /** * Write XML file of a song */ class SongWriter : public H2Core::Object { H2_OBJECT public: SongWriter(); ~SongWriter(); // Returns 0 on success. int writeSong( Song *song, const QString& filename ); }; }; #endif //LFILEMNG_H
#include <defs.h> #include <list.h> #include <proc.h> #include <assert.h> #include <default_sched.h> #define USE_SKEW_HEAP 1 /* You should define the BigStride constant here*/ /* LAB6: 2013011358 */ #define BIG_STRIDE 0x7FFFFFFF/* you should give a value, and is 0111 1111 1111 1111 1111 1111 1111 1111 */ /* The compare function for two skew_heap_node_t's and the * corresponding procs*/ static int proc_stride_comp_f(void *a, void *b) { struct proc_struct *p = le2proc(a, lab6_run_pool); struct proc_struct *q = le2proc(b, lab6_run_pool); int32_t c = p->lab6_stride - q->lab6_stride; if (c > 0) return 1; else if (c == 0) return 0; else return -1; } /* * stride_init initializes the run-queue rq with correct assignment for * member variables, including: * * - run_list: should be a empty list after initialization. * - lab6_run_pool: NULL * - proc_num: 0 * - max_time_slice: no need here, the variable would be assigned by the caller. * * hint: see libs/list.h for routines of the list structures. */ static void stride_init(struct run_queue *rq) { /* LAB6: 2013011358 * (1) init the ready process list: rq->run_list * (2) init the run pool: rq->lab6_run_pool * (3) set number of process: rq->proc_num to 0 */ list_init(&(rq->run_list)); //(1) init the ready process list: rq->run_list rq->lab6_run_pool = 0; //(2) init the run pool: rq->lab6_run_pool rq->proc_num = 0; //(3) set number of process: rq->proc_num to 0 } /* * stride_enqueue inserts the process ``proc'' into the run-queue * ``rq''. The procedure should verify/initialize the relevant members * of ``proc'', and then put the ``lab6_run_pool'' node into the * queue(since we use priority queue here). The procedure should also * update the meta date in ``rq'' structure. * * proc->time_slice denotes the time slices allocation for the * process, which should set to rq->max_time_slice. * * hint: see libs/skew_heap.h for routines of the priority * queue structures. */ static void stride_enqueue(struct run_queue *rq, struct proc_struct *proc) { /* LAB6: 2013011358 * (1) insert the proc into rq correctly * NOTICE: you can use skew_heap or list. Important functions * skew_heap_insert: insert a entry into skew_heap * list_add_before: insert a entry into the last of list * (2) recalculate proc->time_slice * (3) set proc->rq pointer to rq * (4) increase rq->proc_num */ //(1) insert the proc into rq correctly rq->lab6_run_pool = skew_heap_insert(rq->lab6_run_pool, &(proc->lab6_run_pool), proc_stride_comp_f); //(2) recalculate proc->time_slice if (proc->time_slice == 0 || proc->time_slice > rq->max_time_slice) proc->time_slice = rq->max_time_slice; proc->rq = rq; //(3) set proc->rq pointer to rq rq->proc_num ++; //(4) increase rq->proc_num } /* * stride_dequeue removes the process ``proc'' from the run-queue * ``rq'', the operation would be finished by the skew_heap_remove * operations. Remember to update the ``rq'' structure. * * hint: see libs/skew_heap.h for routines of the priority * queue structures. */ static void stride_dequeue(struct run_queue * rq, struct proc_struct * proc) { /* LAB6: 2013011358 * (1) remove the proc from rq correctly * NOTICE: you can use skew_heap or list. Important functions * skew_heap_remove: remove a entry from skew_heap * list_del_init: remove a entry from the list */ //(1) remove the proc from rq correctly rq->lab6_run_pool = skew_heap_remove(rq->lab6_run_pool, &(proc->lab6_run_pool), proc_stride_comp_f); rq->proc_num--; //进程数减一 } /* * stride_pick_next pick the element from the ``run-queue'', with the * minimum value of stride, and returns the corresponding process * pointer. The process pointer would be calculated by macro le2proc, * see kern/process/proc.h for definition. Return NULL if * there is no process in the queue. * * When one proc structure is selected, remember to update the stride * property of the proc. (stride += BIG_STRIDE / priority) * * hint: see libs/skew_heap.h for routines of the priority * queue structures. */ static struct proc_struct * stride_pick_next(struct run_queue * rq) { /* LAB6: 2013011358 * (1) get a proc_struct pointer p with the minimum value of stride (1.1) If using skew_heap, we can use le2proc get the p from rq->lab6_run_poll (1.2) If using list, we have to search list to find the p with minimum stride value * (2) update p;s stride value: p->lab6_stride * (3) return p */ //无进程 if (rq->lab6_run_pool == 0) return 0; //(1) get a proc_struct pointer p with the minimum value of stride struct proc_struct *p = le2proc(rq->lab6_run_pool, lab6_run_pool); //(2) update p;s stride value: p->lab6_stride if (p->lab6_priority == 0) p->lab6_stride += BIG_STRIDE; else p->lab6_stride += BIG_STRIDE / p->lab6_priority; return p; } /* * stride_proc_tick works with the tick event of current process. You * should check whether the time slices for current process is * exhausted and update the proc struct ``proc''. proc->time_slice * denotes the time slices left for current * process. proc->need_resched is the flag variable for process * switching. */ static void stride_proc_tick(struct run_queue * rq, struct proc_struct * proc) { /* LAB6: 2013011358 */ if (proc->time_slice > 0) proc->time_slice--; if (proc->time_slice == 0) proc->need_resched = 1; } struct sched_class default_sched_class = { .name = "stride_scheduler", .init = stride_init, .enqueue = stride_enqueue, .dequeue = stride_dequeue, .pick_next = stride_pick_next, .proc_tick = stride_proc_tick, };
#include "auto_home.h" void hier() { c("/","etc","dnsroots.global",-1,-1,0644); h(auto_home,-1,-1,02755); d(auto_home,"bin",-1,-1,02755); c(auto_home,"bin","dnscache-conf",-1,-1,0755); c(auto_home,"bin","tinydns-conf",-1,-1,0755); c(auto_home,"bin","walldns-conf",-1,-1,0755); c(auto_home,"bin","rbldns-conf",-1,-1,0755); c(auto_home,"bin","pickdns-conf",-1,-1,0755); c(auto_home,"bin","axfrdns-conf",-1,-1,0755); c(auto_home,"bin","dnscache",-1,-1,0755); c(auto_home,"bin","tinydns",-1,-1,0755); c(auto_home,"bin","walldns",-1,-1,0755); c(auto_home,"bin","rbldns",-1,-1,0755); c(auto_home,"bin","pickdns",-1,-1,0755); c(auto_home,"bin","axfrdns",-1,-1,0755); c(auto_home,"bin","tinydns-get",-1,-1,0755); c(auto_home,"bin","tinydns-data",-1,-1,0755); c(auto_home,"bin","tinydns-edit",-1,-1,0755); c(auto_home,"bin","rbldns-data",-1,-1,0755); c(auto_home,"bin","pickdns-data",-1,-1,0755); c(auto_home,"bin","axfr-get",-1,-1,0755); c(auto_home,"bin","dnsip",-1,-1,0755); c(auto_home,"bin","dnsipq",-1,-1,0755); c(auto_home,"bin","dnsname",-1,-1,0755); c(auto_home,"bin","dnstxt",-1,-1,0755); c(auto_home,"bin","dnsmx",-1,-1,0755); c(auto_home,"bin","dnsfilter",-1,-1,0755); c(auto_home,"bin","random-ip",-1,-1,0755); c(auto_home,"bin","dnsqr",-1,-1,0755); c(auto_home,"bin","dnsq",-1,-1,0755); c(auto_home,"bin","dnstrace",-1,-1,0755); c(auto_home,"bin","dnstracesort",-1,-1,0755); }
#ifndef _abort_h_ #define _abort_h_ /* abort.c */ int get_command_width(void); void plot_command(int nit, int icount, int cwidth); int my_abort(void); #endif
#ifndef _XT_CLASSIFY_H #define _XT_CLASSIFY_H #include <linux/types.h> struct xt_classify_target_info { __u32 priority; }; #endif /*_XT_CLASSIFY_H */
#include "../src/gui/embedded/qmousedriverfactory_qws.h"