text
stringlengths
4
6.14k
/*************************************************************************** * Copyright (C) 2010 Philipp Nordhus * * * * This program is free software: you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation, either version 3 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see <http://www.gnu.org/licenses/>. * ***************************************************************************/ #ifndef GAME_DEPOT_H #define GAME_DEPOT_H #include "gfx/video.h" #include "sfx/sound.h" #include "ui/arrow.h" #include "ui/frame.h" #include "ui/list.h" #include "ui/itemlist.h" #include <map> #include <deque> namespace game { class Boat; class Depot : public ui::Frame { private: enum State { Flipping, Loading, Ready, Repair }; enum LoadingState { Arrows, List1, List2 }; class RepairItem { public: int model; QString mounting; int state; int cost; ui::Label lblState; ui::Label lblCost; ui::Button btnRepair; RepairItem(int model, const QString &mounting, ui::Label *parent) : model(model), mounting(mounting), lblState(parent), lblCost(parent), btnRepair(parent) { } }; public: Depot(std::function<void()> &&funcClose); private: void flip(); void loadMounting(int index); void itemListClicked1(int index); void itemListClicked2(int index); void toggleInfo(); void buy(); void sell(); void repair(); void updateInfo(); void updateCredits(); void updateButtons(); void repairItem(int index); void repairAll(); protected: void draw(); bool mousePressEvent(const QPoint &pos, Qt::MouseButton button); private: ui::Label m_backgroundLabel; sfx::Sound m_backgroundSound; ui::Label m_panelMountings; ui::Label m_panelRepair; gfx::Video m_videoFlip1; gfx::Video m_videoFlip2; gfx::Texture m_boatTexture; ui::Label *m_boatLabel; ui::Label *m_boatName; ui::Label *m_credits; ui::Button *m_btnFlip; ui::Button *m_btnRepair; ui::Button *m_btnBuy; ui::Button *m_btnSell; ui::Button *m_btnInfo; ui::Label *m_lblInfo; ui::Label *m_lblItemName; ui::Label *m_lblItemPrice; ui::List *m_lblItemText; ui::Label *m_lblItemVideo; gfx::Video m_videoItem; gfx::Texture m_itemTexture; ui::ItemList *m_itemList1; ui::ItemList *m_itemList2; std::map<int, ui::Arrow> m_mountingArrows; std::list<ui::Label> m_repairLabels; std::deque<RepairItem> m_repairItems; ui::Label m_repairCost; ui::Button m_repairButton; Boat *m_boat; int m_side; int m_mounting; std::vector<int> m_list1; std::vector<int> m_list2; int m_selectedList; int m_selectedItem; QTime m_time; State m_state; LoadingState m_loadingState; int m_loadingItem; sfx::Sound m_sndFlip; sfx::Sound m_sndWeapon; sfx::Sound m_sndError; sfx::Sound m_sndButton; sfx::Sound m_sndSelect; sfx::Sound m_sndNoop; }; } // namespace game #endif // GAME_DEPOT_H
#include <stdio.h> #if ((!(defined(__PS3__) && !defined(__PSL1GHT))) && !defined(__APPLE__)) #include <malloc.h> #endif #include <string.h> #include "sp0256.h" #include "zx81config.h" #include <funcs.h> struct PHONE *Phones=NULL; void SP0256_Init(void) { FILE *f; int a,i,len; char FileName[256]; int offset; if (Phones) free(Phones); Phones=NULL; strcpy(FileName,zx81.cwd); if (FileName[strlen(FileName)-1]=='\\') FileName[strlen(FileName)-1]='\0'; strcat(FileName,"\\rom\\sp0256.bin"); f=fopen(FileName,"rb"); if (!f) return; fseek(f, 0, SEEK_END); len=ftell(f); fseek(f, 0, SEEK_SET); if (!len) { fclose(f); return; } Phones=malloc(len); if (!Phones) { fclose(f); return; } fread(Phones, 1, len, f); fclose(f); offset=64*sizeof(struct PHONE); for(i=0;i<64;i++) { a =(int)Phones[i].position; a += offset; Phones[i].position = (((char *)Phones) + a); a=0; } } static int Last=0; void SP0256_Write(unsigned char Data) { if (!Phones) return; if (!Data) return; if (Data==Last) return; Last=Data; PlaySound(NULL, NULL, SND_PURGE); PlaySound(Phones[Data&63].position, NULL, SND_MEMORY | SND_ASYNC); } unsigned char SP0256_Busy(void) { if (!Phones) return(0); return(!PlaySound(Phones[0].position, NULL, SND_MEMORY | SND_ASYNC | SND_NOSTOP)); }
// // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 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 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #ifndef __CYGNAL_H__ #define __CYGNAL_H__ #include <boost/cstdint.hpp> #include <boost/shared_ptr.hpp> #include <boost/thread/mutex.hpp> #include <vector> #include <string> #include <map> #include "extension.h" #include "handler.h" /// \namespace cygnal /// /// This namespace is for all the Cygnal specific classes not used by /// anything else in Gnash. namespace cygnal { /// \class cygnal::Cygnal class Cygnal { public: typedef Handler::cygnal_init_t (*initentry_t)(); typedef struct { std::string hostname; short port; bool connected; int fd; gnash::Network::protocols_supported_e protocol; std::vector<std::string> supported; } peer_t; static Cygnal& getDefaultInstance(); ~Cygnal(); bool loadPeersFile(); bool loadPeersFile(const std::string &filespec); void probePeers(); void probePeers(peer_t &peer); void probePeers(boost::shared_ptr<peer_t> peer); void probePeers(std::vector<boost::shared_ptr<peer_t> > &peers); void addHandler(const std::string &path, boost::shared_ptr<Handler> x) { _handlers[path] = x; }; boost::shared_ptr<Handler> findHandler(const std::string &path); void removeHandler(const std::string &path); std::vector<boost::shared_ptr<peer_t> > & getActive() { return _active_peers; }; void dump(); private: void addPeer(boost::shared_ptr<peer_t> x) { _peers.push_back(x); }; std::vector<boost::shared_ptr<peer_t> > _peers; std::vector<boost::shared_ptr<peer_t> > _active_peers; std::map<std::string, boost::shared_ptr<Handler> > _handlers; boost::mutex _mutex; }; /// \class cygnal::ThreadCounter of threads currently /// active. This is primarily so the counter can be wrapped with a /// mutex to be thread safe, as threads delete themseleves. class ThreadCounter { public: ThreadCounter() : _tids(0) {}; void increment() { boost::mutex::scoped_lock lk(_tid_mutex); ++_tids; }; void decrement() { boost::mutex::scoped_lock lk(_tid_mutex); --_tids; }; int num_of_tids() { return _tids; }; private: boost::mutex _tid_mutex; int _tids; boost::thread _tid_handle; }; // End of gnash namespace } // __CYGNAL_H__ #endif // local Variables: // mode: C++ // indent-tabs-mode: t // End:
#ifndef __CONFIG_LINUX_KERNEL_INC__ #define __CONFIG_LINUX_KERNEL_INC__ #include <linux/kernel.h> #include <linux/types.h> #include <linux/ctype.h> #include <linux/delay.h> #include <linux/slab.h> #include <linux/crc32.h> #include <linux/ftrace.h> #include <sound/pcm.h> //HTC_AUD_START #undef pr_debug #undef pr_info #undef pr_err #define pr_debug(fmt, ...) pr_aud_debug(fmt, ##__VA_ARGS__) #define pr_info(fmt, ...) pr_aud_info(fmt, ##__VA_ARGS__) #define pr_err(fmt, ...) pr_aud_err(fmt, ##__VA_ARGS__) //HTC_AUD_END /* i2c transaction on Linux limited to 64k (See Linux kernel documentation: Documentation/i2c/writing-clients) */ #define MAX_I2C_BUFFER_SIZE 65536 /* max. length of a alsa mixer control name */ #define MAX_CONTROL_NAME 48 /* dbgprint.h */ #define PRINT(fmt) "%s: " fmt, __func__ #define _ASSERT(e) #define PRINT_ASSERT(e)if ((e)) printk(KERN_ERR "PrintAssert:%s (%s:%d) error code:%d\n",__FUNCTION__,__FILE__,__LINE__, e) #define TFA98XX_MAX_REGISTER 0xff #define TFA98XX_FLAG_DSP_START_ON_MUTE (1 << 0) #define TFA98XX_FLAG_SKIP_INTERRUPTS (1 << 1) #define TFA98XX_FLAG_SAAM_AVAILABLE (1 << 2) #define TFA98XX_FLAG_STEREO_DEVICE (1 << 3) #define TFA98XX_FLAG_MULTI_MIC_INPUTS (1 << 4) #define TFA98XX_FLAG_TAPDET_AVAILABLE (1 << 5) #define TFA98XX_FLAG_TFA9890_FAM_DEV (1 << 6) #define TFA98XX_NUM_RATES 9 /* DSP init status */ enum tfa98xx_dsp_init_state { TFA98XX_DSP_INIT_STOPPED, /* DSP not running */ TFA98XX_DSP_INIT_RECOVER, /* DSP error detected at runtime */ TFA98XX_DSP_INIT_FAIL, /* DSP init failed */ TFA98XX_DSP_INIT_PENDING, /* DSP start requested */ TFA98XX_DSP_INIT_DONE, /* DSP running */ TFA98XX_DSP_INIT_INVALIDATED, /* DSP was running, requires re-init */ }; enum tfa98xx_dsp_fw_state { TFA98XX_DSP_FW_NONE = 0, TFA98XX_DSP_FW_PENDING, TFA98XX_DSP_FW_FAIL, TFA98XX_DSP_FW_OK, }; struct tfa98xx_firmware { void *base; struct tfa98xx_device *dev; char name[9]; //TODO get length from tfa parameter defs }; struct tfa98xx_baseprofile { char basename[MAX_CONTROL_NAME]; /* profile basename */ int len; /* profile length */ int item_id; /* profile id */ int sr_rate_sup[TFA98XX_NUM_RATES]; /* sample rates supported by this profile */ struct list_head list; /* list of all profiles */ }; struct tfa98xx { struct regmap *regmap; struct i2c_client *i2c; struct regulator *vdd; struct snd_soc_codec *codec; struct workqueue_struct *tfa98xx_wq; struct delayed_work init_work; struct delayed_work monitor_work; struct delayed_work interrupt_work; struct delayed_work tapdet_work; struct mutex dsp_lock; int dsp_init; int dsp_fw_state; int sysclk; int rst_gpio; u16 rev; int has_drc; int audio_mode; struct tfa98xx_firmware fw; char *fw_name; int rate; wait_queue_head_t wq; struct device *dev; unsigned int init_count; int pstream; int cstream; struct input_dev *input; bool tapdet_enabled; /* service enabled */ bool tapdet_open; /* device file opened */ unsigned int tapdet_profiles; /* tapdet profile bitfield */ bool tapdet_poll; /* tapdet running on polling mode */ unsigned int rate_constraint_list[TFA98XX_NUM_RATES]; struct snd_pcm_hw_constraint_list rate_constraint; int reset_gpio; int power_gpio; int irq_gpio; //HTC_AUD_START int spk_source; //HTC_AUD_END int handle; #ifdef CONFIG_DEBUG_FS struct dentry *dbg_dir; #endif u8 reg; unsigned int count_wait_for_source_state; unsigned int count_noclk; unsigned int flags; }; #if defined(CONFIG_TRACING) && defined(DEBUG) #define tfa98xx_trace_printk(...) trace_printk(__VA_ARGS__) #else #define tfa98xx_trace_printk(...) #endif #endif /* __CONFIG_LINUX_KERNEL_INC__ */
/* * This file is part of the libsigrok project. * * Copyright (C) 2011 Daniel Ribeiro <drwyrm@gmail.com> * Copyright (C) 2012 Uwe Hermann <uwe@hermann-uwe.de> * Copyright (C) 2012 Alexandru Gagniuc <mr.nuke.me@gmail.com> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 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 St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef LIBSIGROK_HARDWARE_ALSA_PROTOCOL_H #define LIBSIGROK_HARDWARE_ALSA_PROTOCOL_H #include <stdint.h> #include <alsa/asoundlib.h> #include "libsigrok.h" #include "libsigrok-internal.h" /* Message logging helpers with driver-specific prefix string. */ #define DRIVER_LOG_DOMAIN "alsa: " #define sr_log(l, s, args...) sr_log(l, DRIVER_LOG_DOMAIN s, ## args) #define sr_spew(s, args...) sr_spew(DRIVER_LOG_DOMAIN s, ## args) #define sr_dbg(s, args...) sr_dbg(DRIVER_LOG_DOMAIN s, ## args) #define sr_info(s, args...) sr_info(DRIVER_LOG_DOMAIN s, ## args) #define sr_warn(s, args...) sr_warn(DRIVER_LOG_DOMAIN s, ## args) #define sr_err(s, args...) sr_err(DRIVER_LOG_DOMAIN s, ## args) /** Private, per-device-instance driver context. */ struct dev_context { uint64_t cur_samplerate; uint64_t limit_samples; uint64_t num_samples; uint8_t num_probes; struct sr_samplerates supp_rates; char *hwdev; snd_pcm_t *capture_handle; snd_pcm_hw_params_t *hw_params; struct pollfd *ufds; void *cb_data; }; SR_PRIV GSList *alsa_scan(GSList *options, struct sr_dev_driver *di); SR_PRIV void alsa_dev_inst_clear(struct sr_dev_inst *sdi); SR_PRIV int alsa_set_samplerate(const struct sr_dev_inst *sdi, uint64_t newrate); SR_PRIV int alsa_receive_data(int fd, int revents, void *cb_data); #endif
/* readlink wrapper to return the link name in malloc'd storage. Unlike xreadlink and xreadlink_with_size, don't ever call exit. Copyright (C) 2001, 2003-2007, 2009-2012 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ /* Written by Jim Meyering <jim@meyering.net> */ #include <config.h> #include "areadlink.h" #include <errno.h> #include <limits.h> #include <stdint.h> #include <stdlib.h> #include <unistd.h> #ifndef SSIZE_MAX # define SSIZE_MAX ((ssize_t) (SIZE_MAX / 2)) #endif /* SYMLINK_MAX is used only for an initial memory-allocation sanity check, so it's OK to guess too small on hosts where there is no arbitrary limit to symbolic link length. */ #ifndef SYMLINK_MAX # define SYMLINK_MAX 1024 #endif #define MAXSIZE (SIZE_MAX < SSIZE_MAX ? SIZE_MAX : SSIZE_MAX) /* Call readlink to get the symbolic link value of FILE. SIZE is a hint as to how long the link is expected to be; typically it is taken from st_size. It need not be correct. Return a pointer to that NUL-terminated string in malloc'd storage. If readlink fails, malloc fails, or if the link value is longer than SSIZE_MAX, return NULL (caller may use errno to diagnose). */ char * areadlink_with_size (char const *file, size_t size) { /* Some buggy file systems report garbage in st_size. Defend against them by ignoring outlandish st_size values in the initial memory allocation. */ size_t symlink_max = SYMLINK_MAX; size_t INITIAL_LIMIT_BOUND = 8 * 1024; size_t initial_limit = (symlink_max < INITIAL_LIMIT_BOUND ? symlink_max + 1 : INITIAL_LIMIT_BOUND); /* The initial buffer size for the link value. */ size_t buf_size = size < initial_limit ? size + 1 : initial_limit; while (1) { ssize_t r; size_t link_length; char *buffer = malloc (buf_size); if (buffer == NULL) return NULL; r = readlink (file, buffer, buf_size); link_length = r; /* On AIX 5L v5.3 and HP-UX 11i v2 04/09, readlink returns -1 with errno == ERANGE if the buffer is too small. */ if (r < 0 && errno != ERANGE) { int saved_errno = errno; free (buffer); errno = saved_errno; return NULL; } if (link_length < buf_size) { buffer[link_length] = 0; return buffer; } free (buffer); if (buf_size <= MAXSIZE / 2) buf_size *= 2; else if (buf_size < MAXSIZE) buf_size = MAXSIZE; else { errno = ENOMEM; return NULL; } } }
/* * Copyright (C) 2005, 2010-2012 Free Software Foundation, Inc. * Written by Simon Josefsson * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see <http://www.gnu.org/licenses/>. */ #include <config.h> #include <stdio.h> #include <string.h> #include "gc.h" int main (int argc, char *argv[]) { Gc_rc rc; rc = gc_init (); if (rc != GC_OK) { printf ("gc_init() failed\n"); return 1; } /* Test vectors from RFC 2104. */ { char *key = "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; size_t key_len = 16; char *data = "Hi There"; size_t data_len = 8; char *digest = "\x92\x94\x72\x7a\x36\x38\xbb\x1c\x13\xf4\x8e\xf8\x15\x8b\xfc\x9d"; char out[16]; /* key = 0x0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b key_len = 16 bytes data = "Hi There" data_len = 8 bytes digest = 0x9294727a3638bb1c13f48ef8158bfc9d */ if (gc_hmac_md5 (key, key_len, data, data_len, out) != 0) { printf ("call failure\n"); return 1; } if (memcmp (digest, out, 16) != 0) { size_t i; printf ("hash 1 mismatch. expected:\n"); for (i = 0; i < 16; i++) printf ("%02x ", digest[i] & 0xFF); printf ("\ncomputed:\n"); for (i = 0; i < 16; i++) printf ("%02x ", out[i] & 0xFF); printf ("\n"); return 1; } } gc_done (); return 0; }
/* Split a double into fraction and mantissa, for hexadecimal printf. Copyright (C) 2007 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 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> /* Specification. */ #ifdef USE_LONG_DOUBLE # include "printf-frexpl.h" #else # include "printf-frexp.h" #endif #include <float.h> #include <math.h> #ifdef USE_LONG_DOUBLE # include "fpucw.h" #endif /* This file assumes FLT_RADIX = 2. If FLT_RADIX is a power of 2 greater than 2, or not even a power of 2, some rounding errors can occur, so that then the returned mantissa is only guaranteed to be <= 2.0, not < 2.0. */ #ifdef USE_LONG_DOUBLE # define FUNC printf_frexpl # define DOUBLE long double # define MIN_EXP LDBL_MIN_EXP # if HAVE_FREXPL_IN_LIBC && HAVE_LDEXPL_IN_LIBC # define USE_FREXP_LDEXP # define FREXP frexpl # define LDEXP ldexpl # endif # define DECL_ROUNDING DECL_LONG_DOUBLE_ROUNDING # define BEGIN_ROUNDING() BEGIN_LONG_DOUBLE_ROUNDING () # define END_ROUNDING() END_LONG_DOUBLE_ROUNDING () # define L_(literal) literal##L #else # define FUNC printf_frexp # define DOUBLE double # define MIN_EXP DBL_MIN_EXP # if HAVE_FREXP_IN_LIBC && HAVE_LDEXP_IN_LIBC # define USE_FREXP_LDEXP # define FREXP frexp # define LDEXP ldexp # endif # define DECL_ROUNDING # define BEGIN_ROUNDING() # define END_ROUNDING() # define L_(literal) literal #endif DOUBLE FUNC (DOUBLE x, int *expptr) { int exponent; DECL_ROUNDING BEGIN_ROUNDING (); #ifdef USE_FREXP_LDEXP /* frexp and ldexp are usually faster than the loop below. */ x = FREXP (x, &exponent); x = x + x; exponent -= 1; if (exponent < MIN_EXP - 1) { x = LDEXP (x, exponent - (MIN_EXP - 1)); exponent = MIN_EXP - 1; } #else { /* Since the exponent is an 'int', it fits in 64 bits. Therefore the loops are executed no more than 64 times. */ DOUBLE pow2[64]; /* pow2[i] = 2^2^i */ DOUBLE powh[64]; /* powh[i] = 2^-2^i */ int i; exponent = 0; if (x >= L_(1.0)) { /* A nonnegative exponent. */ { DOUBLE pow2_i; /* = pow2[i] */ DOUBLE powh_i; /* = powh[i] */ /* Invariants: pow2_i = 2^2^i, powh_i = 2^-2^i, x * 2^exponent = argument, x >= 1.0. */ for (i = 0, pow2_i = L_(2.0), powh_i = L_(0.5); ; i++, pow2_i = pow2_i * pow2_i, powh_i = powh_i * powh_i) { if (x >= pow2_i) { exponent += (1 << i); x *= powh_i; } else break; pow2[i] = pow2_i; powh[i] = powh_i; } } /* Here 1.0 <= x < 2^2^i. */ } else { /* A negative exponent. */ { DOUBLE pow2_i; /* = pow2[i] */ DOUBLE powh_i; /* = powh[i] */ /* Invariants: pow2_i = 2^2^i, powh_i = 2^-2^i, x * 2^exponent = argument, x < 1.0, exponent >= MIN_EXP - 1. */ for (i = 0, pow2_i = L_(2.0), powh_i = L_(0.5); ; i++, pow2_i = pow2_i * pow2_i, powh_i = powh_i * powh_i) { if (exponent - (1 << i) < MIN_EXP - 1) break; exponent -= (1 << i); x *= pow2_i; if (x >= L_(1.0)) break; pow2[i] = pow2_i; powh[i] = powh_i; } } /* Here either x < 1.0 and exponent - 2^i < MIN_EXP - 1 <= exponent, or 1.0 <= x < 2^2^i and exponent >= MIN_EXP - 1. */ if (x < L_(1.0)) /* Invariants: x * 2^exponent = argument, x < 1.0 and exponent - 2^i < MIN_EXP - 1 <= exponent. */ while (i > 0) { i--; if (exponent - (1 << i) >= MIN_EXP - 1) { exponent -= (1 << i); x *= pow2[i]; if (x >= L_(1.0)) break; } } /* Here either x < 1.0 and exponent = MIN_EXP - 1, or 1.0 <= x < 2^2^i and exponent >= MIN_EXP - 1. */ } /* Invariants: x * 2^exponent = argument, and either x < 1.0 and exponent = MIN_EXP - 1, or 1.0 <= x < 2^2^i and exponent >= MIN_EXP - 1. */ while (i > 0) { i--; if (x >= pow2[i]) { exponent += (1 << i); x *= powh[i]; } } /* Here either x < 1.0 and exponent = MIN_EXP - 1, or 1.0 <= x < 2.0 and exponent >= MIN_EXP - 1. */ } #endif END_ROUNDING (); *expptr = exponent; return x; }
/* -*- Mode: C++; coding: utf-8; tab-width: 3; indent-tabs-mode: tab; c-basic-offset: 3 -*- ******************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * Copyright create3000, Scheffelstraße 31a, Leipzig, Germany 2011. * * All rights reserved. Holger Seelig <holger.seelig@yahoo.de>. * * THIS IS UNPUBLISHED SOURCE CODE OF create3000. * * The copyright notice above does not evidence any actual of intended * publication of such source code, and is an unpublished work by create3000. * This material contains CONFIDENTIAL INFORMATION that is the property of * create3000. * * No permission is granted to copy, distribute, or create derivative works from * the contents of this software, in whole or in part, without the prior written * permission of create3000. * * NON-MILITARY USE ONLY * * All create3000 software are effectively free software with a non-military use * restriction. It is free. Well commented source is provided. You may reuse the * source in any way you please with the exception anything that uses it must be * marked to indicate is contains 'non-military use only' components. * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * Copyright 1999, 2016 Holger Seelig <holger.seelig@yahoo.de>. * * This file is part of the Titania Project. * * Titania is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License version 3 only, as published by the * Free Software Foundation. * * Titania 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 version 3 for more * details (a copy is included in the LICENSE file that accompanied this code). * * You should have received a copy of the GNU General Public License version 3 * along with Titania. If not, see <http://www.gnu.org/licenses/gpl.html> for a * copy of the GPLv3 License. * * For Silvio, Joy and Adi. * ******************************************************************************/ #ifndef __TITANIA_X3D_TOOLS_GEOMETRY3D_INDEXED_FACE_SET_X3DINDEXED_FACE_SET_CUT_OBJECT_H__ #define __TITANIA_X3D_TOOLS_GEOMETRY3D_INDEXED_FACE_SET_X3DINDEXED_FACE_SET_CUT_OBJECT_H__ #include "X3DIndexedFaceSetSelectionObject.h" namespace titania { namespace X3D { class X3DIndexedFaceSetCutObject : virtual public X3DIndexedFaceSetSelectionObject { public: /// @name Hidden fields SFBool & cutSnapping () { return *fields .cutSnapping; } const SFBool & cutSnapping () const { return *fields .cutSnapping; } /// @name Destruction virtual void dispose () { } virtual ~X3DIndexedFaceSetCutObject () override; protected: /// @name Construction X3DIndexedFaceSetCutObject (); /// @name Operations std::vector <int32_t> cut (const size_t, const std::pair <Vector3d, Vector3d> &, const std::vector <int32_t> &, const std::vector <int32_t> &); std::vector <int32_t> cut (const std::vector <size_t> &, const std::vector <std::vector <Vector3d>> &, const std::vector <std::vector <std::vector <int32_t>>> &); private: /// @name Operations void addPoint (const size_t cutFace, const size_t face, const int32_t index, const Vector3d & point, std::map <size_t, size_t> & fillIndices); /// @name Fields struct Fields { Fields (); SFBool* const cutSnapping; }; Fields fields; }; } // X3D } // titania #endif
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ /* libwpd * Version: MPL 2.0 / LGPLv2.1+ * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * Major Contributor(s): * Copyright (C) 2004 Marc Maurer (uwog@uwog.net) * * For minor contributions see the git repository. * * Alternatively, the contents of this file may be used under the terms * of the GNU Lesser General Public License Version 2.1 or later * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are * applicable instead of those above. * * For further information visit http://libwpd.sourceforge.net */ /* "This product is not manufactured, approved, or supported by * Corel Corporation or Corel Corporation Limited." */ #ifndef WP3PARSER_H #define WP3PARSER_H #include "WPXParser.h" class WPXDocumentInterface; class WP3Listener; class WP3ResourceFork; class WP3Parser : public WPXParser { public: WP3Parser(WPXInputStream *input, WPXHeader *header, WPXEncryption *encryption); ~WP3Parser(); void parse(WPXDocumentInterface *documentInterface); void parseSubDocument(WPXDocumentInterface *documentInterface); static void parseDocument(WPXInputStream *input, WPXEncryption *encryption, WP3Listener *listener); private: WP3ResourceFork *getResourceFork(WPXInputStream *input, WPXEncryption *encryption); void parse(WPXInputStream *input, WPXEncryption *encryption, WP3Listener *listener); }; #endif /* WP3PARSER_H */ /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */
/**************************************************************************** * * MODULE: d.paint.labels * AUTHOR(S): Jim Westervelt (CERL) (original contributor) * Radim Blazek <radim.blazek gmail.com>, * Stephan Holl <sholl gmx net>, * Glynn Clements <glynn gclements.plus.com>, * Hamish Bowman <hamish_b yahoo.com>, * Markus Neteler <neteler itc.it> * PURPOSE: displays a paint label file in the active display frame * COPYRIGHT: (C) 2003-2006 by the GRASS Development Team * * This program is free software under the GNU General Public * License (>=v2). Read the file COPYING that comes with GRASS * for details. * *****************************************************************************/ #include <stdlib.h> #include <math.h> #include <grass/gis.h> #include <grass/display.h> #include "local_proto.h" #include <grass/glocale.h> int main(int argc, char **argv) { struct Cell_head window; char *label_name; const char *mapset; double minreg, maxreg, reg, dx, dy; FILE *infile; struct Option *opt1; struct Option *maxreg_opt, *minreg_opt; struct Flag *horiz_flag; struct GModule *module; /* Initialize the GIS calls */ G_gisinit(argv[0]); /* Set description */ module = G_define_module(); G_add_keyword(_("display")); G_add_keyword(_("paint labels")); module->description = _("Displays text labels (created with v.label) " "to the active frame on the graphics monitor."); horiz_flag = G_define_flag(); horiz_flag->key = 'i'; horiz_flag->description = _("Ignore rotation setting and draw horizontally"); opt1 = G_define_option(); opt1->key = "labels"; opt1->type = TYPE_STRING; opt1->required = YES; opt1->gisprompt = "old,paint/labels,paint labels"; opt1->description = _("Name of label file"); minreg_opt = G_define_option(); minreg_opt->key = "minreg"; minreg_opt->type = TYPE_DOUBLE; minreg_opt->required = NO; minreg_opt->description = _("Minimum region size (diagonal) when labels are displayed"); maxreg_opt = G_define_option(); maxreg_opt->key = "maxreg"; maxreg_opt->type = TYPE_DOUBLE; maxreg_opt->required = NO; maxreg_opt->description = _("Maximum region size (diagonal) when labels are displayed"); /* Check command line */ if (G_parser(argc, argv)) exit(EXIT_FAILURE); /* Save map name */ label_name = opt1->answer; /* Make sure map is available */ mapset = G_find_file("paint/labels", label_name, ""); if (mapset == NULL) G_fatal_error(_("Label file <%s> not found"), label_name); /* Read in the map window associated with window */ G_get_window(&window); /* Check min/max region */ dx = window.east - window.west; dy = window.north - window.south; reg = sqrt(dx * dx + dy * dy); if (minreg_opt->answer) { minreg = atof(minreg_opt->answer); if (reg < minreg) { G_warning(_("Region size is lower than minreg, nothing displayed.")); D_close_driver(); exit(0); } } if (maxreg_opt->answer) { maxreg = atof(maxreg_opt->answer); if (reg > maxreg) { G_warning(_("Region size is greater than maxreg, nothing displayed.")); D_close_driver(); exit(0); } } /* Open map is available */ infile = G_fopen_old("paint/labels", label_name, mapset); if (infile == NULL) G_fatal_error(_("Unable to open label file <%s>"), label_name); if (D_open_driver() != 0) G_fatal_error(_("No graphics device selected. " "Use d.mon to select graphics device.")); D_setup(0); /* Go draw the raster map */ do_labels(infile, !horiz_flag->answer); D_save_command(G_recreate_command()); D_close_driver(); exit(EXIT_SUCCESS); }
/** * Copyright (c) 2011-2016 libbitcoin developers (see AUTHORS) * * This file is part of libbitcoin. * * libbitcoin is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License with * additional permissions to the one published by the Free Software * Foundation, either version 3 of the License, or (at your option) * any later version. For more information see LICENSE. * * 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 Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef LIBBITCOIN_C_WALLET_ENCRYPTED_KEYS_H #define LIBBITCOIN_C_WALLET_ENCRYPTED_KEYS_H #include <stdbool.h> #include <stddef.h> #include <stdint.h> #include <bitcoin/bitcoin/c/math/elliptic_curve.h> #include <bitcoin/bitcoin/c/utility/data.h> #ifdef __cplusplus extern "C" { #endif /** * The maximum lot and sequence values for encrypted key token creation. */ uint32_t bc_ek_max_lot(); uint32_t bc_ek_max_sequence(); /** * A seed for use in creating an intermediate passphrase (token). */ BC_DECLARE_BYTE_ARRAY(ek_salt); /** * A seed for use in creating an intermediate passphrase (token). */ BC_DECLARE_BYTE_ARRAY(ek_entropy); /** * A seed for use in creating a key pair. */ BC_DECLARE_BYTE_ARRAY(ek_seed); /** * An intermediate passphrase (token) type (checked but not base58 encoded). */ size_t bc_encrypted_token_encoded_size(); size_t bc_encrypted_token_decoded_size(); BC_DECLARE_BYTE_ARRAY(encrypted_token); /** * An encrypted private key type (checked but not base58 encoded). */ size_t bc_ek_private_encoded_size(); size_t bc_ek_private_decoded_size(); BC_DECLARE_BYTE_ARRAY(encrypted_private); /** * DEPRECATED * An encrypted public key type (checked but not base58 encoded). * This is refered to as a confirmation code in bip38. */ size_t bc_encrypted_public_encoded_size(); size_t bc_encrypted_public_decoded_size(); BC_DECLARE_BYTE_ARRAY(encrypted_public); // BIP38 // It is requested that the unused flag bytes NOT be used for denoting that // the key belongs to an alt-chain [This shoud read "flag bits"]. typedef enum bc_ek_flag_t { bc_ek_flag__lot_sequence_key = 1 << 2, bc_ek_flag__ec_compressed_key = 1 << 5, bc_ek_flag__ec_non_multiplied_low = 1 << 6, bc_ek_flag__ec_non_multiplied_high = 1 << 7, /// Two bits are used to represent "not multiplied". bc_ek_flag__ec_non_multiplied = ( bc_ek_flag__ec_non_multiplied_low | bc_ek_flag__ec_non_multiplied_high) } bc_ek_flag_t; // TODO: these calls require ICU #if 0 /** * Create an intermediate passphrase for subsequent key pair generation. * @param[out] out_token The new intermediate passphrase. * @param[in] passphrase A passphrase for use in the encryption. * @param[in] entropy A random value for use in the encryption. * @return false if the token could not be created from the entropy. */ bool bc_create_token(bc_encrypted_token_t* out_token, const char* passphrase, const bc_ek_entropy_t* entropy); /** * Create an intermediate passphrase for subsequent key pair generation. * @param[out] out_token The new intermediate passphrase. * @param[in] passphrase A passphrase for use in the encryption. * @param[in] salt A random value for use in the encryption. * @param[in] lot A lot, max allowed value 1048575 (2^20-1). * @param[in] sequence A sequence, max allowed value 4095 (2^12-1). * @return false if the lot and/or sequence are out of range or the token * could not be created from the entropy. */ bool bc_create_token_Salt(bc_encrypted_token_t* out_token, const char* passphrase, const bc_ek_salt_t* salt, uint32_t lot, uint32_t sequence); #endif /** * Create an encrypted private key from an intermediate passphrase. * The `out_point` paramter is always compressed, so to use it it should be * decompressed as necessary to match the state of the `compressed` parameter. * @param[out] out_private The new encrypted private key. * @param[out] out_point The ec compressed public key of the new key pair. * @param[in] token An intermediate passphrase string. * @param[in] seed A random value for use in the encryption. * @param[in] version The coin address version byte. * @param[in] compressed Set true to associate ec public key compression. * @return false if the token checksum is not valid. */ bool bc_create_key_pair(bc_encrypted_private_t* out_private, bc_ec_compressed_t* out_point, const bc_encrypted_token_t* token, const bc_ek_seed_t* seed, uint8_t version); bool bc_create_key_pair_nocompress(bc_encrypted_private_t* out_private, bc_ec_compressed_t* out_point, const bc_encrypted_token_t* token, const bc_ek_seed_t* seed, uint8_t version); #ifdef __cplusplus } #endif #endif
/*************************************************************************** ** ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Karoliina T. Salminen <karoliina.t.salminen@nokia.com> ** ** This file is part of duicontrolpanel. ** ** ** This library is free software; you can redistribute it and/or ** modify it under the terms of the GNU Lesser General Public ** License version 2.1 as published by the Free Software Foundation ** and appearing in the file LICENSE.LGPL included in the packaging ** of this file. ** ****************************************************************************/ #ifndef UT_DCPBRIEF_H #define UT_DCPBRIEF_H #include <QtTest/QtTest> #include <QObject> // the real unit/DcpBrief class declaration #include <dcpbrief.h> Q_DECLARE_METATYPE(DcpBrief*); class Ut_DcpBrief : public QObject { Q_OBJECT private slots: void init(); void cleanup(); void initTestCase(); void cleanupTestCase(); void testCreation(); void testWidgetTypeID(); void testValueText(); void testIcon(); void testToggleIconId(); void testAlign(); void testToggle(); void testImage(); void testActivate(); void testTitleText(); void testUseless(); private: DcpBrief* m_subject; }; #endif
/* Copyright (C) 2010 William Hart Copyright (C) 2014 Abhinav Baid Copyright (C) 2015 Elena Sergeicheva This file is part of FLINT. FLINT is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License (LGPL) as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>. */ #include <stdio.h> #include <stdlib.h> #include <gmp.h> #include "flint.h" #include "nmod_poly.h" #include "nmod_poly_mat.h" #include "ulong_extras.h" int main(void) { int i; FLINT_TEST_INIT(state); flint_printf("window_init/clear...."); fflush(stdout); for (i = 0; i < 1000 * flint_test_multiplier(); i++) { nmod_poly_mat_t a, w; mp_limb_t mod; slong j, k, r1, r2, c1, c2; slong rows = n_randint(state, 10); slong cols = n_randint(state, 10); mod = n_randtest_prime(state, 0); nmod_poly_mat_init(a, rows, cols, mod); nmod_poly_mat_randtest(a, state, n_randint(state, 10) + 1); r2 = n_randint(state, rows + 1); c2 = n_randint(state, cols + 1); if (r2) r1 = n_randint(state, r2); else r1 = 0; if (c2) c1 = n_randint(state, c2); else c1 = 0; nmod_poly_mat_window_init(w, a, r1, c1, r2, c2); for (j = 0; j < r2 - r1; j++) for (k = 0; k < c2 - c1; k++) nmod_poly_zero(nmod_poly_mat_entry(w, j, k)); nmod_poly_mat_window_clear(w); nmod_poly_mat_clear(a); } FLINT_TEST_CLEANUP(state); flint_printf("PASS\n"); return 0; }
/* Copyright (C) 2005 by Andrew Mann This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __CS_SNDSYS_FILTER_H__ #define __CS_SNDSYS_FILTER_H__ /**\file * Sound system: software filters */ #include "csutil/scf.h" #include "isndsys/ss_structs.h" /**\addtogroup sndsys * @{ */ class csSourceParameters3D; class csListenerProperties; struct iReporter; struct iSndSysSoftwareFilter3DProperties { csSoundSample *clean_buffer; csSoundSample *work_buffer; size_t buffer_samples; csSourceParameters3D *source_parameters; csListenerProperties *listener_parameters; csSndSysSoundFormat *sound_format; float closest_speaker_distance; float *speaker_distance; float *speaker_direction_cos; size_t channel; }; /** * A sound filter is an interface to an object that modifies sequences of * sound samples. */ struct iSndSysSoftwareFilter3D : public virtual iBase { /// SCF2006 - See http://www.crystalspace3d.org/cseps/csep-0010.html SCF_INTERFACE(iSndSysSoftwareFilter3D,0,1,0); /** * Apply this filter to the mutable buffer passed. The unmutable main * buffer is also passed, although this is not likely to be * very useful, since the main buffer has an unknown number of sources * previously mixed in (possibly none). * The sample_count is the number of samples available in both the mutable * buffer and the main buffer. * The format is the format of the audio. */ virtual void Apply(iSndSysSoftwareFilter3DProperties &properties) = 0; virtual bool AddSubFilter(iSndSysSoftwareFilter3D *filter, int chain_idx=0) = 0; virtual iSndSysSoftwareFilter3D *GetSubFilter(int chain_idx=0) = 0; /** * Retrieve the base pointer for this filter. Used internally by the * sound system. */ virtual iSndSysSoftwareFilter3D *GetPtr() = 0; }; /// Temporary filter interface definition. // // This will be used by the renderer after all mixing is complete. // This filter interface allows the renderer to hand off a copy of the // completed sound data to an application processing function as it // is delivered to the lower level. struct iSndSysSoftwareOutputFilter : public virtual iBase { /// SCF2006 - See http://www.crystalspace3d.org/cseps/csep-0010.html SCF_INTERFACE(iSndSysSoftwareOutputFilter,0,1,0); /// Return TRUE to acknowledge that the format is supported and the filter // should stay. Return FALSE if the filter should not be used. virtual bool FormatNotify(const csSndSysSoundFormat *pSoundFormat) = 0; /// Called to deliver data to the filter virtual void DeliverData(const csSoundSample *SampleBuffer, size_t Frames) = 0; }; /// Possible locations at which filters may be installed into the sound system typedef enum { // Render Output location - This is the final mix buffer before it goes to the driver SS_FILTER_LOC_RENDEROUT=0, // Source Output location - This is the final output from a source after all mutation filters SS_FILTER_LOC_SOURCEOUT, // Source Input location - This is the data the source receives from the stream before any mutation filters are applied SS_FILTER_LOC_SOURCEIN } SndSysFilterLocation; /** @} */ #endif // __CS_SNDSYS_FILTER_H__
#ifndef __TEST_NOISE_COMMON_H__ #define __TEST_NOISE_COMMON_H__ #include "my_time.h" #include "tests_common.h" extern int comm_rank; extern int comm_size; #define MODE_IDLE 0 #define MODE_GOAL_MESSAGES 1 #define MODE_NOISE_MESSAGES 2 #define MODE_FINISH_WORK 3 /* * Structure to keep most of test data together */ typedef struct tag_test_data { px_my_time_type **tmp_results; char **send_data; char **recv_data; char **send_data_noise; char **recv_data_noise; int *processors; } test_data; #ifndef __TEST_NOISE_COMMON_C__ #ifdef __cplusplus extern "C" { #endif extern void init_test_data( test_data* td ); extern void clear_test_data( test_data* td ); extern void clear_more_test_data( test_data* td, int i ); extern int alloc_test_data( test_data* td, int mes_length, int num_repeats, int loading, int num_processors ); extern void free_test_data( test_data* td ); extern int random_choice( int proc1, int proc2, int num_processors, int* processors ); /** * This function fill mode_array on one MPI-proccess. The formed array contains data with all MPI-processes modes (Idle,Noise,Goal). * This array should be brodcasted to all MPI-processes. */ extern int init_mode_array(int proc1,int proc2,int num_noise_procs,int num_all_procs,int *mode_array); #ifdef __cplusplus } #endif #endif /* __TEST_NOISE_COMMON_C__ */ #endif /* __TEST_NOISE_COMMON_H__ */
/* * Copyright (C) 2010 Nokia Corporation. * * Contact: Maemo MMF Audio <mmf-audio@projects.maemo.org> * or Jyri Sarha <jyri.sarha@nokia.com> * * These PulseAudio Modules are 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 * version 2.1 of the License. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA. */ #ifndef _parameters_h_ #define _parameters_h_ int initme(struct userdata *u, const char *initial_mode); int switch_mode(struct userdata *u, const char *mode); int update_mode(struct userdata *u, const char *mode); void unloadme(struct userdata *u); int algorithm_reload(struct userdata *u, const char *alg); #endif
// // libavg - Media Playback Engine. // Copyright (C) 2003-2011 Ulrich von Zadow // // 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 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 // // Current versions can be found at www.libavg.de // #ifndef _ContinuousAnim_H_ #define _ContinuousAnim_H_ #include "../api.h" #include "SimpleAnim.h" namespace avg { class AVG_API ContinuousAnim: public AttrAnim { public: ContinuousAnim(const boost::python::object& node, const std::string& sAttrName, const boost::python::object& startValue, const boost::python::object& speed, bool bUseInt=false, const boost::python::object& startCallback=boost::python::object(), const boost::python::object& stopCallback=boost::python::object()); virtual ~ContinuousAnim(); virtual void start(bool bKeepAttr=false); virtual void abort(); virtual bool step(); private: boost::python::object m_StartValue; boost::python::object m_Speed; bool m_bUseInt; boost::python::object m_EffStartValue; long long m_StartTime; }; } #endif
#ifndef RPCRUNTIMEDECODEDPARAM_H #define RPCRUNTIMEDECODEDPARAM_H #include <cinttypes> #include <istream> #include <ostream> #include <utility> #include <vector> class RPCRuntimeParameterDescription; /* * A RPCRuntimeDecodedParam represents a script-understandable parameter in an RPC-Function call */ struct Decoded_struct; struct Decoded_enum; class RPCRuntimeDecodedParam { public: RPCRuntimeDecodedParam(const RPCRuntimeParameterDescription &parameter_description, std::string field_id); uint64_t as_unsigned_integer() const; int64_t as_signed_integer() const; int64_t as_integer() const; //works for all integers except uint64_t Decoded_enum as_enum() const; //since we come from C we only need to support enums that have int as their underlying type std::vector<Decoded_struct> as_struct() const; std::vector<RPCRuntimeDecodedParam> as_array() const; std::string as_full_string() const; std::string as_string() const; std::string get_field_id() const; const RPCRuntimeParameterDescription *get_desciption() const; void set_data(std::vector<unsigned char> data); void set_data(const unsigned char *begin, int size); private: const RPCRuntimeParameterDescription *parameter_description; std::vector<unsigned char> data; std::string field_id; }; struct Decoded_struct{ std::string name; RPCRuntimeDecodedParam type; }; struct Decoded_enum{ std::string name; //may be empty int value; }; std::istream &operator>>(std::istream &is, RPCRuntimeDecodedParam &param); #endif //RPCRUNTIMEDECODEDPARAM_H
/* Copyright (C) 2013 Mike Hansen This file is part of FLINT. FLINT is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License (LGPL) as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>. */ #include "fq_zech_poly.h" #ifdef T #undef T #endif #define T fq_zech #define CAP_T FQ_ZECH #include "fq_poly_templates/test/t-scalar_submul_fq.c" #undef CAP_T #undef T
/* * Copyright (C) 2015 Lari Lehtomäki * * This file is subject to the terms and conditions of the GNU Lesser * General Public License v2.1. See the file LICENSE in the top level * directory for more details. */ /** * @ingroup boards_nucleo-f401 * @{ * * @file * @name Peripheral MCU configuration for the nucleo-f401 board * * @author Lari Lehtomäki <lari@lehtomaki.fi> */ #ifndef PERIPH_CONF_H_ #define PERIPH_CONF_H_ #include "periph_cpu.h" #ifdef __cplusplus extern "C" { #endif /** * @name Clock system configuration * @{ */ #define CLOCK_HSE (8000000U) /* external oscillator */ #define CLOCK_CORECLOCK (84000000U) /* desired core clock frequency */ /* the actual PLL values are automatically generated */ #define CLOCK_PLL_M (CLOCK_HSE / 1000000) #define CLOCK_PLL_N ((CLOCK_CORECLOCK / 1000000) * 2) #define CLOCK_PLL_P (2U) #define CLOCK_PLL_Q (CLOCK_PLL_N / 48) #define CLOCK_AHB_DIV RCC_CFGR_HPRE_DIV1 #define CLOCK_APB1_DIV RCC_CFGR_PPRE1_DIV2 #define CLOCK_APB2_DIV RCC_CFGR_PPRE2_DIV1 #define CLOCK_FLASH_LATENCY FLASH_ACR_LATENCY_5WS /* bus clocks for simplified peripheral initialization, UPDATE MANUALLY! */ #define CLOCK_AHB (CLOCK_CORECLOCK / 1) #define CLOCK_APB1 (CLOCK_CORECLOCK / 2) #define CLOCK_APB2 (CLOCK_CORECLOCK / 1) /** @} */ /** * @brief Timer configuration * @{ */ static const timer_conf_t timer_config[] = { { .dev = TIM2, .max = 0xffffffff, .rcc_mask = RCC_APB1ENR_TIM2EN, .bus = APB1, .irqn = TIM2_IRQn }, { .dev = TIM5, .max = 0xffffffff, .rcc_mask = RCC_APB1ENR_TIM5EN, .bus = APB1, .irqn = TIM5_IRQn } }; #define TIMER_0_ISR isr_tim2 #define TIMER_1_ISR isr_tim5 #define TIMER_NUMOF (sizeof(timer_config) / sizeof(timer_config[0])) /** @} */ /** * @brief UART configuration * @{ */ static const uart_conf_t uart_config[] = { { .dev = USART2, .rcc_mask = RCC_APB1ENR_USART2EN, .rx_pin = GPIO_PIN(PORT_A, 3), .tx_pin = GPIO_PIN(PORT_A, 2), .rx_af = GPIO_AF7, .tx_af = GPIO_AF7, .bus = APB1, .irqn = USART2_IRQn, #ifdef UART_USE_DMA .dma_stream = 6, .dma_chan = 4 #endif }, { .dev = USART6, .rcc_mask = RCC_APB2ENR_USART6EN, .rx_pin = GPIO_PIN(PORT_A, 12), .tx_pin = GPIO_PIN(PORT_A, 11), .rx_af = GPIO_AF8, .tx_af = GPIO_AF8, .bus = APB2, .irqn = USART6_IRQn, #ifdef UART_USE_DMA .dma_stream = 6, .dma_chan = 4 #endif } }; #define UART_0_ISR (isr_usart2) #define UART_0_DMA_ISR (isr_dma1_stream6) #define UART_1_ISR (isr_usart6) #define UART_1_DMA_ISR (isr_dma1_stream6) #define UART_NUMOF (sizeof(uart_config) / sizeof(uart_config[0])) /** @} */ /** * @name SPI configuration * @{ */ #define SPI_NUMOF (1U) #define SPI_0_EN 1 #define SPI_IRQ_PRIO 1 /* SPI 0 device config */ #define SPI_0_DEV SPI1 #define SPI_0_CLKEN() (periph_clk_en(APB2, RCC_APB2ENR_SPI1EN)) #define SPI_0_CLKDIS() (periph_clk_dis(APB2, RCC_APB2ENR_SPI1EN)) #define SPI_0_BUS_DIV 1 /* 1 -> SPI bus runs with half CPU clock, 0 -> quarter CPU clock */ #define SPI_0_IRQ SPI1_IRQn #define SPI_0_IRQ_HANDLER isr_spi1 /* SPI 0 pin configuration */ #define SPI_0_SCK_PORT GPIOA /* A5 pin is shared with the green LED. */ #define SPI_0_SCK_PIN 5 #define SPI_0_SCK_AF 5 #define SPI_0_SCK_PORT_CLKEN() (periph_clk_en(AHB1, RCC_AHB1ENR_GPIOAEN)) #define SPI_0_MISO_PORT GPIOA #define SPI_0_MISO_PIN 6 #define SPI_0_MISO_AF 5 #define SPI_0_MISO_PORT_CLKEN() (periph_clk_en(AHB1, RCC_AHB1ENR_GPIOAEN)) #define SPI_0_MOSI_PORT GPIOA #define SPI_0_MOSI_PIN 7 #define SPI_0_MOSI_AF 5 #define SPI_0_MOSI_PORT_CLKEN() (periph_clk_en(AHB1, RCC_AHB1ENR_GPIOAEN)) /** @} */ /** * @name I2C configuration * @{ */ #define I2C_NUMOF (1U) #define I2C_0_EN 1 #define I2C_IRQ_PRIO 1 #define I2C_APBCLK (42000000U) /* I2C 0 device configuration */ #define I2C_0_DEV I2C1 #define I2C_0_CLKEN() (periph_clk_en(APB1, RCC_APB1ENR_I2C1EN)) #define I2C_0_CLKDIS() (periph_clk_dis(APB1, RCC_APB1ENR_I2C1EN)) #define I2C_0_EVT_IRQ I2C1_EV_IRQn #define I2C_0_EVT_ISR isr_i2c1_ev #define I2C_0_ERR_IRQ I2C1_ER_IRQn #define I2C_0_ERR_ISR isr_i2c1_er /* I2C 0 pin configuration */ #define I2C_0_SCL_PORT GPIOB #define I2C_0_SCL_PIN 8 #define I2C_0_SCL_AF 4 #define I2C_0_SCL_CLKEN() (periph_clk_en(AHB1, RCC_AHB1ENR_GPIOBEN)) #define I2C_0_SDA_PORT GPIOB #define I2C_0_SDA_PIN 9 #define I2C_0_SDA_AF 4 #define I2C_0_SDA_CLKEN() (periph_clk_en(AHB1, RCC_AHB1ENR_GPIOBEN)) /** @} */ /** * @brief ADC configuration * @{ */ #define ADC_NUMOF (0) /** @} */ /** * @brief DAC configuration * @{ */ #define DAC_NUMOF (0) /** @} */ #ifdef __cplusplus } #endif #endif /* PERIPH_CONF_H_ */ /** @} */
/* * Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). * Contact: http://www.qt-project.org/legal * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" * which accompanies this distribution, and is available * at the URL "http://www.eclipse.org/legal/epl-v10.html". * * Initial Contributors: * Nokia Corporation - initial contribution. * * Contributors: * * Description: * */ #ifndef ECntOpenDataBase1_H_ #define ECntOpenDataBase1_H_ //Include the suite header #include "csuite.h" #include "ccntserver.h" #include "ccntipccodes.h" class CECntOpenDataBase1Step: public CCapabilityTestStep { public: //Get the version of the server to be called TVersion Version() { return TVersion(KLockSrvMajorVersionNumber, KLockSrvMinorVersionNumber, KLockSrvBuildVersionNumber); } //Constructor called from the respective Suite.cpp from their "AddTestStep" function CECntOpenDataBase1Step() ; //Always clean your mess ~CECntOpenDataBase1Step() { tChildThread.Close(); } //This is the Function called from "doTestStepL" by the test Suite,and it creates an //child thread which internally calls the corresponding Exec_SendReceive_SERVERNAME fn. TVerdict MainThread(); //Here's where the connection and testing the message takes place TInt Exec_SendReceive(); }; #endif
/* * Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). * Contact: http://www.qt-project.org/legal * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" * which accompanies this distribution, and is available * at the URL "http://www.eclipse.org/legal/epl-v10.html". * * Initial Contributors: * Nokia Corporation - initial contribution. * * Contributors: * * Description: * */ #ifndef __T_STATE_TEST_H__ #define __T_STATE_TEST_H__ #include "nbcnttestlib.h" #include <cntitem.h> #include <cntdbobs.h> class COpenCommitTest : CBase { public: static COpenCommitTest* NewLC(); ~COpenCommitTest(); void RunOpenCommitTestL(); void RunGroupTestL(); private: COpenCommitTest(); void ConstructL(); const CContactTemplate& GetSysTemplateL(); private: CContactDatabase* iCntDb; CCntItemBuilder* iCntItemBldr; CContactTemplate* iGoldenTemplate; RTest* iTest; }; #endif // __T_STATE_TEST_H__
/**************************************************************************** ** ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the plugins of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** Commercial Usage ** Licensees holding valid Qt Commercial licenses may use this file in ** accordance with the Qt Commercial License Agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and Nokia. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Nokia gives you certain additional ** rights. These rights are described in the Nokia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 3.0 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU General Public License version 3.0 requirements will be ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you have questions regarding the use of this file, please contact ** Nokia at qt-info@nokia.com. ** $QT_END_LICENSE$ ** ****************************************************************************/ #ifndef QSVGIOHANDLER_H #define QSVGIOHANDLER_H #include <QtGui/qimageiohandler.h> #ifndef QT_NO_SVGRENDERER QT_BEGIN_NAMESPACE class QImage; class QByteArray; class QIODevice; class QVariant; class QSvgIOHandlerPrivate; class QSvgIOHandler : public QImageIOHandler { public: QSvgIOHandler(); ~QSvgIOHandler(); virtual bool canRead() const; virtual QByteArray name() const; virtual bool read(QImage *image); static bool canRead(QIODevice *device); virtual QVariant option(ImageOption option) const; virtual void setOption(ImageOption option, const QVariant & value); virtual bool supportsOption(ImageOption option) const; private: QSvgIOHandlerPrivate *d; }; QT_END_NAMESPACE #endif // QT_NO_SVGRENDERER #endif // QSVGIOHANDLER_H
/* Copyright (C) 2011 William Hart Copyright (C) 2011 Sebastian Pancratz This file is part of FLINT. FLINT is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License (LGPL) as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>. */ #include <stdio.h> #include <stdlib.h> #include <gmp.h> #include "flint.h" #include "nmod_poly.h" #include "ulong_extras.h" int main(void) { int i, result; FLINT_TEST_INIT(state); flint_printf("gcd_hgcd...."); fflush(stdout); /* Find coprime polys, multiply by another poly and check the GCD is that poly */ for (i = 0; i < 100 * flint_test_multiplier(); i++) { nmod_poly_t a, b, c, g; mp_limb_t n; do n = n_randtest_not_zero(state); while (!n_is_probabprime(n)); nmod_poly_init(a, n); nmod_poly_init(b, n); nmod_poly_init(c, n); nmod_poly_init(g, n); do { nmod_poly_randtest(a, state, n_randint(state, 1000)); nmod_poly_randtest(b, state, n_randint(state, 1000)); nmod_poly_gcd_hgcd(g, a, b); } while (g->length != 1); do { nmod_poly_randtest(c, state, n_randint(state, 1000)); } while (c->length < 2); nmod_poly_make_monic(c, c); nmod_poly_mul(a, a, c); nmod_poly_mul(b, b, c); nmod_poly_gcd_hgcd(g, a, b); result = (nmod_poly_equal(g, c)); if (!result) { flint_printf("FAIL:\n"); nmod_poly_print(a), flint_printf("\n\n"); nmod_poly_print(b), flint_printf("\n\n"); nmod_poly_print(c), flint_printf("\n\n"); nmod_poly_print(g), flint_printf("\n\n"); flint_printf("n = %wd\n", n); fflush(stdout); flint_abort(); } nmod_poly_clear(a); nmod_poly_clear(b); nmod_poly_clear(c); nmod_poly_clear(g); } /* Check aliasing of a and g */ for (i = 0; i < 100 * flint_test_multiplier(); i++) { nmod_poly_t a, b, g; mp_limb_t n; do n = n_randtest(state); while (!n_is_probabprime(n)); nmod_poly_init(a, n); nmod_poly_init(b, n); nmod_poly_init(g, n); nmod_poly_randtest(a, state, n_randint(state, 1000)); nmod_poly_randtest(b, state, n_randint(state, 1000)); nmod_poly_gcd_hgcd(g, a, b); nmod_poly_gcd_hgcd(a, a, b); result = (nmod_poly_equal(a, g)); if (!result) { flint_printf("FAIL:\n"); nmod_poly_print(a), flint_printf("\n\n"); nmod_poly_print(b), flint_printf("\n\n"); nmod_poly_print(g), flint_printf("\n\n"); flint_printf("n = %wd\n", n); fflush(stdout); flint_abort(); } nmod_poly_clear(a); nmod_poly_clear(b); nmod_poly_clear(g); } /* Check aliasing of b and g */ for (i = 0; i < 100 * flint_test_multiplier(); i++) { nmod_poly_t a, b, g; mp_limb_t n; do n = n_randtest(state); while (!n_is_probabprime(n)); nmod_poly_init(a, n); nmod_poly_init(b, n); nmod_poly_init(g, n); nmod_poly_randtest(a, state, n_randint(state, 1000)); nmod_poly_randtest(b, state, n_randint(state, 1000)); nmod_poly_gcd_hgcd(g, a, b); nmod_poly_gcd_hgcd(b, a, b); result = (nmod_poly_equal(b, g)); if (!result) { flint_printf("FAIL:\n"); nmod_poly_print(a), flint_printf("\n\n"); nmod_poly_print(b), flint_printf("\n\n"); nmod_poly_print(g), flint_printf("\n\n"); flint_printf("n = %wd\n", n); fflush(stdout); flint_abort(); } nmod_poly_clear(a); nmod_poly_clear(b); nmod_poly_clear(g); } FLINT_TEST_CLEANUP(state); flint_printf("PASS\n"); return 0; }
#ifndef __FX_TEXTTERMREADERTESTCASE_H #define __FX_TEXTTERMREADERTESTCASE_H #include "firtex/common/StdHeader.h" #include "firtex/common/Logger.h" #include "firtex/common/SharedPtr.h" #include "cppunit/extensions/HelperMacros.h" #include "firtex/index/text/TextIndexer.h" #include "firtex/index/text/TextTermReader.h" #include "firtex/utility/HashMap.h" FX_NS_DEF(index); class TextTermReaderTestCase : public CPPUNIT_NS::TestFixture { CPPUNIT_TEST_SUITE(TextTermReaderTestCase); CPPUNIT_TEST(testNumTerms); CPPUNIT_TEST(testTermPosIterator); CPPUNIT_TEST(testTermIterator); CPPUNIT_TEST(testInMemTermIterator); CPPUNIT_TEST(testTermRangeIterator); CPPUNIT_TEST(testInMemTermRangeIterator); CPPUNIT_TEST(testSeek); CPPUNIT_TEST(testInMemSeek); CPPUNIT_TEST_SUITE_END(); public: TextTermReaderTestCase(); ~TextTermReaderTestCase(); void setUp(); void tearDown(); protected: void testNumTerms(); void testTermPosIterator(); void testTermIterator(); void testInMemTermIterator(); void testTermRangeIterator(); void testInMemTermRangeIterator(); void testSeek(); void testInMemSeek(); private: typedef std::map<uint64_t, TermMetaPtr> TermMap; typedef std::map<uint64_t, std::string> TermHashMap; void makeData(); void checkIterator(TermIteratorPtr& pTermIt, const TermMap& answer); std::string getTestPath(); private: TextIndexerPtr m_pIndexer; TextTermReaderPtr m_pTermReader; FX_NS(document)::FieldSchemaPtr m_pFieldSchema; PostingPoolPtr m_pPool; TermMap m_answer; TermHashMap m_termHashMap; std::string m_sBarrel; FX_NS(store)::FileSystemPtr m_pFileSystem; FX_NS(store)::InputStreamPoolPtr m_pStreamPool; size_t m_nDataSize; private: DECLARE_STREAM_LOGGER(); }; FX_NS_END #endif //__FX_TEXTTERMREADERTESTCASE_H
/* Copyright (C) 2010 Casey Link <unnamedrambler@gmail.com> 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 3 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 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 MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> #include <QHash> #include <QUrl> #include <QThread> namespace Ui { class MainWindow; } class PixelDelegate; class ImageModel; class ViewMonitor; class QTableView; class OutputModel; class RunController; class CommandWidget; class DebugWidget; class UndoHandler; class QUndoStack; class QLabel; class MainWindow : public QMainWindow { Q_OBJECT public: explicit MainWindow( QWidget *parent = 0 ); ~MainWindow(); virtual bool eventFilter( QObject* , QEvent* ); protected: void closeEvent(QCloseEvent *event); signals: void validImageDocument( bool ); void executeSource( const QImage & ); void debugSource( const QImage & ); void debugStep(); void debugStop(); void debugStarted( bool ); void setStopEnabled( bool ); private slots: void slotActionExit(); void slotActionSaveAs(); void slotActionSave(); void slotActionOpen(); void slotActionToggleGrid(); void slotActionToggleHeaders(); void slotActionNew(); void slotActionResize(); void slotActionInsert(); void slotActionZoom(); void slotActionDebug(); void slotActionRun(); void slotUpdateView( int pixelSize ); void slotImageEdited(); void slotToggleOutput(); void slotClearOutputView(); void slotStartDebug(); void slotControllerStopped(); void slotControllerStarted(); void slotGetChar(); void slotGetInt(); void slotReturnPressed(); void slotStopController(); void slotNewOutput( QString ); private: void setupToolbar(); void setModified( bool flag ); bool promptSave(bool close=false); Ui::MainWindow *ui; QString mSaveMessage; QHash<QString, QString> mExtensions; QUndoStack* mUndoStack; UndoHandler* mUndoHandler; ImageModel* mModel; PixelDelegate* mDelegate; ViewMonitor* mMonitor; OutputModel* mOutputModel; RunController* mRunController; CommandWidget* mCommandWidget; DebugWidget* mDebugWidget; QLabel* mStatusLabel; QThread mRunThread; QUrl mCurrentFile; bool mModified; bool mWaitInt; bool mWaitChar; bool mWaitingForCoordSelection; QImage mInsertImage; }; #endif // MAINWINDOW_H
// // Copyright (C) 2003-2014 eXo Platform SAS. // // This is free software; you can redistribute it and/or modify it // under the terms of the GNU Lesser General Public License as // published by the Free Software Foundation; either version 3 of // the License, or (at your option) any later version. // // This software is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this software; if not, write to the Free // Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA // 02110-1301 USA, or see the FSF site: http://www.fsf.org. // #import <UIKit/UIKit.h> #import "SocialProxy.h" #import "EGORefreshTableHeaderView.h" #import "MessageComposerViewController.h" #import "eXoViewController.h" @class ActivityDetailMessageTableViewCell; @class SocialActivity; @class SocialUserProfile; #define kFontForName [UIFont fontWithName:@"Helvetica-Bold" size:13] #define kFontForMessage [UIFont fontWithName:@"Helvetica" size:13] @interface ActivityDetailViewController : eXoViewController <UITableViewDelegate, UITableViewDataSource, UITextViewDelegate, SocialProxyDelegate, EGORefreshTableHeaderDelegate, SocialMessageComposerDelegate, UIAlertViewDelegate, UIWebViewDelegate>{ IBOutlet UITableView* _tblvActivityDetail; // IBOutlet UINavigationBar* _navigationBar; BOOL _currentUserLikeThisActivity; UITextView* _txtvMsgComposer; IBOutlet UIButton* _btnMsgComposer; //Refresh Management EGORefreshTableHeaderView* _refreshHeaderView; BOOL _reloading; NSDate* _dateOfLastUpdate; int _activityAction;//0: getting, 1: updating, 2: like, 3: dislike CGRect originRect; BOOL zoomOutOrZoomIn; //UITapGestureRecognizer *tapGesture; UIView *maskView; NSString *_iconType; // icon for type of activity detail BOOL isPostComment; } @property (retain) NSString *iconType; @property (nonatomic, retain) SocialActivity *socialActivity; @property (nonatomic, retain) ActivityDetailMessageTableViewCell *activityDetailCell; @property (nonatomic, retain) UITableView *tblvActivityDetail; @property (nonatomic, retain) EGORefreshTableHeaderView *refreshHeaderView; - (void)setSocialActivityStream:(SocialActivity *)socialActivityStream andCurrentUserProfile:(SocialUserProfile*)currentUserProfile; - (void)likeDislikeActivity:(NSString *)activity; - (void)finishLoadingAllComments; - (void)finishLoadingAllLikers; /* Methods for managing the like/unlike actions The derived classs can override these method for particular behavior */ - (void)didFinishedLikeAction; - (void)didFailedLikeAction; @end
/**************************************************************************** ** ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the documentation of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: ** ** "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 Nokia Corporation and its Subsidiary(-ies) 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." ** $QT_END_LICENSE$ ** ****************************************************************************/ #ifndef IMAGEDIALOG_H #define IMAGEDIALOG_H #include "ui_imagedialog.h" //! [0] class ImageDialog : public QDialog, private Ui::ImageDialog { Q_OBJECT public: ImageDialog(QWidget *parent = 0); private slots: void on_okButton_clicked(); }; //! [0] #endif
// // Generated by the J2ObjC translator. DO NOT EDIT! // source: android/libcore/xml/src/main/java/org/xmlpull/v1/XmlSerializer.java // #ifndef _OrgXmlpullV1XmlSerializer_H_ #define _OrgXmlpullV1XmlSerializer_H_ @class IOSCharArray; @class JavaIoOutputStream; @class JavaIoWriter; @class JavaLangBoolean; #include "J2ObjC_header.h" @protocol OrgXmlpullV1XmlSerializer < NSObject, JavaObject > - (void)setFeatureWithNSString:(NSString *)name withBoolean:(jboolean)state; - (jboolean)getFeatureWithNSString:(NSString *)name; - (void)setPropertyWithNSString:(NSString *)name withId:(id)value; - (id)getPropertyWithNSString:(NSString *)name; - (void)setOutputWithJavaIoOutputStream:(JavaIoOutputStream *)os withNSString:(NSString *)encoding; - (void)setOutputWithJavaIoWriter:(JavaIoWriter *)writer; - (void)startDocumentWithNSString:(NSString *)encoding withJavaLangBoolean:(JavaLangBoolean *)standalone; - (void)endDocument; - (void)setPrefixWithNSString:(NSString *)prefix withNSString:(NSString *)namespace_; - (NSString *)getPrefixWithNSString:(NSString *)namespace_ withBoolean:(jboolean)generatePrefix; - (jint)getDepth; - (NSString *)getNamespace; - (NSString *)getName; - (id<OrgXmlpullV1XmlSerializer>)startTagWithNSString:(NSString *)namespace_ withNSString:(NSString *)name; - (id<OrgXmlpullV1XmlSerializer>)attributeWithNSString:(NSString *)namespace_ withNSString:(NSString *)name withNSString:(NSString *)value; - (id<OrgXmlpullV1XmlSerializer>)endTagWithNSString:(NSString *)namespace_ withNSString:(NSString *)name; - (id<OrgXmlpullV1XmlSerializer>)textWithNSString:(NSString *)text; - (id<OrgXmlpullV1XmlSerializer>)textWithCharArray:(IOSCharArray *)buf withInt:(jint)start withInt:(jint)len; - (void)cdsectWithNSString:(NSString *)text; - (void)entityRefWithNSString:(NSString *)text; - (void)processingInstructionWithNSString:(NSString *)text; - (void)commentWithNSString:(NSString *)text; - (void)docdeclWithNSString:(NSString *)text; - (void)ignorableWhitespaceWithNSString:(NSString *)text; - (void)flush; @end J2OBJC_EMPTY_STATIC_INIT(OrgXmlpullV1XmlSerializer) J2OBJC_TYPE_LITERAL_HEADER(OrgXmlpullV1XmlSerializer) #endif // _OrgXmlpullV1XmlSerializer_H_
/*============================================================================= * * @file : transfer.h * @author : JackABK * @data : 2014/2/2 * @brief : shell.c header file * *============================================================================*/ #ifndef __TRANSFER_H__ #define __TRANSFER_H__ #include "EPW_command.h" #include "stm32f4xx.h" extern void receive_task(void *p); extern void send_data_task(void * p); extern void neural_task(void *p); /*determine yes or no reatch the MAX_STRLEN */ extern uint8_t Receive_String_Ready; /*arrange the receive of command to structure */ #pragma pack(1) static struct receive_cmd_list{ unsigned char Identifier[3]; unsigned char group; unsigned char control_id; unsigned char value; }; #pragma pack() /*list of the EPW information structure*/ typedef struct{ char * name; EPW_Info_id id; unsigned char *value; }EPW_info; /* USART receive command and pwm value*/ /*should be to define to main.h or uart.h*/ enum { RECEIVE_CMD, RECEIVE_PWM_VALUE }; #endif /* __SHELL_H__ */
#ifndef LCD_FCN_H_ #define LCD_FCN_H_ Int16 OSD9616_send( Uint16 comdat, Uint16 data ); Int16 OSD9616_multiSend( Uint8* data, Uint16 len ); void LCD_init(void); void LCD_Display(Int16 * array, Int16 power); #endif /*LCD_FCN_H_*/
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #ifndef nsDeviceSensors_h #define nsDeviceSensors_h #include "nsIDeviceSensors.h" #include "nsIDOMDeviceMotionEvent.h" #include "nsCOMArray.h" #include "nsTArray.h" #include "nsCOMPtr.h" #include "nsITimer.h" #include "nsIDOMDeviceLightEvent.h" #include "nsIDOMDeviceOrientationEvent.h" #include "nsIDOMDeviceProximityEvent.h" #include "nsIDOMUserProximityEvent.h" #include "nsIDOMDeviceMotionEvent.h" #include "nsDOMDeviceMotionEvent.h" #include "mozilla/TimeStamp.h" #include "mozilla/HalSensor.h" #include "nsDataHashtable.h" #define NS_DEVICE_SENSORS_CID \ { 0xecba5203, 0x77da, 0x465a, \ { 0x86, 0x5e, 0x78, 0xb7, 0xaf, 0x10, 0xd8, 0xf7 } } #define NS_DEVICE_SENSORS_CONTRACTID "@mozilla.org/devicesensors;1" class nsIDOMWindow; class nsDeviceSensors : public nsIDeviceSensors, public mozilla::hal::ISensorObserver { public: NS_DECL_ISUPPORTS NS_DECL_NSIDEVICESENSORS nsDeviceSensors(); virtual ~nsDeviceSensors(); void Notify(const mozilla::hal::SensorData& aSensorData); private: // sensor -> window listener nsTArray<nsTArray<nsIDOMWindow*>* > mWindowListeners; void FireDOMLightEvent(nsIDOMEventTarget *target, double value); void FireDOMProximityEvent(nsIDOMEventTarget *aTarget, double aValue, double aMin, double aMax); void FireDOMUserProximityEvent(nsIDOMEventTarget *aTarget, bool aNear); void FireDOMOrientationEvent(class nsIDOMDocument *domDoc, class nsIDOMEventTarget *target, double alpha, double beta, double gamma); void FireDOMMotionEvent(class nsIDOMDocument *domDoc, class nsIDOMEventTarget *target, uint32_t type, double x, double y, double z); bool mEnabled; inline bool IsSensorEnabled(uint32_t aType) { return mWindowListeners[aType]->Length() > 0; } mozilla::TimeStamp mLastDOMMotionEventTime; bool mIsUserProximityNear; nsRefPtr<nsDOMDeviceAcceleration> mLastAcceleration; nsRefPtr<nsDOMDeviceAcceleration> mLastAccelerationIncluduingGravity; nsRefPtr<nsDOMDeviceRotationRate> mLastRotationRate; }; #endif
/* Copyright 2016 Richard Bernardino 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. */ #pragma once #include "BuildCommand.h" #include "..\Model\Rock.h" #include "..\Utils.h" #include "..\Model\World.h" class AddRockCommand : public BuildCommand { public: void Process( World ** pWorld, float2 fScreenDimensions, ServiceProxy::BuildCommand ^ command, Subdivision ** pSubdivision, const shared_ptr<DeviceResources>& deviceResources) { float x; float y; Utils::CalculateSquareCenter( fScreenDimensions.x, fScreenDimensions.y, ((ServiceProxy::AddRockCommand ^)command)->X, ((ServiceProxy::AddRockCommand ^)command)->Y, &x, &y); (*pSubdivision)->Set(LAYER_COLLIDABLES, new Rock( float2(x, y), 0.f, float2 { Utils::CalculateSquareWidthRatio(fScreenDimensions.x), Utils::CalculateSquareHeightRatio(fScreenDimensions.y) }, true, command, deviceResources)); } protected: private: };
#include "arch.h" #include "fp_SECP256K1.h" /* Curve SECP256K1 */ #if CHUNK==16 #error Not supported #endif #if CHUNK==32 // Base Bits= 28 const BIG_256_28 Modulus_SECP256K1= {0xFFFFC2F,0xFFFFFEF,0xFFFFFFF,0xFFFFFFF,0xFFFFFFF,0xFFFFFFF,0xFFFFFFF,0xFFFFFFF,0xFFFFFFF,0xF}; const BIG_256_28 R2modp_SECP256K1= {0x0,0xA100000,0x2000E90,0x7A,0x1,0x0,0x0,0x0,0x0,0x0}; const chunk MConst_SECP256K1= 0x2253531; #endif #if CHUNK==64 // Base Bits= 56 const BIG_256_56 Modulus_SECP256K1= {0xFFFFFEFFFFFC2FL,0xFFFFFFFFFFFFFFL,0xFFFFFFFFFFFFFFL,0xFFFFFFFFFFFFFFL,0xFFFFFFFFL}; const BIG_256_56 R2modp_SECP256K1= {0xA1000000000000L,0x7A2000E90L,0x1L,0x0L,0x0L}; const chunk MConst_SECP256K1= 0x38091DD2253531L; #endif
/* * Copyright (c) 2021 Nordic Semiconductor ASA * * SPDX-License-Identifier: Apache-2.0 */ #define SW_SWITCH_RX 0 #define SW_SWITCH_TX 1 #define SW_SWITCH_PHY_1M 0 #define SW_SWITCH_FLAGS_DONTCARE 0 void sw_switch(uint8_t dir_curr, uint8_t dir_next, uint8_t phy_curr, uint8_t flags_curr, uint8_t phy_next, uint8_t flags_next, enum radio_end_evt_delay_state end_evt_delay);
/* * Copyright 2012 Google Inc. 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. */ #ifndef SRC_LB_SHELL_SWITCHES_H_ #define SRC_LB_SHELL_SWITCHES_H_ #include "lb_shell_export.h" namespace LB { namespace switches { LB_SHELL_EXTERN const char kUrl[]; LB_SHELL_EXTERN const char kQueryString[]; LB_SHELL_EXTERN const char kWebCoreLogChannels[]; LB_SHELL_EXTERN const char kDisableSave[]; LB_SHELL_EXTERN const char kLoadSavegame[]; LB_SHELL_EXTERN const char kUserAgent[]; LB_SHELL_EXTERN const char kLang[]; LB_SHELL_EXTERN const char kIgnorePlatformAuthentication[]; LB_SHELL_EXTERN const char kProxy[]; LB_SHELL_EXTERN const char kHideSplashScreenAtInit[]; #if defined(__LB_WIIU__) LB_SHELL_EXTERN const char kErrorTest[]; #endif #if defined(__LB_LINUX__) LB_SHELL_EXTERN const char kVersion[]; LB_SHELL_EXTERN const char kHelp[]; #endif #if defined(__LB_XB1__) || defined(__LB_XB360__) LB_SHELL_EXTERN const char kDrawGestureRecognizerBorder[]; #endif } // namespace switches } // namespace LB #endif // SRC_LB_SHELL_SWITCHES_H_
#define IOS_CAFFE_EXPORT __attribute__((visibility("default")))
#ifndef STREAM_FD_H #define STREAM_FD_H 1 #include <stdbool.h> #include <stddef.h> #include <stdint.h> struct stream; struct pstream; struct sockaddr; int new_fd_stream(const char *name, int fd, int connect_status, struct stream **streamp); int new_fd_pstream(const char *name, int fd, int (*accept_cb)(int fd, const struct sockaddr *, size_t sa_len, struct stream **), int (*set_dscp_cb)(int fd, uint8_t dscp), char *unlink_path, struct pstream **pstreamp); #endif /* stream-fd.h */
// // Copyright (C) 2012 Opensim Ltd. // Author: Tamas Borbely // Copyright (C) 2013 Thomas Dreibholz // // 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, see <http://www.gnu.org/licenses/>. // #ifndef __INET_REDDROPPER_H #define __INET_REDDROPPER_H #include "inet/common/INETDefs.h" #include "inet/common/queue/AlgorithmicDropperBase.h" namespace inet { /** * Implementation of Random Early Detection (RED). */ class INET_API REDDropper : public AlgorithmicDropperBase { protected: double wq = 0.0; double *minths = nullptr; double *maxths = nullptr; double *maxps = nullptr; double *pkrates = nullptr; double *count = nullptr; double avg = 0.0; simtime_t q_time; public: REDDropper() {} protected: virtual ~REDDropper(); virtual void initialize() override; virtual bool shouldDrop(cPacket *packet) override; virtual void sendOut(cPacket *packet) override; }; } // namespace inet #endif // ifndef __INET_REDDROPPER_H
/* petpvcRegionConvolutionPVCImageFilter.h Author: Benjamin A. Thomas Copyright 2015 Institute of Nuclear Medicine, University College London. Copyright 2015 Clinical Imaging Research Centre, A*STAR-NUS. 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 __PETPVCREGIONCONVOLUTIONIMAGEFILTER_H #define __PETPVCREGIONCONVOLUTIONIMAGEFILTER_H #include <itkImage.h> #include <itkImageToImageFilter.h> #include <itkMultiplyImageFilter.h> #include <itkDivideImageFilter.h> #include <itkDiscreteGaussianImageFilter.h> #include <itkImageDuplicator.h> #include <algorithm> using namespace itk; namespace petpvc { template< class TInputImage, typename TMaskImage> class RegionConvolutionPVCImageFilter:public ImageToImageFilter< TInputImage, TInputImage > { public: /** Standard class typedefs. */ typedef RegionConvolutionPVCImageFilter Self; typedef ImageToImageFilter< TInputImage, TInputImage > Superclass; typedef SmartPointer< Self > Pointer; /** Method for creation through the object factory. */ itkNewMacro(Self); /** Run-time type information (and related methods). */ itkTypeMacro(RegionConvolutionPVCImageFilter, ImageToImageFilter); /** Image related typedefs. */ typedef TInputImage InputImageType; typedef typename TInputImage::ConstPointer InputImagePointer; typedef typename TInputImage::RegionType RegionType; typedef typename TInputImage::SizeType SizeType; typedef typename TInputImage::IndexType IndexType; typedef typename TInputImage::PixelType PixelType; /** Mask image related typedefs. */ typedef TMaskImage MaskImageType; typedef typename TMaskImage::ConstPointer MaskImagePointer; typedef typename TMaskImage::RegionType MaskRegionType; typedef typename TMaskImage::SizeType MaskSizeType; typedef typename TMaskImage::IndexType MaskIndexType; typedef typename TMaskImage::PixelType MaskPixelType; typedef itk::MultiplyImageFilter<TInputImage, TInputImage> MultiplyFilterType; typedef itk::DivideImageFilter<TInputImage,TInputImage, TInputImage> DivideFilterType; typedef itk::DiscreteGaussianImageFilter<TInputImage, TInputImage> BlurringFilterType; typedef itk::ImageDuplicator<TInputImage> DuplicatorType; typedef itk::Vector<float, 3> ITKVectorType; /** Image related typedefs. */ itkStaticConstMacro(InputImageDimension, unsigned int, 3); itkStaticConstMacro(MaskImageDimension, unsigned int, 3); typedef vnl_vector<float> VectorType; typedef vnl_matrix<float> MatrixType; /** Set the mask image */ void SetMaskInput(const TMaskImage *input) { // Process object is not const-correct so the const casting is required. this->SetNthInput( 1, const_cast< TMaskImage * >( input ) ); } /** Get the label image */ const MaskImageType * GetMaskInput() const { return itkDynamicCastInDebugMode< MaskImageType * >( const_cast< DataObject * >( this->ProcessObject::GetInput(0) ) ); } void SetPSF(ITKVectorType vec) { this->m_vecVariance = vec; } ITKVectorType GetPSF() { return this->m_vecVariance; } void SetVerbose( bool bVerbose ) { this->m_bVerbose = bVerbose; } protected: RegionConvolutionPVCImageFilter(); ~RegionConvolutionPVCImageFilter() {}; /** Does the real work. */ virtual void GenerateData() ITK_OVERRIDE; ITKVectorType m_vecVariance; bool m_bVerbose; private: RegionConvolutionPVCImageFilter(const Self &); //purposely not implemented void operator=(const Self &); //purposely not implemented }; } //namespace petpvc #ifndef ITK_MANUAL_INSTANTIATION #include "petpvcRegionConvolutionImageFilter.txx" #endif #endif // __PETPVCREGIONCONVOLUTIONIMAGEFILTER_H
/* * Copyright 2010-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. * A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ #pragma once #include <aws/clouddirectory/CloudDirectory_EXPORTS.h> namespace Aws { namespace Utils { namespace Json { class JsonValue; class JsonView; } // namespace Json } // namespace Utils namespace CloudDirectory { namespace Model { /** * <p>Represents the output of a <a>DeleteObject</a> response * operation.</p><p><h3>See Also:</h3> <a * href="http://docs.aws.amazon.com/goto/WebAPI/clouddirectory-2017-01-11/BatchDeleteObjectResponse">AWS * API Reference</a></p> */ class AWS_CLOUDDIRECTORY_API BatchDeleteObjectResponse { public: BatchDeleteObjectResponse(); BatchDeleteObjectResponse(Aws::Utils::Json::JsonView jsonValue); BatchDeleteObjectResponse& operator=(Aws::Utils::Json::JsonView jsonValue); Aws::Utils::Json::JsonValue Jsonize() const; }; } // namespace Model } // namespace CloudDirectory } // namespace Aws
/*========================================================================= * * Copyright Insight Software Consortium * * 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.txt * * 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 __itkFEMMaterialBase_h #define __itkFEMMaterialBase_h #include "itkFEMLightObject.h" #include "itkFEMPArray.h" namespace itk { namespace fem { /** * \class Material * \brief Base class for storing all the implicit material and other properties required to fully define the element class. * * When specifying materials for particular element, you should use * MaterialStandard class or derive your own class (using Material * or MaterialStandard as a base class) if your Element requires * special properties or constants. * * Material base class doesn't define any data member. * Everything usefull is stored in derived clases. This class * is here just to group all material classes together and access * them via this base class. * \ingroup ITKFEM */ class Material : public FEMLightObject { public: /** Standard class typedefs. */ typedef Material Self; typedef FEMLightObject Superclass; typedef SmartPointer<Self> Pointer; typedef SmartPointer<const Self> ConstPointer; /** Run-time type information (and related methods). */ itkTypeMacro(Material, FEMLightObject); /** * Array class that holds special pointers to objects of all Material classes */ typedef FEMPArray<Self> ArrayType; protected: virtual void PrintSelf(std::ostream& os, Indent indent) const; }; } } // end namespace itk::fem #endif // #ifndef __itkFEMMaterialBase_h
// Copyright 2016 the V8 project authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef V8_COMPILER_MEMORY_OPTIMIZER_H_ #define V8_COMPILER_MEMORY_OPTIMIZER_H_ #include "src/compiler/graph-assembler.h" #include "src/zone/zone-containers.h" namespace v8 { namespace internal { namespace compiler { // Forward declarations. class CommonOperatorBuilder; struct ElementAccess; class Graph; class JSGraph; class MachineOperatorBuilder; class Node; class Operator; // NodeIds are identifying numbers for nodes that can be used to index auxiliary // out-of-line data associated with each node. typedef uint32_t NodeId; // Lowers all simplified memory access and allocation related nodes (i.e. // Allocate, LoadField, StoreField and friends) to machine operators. // Performs allocation folding and store write barrier elimination // implicitly. class MemoryOptimizer final { public: MemoryOptimizer(JSGraph* jsgraph, Zone* zone); ~MemoryOptimizer() {} void Optimize(); private: // An allocation group represents a set of allocations that have been folded // together. class AllocationGroup final : public ZoneObject { public: AllocationGroup(Node* node, PretenureFlag pretenure, Zone* zone); AllocationGroup(Node* node, PretenureFlag pretenure, Node* size, Zone* zone); ~AllocationGroup() {} void Add(Node* object); bool Contains(Node* object) const; bool IsNewSpaceAllocation() const { return pretenure() == NOT_TENURED; } PretenureFlag pretenure() const { return pretenure_; } Node* size() const { return size_; } private: ZoneSet<NodeId> node_ids_; PretenureFlag const pretenure_; Node* const size_; DISALLOW_IMPLICIT_CONSTRUCTORS(AllocationGroup); }; // An allocation state is propagated on the effect paths through the graph. class AllocationState final : public ZoneObject { public: static AllocationState const* Empty(Zone* zone) { return new (zone) AllocationState(); } static AllocationState const* Closed(AllocationGroup* group, Zone* zone) { return new (zone) AllocationState(group); } static AllocationState const* Open(AllocationGroup* group, int size, Node* top, Zone* zone) { return new (zone) AllocationState(group, size, top); } bool IsNewSpaceAllocation() const; AllocationGroup* group() const { return group_; } Node* top() const { return top_; } int size() const { return size_; } private: AllocationState(); explicit AllocationState(AllocationGroup* group); AllocationState(AllocationGroup* group, int size, Node* top); AllocationGroup* const group_; // The upper bound of the combined allocated object size on the current path // (max int if allocation folding is impossible on this path). int const size_; Node* const top_; DISALLOW_COPY_AND_ASSIGN(AllocationState); }; // An array of allocation states used to collect states on merges. typedef ZoneVector<AllocationState const*> AllocationStates; // We thread through tokens to represent the current state on a given effect // path through the graph. struct Token { Node* node; AllocationState const* state; }; void VisitNode(Node*, AllocationState const*); void VisitAllocate(Node*, AllocationState const*); void VisitCall(Node*, AllocationState const*); void VisitCallWithCallerSavedRegisters(Node*, AllocationState const*); void VisitLoadElement(Node*, AllocationState const*); void VisitLoadField(Node*, AllocationState const*); void VisitStoreElement(Node*, AllocationState const*); void VisitStoreField(Node*, AllocationState const*); void VisitOtherEffect(Node*, AllocationState const*); Node* ComputeIndex(ElementAccess const&, Node*); WriteBarrierKind ComputeWriteBarrierKind(Node* object, AllocationState const* state, WriteBarrierKind); AllocationState const* MergeStates(AllocationStates const& states); void EnqueueMerge(Node*, int, AllocationState const*); void EnqueueUses(Node*, AllocationState const*); void EnqueueUse(Node*, int, AllocationState const*); AllocationState const* empty_state() const { return empty_state_; } Graph* graph() const; Isolate* isolate() const; JSGraph* jsgraph() const { return jsgraph_; } CommonOperatorBuilder* common() const; MachineOperatorBuilder* machine() const; Zone* zone() const { return zone_; } GraphAssembler* gasm() { return &graph_assembler_; } SetOncePointer<const Operator> allocate_operator_; JSGraph* const jsgraph_; AllocationState const* const empty_state_; ZoneMap<NodeId, AllocationStates> pending_; ZoneQueue<Token> tokens_; Zone* const zone_; GraphAssembler graph_assembler_; DISALLOW_IMPLICIT_CONSTRUCTORS(MemoryOptimizer); }; } // namespace compiler } // namespace internal } // namespace v8 #endif // V8_COMPILER_MEMORY_OPTIMIZER_H_
// // CartJiuModel.h // Jiu // // Created by Molly on 15/11/26. // Copyright © 2015年 NTTDATA. All rights reserved. // #import "BaseModel.h" @interface CartJiuModel : BaseModel @property(nonatomic,strong)NSString* cartid; @property(nonatomic,strong)NSString* title; @property(nonatomic,strong)NSString* count; @property(nonatomic,strong)NSString* price; @property(nonatomic,strong)NSString* image; @property(nonatomic,strong)NSString* uid; @property(nonatomic,strong)NSString* agentid; @property(nonatomic,strong)NSString* gid; @property(nonatomic,strong)NSString* status; @end
#ifndef RB_TREE_H #define RB_TREE_H #include <cstdio> #include <cstring> #include <iostream> #include "GenTree.h" #include "bplus_tree_handler.h" using namespace std; #if RB_TREE_NODE_SIZE == 512 #define RB_TREE_HDR_SIZE 7 #define DATA_END_POS 2 #define ROOT_NODE_POS 4 #else #define RB_TREE_HDR_SIZE 8 #define DATA_END_POS 3 #define ROOT_NODE_POS 5 #endif #define RB_RED 0 #define RB_BLACK 1 #if RB_TREE_NODE_SIZE == 512 #define RBT_BITMAP_POS 0 #define LEFT_PTR_POS 1 #define RYTE_PTR_POS 2 #define PARENT_PTR_POS 3 #define KEY_LEN_POS 4 #else #define COLOR_POS 0 #define LEFT_PTR_POS 1 #define RYTE_PTR_POS 3 #define PARENT_PTR_POS 5 #define KEY_LEN_POS 7 #endif // CRTP see https://en.wikipedia.org/wiki/Curiously_recurring_template_pattern class rb_tree : public bplus_tree_handler<rb_tree> { private: int16_t binarySearch(const char *key, int16_t key_len); inline int16_t getLeft(int16_t n); inline int16_t getRight(int16_t n); inline int16_t getParent(int16_t n); int16_t getSibling(int16_t n); inline int16_t getUncle(int16_t n); inline int16_t getGrandParent(int16_t n); inline int16_t getRoot(); inline int16_t getColor(int16_t n); inline void setLeft(int16_t n, int16_t l); inline void setRight(int16_t n, int16_t r); inline void setParent(int16_t n, int16_t p); inline void setRoot(int16_t n); inline void setColor(int16_t n, byte c); void rotateLeft(int16_t n); void rotateRight(int16_t n); void replaceNode(int16_t oldn, int16_t newn); void insertCase1(int16_t n); void insertCase2(int16_t n); void insertCase3(int16_t n); void insertCase4(int16_t n); void insertCase5(int16_t n); public: int16_t pos; byte last_direction; rb_tree(uint16_t leaf_block_sz = DEFAULT_LEAF_BLOCK_SIZE, uint16_t parent_block_sz = DEFAULT_PARENT_BLOCK_SIZE) : bplus_tree_handler<rb_tree>(leaf_block_sz, parent_block_sz) { GenTree::generateLists(); initBuf(); } int16_t getDataEndPos(); void setDataEndPos(int16_t pos); int16_t filledUpto(); void setFilledUpto(int16_t filledUpto); int16_t getPtr(int16_t pos); void setPtr(int16_t pos, int16_t ptr); bool isFull(int16_t search_result); void setCurrentBlockRoot(); void setCurrentBlock(byte *m); int16_t searchCurrentBlock(); void addData(int16_t search_result); void addFirstData(); byte *getKey(int16_t pos, int16_t *plen); byte *getFirstKey(int16_t *plen); int16_t getFirst(); int16_t getNext(int16_t n); int16_t getPrevious(int16_t n); byte *split(byte *first_key, int16_t *first_len_ptr); void initVars(); byte *getChildPtrPos(int16_t search_result); char *getValueAt(int16_t *vlen); using bplus_tree_handler::getChildPtr; byte *getChildPtr(int16_t pos); byte *getPtrPos(); int getHeaderSize(); void initBuf(); }; #endif
#include "metal/console.h" #include "pin.h" #include <stdbool.h> // finding a spare UART tx pin on the STM3240G-eval board is tricky... just // about every pin is doing several things. This configuration of UART means // that you can't use the micro-SD card. Every other configuration I could // find also has tradeoffs. At the moment I don't intend to use micro-SD // with freertps-based systems, so we'll just go with this for now. This can // be swapped for various other tradeoffs (i.e., make the camera unusable) // if desired. // // PC12 = UART5 TX on AF8 #define PORTC_TX_PIN 12 USART_TypeDef *g_console_usart = UART5; static volatile bool g_console_init_complete = false; void console_init(void) { RCC->APB1ENR |= RCC_APB1ENR_UART5EN; pin_set_alternate_function(GPIOC, PORTC_TX_PIN, 8); g_console_usart->CR1 &= ~USART_CR1_UE; g_console_usart->CR1 |= USART_CR1_TE; // we want 1 megabit. the UART5 bus is 168 mhz / 4 = 42 mhz. // the uart bit counter is /16, so we need to further divide by 2.625 // to get 1 megabit using the fractional baud rate divider // so, we have to set mantissa=2 and fraction (sixteenths)=10 g_console_usart->BRR = (((uint16_t)2) << 4) | 10; g_console_usart->CR1 |= USART_CR1_UE; g_console_init_complete = true; } void console_send_block(const uint8_t *buf, uint32_t len) { if (!g_console_init_complete) console_init(); for (uint32_t i = 0; i < len; i++) { while (!(g_console_usart->SR & USART_SR_TXE)) { } // wait for tx buffer g_console_usart->DR = buf[i]; } while (!(g_console_usart->SR & USART_SR_TC)) { } // wait for TX to finish }
/* * Copyright 2010-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. * A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ #pragma once #include <aws/medialive/MediaLive_EXPORTS.h> #include <aws/core/utils/memory/stl/AWSString.h> namespace Aws { namespace MediaLive { namespace Model { enum class H264LookAheadRateControl { NOT_SET, HIGH, LOW, MEDIUM }; namespace H264LookAheadRateControlMapper { AWS_MEDIALIVE_API H264LookAheadRateControl GetH264LookAheadRateControlForName(const Aws::String& name); AWS_MEDIALIVE_API Aws::String GetNameForH264LookAheadRateControl(H264LookAheadRateControl value); } // namespace H264LookAheadRateControlMapper } // namespace Model } // namespace MediaLive } // namespace Aws
/* * Copyright 2010-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. * A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ #pragma once #include <aws/snowball/Snowball_EXPORTS.h> #include <aws/core/utils/memory/stl/AWSVector.h> #include <aws/core/utils/memory/stl/AWSString.h> #include <aws/snowball/model/Address.h> #include <utility> namespace Aws { template<typename RESULT_TYPE> class AmazonWebServiceResult; namespace Utils { namespace Json { class JsonValue; } // namespace Json } // namespace Utils namespace Snowball { namespace Model { class AWS_SNOWBALL_API DescribeAddressesResult { public: DescribeAddressesResult(); DescribeAddressesResult(const Aws::AmazonWebServiceResult<Aws::Utils::Json::JsonValue>& result); DescribeAddressesResult& operator=(const Aws::AmazonWebServiceResult<Aws::Utils::Json::JsonValue>& result); /** * <p>The Snowball shipping addresses that were created for this account.</p> */ inline const Aws::Vector<Address>& GetAddresses() const{ return m_addresses; } /** * <p>The Snowball shipping addresses that were created for this account.</p> */ inline void SetAddresses(const Aws::Vector<Address>& value) { m_addresses = value; } /** * <p>The Snowball shipping addresses that were created for this account.</p> */ inline void SetAddresses(Aws::Vector<Address>&& value) { m_addresses = std::move(value); } /** * <p>The Snowball shipping addresses that were created for this account.</p> */ inline DescribeAddressesResult& WithAddresses(const Aws::Vector<Address>& value) { SetAddresses(value); return *this;} /** * <p>The Snowball shipping addresses that were created for this account.</p> */ inline DescribeAddressesResult& WithAddresses(Aws::Vector<Address>&& value) { SetAddresses(std::move(value)); return *this;} /** * <p>The Snowball shipping addresses that were created for this account.</p> */ inline DescribeAddressesResult& AddAddresses(const Address& value) { m_addresses.push_back(value); return *this; } /** * <p>The Snowball shipping addresses that were created for this account.</p> */ inline DescribeAddressesResult& AddAddresses(Address&& value) { m_addresses.push_back(std::move(value)); return *this; } /** * <p>HTTP requests are stateless. If you use the automatically generated * <code>NextToken</code> value in your next <code>DescribeAddresses</code> call, * your list of returned addresses will start from this point in the array.</p> */ inline const Aws::String& GetNextToken() const{ return m_nextToken; } /** * <p>HTTP requests are stateless. If you use the automatically generated * <code>NextToken</code> value in your next <code>DescribeAddresses</code> call, * your list of returned addresses will start from this point in the array.</p> */ inline void SetNextToken(const Aws::String& value) { m_nextToken = value; } /** * <p>HTTP requests are stateless. If you use the automatically generated * <code>NextToken</code> value in your next <code>DescribeAddresses</code> call, * your list of returned addresses will start from this point in the array.</p> */ inline void SetNextToken(Aws::String&& value) { m_nextToken = std::move(value); } /** * <p>HTTP requests are stateless. If you use the automatically generated * <code>NextToken</code> value in your next <code>DescribeAddresses</code> call, * your list of returned addresses will start from this point in the array.</p> */ inline void SetNextToken(const char* value) { m_nextToken.assign(value); } /** * <p>HTTP requests are stateless. If you use the automatically generated * <code>NextToken</code> value in your next <code>DescribeAddresses</code> call, * your list of returned addresses will start from this point in the array.</p> */ inline DescribeAddressesResult& WithNextToken(const Aws::String& value) { SetNextToken(value); return *this;} /** * <p>HTTP requests are stateless. If you use the automatically generated * <code>NextToken</code> value in your next <code>DescribeAddresses</code> call, * your list of returned addresses will start from this point in the array.</p> */ inline DescribeAddressesResult& WithNextToken(Aws::String&& value) { SetNextToken(std::move(value)); return *this;} /** * <p>HTTP requests are stateless. If you use the automatically generated * <code>NextToken</code> value in your next <code>DescribeAddresses</code> call, * your list of returned addresses will start from this point in the array.</p> */ inline DescribeAddressesResult& WithNextToken(const char* value) { SetNextToken(value); return *this;} private: Aws::Vector<Address> m_addresses; Aws::String m_nextToken; }; } // namespace Model } // namespace Snowball } // namespace Aws
/** * Appcelerator Titanium Mobile * Copyright (c) 2010 by TiBountyHunter, Inc. All Rights Reserved. * Licensed under the terms of the Apache Public License * Please see the LICENSE included with this distribution for details. * * WARNING: This is generated code. Modify at your own risk and without support. */ #import "TiBase.h" #ifdef USE_TI_FILESYSTEM #import "TiFile.h" @interface TiFilesystemBlobProxy : TiFile { @private NSURL *url; NSData *data; } -(id)initWithURL:(NSURL*)url data:(NSData*)data; @end #endif
// // Copyright 2010 Autodesk, Inc. All rights reserved. // // Use of this software is subject to the terms of the Autodesk license // agreement provided at the time of installation or download, or which // otherwise accompanies this software in either electronic or hard copy form. // // #pragma once #include "BaseMaterialHandle.h" #include "TextureHandle.h" namespace MaxSDK { namespace Graphics { /** This is material class to support material with texture. How to use: \code TextureMaterialHandle hMaterial hMaterial.Initialize(); hMaterial.SetTexture(hTexture); // hTexture is an instance of TextureHandle pItem->SetCustomMaterial(hMaterial); // pItem is an instance of RenderItemHandle \endcode */ class TextureMaterialHandle : public BaseMaterialHandle { public: GraphicsDriverAPI TextureMaterialHandle(); GraphicsDriverAPI TextureMaterialHandle(const TextureMaterialHandle& from); GraphicsDriverAPI TextureMaterialHandle& operator = (const TextureMaterialHandle& from); GraphicsDriverAPI virtual ~TextureMaterialHandle(); /** Initialize an instance of texture material. A TextureMaterialHandle should be initialized before it's used. \return true if successfully initialized, false otherwise. */ GraphicsDriverAPI bool Initialize(); /** Specifies a texture handle. \param[in] hTexture the texture handle. */ GraphicsDriverAPI void SetTexture(const BaseRasterHandle& hTexture); /** Returns the texture handle. \return the texture handle. */ GraphicsDriverAPI BaseRasterHandle GetTexture() const; /** Specifies texture map channel ID. Change of texture map channel ID will change the MaterialRequiredStreams. \param[in] channelID the texture map channel ID. */ GraphicsDriverAPI void SetTextureMapChannel(int channelID); /** Returns the texture map channel ID. \return the texture map channel ID. */ GraphicsDriverAPI int GetTextureMapChannel(); /** Returns the material required streams to tell how to setup mesh data. \return the material required streams. */ GraphicsDriverAPI virtual const MaterialRequiredStreams* GetRequiredStreams() const; }; } } // end namespace
// Copyright (c) 2021 PaddlePaddle Authors. 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. #pragma once #include <unsupported/Eigen/SpecialFunctions> #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/operator.h" #include "paddle/fluid/platform/for_range.h" namespace paddle { namespace operators { template <typename T> struct LgammaFunctor { LgammaFunctor(const T* input, T* output, int64_t numel) : input_(input), output_(output), numel_(numel) {} HOSTDEVICE void operator()(int64_t idx) const { output_[idx] = Eigen::numext::lgamma(input_[idx]); } private: const T* input_; T* output_; int64_t numel_; }; template <typename T> struct LgammaGradFunctor { LgammaGradFunctor(const T* dout, const T* x, T* output, int64_t numel) : dout_(dout), x_(x), output_(output), numel_(numel) {} HOSTDEVICE void operator()(int64_t idx) const { output_[idx] = dout_[idx] * Eigen::numext::digamma(x_[idx]); } private: const T* dout_; const T* x_; T* output_; int64_t numel_; }; using Tensor = framework::Tensor; template <typename DeviceContext, typename T> class LgammaKernel : public framework::OpKernel<T> { public: void Compute(const framework::ExecutionContext& context) const override { const Tensor* x = context.Input<Tensor>("X"); Tensor* out = context.Output<Tensor>("Out"); auto numel = x->numel(); auto* x_data = x->data<T>(); auto* out_data = out->mutable_data<T>(context.GetPlace(), size_t(x->numel() * sizeof(T))); auto& dev_ctx = context.template device_context<DeviceContext>(); platform::ForRange<DeviceContext> for_range(dev_ctx, numel); LgammaFunctor<T> functor(x_data, out_data, numel); for_range(functor); } }; template <typename DeviceContext, typename T> class LgammaGradKernel : public framework::OpKernel<T> { public: void Compute(const framework::ExecutionContext& ctx) const { const framework::Tensor* d_out = ctx.Input<framework::Tensor>(framework::GradVarName("Out")); const framework::Tensor* x = ctx.Input<framework::Tensor>("X"); framework::Tensor* d_x = ctx.Output<framework::Tensor>(framework::GradVarName("X")); auto numel = d_out->numel(); auto* dout_data = d_out->data<T>(); auto* x_data = x->data<T>(); auto* dx_data = d_x->mutable_data<T>( ctx.GetPlace(), static_cast<size_t>(numel * sizeof(T))); auto& dev_ctx = ctx.template device_context<DeviceContext>(); platform::ForRange<DeviceContext> for_range(dev_ctx, numel); LgammaGradFunctor<T> functor(dout_data, x_data, dx_data, numel); for_range(functor); } }; } // namespace operators } // namespace paddle
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* Fluent Bit * ========== * Copyright (C) 2015-2022 The Fluent Bit Authors * * 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_SP_KEY_H #define FLB_SP_KEY_H #include <fluent-bit/flb_info.h> #include <fluent-bit/flb_sds.h> #include <msgpack.h> struct flb_sp_value *flb_sp_key_to_value(flb_sds_t ckey, msgpack_object map, struct mk_list *subkeys); void flb_sp_key_value_destroy(struct flb_sp_value *v); void flb_sp_key_value_print(struct flb_sp_value *v); #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. */ // Threadsafe and minimal functionality cached op version for Inference // lot of code reused from cached_op.h #ifndef MXNET_IMPERATIVE_NAIVE_CACHED_OP_H_ #define MXNET_IMPERATIVE_NAIVE_CACHED_OP_H_ #include <mxnet/imperative.h> #include <vector> #include <atomic> #include <utility> #include <string> #include <unordered_map> #include "./cached_op.h" namespace mxnet { /*! \brief NaiveCachedOp which does not involve engine which is useful when executed in parallel. It does not support advanced features of CachedOp, including backward/recording, etc... */ class NaiveCachedOp : public CachedOp { public: NaiveCachedOp( const nnvm::Symbol &sym, const std::vector<std::pair<std::string, std::string>> &flags) : CachedOp(sym, flags) {} virtual ~NaiveCachedOp() {} OpStatePtr Forward( const std::shared_ptr<CachedOp>& op_ptr, const std::vector<NDArray*>& inputs, const std::vector<NDArray*>& outputs) override; void Backward( const bool retain_graph, const OpStatePtr& state, const std::vector<NDArray*>& inputs, const std::vector<OpReqType>& reqs, const std::vector<NDArray*>& outputs) override { LOG(FATAL) << "Backward is not supported in NaiveCachedOp."; } // backward storage type inference bool BackwardStorageType( const nnvm::NodeAttrs& attrs, const int dev_mask, DispatchMode* dispatch_mode, std::vector<int> *in_attrs, std::vector<int> *out_attrs) override { LOG(FATAL) << "Backward is not supported in NaiveCachedOp."; return false; } }; // NaiveCachedOp using NaiveCachedOpPtr = std::shared_ptr<NaiveCachedOp>; } // namespace mxnet #endif // MXNET_IMPERATIVE_NAIVE_CACHED_OP_H_
// // P2UXViewContainerDelegate.h // P2UXCore // // Created by Stephen Schalkhauser on 3/11/15. // Copyright (c) 2015 Phase 2 Industries, LLC. All rights reserved. // #import <Foundation/Foundation.h> #import <P2UXCore/P2UXActionDelegate.h> #import <P2UXCore/P2UXEventAction.h> #ifdef LOCAL_NOTIFICATION_SUPPORT #import <UserNotifications/UserNotifications.h> #endif @class P2UXEventAction, P2UXElementInstance, P2UXEventTransition, P2UXDefinition, P2UXPanel, P2UXViewController; @protocol P2UXHelperDelegate; @protocol P2UXViewContainerDelegate <NSObject> - (void) showPanelFromAction:(P2UXEventAction*)action; - (void) hidePanelFromAction:(P2UXEventAction*)action; - (void) setAppStateFromAction:(P2UXEventAction*)action; - (void) hidePanel:(NSString*)systemType transition:(P2UXEventTransition*)transition; - (NSDictionary*) nativeDialogWithIdent:(NSString*)ident; - (void) clearBackStack; - (P2UXView*) currentView; - (P2UXView*) screenWithIdent:(NSString*)ident rect:(CGRect)rect cache:(BOOL)cache index:(NSString*)index data:(id)data; - (P2UXPanel*) panelWithIdent:(NSString*)ident rect:(CGRect)rect cache:(BOOL)cache index:(NSString*)index data:(id)data; - (void) handleEvents:(NSArray*)events element:(P2UXElementInstance*)element source:(id)source; - (void) handleEvents:(NSArray*)events element:(P2UXElementInstance*)element source:(id)source result:(NSInteger)result; - (BOOL) setCurrentView:(NSString*)viewId history:(P2UXEventBackHistory)history; - (BOOL) setCurrentView:(NSString*)viewId history:(P2UXEventBackHistory)history data:(id)data transition:(P2UXEventTransition*)transition toggle:(BOOL)toggle index:(id)index rect:(NSDictionary*)rect modal:(BOOL)modal; - (void) peekScreen:(NSString*)ident spec:(NSDictionary*)spec index:(id)index data:(id)data transition:(P2UXEventTransition*)transition; - (void) handleBackToView:(NSString*)viewId transition:(P2UXEventTransition *)transition; - (void) reloadContents; - (void) addLayoutToBackStack:(UIView*)view layout:(NSString*)layout transient:(BOOL)transient duration:(float)duration replace:(BOOL)replace clear:(BOOL)clear; - (void) createModalLayer:(UIView*)view color:(NSString*)color fade:(float)fade; - (void) handleBack; - (void) resetEvents; - (P2UXView*) cachedView:(NSString*)ident; - (void) cacheView:(P2UXView*)view; - (UIViewController*) currentController; - (CGRect) containerBounds; - (P2UXDefinition*) screenDefWithIdentOrSystemType:(NSString*)ident; - (P2UXDefinition*) panelDefWithIdentOrSystemType:(NSString*)ident; - (void) showOverlaysForCurrentView; - (void) presentViewController:(UIViewController *)viewControllerToPresent animated:(BOOL)flag completion:(void (^)(void))completion; - (OSColorClass*) colorWithId:(NSString*)colorWithId; - (NSDictionary*) gradientWithId:(NSString*)gradientWithId; - (CGFloat) scale; - (UIView*) overlayWithFrame:(CGRect)frame elemInst:(P2UXElementInstance*)elemInst uipath:(NSString*)path ext:(BOOL)ext handler:(id<P2UXActionDelegate>)handler index:(id)index data:(id)data; - (UIView*) overlayParent; - (void) removeOverlay:(NSString*)systemType; - (P2UXView*) createViewItemWithDef:(P2UXDefinition*)def rect:(CGRect)rect cache:(BOOL)cache index:(id)index data:(id)data; - (void) handleTimeUpdate; - (id<P2UXHelperDelegate>) helperDelegate; - (UIView*) overrideControlWithType:(int)ctrlType frame:(CGRect)frame elemInst:(P2UXElementInstance*)elemInst uipath:(NSString*)path ext:(BOOL)ext handler:(id<P2UXActionDelegate>)handler index:(id)index; - (void) clearCachedViews; - (NSArray*) eventsWithEventType:(P2UXElementEvent)eventType; #ifdef LOCAL_NOTIFICATION_SUPPORT - (void) handleSystemLocalNotification:(UNNotification*)notification; #endif @end
#include <pal.h> /** * * Calculates the hyperbolic tangent of the input vector 'a'. * Angles are specified in radians. * * @param a Pointer to input vector * * @param c Pointer to output vector * * @param n Size of 'a' and 'c' vector. * * @return None * */ #include <math.h> void p_tanh_f32(const float *a, float *c, int n) { int i; for (i = 0; i < n; i++) { *(c + i) = tanhf(*(a + i)); } }
#pragma once #include <list> #include <memory> #include "common/common/assert.h" namespace Envoy { /** * Mixin class that allows an object contained in a unique pointer to be easily linked and unlinked * from lists. */ template <class T> class LinkedObject { public: typedef std::list<std::unique_ptr<T>> ListType; /** * @return the list iterator for the object. */ typename ListType::iterator entry() { ASSERT(inserted_); return entry_; } /** * @return whether the object is currently inserted into a list. */ bool inserted() { return inserted_; } /** * Move a linked item between 2 lists. * @param list1 supplies the first list. * @param list2 supplies the second list. */ void moveBetweenLists(ListType& list1, ListType& list2) { ASSERT(inserted_); ASSERT(std::find(list1.begin(), list1.end(), *entry_) != list1.end()); list2.splice(list2.begin(), list1, entry_); } /** * Move an item into a linked list at the front. * @param item supplies the item to move in. * @param list supplies the list to move the item into. */ void moveIntoList(std::unique_ptr<T>&& item, ListType& list) { ASSERT(!inserted_); inserted_ = true; entry_ = list.emplace(list.begin(), std::move(item)); } /** * Move an item into a linked list at the back. * @param item supplies the item to move in. * @param list supplies the list to move the item into. */ void moveIntoListBack(std::unique_ptr<T>&& item, ListType& list) { ASSERT(!inserted_); inserted_ = true; entry_ = list.emplace(list.end(), std::move(item)); } /** * Remove this item from a list. * @param list supplies the list to remove from. This item should be in this list. */ std::unique_ptr<T> removeFromList(ListType& list) { ASSERT(inserted_); ASSERT(std::find(list.begin(), list.end(), *entry_) != list.end()); std::unique_ptr<T> removed = std::move(*entry_); list.erase(entry_); inserted_ = false; return removed; } protected: LinkedObject() : inserted_(false) {} private: typename ListType::iterator entry_; bool inserted_; // iterators do not have any "invalid" value so we need this boolean for sanity // checking. }; } // Envoy
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* libft.h :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: aljourda <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2015/11/25 13:28:21 by aljourda #+# #+# */ /* Updated: 2015/11/26 14:56:31 by aljourda ### ########.fr */ /* */ /* ************************************************************************** */ #ifndef LIBFT_H # define LIBFT_H # include <stdlib.h> # include <unistd.h> # include <string.h> typedef struct s_list { void *content; size_t content_size; struct s_list *next; } t_list; void *ft_memset(void *b, int c, size_t len); void ft_bzero(void *s, size_t n); void *ft_memcpy(void *dst, const void *src, size_t n); void *ft_memccpy(void *dst, const void *src, int c, size_t n); void *ft_memmove(void *dst, const void *src, size_t len); void *ft_memchr(const void *s, int c, size_t n); int ft_memcmp(const void *s1, const void *s2, size_t n); size_t ft_strlen(const char *s); char *ft_strdup(const char *s1); char *ft_strcpy(char *dst, const char *src); char *ft_strncpy(char *dst, const char *src, size_t n); char *ft_strcat(char *s1, const char *s2); char *ft_strncat(char *s1, const char *s2, size_t n); size_t ft_strlcat(char *dst, const char *src, size_t size); char *ft_strchr(const char *s, int c); char *ft_strrchr(const char *s, int c); char *ft_strstr(const char *s1, const char *s2); char *ft_strnstr(const char *s1, const char *s2, size_t n); int ft_strcmp(const char *s1, const char *s2); int ft_strncmp(const char *s1, const char *s2, size_t n); int ft_atoi(const char *str); int ft_isalpha(int c); int ft_isdigit(int c); int ft_isalnum(int c); int ft_isascii(int c); int ft_isprint(int c); int ft_toupper(int c); int ft_tolower(int c); void *ft_memalloc(size_t size); void ft_memdel(void **ap); char *ft_strnew(size_t size); void ft_strdel(char **as); void ft_strclr(char *s); void ft_striter(char *s, void (*f)(char *)); void ft_striteri(char *s, void (*f)(unsigned int, char *)); char *ft_strmap(char const *s, char (*f)(char)); char *ft_strmapi(char const *s, char (*f)(unsigned int, char)); int ft_strequ(char const *s1, char const *s2); int ft_strnequ(char const *s1, char const *s2, size_t n); char *ft_strsub(char const *s, unsigned int start, size_t len); char *ft_strjoin(char const *s1, char const *s2); char *ft_strtrim(char const *s); char **ft_strsplit(char const *s, char c); char *ft_itoa(int n); void ft_putchar(char c); void ft_putstr(char const *s); void ft_putendl(char const *s); void ft_putnbr(int n); void ft_putchar_fd(char c, int fd); void ft_putstr_fd(char const *s, int fd); void ft_putendl_fd(char const *s, int fd); void ft_putnbr_fd(int n, int fd); t_list *ft_lstnew(void const *content, size_t content_size); void ft_lstdelone(t_list **alst, void (*del)(void *, size_t)); void ft_lstdel(t_list **alst, void (*del)(void *, size_t)); void ft_lstadd(t_list **alst, t_list *new); void ft_lstiter(t_list *lst, void (*f)(t_list *elem)); t_list *ft_lstmap(t_list *lst, t_list *(*f)(t_list *elem)); void ft_swap(char *p1, char *p2); void ft_swap_int(int *p1, int *p2); void ft_strrev(char *str); int ft_isspace(int c); void *ft_memdup(const void *src, size_t n); int ft_pow(int x, unsigned int y); int ft_sqrt(int nb); #endif
// // BOXRepresentationInfoRequest.h // BoxContentSDK // // Created by Prithvi Jutur on 4/10/18. // Copyright © 2018 Box. All rights reserved. // #import <BoxContentSDK/BOXContentSDK.h> @class BOXRepresentation; @interface BOXRepresentationInfoRequest : BOXRequestWithSharedLinkHeader - (instancetype)initWithFileID:(NSString *)fileID representation:(BOXRepresentation *)representation; - (void)performRequestWithCompletion:(BOXRepresentationInfoBlock)completionBlock; @end
// Copyright 2015 the V8 project authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef V8_COMPILER_JS_NATIVE_CONTEXT_SPECIALIZATION_H_ #define V8_COMPILER_JS_NATIVE_CONTEXT_SPECIALIZATION_H_ #include "src/base/flags.h" #include "src/compiler/graph-reducer.h" namespace v8 { namespace internal { // Forward declarations. class CompilationDependencies; class Factory; class FeedbackNexus; class TypeCache; namespace compiler { // Forward declarations. enum class AccessMode; class CommonOperatorBuilder; class JSGraph; class JSOperatorBuilder; class MachineOperatorBuilder; class SimplifiedOperatorBuilder; // Specializes a given JSGraph to a given native context, potentially constant // folding some {LoadGlobal} nodes or strength reducing some {StoreGlobal} // nodes. And also specializes {LoadNamed} and {StoreNamed} nodes according // to type feedback (if available). class JSNativeContextSpecialization final : public AdvancedReducer { public: // Flags that control the mode of operation. enum Flag { kNoFlags = 0u, kBailoutOnUninitialized = 1u << 0, kDeoptimizationEnabled = 1u << 1, }; typedef base::Flags<Flag> Flags; JSNativeContextSpecialization(Editor* editor, JSGraph* jsgraph, Flags flags, MaybeHandle<Context> native_context, CompilationDependencies* dependencies, Zone* zone); Reduction Reduce(Node* node) final; private: Reduction ReduceJSLoadContext(Node* node); Reduction ReduceJSLoadNamed(Node* node); Reduction ReduceJSStoreNamed(Node* node); Reduction ReduceJSLoadProperty(Node* node); Reduction ReduceJSStoreProperty(Node* node); Reduction ReduceElementAccess(Node* node, Node* index, Node* value, MapHandleList const& receiver_maps, AccessMode access_mode, LanguageMode language_mode, KeyedAccessStoreMode store_mode); Reduction ReduceKeyedAccess(Node* node, Node* index, Node* value, FeedbackNexus const& nexus, AccessMode access_mode, LanguageMode language_mode, KeyedAccessStoreMode store_mode); Reduction ReduceNamedAccess(Node* node, Node* value, FeedbackNexus const& nexus, Handle<Name> name, AccessMode access_mode, LanguageMode language_mode); Reduction ReduceNamedAccess(Node* node, Node* value, MapHandleList const& receiver_maps, Handle<Name> name, AccessMode access_mode, LanguageMode language_mode, Node* index = nullptr); Reduction ReduceSoftDeoptimize(Node* node); // Adds stability dependencies on all prototypes of every class in // {receiver_type} up to (and including) the {holder}. void AssumePrototypesStable(Type* receiver_type, Handle<Context> native_context, Handle<JSObject> holder); // Assuming that {if_projection} is either IfTrue or IfFalse, adds a hint on // the dominating Branch that {if_projection} is the unlikely (deferred) case. void MarkAsDeferred(Node* if_projection); // Retrieve the native context from the given {node} if known. MaybeHandle<Context> GetNativeContext(Node* node); Graph* graph() const; JSGraph* jsgraph() const { return jsgraph_; } Isolate* isolate() const; Factory* factory() const; CommonOperatorBuilder* common() const; JSOperatorBuilder* javascript() const; SimplifiedOperatorBuilder* simplified() const; MachineOperatorBuilder* machine() const; Flags flags() const { return flags_; } MaybeHandle<Context> native_context() const { return native_context_; } CompilationDependencies* dependencies() const { return dependencies_; } Zone* zone() const { return zone_; } JSGraph* const jsgraph_; Flags const flags_; MaybeHandle<Context> native_context_; CompilationDependencies* const dependencies_; Zone* const zone_; TypeCache const& type_cache_; DISALLOW_COPY_AND_ASSIGN(JSNativeContextSpecialization); }; DEFINE_OPERATORS_FOR_FLAGS(JSNativeContextSpecialization::Flags) } // namespace compiler } // namespace internal } // namespace v8 #endif // V8_COMPILER_JS_NATIVE_CONTEXT_SPECIALIZATION_H_
#include <stdint.h> #include <stdio.h> int32_t cmTestFunc(void); int main(void) { if (cmTestFunc() > 4200) { printf("Test success.\n"); return 0; } else { printf("Test failure.\n"); return 1; } }
/* * 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. */ #ifndef __SHELL_PRIV_H_ #define __SHELL_PRIV_H_ #ifdef __cplusplus extern "C" { #endif #include "streamer/streamer.h" #include "shell/shell.h" struct CborEncoder; #if MYNEWT_VAL(SHELL_BRIDGE) /** * Streams CBOR text strings to its encoder. */ struct shell_bridge_streamer { struct streamer streamer; struct CborEncoder *str_encoder; }; #endif #if MYNEWT_VAL(SHELL_MGMT) #define SHELL_NLIP_PKT_START1 (6) #define SHELL_NLIP_PKT_START2 (9) #define SHELL_NLIP_DATA_START1 (4) #define SHELL_NLIP_DATA_START2 (20) int shell_nlip_process(char *data, int len); void shell_nlip_init(void); void shell_nlip_clear_pkt(void); #endif void shell_os_register(void); void shell_prompt_register(void); #if MYNEWT_VAL(SHELL_BRIDGE) void shell_bridge_streamer_new(struct shell_bridge_streamer *sbs, struct CborEncoder *str_encoder); int shell_bridge_init(void); #endif #ifdef __cplusplus } #endif #endif /* __SHELL_PRIV_H_ */
/*========================================================================= * * Copyright Insight Software Consortium * * 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.txt * * 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 __itkMeanSquaresImageToImageMetric_h #define __itkMeanSquaresImageToImageMetric_h #include "itkImageToImageMetric.h" #include "itkPoint.h" #include "itkIndex.h" namespace itk { /** * \class MeanSquaresImageToImageMetric * \brief TODO * \ingroup ITKRegistrationCommon */ template< class TFixedImage, class TMovingImage > class ITK_EXPORT MeanSquaresImageToImageMetric: public ImageToImageMetric< TFixedImage, TMovingImage > { public: /** Standard class typedefs. */ typedef MeanSquaresImageToImageMetric Self; typedef ImageToImageMetric< TFixedImage, TMovingImage > Superclass; typedef SmartPointer< Self > Pointer; typedef SmartPointer< const Self > ConstPointer; /** Method for creation through the object factory. */ itkNewMacro(Self); /** Run-time type information (and related methods). */ itkTypeMacro(MeanSquaresImageToImageMetric, ImageToImageMetric); /** Types inherited from Superclass. */ typedef typename Superclass::TransformType TransformType; typedef typename Superclass::TransformPointer TransformPointer; typedef typename Superclass::TransformJacobianType TransformJacobianType; typedef typename Superclass::InterpolatorType InterpolatorType; typedef typename Superclass::MeasureType MeasureType; typedef typename Superclass::DerivativeType DerivativeType; typedef typename Superclass::ParametersType ParametersType; typedef typename Superclass::FixedImageType FixedImageType; typedef typename Superclass::MovingImageType MovingImageType; typedef typename Superclass::MovingImagePointType MovingImagePointType; typedef typename Superclass::FixedImageConstPointer FixedImageConstPointer; typedef typename Superclass::MovingImageConstPointer MovingImageConstPointer; typedef typename Superclass::CoordinateRepresentationType CoordinateRepresentationType; typedef typename Superclass::FixedImageSampleContainer FixedImageSampleContainer; typedef typename Superclass::ImageDerivativesType ImageDerivativesType; typedef typename Superclass::WeightsValueType WeightsValueType; typedef typename Superclass::IndexValueType IndexValueType; // Needed for evaluation of Jacobian. typedef typename Superclass::FixedImagePointType FixedImagePointType; /** The moving image dimension. */ itkStaticConstMacro(MovingImageDimension, unsigned int, MovingImageType::ImageDimension); /** * Initialize the Metric by * (1) making sure that all the components are present and plugged * together correctly, * (2) uniformly select NumberOfSpatialSamples within * the FixedImageRegion, and * (3) allocate memory for pdf data structures. */ virtual void Initialize(void) throw ( ExceptionObject ); /** Get the value. */ MeasureType GetValue(const ParametersType & parameters) const; /** Get the derivatives of the match measure. */ void GetDerivative(const ParametersType & parameters, DerivativeType & Derivative) const; /** Get the value and derivatives for single valued optimizers. */ void GetValueAndDerivative(const ParametersType & parameters, MeasureType & Value, DerivativeType & Derivative) const; protected: MeanSquaresImageToImageMetric(); virtual ~MeanSquaresImageToImageMetric(); void PrintSelf(std::ostream & os, Indent indent) const; private: //purposely not implemented MeanSquaresImageToImageMetric(const Self &); //purposely not implemented void operator=(const Self &); inline bool GetValueThreadProcessSample(ThreadIdType threadID, SizeValueType fixedImageSample, const MovingImagePointType & mappedPoint, double movingImageValue) const; inline bool GetValueAndDerivativeThreadProcessSample(ThreadIdType threadID, SizeValueType fixedImageSample, const MovingImagePointType & mappedPoint, double movingImageValue, const ImageDerivativesType & movingImageGradientValue) const; MeasureType * m_ThreaderMSE; DerivativeType *m_ThreaderMSEDerivatives; }; } // end namespace itk #ifndef ITK_MANUAL_INSTANTIATION #include "itkMeanSquaresImageToImageMetric.hxx" #endif #endif
// Copyright (C) 2017 by Pedro Mendes, Virginia Tech Intellectual // Properties, Inc., University of Heidelberg, and University of // of Connecticut School of Medicine. // All rights reserved. // Copyright (C) 2016 by Pedro Mendes, Virginia Tech Intellectual // Properties, Inc., University of Heidelberg, and The University // of Manchester. // All rights reserved. #ifndef CENTITYPROVENANCEDialog_H #define CENTITYPROVENANCEDialog_H #include <QStandardItemModel> #include "copasiWidget.h" #include "ui_CEntityProvenanceDialog.h" class CUndoStack; class CEntityProvenanceDialog : public CopasiWidget, public Ui::CEntityProvenanceDialog { Q_OBJECT public: CEntityProvenanceDialog(QWidget *parent = 0, CUndoStack * UndoStack = NULL, QString PathFile = "", QList<QString> VersionsPathToCurrentModel = QList<QString> (), const char* name = 0); ~CEntityProvenanceDialog(); void load(CUndoStack * UndoStack, QString EntityNameQString, QString PathFile, QList<QString> VersionsPathToCurrentModel); private: /** * Pointer to Undo Stack */ CUndoStack * mpUndoStack; /** * Pointer to Provenance data table */ QStandardItemModel *mpProvenanceTable; /** * Number of Columns of Provenance data table */ int mNCol; /** * Number of Ros of Provenance data table */ int mNRow; int mSelectedIndex; /** * Path to Combine Archive */ QString mPathFile; /** * A list of Versions from the root to the Parent of Current Model */ QList<QString> mVersionsPathToCurrentModel; /** * Name of the Entity that Provenance table is made for */ QString mEntityName; /** * The last Provenance parent of current model version */ // QString mProvenanceParentOfCurrentModel; /** * The parent of current model version * Last Created/Restored Version */ //QString mVersioningParentOfCurrentModel; /** * Generate Provenance data from Undo History and append them to the provenance table */ void CurrentSessionEdits2ProvenanceTable(); /** * Append data from Prov XML files to the provenance table */ void ProvXMLFiles2ProvenanceTable(); /** * When the last row of Provenance table is reached reallocate 100 rows more */ void reallocateProvenanceTable(int Nrow); /** * Add one row to Provenance table with the given data */ void AddOneLineToTable(QString Action, QString Property, QString NewValue, QString Time, QString Author); }; #endif // CENTITYPROVENANCEDialog_H
/* * Copyright (C) 1999 Lars Knoll (knoll@kde.org) * (C) 1999 Antti Koivisto (koivisto@kde.org) * (C) 2000 Dirk Mueller (mueller@kde.org) * Copyright (C) 2004, 2005, 2006, 2010, 2011 Apple Inc. All rights reserved. * Copyright (C) 2010 Google Inc. All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. * */ #ifndef HTMLOptionElement_h #define HTMLOptionElement_h #include "HTMLElement.h" namespace WebCore { class HTMLDataListElement; class HTMLSelectElement; class HTMLOptionElement final : public HTMLElement { public: static PassRefPtr<HTMLOptionElement> create(Document&); static PassRefPtr<HTMLOptionElement> create(const QualifiedName&, Document&); static PassRefPtr<HTMLOptionElement> createForJSConstructor(Document&, const String& data, const String& value, bool defaultSelected, bool selected, ExceptionCode&); virtual String text() const; void setText(const String&, ExceptionCode&); int index() const; String value() const; void setValue(const String&); bool selected(); void setSelected(bool); #if ENABLE(DATALIST_ELEMENT) HTMLDataListElement* ownerDataListElement() const; #endif HTMLSelectElement* ownerSelectElement() const; String label() const; void setLabel(const String&); bool ownElementDisabled() const { return m_disabled; } virtual bool isDisabledFormControl() const override; String textIndentedToRespectGroupLabel() const; void setSelectedState(bool); private: HTMLOptionElement(const QualifiedName&, Document&); virtual bool isFocusable() const override; virtual bool rendererIsNeeded(const RenderStyle&) override { return false; } virtual void didAttachRenderers() override; virtual void willDetachRenderers() override; virtual void parseAttribute(const QualifiedName&, const AtomicString&) override; virtual InsertionNotificationRequest insertedInto(ContainerNode&) override; virtual void accessKeyAction(bool) override; virtual void childrenChanged(const ChildChange&) override; // <option> never has a renderer so we manually manage a cached style. void updateNonRenderStyle(RenderStyle& parentStyle); virtual RenderStyle* nonRendererStyle() const override; virtual PassRefPtr<RenderStyle> customStyleForRenderer(RenderStyle& parentStyle) override; virtual void didRecalcStyle(Style::Change) override; String collectOptionInnerText() const; bool m_disabled; bool m_isSelected; RefPtr<RenderStyle> m_style; }; NODE_TYPE_CASTS(HTMLOptionElement) } // namespace #endif
/* * Copyright (C) 2013 Apple 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 CurlDownload_h #define CurlDownload_h #include "FileSystem.h" #include "ResourceHandle.h" #include "ResourceResponse.h" #include <wtf/Threading.h> #if PLATFORM(WIN) #include <windows.h> #include <winsock2.h> #endif #include <curl/curl.h> namespace WebCore { class CurlDownloadManager { public: CurlDownloadManager(); ~CurlDownloadManager(); bool add(CURL* curlHandle); bool remove(CURL* curlHandle); int getActiveDownloadCount() const; int getPendingDownloadCount() const; private: void startThreadIfNeeded(); void stopThread(); void stopThreadIfIdle(); void updateHandleList(); CURLM* getMultiHandle() const { return m_curlMultiHandle; } bool runThread() const { return m_runThread; } void setRunThread(bool runThread) { m_runThread = runThread; } bool addToCurl(CURL* curlHandle); bool removeFromCurl(CURL* curlHandle); static void downloadThread(void* data); ThreadIdentifier m_threadId; CURLM* m_curlMultiHandle; Vector<CURL*> m_pendingHandleList; Vector<CURL*> m_activeHandleList; Vector<CURL*> m_removedHandleList; mutable Mutex m_mutex; bool m_runThread; }; class CurlDownloadListener { public: virtual void didReceiveResponse() { } virtual void didReceiveDataOfLength(int size) { } virtual void didFinish() { } virtual void didFail() { } }; class CurlDownload { public: CurlDownload(); ~CurlDownload(); void init(CurlDownloadListener*, const WebCore::URL&); void init(CurlDownloadListener*, ResourceHandle*, const ResourceRequest&, const ResourceResponse&); bool start(); bool cancel(); String getTempPath() const; String getUrl() const; WebCore::ResourceResponse getResponse() const; bool deletesFileUponFailure() const { return m_deletesFileUponFailure; } void setDeletesFileUponFailure(bool deletesFileUponFailure) { m_deletesFileUponFailure = deletesFileUponFailure; } void setDestination(const String& destination) { m_destination = destination; } private: void closeFile(); void moveFileToDestination(); void writeDataToFile(const char* data, int size); void addHeaders(const ResourceRequest&); // Called on download thread. void didReceiveHeader(const String& header); void didReceiveData(void* data, int size); // Called on main thread. void didReceiveResponse(); void didReceiveDataOfLength(int size); void didFinish(); void didFail(); static size_t writeCallback(void* ptr, size_t, size_t nmemb, void* data); static size_t headerCallback(char* ptr, size_t, size_t nmemb, void* data); static void downloadFinishedCallback(CurlDownload*); static void downloadFailedCallback(CurlDownload*); static void receivedDataCallback(CurlDownload*, int size); static void receivedResponseCallback(CurlDownload*); CURL* m_curlHandle; struct curl_slist* m_customHeaders; char* m_url; String m_tempPath; String m_destination; WebCore::PlatformFileHandle m_tempHandle; WebCore::ResourceResponse m_response; bool m_deletesFileUponFailure; mutable Mutex m_mutex; CurlDownloadListener *m_listener; static CurlDownloadManager m_downloadManager; friend class CurlDownloadManager; }; } #endif
/* Copyright 2009-2014 Urban Airship 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 binaryform must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided withthe distribution. THIS SOFTWARE IS PROVIDED BY THE URBAN AIRSHIP 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 URBAN AIRSHIP 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. */ #import "UAAction.h" /** * Derivative of UAAction that defines a variant of the performWithArguments method * that returns a UAActionResult synchronously. This is a convenience class intended * for scenarios where an asynchronous completion handler is unnecessary. */ @interface UASyncAction : UAAction /** * Triggers the action synchronously. Subclasses of UASyncAction should override this method to define custom behavior. * * @param arguments An id value representing the arguments passed to the action. * @return UAActionResult for the action */ - (UAActionResult *)performWithArguments:(UAActionArguments *)arguments; @end
/* $NetBSD: compare_name.c,v 1.1.1.1 2011/04/13 18:14:44 elric Exp $ */ /* * Copyright (c) 1997-2003 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * 3. Neither the name of the Institute 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 INSTITUTE 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 INSTITUTE OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include "gsskrb5_locl.h" OM_uint32 GSSAPI_CALLCONV _gsskrb5_compare_name (OM_uint32 * minor_status, const gss_name_t name1, const gss_name_t name2, int * name_equal ) { krb5_const_principal princ1 = (krb5_const_principal)name1; krb5_const_principal princ2 = (krb5_const_principal)name2; krb5_context context; GSSAPI_KRB5_INIT(&context); *name_equal = krb5_principal_compare (context, princ1, princ2); *minor_status = 0; return GSS_S_COMPLETE; }
/*********************************************************************** filename: CEGUITextUtils.h created: 30/5/2004 author: Paul D Turner purpose: Interface to a static class containing some utility functions for text / string operations *************************************************************************/ /*************************************************************************** * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team * * 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 BE LIABLE FOR ANY CLAIM, DAMAGES OR * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. ***************************************************************************/ #ifndef _CEGUITextUtils_h_ #define _CEGUITextUtils_h_ #include "CEGUIBase.h" #include "CEGUIString.h" // Start of CEGUI namespace section namespace CEGUI { /*! \brief Text utility support class. This class is all static members. You do not create instances of this class. */ class CEGUIEXPORT TextUtils { public: /************************************************************************* Constants *************************************************************************/ static const String DefaultWhitespace; //!< The default set of whitespace static const String DefaultAlphanumerical; //!< default set of alphanumericals. static const String DefaultWrapDelimiters; //!< The default set of word-wrap delimiters /************************************************************************* Methods *************************************************************************/ /*! \brief return a String containing the the next word in a String. This method returns a String object containing the the word, starting at index \a start_idx, of String \a str as delimited by the code points specified in string \a delimiters (or the ends of the input string). \param str String object containing the input data. \param start_idx index into \a str where the search for the next word is to begin. Defaults to start of \a str. \param delimiters String object containing the set of delimiter code points to be used when determining the start and end points of a word in string \a str. Defaults to whitespace. \return String object containing the next \a delimiters delimited word from \a str, starting at index \a start_idx. */ static String getNextWord(const String& str, String::size_type start_idx = 0, const String& delimiters = DefaultWhitespace); /*! \brief Return the index of the first character of the word at \a idx. /note This currently uses DefaultWhitespace and DefaultAlphanumerical to determine groupings for what constitutes a 'word'. \param str String containing text. \param idx Index into \a str where search for start of word is to begin. \return Index into \a str which marks the begining of the word at index \a idx. */ static String::size_type getWordStartIdx(const String& str, String::size_type idx); /*! \brief Return the index of the first character of the word after the word at \a idx. /note This currently uses DefaultWhitespace and DefaultAlphanumerical to determine groupings for what constitutes a 'word'. \param str String containing text. \param idx Index into \a str where search is to begin. \return Index into \a str which marks the begining of the word at after the word at index \a idx. If \a idx is within the last word, then the return is the last index in \a str. */ static String::size_type getNextWordStartIdx(const String& str, String::size_type idx); /*! \brief Trim all characters from the set specified in \a chars from the begining of \a str. \param str String object to be trimmed. \param chars String object containing the set of code points to be trimmed. */ static void trimLeadingChars(String& str, const String& chars); /*! \brief Trim all characters from the set specified in \a chars from the end of \a str. \param str String object to be trimmed. \param chars String object containing the set of code points to be trimmed. */ static void trimTrailingChars(String& str, const String& chars); private: /************************************************************************* Data *************************************************************************/ static String d_delimiters; //!< Current set of delimiters. static String d_whitespace; //!< Current set of whitespace. /************************************************************************* Construction / Destruction *************************************************************************/ /*! \brief Constructor and Destructor are private. This class has all static members. */ TextUtils(void); ~TextUtils(void); }; } // End of CEGUI namespace section #endif // end of guard _CEGUITextUtils_h_
#include "ccv.h" #include <sys/time.h> unsigned int get_current_time() { struct timeval tv; gettimeofday(&tv, 0); return tv.tv_sec * 1000 + tv.tv_usec / 1000; } int main(int argc, char** argv) { int i, j; ccv_dense_matrix_t* image = 0; ccv_unserialize(argv[1], &image, CCV_SERIAL_GRAY | CCV_SERIAL_ANY_FILE); ccv_dense_matrix_t* x = 0; unsigned int elapsed_time = get_current_time(); ccv_sobel(image, &x, 0, 0, 1); printf("elpased time : %d\n", get_current_time() - elapsed_time); ccv_dense_matrix_t* imx = ccv_dense_matrix_new(x->rows, x->cols, CCV_8U | CCV_C1, 0, 0); for (i = 0; i < x->rows; i++) for (j = 0; j < x->cols; j++) imx->data.ptr[i * imx->step + j] = ccv_clamp(x->data.i[i * x->cols + j] / 4, 0, 255); int len; ccv_serialize(imx, argv[2], &len, CCV_SERIAL_JPEG_FILE, 0); ccv_matrix_free(image); ccv_matrix_free(x); ccv_matrix_free(imx); ccv_garbage_collect(); return 0; }
/* * Copyright (c) 2010 The WebM project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ #include "vpx_ports/config.h" #include "vpx_ports/arm.h" #include "vp8/common/g_common.h" #include "vp8/common/pragmas.h" #include "vp8/common/subpixel.h" #include "vp8/common/loopfilter.h" #include "vp8/common/recon.h" #include "vp8/common/idct.h" #include "vp8/common/onyxc_int.h" void vp8_arch_arm_common_init(VP8_COMMON *ctx) { #if CONFIG_RUNTIME_CPU_DETECT VP8_COMMON_RTCD *rtcd = &ctx->rtcd; int flags = arm_cpu_caps(); rtcd->flags = flags; /* Override default functions with fastest ones for this CPU. */ #if HAVE_ARMV5TE if (flags & HAS_EDSP) { } #endif #if HAVE_ARMV6 if (flags & HAS_MEDIA) { rtcd->subpix.sixtap16x16 = vp8_sixtap_predict16x16_armv6; rtcd->subpix.sixtap8x8 = vp8_sixtap_predict8x8_armv6; rtcd->subpix.sixtap8x4 = vp8_sixtap_predict8x4_armv6; rtcd->subpix.sixtap4x4 = vp8_sixtap_predict_armv6; rtcd->subpix.bilinear16x16 = vp8_bilinear_predict16x16_armv6; rtcd->subpix.bilinear8x8 = vp8_bilinear_predict8x8_armv6; rtcd->subpix.bilinear8x4 = vp8_bilinear_predict8x4_armv6; rtcd->subpix.bilinear4x4 = vp8_bilinear_predict4x4_armv6; rtcd->idct.idct1 = vp8_short_idct4x4llm_1_v6; rtcd->idct.idct16 = vp8_short_idct4x4llm_v6_dual; rtcd->idct.iwalsh1 = vp8_short_inv_walsh4x4_1_v6; rtcd->idct.iwalsh16 = vp8_short_inv_walsh4x4_v6; rtcd->loopfilter.normal_mb_v = vp8_loop_filter_mbv_armv6; rtcd->loopfilter.normal_b_v = vp8_loop_filter_bv_armv6; rtcd->loopfilter.normal_mb_h = vp8_loop_filter_mbh_armv6; rtcd->loopfilter.normal_b_h = vp8_loop_filter_bh_armv6; rtcd->loopfilter.simple_mb_v = vp8_loop_filter_simple_vertical_edge_armv6; rtcd->loopfilter.simple_b_v = vp8_loop_filter_bvs_armv6; rtcd->loopfilter.simple_mb_h = vp8_loop_filter_simple_horizontal_edge_armv6; rtcd->loopfilter.simple_b_h = vp8_loop_filter_bhs_armv6; rtcd->recon.copy16x16 = vp8_copy_mem16x16_v6; rtcd->recon.copy8x8 = vp8_copy_mem8x8_v6; rtcd->recon.copy8x4 = vp8_copy_mem8x4_v6; rtcd->recon.recon = vp8_recon_b_armv6; rtcd->recon.recon2 = vp8_recon2b_armv6; rtcd->recon.recon4 = vp8_recon4b_armv6; } #endif #if HAVE_ARMV7 if (flags & HAS_NEON) { rtcd->subpix.sixtap16x16 = vp8_sixtap_predict16x16_neon; rtcd->subpix.sixtap8x8 = vp8_sixtap_predict8x8_neon; rtcd->subpix.sixtap8x4 = vp8_sixtap_predict8x4_neon; rtcd->subpix.sixtap4x4 = vp8_sixtap_predict_neon; rtcd->subpix.bilinear16x16 = vp8_bilinear_predict16x16_neon; rtcd->subpix.bilinear8x8 = vp8_bilinear_predict8x8_neon; rtcd->subpix.bilinear8x4 = vp8_bilinear_predict8x4_neon; rtcd->subpix.bilinear4x4 = vp8_bilinear_predict4x4_neon; rtcd->idct.idct1 = vp8_short_idct4x4llm_1_neon; rtcd->idct.idct16 = vp8_short_idct4x4llm_neon; rtcd->idct.iwalsh1 = vp8_short_inv_walsh4x4_1_neon; rtcd->idct.iwalsh16 = vp8_short_inv_walsh4x4_neon; rtcd->loopfilter.normal_mb_v = vp8_loop_filter_mbv_neon; rtcd->loopfilter.normal_b_v = vp8_loop_filter_bv_neon; rtcd->loopfilter.normal_mb_h = vp8_loop_filter_mbh_neon; rtcd->loopfilter.normal_b_h = vp8_loop_filter_bh_neon; rtcd->loopfilter.simple_mb_v = vp8_loop_filter_mbvs_neon; rtcd->loopfilter.simple_b_v = vp8_loop_filter_bvs_neon; rtcd->loopfilter.simple_mb_h = vp8_loop_filter_mbhs_neon; rtcd->loopfilter.simple_b_h = vp8_loop_filter_bhs_neon; rtcd->recon.copy16x16 = vp8_copy_mem16x16_neon; rtcd->recon.copy8x8 = vp8_copy_mem8x8_neon; rtcd->recon.copy8x4 = vp8_copy_mem8x4_neon; rtcd->recon.recon = vp8_recon_b_neon; rtcd->recon.recon2 = vp8_recon2b_neon; rtcd->recon.recon4 = vp8_recon4b_neon; rtcd->recon.recon_mb = vp8_recon_mb_neon; rtcd->recon.build_intra_predictors_mby = vp8_build_intra_predictors_mby_neon; rtcd->recon.build_intra_predictors_mby_s = vp8_build_intra_predictors_mby_s_neon; } #endif #endif }
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE121_Stack_Based_Buffer_Overflow__src_char_declare_cat_12.c Label Definition File: CWE121_Stack_Based_Buffer_Overflow__src.label.xml Template File: sources-sink-12.tmpl.c */ /* * @description * CWE: 121 Stack Based Buffer Overflow * BadSource: Initialize data as a large string * GoodSource: Initialize data as a small string * Sink: cat * BadSink : Copy data to string using strcat * Flow Variant: 12 Control flow: if(globalReturnsTrueOrFalse()) * * */ #include "std_testcase.h" #include <wchar.h> #ifndef OMITBAD void CWE121_Stack_Based_Buffer_Overflow__src_char_declare_cat_12_bad() { char * data; char dataBuffer[100]; data = dataBuffer; if(globalReturnsTrueOrFalse()) { /* FLAW: Initialize data as a large buffer that is larger than the small buffer used in the sink */ memset(data, 'A', 100-1); /* fill with 'A's */ data[100-1] = '\0'; /* null terminate */ } else { /* FIX: Initialize data as a small buffer that as small or smaller than the small buffer used in the sink */ memset(data, 'A', 50-1); /* fill with 'A's */ data[50-1] = '\0'; /* null terminate */ } { char dest[50] = ""; /* POTENTIAL FLAW: Possible buffer overflow if data is larger than sizeof(dest)-strlen(dest)*/ strcat(dest, data); printLine(data); } } #endif /* OMITBAD */ #ifndef OMITGOOD /* goodG2B() - use goodsource and badsink by changing the "if" so that * both branches use the GoodSource */ static void goodG2B() { char * data; char dataBuffer[100]; data = dataBuffer; if(globalReturnsTrueOrFalse()) { /* FIX: Initialize data as a small buffer that as small or smaller than the small buffer used in the sink */ memset(data, 'A', 50-1); /* fill with 'A's */ data[50-1] = '\0'; /* null terminate */ } else { /* FIX: Initialize data as a small buffer that as small or smaller than the small buffer used in the sink */ memset(data, 'A', 50-1); /* fill with 'A's */ data[50-1] = '\0'; /* null terminate */ } { char dest[50] = ""; /* POTENTIAL FLAW: Possible buffer overflow if data is larger than sizeof(dest)-strlen(dest)*/ strcat(dest, data); printLine(data); } } void CWE121_Stack_Based_Buffer_Overflow__src_char_declare_cat_12_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__src_char_declare_cat_12_good(); printLine("Finished good()"); #endif /* OMITGOOD */ #ifndef OMITBAD printLine("Calling bad()..."); CWE121_Stack_Based_Buffer_Overflow__src_char_declare_cat_12_bad(); printLine("Finished bad()"); #endif /* OMITBAD */ return 0; } #endif
/**************************************************************************** * * Copyright (c) 2012-2015 PX4 Development Team. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * 3. Neither the name PX4 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. * ****************************************************************************/ /** * @file s2740vc_init.c * * S2740VCv1-specific early startup code. This file implements the * board_app_initialize() function that is called early by nsh during startup. * * Code here is run before the rcS script is invoked; it should start required * subsystems and perform board-specific initialization. */ /**************************************************************************** * Included Files ****************************************************************************/ #include <px4_config.h> #include <stdbool.h> #include <stdio.h> #include <debug.h> #include <errno.h> #include <nuttx/board.h> #include <nuttx/spi/spi.h> #include <nuttx/i2c/i2c_master.h> #include <nuttx/mmcsd.h> #include <nuttx/analog/adc.h> #include <stm32.h> #include "board_config.h" #include "stm32_uart.h" #include <arch/board/board.h> #include <drivers/drv_hrt.h> #include <drivers/drv_board_led.h> #include <px4_init.h> #if defined(CONFIG_HAVE_CXX) && defined(CONFIG_HAVE_CXXINITIALIZE) #endif #include "board_config.h" /* todo: This is constant but not proper */ __BEGIN_DECLS extern void led_off(int led); __END_DECLS /**************************************************************************** * Pre-Processor Definitions ****************************************************************************/ /* Configuration ************************************************************/ /* Debug ********************************************************************/ /**************************************************************************** * Protected Functions ****************************************************************************/ /**************************************************************************** * Public Functions ****************************************************************************/ /************************************************************************************ * Name: stm32_boardinitialize * * Description: * All STM32 architectures must provide the following entry point. This entry point * is called early in the initialization -- after all memory has been configured * and mapped but before any devices have been initialized. * ************************************************************************************/ __EXPORT void stm32_boardinitialize(void) { stm32_configgpio(GPIO_CAN_SILENT); } __EXPORT void board_initialize(void) { } /**************************************************************************** * Name: board_app_initialize * * Description: * Perform application specific initialization. This function is never * called directly from application code, but only indirectly via the * (non-standard) boardctl() interface using the command BOARDIOC_INIT. * * Input Parameters: * arg - The boardctl() argument is passed to the board_app_initialize() * implementation without modification. The argument has no * meaning to NuttX; the meaning of the argument is a contract * between the board-specific initalization logic and the the * matching application logic. The value cold be such things as a * mode enumeration value, a set of DIP switch switch settings, a * pointer to configuration data read from a file or serial FLASH, * or whatever you would like to do with it. Every implementation * should accept zero/NULL as a default configuration. * * Returned Value: * Zero (OK) is returned on success; a negated errno value is returned on * any failure to indicate the nature of the failure. * ****************************************************************************/ __EXPORT int board_app_initialize(uintptr_t arg) { int result = OK; px4_platform_init(); /* set up the serial DMA polling */ static struct hrt_call serial_dma_call; struct timespec ts; /* * Poll at 1ms intervals for received bytes that have not triggered * a DMA event. */ ts.tv_sec = 0; ts.tv_nsec = 1000000; hrt_call_every(&serial_dma_call, ts_to_abstime(&ts), ts_to_abstime(&ts), (hrt_callout)stm32_serial_dma_poll, NULL); return result; }
// Copyright 2021 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_VIEWS_SEND_TAB_TO_SELF_SEND_TAB_TO_SELF_TOOLBAR_ICON_VIEW_H_ #define CHROME_BROWSER_UI_VIEWS_SEND_TAB_TO_SELF_SEND_TAB_TO_SELF_TOOLBAR_ICON_VIEW_H_ #include "chrome/browser/ui/send_tab_to_self/send_tab_to_self_toolbar_icon_controller_delegate.h" #include "components/send_tab_to_self/send_tab_to_self_entry.h" #include "ui/base/metadata/metadata_header_macros.h" #include "ui/views/controls/image_view.h" class Browser; class BrowserView; namespace send_tab_to_self { // STTS icon shown in the trusted area of toolbar. Its lifetime is tied to that // of its parent ToolbarView. The icon is made visible when there is a received // STTS notification. class SendTabToSelfToolbarIconView : public views::ImageView, public SendTabToSelfToolbarIconControllerDelegate { public: explicit SendTabToSelfToolbarIconView(BrowserView* browser_view); SendTabToSelfToolbarIconView(const SendTabToSelfToolbarIconView&) = delete; SendTabToSelfToolbarIconView& operator=(const SendTabToSelfToolbarIconView&) = delete; ~SendTabToSelfToolbarIconView() override; // SendTabToSelfToolbarIconControllerDelegate implementation. void Show(const SendTabToSelfEntry& entry) override; bool IsActive() override; void DismissEntry(std::string& guid); void LogNotificationOpened(); void LogNotificationDismissed(); private: const Browser* const browser_; const BrowserView* browser_view_; const SendTabToSelfEntry* entry_; }; } // namespace send_tab_to_self #endif // CHROME_BROWSER_UI_VIEWS_SEND_TAB_TO_SELF_SEND_TAB_TO_SELF_TOOLBAR_ICON_VIEW_H_
/*========================================================================= Program: Visualization Toolkit Module: vtkGPUInfo.h Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen All rights reserved. See Copyright.txt or http://www.kitware.com/Copyright.htm for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notice for more information. =========================================================================*/ // .NAME vtkGPUInfo - Stores GPU VRAM information. // .SECTION Description // vtkGPUInfo stores information about GPU Video RAM. An host can have // several GPUs. The values are set by vtkGPUInfoList. // .SECTION See Also // vtkGPUInfoList vtkDirectXGPUInfoList vtkCoreGraphicsGPUInfoList #ifndef __vtkGPUInfo_h #define __vtkGPUInfo_h #include "vtkRenderingCoreModule.h" // For export macro #include "vtkObject.h" class VTKRENDERINGCORE_EXPORT vtkGPUInfo : public vtkObject { public: static vtkGPUInfo* New(); vtkTypeMacro(vtkGPUInfo, vtkObject); void PrintSelf(ostream& os, vtkIndent indent); // Description: // Set/Get dedicated video memory in bytes. Initial value is 0. // Usually the fastest one. If it is not null, it should be take into // account first and DedicatedSystemMemory or SharedSystemMemory should be // ignored. vtkSetMacro(DedicatedVideoMemory,vtkIdType); vtkGetMacro(DedicatedVideoMemory,vtkIdType); // Description: // Set/Get dedicated system memory in bytes. Initial value is 0. // This is slow memory. If it is not null, this value should be taken into // account only if there is no DedicatedVideoMemory and SharedSystemMemory // should be ignored. vtkSetMacro(DedicatedSystemMemory,vtkIdType); vtkGetMacro(DedicatedSystemMemory,vtkIdType); // Description: // Set/Get shared system memory in bytes. Initial value is 0. // Slowest memory. This value should be taken into account only if there is // neither DedicatedVideoMemory nor DedicatedSystemMemory. vtkSetMacro(SharedSystemMemory,vtkIdType); vtkGetMacro(SharedSystemMemory,vtkIdType); protected: vtkGPUInfo(); ~vtkGPUInfo(); vtkIdType DedicatedVideoMemory; vtkIdType DedicatedSystemMemory; vtkIdType SharedSystemMemory; private: vtkGPUInfo(const vtkGPUInfo&); // Not implemented. void operator=(const vtkGPUInfo&); // Not implemented. }; #endif
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE761_Free_Pointer_Not_at_Start_of_Buffer__wchar_t_connect_socket_64b.c Label Definition File: CWE761_Free_Pointer_Not_at_Start_of_Buffer.label.xml Template File: source-sinks-64b.tmpl.c */ /* * @description * CWE: 761 Free Pointer not at Start of Buffer * BadSource: connect_socket Read data using a connect socket (client side) * Sinks: * GoodSink: free() memory correctly at the start of the buffer * BadSink : free() memory not at the start of the buffer * Flow Variant: 64 Data flow: void pointer to data passed from one function to another in different source files * * */ #include "std_testcase.h" #include <wchar.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 #define IP_ADDRESS "127.0.0.1" #define SEARCH_CHAR L'S' #ifndef OMITBAD void CWE761_Free_Pointer_Not_at_Start_of_Buffer__wchar_t_connect_socket_64b_badSink(void * dataVoidPtr) { /* cast void pointer to a pointer of the appropriate type */ wchar_t * * dataPtr = (wchar_t * *)dataVoidPtr; /* dereference dataPtr into data */ wchar_t * data = (*dataPtr); /* FLAW: We are incrementing the pointer in the loop - this will cause us to free the * memory block not at the start of the buffer */ for (; *data != L'\0'; data++) { if (*data == SEARCH_CHAR) { printLine("We have a match!"); break; } } free(data); } #endif /* OMITBAD */ #ifndef OMITGOOD /* goodB2G uses the BadSource with the GoodSink */ void CWE761_Free_Pointer_Not_at_Start_of_Buffer__wchar_t_connect_socket_64b_goodB2GSink(void * dataVoidPtr) { /* cast void pointer to a pointer of the appropriate type */ wchar_t * * dataPtr = (wchar_t * *)dataVoidPtr; /* dereference dataPtr into data */ wchar_t * data = (*dataPtr); { size_t i; /* FIX: Use a loop variable to traverse through the string pointed to by data */ for (i=0; i < wcslen(data); i++) { if (data[i] == SEARCH_CHAR) { printLine("We have a match!"); break; } } free(data); } } #endif /* OMITGOOD */
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE191_Integer_Underflow__unsigned_int_rand_sub_65a.c Label Definition File: CWE191_Integer_Underflow.label.xml Template File: sources-sinks-65a.tmpl.c */ /* * @description * CWE: 191 Integer Underflow * BadSource: rand Set data to result of rand() * GoodSource: Set data to a small, non-zero number (negative two) * Sinks: sub * GoodSink: Ensure there will not be an underflow before subtracting 1 from data * BadSink : Subtract 1 from data, which can cause an Underflow * Flow Variant: 65 Data/control flow: data passed as an argument from one function to a function in a different source file called via a function pointer * * */ #include "std_testcase.h" #ifndef OMITBAD /* bad function declaration */ void CWE191_Integer_Underflow__unsigned_int_rand_sub_65b_badSink(unsigned int data); void CWE191_Integer_Underflow__unsigned_int_rand_sub_65_bad() { unsigned int data; /* define a function pointer */ void (*funcPtr) (unsigned int) = CWE191_Integer_Underflow__unsigned_int_rand_sub_65b_badSink; data = 0; /* POTENTIAL FLAW: Use a random value */ data = (unsigned int)RAND32(); /* use the function pointer */ funcPtr(data); } #endif /* OMITBAD */ #ifndef OMITGOOD /* goodG2B uses the GoodSource with the BadSink */ void CWE191_Integer_Underflow__unsigned_int_rand_sub_65b_goodG2BSink(unsigned int data); static void goodG2B() { unsigned int data; void (*funcPtr) (unsigned int) = CWE191_Integer_Underflow__unsigned_int_rand_sub_65b_goodG2BSink; data = 0; /* FIX: Use a small, non-zero value that will not cause an underflow in the sinks */ data = -2; funcPtr(data); } /* goodB2G uses the BadSource with the GoodSink */ void CWE191_Integer_Underflow__unsigned_int_rand_sub_65b_goodB2GSink(unsigned int data); static void goodB2G() { unsigned int data; void (*funcPtr) (unsigned int) = CWE191_Integer_Underflow__unsigned_int_rand_sub_65b_goodB2GSink; data = 0; /* POTENTIAL FLAW: Use a random value */ data = (unsigned int)RAND32(); funcPtr(data); } void CWE191_Integer_Underflow__unsigned_int_rand_sub_65_good() { goodG2B(); goodB2G(); } #endif /* OMITGOOD */ /* Below is the main(). It is only used when building this testcase on its own for testing or for building a binary to use in testing binary analysis tools. It is not used when compiling all the testcases as one application, which is how source code analysis tools are tested. */ #ifdef INCLUDEMAIN int main(int argc, char * argv[]) { /* seed randomness */ srand( (unsigned)time(NULL) ); #ifndef OMITGOOD printLine("Calling good()..."); CWE191_Integer_Underflow__unsigned_int_rand_sub_65_good(); printLine("Finished good()"); #endif /* OMITGOOD */ #ifndef OMITBAD printLine("Calling bad()..."); CWE191_Integer_Underflow__unsigned_int_rand_sub_65_bad(); printLine("Finished bad()"); #endif /* OMITBAD */ return 0; } #endif
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE761_Free_Pointer_Not_at_Start_of_Buffer__wchar_t_fixed_string_51b.c Label Definition File: CWE761_Free_Pointer_Not_at_Start_of_Buffer.label.xml Template File: source-sinks-51b.tmpl.c */ /* * @description * CWE: 761 Free Pointer not at Start of Buffer * BadSource: fixed_string Initialize data to be a fixed string * Sinks: * GoodSink: free() memory correctly at the start of the buffer * BadSink : free() memory not at the start of the buffer * Flow Variant: 51 Data flow: data passed as an argument from one function to another in different source files * * */ #include "std_testcase.h" #include <wchar.h> #define BAD_SOURCE_FIXED_STRING L"Fixed String" /* MAINTENANCE NOTE: This string must contain the SEARCH_CHAR */ #define SEARCH_CHAR L'S' #ifndef OMITBAD void CWE761_Free_Pointer_Not_at_Start_of_Buffer__wchar_t_fixed_string_51b_badSink(wchar_t * data) { /* FLAW: We are incrementing the pointer in the loop - this will cause us to free the * memory block not at the start of the buffer */ for (; *data != L'\0'; data++) { if (*data == SEARCH_CHAR) { printLine("We have a match!"); break; } } free(data); } #endif /* OMITBAD */ #ifndef OMITGOOD void CWE761_Free_Pointer_Not_at_Start_of_Buffer__wchar_t_fixed_string_51b_goodB2GSink(wchar_t * data) { { size_t i; /* FIX: Use a loop variable to traverse through the string pointed to by data */ for (i=0; i < wcslen(data); i++) { if (data[i] == SEARCH_CHAR) { printLine("We have a match!"); break; } } free(data); } } #endif /* OMITGOOD */
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE789_Uncontrolled_Mem_Alloc__new_wchar_t_rand_81.h Label Definition File: CWE789_Uncontrolled_Mem_Alloc__new.label.xml Template File: sources-sinks-81.tmpl.h */ /* * @description * CWE: 789 Uncontrolled Memory Allocation * BadSource: rand Set data to result of rand(), which may be zero * GoodSource: Small number greater than zero * Sinks: * GoodSink: Allocate memory with new [] and check the size of the memory to be allocated * BadSink : Allocate memory with new [], but incorrectly check the size of the memory to be allocated * Flow Variant: 81 Data flow: data passed in a parameter to an virtual method called via a reference * * */ #include "std_testcase.h" #ifndef _WIN32 #include <wchar.h> #endif namespace CWE789_Uncontrolled_Mem_Alloc__new_wchar_t_rand_81 { class CWE789_Uncontrolled_Mem_Alloc__new_wchar_t_rand_81_base { public: /* pure virtual function */ virtual void action(size_t data) const = 0; }; #ifndef OMITBAD class CWE789_Uncontrolled_Mem_Alloc__new_wchar_t_rand_81_bad : public CWE789_Uncontrolled_Mem_Alloc__new_wchar_t_rand_81_base { public: void action(size_t data) const; }; #endif /* OMITBAD */ #ifndef OMITGOOD class CWE789_Uncontrolled_Mem_Alloc__new_wchar_t_rand_81_goodG2B : public CWE789_Uncontrolled_Mem_Alloc__new_wchar_t_rand_81_base { public: void action(size_t data) const; }; class CWE789_Uncontrolled_Mem_Alloc__new_wchar_t_rand_81_goodB2G : public CWE789_Uncontrolled_Mem_Alloc__new_wchar_t_rand_81_base { public: void action(size_t data) const; }; #endif /* OMITGOOD */ }
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE194_Unexpected_Sign_Extension__negative_memmove_42.c Label Definition File: CWE194_Unexpected_Sign_Extension.label.xml Template File: sources-sink-42.tmpl.c */ /* * @description * CWE: 194 Unexpected Sign Extension * BadSource: negative Set data to a fixed negative number * GoodSource: Positive integer * Sink: memmove * BadSink : Copy strings using memmove() with the length of data * Flow Variant: 42 Data flow: data returned from one function to another in the same source file * * */ #include "std_testcase.h" #ifndef OMITBAD static short badSource(short data) { /* FLAW: Use a negative number */ data = -1; return data; } void CWE194_Unexpected_Sign_Extension__negative_memmove_42_bad() { short data; /* Initialize data */ data = 0; data = badSource(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 static short goodG2BSource(short data) { /* FIX: Use a positive integer less than &InitialDataSize&*/ data = 100-1; return data; } /* goodG2B uses the GoodSource with the BadSink */ static void goodG2B() { short data; /* Initialize data */ data = 0; data = goodG2BSource(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); } } void CWE194_Unexpected_Sign_Extension__negative_memmove_42_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()..."); CWE194_Unexpected_Sign_Extension__negative_memmove_42_good(); printLine("Finished good()"); #endif /* OMITGOOD */ #ifndef OMITBAD printLine("Calling bad()..."); CWE194_Unexpected_Sign_Extension__negative_memmove_42_bad(); printLine("Finished bad()"); #endif /* OMITBAD */ return 0; } #endif
/*============================================================================ The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center (DKFZ) All rights reserved. Use of this source code is governed by a 3-clause BSD license that can be found in the LICENSE file. ============================================================================*/ #ifndef LegacyFileWriterService_H_HEADER_INCLUDED_C1E7E521 #define LegacyFileWriterService_H_HEADER_INCLUDED_C1E7E521 #include <mitkAbstractFileWriter.h> #include <mitkFileWriter.h> namespace mitk { class LegacyFileWriterService : public mitk::AbstractFileWriter { public: LegacyFileWriterService(mitk::FileWriter::Pointer legacyWriter, const std::string &description); ~LegacyFileWriterService() override; using AbstractFileWriter::Write; void Write() override; ConfidenceLevel GetConfidenceLevel() const override; private: LegacyFileWriterService *Clone() const override; mitk::FileWriter::Pointer m_LegacyWriter; us::ServiceRegistration<IFileWriter> m_ServiceRegistration; }; } // namespace mitk #endif /* LegacyFileWriterService_H_HEADER_INCLUDED_C1E7E521 */
/* * Copyright (C) 2006, 2010 Apple Inc. All rights reserved. * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/) * 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: * 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 BackForwardClient_h #define BackForwardClient_h #include "wtf/PassRefPtr.h" namespace blink { class HistoryItem; class BackForwardClient { public: virtual ~BackForwardClient() { } virtual int backListCount() = 0; virtual int forwardListCount() = 0; virtual int backForwardListCount() = 0; }; } // namespace blink #endif // BackForwardClient_h
#ifndef SQL_H #define SQL_H #include <QObject> #include <QtSql> #include <QJsonDocument> #include <QJsonObject> #include <QJsonArray> #include <QJsonParseError> class adhigunasql : public QObject { Q_OBJECT public: explicit adhigunasql(QObject *parent = 0); //QSqlQuery qry; QSqlDatabase db; signals: //void record_sig(bool err,const QByteArray& data); //void record(bool err,const QByteArray& data); public slots: bool driver(const QString& drv, QString connect); QVariant query(const QString& qr); //void record_slot(bool err,const QByteArray& data); }; #endif // SQL_H
/*========================================================================= Program: Visualization Toolkit Module: vtkXMLHyperOctreeWriter.h Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen All rights reserved. See Copyright.txt or http://www.kitware.com/Copyright.htm for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notice for more information. =========================================================================*/ // .NAME vtkXMLHyperOctreeWriter - Write VTK XML HyperOctree files. // .SECTION Description // vtkXMLHyperOctreeWriter writes the VTK XML HyperOctree file // format. One HyperOctree input can be written into one file in // any number of streamed pieces. The standard extension for this // writer's file format is "vto". This writer is also used to write a // single piece of the parallel file format. // .SECTION See Also // vtkXMLPHyperOctreeWriter #ifndef __vtkXMLHyperOctreeWriter_h #define __vtkXMLHyperOctreeWriter_h #include "vtkIOXMLModule.h" // For export macro #include "vtkXMLWriter.h" class vtkHyperOctree; class vtkHyperOctreeCursor; class vtkIntArray; class VTKIOXML_EXPORT vtkXMLHyperOctreeWriter : public vtkXMLWriter { public: vtkTypeMacro(vtkXMLHyperOctreeWriter,vtkXMLWriter); void PrintSelf(ostream& os, vtkIndent indent); static vtkXMLHyperOctreeWriter* New(); //BTX // Description: // Get/Set the writer's input. vtkHyperOctree* GetInput(); //ETX // Description: // Get the default file extension for files written by this writer. const char* GetDefaultFileExtension(); protected: vtkXMLHyperOctreeWriter(); ~vtkXMLHyperOctreeWriter(); const char* GetDataSetName(); // specify that we require HyperOctree input virtual int FillInputPortInformation(int port, vtkInformation* info); //The most important method, make the XML file for my input. int WriteData(); //<HyperOctree ... int StartPrimElement(vtkIndent); //... dim, size, origin> void WritePrimaryElementAttributes(ostream &, vtkIndent); //Tree Structure int WriteTopology(vtkIndent); //Used by WriteTopology to make and array from the Tree structure recursively void SerializeTopology(vtkHyperOctreeCursor *, int); //Writes PointData and CellData attribute data. int WriteAttributeData(vtkIndent); //</HyperOctree> int FinishPrimElement(vtkIndent); //For appended mode placekeeping vtkIntArray *TopologyArray; unsigned long TopoOffset; OffsetsManagerGroup * TopologyOM; OffsetsManagerGroup * PointDataOM; OffsetsManagerGroup * CellDataOM; private: vtkXMLHyperOctreeWriter(const vtkXMLHyperOctreeWriter&); // Not implemented. void operator=(const vtkXMLHyperOctreeWriter&); // Not implemented. }; #endif
/* * * 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. * */ #include "test/core/end2end/end2end_tests.h" #include <stdio.h> #include <string.h> #include "src/core/channel/channel_args.h" #include "src/core/security/credentials.h" #include <grpc/support/alloc.h> #include <grpc/support/host_port.h> #include <grpc/support/log.h> #include "test/core/util/test_config.h" #include "test/core/util/port.h" #include "test/core/end2end/data/ssl_test_data.h" typedef struct fullstack_secure_fixture_data { char *localaddr; } fullstack_secure_fixture_data; static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack( grpc_channel_args *client_args, grpc_channel_args *server_args) { grpc_end2end_test_fixture f; int port = grpc_pick_unused_port_or_die(); fullstack_secure_fixture_data *ffd = gpr_malloc(sizeof(fullstack_secure_fixture_data)); memset(&f, 0, sizeof(f)); gpr_join_host_port(&ffd->localaddr, "localhost", port); f.fixture_data = ffd; f.client_cq = grpc_completion_queue_create(); f.server_cq = grpc_completion_queue_create(); return f; } static void chttp2_init_client_secure_fullstack(grpc_end2end_test_fixture *f, grpc_channel_args *client_args, grpc_credentials *creds) { fullstack_secure_fixture_data *ffd = f->fixture_data; f->client = grpc_secure_channel_create(creds, ffd->localaddr, client_args); GPR_ASSERT(f->client != NULL); grpc_credentials_release(creds); } static void chttp2_init_server_secure_fullstack( grpc_end2end_test_fixture *f, grpc_channel_args *server_args, grpc_server_credentials *server_creds) { fullstack_secure_fixture_data *ffd = f->fixture_data; if (f->server) { grpc_server_destroy(f->server); } f->server = grpc_server_create(server_args); grpc_server_register_completion_queue(f->server, f->server_cq); GPR_ASSERT(grpc_server_add_secure_http2_port(f->server, ffd->localaddr, server_creds)); grpc_server_credentials_release(server_creds); grpc_server_start(f->server); } void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture *f) { fullstack_secure_fixture_data *ffd = f->fixture_data; gpr_free(ffd->localaddr); gpr_free(ffd); } static void chttp2_init_client_fake_secure_fullstack( grpc_end2end_test_fixture *f, grpc_channel_args *client_args) { grpc_credentials *fake_ts_creds = grpc_fake_transport_security_credentials_create(); chttp2_init_client_secure_fullstack(f, client_args, fake_ts_creds); } static void chttp2_init_server_fake_secure_fullstack( grpc_end2end_test_fixture *f, grpc_channel_args *server_args) { grpc_server_credentials *fake_ts_creds = grpc_fake_transport_security_server_credentials_create(); chttp2_init_server_secure_fullstack(f, server_args, fake_ts_creds); } /* All test configurations */ static grpc_end2end_test_config configs[] = { {"chttp2/fake_secure_fullstack", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | FEATURE_MASK_SUPPORTS_PER_CALL_CREDENTIALS, chttp2_create_fixture_secure_fullstack, chttp2_init_client_fake_secure_fullstack, chttp2_init_server_fake_secure_fullstack, chttp2_tear_down_secure_fullstack}, }; int main(int argc, char **argv) { size_t i; grpc_test_init(argc, argv); grpc_init(); for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) { grpc_end2end_tests(configs[i]); } grpc_shutdown(); return 0; }
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE134_Uncontrolled_Format_String__wchar_t_connect_socket_vfprintf_67b.c Label Definition File: CWE134_Uncontrolled_Format_String.vasinks.label.xml Template File: sources-vasinks-67b.tmpl.c */ /* * @description * CWE: 134 Uncontrolled Format String * BadSource: connect_socket Read data using a connect socket (client side) * GoodSource: Copy a fixed string into data * Sinks: vfprintf * GoodSink: vfwprintf with a format string * BadSink : vfwprintf without a format string * Flow Variant: 67 Data flow: data passed in a struct from one function to another in different source files * * */ #include <stdarg.h> #include "std_testcase.h" #ifndef _WIN32 #include <wchar.h> #endif #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 #define IP_ADDRESS "127.0.0.1" typedef struct _CWE134_Uncontrolled_Format_String__wchar_t_connect_socket_vfprintf_67_structType { wchar_t * structFirst; } CWE134_Uncontrolled_Format_String__wchar_t_connect_socket_vfprintf_67_structType; #ifndef OMITBAD static void badVaSink(wchar_t * data, ...) { { va_list args; va_start(args, data); /* POTENTIAL FLAW: Do not specify the format allowing a possible format string vulnerability */ vfwprintf(stdout, data, args); va_end(args); } } void CWE134_Uncontrolled_Format_String__wchar_t_connect_socket_vfprintf_67b_badSink(CWE134_Uncontrolled_Format_String__wchar_t_connect_socket_vfprintf_67_structType myStruct) { wchar_t * data = myStruct.structFirst; badVaSink(data, data); } #endif /* OMITBAD */ #ifndef OMITGOOD /* goodG2B uses the GoodSource with the BadSink */ static void goodG2BVaSink(wchar_t * data, ...) { { va_list args; va_start(args, data); /* POTENTIAL FLAW: Do not specify the format allowing a possible format string vulnerability */ vfwprintf(stdout, data, args); va_end(args); } } void CWE134_Uncontrolled_Format_String__wchar_t_connect_socket_vfprintf_67b_goodG2BSink(CWE134_Uncontrolled_Format_String__wchar_t_connect_socket_vfprintf_67_structType myStruct) { wchar_t * data = myStruct.structFirst; goodG2BVaSink(data, data); } /* goodB2G uses the BadSource with the GoodSink */ static void goodB2GVaSink(wchar_t * data, ...) { { va_list args; va_start(args, data); /* FIX: Specify the format disallowing a format string vulnerability */ vfwprintf(stdout, L"%s", args); va_end(args); } } void CWE134_Uncontrolled_Format_String__wchar_t_connect_socket_vfprintf_67b_goodB2GSink(CWE134_Uncontrolled_Format_String__wchar_t_connect_socket_vfprintf_67_structType myStruct) { wchar_t * data = myStruct.structFirst; goodB2GVaSink(data, data); } #endif /* OMITGOOD */
/* * Copyright (c) The Shogun Machine Learning Toolbox * Written (w) 2014 Parijat Mazumdar * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * The views and conclusions contained in the software and documentation are those * of the authors and should not be interpreted as representing official policies, * either expressed or implied, of the Shogun Development Team. */ #ifndef ID3TREENODEDATA_H__ #define ID3TREENODEDATA_H__ #include <shogun/lib/config.h> namespace shogun { /** @brief structure to store data of a node of * id3 tree. This can be used as a template type in * TreeMachineNode class. Ex: id3 algorithm uses nodes * of type TreeMachineNode<id3TreeNodeData> */ struct id3TreeNodeData { /** classifying attribute */ int32_t attribute_id; /** feature value required to move into this node */ float64_t transit_if_feature_value; /** class label of data (-1 for internal nodes) */ float64_t class_label; /** total weight of training samples passing through this node **/ float64_t total_weight; float64_t impurity; /** constructor */ id3TreeNodeData() { attribute_id=-1; transit_if_feature_value=-1.0; class_label=-1.0; impurity = 0; total_weight = 0.; } }; template<class T> constexpr void register_params(id3TreeNodeData& n, T* o) { o->watch_param("attribute_id", &n.attribute_id, AnyParameterProperties("classifying feature index")); o->watch_param("transit_if_feature_value", &n.transit_if_feature_value, AnyParameterProperties("distinct feature values possible for attribute_id")); o->watch_param("class_label", &n.class_label, AnyParameterProperties("class label of data (-1 for internal nodes)")); } } /* shogun */ #endif /* ID3TREENODEDATA_H__ */
// Copyright (c) 2009 Aurelio Lucchesi // For information on usage and redistribution, and for a DISCLAIMER OF ALL // WARRANTIES, see the file "LICENSE.txt" in this distribution. // // OpReducer.h #ifndef _OP_REDUCER_H_ #define _OP_REDUCER_H_ #include "OpDEF.h" #include "Op.h" #ifdef OP_INC_OP_REDUCER // Reducer //////////////////////////////////////////////////////////////////////////////// class COpReducer : public COp { public: COpReducer(); virtual ~COpReducer(); public: virtual void Proc(); OP_GENERIC_COPY_CTOR_DEC( COpReducer ) OP_GENERIC_METHODS_DEC( COpReducer ) }; #endif // OP_INC_OP_REDUCER #endif // _OP_REDUCER_H_
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE191_Integer_Underflow__int_fscanf_multiply_07.c Label Definition File: CWE191_Integer_Underflow__int.label.xml Template File: sources-sinks-07.tmpl.c */ /* * @description * CWE: 191 Integer Underflow * BadSource: fscanf Read data from the console using fscanf() * GoodSource: Set data to a small, non-zero number (negative two) * Sinks: multiply * GoodSink: Ensure there will not be an underflow before multiplying data by 2 * BadSink : If data is negative, multiply by 2, which can cause an underflow * Flow Variant: 07 Control flow: if(staticFive==5) and if(staticFive!=5) * * */ #include "std_testcase.h" /* The variable below is not declared "const", but is never assigned any other value so a tool should be able to identify that reads of this will always give its initialized value. */ static int staticFive = 5; #ifndef OMITBAD void CWE191_Integer_Underflow__int_fscanf_multiply_07_bad() { int data; /* Initialize data */ data = 0; if(staticFive==5) { /* POTENTIAL FLAW: Read data from the console using fscanf() */ fscanf(stdin, "%d", &data); } if(staticFive==5) { if(data < 0) /* ensure we won't have an overflow */ { /* POTENTIAL FLAW: if (data * 2) < INT_MIN, this will underflow */ int result = data * 2; printIntLine(result); } } } #endif /* OMITBAD */ #ifndef OMITGOOD /* goodB2G1() - use badsource and goodsink by changing the second staticFive==5 to staticFive!=5 */ static void goodB2G1() { int data; /* Initialize data */ data = 0; if(staticFive==5) { /* POTENTIAL FLAW: Read data from the console using fscanf() */ fscanf(stdin, "%d", &data); } if(staticFive!=5) { /* INCIDENTAL: CWE 561 Dead Code, the code below will never run */ printLine("Benign, fixed string"); } else { if(data < 0) /* ensure we won't have an overflow */ { /* FIX: Add a check to prevent an underflow from occurring */ if (data > (INT_MIN/2)) { int result = data * 2; printIntLine(result); } else { printLine("data value is too small to perform multiplication."); } } } } /* goodB2G2() - use badsource and goodsink by reversing the blocks in the second if */ static void goodB2G2() { int data; /* Initialize data */ data = 0; if(staticFive==5) { /* POTENTIAL FLAW: Read data from the console using fscanf() */ fscanf(stdin, "%d", &data); } if(staticFive==5) { if(data < 0) /* ensure we won't have an overflow */ { /* FIX: Add a check to prevent an underflow from occurring */ if (data > (INT_MIN/2)) { int result = data * 2; printIntLine(result); } else { printLine("data value is too small to perform multiplication."); } } } } /* goodG2B1() - use goodsource and badsink by changing the first staticFive==5 to staticFive!=5 */ static void goodG2B1() { int data; /* Initialize data */ data = 0; if(staticFive!=5) { /* INCIDENTAL: CWE 561 Dead Code, the code below will never run */ printLine("Benign, fixed string"); } else { /* FIX: Use a small, non-zero value that will not cause an integer underflow in the sinks */ data = -2; } if(staticFive==5) { if(data < 0) /* ensure we won't have an overflow */ { /* POTENTIAL FLAW: if (data * 2) < INT_MIN, this will underflow */ int result = data * 2; printIntLine(result); } } } /* goodG2B2() - use goodsource and badsink by reversing the blocks in the first if */ static void goodG2B2() { int data; /* Initialize data */ data = 0; if(staticFive==5) { /* FIX: Use a small, non-zero value that will not cause an integer underflow in the sinks */ data = -2; } if(staticFive==5) { if(data < 0) /* ensure we won't have an overflow */ { /* POTENTIAL FLAW: if (data * 2) < INT_MIN, this will underflow */ int result = data * 2; printIntLine(result); } } } void CWE191_Integer_Underflow__int_fscanf_multiply_07_good() { goodB2G1(); goodB2G2(); goodG2B1(); goodG2B2(); } #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()..."); CWE191_Integer_Underflow__int_fscanf_multiply_07_good(); printLine("Finished good()"); #endif /* OMITGOOD */ #ifndef OMITBAD printLine("Calling bad()..."); CWE191_Integer_Underflow__int_fscanf_multiply_07_bad(); printLine("Finished bad()"); #endif /* OMITBAD */ return 0; } #endif
#ifndef __COMMON_ALEMBIC_H #define __COMMON_ALEMBIC_H #include <utility> #include <limits> #include <set> #include <vector> #include <map> #include <list> #include <deque> #include <cmath> #include <algorithm> #include <stdexcept> #include <exception> #include <string> #include <sstream> #include <fstream> #include <cstring> #include <iostream> #include <time.h> #include <math.h> #include <float.h> #include <stdio.h> #include <string.h> #include <stdlib.h> #include <assert.h> #include <boost/algorithm/string.hpp> #include <boost/cstdint.hpp> #include <boost/smart_ptr.hpp> #include <boost/format.hpp> #include <boost/variant.hpp> #include <boost/exception/all.hpp> #include <boost/lexical_cast.hpp> #include <boost/filesystem.hpp> #include <boost/filesystem/operations.hpp> #include <boost/filesystem/path.hpp> #include <boost/thread/mutex.hpp> namespace fs = boost::filesystem; #include <ImathMatrixAlgo.h> #include <Alembic/Abc/All.h> #include <Alembic/AbcGeom/All.h> #include <Alembic/AbcCoreHDF5/All.h> #include <Alembic/AbcCoreOgawa/All.h> #include <Alembic/AbcCoreFactory/All.h> #include <Alembic/AbcCoreAbstract/TimeSampling.h> #include <Alembic/Util/Murmur3.h> #include <Alembic/AbcMaterial/All.h> namespace Alembic { namespace Abc { namespace ALEMBIC_VERSION_NS { using Imath::V4s; using Imath::V4i; using Imath::V4f; using Imath::V4d; } } } namespace AbcA = ::Alembic::AbcCoreAbstract::ALEMBIC_VERSION_NS; namespace AbcF = ::Alembic::AbcCoreFactory::ALEMBIC_VERSION_NS; namespace Abc = ::Alembic::Abc::ALEMBIC_VERSION_NS; namespace AbcG = ::Alembic::AbcGeom::ALEMBIC_VERSION_NS; namespace AbcU = ::Alembic::Util::ALEMBIC_VERSION_NS; namespace AbcM = ::Alembic::AbcMaterial::ALEMBIC_VERSION_NS; #include "CommonOS.h" #include "CommonLog.h" #include "CommonProfiler.h" #endif // __COMMON_ALEMBIC_H
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE546_Suspicious_Comment__HACK_07.c Label Definition File: CWE546_Suspicious_Comment.label.xml Template File: point-flaw-07.tmpl.c */ /* * @description * CWE: 546 Suspicious Comment * Sinks: HACK * GoodSink: Comments show no indications of hacks * BadSink : Comment contains the word HACK * Flow Variant: 07 Control flow: if(staticFive==5) and if(staticFive!=5) * * */ #include "std_testcase.h" /* The variable below is not declared "const", but is never assigned any other value so a tool should be able to identify that reads of this will always give its initialized value. */ static int staticFive = 5; #ifndef OMITBAD void CWE546_Suspicious_Comment__HACK_07_bad() { if(staticFive==5) { /* FLAW: The following comment has the letters 'HACK' in it*/ /* HACK: This comment has the letters 'HACK' in it, which is certainly * suspicious, because it could indicate this code needs to be investigated further. */ printLine("Hello"); } } #endif /* OMITBAD */ #ifndef OMITGOOD /* good1() uses if(staticFive!=5) instead of if(staticFive==5) */ static void good1() { if(staticFive!=5) { /* INCIDENTAL: CWE 561 Dead Code, the code below will never run */ printLine("Benign, fixed string"); } else { /* FIX: Removed the suspicious comments */ printLine("Hello"); } } /* good2() reverses the bodies in the if statement */ static void good2() { if(staticFive==5) { /* FIX: Removed the suspicious comments */ printLine("Hello"); } } void CWE546_Suspicious_Comment__HACK_07_good() { good1(); good2(); } #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()..."); CWE546_Suspicious_Comment__HACK_07_good(); printLine("Finished good()"); #endif /* OMITGOOD */ #ifndef OMITBAD printLine("Calling bad()..."); CWE546_Suspicious_Comment__HACK_07_bad(); printLine("Finished bad()"); #endif /* OMITBAD */ return 0; } #endif
/* Copyright (c) 2014, Patricio Gonzalez Vivo All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #pragma once #include <string> #include "gl.h" class Texture { public: Texture(); virtual ~Texture(); bool load(const std::string& _filepath); bool load(unsigned char* _pixels, int _width, int _height); static bool savePixels(const std::string& _path, unsigned char* _pixels, int _width, int _height); const GLuint getId() const { return m_id; }; std::string getFilePath() const { return m_path; }; /* Width and Height texture getters */ int getWidth() const { return m_width; }; int getHeight() const { return m_height; }; /* Binds the texture to GPU */ void bind(); /* Unbinds the texture from GPU */ void unbind(); protected: void glHandleError(); std::string m_path; int m_width; int m_height; GLuint m_id; };
/******************************************************************************* * File Name: ISR_RS485_RX.h * Version 1.70 * * Description: * Provides the function definitions for the Interrupt Controller. * * ******************************************************************************** * Copyright 2008-2015, Cypress Semiconductor Corporation. All rights reserved. * You may use this file only in accordance with the license, terms, conditions, * disclaimers, and limitations in the end user license agreement accompanying * the software package with which this file was provided. *******************************************************************************/ #if !defined(CY_ISR_ISR_RS485_RX_H) #define CY_ISR_ISR_RS485_RX_H #include <cytypes.h> #include <cyfitter.h> /* Interrupt Controller API. */ void ISR_RS485_RX_Start(void) ; void ISR_RS485_RX_StartEx(cyisraddress address) ; void ISR_RS485_RX_Stop(void) ; CY_ISR_PROTO(ISR_RS485_RX_Interrupt); void ISR_RS485_RX_SetVector(cyisraddress address) ; cyisraddress ISR_RS485_RX_GetVector(void) ; void ISR_RS485_RX_SetPriority(uint8 priority) ; uint8 ISR_RS485_RX_GetPriority(void) ; void ISR_RS485_RX_Enable(void) ; uint8 ISR_RS485_RX_GetState(void) ; void ISR_RS485_RX_Disable(void) ; void ISR_RS485_RX_SetPending(void) ; void ISR_RS485_RX_ClearPending(void) ; /* Interrupt Controller Constants */ /* Address of the INTC.VECT[x] register that contains the Address of the ISR_RS485_RX ISR. */ #define ISR_RS485_RX_INTC_VECTOR ((reg16 *) ISR_RS485_RX__INTC_VECT) /* Address of the ISR_RS485_RX ISR priority. */ #define ISR_RS485_RX_INTC_PRIOR ((reg8 *) ISR_RS485_RX__INTC_PRIOR_REG) /* Priority of the ISR_RS485_RX interrupt. */ #define ISR_RS485_RX_INTC_PRIOR_NUMBER ISR_RS485_RX__INTC_PRIOR_NUM /* Address of the INTC.SET_EN[x] byte to bit enable ISR_RS485_RX interrupt. */ #define ISR_RS485_RX_INTC_SET_EN ((reg8 *) ISR_RS485_RX__INTC_SET_EN_REG) /* Address of the INTC.CLR_EN[x] register to bit clear the ISR_RS485_RX interrupt. */ #define ISR_RS485_RX_INTC_CLR_EN ((reg8 *) ISR_RS485_RX__INTC_CLR_EN_REG) /* Address of the INTC.SET_PD[x] register to set the ISR_RS485_RX interrupt state to pending. */ #define ISR_RS485_RX_INTC_SET_PD ((reg8 *) ISR_RS485_RX__INTC_SET_PD_REG) /* Address of the INTC.CLR_PD[x] register to clear the ISR_RS485_RX interrupt. */ #define ISR_RS485_RX_INTC_CLR_PD ((reg8 *) ISR_RS485_RX__INTC_CLR_PD_REG) #endif /* CY_ISR_ISR_RS485_RX_H */ /* [] END OF FILE */
/*============================================================================ The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center (DKFZ) All rights reserved. Use of this source code is governed by a 3-clause BSD license that can be found in the LICENSE file. ============================================================================*/ #ifndef QMITKDATANODESETCONTROLPOINTACTION_H #define QMITKDATANODESETCONTROLPOINTACTION_H // mitk gui qt application plugin #include <QmitkAbstractDataNodeAction.h> // qt #include <QAction> class QmitkDataNodeSetControlPointAction : public QAction, public QmitkAbstractDataNodeAction { Q_OBJECT public: QmitkDataNodeSetControlPointAction(QWidget* parent, berry::IWorkbenchPartSite::Pointer workbenchPartSite); QmitkDataNodeSetControlPointAction(QWidget* parent, berry::IWorkbenchPartSite* workbenchPartSite); private Q_SLOTS: void OnActionTriggered(bool); protected: void InitializeAction() override; QWidget* m_Parent; }; #endif // QMITKDATANODESETCONTROLPOINTACTION_H
/* BLIS An object-based framework for developing high-performance BLAS-like libraries. Copyright (C) 2014, The University of Texas Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - Neither the name of The University of Texas 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. */ void bli_trmv_basic_check( obj_t* alpha, obj_t* a, obj_t* x ); void bli_trmv_check( obj_t* alpha, obj_t* a, obj_t* x ); void bli_trmv_int_check( obj_t* alpha, obj_t* a, obj_t* x, trmv_t* cntl );
/* * Copyright (C) 2014 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 THIRD_PARTY_BLINK_RENDERER_CORE_SVG_SVG_ANIMATED_STRING_H_ #define THIRD_PARTY_BLINK_RENDERER_CORE_SVG_SVG_ANIMATED_STRING_H_ #include "third_party/blink/renderer/core/svg/properties/svg_animated_property.h" #include "third_party/blink/renderer/core/svg/svg_string.h" #include "third_party/blink/renderer/platform/bindings/script_wrappable.h" #include "third_party/blink/renderer/platform/heap/heap.h" namespace blink { class V8UnionStringOrTrustedScriptURL; class SVGAnimatedString : public ScriptWrappable, public SVGAnimatedProperty<SVGString> { DEFINE_WRAPPERTYPEINFO(); public: SVGAnimatedString(SVGElement* context_element, const QualifiedName& attribute_name) : SVGAnimatedProperty<SVGString>(context_element, attribute_name, MakeGarbageCollected<SVGString>()) {} virtual V8UnionStringOrTrustedScriptURL* baseVal(); virtual void setBaseVal(const V8UnionStringOrTrustedScriptURL* value, ExceptionState& exception_state); virtual String animVal(); void Trace(Visitor*) const override; }; } // namespace blink #endif // THIRD_PARTY_BLINK_RENDERER_CORE_SVG_SVG_ANIMATED_STRING_H_
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE369_Divide_by_Zero__int_fgets_divide_14.c Label Definition File: CWE369_Divide_by_Zero__int.label.xml Template File: sources-sinks-14.tmpl.c */ /* * @description * CWE: 369 Divide by Zero * BadSource: fgets Read data from the console using fgets() * GoodSource: Non-zero * Sinks: divide * GoodSink: Check for zero before dividing * BadSink : Divide a constant by data * Flow Variant: 14 Control flow: if(globalFive==5) and if(globalFive!=5) * * */ #include "std_testcase.h" #define CHAR_ARRAY_SIZE (3 * sizeof(data) + 2) #ifndef OMITBAD void CWE369_Divide_by_Zero__int_fgets_divide_14_bad() { int data; /* Initialize data */ data = -1; if(globalFive==5) { { char inputBuffer[CHAR_ARRAY_SIZE] = ""; /* POTENTIAL FLAW: Read data from the console using fgets() */ if (fgets(inputBuffer, CHAR_ARRAY_SIZE, stdin) != NULL) { /* Convert to int */ data = atoi(inputBuffer); } else { printLine("fgets() failed."); } } } if(globalFive==5) { /* POTENTIAL FLAW: Possibly divide by zero */ printIntLine(100 / data); } } #endif /* OMITBAD */ #ifndef OMITGOOD /* goodB2G1() - use badsource and goodsink by changing the second globalFive==5 to globalFive!=5 */ static void goodB2G1() { int data; /* Initialize data */ data = -1; if(globalFive==5) { { char inputBuffer[CHAR_ARRAY_SIZE] = ""; /* POTENTIAL FLAW: Read data from the console using fgets() */ if (fgets(inputBuffer, CHAR_ARRAY_SIZE, stdin) != NULL) { /* Convert to int */ data = atoi(inputBuffer); } else { printLine("fgets() failed."); } } } if(globalFive!=5) { /* INCIDENTAL: CWE 561 Dead Code, the code below will never run */ printLine("Benign, fixed string"); } else { /* FIX: test for a zero denominator */ if( data != 0 ) { printIntLine(100 / data); } else { printLine("This would result in a divide by zero"); } } } /* goodB2G2() - use badsource and goodsink by reversing the blocks in the second if */ static void goodB2G2() { int data; /* Initialize data */ data = -1; if(globalFive==5) { { char inputBuffer[CHAR_ARRAY_SIZE] = ""; /* POTENTIAL FLAW: Read data from the console using fgets() */ if (fgets(inputBuffer, CHAR_ARRAY_SIZE, stdin) != NULL) { /* Convert to int */ data = atoi(inputBuffer); } else { printLine("fgets() failed."); } } } if(globalFive==5) { /* FIX: test for a zero denominator */ if( data != 0 ) { printIntLine(100 / data); } else { printLine("This would result in a divide by zero"); } } } /* goodG2B1() - use goodsource and badsink by changing the first globalFive==5 to globalFive!=5 */ static void goodG2B1() { int data; /* Initialize data */ data = -1; if(globalFive!=5) { /* INCIDENTAL: CWE 561 Dead Code, the code below will never run */ printLine("Benign, fixed string"); } else { /* FIX: Use a value not equal to zero */ data = 7; } if(globalFive==5) { /* POTENTIAL FLAW: Possibly divide by zero */ printIntLine(100 / data); } } /* goodG2B2() - use goodsource and badsink by reversing the blocks in the first if */ static void goodG2B2() { int data; /* Initialize data */ data = -1; if(globalFive==5) { /* FIX: Use a value not equal to zero */ data = 7; } if(globalFive==5) { /* POTENTIAL FLAW: Possibly divide by zero */ printIntLine(100 / data); } } void CWE369_Divide_by_Zero__int_fgets_divide_14_good() { goodB2G1(); goodB2G2(); goodG2B1(); goodG2B2(); } #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()..."); CWE369_Divide_by_Zero__int_fgets_divide_14_good(); printLine("Finished good()"); #endif /* OMITGOOD */ #ifndef OMITBAD printLine("Calling bad()..."); CWE369_Divide_by_Zero__int_fgets_divide_14_bad(); printLine("Finished bad()"); #endif /* OMITBAD */ return 0; } #endif
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE843_Type_Confusion__short_52c.c Label Definition File: CWE843_Type_Confusion.label.xml Template File: sources-sink-52c.tmpl.c */ /* * @description * CWE: 843 Type Confusion * BadSource: short Point data to a short data type * GoodSource: Point data to an int data type * Sink: * BadSink : Attempt to access data as an int * 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" /* all the sinks are the same, we just want to know where the hit originated if a tool flags one */ #ifndef OMITBAD void CWE843_Type_Confusion__short_52c_badSink(void * data) { /* POTENTIAL FLAW: Attempt to access data as an int */ printIntLine(*((int*)data)); } #endif /* OMITBAD */ #ifndef OMITGOOD /* goodG2B uses the GoodSource with the BadSink */ void CWE843_Type_Confusion__short_52c_goodG2BSink(void * data) { /* POTENTIAL FLAW: Attempt to access data as an int */ printIntLine(*((int*)data)); } #endif /* OMITGOOD */
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE194_Unexpected_Sign_Extension__fgets_malloc_52a.c Label Definition File: CWE194_Unexpected_Sign_Extension.label.xml Template File: sources-sink-52a.tmpl.c */ /* * @description * CWE: 194 Unexpected Sign Extension * BadSource: fgets Read data from the console using fgets() * GoodSource: Positive integer * Sink: malloc * BadSink : Allocate memory using malloc() with the size of data * Flow Variant: 52 Data flow: data passed as an argument from one function to another to another in three different source files * * */ #include "std_testcase.h" /* Must be at least 8 for atoi() to work properly */ #define CHAR_ARRAY_SIZE 8 #ifndef OMITBAD /* bad function declaration */ void CWE194_Unexpected_Sign_Extension__fgets_malloc_52b_badSink(short data); void CWE194_Unexpected_Sign_Extension__fgets_malloc_52_bad() { short data; /* Initialize data */ data = 0; { char inputBuffer[CHAR_ARRAY_SIZE] = ""; /* FLAW: Use a value input from the console using fgets() */ if (fgets(inputBuffer, CHAR_ARRAY_SIZE, stdin) != NULL) { /* Convert to short */ data = (short)atoi(inputBuffer); } else { printLine("fgets() failed."); } } CWE194_Unexpected_Sign_Extension__fgets_malloc_52b_badSink(data); } #endif /* OMITBAD */ #ifndef OMITGOOD /* good function declaration */ void CWE194_Unexpected_Sign_Extension__fgets_malloc_52b_goodG2BSink(short data); /* goodG2B uses the GoodSource with the BadSink */ static void goodG2B() { short data; /* Initialize data */ data = 0; /* FIX: Use a positive integer less than &InitialDataSize&*/ data = 100-1; CWE194_Unexpected_Sign_Extension__fgets_malloc_52b_goodG2BSink(data); } void CWE194_Unexpected_Sign_Extension__fgets_malloc_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()..."); CWE194_Unexpected_Sign_Extension__fgets_malloc_52_good(); printLine("Finished good()"); #endif /* OMITGOOD */ #ifndef OMITBAD printLine("Calling bad()..."); CWE194_Unexpected_Sign_Extension__fgets_malloc_52_bad(); printLine("Finished bad()"); #endif /* OMITBAD */ return 0; } #endif
/* * Copyright (C) 2012 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 WTF_StreamBuffer_h #define WTF_StreamBuffer_h #include <wtf/Deque.h> #include <wtf/PassOwnPtr.h> namespace WTF { template <typename T, size_t BlockSize> class StreamBuffer { private: typedef Vector<T> Block; public: StreamBuffer() : m_size(0) , m_readOffset(0) { } ~StreamBuffer() { } bool isEmpty() const { return !size(); } void append(const T* data, size_t size) { if (!size) return; m_size += size; while (size) { if (!m_buffer.size() || m_buffer.last()->size() == BlockSize) m_buffer.append(adoptPtr(new Block)); size_t appendSize = std::min(BlockSize - m_buffer.last()->size(), size); m_buffer.last()->append(data, appendSize); data += appendSize; size -= appendSize; } } // This function consume data in the fist block. // Specified size must be less than over equal to firstBlockSize(). void consume(size_t size) { ASSERT(m_size >= size); if (!m_size) return; ASSERT(m_buffer.size() > 0); ASSERT(m_readOffset + size <= m_buffer.first()->size()); m_readOffset += size; m_size -= size; if (m_readOffset >= m_buffer.first()->size()) { m_readOffset = 0; m_buffer.removeFirst(); } } size_t size() const { return m_size; } const T* firstBlockData() const { if (!m_size) return 0; ASSERT(m_buffer.size() > 0); return &m_buffer.first()->data()[m_readOffset]; } size_t firstBlockSize() const { if (!m_size) return 0; ASSERT(m_buffer.size() > 0); return m_buffer.first()->size() - m_readOffset; } private: size_t m_size; size_t m_readOffset; Deque<OwnPtr<Block> > m_buffer; }; } // namespace WTF using WTF::StreamBuffer; #endif // WTF_StreamBuffer_h