text
stringlengths
4
6.14k
#pragma once #define CPUM_CACHELINESIZE 64
/* * GraphicCurrentTimeLine.h * * Author : Alwin de Jong * e-mail : jong@astron.nl * Revision : $Revision$ * Last change by : $Author$ * Change date : $Date$ * First creation : 15-apr-2010 * URL : $URL: https://svn.astron.nl/ROD/trunk/LOFAR_Scheduler/GraphicCurrentTimeLine.h $ * */ #ifndef GRAPHICCURRENTTIMELINE_H_ #define GRAPHICCURRENTTIMELINE_H_ #include <QGraphicsItem> #include <QDateTime> #include <QPen> #include <QBrush> #include "astrodatetime.h" class GraphicResourceScene; class GraphicCurrentTimeLine : public QGraphicsItem { public: GraphicCurrentTimeLine(GraphicResourceScene *scene, int height); virtual ~GraphicCurrentTimeLine(); QRectF boundingRect() const {return itsBoundings;} void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); inline void updateHeight(int height) {itsHeight = height;} void updateTime(const QDateTime &UTC); void redrawTime(void) {updateTime(itsCurrentTime);} bool isWithinSchedule(void) {return isInSchedule;} AstroDateTime currentDateTime(void) const; void show(void) {isHidden = false;} void hide(void) {isHidden = true;} private: GraphicResourceScene *itsScene; QRectF itsBoundings; QDateTime itsCurrentTime; AstroTime itsLST; int itsHeight; QPen itsLinePen; QBrush itsTimeBackgroundBrush; bool isInSchedule, isHidden; }; #endif /* GRAPHICCURRENTTIMELINE_H_ */
/** * Marlin 3D Printer Firmware * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] * * Based on Sprinter and grbl. * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ #pragma once /** * InterruptVectors_Due.h * * This module relocates the Interrupt vector table to SRAM, allowing new * interrupt handlers to be added at runtime. This is required because the * Arduino runtime steals interrupt handlers that Marlin MUST use to support * extended functionality such as USB hosts and USB devices (MSD, MTP) and * custom serial port handlers. Rather than modifying and/or recompiling the * Arduino runtime, We just want to run as much as possible on Stock Arduino. * * Copyright (c) 2017 Eduardo José Tagle. All right reserved */ #ifdef ARDUINO_ARCH_SAM // ISR handler type typedef void (*pfnISR_Handler)(); // Install a new interrupt vector handler for the given irq, returning the old one pfnISR_Handler install_isr(IRQn_Type irq, pfnISR_Handler newHandler); #endif // ARDUINO_ARCH_SAM
//# BlAllocArr.h: Tripled that describes an allocation of a beamlet //# //# Copyright (C) 2009 //# ASTRON (Netherlands Foundation for Research in Astronomy) //# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, softwaresupport@astron.nl //# //# This program is free software; you can redistribute it and/or modify //# it under the terms of the GNU General Public License as published by //# the Free Software Foundation; either version 2 of the License, or //# (at your option) any later version. //# //# This program is distributed in the hope that it will be useful, //# but WITHOUT ANY WARRANTY; without even the implied warranty of //# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //# GNU General Public License for more details. //# //# You should have received a copy of the GNU General Public License //# along with this program; if not, write to the Free Software //# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA //# //# $Id$ #ifndef LOFAR_MD_PROTOCOL_BL_ALLOC_ARR_H #define LOFAR_MD_PROTOCOL_BL_ALLOC_ARR_H // \file // Streamable container of BeamletAllocations //# Includes #include <Common/LofarConstants.h> #include <Common/lofar_iostream.h> #include <Common/lofar_vector.h> #include <MD_Protocol/BeamletAllocation.h> namespace LOFAR { namespace MD_Protocol { class BlAllocArr { public: // construction explicit BlAllocArr(int nrElements); ~BlAllocArr(); // default construction needed for protocol BlAllocArr(); BeamletAllocation& operator[](uint index); const BeamletAllocation& operator[](uint index) const; // print function for operator<< ostream& print (ostream& os) const; void set (uint idx, uint subband, int beam, uint observation); void clear (uint idx); void clear (uint idx, uint count); void clearRange (uint lowlimit, uint upperlimit); void clearRSP (uint rspNr); //@{ // marshalling methods unsigned int getSize(); unsigned int pack (void* buffer); unsigned int unpack (void* buffer); //@} private: // copying is not allowed BlAllocArr(const BlAllocArr& that); BlAllocArr& operator=(const BlAllocArr& that); // ----- Datamembers ----- uint itsSize; vector<BeamletAllocation> itsPool; }; //# //# operator<< //# inline ostream& operator<< (ostream& os, const BlAllocArr& aBAA) { return (aBAA.print(os)); } } // namespace MD_Protocol } // namespace LOFAR #endif
// rawimg2png.c // Meteor Pi, Cambridge Science Centre // Dominic Ford // ------------------------------------------------- // Copyright 2016 Cambridge Science Centre. // This file is part of Meteor Pi. // Meteor Pi 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. // // Meteor Pi 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 Meteor Pi. If not, see <http://www.gnu.org/licenses/>. // ------------------------------------------------- #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include "utils/tools.h" #include "png/image.h" #include "utils/asciiDouble.h" #include "utils/error.h" #include "utils/lensCorrect.h" #include "utils/tools.h" #include "settings.h" int main(int argc, char *argv[]) { int i; if (argc != 8) { sprintf(temp_err_string, "ERROR: Need to specify raw image filename on commandline, followed by output frame filename, e.g. 'rawimg2png foo.raw frame.png produceFilesWithoutLensCorrection noiseLevel barrelA barrelB barrelC'."); gnom_fatal(__FILE__, __LINE__, temp_err_string); } char *rawFname = argv[1]; char *fname = argv[2]; int lcmin = getFloat(argv[3], NULL) ? 0 : 1; double noise = getFloat(argv[4], NULL); double barrelA = getFloat(argv[5], NULL); double barrelB = getFloat(argv[6], NULL); double barrelC = getFloat(argv[7], NULL); FILE *infile; if ((infile = fopen(rawFname, "rb")) == NULL) { sprintf(temp_err_string, "ERROR: Cannot open output raw image file %s.\n", rawFname); gnom_fatal(__FILE__, __LINE__, temp_err_string); } int width, height, channels; i = fread(&width, sizeof(int), 1, infile); i = fread(&height, sizeof(int), 1, infile); i = fread(&channels, sizeof(int), 1, infile); const int frameSize = width * height; unsigned char *imgRaw = malloc(channels * frameSize); if (imgRaw == NULL) { sprintf(temp_err_string, "ERROR: malloc fail"); gnom_fatal(__FILE__, __LINE__, temp_err_string); } i = fread(imgRaw, 1, channels * frameSize, infile); fclose(infile); image_ptr OutputImage; image_alloc(&OutputImage, width, height); OutputImage.data_w = 1; if (channels >= 3) { for (i = 0; i < frameSize; i++) OutputImage.data_red[i] = imgRaw[i]; for (i = 0; i < frameSize; i++) OutputImage.data_grn[i] = imgRaw[i + frameSize]; for (i = 0; i < frameSize; i++) OutputImage.data_blu[i] = imgRaw[i + frameSize * 2]; } else { for (i = 0; i < frameSize; i++) OutputImage.data_red[i] = imgRaw[i]; for (i = 0; i < frameSize; i++) OutputImage.data_grn[i] = imgRaw[i]; for (i = 0; i < frameSize; i++) OutputImage.data_blu[i] = imgRaw[i]; } int lc; for (lc = lcmin; lc < 2; lc++) { char frOut[FNAME_BUFFER]; sprintf(frOut, "%s_LC%d.png", fname, lc); if (lc) { image_ptr CorrectedImage = lensCorrect(&OutputImage, barrelA, barrelB, barrelC); image_put(frOut, CorrectedImage, (channels < 3)); image_dealloc(&CorrectedImage); } else { image_put(frOut, OutputImage, (channels < 3)); } sprintf(frOut, "%s_LC%d.txt", fname, lc); FILE *f = fopen(frOut, "w"); if (f) { fprintf(f, "skyClarity %.2f\n", calculateSkyClarity(&OutputImage, noise)); fclose(f); } } image_dealloc(&OutputImage); free(imgRaw); return 0; }
/* Simple DirectMedia Layer Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /** * \file SDL_clipboard.h * * Include file for SDL clipboard handling */ #ifndef _SDL_clipboard_h #define _SDL_clipboard_h #include "SDL_stdinc.h" #include "begin_code.h" /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus /* *INDENT-OFF* */ extern "C" { /* *INDENT-ON* */ #endif /* Function prototypes */ /** * \brief Put UTF-8 text into the clipboard * * \sa SDL_GetClipboardText() */ extern DECLSPEC int SDLCALL SDL_SetClipboardText(const char *text); /** * \brief Get UTF-8 text from the clipboard, which must be freed with SDL_free() * * \sa SDL_SetClipboardText() */ extern DECLSPEC char * SDLCALL SDL_GetClipboardText(void); /** * \brief Returns a flag indicating whether the clipboard exists and contains a text string that it non-empty * * \sa SDL_GetClipboardText() */ extern DECLSPEC SDL_bool SDLCALL SDL_HasClipboardText(void); /* Ends C function definitions when using C++ */ #ifdef __cplusplus /* *INDENT-OFF* */ } /* *INDENT-ON* */ #endif #include "close_code.h" #endif /* _SDL_clipboard_h */ /* vi: set ts=4 sw=4 expandtab: */
#ifndef _SMARTRF_SETTINGS_H_ #define _SMARTRF_SETTINGS_H_ //********************************************************************************* // Generated by SmartRF Studio version 2.6.0 (build #81) // Tested for SimpleLink SDK version: CC13x0 SDK 1.0.xx // Device: CC1310 Rev. 2.1 // //********************************************************************************* #include <ti/devices/DeviceFamily.h> #include DeviceFamily_constructPath(driverlib/rf_mailbox.h) #include DeviceFamily_constructPath(driverlib/rf_common_cmd.h) #include DeviceFamily_constructPath(driverlib/rf_prop_cmd.h) #include <ti/drivers/rf/RF.h> // TI-RTOS RF Mode Object extern RF_Mode RF_prop; // RF Core API commands extern rfc_CMD_PROP_RADIO_DIV_SETUP_t RF_cmdPropRadioDivSetup; extern rfc_CMD_FS_t RF_cmdFs; extern rfc_CMD_PROP_TX_t RF_cmdPropTx; extern rfc_CMD_PROP_RX_t RF_cmdPropRx; extern rfc_CMD_TX_TEST_t RF_cmdTxTest; #endif // _SMARTRF_SETTINGS_H_
/** * @file object.h * @brief */ #ifndef _OBJECT_H_ #define _OBJECT_H_ /** * */ extern const void * Object; /** * @param _objA * @param _objB * @return * @brief */ extern int differ(const void * _objA, const void * _objB); #endif
#ifndef RlMove_RandomGeometricWalk_H #define RlMove_RandomGeometricWalk_H #include "RlMove.h" #include "TypedDagNode.h" #include <ostream> #include <string> namespace RevLanguage { /** * The RevLanguage wrapper of the random-geometric-walk move. * * The RevLanguage wrapper of the random-geometric-walk move simply * manages the interactions through the Rev with our core. * That is, the internal move object can be constructed and hooked up * in a DAG-nove (variable) that it works on. * See the Move_RandomGeometricWalk.h for more details. * * * @copyright Copyright 2009- * @author The RevBayes Development Core Team (Sebastian Hoehna) * */ class Move_RandomGeometricWalk : public Move { public: Move_RandomGeometricWalk(void); //!< Default constructor // Basic utility functions virtual Move_RandomGeometricWalk* clone(void) const; //!< Clone object void constructInternalObject(void); //!< We construct the a new internal SlidingMove. static const std::string& getClassType(void); //!< Get Rev type static const TypeSpec& getClassTypeSpec(void); //!< Get class type spec std::string getMoveName(void) const; //!< Get the name used for the constructor function in Rev. const MemberRules& getParameterRules(void) const; //!< Get member rules (const) virtual const TypeSpec& getTypeSpec(void) const; //!< Get language type of the object virtual void printValue(std::ostream& o) const; //!< Print value (for user) protected: void setConstParameter(const std::string& name, const RevPtr<const RevVariable> &var); //!< Set member variable RevPtr<const RevVariable> x; //!< The variable on which the move works RevPtr<const RevVariable> p; //!< The tuning parameter RevPtr<const RevVariable> tune; //!< If autotuning should be used. }; } #endif
/* $Id: nls_time.c,v 1.5 2004/02/01 13:52:17 skaus Exp $ Return the dynamically allocated ASCII representation of the passed in time This file bases on NLS.C of FreeCOM v0.81 beta 1. $Log: nls_time.c,v $ Revision 1.5 2004/02/01 13:52:17 skaus add/upd: CVS $id$ keywords to/of files Revision 1.4 2003/03/11 20:01:14 skaus bugfix: PROMPT $T: hour: space padded; fraction zero padded [#1481] Revision 1.3 2001/06/12 22:56:59 skaus bugfix: nls_maketime(): 12hour display does not free AM/PM id Revision 1.2 2001/04/29 11:33:51 skaus chg: default heap size (tools\ptchsize) set to 6KB chg: error displaying functions centralized into lib\err_fcts.src add: displayError() chg: all errors are displayed through functions void error_*() bugfix: somtimes error messages are not displayed (see displayError()) bugfix: docommand(): type:file must pass ":file" to TYPE bugfix: error_sfile(): string _SFILE_ bugfix: error message on empty redirection bugfix: comma and semicolon ';' are recognized as argument seperators of internal commands Revision 1.1 2001/04/12 00:33:53 skaus chg: new structure chg: If DEBUG enabled, no available commands are displayed on startup fix: PTCHSIZE also patches min extra size to force to have this amount of memory available on start bugfix: CALL doesn't reset options add: PTCHSIZE to patch heap size add: VSPAWN, /SWAP switch, .SWP resource handling bugfix: COMMAND.COM A:\ bugfix: CALL: if swapOnExec == ERROR, no change of swapOnExec allowed add: command MEMORY bugfix: runExtension(): destroys command[-2] add: clean.bat add: localized CRITER strings chg: use LNG files for hard-coded strings (hangForEver(), init.c) via STRINGS.LIB add: DEL.C, COPY.C, CBREAK.C: STRINGS-based prompts add: fixstrs.c: prompts & symbolic keys add: fixstrs.c: backslash escape sequences add: version IDs to DEFAULT.LNG and validation to FIXSTRS.C chg: splitted code apart into LIB\*.c and CMD\*.c bugfix: IF is now using error system & STRINGS to report errors add: CALL: /N */ #include "../config.h" #include <assert.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include "../include/misc.h" #include "../include/nls.h" #include "../strings.h" char *nls_maketime(int mode, int hour, int minute, int second, int fraction) { char buf[4 + 4 + sizeof(int) * 8 * 4 + 6]; char *p; int i, pm; #ifdef FEATURE_NLS refreshNLS(); #define fmt nlsBuf->timefmt #define sep nlsBuf->timeSep #define dsep nlsBuf->decimalSep #else #define fmt 0 #define sep ":" #define dsep "." #endif /** Warning: condition always true -- if !NLS **/ if(fmt == 0) { /* 12hour display */ if((pm = hour >= 12) != 0) { hour -= 12; } if(hour == 0) hour = 12; i = sprintf(p = buf, "%2u%s%02u", hour, sep, minute); } else { /** Warning: unreachable code -- if !defined(NLS) **/ i = sprintf(p = buf, "%2u%s%02u", hour, sep, minute); } assert(strlen(buf) < sizeof(buf)); if(i == EOF) return 0; if(second >= 0) { i = sprintf(p += i, "%s%02u", sep, second); if(i == EOF) return 0; if(fraction) { i = sprintf(p += i, "%s%-2u", dsep, fraction); if(i == EOF) return 0; { char *q = p + i; while(*--q == ' ') *q = '0'; } } } assert(strlen(buf) < sizeof(buf)); /** Warning: conditional always true -- if !NLS **/ if(fmt == 0) { char *q = getString(pm? TEXT_STRING_PM: TEXT_STRING_AM); if(!q) return 0; if(mode & NLS_MAKE_SHORT_AMPM) { *(p += i) = *ltrimsp(q); p[1] = 0; } else strcpy(p + i, q); free(q); } assert(strlen(buf) < sizeof(buf)); return strdup(buf); }
/************************************************************************ * To the extent possible under law, Nils Maier has waived all copyright * and related or neighboring rights to this work. ************************************************************************/ #include <windows.h> BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved) { return TRUE; }
/****************************************************************************** Copyright (C) 2002-2015 Argentum Online & Dakara Online Developers This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero 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 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/>. ******************************************************************************/ /* AUTOMATICALLY CONVERTED FILE */ #ifndef MODCENTINELA_H #define MODCENTINELA_H #include <vector> #include <memory> #include <string> #include "vb6compat.h" #include "enums.h" /* [(0, 'ATTRIBUTE'), (1, 'VB_Name'), (5, '='), (4, '"modCentinela"')] */ /* '***************************************************************** */ /* 'modCentinela.bas - ImperiumAO - v1.2 */ /* ' */ /* 'Funciónes de control para usuarios que se encuentran trabajando */ /* ' */ /* '***************************************************************** */ /* 'Augusto Rando(barrin@imperiumao.com.ar) */ /* ' ImperiumAO 1.2 */ /* ' - First Relase */ /* ' */ /* 'Juan Martín Sotuyo Dodero (juansotuyo@gmail.com) */ /* ' Alkon AO 0.11.5 */ /* ' - Small improvements and added logs to detect possible cheaters */ /* ' */ /* 'Juan Martín Sotuyo Dodero (juansotuyo@gmail.com) */ /* ' Alkon AO 0.12.0 */ /* ' - Added several messages to spam users until they reply */ /* ' */ /* 'ZaMa */ /* ' Alkon AO 0.13.0 */ /* ' - Added several paralel checks */ /* '***************************************************************** */ /* 'Índice del NPC en el .dat */ /* 'Tiempo inicial en minutos. No reducir sin antes revisar el timer que maneja estos datos. */ /* 'Tiempo minimo fijo para volver a pasar */ /* 'Tiempo máximo para el random para que el centinela vuelva a pasar */ struct tCentinela { /* ' Index of centinela en el servidor */ int NpcIndex; /* '¿Qué índice revisamos? */ int RevisandoUserIndex; /* '¿Cuántos minutos le quedan al usuario? */ int TiempoRestante; /* 'Clave que debe escribir */ int clave; int SpawnTime; bool Activo; }; extern bool centinelaActivado; /* 'Guardo cuando voy a resetear a la lista de usuarios del centinela */ extern const int NRO_CENTINELA; extern vb6::array<struct tCentinela> Centinela; void CallUserAttention(); void GoToNextWorkingChar(); int GetIdleCentinela(int StartCheckIndex); void CentinelaFinalCheck(int CentiIndex); void CentinelaCheckClave(int UserIndex, int clave); void ResetCentinelaInfo(); void CentinelaSendClave(int UserIndex, int CentinelaIndex); void PasarMinutoCentinela(); void WarpCentinela(int UserIndex, int CentinelaIndex); void CentinelaUserLogout(int CentinelaIndex); void ResetCentinelas(); int EsCentinela(int NpcIndex); void RenovarResetTimer(); #endif
#ifndef JSONREADER_H #define JSONREADER_H #include "System/Buffers/ReadBuffer.h" /* =============================================================================================== JSONReader =============================================================================================== */ class JSONReader { public: // Low-level interface static bool FindMember(ReadBuffer json, ReadBuffer name, ReadBuffer& member); static bool FirstMember(ReadBuffer json, ReadBuffer& member); static bool MemberValue(ReadBuffer jsonMember, ReadBuffer& value); static bool MemberStringValue(ReadBuffer jsonMember, ReadBuffer& value); static bool MemberInt64Value(ReadBuffer json, int64_t& value); static bool GetMemberValue(ReadBuffer json, ReadBuffer name, ReadBuffer &member); static bool GetObject(ReadBuffer json, ReadBuffer name, ReadBuffer& object); static bool FindValue(ReadBuffer json, ReadBuffer name, ReadBuffer& value); static bool GetValue(ReadBuffer json, ReadBuffer& value); static bool GetStringValue(ReadBuffer json, ReadBuffer& value); static bool GetNumberValue(ReadBuffer json, ReadBuffer& value); static bool GetObjectValue(ReadBuffer json, ReadBuffer& value); static bool GetArray(ReadBuffer json, ReadBuffer& value, unsigned& length); static bool GetArrayElement(ReadBuffer json, unsigned index, ReadBuffer& value); static bool IsTrue(ReadBuffer json); static bool IsFalse(ReadBuffer json); static bool IsNull(ReadBuffer json); static bool GetBooleanValue(ReadBuffer json, bool& value); static bool IsValid(ReadBuffer json); }; /* =============================================================================================== JSONIterator =============================================================================================== */ class JSON; class JSONIterator { public: JSONIterator(); JSONIterator(const ReadBuffer& data, bool isPair); // HACK: enable FOREACH bool operator!=(unsigned u); bool IsPair(); bool GetName(ReadBuffer& name); bool GetValue(JSON& value); private: friend class JSON; ReadBuffer data; bool isPair; }; /* =============================================================================================== JSON =============================================================================================== */ class JSON { public: enum Type { Undefined = 0, String = 1, Number = 2, Object = 3, Array = 4, True = 5, False = 6, Bool = True | False, // 7 Null = 8 }; unsigned GetLength(); char* GetBuffer(); Type GetType(); void SetType(Type type); static Type GetJSONType(ReadBuffer json); static JSON Create(ReadBuffer json); JSONIterator First(); JSONIterator Next(JSONIterator it); bool IsString(); bool IsNumber(); bool IsObject(); bool IsArray(); bool IsTrue(); bool IsFalse(); bool IsNull(); bool IsUndefined(); bool GetMember(ReadBuffer name, JSON& json); bool GetArrayLength(unsigned& length); bool GetArrayElement(unsigned index, JSON& json); bool GetStringValue(ReadBuffer& value); bool GetInt64Value(int64_t& value); bool GetBoolValue(bool& value); ReadBuffer GetReadBuffer(); private: ReadBuffer data; }; #endif
/* draw a circle on an image * * Author N. Dessipris * Written on 30/05/1990 * Updated on: * 22/7/93 JC * - im_incheck() call added * 16/8/94 JC * - im_incheck() changed to im_makerw() * 5/12/06 * - im_invalidate() after paint * 6/3/10 * - don't im_invalidate() after paint, this now needs to be at a higher * level * 18/8/10 * - gtkdoc * - rewritten: clips, fills, any bands, any format * 27/9/10 * - break base out to Draw */ /* This file is part of VIPS. VIPS is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk */ #ifdef HAVE_CONFIG_H #include <config.h> #endif /*HAVE_CONFIG_H*/ #include <vips/intl.h> #include <string.h> #include <vips/vips.h> #include "draw.h" /* Our state. */ typedef struct { Draw draw; /* Parameters. */ int cx, cy; int radius; gboolean fill; /* Derived stuff. */ VipsPel *centre; } Circle; static void circle_octants( Circle *circle, int x, int y ) { Draw *draw = DRAW( circle ); if( circle->fill ) { const int cx = circle->cx; const int cy = circle->cy; im__draw_scanline( draw, cy + y, cx - x, cx + x ); im__draw_scanline( draw, cy - y, cx - x, cx + x ); im__draw_scanline( draw, cy + x, cx - y, cx + y ); im__draw_scanline( draw, cy - x, cx - y, cx + y ); } else if( DRAW( circle )->noclip ) { const size_t lsize = draw->lsize; const size_t psize = draw->psize; VipsPel *centre = circle->centre; im__draw_pel( draw, centre + lsize * y - psize * x ); im__draw_pel( draw, centre + lsize * y + psize * x ); im__draw_pel( draw, centre - lsize * y - psize * x ); im__draw_pel( draw, centre - lsize * y + psize * x ); im__draw_pel( draw, centre + lsize * x - psize * y ); im__draw_pel( draw, centre + lsize * x + psize * y ); im__draw_pel( draw, centre - lsize * x - psize * y ); im__draw_pel( draw, centre - lsize * x + psize * y ); } else { const int cx = circle->cx; const int cy = circle->cy; im__draw_pel_clip( draw, cx + y, cy - x ); im__draw_pel_clip( draw, cx + y, cy + x ); im__draw_pel_clip( draw, cx - y, cy - x ); im__draw_pel_clip( draw, cx - y, cy + x ); im__draw_pel_clip( draw, cx + x, cy - y ); im__draw_pel_clip( draw, cx + x, cy + y ); im__draw_pel_clip( draw, cx - x, cy - y ); im__draw_pel_clip( draw, cx - x, cy + y ); } } static void circle_free( Circle *circle ) { im__draw_free( DRAW( circle ) ); im_free( circle ); } static Circle * circle_new( IMAGE *im, int cx, int cy, int radius, gboolean fill, VipsPel *ink ) { Circle *circle; if( im_check_coding_known( "im_draw_circle", im ) ) return( NULL ); if( !(circle = IM_NEW( NULL, Circle )) ) return( NULL ); if( !im__draw_init( DRAW( circle ), im, ink ) ) { circle_free( circle ); return( NULL ); } circle->cx = cx; circle->cy = cy; circle->radius = radius; circle->fill = fill; circle->centre = IM_IMAGE_ADDR( im, cx, cy ); if( cx - radius >= 0 && cx + radius < im->Xsize && cy - radius >= 0 && cy + radius < im->Ysize ) DRAW( circle )->noclip = TRUE; return( circle ); } static void circle_draw( Circle *circle ) { int x, y, d; y = circle->radius; d = 3 - 2 * circle->radius; for( x = 0; x < y; x++ ) { circle_octants( circle, x, y ); if( d < 0 ) d += 4 * x + 6; else { d += 4 * (x - y) + 10; y--; } } if( x == y ) circle_octants( circle, x, y ); } /** * im_draw_circle: * @image: image to draw on * @x: centre of circle * @y: centre of circle * @radius: circle radius * @fill: fill the circle * @ink: value to draw * * Draws a circle on @image. If @fill is %TRUE then the circle is filled, * otherwise a 1-pixel-wide perimeter is drawn. * * @ink is an array of bytes containing a valid pixel for the image's format. * It must have at least IM_IMAGE_SIZEOF_PEL( @image ) bytes. * * See also: im_draw_line(). * * Returns: 0 on success, or -1 on error. */ int im_draw_circle( VipsImage *image, int x, int y, int radius, gboolean fill, VipsPel *ink ) { if( x + radius >= 0 && x - radius < image->Xsize && y + radius >= 0 && y - radius < image->Ysize ) { Circle *circle; if( !(circle = circle_new( image, x, y, radius, fill, ink )) ) return( -1 ); circle_draw( circle ); circle_free( circle ); } return( 0 ); }
/**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the Qt Mobility Components. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage ** 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. ** ** Other Usage ** Alternatively, this file may be used in accordance with the terms and ** conditions contained in a signed written agreement between you and Nokia. ** ** ** ** ** ** $QT_END_LICENSE$ ** ****************************************************************************/ #ifndef QT7CIIMAGEVIDEOBUFFER_H #define QT7CIIMAGEVIDEOBUFFER_H #include "qt7backend.h" #import <QTKit/QTKit.h> #include <QtCore/qvariant.h> #include <qabstractvideobuffer.h> // // W A R N I N G // ------------- // // This file is not part of the Qt API. It exists purely as an // implementation detail. This header file may change from version to // version without notice, or even be removed. // // We mean it. // QT_BEGIN_NAMESPACE class QT7CIImageVideoBuffer : public QAbstractVideoBuffer { public: QT7CIImageVideoBuffer(CIImage *image); virtual ~QT7CIImageVideoBuffer(); MapMode mapMode() const; uchar *map(MapMode mode, int *numBytes, int *bytesPerLine); void unmap(); QVariant handle() const; private: CIImage *m_image; NSBitmapImageRep *m_buffer; MapMode m_mode; }; QT_END_NAMESPACE #endif
/**************************************************************************** ** ** Copyright (C) 2015 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing ** ** This file is part of Qt Creator. ** ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms and ** conditions see http://www.qt.io/terms-conditions. For further information ** use the contact form at http://www.qt.io/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, The Qt Company gives you certain additional ** rights. These rights are described in The Qt Company LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ****************************************************************************/ #ifndef FONTSETTINGSPAGE_H #define FONTSETTINGSPAGE_H #include "texteditor_global.h" #include "texteditorconstants.h" #include "colorscheme.h" #include "texteditoroptionspage.h" #include <QList> #include <QString> QT_BEGIN_NAMESPACE class QWidget; class QColor; QT_END_NAMESPACE namespace TextEditor { class Format; class FontSettings; namespace Internal { class FontSettingsPagePrivate; } // GUI description of a format consisting of id (settings key) // and displayName to be displayed class TEXTEDITOR_EXPORT FormatDescription { public: FormatDescription(TextStyle id, const QString &displayName, const QString &tooltipText, const QColor &foreground = Qt::black); FormatDescription(TextStyle id, const QString &displayName, const QString &tooltipText, const Format &format); TextStyle id() const { return m_id; } QString displayName() const { return m_displayName; } QColor foreground() const; QColor background() const; const Format &format() const { return m_format; } Format &format() { return m_format; } QString tooltipText() const { return m_tooltipText; } private: TextStyle m_id; // Name of the category Format m_format; // Default format QString m_displayName; // Displayed name of the category QString m_tooltipText; // Description text for category }; typedef QList<FormatDescription> FormatDescriptions; class TEXTEDITOR_EXPORT FontSettingsPage : public TextEditorOptionsPage { Q_OBJECT public: FontSettingsPage(const FormatDescriptions &fd, Core::Id id, QObject *parent = 0); ~FontSettingsPage(); QWidget *widget(); void apply(); void finish(); void saveSettings(); const FontSettings &fontSettings() const; signals: void changed(const TextEditor::FontSettings&); private slots: void delayedChange(); void fontSelected(const QFont &font); void fontSizeSelected(const QString &sizeString); void fontZoomChanged(); void antialiasChanged(); void colorSchemeSelected(int index); void openCopyColorSchemeDialog(); void copyColorScheme(const QString &name); void confirmDeleteColorScheme(); void deleteColorScheme(); private: void maybeSaveColorScheme(); void updatePointSizes(); QList<int> pointSizesForSelectedFont() const; void refreshColorSchemeList(); Internal::FontSettingsPagePrivate *d_ptr; }; } // namespace TextEditor #endif // FONTSETTINGSPAGE_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 tools applications of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage ** This file contains pre-release code and may not be distributed. ** You may use this file in accordance with the terms and conditions ** contained in the Technology Preview License Agreement accompanying ** this package. ** ** 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. ** ** If you have questions regarding the use of this file, please contact ** Nokia at qt-info@nokia.com. ** ** ** ** ** ** ** ** ** $QT_END_LICENSE$ ** ****************************************************************************/ /* codeparser.h */ #ifndef CODEPARSER_H #define CODEPARSER_H #include <QSet> #include "location.h" QT_BEGIN_NAMESPACE class Config; class Node; class QString; class Tree; class CodeParser { public: CodeParser(); virtual ~CodeParser(); virtual void initializeParser(const Config& config); virtual void terminateParser(); virtual QString language() = 0; virtual QString headerFileNameFilter(); virtual QString sourceFileNameFilter() = 0; virtual void parseHeaderFile(const Location& location, const QString& filePath, Tree *tree); virtual void parseSourceFile(const Location& location, const QString& filePath, Tree *tree) = 0; virtual void doneParsingHeaderFiles(Tree *tree); virtual void doneParsingSourceFiles(Tree *tree) = 0; static void initialize(const Config& config); static void terminate(); static CodeParser *parserForLanguage(const QString& language); protected: QSet<QString> commonMetaCommands(); void processCommonMetaCommand(const Location& location, const QString& command, const QString& arg, Node *node, Tree *tree); private: static QList<CodeParser *> parsers; static bool showInternal; }; QT_END_NAMESPACE #endif
/**************************************************************************** ** ** 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 Qt Mobility Components. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage ** 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. ** ** Other Usage ** Alternatively, this file may be used in accordance with the terms and ** conditions contained in a signed written agreement between you and Nokia. ** ** ** ** ** ** $QT_END_LICENSE$ ** ****************************************************************************/ #ifndef QDECLARATIVECONTACTURL_H #define QDECLARATIVECONTACTURL_H #include <QUrl> #include "qdeclarativecontactdetail_p.h" #include "qcontacturl.h" class QDeclarativeContactUrl : public QDeclarativeContactDetail { Q_OBJECT Q_PROPERTY(QString url READ url WRITE setUrl NOTIFY fieldsChanged) Q_PROPERTY(QVariant subType READ subType WRITE setSubType NOTIFY fieldsChanged) Q_ENUMS(FieldType) Q_ENUMS(UrlSubType) public: enum FieldType { Url = 0, SubType }; enum UrlSubType { Unknown = 0, HomePage, Blog, Favourite }; QDeclarativeContactUrl(QObject* parent = 0) :QDeclarativeContactDetail(parent) { setDetail(QContactUrl()); connect(this, SIGNAL(fieldsChanged()), SIGNAL(valueChanged())); } ContactDetailType detailType() const { return QDeclarativeContactDetail::Url; } static QString fieldNameFromFieldType(int fieldType) { switch (fieldType) { case Url: return QContactUrl::FieldUrl; case SubType: return QContactUrl::FieldSubType; default: break; } qmlInfo(0) << tr("Unknown field type."); return QString(); } void setUrl(const QString& v) { if (!readOnly() && v != url()) { detail().setValue(QContactUrl::FieldUrl, v); } } QString url() const {return detail().value(QContactUrl::FieldUrl);} void setSubType(const QVariant& v) { if (!readOnly()) { QString st; if (v.type() != QVariant::String) { switch (v.toInt()) { case HomePage: st = QLatin1String(QContactUrl::SubTypeHomePage); break; case Blog: st = QLatin1String(QContactUrl::SubTypeBlog); break; case Favourite: st = QLatin1String(QContactUrl::SubTypeFavourite); break; default:break; } } else { st = v.toString(); } if (st != detail().value(QContactUrl::FieldSubType)) { detail().setValue(QContactUrl::FieldSubType, st); emit fieldsChanged(); } } } QVariant subType() const { return detail().value(QContactUrl::FieldSubType); } signals: void fieldsChanged(); }; QML_DECLARE_TYPE(QDeclarativeContactUrl) #endif
/**************************************************************************** ** ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the plugins of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and Digia. For licensing terms and ** conditions see http://qt.digia.com/licensing. For further information ** use the contact form at http://qt.digia.com/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 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, Digia gives you certain additional ** rights. These rights are described in the Digia 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. ** ** ** $QT_END_LICENSE$ ** ****************************************************************************/ #include "qmeegofencesync.h" #ifndef QMEEGOFENCESYNC_P_H #define QMEEGOFENCESYNC_P_H class QMeeGoFenceSyncPrivate { public: Q_DECLARE_PUBLIC(QMeeGoFenceSync); QMeeGoFenceSyncPrivate(); virtual ~QMeeGoFenceSyncPrivate(); void* syncObject; QMeeGoFenceSync *q_ptr; }; #endif
/**************************************************************************** ** ** 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 QtGui module 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 QPROXYSTYLE_P_H #define QPROXYSTYLE_P_H // // W A R N I N G // ------------- // // This file is not part of the Qt API. It exists for the convenience // of qapplication_*.cpp, qwidget*.cpp and qfiledialog.cpp. This header // file may change from version to version without notice, or even be removed. // // We mean it. // #include "qcommonstyle.h" #include "qcommonstyle_p.h" #include "qproxystyle.h" #ifndef QT_NO_STYLE_PROXY QT_BEGIN_NAMESPACE class QProxyStylePrivate : public QCommonStylePrivate { Q_DECLARE_PUBLIC(QProxyStyle) public: void ensureBaseStyle() const; private: QProxyStylePrivate() : QCommonStylePrivate(), baseStyle(0) {} mutable QPointer <QStyle> baseStyle; }; QT_END_NAMESPACE #endif // QT_NO_STYLE_PROXY #endif //QPROXYSTYLE_P_H
/**************************************************************************** ** ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the Qt Mobility Components. ** ** $QT_BEGIN_LICENSE:LGPL$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and Digia. For licensing terms and ** conditions see http://qt.digia.com/licensing. For further information ** use the contact form at http://qt.digia.com/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 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, Digia gives you certain additional ** rights. These rights are described in the Digia 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. ** ** ** $QT_END_LICENSE$ ** ****************************************************************************/ #ifndef QMESSAGEACCOUNTSORTORDERPRIVATE_H #define QMESSAGEACCOUNTSORTORDERPRIVATE_H #include "qmessageaccountsortorder.h" #include "qstring.h" #if defined(Q_OS_SYMBIAN) || defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6) #include <qmessageaccount.h> #endif QTM_BEGIN_NAMESPACE class QMessageAccountSortOrderPrivate { public: QMessageAccountSortOrderPrivate(QMessageAccountSortOrder *sortOrder); bool _empty; Qt::SortOrder _order; QMessageAccountSortOrder *q_ptr; static Qt::SortOrder order(const QMessageAccountSortOrder &sortOrder) { return sortOrder.d_ptr->_order; } #if defined(Q_OS_SYMBIAN) || defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6) static bool lessThan(const QMessageAccountSortOrder &sortOrder, const QMessageAccount &account1, const QMessageAccount &account2); #endif }; QTM_END_NAMESPACE #endif
/* Copyright (C) 2011, 2010 Sebastian Pancratz Copyright (C) 2009 William Hart 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 <http://www.gnu.org/licenses/>. */ #include <stdio.h> #include <stdlib.h> #include <gmp.h> #include "flint.h" #include "fmpz.h" #include "fmpz_mod_poly.h" #include "ulong_extras.h" int main(void) { int i, result; FLINT_TEST_INIT(state); flint_printf("derivative...."); fflush(stdout); /* Check aliasing */ for (i = 0; i < 1000 * flint_test_multiplier(); i++) { fmpz_t p; fmpz_mod_poly_t a, b, c; fmpz_init(p); fmpz_randtest_unsigned(p, state, 2 * FLINT_BITS); fmpz_add_ui(p, p, 2); fmpz_mod_poly_init(a, p); fmpz_mod_poly_init(b, p); fmpz_mod_poly_init(c, p); fmpz_mod_poly_randtest(a, state, n_randint(state, 100)); fmpz_mod_poly_set(b, a); fmpz_mod_poly_derivative(c, b); fmpz_mod_poly_derivative(b, b); result = (fmpz_mod_poly_equal(b, c)); if (!result) { flint_printf("FAIL (alias):\n"); fmpz_mod_poly_print(a), flint_printf("\n\n"); fmpz_mod_poly_print(b), flint_printf("\n\n"); fmpz_mod_poly_print(c), flint_printf("\n\n"); abort(); } fmpz_mod_poly_clear(a); fmpz_mod_poly_clear(b); fmpz_mod_poly_clear(c); fmpz_clear(p); } /* Check constants have derivative zero */ for (i = 0; i < 1000 * flint_test_multiplier(); i++) { fmpz_t p; fmpz_mod_poly_t a, b; fmpz_init(p); fmpz_randtest_unsigned(p, state, 2 * FLINT_BITS); fmpz_add_ui(p, p, 2); fmpz_mod_poly_init(a, p); fmpz_mod_poly_init(b, p); fmpz_mod_poly_randtest(a, state, n_randint(state, 2)); fmpz_mod_poly_derivative(b, a); result = (b->length == 0); if (!result) { flint_printf("FAIL (da == 0):\n"); fmpz_mod_poly_print(a), flint_printf("\n\n"); fmpz_mod_poly_print(b), flint_printf("\n\n"); abort(); } fmpz_mod_poly_clear(a); fmpz_mod_poly_clear(b); fmpz_clear(p); } /* Check (f g)' = f' g + f g' */ for (i = 0; i < 1000 * flint_test_multiplier(); i++) { fmpz_t p; fmpz_mod_poly_t a, b, c, d, lhs, rhs; fmpz_init(p); fmpz_randtest_unsigned(p, state, 2 * FLINT_BITS); fmpz_add_ui(p, p, 2); fmpz_mod_poly_init(a, p); fmpz_mod_poly_init(b, p); fmpz_mod_poly_init(c, p); fmpz_mod_poly_init(d, p); fmpz_mod_poly_init(lhs, p); fmpz_mod_poly_init(rhs, p); fmpz_mod_poly_randtest(a, state, n_randint(state, 100)); fmpz_mod_poly_randtest(b, state, n_randint(state, 100)); fmpz_mod_poly_mul(lhs, a, b); fmpz_mod_poly_derivative(lhs, lhs); fmpz_mod_poly_derivative(c, a); fmpz_mod_poly_derivative(d, b); fmpz_mod_poly_mul(c, c, b); fmpz_mod_poly_mul(d, a, d); fmpz_mod_poly_add(rhs, c, d); result = fmpz_mod_poly_equal(lhs, rhs); if (!result) { flint_printf("FAIL (Leibniz):\n"); flint_printf("a = "), fmpz_mod_poly_print(a), flint_printf("\n\n"); flint_printf("b = "), fmpz_mod_poly_print(b), flint_printf("\n\n"); flint_printf("(ab)' = "), fmpz_mod_poly_print(lhs), flint_printf("\n\n"); flint_printf("a'b + ab' = "), fmpz_mod_poly_print(rhs), flint_printf("\n\n"); abort(); } fmpz_mod_poly_clear(a); fmpz_mod_poly_clear(b); fmpz_mod_poly_clear(c); fmpz_mod_poly_clear(d); fmpz_mod_poly_clear(lhs); fmpz_mod_poly_clear(rhs); fmpz_clear(p); } FLINT_TEST_CLEANUP(state); flint_printf("PASS\n"); return 0; }
/**************************************************************************** ** ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the Qt Mobility Components. ** ** $QT_BEGIN_LICENSE:LGPL$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and Digia. For licensing terms and ** conditions see http://qt.digia.com/licensing. For further information ** use the contact form at http://qt.digia.com/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 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, Digia gives you certain additional ** rights. These rights are described in the Digia 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. ** ** ** $QT_END_LICENSE$ ** ****************************************************************************/ #ifndef CNTSIMDETAILDEFINITIONFETCHREQUEST_H_ #define CNTSIMDETAILDEFINITIONFETCHREQUEST_H_ #include "cntabstractsimrequest.h" QTM_USE_NAMESPACE class CntSimDetailDefinitionFetchRequest : public CntAbstractSimRequest { Q_OBJECT public: CntSimDetailDefinitionFetchRequest(CntSymbianSimEngine *engine, QContactDetailDefinitionFetchRequest *req); virtual ~CntSimDetailDefinitionFetchRequest(); public Q_SLOTS: // from CntAbstractSimRequest void run(); }; #endif // CNTSIMDETAILDEFINITIONFETCHREQUEST_H_
/* Copyright (C) 2016 Vincent Delecroix 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 <http://www.gnu.org/licenses/>. */ #include <gmp.h> #include "flint.h" #include "fmpz.h" #include "fmpq.h" #include "fmpq_poly.h" void _fmpq_poly_power_sums_to_poly(fmpz * res, const fmpz * poly, const fmpz_t den, slong len) { slong i, k; fmpz_t f; slong d; ulong a; fmpz_init(f); fmpz_divexact(f, poly, den); d = fmpz_get_ui(f); fmpz_one(f); for (k = 1; k <= d; k++) { if(k < len) fmpz_mul(res + d - k, poly + k, f); else fmpz_zero(res + d - k); for (i = 1; i < FLINT_MIN(k, len); i++) fmpz_addmul(res + d - k, res + d - k + i, poly + i); a = n_gcd(FLINT_ABS(fmpz_fdiv_ui(res + d - k, k)), k); fmpz_divexact_ui(res + d - k, res + d - k, a); if (a != k) { a = k / a; for (i = d - k + 1; i < d; i++) fmpz_mul_ui(res + i, res + i, a); fmpz_mul_ui(f, f, a); } fmpz_neg(res + d - k, res + d - k); fmpz_mul(f, f, den); for (i = d - k + 1; i < d; i++) fmpz_mul(res + i, res + i, den); } fmpz_swap(res + d, f); fmpz_clear(f); } void fmpq_poly_power_sums_to_fmpz_poly(fmpz_poly_t res, const fmpq_poly_t Q) { if (Q->length == 0) fmpz_poly_one(res); else { fmpz_t fd; slong d; fmpz_init(fd); fmpz_divexact(fd, Q->coeffs, Q->den); d = fmpz_get_ui(fd); fmpz_clear(fd); fmpz_poly_fit_length(res, d + 1); _fmpq_poly_power_sums_to_poly(res->coeffs, Q->coeffs, Q->den, Q->length); _fmpz_poly_set_length(res, d + 1); _fmpz_poly_normalise(res); _fmpz_poly_primitive_part(res->coeffs, res->coeffs, d + 1); } } void fmpq_poly_power_sums_to_poly(fmpq_poly_t res, const fmpq_poly_t Q) { if (Q->length == 0) fmpq_poly_one(res); else { fmpz_t fd; slong d; fmpz_init(fd); fmpz_divexact(fd, Q->coeffs, Q->den); d = fmpz_get_ui(fd); fmpz_clear(fd); if (res == Q) { fmpq_poly_t t; fmpq_poly_init(t); fmpq_poly_fit_length(res, d + 1); _fmpq_poly_power_sums_to_poly(t->coeffs, Q->coeffs, Q->den, Q->length); fmpq_poly_swap(res, t); fmpq_poly_clear(t); } else { fmpq_poly_fit_length(res, d + 1); _fmpq_poly_power_sums_to_poly(res->coeffs, Q->coeffs, Q->den, Q->length); } _fmpq_poly_set_length(res, d + 1); _fmpq_poly_normalise(res); _fmpq_poly_make_monic(res->coeffs, res->den, res->coeffs, res->den, res->length); } }
#include <cxxtest/TestSuite.h> // // A simple test suite that cannot be parsed with the default test discovery mechanism // class BadTest : public CxxTest::TestSuite { public: void testEquality() { TS_ASSERT_EQUALS( 1, 1 ); TS_ASSERT_EQUALS( 1, 2 ); TS_ASSERT_EQUALS( 'a', 'A' ); TS_ASSERT_EQUALS( 1.0, -12345678900000000000000000000000000000000000000000.1234 ); } void testAddition() { TS_ASSERT_EQUALS( 1 + 1, 2 ); TS_ASSERT_EQUALS( 2 + 2, 5 ); } void TestMultiplication() { TS_ASSERT_EQUALS( 2 * 2, 4 ); TS_ASSERT_EQUALS( 4 * 4, 44 ); TS_ASSERT_DIFFERS( -2 * -2, 4 ); } void testComparison() { TS_ASSERT_LESS_THAN( (int)1, (unsigned long)2 ); TS_ASSERT_LESS_THAN( -1, -2 ); } void testTheWorldIsCrazy() { TS_ASSERT_EQUALS( true, false ); } void test_Failure() { TS_FAIL( "Not implemented" ); TS_FAIL( 1569779912 ); } void test_TS_WARN_macro() { TS_WARN( "Just a friendly warning" ); TS_WARN( "Warnings don't abort the test" ); } };
/* * Copyright (C) 2011, 2012, 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. AND ITS 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 APPLE INC. OR ITS 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 WKGeolocationManager_h #define WKGeolocationManager_h #include <WebKit/WKBase.h> #ifdef __cplusplus extern "C" { #endif // Provider. typedef void (*WKGeolocationProviderStartUpdatingCallback)(WKGeolocationManagerRef geolocationManager, const void* clientInfo); typedef void (*WKGeolocationProviderStopUpdatingCallback)(WKGeolocationManagerRef geolocationManager, const void* clientInfo); typedef void (*WKGeolocationProviderSetEnableHighAccuracyCallback)(WKGeolocationManagerRef geolocationManager, bool enabled, const void* clientInfo); typedef struct WKGeolocationProviderBase { int version; const void * clientInfo; } WKGeolocationProviderBase; typedef struct WKGeolocationProviderV0 { WKGeolocationProviderBase base; // Version 0. WKGeolocationProviderStartUpdatingCallback startUpdating; WKGeolocationProviderStopUpdatingCallback stopUpdating; } WKGeolocationProviderV0; typedef struct WKGeolocationProviderV1 { WKGeolocationProviderBase base; // Version 0. WKGeolocationProviderStartUpdatingCallback startUpdating; WKGeolocationProviderStopUpdatingCallback stopUpdating; // Version 1. WKGeolocationProviderSetEnableHighAccuracyCallback setEnableHighAccuracy; } WKGeolocationProviderV1; WK_EXPORT WKTypeID WKGeolocationManagerGetTypeID(); WK_EXPORT void WKGeolocationManagerSetProvider(WKGeolocationManagerRef geolocationManager, const WKGeolocationProviderBase* provider); WK_EXPORT void WKGeolocationManagerProviderDidChangePosition(WKGeolocationManagerRef geolocationManager, WKGeolocationPositionRef position); WK_EXPORT void WKGeolocationManagerProviderDidFailToDeterminePosition(WKGeolocationManagerRef geolocationManager); WK_EXPORT void WKGeolocationManagerProviderDidFailToDeterminePositionWithErrorMessage(WKGeolocationManagerRef geolocationManager, WKStringRef errorMessage); #ifdef __cplusplus } #endif #endif /* WKGeolocationManager_h */
/**************************************************************************** ** ** Copyright (C) 2017 Klaralvdalens Datakonsult AB (KDAB). ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt3D module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms ** and conditions see https://www.qt.io/terms-conditions. For further ** information use the contact form at https://www.qt.io/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 3 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL3 included in the ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 3 requirements ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. ** ** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 2.0 or (at your option) the GNU General ** Public license version 3 or any later version approved by the KDE Free ** Qt Foundation. The licenses are as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 ** included in the packaging of this file. Please review the following ** information to ensure the GNU General Public License requirements will ** be met: https://www.gnu.org/licenses/gpl-2.0.html and ** https://www.gnu.org/licenses/gpl-3.0.html. ** ** $QT_END_LICENSE$ ** ****************************************************************************/ #ifndef QT3DANIMATION_QCLIPBLENDVALUE_H #define QT3DANIMATION_QCLIPBLENDVALUE_H #include <Qt3DAnimation/qt3danimation_global.h> #include <Qt3DAnimation/qabstractclipblendnode.h> QT_BEGIN_NAMESPACE namespace Qt3DAnimation { class QClipBlendValuePrivate; class Q_3DANIMATIONSHARED_EXPORT QClipBlendValue : public Qt3DAnimation::QAbstractClipBlendNode { Q_OBJECT Q_PROPERTY(Qt3DAnimation::QAbstractAnimationClip *clip READ clip WRITE setClip NOTIFY clipChanged) public: explicit QClipBlendValue(Qt3DCore::QNode *parent = nullptr); explicit QClipBlendValue(Qt3DAnimation::QAbstractAnimationClip *clip, Qt3DCore::QNode *parent = nullptr); ~QClipBlendValue(); Qt3DAnimation::QAbstractAnimationClip *clip() const; public Q_SLOTS: void setClip(Qt3DAnimation::QAbstractAnimationClip *clip); Q_SIGNALS: void clipChanged(Qt3DAnimation::QAbstractAnimationClip *clip); protected: explicit QClipBlendValue(QClipBlendValuePrivate &dd, Qt3DCore::QNode *parent = nullptr); private: Q_DECLARE_PRIVATE(QClipBlendValue) }; } // namespace Qt3DAnimation QT_END_NAMESPACE #endif // QT3DANIMATION_QCLIPBLENDVALUE_H
/** * Copyright (c) 2018 panStamp S.L.U. <contact@panstamp.com> * * This file is part of the panStamp project. * * panStamp 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. * * panStamp 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 panStamp; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 * USA * * Author: Daniel Berenguer * Creation date: Dec 12 2018 */ #ifndef _REGTABLE_H #define _REGTABLE_H #include "register.h" #include "commonregs.h" /** * Register indexes */ DEFINE_REGINDEX_START() REGI_SENSOR DEFINE_REGINDEX_END() #endif
// Copyright (c) 2012-2015, The CryptoNote developers, The Bytecoin developers // // This file is part of Bytecoin. // // Bytecoin 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. // // Bytecoin 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 Bytecoin. If not, see <http://www.gnu.org/licenses/>. #pragma once #include "CryptoNote.h" namespace CryptoNote { class IBlock { public: virtual ~IBlock(); virtual const Block& getBlock() const = 0; virtual size_t getTransactionCount() const = 0; virtual const Transaction& getTransaction(size_t index) const = 0; }; }
/** * Copyright (c) 2016 panStamp <contact@panstamp.com> * * This file is part of the panStamp project. * * panStamp 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 * any later version. * * panStamp 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 panStamp; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 * USA * * Author: Daniel Berenguer * Creation date: 03/11/2016 */ #ifndef _GWSTATUS_H #define _GWSTATUS_H #include "gwpacket.h" class GWSTATUS : public GWPACKET { public: /** * GWSTATUS * * Class constructor * * @param rId Register id * @param val Pointer to new value * @param len Buffer length * @param type type of data contained */ GWSTATUS(uint8_t rId, uint8_t *val, uint8_t len, GWDTYPE type = GWDTYPE_OTHER); }; #endif
/*------------------------------------------------------------------------------ * (c) 2015 by Ivan Peon * All rights reserved *------------------------------------------------------------------------------ * Module : OsProcTest.h * Date : Jun 28, 2016 *------------------------------------------------------------------------------ * Module description: */ /** @file * ... */ /*------------------------------------------------------------------------------ */ #ifndef OSPROCTEST_H_ #define OSPROCTEST_H_ /*------------------------------------------------------------------------------ * Includes */ #include "cppunit/extensions/HelperMacros.h" #include "cppunit/TestCase.h" /*------------------------------------------------------------------------------ * Type definitions */ class COsProcTest : public CppUnit::TestCase { public: void setUp(); void tearDown(); CPPUNIT_TEST_SUITE(COsProcTest); CPPUNIT_TEST(Init); CPPUNIT_TEST(OwnNames); CPPUNIT_TEST(NameFromPID); CPPUNIT_TEST(CtrlTaskPID); CPPUNIT_TEST(PIDFiles); CPPUNIT_TEST(Prio); CPPUNIT_TEST(ControlThread); CPPUNIT_TEST(ControlTask); CPPUNIT_TEST(ControlTaskOvertime); CPPUNIT_TEST(ControlThreadOvertime); CPPUNIT_TEST(Exit); CPPUNIT_TEST_SUITE_END(); public: void Init(); void OwnNames(); void NameFromPID(); void CtrlTaskPID(); void PIDFiles(); void Prio(); void ControlThread(); void ControlTask(); void ControlTaskOvertime(); void ControlThreadOvertime(); void Exit(); }; #endif // OSPROCTEST_H_
#include <stdint.h> #include <stdlib.h> #include "pd9p.h" uint32_t pd9p_newfid(pd9p_session *s) { uint32_t fid; struct pd9p_fidlinklist *newp; if(!(*s).freefids) fid=(*s).fidcounter++; else { fid=(*(*s).freefids).fid; newp=(*(*s).freefids).next; free((*s).freefids); (*s).freefids=newp; } return fid; } void pd9p_delfid(pd9p_session *s, uint32_t fid) { struct pd9p_fidlinklist *newp; if((newp=malloc(sizeof(struct pd9p_fidlinklist))) == 0) exit(1); (*newp).fid=fid; (*newp).next=(*s).freefids; (*s).freefids=newp; }
#include "Python.h" static PyObject *__Pyx_UnpackItem(PyObject *, int); static int __Pyx_EndUnpack(PyObject *, int); static int __Pyx_PrintItem(PyObject *); static int __Pyx_PrintNewline(void); static void __Pyx_ReRaise(void); static void __Pyx_RaiseWithTraceback(PyObject *, PyObject *, PyObject *); static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list); static PyObject *__Pyx_GetExcValue(void); static PyObject *__Pyx_GetName(PyObject *dict, char *name); static PyObject *__pyx_m; static PyObject *__pyx_d; static PyObject *__pyx_b; PyObject *__pyx_f_primes(PyObject *__pyx_self, PyObject *__pyx_args); /*proto*/ PyObject *__pyx_f_primes(PyObject *__pyx_self, PyObject *__pyx_args) { int __pyx_v_kmax; int __pyx_v_n; int __pyx_v_k; int __pyx_v_i; int (__pyx_v_p[1000]); PyObject *__pyx_v_result; PyObject *__pyx_r; PyObject *__pyx_1 = 0; int __pyx_2; int __pyx_3; int __pyx_4; PyObject *__pyx_5 = 0; PyObject *__pyx_6 = 0; if (!PyArg_ParseTuple(__pyx_args, "i", &__pyx_v_kmax)) return 0; __pyx_v_result = Py_None; Py_INCREF(__pyx_v_result); /* "ProjectsA:Python:Pyrex:Demos:primes.pyx":2 */ /* "ProjectsA:Python:Pyrex:Demos:primes.pyx":3 */ /* "ProjectsA:Python:Pyrex:Demos:primes.pyx":4 */ __pyx_1 = PyList_New(0); if (!__pyx_1) goto __pyx_L1; Py_DECREF(__pyx_v_result); __pyx_v_result = __pyx_1; __pyx_1 = 0; /* "ProjectsA:Python:Pyrex:Demos:primes.pyx":5 */ __pyx_2 = (__pyx_v_kmax > 1000); if (__pyx_2) { /* "ProjectsA:Python:Pyrex:Demos:primes.pyx":6 */ __pyx_v_kmax = 1000; goto __pyx_L2; } __pyx_L2:; /* "ProjectsA:Python:Pyrex:Demos:primes.pyx":7 */ __pyx_v_k = 0; /* "ProjectsA:Python:Pyrex:Demos:primes.pyx":8 */ __pyx_v_n = 2; /* "ProjectsA:Python:Pyrex:Demos:primes.pyx":9 */ while (1) { __pyx_L3:; __pyx_2 = (__pyx_v_k < __pyx_v_kmax); if (!__pyx_2) break; /* "ProjectsA:Python:Pyrex:Demos:primes.pyx":10 */ __pyx_v_i = 0; /* "ProjectsA:Python:Pyrex:Demos:primes.pyx":11 */ while (1) { __pyx_L5:; if (__pyx_3 = (__pyx_v_i < __pyx_v_k)) { __pyx_3 = ((__pyx_v_n % (__pyx_v_p[__pyx_v_i])) != 0); } if (!__pyx_3) break; /* "ProjectsA:Python:Pyrex:Demos:primes.pyx":12 */ __pyx_v_i = (__pyx_v_i + 1); } __pyx_L6:; /* "ProjectsA:Python:Pyrex:Demos:primes.pyx":13 */ __pyx_4 = (__pyx_v_i == __pyx_v_k); if (__pyx_4) { /* "ProjectsA:Python:Pyrex:Demos:primes.pyx":14 */ (__pyx_v_p[__pyx_v_k]) = __pyx_v_n; /* "ProjectsA:Python:Pyrex:Demos:primes.pyx":15 */ __pyx_v_k = (__pyx_v_k + 1); /* "ProjectsA:Python:Pyrex:Demos:primes.pyx":16 */ __pyx_1 = PyObject_GetAttrString(__pyx_v_result, "append"); if (!__pyx_1) goto __pyx_L1; __pyx_5 = PyInt_FromLong(__pyx_v_n); if (!__pyx_5) goto __pyx_L1; __pyx_6 = PyTuple_New(1); if (!__pyx_6) goto __pyx_L1; PyTuple_SET_ITEM(__pyx_6, 0, __pyx_5); __pyx_5 = 0; __pyx_5 = PyObject_CallObject(__pyx_1, __pyx_6); if (!__pyx_5) goto __pyx_L1; Py_DECREF(__pyx_6); __pyx_6 = 0; Py_DECREF(__pyx_5); __pyx_5 = 0; goto __pyx_L7; } __pyx_L7:; /* "ProjectsA:Python:Pyrex:Demos:primes.pyx":17 */ __pyx_v_n = (__pyx_v_n + 1); } __pyx_L4:; /* "ProjectsA:Python:Pyrex:Demos:primes.pyx":18 */ Py_INCREF(__pyx_v_result); __pyx_r = __pyx_v_result; goto __pyx_L0; __pyx_r = Py_None; Py_INCREF(__pyx_r); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_1); Py_XDECREF(__pyx_5); Py_XDECREF(__pyx_6); __pyx_r = 0; __pyx_L0:; Py_DECREF(__pyx_v_result); return __pyx_r; } static struct PyMethodDef __pyx_methods[] = { {"primes", (PyCFunction)__pyx_f_primes, METH_VARARGS, 0}, {0, 0, 0, 0} }; void initprimes(void); /*proto*/ void initprimes(void) { __pyx_m = Py_InitModule4("primes", __pyx_methods, 0, 0, PYTHON_API_VERSION); __pyx_d = PyModule_GetDict(__pyx_m); __pyx_b = PyImport_AddModule("__builtin__"); PyDict_SetItemString(__pyx_d, "__builtins__", __pyx_b); } /* Runtime support code */
#pragma once #include "Serialize.h" class Serialize__tagUserOwnProjectTab : public Serialize_StructBase<_tagUserOwnProjectTab,Serialize__tagUserOwnProjectTab> { public: typedef _tagUserOwnProjectTab _MyObjectType; Serialize_map<Serialize_BaseObject<tstring> ,Serialize__tagUserProjectSet ,less<tstring>> OwnProjectArray; Serialize__tagUserOwnProjectTab(){}; ~Serialize__tagUserOwnProjectTab(){}; _Myt& operator=(_tagUserOwnProjectTab & _X); void GetData(); BOOL Construct(StorageObjectInterface * pOutObject); void SetData(_tagUserOwnProjectTab & _X); BOOL LoadGetCurSerializeObject(FieldAddr & CurFieldAddr, SerializeLoadSaveInterface * * RetObj); BOOL Save(StorageObjectInterface * pStorageObject); BOOL GetObjectMap(IN OUT vector<SerializeObjectInterface *> & ObjectInterfaceMap); };
// Copyright 2020 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // ospray #include "../ImageOp.h" #include "rkcommon/tasking/parallel_for.h" // std #include <algorithm> namespace ospray { // The blur frame op is a test which applies a Gaussian blur to the frame struct OSPRAY_SDK_INTERFACE BlurFrameOp : public FrameOp { std::unique_ptr<LiveImageOp> attach(FrameBufferView &fbView) override; std::string toString() const override; }; template <typename T> struct OSPRAY_SDK_INTERFACE LiveBlurFrameOp : public LiveFrameOp { LiveBlurFrameOp(FrameBufferView &_fbView) : LiveFrameOp(_fbView) {} void process(const Camera *) override; }; // Inlined definitions //////////////////////////////////////////////////////// template <typename T> inline void LiveBlurFrameOp<T>::process(const Camera *) { // TODO: For SRGBA we actually need to convert to linear before filtering T *color = static_cast<T *>(fbView.colorBuffer); const int blurRadius = 4; // variance = std-dev^2 const float variance = 9.f; std::vector<T> blurScratch(fbView.fbDims.x * fbView.fbDims.y * 4, 0); // Blur along X for each pixel tasking::parallel_for(fbView.fbDims.x * fbView.fbDims.y, [&](int pixelID) { int i = pixelID % fbView.fbDims.x; int j = pixelID / fbView.fbDims.x; vec4f result = 0.f; float weightSum = 0.f; for (int b = -blurRadius; b <= blurRadius; ++b) { const int bx = i + b; if (bx < 0 || bx >= fbView.fbDims.x) continue; float weight = 1.f / std::sqrt(2 * M_PI * variance) * std::exp(b / (2.f * variance)); weightSum += weight; // Assumes 4 color channels, which is the case for the OSPRay color // buffer types for (int c = 0; c < 4; ++c) result[c] += color[(j * fbView.fbDims.x + bx) * 4 + c] * weight; } for (int c = 0; c < 4; ++c) blurScratch[(j * fbView.fbDims.x + i) * 4 + c] = result[c] / weightSum; }); // Blur along Y for each pixel tasking::parallel_for(fbView.fbDims.x * fbView.fbDims.y, [&](int pixelID) { int i = pixelID % fbView.fbDims.x; int j = pixelID / fbView.fbDims.x; vec4f result = 0.f; float weightSum = 0.f; for (int b = -blurRadius; b <= blurRadius; ++b) { const int by = j + b; if (by < 0 || by >= fbView.fbDims.y) continue; float weight = 1.f / std::sqrt(2 * M_PI * variance) * std::exp(b / (2.f * variance)); weightSum += weight; // Assumes 4 color channels, which is the case for the OSPRay color // buffer types for (int c = 0; c < 4; ++c) result[c] += blurScratch[(by * fbView.fbDims.x + i) * 4 + c] * weight; } for (int c = 0; c < 4; ++c) color[(j * fbView.fbDims.x + i) * 4 + c] = result[c] / weightSum; }); } } // namespace ospray
/*========================================================================= Library: TubeTK Copyright 2010 Kitware Inc. 28 Corporate Drive, Clifton Park, NY, 12065, USA. 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 __itktubeMetaRidgeSeed_h #define __itktubeMetaRidgeSeed_h #include "itktubeMetaLDA.h" #include <metaForm.h> namespace itk { namespace tube { /** * * Reads and Writes MetaRidgeSeed Files, typically designated .mnda files * * REQUIRED: RidgeSeedGenerator instance * * \author Stephen R. Aylward * * \date August 29, 1999 * */ class MetaRidgeSeed : public MetaLDA { public: typedef std::vector< double > RidgeSeedScalesType; typedef MetaLDA::LDAValuesType LDAValuesType; typedef MetaLDA::LDAMatrixType LDAMatrixType; MetaRidgeSeed( void ); MetaRidgeSeed( const char * _headerName ); MetaRidgeSeed( const MetaRidgeSeed & _metaRidgeSeed ); MetaRidgeSeed( const RidgeSeedScalesType & _ridgeScales, const bool _useIntensityOnly, const LDAValuesType & _ldaValues, const LDAMatrixType & _ldaMatrix, const ValueListType & _inputWhitenMeans, const ValueListType & _inputWhitenStdDevs, const ValueListType & _outputWhitenMeans, const ValueListType & _outputWhitenStdDevs, const std::string & _pdfFileName ); ~MetaRidgeSeed( void ); virtual void PrintInfo( void ) const; using MetaLDA::CopyInfo; virtual void CopyInfo( const MetaRidgeSeed & _lda ); virtual void Clear( void ); bool InitializeEssential( const RidgeSeedScalesType & _ridgeScales, const bool _useIntensityOnly, const LDAValuesType & _ldaValues, const LDAMatrixType & _ldaMatrix, const ValueListType & _inputWhitenMeans, const ValueListType & _inputWhitenStdDevs, const ValueListType & _outputWhitenMeans, const ValueListType & _outputWhitenStdDevs, const std::string & _pdfFileName ); void SetRidgeSeedScales( const RidgeSeedScalesType & _ridgeScales ); const RidgeSeedScalesType & GetRidgeSeedScales( void ) const; void SetUseIntensityOnly( bool _useIntensityOnly ); bool GetUseIntensityOnly( void ) const; void SetPDFFileName( const std::string & _pdfFileName ); const std::string & GetPDFFileName( void ) const; void SetRidgeId( int _ridgeId ); int GetRidgeId( void ) const; void SetBackgroundId( int _backgroundId ); int GetBackgroundId( void ) const; void SetUnknownId( int _unknownId ); int GetUnknownId( void ) const; void SetSeedTolerance( double _seedTolerance ); double GetSeedTolerance( void ) const; void SetSkeletonize( bool _skeletonize ); bool GetSkeletonize( void ) const; virtual bool CanRead( const char * _headerName = NULL ) const; virtual bool Read( const char * _headerName = NULL ); virtual bool CanReadStream( std::ifstream * _stream ) const; virtual bool ReadStream( std::ifstream * _stream ); virtual bool Write( const char * _headName = NULL ); virtual bool WriteStream( std::ofstream * _stream ); protected: void M_Destroy( void ); void M_SetupReadFields( void ); void M_SetupWriteFields( void ); bool M_Read( void ); bool m_UseIntensityOnly; int m_RidgeId; int m_BackgroundId; int m_UnknownId; double m_SeedTolerance; bool m_Skeletonize; RidgeSeedScalesType m_RidgeSeedScales; std::string m_PDFFileName; }; // End class MetaRidgeSeed } // End namespace tube } // End namespace itk #endif // End !defined( __itktubeMetaRidgeSeed_h )
/* * Copyright 2011-2013 Ziminji * * 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. */ #import "ZIMSqlStatement.h" #import "ZIMSqlDataDefinitionCommand.h" /*! @class ZIMSqlTruncateTableStatement @discussion This class represents an SQL truncate table statement. Execute as a transaction. @updated 2011-11-01 @see http://dev.mysql.com/doc/refman/5.0/en/truncate-table.html @see http://stackoverflow.com/questions/3443630/reset-the-row-number-count-in-sqlite3-mysql */ @interface ZIMSqlTruncateTableStatement : NSObject <ZIMSqlStatement, ZIMSqlDataDefinitionCommand> { @protected NSString *_tableIdentifier; NSString *_tableName; } /*! @method table: @discussion This method will set the table used in the SQL statement. @param table The table that will be used in the SQL statement. @updated 2012-03-20 */ - (void) table: (NSString *)table; /*! @method statement @discussion This method will return the SQL statement. @return The SQL statement that was constructed. @updated 2011-11-01 */ - (NSString *) statement; @end
/* * Copyright 2006-2008 The FLWOR Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <zorba/zorbac.h> #include <zorba/store_manager_c.h> XQC_Error gError; // define a callback function that is called if an error occurs // during preparing or executing the query. This version is using // Zorba's extended error handler. void zerror_handler(XQC_ErrorHandler* handler, XQC_Error error, const char *local_name, const char *description, const char *query_uri, unsigned int line, unsigned int column) { printf("query_uri: %s\nlocalname: %s\ndescription: %s\nline: %i\ncolumn: %i\n", query_uri, local_name, description, line, column); // Remember the error code gError = error; } // This version uses XQC's basic error handler. void error_handler(XQC_ErrorHandler* handler, XQC_Error error, const char* error_uri, const char* error_name, const char* description, XQC_Sequence* error_object) { printf("error: %s:%s\ndescription: %s\n", error_uri, error_name, description); gError = error; } // Convenience function XQC_ErrorHandler* create_error_handler() { XQC_ErrorHandler* lErrorHandler = (XQC_ErrorHandler*) malloc(sizeof(XQC_ErrorHandler)); lErrorHandler->error = error_handler; // reset global error code gError = XQC_NO_ERROR; return lErrorHandler; } /** * Use an error handler and test it by preparing a syntactically wrong query. */ int cerror_example_1(XQC_Implementation* impl) { XQC_Error lError = XQC_NO_ERROR; XQC_Expression* lExpr; XQC_StaticContext* lCtx; XQC_ErrorHandler* lErrorHandler = create_error_handler(); // Assign error handler to the static context impl->create_context(impl, &lCtx); lCtx->set_error_handler(lCtx, lErrorHandler); // compile the query lError = impl->prepare(impl, "for $i in 1, 2, 3", lCtx, &lExpr); // no need to free the query // because it was not successfully created free(lErrorHandler); lCtx->free(lCtx); return (gError == XQC_STATIC_ERROR && lError == XQC_STATIC_ERROR) ? 1 : 0; } /** * Use an error handler and test it by executing a query that raises an error. */ int cerror_example_2(XQC_Implementation* impl) { XQC_Expression* lExpr; XQC_DynamicContext* lCtx; XQC_ErrorHandler* lErrorHandler = create_error_handler(); XQC_Sequence* lResult; // compile the query impl->prepare(impl, "1 div 0", NULL, &lExpr); // set the error handler for handling errors // during query execution lExpr->create_context(lExpr, &lCtx); lCtx->set_error_handler(lCtx, lErrorHandler); // execute it and iterate results lExpr->execute(lExpr, lCtx, &lResult); while (lResult->next(lResult) == XQC_NO_ERROR); // release all resources lResult->free(lResult); lExpr->free(lExpr); lCtx->free(lCtx); free(lErrorHandler); return gError == XQC_DYNAMIC_ERROR ? 1 : 0; } int cerror_example_3(XQC_Implementation* impl) { XQC_Error lError = XQC_NO_ERROR; XQC_Expression* lExpr; XQC_StaticContext* lCtx; const char* lStringValue; XQC_Sequence* lResult; XQC_ErrorHandler* lErrorHandler = create_error_handler(); // Assign error handler to the static context impl->create_context(impl, &lCtx); lCtx->set_error_handler(lCtx, lErrorHandler); // compile the query and get the result as a sequence lError = impl->prepare(impl, "for $i in (3, 2, 1, 0) return 3 div $i", lCtx, &lExpr); lExpr->execute(lExpr, NULL, &lResult); // an error is reported during the last for iteration // the error callback function is called and the loop terminates while ( lResult->next(lResult) == XQC_NO_ERROR ) { lResult->string_value(lResult, &lStringValue); printf("%s ", lStringValue); } // release all aquired resources free(lErrorHandler); lResult->free(lResult); lExpr->free(lExpr); lCtx->free(lCtx); return (gError == XQC_DYNAMIC_ERROR && lError == XQC_NO_ERROR) ? 1 : 0; } int cerror(int argc, char** argv) { int res = 0; XQC_Implementation* impl; void* store = create_store(); if ( zorba_implementation(&impl, store) != XQC_NO_ERROR) return 1; printf("executing C example 1\n"); res = cerror_example_1(impl); if (!res) { impl->free(impl); return 1; }; printf("\n"); printf("executing C example 2\n"); res = cerror_example_2(impl); if (!res) { impl->free(impl); return 1; }; printf("\n"); printf("executing C example 3\n"); res = cerror_example_3(impl); if (!res) { impl->free(impl); return 1; }; printf("\n"); impl->free(impl); shutdown_store(store); return 0; }
/* $OpenBSD: xmalloc.c,v 1.2 2009/06/07 08:39:13 ray Exp $ */ /* * Author: Tatu Ylonen <ylo@cs.hut.fi> * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland * All rights reserved * Versions of malloc and friends that check their results, and never return * failure (they call fatal if they encounter an error). * * As far as I am concerned, the code I have written for this software * can be used freely for any purpose. Any derived versions of this * software must be clearly marked as such, and if the derived work is * incompatible with the protocol description in the RFC file, it must be * called by a name other than "ssh" or "Secure Shell". */ #include <err.h> #include <limits.h> #include <stdarg.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include "xmalloc.h" void * xmalloc(size_t size) { void *ptr; if (size == 0) errx(2, NULL); ptr = malloc(size); if (ptr == NULL) errx(2, NULL); return ptr; } void * xcalloc(size_t nmemb, size_t size) { void *ptr; if (size == 0 || nmemb == 0) errx(1, "xcalloc: zero size"); if (SIZE_MAX / nmemb < size) errx(1, "xcalloc: nmemb * size > SIZE_MAX"); ptr = calloc(nmemb, size); if (ptr == NULL) errx(1, "xcalloc: out of memory (allocating %lu bytes)", (u_long)(size * nmemb)); return ptr; } void * xrealloc(void *ptr, size_t nmemb, size_t size) { void *new_ptr; size_t new_size = nmemb * size; if (new_size == 0) errx(2, NULL); if (SIZE_MAX / nmemb < size) errx(2, NULL); if (ptr == NULL) new_ptr = malloc(new_size); else new_ptr = realloc(ptr, new_size); if (new_ptr == NULL) errx(2, NULL); return new_ptr; } void xfree(void *ptr) { if (ptr == NULL) errx(2, NULL); free(ptr); } char * xstrdup(const char *str) { size_t len; char *cp; len = strlen(str) + 1; cp = xmalloc(len); strlcpy(cp, str, len); return cp; } #if 0 int xasprintf(char **ret, const char *fmt, ...) { va_list ap; int i; va_start(ap, fmt); i = vasprintf(ret, fmt, ap); va_end(ap); if (i < 0 || *ret == NULL) errx(2, NULL); return (i); } #endif
/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ /* * Copyright 2017 Couchbase, Inc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once #include <algorithm> #include <cstdint> #include <string> #include <vector> namespace Collections { /** * Manifest is an object that is constructed from JSON data as per * a set_collections command * * Users of this class can then obtain the revision, separator and * all collections that are included in the manifest. */ class Manifest { public: /* * Initialise the default manifest */ Manifest(); /* * Create a manifest from json. * Validates the json as per SET_COLLECTIONS rules. */ Manifest(const std::string& json); int getRevision() const { return revision; } const std::string& getSeparator() const { return separator; } bool doesDefaultCollectionExist() const { return defaultCollectionExists; } std::vector<std::string>::const_iterator begin() const { return collections.begin(); } std::vector<std::string>::const_iterator end() const { return collections.end(); } size_t size() const { return collections.size(); } std::vector<std::string>::const_iterator find( const std::string& collection) const { return std::find(begin(), end(), collection); } private: /** * Check if the C-string input has a length > 0 and < 250. * * @param separator a C-string representing the separator. */ static bool validSeparator(const char* separator); /** * Check if the C-string represents a legal collection name. * Current validation is to ensure we block creation of _ prefixed * collections and only accept $default for $ prefixed names. * @param collection a C-string representing a collection name. */ static bool validCollection(const char* collection); int revision; bool defaultCollectionExists; std::string separator; std::vector<std::string> collections; }; } // end namespace Collections
/* * Copyright (c) 2017 Linaro Limited * Copyright (c) 2017 BayLibre, SAS. * * SPDX-License-Identifier: Apache-2.0 */ #ifndef DRIVERS_FLASH_STM32_H #define DRIVERS_FLASH_STM32_H #include <flash_registers.h> #if defined(CONFIG_SOC_SERIES_STM32F4X) #include <flash_map.h> #endif #if defined(CONFIG_SOC_SERIES_STM32L4X) #include <clock_control.h> #include <clock_control/stm32_clock_control.h> #endif struct flash_stm32_priv { #if defined(CONFIG_SOC_SERIES_STM32F4X) struct stm32f4x_flash *regs; #elif defined(CONFIG_SOC_SERIES_STM32L4X) struct stm32l4x_flash *regs; /* clock subsystem driving this peripheral */ struct stm32_pclken pclken; #endif struct k_sem sem; }; bool flash_stm32_valid_range(off_t offset, u32_t len); int flash_stm32_write_range(unsigned int offset, const void *data, unsigned int len, struct flash_stm32_priv *p); int flash_stm32_block_erase_loop(unsigned int offset, unsigned int len, struct flash_stm32_priv *p); void flash_stm32_flush_caches(struct flash_stm32_priv *p); int flash_stm32_wait_flash_idle(struct flash_stm32_priv *p); int flash_stm32_check_status(struct flash_stm32_priv *p); int flash_stm32_erase(struct device *dev, off_t offset, size_t len); int flash_stm32_write(struct device *dev, off_t offset, const void *data, size_t len); #endif /* DRIVERS_FLASH_STM32_H */
// // Cannon.h // findit // // Created by Hongmin Wang on 6/7/15. // Copyright (c) 2015 www.whunmr.com. All rights reserved. // #import <SpriteKit/SpriteKit.h> #import "common.h" @interface Cannon : SKSpriteNode<Updatable> +(Cannon*)cannon: (NSString*)param; -(void)update:(CFTimeInterval)currentTime; @end
/*========================================================================= Program: Visualization Toolkit Module: $RCSfile: MainFrm.h,v $ 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. =========================================================================*/ // MainFrm.h : interface of the CMainFrame class // ///////////////////////////////////////////////////////////////////////////// #if !defined(AFX_MAINFRM_H__B7F7B85D_EEC9_11D2_87FE_0060082B79FD__INCLUDED_) #define AFX_MAINFRM_H__B7F7B85D_EEC9_11D2_87FE_0060082B79FD__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 class CMainFrame : public CMDIFrameWnd { DECLARE_DYNAMIC(CMainFrame) public: CMainFrame(); // Attributes public: // Operations public: // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CMainFrame) virtual BOOL PreCreateWindow(CREATESTRUCT& cs); //}}AFX_VIRTUAL // Implementation public: virtual ~CMainFrame(); #ifdef _DEBUG virtual void AssertValid() const; virtual void Dump(CDumpContext& dc) const; #endif // Generated message map functions protected: //{{AFX_MSG(CMainFrame) // NOTE - the ClassWizard will add and remove member functions here. // DO NOT EDIT what you see in these blocks of generated code! //}}AFX_MSG DECLARE_MESSAGE_MAP() }; ///////////////////////////////////////////////////////////////////////////// //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_MAINFRM_H__B7F7B85D_EEC9_11D2_87FE_0060082B79FD__INCLUDED_)
// Copyright 2015 Google, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #include <iostream> #include <cassert> #include <cmath> using namespace std; template <typename T, typename U> inline void assert_lt(T l, U r, const char *msg) { if (!(l < r)) { cerr << "Assertion failed: " << msg << " " << l << " !< " << r << endl; } } template <typename T, typename U> inline void assert_eq(T l, U r, const char *msg) { if (l != r) { cerr << "Assertion failed: " << msg << " " << l << " != " << r << endl; } } inline void assert_true(bool c, const char *msg) { if (!c) { cerr << "Assertion failed: " << msg << endl; } } inline void assert_false(bool c, const char *msg) { if (c) { cerr << "Assertion failed: " << msg << endl; } } #define ASSERT_LT(x, y) assert_lt(x, y, #x" < "#y) #define ASSERT_EQ(x, y) assert_lt(x, y, #x" == "#y) #define ASSERT_TRUE(x) assert_true(x, #x) #define ASSERT_FALSE(x) assert_false(x, "!"#x)
/* ========================================================================= * * * * The Apache Software License, Version 1.1 * * * * Copyright (c) 1999-2003 The Apache Software Foundation. * * All rights reserved. * * * * ========================================================================= * * * * Redistribution and use in source and binary forms, with or without modi- * * fication, are permitted provided that the following conditions are met: * * * * 1. Redistributions of source code must retain the above copyright notice * * 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. The end-user documentation included with the redistribution, if any, * * must include the following acknowlegement: * * * * "This product includes software developed by the Apache Software * * Foundation <http://www.apache.org/>." * * * * Alternately, this acknowlegement may appear in the software itself, if * * and wherever such third-party acknowlegements normally appear. * * * * 4. The names "The Jakarta Project", "Jk", and "Apache Software * * Foundation" must not be used to endorse or promote products derived * * from this software without prior written permission. For written * * permission, please contact <apache@apache.org>. * * * * 5. Products derived from this software may not be called "Apache" nor may * * "Apache" appear in their names without prior written permission of the * * Apache Software Foundation. * * * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED 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 APACHE SOFTWARE FOUNDATION OR ITS 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. * * * * ========================================================================= * * * * This software consists of voluntary contributions made by many indivi- * * duals on behalf of the Apache Software Foundation. For more information * * on the Apache Software Foundation, please see <http://www.apache.org/>. * * * * ========================================================================= */ /*************************************************************************** * Description: Workers controller header file * * Author: Gal Shachor <shachor@il.ibm.com> * * Version: $Revision: 1.8 $ * ***************************************************************************/ #ifndef JK_WORKER_H #define JK_WORKER_H #include "jk_logger.h" #include "jk_service.h" #include "jk_map.h" #include "jk_uri_worker_map.h" #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ int wc_open(jk_map_t *init_data, jk_worker_env_t *we, jk_logger_t *l); void wc_close(jk_logger_t *l); jk_worker_t *wc_get_worker_for_name(const char *name, jk_logger_t *l); int wc_create_worker(const char *name, jk_map_t *init_data, jk_worker_t **rc, jk_worker_env_t *we, jk_logger_t *l); #ifdef __cplusplus } #endif /* __cplusplus */ #endif /* JK_WORKER_H */
/* * Copyright 2014 - 2015 Real Logic Ltd. * * 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 INCLUDED_ATOMIC64_GCC_X86_64_ #define INCLUDED_ATOMIC64_GCC_X86_64_ namespace aeron { namespace concurrent { namespace atomic { /** * A compiler directive not reorder instructions. */ inline void thread_fence() { asm volatile("" ::: "memory"); } /** * Fence operation that uses locked addl as mfence is sometimes expensive */ inline void fence() { asm volatile("lock; addl $0,0(%%rsp)" : : : "cc", "memory"); } inline void acquire() { volatile std::int64_t* dummy; asm volatile("movq 0(%%rsp), %0" : "=r" (dummy) : : "memory"); } inline void release() { #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-variable" // Avoid hitting the same cache-line from different threads. volatile std::int64_t dummy = 0; #pragma GCC diagnostic pop } /** * A more jitter friendly alternate to thread:yield in spin waits. */ inline void cpu_pause() { asm volatile("pause\n": : :"memory"); } /** * Returns a 32 bit integer with volatile semantics. * On x64 MOV is a SC Atomic a operation. */ inline std::int32_t getInt32Volatile(volatile std::int32_t* source) { int32_t sequence = *reinterpret_cast<volatile std::int32_t *>(source); thread_fence(); return sequence; } /** * Put a 32 bit int with volatile semantics */ inline void putInt32Volatile(volatile std::int32_t* source, std::int32_t value) { thread_fence(); *reinterpret_cast<volatile std::int32_t *>(source) = value; } /** * Put a 32 bit int with ordered semantics */ inline void putInt32Ordered(volatile std::int32_t* source, std::int32_t value) { thread_fence(); *reinterpret_cast<volatile std::int32_t *>(source) = value; } /** * Put a 32 bit int with atomic semantics. **/ inline void putInt32Atomic(volatile std::int32_t* address, std::int32_t value) { asm volatile( "xchgl (%2), %0" : "=r" (value) : "0" (value), "r" (address) : "memory"); } /** * Returns a 64 bit integer with volatile semantics. * On x64 MOV is a SC Atomic a operation. */ inline std::int64_t getInt64Volatile(volatile std::int64_t* source) { int64_t sequence = *reinterpret_cast<volatile std::int64_t *>(source); thread_fence(); return sequence; } /** * Put a 64 bit int with volatile semantics. */ inline void putInt64Volatile(volatile std::int64_t* address, std::int64_t value) { thread_fence(); *reinterpret_cast<volatile std::int64_t *>(address) = value; } /** * Put a 64 bit int with ordered semantics. */ inline void putInt64Ordered(volatile std::int64_t* address, std::int64_t value) { thread_fence(); *reinterpret_cast<volatile std::int64_t *>(address) = value; } /** * Put a 64 bit int with atomic semantics. **/ inline void putInt64Atomic(volatile std::int64_t* address, std::int64_t value) { asm volatile( "xchgq (%2), %0" : "=r" (value) : "0" (value), "r" (address) : "memory"); } inline std::int64_t getAndAddInt64(volatile std::int64_t* address, std::int64_t value) { std::int64_t original; asm volatile( "lock; xaddq %0, %1" : "=r"(original), "+m"(*address) : "0"(value)); return original; } inline std::int32_t getAndAddInt32(volatile std::int32_t* address, std::int32_t value) { std::int32_t original; asm volatile( "lock; xaddl %0, %1" : "=r"(original), "+m"(*address) : "0"(value)); return original; } inline std::int32_t cmpxchg(volatile std::int32_t* destination, std::int32_t expected, std::int32_t desired) { std::int32_t original; asm volatile( "lock; cmpxchgl %2, %1" : "=a"(original), "+m"(*destination) : "q"(desired), "0"(expected)); return original; } inline std::int64_t cmpxchg(volatile std::int64_t* destination, std::int64_t expected, std::int64_t desired) { std::int64_t original; asm volatile( "lock; cmpxchgq %2, %1" : "=a"(original), "+m"(*destination) : "q"(desired), "0"(expected)); return original; } //------------------------------------- // Alignment //------------------------------------- // Note: May not work on local variables. // http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24691 #define AERON_DECL_ALIGNED(declaration, amt) declaration __attribute__((aligned(amt))) }}} #endif
/* Copyright 2016 Mirantis 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 PKG_LIBVIRTTOOLS_ERROR_H_ #define PKG_LIBVIRTTOOLS_ERROR_H_ enum virtletErr { VIRTLET_OK = 0, }; #endif // PKG_LIBVIRTTOOLS_ERROR_H_
/*========================================================================= * * Copyright NumFOCUS * * 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 itkLevelSetEvolutionNumberOfIterationsStoppingCriterion_h #define itkLevelSetEvolutionNumberOfIterationsStoppingCriterion_h #include "itkObjectFactory.h" #include "itkLevelSetEvolutionStoppingCriterion.h" namespace itk { /** *\class LevelSetEvolutionStoppingCriterion \ingroup ITKLevelSetsv4 */ template <typename TLevelSetContainer> class ITK_TEMPLATE_EXPORT LevelSetEvolutionNumberOfIterationsStoppingCriterion : public LevelSetEvolutionStoppingCriterion<TLevelSetContainer> { public: ITK_DISALLOW_COPY_AND_ASSIGN(LevelSetEvolutionNumberOfIterationsStoppingCriterion); using Self = LevelSetEvolutionNumberOfIterationsStoppingCriterion; using Superclass = LevelSetEvolutionStoppingCriterion<TLevelSetContainer>; using Pointer = SmartPointer<Self>; using ConstPointer = SmartPointer<const Self>; /** Method for creation through object factory */ itkNewMacro(Self); /** Run-time type information (and related methods). */ itkTypeMacro(LevelSetEvolutionNumberOfIterationsStoppingCriterion, LevelSetEvolutionStoppingCriterion); using LevelSetContainerType = TLevelSetContainer; using LevelSetContainerPointer = typename LevelSetContainerType::Pointer; using LevelSetIdentifierType = typename LevelSetContainerType::LevelSetIdentifierType; using LevelSetType = typename LevelSetContainerType::LevelSetType; using LevelSetPointer = typename LevelSetContainerType::LevelSetPointer; using InputIndexType = typename LevelSetContainerType::InputIndexType; using OutputType = typename LevelSetContainerType::OutputType; using OutputRealType = typename LevelSetContainerType::OutputRealType; using GradientType = typename LevelSetContainerType::GradientType; using HessianType = typename LevelSetContainerType::HessianType; using HeavisideType = typename LevelSetContainerType::HeavisideType; using HeavisidePointer = typename LevelSetContainerType::HeavisideType; bool IsSatisfied() const override; std::string GetDescription() const override; protected: /** Constructor */ LevelSetEvolutionNumberOfIterationsStoppingCriterion() = default; /** Destructor */ ~LevelSetEvolutionNumberOfIterationsStoppingCriterion() override = default; }; } // namespace itk #ifndef ITK_MANUAL_INSTANTIATION # include "itkLevelSetEvolutionNumberOfIterationsStoppingCriterion.hxx" #endif #endif
/* * Copyright (c) 2014 The WebRTC 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. */ #ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_CNG_AUDIO_ENCODER_CNG_H_ #define WEBRTC_MODULES_AUDIO_CODING_CODECS_CNG_AUDIO_ENCODER_CNG_H_ #include <memory> #include <vector> #include "webrtc/api/audio_codecs/audio_encoder.h" #include "webrtc/base/constructormagic.h" #include "webrtc/common_audio/vad/include/vad.h" #include "webrtc/modules/audio_coding/codecs/cng/webrtc_cng.h" namespace webrtc { class Vad; class AudioEncoderCng final : public AudioEncoder { public: struct Config { Config(); Config(Config&&); ~Config(); bool IsOk() const; size_t num_channels = 1; int payload_type = 13; std::unique_ptr<AudioEncoder> speech_encoder; Vad::Aggressiveness vad_mode = Vad::kVadNormal; int sid_frame_interval_ms = 100; int num_cng_coefficients = 8; // The Vad pointer is mainly for testing. If a NULL pointer is passed, the // AudioEncoderCng creates (and destroys) a Vad object internally. If an // object is passed, the AudioEncoderCng assumes ownership of the Vad // object. Vad* vad = nullptr; }; explicit AudioEncoderCng(Config&& config); ~AudioEncoderCng() override; int SampleRateHz() const override; size_t NumChannels() const override; int RtpTimestampRateHz() const override; size_t Num10MsFramesInNextPacket() const override; size_t Max10MsFramesInAPacket() const override; int GetTargetBitrate() const override; EncodedInfo EncodeImpl(uint32_t rtp_timestamp, rtc::ArrayView<const int16_t> audio, rtc::Buffer* encoded) override; void Reset() override; bool SetFec(bool enable) override; bool SetDtx(bool enable) override; bool SetApplication(Application application) override; void SetMaxPlaybackRate(int frequency_hz) override; rtc::ArrayView<std::unique_ptr<AudioEncoder>> ReclaimContainedEncoders() override; void OnReceivedUplinkPacketLossFraction( float uplink_packet_loss_fraction) override; void OnReceivedUplinkRecoverablePacketLossFraction( float uplink_recoverable_packet_loss_fraction) override; void OnReceivedUplinkBandwidth( int target_audio_bitrate_bps, rtc::Optional<int64_t> probing_interval_ms) override; private: EncodedInfo EncodePassive(size_t frames_to_encode, rtc::Buffer* encoded); EncodedInfo EncodeActive(size_t frames_to_encode, rtc::Buffer* encoded); size_t SamplesPer10msFrame() const; std::unique_ptr<AudioEncoder> speech_encoder_; const int cng_payload_type_; const int num_cng_coefficients_; const int sid_frame_interval_ms_; std::vector<int16_t> speech_buffer_; std::vector<uint32_t> rtp_timestamps_; bool last_frame_active_; std::unique_ptr<Vad> vad_; std::unique_ptr<ComfortNoiseEncoder> cng_encoder_; RTC_DISALLOW_COPY_AND_ASSIGN(AudioEncoderCng); }; } // namespace webrtc #endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_CNG_AUDIO_ENCODER_CNG_H_
//===--- CodeCompletionResultSink.h ---------------------------------------===// // // This source file is part of the Swift.org open source project // // Copyright (c) 2022 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// #ifndef SWIFT_IDE_CODECOMPLETIONRESULTSINK #define SWIFT_IDE_CODECOMPLETIONRESULTSINK #include "swift/IDE/CodeCompletionResult.h" namespace swift { namespace ide { struct CodeCompletionResultSink { using AllocatorPtr = std::shared_ptr<llvm::BumpPtrAllocator>; /// The allocator used to allocate results "native" to this sink. AllocatorPtr Allocator; /// Allocators that keep alive "foreign" results imported into this sink from /// other sinks. std::vector<AllocatorPtr> ForeignAllocators; /// Whether to annotate the results with XML. bool annotateResult = false; /// Whether to emit object literals if desired. bool includeObjectLiterals = true; /// Whether to emit type initializers in addition to type names in expression /// position. bool addInitsToTopLevel = false; /// Whether to perform "call pettern heuristics". bool enableCallPatternHeuristics = false; /// Whether to include an item without any default arguments. bool addCallWithNoDefaultArgs = true; private: /// Whether the code completion results computed for this sink are intended to /// only be stored in the cache. In this case no contextual information is /// computed and all types in \c ContextFreeCodeCompletionResult should be /// USR-based instead of AST-based. USRBasedTypeArena *USRTypeArena = nullptr; public: std::vector<CodeCompletionResult *> Results; /// A single-element cache for module names stored in Allocator, keyed by a /// clang::Module * or swift::ModuleDecl *. std::pair<void *, NullTerminatedStringRef> LastModule; CodeCompletionResultSink() : Allocator(std::make_shared<llvm::BumpPtrAllocator>()) {} llvm::BumpPtrAllocator &getAllocator() { return *Allocator; } /// Marks the sink as producing results for the code completion cache. /// In this case the produced results will not contain any contextual /// information and all types in the \c ContextFreeCodeCompletionResult are /// USR-based. void setProduceContextFreeResults(USRBasedTypeArena &USRTypeArena) { this->USRTypeArena = &USRTypeArena; } /// See \c setProduceContextFreeResults. bool shouldProduceContextFreeResults() const { return USRTypeArena != nullptr; } /// If \c shouldProduceContextFreeResults is \c true, returns the arena in /// which the USR-based types of the \c ContextFreeCodeCompletionResult should /// be stored. USRBasedTypeArena &getUSRTypeArena() const { assert(USRTypeArena != nullptr && "Must only be called if shouldProduceContextFreeResults is true"); return *USRTypeArena; } }; } // end namespace ide } // end namespace swift #endif // SWIFT_IDE_CODECOMPLETIONRESULTSINK
// // JTAlipayFriendsViewController.h // JLGT // // Created by 刘蒲艳 on 15/7/25. // Copyright (c) 2015年 ds. All rights reserved. // #import "JTBaseViewController.h" @interface JTAlipayFriendsViewController : JTBaseViewController @end
/* * Copyright 2017 The WebRTC 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. */ #ifndef SDK_ANDROID_SRC_JNI_PC_PEERCONNECTIONFACTORY_H_ #define SDK_ANDROID_SRC_JNI_PC_PEERCONNECTIONFACTORY_H_ #include <jni.h> namespace webrtc { namespace jni { void PeerConnectionFactoryNetworkThreadReady(); void PeerConnectionFactoryWorkerThreadReady(); void PeerConnectionFactorySignalingThreadReady(); } // namespace jni } // namespace webrtc #endif // SDK_ANDROID_SRC_JNI_PC_PEERCONNECTIONFACTORY_H_
// // ZUser.h // Zulip // // Created by Leonardo Franchi on 7/29/13. // // #import <Foundation/Foundation.h> #import <CoreData/CoreData.h> @class ZMessage, ZSubscription; @interface ZUser : NSManagedObject @property (nonatomic, retain) NSString * avatar_url; @property (nonatomic, retain) NSString * email; @property (nonatomic, retain) NSString * full_name; @property (nonatomic, retain) NSNumber * userID; @property (nonatomic, retain) NSSet *received_pms; @property (nonatomic, retain) NSSet *sent_messages; @property (nonatomic, retain) NSSet *subscriptions; @end @interface ZUser (CoreDataGeneratedAccessors) - (void)addReceived_pmsObject:(ZMessage *)value; - (void)removeReceived_pmsObject:(ZMessage *)value; - (void)addReceived_pms:(NSSet *)values; - (void)removeReceived_pms:(NSSet *)values; - (void)addSent_messagesObject:(ZMessage *)value; - (void)removeSent_messagesObject:(ZMessage *)value; - (void)addSent_messages:(NSSet *)values; - (void)removeSent_messages:(NSSet *)values; - (void)addSubscriptionsObject:(ZSubscription *)value; - (void)removeSubscriptionsObject:(ZSubscription *)value; - (void)addSubscriptions:(NSSet *)values; - (void)removeSubscriptions:(NSSet *)values; @end
// // UIViewCtrl_Software_Help.h // GreatTit04_Application // // Created by gabriella on 14-3-3. // Copyright (c) 2014年 gabriella. All rights reserved. // #import <UIKit/UIKit.h> @interface UIViewCtrl_Software_Help : FrameBaseViewController<UIWebViewDelegate> @property (assign, nonatomic) IBOutlet UIWebView *webview_01; - (IBAction)onBtnReturn_Click:(id)sender; @end
#ifndef __wx__friendemploylog__ #define __wx__friendemploylog__ #include <iostream> #include "cocos2d.h" #include "cocos-ext.h" USING_NS_CC; USING_NS_CC_EXT; using namespace std; class friendemploylog:public CCLayer { public: CREATE_FUNC(friendemploylog); private: virtual bool init(); virtual void registerWithTouchDispatcher(); virtual bool ccTouchBegan(CCTouch* touch, CCEvent* event); virtual void ccTouchMoved(CCTouch* touch, CCEvent* event); virtual void ccTouchEnded(CCTouch* touch, CCEvent* event); void rec_2309(float); CCScrollView* _scrollView; CCSize size; bool istouch; }; #endif /* defined(__wx__friendemploylog__) */
/*************************************************************** * * Copyright (C) 1990-2007, Condor Team, Computer Sciences Department, * University of Wisconsin-Madison, WI. * * 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 _CONDOR_DC_STARTER_H #define _CONDOR_DC_STARTER_H #include "condor_common.h" #include "condor_classad.h" #include "condor_io.h" /** The subclass of the Daemon object for talking to a starter */ class DCStarter : public Daemon { public: /** Constructor. The Starter can't be found for the usual means, so you don't instantiate the DCStarter with the usual stuff (name, pool, etc). You can't query the collector for it, or look for an address file, etc. So, once you instantiate a DCStarter object, you have to call initFromClassAd() to initialize the DCStarter. @param name The name of the starter, NULL if you don't know */ DCStarter( const char* name = NULL ); /// Destructor. ~DCStarter(); /** Initialize this object with a ClassAd that contains the information we need. At minimum, it must include ATTR_STARTER_IP_ADDR. Ideally, it'd also have ATTR_VERSION, ATTR_NAME, and ATTR_MACHINE. @param ad ClassAd with info about the starter. @return true if the ad was valid, false if not */ bool initFromClassAd( ClassAd* ad ); /** The starter can't be found through the usual means. Instead, when you instantiate a DCStarter object, you give it all the info in a ClassAd. So, locate() just has to check that the ClassAd was valid and we have the info we need. @return true if we have the info, false if not */ bool locate( void ); /** @param timeout -1 to leave things alone; 0 for no timeout @param sec_session_id NULL for auto-negotiation */ bool reconnect( ClassAd* req, ClassAd* reply, ReliSock* rsock, int timeout, char const *sec_session_id); // Error - Failed to update, a problem // Okay - Success. Updated // Declined - Success. Other side doesn't want it. Don't bother // to try again. enum X509UpdateStatus { XUS_Error = 0, XUS_Okay = 1, XUS_Declined = 2 }; X509UpdateStatus updateX509Proxy(const char * filename, char const *sec_session_id); // expiration_time: 0 if none; o.w. time of delegated proxy expiration // result_expiration_time: set to actual expiration time of // remote proxy (could be shorter than // requested if source proxy is not valid // for long enough) X509UpdateStatus delegateX509Proxy(const char * filename, time_t expiration_time,char const *sec_session_id, time_t *result_expiration_time); bool createJobOwnerSecSession(int timeout,char const *job_claim_id,char const *starter_sec_session,char const *session_info,MyString &owner_claim_id,MyString &error_msg,MyString &starter_version,MyString &starter_addr); bool startSSHD(char const *known_hosts_file,char const *private_client_key_file,char const *preferred_shells,char const *slot_name,char const *ssh_keygen_args,ReliSock &sock,int timeout,char const *sec_session_id,MyString &remote_user,MyString &error_msg,bool &retry_is_sensible); private: bool is_initialized; // I can't be copied (yet) DCStarter( const DCStarter& ); DCStarter& operator = ( const DCStarter& ); }; class StarterHoldJobMsg: public DCMsg { public: StarterHoldJobMsg( char const *hold_reason, int hold_code, int hold_subcode, bool soft ); bool writeMsg( DCMessenger *messenger, Sock *sock ); bool readMsg( DCMessenger *messenger, Sock *sock ); MessageClosureEnum messageSent( DCMessenger *messenger, Sock *sock ); private: MyString m_hold_reason; int m_hold_code; int m_hold_subcode; bool m_soft; }; #endif /* _CONDOR_DC_STARTER_H */
/* * Copyright (c) 2013-2014 Wind River Systems, Inc. * * SPDX-License-Identifier: Apache-2.0 */ /** * @file * @brief Cache manipulation * * This module contains functions for manipulation caches. */ #include <kernel.h> #include <arch/cpu.h> #include <misc/util.h> #include <toolchain.h> #include <cache.h> #include <cache_private.h> #include <stdbool.h> #if defined(CONFIG_CLFLUSH_INSTRUCTION_SUPPORTED) || \ defined(CONFIG_CLFLUSH_DETECT) #if (CONFIG_CACHE_LINE_SIZE == 0) && !defined(CONFIG_CACHE_LINE_SIZE_DETECT) #error Cannot use this implementation with a cache line size of 0 #endif /** * * @brief Flush cache lines to main memory * * No alignment is required for either <virt> or <size>, but since * sys_cache_flush() iterates on the cache lines, a cache line alignment for * both is optimal. * * The cache line size is specified either via the CONFIG_CACHE_LINE_SIZE * kconfig option or it is detected at runtime. * * @return N/A */ _sys_cache_flush_sig(_cache_flush_clflush) { int end; size = ROUND_UP(size, sys_cache_line_size); end = virt + size; for (; virt < end; virt += sys_cache_line_size) { __asm__ volatile("clflush %0;\n\t" : : "m"(virt)); } __asm__ volatile("mfence;\n\t"); } #endif /* CONFIG_CLFLUSH_INSTRUCTION_SUPPORTED || CLFLUSH_DETECT */ #if defined(CONFIG_CLFLUSH_DETECT) || defined(CONFIG_CACHE_LINE_SIZE_DETECT) #include <init.h> #if defined(CONFIG_CLFLUSH_DETECT) _sys_cache_flush_t *sys_cache_flush; static void init_cache_flush(void) { if (_is_clflush_available()) { sys_cache_flush = _cache_flush_clflush; } else { sys_cache_flush = _cache_flush_wbinvd; } } #else #define init_cache_flush() do { } while (false) #if defined(CONFIG_CLFLUSH_INSTRUCTION_SUPPORTED) FUNC_ALIAS(_cache_flush_clflush, sys_cache_flush, void); #endif #endif /* CONFIG_CLFLUSH_DETECT */ #if defined(CONFIG_CACHE_LINE_SIZE_DETECT) size_t sys_cache_line_size; static void init_cache_line_size(void) { sys_cache_line_size = _cache_line_size_get(); } #else #define init_cache_line_size() do { } while ((0)) #endif static int init_cache(struct device *unused) { ARG_UNUSED(unused); init_cache_flush(); init_cache_line_size(); return 0; } SYS_INIT(init_cache, PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT); #endif /* CONFIG_CLFLUSH_DETECT || CONFIG_CACHE_LINE_SIZE_DETECT */
/***************************************************************************** * Copyright (C) 2013-2017 MulticoreWare, Inc * * Authors: Steve Borho <steve@borho.org> * Min Chen <chenm003@163.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 Street, Fifth Floor, Boston, MA 02111, USA. * * This program is also available under a commercial proprietary license. * For more information, contact us at license @ x265.com. *****************************************************************************/ #ifndef X265_REFERENCE_H #define X265_REFERENCE_H #include "primitives.h" #include "picyuv.h" #include "lowres.h" #include "mv.h" namespace X265_NS { // private x265 namespace struct WeightParam; class MotionReference : public ReferencePlanes { public: MotionReference(); ~MotionReference(); int init(PicYuv*, WeightParam* wp, const x265_param& p); void applyWeight(uint32_t finishedRows, uint32_t maxNumRows, uint32_t maxNumRowsInSlice, uint32_t sliceId); pixel* weightBuffer[3]; int numInterpPlanes; uint32_t* numSliceWeightedRows; protected: MotionReference& operator =(const MotionReference&); }; } #endif // ifndef X265_REFERENCE_H
/* objplane.h - structure values for plane */ { "plane", "plane", /* long and short names */ "cube", /* long name of dual */ 4, 4, 1, /* number of vertices, edges, and faces */ { /* vertices (x,y,z) */ /* all points must be within radius 1 of the origin */ #define T 1.0 { T, 0, 0 }, { -T, 0, 0 }, { 0, T, 0 }, { 0, -T, 0 }, #undef T }, { /* faces (numfaces + indexes into vertices) */ /* faces must be specified clockwise from the outside */ 4, 0, 2, 1, 3, } }, /* leave a comma to separate from the next include file */ /* end */
/*========================================================================= * * 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 __itkTransformIOFactory_h #define __itkTransformIOFactory_h #include "itkObject.h" #include "itkTransformIOBase.h" namespace itk { /** \class TransformIOFactory * \brief Create instances of TransformIO objects using an object factory. * \ingroup ITKTransform */ class ITK_EXPORT TransformIOFactory:public Object { public: /** Standard class typedefs. */ typedef TransformIOFactory Self; typedef Object Superclass; typedef SmartPointer< Self > Pointer; typedef SmartPointer< const Self > ConstPointer; /** Class Methods used to interface with the registered factories */ /** Run-time type information (and related methods). */ itkTypeMacro(TransformIOFactory, Object); /** Convenient typedefs. */ typedef TransformIOBase::Pointer TransformIOBasePointer; /** Mode in which the files is intended to be used */ typedef enum { ReadMode, WriteMode } FileModeType; /** Create the appropriate TransformIO depending on * the particulars of the file. */ static TransformIOBasePointer CreateTransformIO(const char *path, FileModeType mode); /** Register Built-in factories */ static void RegisterBuiltInFactories(); protected: TransformIOFactory(); ~TransformIOFactory(); private: TransformIOFactory(const Self &); //purposely not implemented void operator=(const Self &); //purposely not implemented }; } // end namespace itk #endif
/** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ #pragma once #include <aws/events/CloudWatchEvents_EXPORTS.h> #include <aws/core/utils/memory/stl/AWSString.h> #include <utility> namespace Aws { namespace Utils { namespace Json { class JsonValue; class JsonView; } // namespace Json } // namespace Utils namespace CloudWatchEvents { namespace Model { /** * <p>Contains the Basic authorization parameters to use for the * connection.</p><p><h3>See Also:</h3> <a * href="http://docs.aws.amazon.com/goto/WebAPI/events-2015-10-07/CreateConnectionBasicAuthRequestParameters">AWS * API Reference</a></p> */ class AWS_CLOUDWATCHEVENTS_API CreateConnectionBasicAuthRequestParameters { public: CreateConnectionBasicAuthRequestParameters(); CreateConnectionBasicAuthRequestParameters(Aws::Utils::Json::JsonView jsonValue); CreateConnectionBasicAuthRequestParameters& operator=(Aws::Utils::Json::JsonView jsonValue); Aws::Utils::Json::JsonValue Jsonize() const; /** * <p>The user name to use for Basic authorization.</p> */ inline const Aws::String& GetUsername() const{ return m_username; } /** * <p>The user name to use for Basic authorization.</p> */ inline bool UsernameHasBeenSet() const { return m_usernameHasBeenSet; } /** * <p>The user name to use for Basic authorization.</p> */ inline void SetUsername(const Aws::String& value) { m_usernameHasBeenSet = true; m_username = value; } /** * <p>The user name to use for Basic authorization.</p> */ inline void SetUsername(Aws::String&& value) { m_usernameHasBeenSet = true; m_username = std::move(value); } /** * <p>The user name to use for Basic authorization.</p> */ inline void SetUsername(const char* value) { m_usernameHasBeenSet = true; m_username.assign(value); } /** * <p>The user name to use for Basic authorization.</p> */ inline CreateConnectionBasicAuthRequestParameters& WithUsername(const Aws::String& value) { SetUsername(value); return *this;} /** * <p>The user name to use for Basic authorization.</p> */ inline CreateConnectionBasicAuthRequestParameters& WithUsername(Aws::String&& value) { SetUsername(std::move(value)); return *this;} /** * <p>The user name to use for Basic authorization.</p> */ inline CreateConnectionBasicAuthRequestParameters& WithUsername(const char* value) { SetUsername(value); return *this;} /** * <p>The password associated with the user name to use for Basic * authorization.</p> */ inline const Aws::String& GetPassword() const{ return m_password; } /** * <p>The password associated with the user name to use for Basic * authorization.</p> */ inline bool PasswordHasBeenSet() const { return m_passwordHasBeenSet; } /** * <p>The password associated with the user name to use for Basic * authorization.</p> */ inline void SetPassword(const Aws::String& value) { m_passwordHasBeenSet = true; m_password = value; } /** * <p>The password associated with the user name to use for Basic * authorization.</p> */ inline void SetPassword(Aws::String&& value) { m_passwordHasBeenSet = true; m_password = std::move(value); } /** * <p>The password associated with the user name to use for Basic * authorization.</p> */ inline void SetPassword(const char* value) { m_passwordHasBeenSet = true; m_password.assign(value); } /** * <p>The password associated with the user name to use for Basic * authorization.</p> */ inline CreateConnectionBasicAuthRequestParameters& WithPassword(const Aws::String& value) { SetPassword(value); return *this;} /** * <p>The password associated with the user name to use for Basic * authorization.</p> */ inline CreateConnectionBasicAuthRequestParameters& WithPassword(Aws::String&& value) { SetPassword(std::move(value)); return *this;} /** * <p>The password associated with the user name to use for Basic * authorization.</p> */ inline CreateConnectionBasicAuthRequestParameters& WithPassword(const char* value) { SetPassword(value); return *this;} private: Aws::String m_username; bool m_usernameHasBeenSet; Aws::String m_password; bool m_passwordHasBeenSet; }; } // namespace Model } // namespace CloudWatchEvents } // namespace Aws
#include <math.h> #include <vector> #include <random> #include <algorithm> #include <Eigen\dense> std::vector<int> DTMC (Eigen::MatrixXf, int, int);
// // BYTableViewCellRenderer.h // Beautify // // Created by Colin Eberhardt on 02/06/2013. // Copyright (c) 2013 Colin Eberhardt. All rights reserved. // #import "BYViewRenderer.h" #import "BYControlRenderer.h" @interface BYTableViewCellRenderer : BYControlRenderer @end
/* * Copyright (C) 2013 The Android Open Source Project * * 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 ART_COMPILER_LINKER_OUTPUT_STREAM_H_ #define ART_COMPILER_LINKER_OUTPUT_STREAM_H_ #include <ostream> #include <string> #include "base/macros.h" namespace art { enum Whence { kSeekSet = SEEK_SET, kSeekCurrent = SEEK_CUR, kSeekEnd = SEEK_END, }; std::ostream& operator<<(std::ostream& os, const Whence& rhs); class OutputStream { public: explicit OutputStream(const std::string& location) : location_(location) {} virtual ~OutputStream() {} const std::string& GetLocation() const { return location_; } virtual bool WriteFully(const void* buffer, size_t byte_count) = 0; virtual off_t Seek(off_t offset, Whence whence) = 0; /* * Flushes the stream. Returns whether the operation was successful. * * An OutputStream may delay reporting errors from WriteFully() or * Seek(). In that case, Flush() shall report any pending error. */ virtual bool Flush() = 0; private: const std::string location_; DISALLOW_COPY_AND_ASSIGN(OutputStream); }; } // namespace art #endif // ART_COMPILER_LINKER_OUTPUT_STREAM_H_
// // CharacterScene.h // mcdrunning // // Created by chenbingfeng on 15/6/22. // // 角色选择 #ifndef __mcdrunning__CharacterScene__ #define __mcdrunning__CharacterScene__ #include "TRBaseScene.h" #include "cocos2d.h" #include <string> #include <unordered_map> #include <vector> class CharacterScene: public TRBaseScene { public: virtual bool init() override; CREATE_FUNC(CharacterScene); private: cocos2d::Node* _btnSelect; cocos2d::Node* _btnUnlock; std::vector<int> _roleIds; int _roleShowIndex = 0; int _roleShowIndexLast = 99; std::unordered_map<int, cocos2d::Sprite*> _roleMap; void roleDispUpdate(); void next(); void prev(); void select(); void unlock(); }; #endif /* defined(__mcdrunning__CharacterScene__) */
// ZMTP protocol engine class /* 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 __ZMTP_HANDSHAKE_H_INCLUDED__ #define __ZMTP_HANDSHAKE_H_INCLUDED__ #include "protocol_engine.h" typedef struct zmtp_handshake zmtp_handshake_t; zmtp_handshake_t * zmtp_handshake_new (); protocol_engine_t * zmtp_handshake_new_protocol_engine (); #endif
/*************************************************************************** *cr *cr (C) Copyright 2008-2010 The Board of Trustees of the *cr University of Illinois *cr All Rights Reserved *cr ***************************************************************************/ #ifndef CUTOFF_H #define CUTOFF_H #ifdef __cplusplus extern "C" { #endif #define SHIFTED /* A structure to record how points in 3D space map to array elements. Array element (z, y, x) where 0 <= x < nx, 0 <= y < ny, 0 <= z < nz maps to coordinate (xlo, ylo, zlo) + h * (x, y, z). */ typedef struct LatticeDim_t { /* Number of lattice points in x, y, z dimensions */ int nx, ny, nz; /* Lowest corner of lattice */ Vec3 lo; /* Lattice spacing */ float h; } LatticeDim; /* An electric potential field sampled on a regular grid. The lattice size and grid point positions are specified by 'dim'. */ typedef struct Lattice_t { LatticeDim dim; float *lattice; } Lattice; LatticeDim lattice_from_bounding_box(Vec3 lo, Vec3 hi, float h); Lattice *create_lattice(LatticeDim dim); void destroy_lattice(Lattice *); int gpu_compute_cutoff_potential_lattice6overlap( struct pb_TimerSet *timers, /* for measuring execution time */ Lattice *lattice, float cutoff, /* cutoff distance */ Atoms *atoms, /* array of atoms */ int verbose /* print info/debug messages */ ); int cpu_compute_cutoff_potential_lattice( Lattice *lattice, /* the lattice */ float cutoff, /* cutoff distance */ Atoms *atoms /* array of atoms */ ); int remove_exclusions( Lattice *lattice, /* the lattice */ float exclcutoff, /* exclusion cutoff distance */ Atoms *atom /* array of atoms */ ); #ifdef __cplusplus } #endif #endif /* CUTOFF_H */
#ifndef framework2_h #define framework2_h #ifdef WIN32 # ifdef framework2_EXPORTS # define FRAMEWORK2_EXPORT __declspec(dllexport) # else # define FRAMEWORK2_EXPORT __declspec(dllimport) # endif #else # define FRAMEWORK2_EXPORT #endif void FRAMEWORK2_EXPORT framework2(); #endif
#include "e.h" #include "e_mod_main.h" /* actual module specifics */ static void _e_mod_action_syscon_cb(E_Object *obj, const char *params); static Eina_Bool _e_mod_syscon_defer_cb(void *data); static void _e_mod_syscon_cb(void *data, E_Menu *m, E_Menu_Item *mi); static void _e_mod_menu_add(void *data, E_Menu *m); static E_Module *conf_module = NULL; static E_Action *act = NULL; static E_Int_Menu_Augmentation *maug = NULL; /* module setup */ EAPI E_Module_Api e_modapi = { E_MODULE_API_VERSION, "Syscon" }; EAPI void * e_modapi_init(E_Module *m) { conf_module = m; e_syscon_init(); /* add module supplied action */ act = e_action_add("syscon"); if (act) { act->func.go = _e_mod_action_syscon_cb; e_action_predef_name_set(N_("System"), N_("System Controls"), "syscon", NULL, NULL, 0); } maug = e_int_menus_menu_augmentation_add_sorted ("main/8", _("System"), _e_mod_menu_add, NULL, NULL, NULL); e_configure_registry_category_add("advanced", 80, _("Advanced"), NULL, "preferences-advanced"); e_configure_registry_item_add("advanced/syscon", 10, _("Syscon"), NULL, "system-shutdown", e_int_config_syscon); e_syscon_gadget_init(m); e_module_delayed_set(m, 1); return m; } EAPI int e_modapi_shutdown(E_Module *m __UNUSED__) { E_Config_Dialog *cfd; while ((cfd = e_config_dialog_get("E", "advanced/conf_syscon"))) e_object_del(E_OBJECT(cfd)); e_configure_registry_item_del("advanced/syscon"); e_configure_registry_category_del("advanced"); /* remove module-supplied menu additions */ if (maug) { e_int_menus_menu_augmentation_del("main/8", maug); maug = NULL; } /* remove module-supplied action */ if (act) { e_action_predef_name_del("System", "System Controls"); e_action_del("syscon"); act = NULL; } e_syscon_gadget_shutdown(); e_syscon_shutdown(); conf_module = NULL; return 1; } /* action callback */ static void _e_mod_action_syscon_cb(E_Object *obj, const char *params) { E_Zone *zone = NULL; // params = syscon action + now: // desk_lock // logout // halt // reboot // suspend // hibernate if (obj) { if (obj->type == E_MANAGER_TYPE) zone = e_util_zone_current_get((E_Manager *)obj); else if (obj->type == E_CONTAINER_TYPE) zone = e_util_zone_current_get(((E_Container *)obj)->manager); else if (obj->type == E_ZONE_TYPE) zone = e_util_zone_current_get(((E_Zone *)obj)->container->manager); else zone = e_util_zone_current_get(e_manager_current_get()); } if (!zone) zone = e_util_zone_current_get(e_manager_current_get()); if (zone) e_syscon_show(zone, params); } /* menu item callback(s) */ static Eina_Bool _e_mod_syscon_defer_cb(void *data) { E_Zone *zone; zone = data; if (zone) e_syscon_show(zone, NULL); return ECORE_CALLBACK_CANCEL; } static void _e_mod_syscon_cb(void *data __UNUSED__, E_Menu *m, E_Menu_Item *mi __UNUSED__) { ecore_idle_enterer_add(_e_mod_syscon_defer_cb, m->zone); } static void _e_mod_menu_generate(void *data __UNUSED__, E_Menu *m) { e_syscon_menu_fill(m); } /* menu item add hook */ static void _e_mod_menu_add(void *data __UNUSED__, E_Menu *m) { E_Menu *sub; E_Menu_Item *mi; mi = e_menu_item_new(m); e_menu_item_label_set(mi, _("System")); e_util_menu_item_theme_icon_set(mi, "system"); e_menu_item_callback_set(mi, _e_mod_syscon_cb, NULL); sub = e_menu_new(); e_menu_item_submenu_set(mi, sub); e_object_unref(E_OBJECT(sub)); e_menu_pre_activate_callback_set(sub, _e_mod_menu_generate, NULL); }
// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef UI_APP_LIST_VIEWS_SEARCH_BOX_VIEW_H_ #define UI_APP_LIST_VIEWS_SEARCH_BOX_VIEW_H_ #include <string> #include "base/macros.h" #include "ui/app_list/search_box_model_observer.h" #include "ui/app_list/speech_ui_model_observer.h" #include "ui/gfx/shadow_value.h" #include "ui/views/controls/button/image_button.h" #include "ui/views/controls/textfield/textfield_controller.h" #include "ui/views/view.h" namespace views { class ImageView; class Textfield; } // namespace views namespace app_list { // Possible locations for partial keyboard focus (but note that the search // box always handles typing). enum SearchBoxFocus { FOCUS_BACK_BUTTON, // Back button, only responds to ENTER FOCUS_SEARCH_BOX, // Nothing else has partial focus FOCUS_MIC_BUTTON, // Mic button, only responds to ENTER FOCUS_CONTENTS_VIEW, // Something outside the SearchBox is selected }; class AppListModel; class AppListViewDelegate; class SearchBoxModel; class SearchBoxViewDelegate; class SearchBoxImageButton; // SearchBoxView consists of an icon and a Textfield. SearchBoxModel is its data // model that controls what icon to display, what placeholder text to use for // Textfield. The text and selection model part could be set to change the // contents and selection model of the Textfield. class APP_LIST_EXPORT SearchBoxView : public views::View, public views::TextfieldController, public views::ButtonListener, public SearchBoxModelObserver, public SpeechUIModelObserver { public: SearchBoxView(SearchBoxViewDelegate* delegate, AppListViewDelegate* view_delegate); ~SearchBoxView() override; void ModelChanged(); bool HasSearch() const; void ClearSearch(); // Sets the shadow border of the search box. void SetShadow(const gfx::ShadowValue& shadow); // Returns the bounds to use for the view (including the shadow) given the // desired bounds of the search box contents. gfx::Rect GetViewBoundsForSearchBoxContentsBounds( const gfx::Rect& rect) const; views::ImageButton* back_button(); views::Textfield* search_box() { return search_box_; } void set_contents_view(views::View* contents_view) { contents_view_ = contents_view; } // Moves focus forward/backwards in response to TAB. bool MoveTabFocus(bool move_backwards); // Moves focus to contents or SearchBox and unselects buttons. void ResetTabFocus(bool on_contents); // Sets voice label for Back button depending on whether a folder is open. void SetBackButtonLabel(bool folder); // Overridden from views::View: gfx::Size GetPreferredSize() const override; bool OnMouseWheel(const ui::MouseWheelEvent& event) override; void OnEnabledChanged() override; private: // Updates model text and selection model with current Textfield info. void UpdateModel(); // Fires query change notification. void NotifyQueryChanged(); // Overridden from views::TextfieldController: void ContentsChanged(views::Textfield* sender, const base::string16& new_contents) override; bool HandleKeyEvent(views::Textfield* sender, const ui::KeyEvent& key_event) override; // Overridden from views::ButtonListener: void ButtonPressed(views::Button* sender, const ui::Event& event) override; // Overridden from SearchBoxModelObserver: void SpeechRecognitionButtonPropChanged() override; void HintTextChanged() override; void SelectionModelChanged() override; void TextChanged() override; // Overridden from SpeechUIModelObserver: void OnSpeechRecognitionStateChanged( SpeechRecognitionState new_state) override; SearchBoxViewDelegate* delegate_; // Not owned. AppListViewDelegate* view_delegate_; // Not owned. AppListModel* model_; // Owned by the profile-keyed service. views::View* content_container_; // Owned by views hierarchy. SearchBoxImageButton* back_button_; // Owned by views hierarchy. SearchBoxImageButton* speech_button_; // Owned by views hierarchy. views::Textfield* search_box_; // Owned by views hierarchy. views::View* contents_view_; // Owned by views hierarchy. SearchBoxFocus focused_view_; // Which element has TAB'd focus. DISALLOW_COPY_AND_ASSIGN(SearchBoxView); }; } // namespace app_list #endif // UI_APP_LIST_VIEWS_SEARCH_BOX_VIEW_H_
#ifndef INTERNAL_H #define INTERNAL_H #include <stdio.h> #include <stddef.h> #include <stdint.h> #include <stdlib.h> #include <time.h> #include <string.h> typedef int (*_compar_fn_t)(const void * r1, const void * r2, size_t rsize); typedef void (*_bisect_fn_t)(void * r, const void * r1, const void * r2, size_t rsize); struct crstruct { void * base; size_t nmemb; size_t size; size_t rsize; void * arg; void (*radix)(const void * ptr, void * radix, void * arg); _compar_fn_t compar; _bisect_fn_t bisect; }; void _setup_radix_sort( struct crstruct *d, void * base, size_t nmemb, size_t size, void (*radix)(const void * ptr, void * radix, void * arg), size_t rsize, void * arg); #endif
#ifndef FALCON_DAMAGE_H #define FALCON_DAMAGE_H class FalconDamageType { public: enum { BulletDamage, MissileDamage, CollisionDamage, BombDamage, FODDamage, GroundCollisionDamage, ObjectCollisionDamage, FeatureCollisionDamage, DebrisDamage, ProximityDamage, OtherDamage, // KCK: Use if you don't want any messages/scoring to occur }; }; #endif
/* file: OGREUser.h * description: Defines a Database interface for generation and interaction * with the users in the database. * * For detailed usage and design notes, please refer the * OGRE Server - Data Services.md documentation. * * License ********************************************************************* * * Copyright (c) 2014-2015, Andy 'Dru' Satori @ WeAreOGRE.com * All rights reserved. * * See LICENSE.txt for detailed license information. * ******************************************************************************* * * history: * see method headers for detailed history of changes * ******************************************************************************/ #import <PGSQLKit/PGSQLKit.h> #import <PGSQLKit/PGSQLDataObject.h> #import <PGSQLKit/PGSQLRecordset.h> @interface OGREUser : PGSQLDataObject { // OGREContact *_contact; } #pragma mark customer initializers - (id)initWithConnection:(PGSQLConnection *)pgConn; - (id)initWithConnection:(PGSQLConnection *)pgConn forId:(NSNumber *)referenceId; - (id)initWithConnection:(PGSQLConnection *)pgConn forRecord:(PGSQLRecordset *)rs; - (id)initWithConnection:(PGSQLConnection *)pgConn forLogin:(NSString *)login withHash:(NSString *)hash; #pragma mark persistance methods (rdbms, xml) - (BOOL)save; - (NSXMLElement *)xmlForObject; - (BOOL)loadFromXml:(NSXMLElement *)xmlElement; - (NSDictionary *)jsonForObject; - (BOOL)loadFromJson:(NSArray *)jsonElement; #pragma mark custom properties @property (copy,readonly) NSNumber *userId; @property (copy) NSString *login; @property (copy) NSString *passwordHash; @property (copy,readonly) NSDate *accountValidated; @property (copy,readonly) NSNumber *contactId; // @property (copy,readonly) OGREContact *contact; #pragma mark custom accessors / property overrides - (NSNumber *)userId; - (NSString *)login; - (NSString *)passwordHash; - (NSDate *)accountValidated; - (void)setAccountValidated:(NSDate *)value; - (NSNumber *)contactId; // - (OGREContact *)contact; #pragma mark custom methods and implmentation // will need methods for resetting passwords, and other fun things. @end
//===-- MachException.h -----------------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // Created by Greg Clayton on 6/18/07. // //===----------------------------------------------------------------------===// #ifndef __MachException_h__ #define __MachException_h__ #include <mach/mach.h> #include <vector> #include "lldb/Host/Debug.h" #include "lldb/lldb-private-forward.h" #include "lldb/lldb-types.h" namespace lldb_private { namespace process_darwin { typedef union MachMessageTag { mach_msg_header_t hdr; char data[1024]; } MachMessage; class MachException { public: struct PortInfo { exception_mask_t mask; // the exception mask for this device which may be a // subset of EXC_MASK_ALL... exception_mask_t masks[EXC_TYPES_COUNT]; mach_port_t ports[EXC_TYPES_COUNT]; exception_behavior_t behaviors[EXC_TYPES_COUNT]; thread_state_flavor_t flavors[EXC_TYPES_COUNT]; mach_msg_type_number_t count; Status Save(task_t task); Status Restore(task_t task); }; struct Data { task_t task_port; thread_t thread_port; exception_type_t exc_type; std::vector<mach_exception_data_type_t> exc_data; Data() : task_port(TASK_NULL), thread_port(THREAD_NULL), exc_type(0), exc_data() {} void Clear() { task_port = TASK_NULL; thread_port = THREAD_NULL; exc_type = 0; exc_data.clear(); } bool IsValid() const { return task_port != TASK_NULL && thread_port != THREAD_NULL && exc_type != 0; } // Return the SoftSignal for this MachException data, or zero if there is // none int SoftSignal() const { if (exc_type == EXC_SOFTWARE && exc_data.size() == 2 && exc_data[0] == EXC_SOFT_SIGNAL) return static_cast<int>(exc_data[1]); return 0; } bool IsBreakpoint() const { return (exc_type == EXC_BREAKPOINT || ((exc_type == EXC_SOFTWARE) && exc_data[0] == 1)); } bool GetStopInfo(ThreadStopInfo *stop_info, const UnixSignals &signals, Stream &stream) const; }; struct Message { MachMessage exc_msg; MachMessage reply_msg; Data state; Message() : state() { memset(&exc_msg, 0, sizeof(exc_msg)); memset(&reply_msg, 0, sizeof(reply_msg)); } bool CatchExceptionRaise(task_t task); Status Reply(::pid_t inferior_pid, task_t inferior_task, int signal); Status Receive(mach_port_t receive_port, mach_msg_option_t options, mach_msg_timeout_t timeout, mach_port_t notify_port = MACH_PORT_NULL); void Dump(Stream &stream) const; typedef std::vector<Message> collection; typedef collection::iterator iterator; typedef collection::const_iterator const_iterator; }; enum { e_actionForward, // Forward signal to inferior process e_actionStop, // Stop when this signal is received }; struct Action { task_t task_port; // Set to TASK_NULL for any TASK thread_t thread_port; // Set to THREAD_NULL for any thread exception_type_t exc_mask; // Mach exception mask to watch for std::vector<mach_exception_data_type_t> exc_data_mask; // Mask to apply to // exception data, or // empty to ignore // exc_data value for // exception std::vector<mach_exception_data_type_t> exc_data_value; // Value to compare // to exception data // after masking, or // empty to ignore // exc_data value // for exception uint8_t flags; // Action flags describing what to do with the exception }; static const char *Name(exception_type_t exc_type); }; } // namespace process_darwin } // namespace lldb_private #endif
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE121_Stack_Based_Buffer_Overflow__dest_wchar_t_declare_cat_41.c Label Definition File: CWE121_Stack_Based_Buffer_Overflow__dest.label.xml Template File: sources-sink-41.tmpl.c */ /* * @description * CWE: 121 Stack Based Buffer Overflow * BadSource: Set data pointer to the bad buffer * GoodSource: Set data pointer to the good buffer * Sink: cat * BadSink : Copy string to data using wcscat * Flow Variant: 41 Data flow: data passed as an argument from one function to another in the same source file * * */ #include "std_testcase.h" #include <wchar.h> #ifndef OMITBAD void CWE121_Stack_Based_Buffer_Overflow__dest_wchar_t_declare_cat_41_badSink(wchar_t * data) { { wchar_t source[100]; wmemset(source, L'C', 100-1); /* fill with L'C's */ source[100-1] = L'\0'; /* null terminate */ /* POTENTIAL FLAW: Possible buffer overflow if the sizeof(data)-strlen(data) is less than the length of source */ wcscat(data, source); printWLine(data); } } void CWE121_Stack_Based_Buffer_Overflow__dest_wchar_t_declare_cat_41_bad() { wchar_t * data; wchar_t dataBadBuffer[50]; wchar_t dataGoodBuffer[100]; /* FLAW: Set a pointer to a "small" buffer. This buffer will be used in the sinks as a destination * buffer in various memory copying functions using a "large" source buffer. */ data = dataBadBuffer; data[0] = L'\0'; /* null terminate */ CWE121_Stack_Based_Buffer_Overflow__dest_wchar_t_declare_cat_41_badSink(data); } #endif /* OMITBAD */ #ifndef OMITGOOD void CWE121_Stack_Based_Buffer_Overflow__dest_wchar_t_declare_cat_41_goodG2BSink(wchar_t * data) { { wchar_t source[100]; wmemset(source, L'C', 100-1); /* fill with L'C's */ source[100-1] = L'\0'; /* null terminate */ /* POTENTIAL FLAW: Possible buffer overflow if the sizeof(data)-strlen(data) is less than the length of source */ wcscat(data, source); printWLine(data); } } /* goodG2B uses the GoodSource with the BadSink */ static void goodG2B() { wchar_t * data; wchar_t dataBadBuffer[50]; wchar_t dataGoodBuffer[100]; /* FIX: Set a pointer to a "large" buffer, thus avoiding buffer overflows in the sinks. */ data = dataGoodBuffer; data[0] = L'\0'; /* null terminate */ CWE121_Stack_Based_Buffer_Overflow__dest_wchar_t_declare_cat_41_goodG2BSink(data); } void CWE121_Stack_Based_Buffer_Overflow__dest_wchar_t_declare_cat_41_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__dest_wchar_t_declare_cat_41_good(); printLine("Finished good()"); #endif /* OMITGOOD */ #ifndef OMITBAD printLine("Calling bad()..."); CWE121_Stack_Based_Buffer_Overflow__dest_wchar_t_declare_cat_41_bad(); printLine("Finished bad()"); #endif /* OMITBAD */ return 0; } #endif
/****************************************************************************** This source file is part of the Avogadro project. Copyright 2011-2012 Kitware, Inc. This source code is released under the New BSD License, (the "License"). 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 AVOGADRO_CORE_VARIANT_H #define AVOGADRO_CORE_VARIANT_H #include "avogadrocore.h" #include "matrix.h" #include <string> namespace Avogadro { namespace Core { /** * @class Variant variant.h <avogadro/core/variant.h> * @brief The Variant class represents a union of data values. * * Variant objects allow for the storage of and conversion between a variety of * different data types. */ class AVOGADROCORE_EXPORT Variant { public: // enumerations enum Type { Null, Bool, Int, Long, Float, Double, Pointer, String, Matrix }; /** Creates a null variant. */ inline Variant(); /** Creates a variant to store @p value. */ template<typename T> Variant(T value); /** Creates a new copy of @p variant. */ inline Variant(const Variant &variant); /** Destroys the variant object. */ inline ~Variant(); /** Returns variant's type. */ inline Type type() const; /** Returns \c true if the variant is null. */ inline bool isNull() const; /** Sets the value of the variant to @p value. */ template<typename T> bool setValue(T value); /** Returns the value of the variant in the type given by \c T. */ template<typename T> T value() const; /** Clears the variant's data and sets the variant to null. */ inline void clear(); /** Returns the value of the variant as a \c bool. */ inline bool toBool() const; /** Returns the value of the variant as a \c char. */ inline char toChar() const; /** Returns the value of the variant as an \c unsigned \c char. */ inline unsigned char toUChar() const; /** Returns the value of the variant as a \c short. */ inline short toShort() const; /** Returns the value of the variant as an \c unsigned \c short. */ inline unsigned short toUShort() const; /** Returns the value of the variant as an \c int. */ inline int toInt() const; /** Returns the value of the variant as an \c unsigned \c int. */ inline unsigned int toUInt() const; /** Returns the value of the variant as a \c long. */ inline long toLong() const; /** Returns the value of the variant as an \c unsigned \c long. */ inline unsigned long toULong() const; /** Returns the value of the variant as a \c float. */ inline float toFloat() const; /** Returns the value of the variant as a \c double. */ inline double toDouble() const; /** Returns the value of the variant as a \c Real. */ inline Real toReal() const; /** Returns the value of the variant as a pointer. */ inline void* toPointer() const; /** Returns the value of the variant as a string. */ inline std::string toString() const; /** Returns the value of the variant as a MatrixX. */ inline MatrixX toMatrix() const; /** * Returns a reference to the value of the variant as a MatrixX. * This method will not perform any casting -- if type() is not exactly * MatrixX, the function will fail and return a reference to an empty MatrixX. */ inline const MatrixX& toMatrixRef() const; // operators inline Variant& operator=(const Variant &variant); private: template<typename T> static T lexical_cast(const std::string &string); private: Type m_type; union { bool _bool; char _char; int _int; long _long; float _float; double _double; void *pointer; std::string *string; MatrixX *matrix; } m_value; }; } // end Core namespace } // end Avogadro namespace #include "variant-inline.h" #endif // AVOGADRO_CORE_VARIANT_H
/*- * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Chris Torek. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)strcmp.c 8.1 (Berkeley) 6/4/93"; #endif /* LIBC_SCCS and not lint */ #include <sys/cdefs.h> #include <string.h> /* * Compare strings. */ int strcmp(s1, s2) register const char *s1, *s2; { while (*s1 == *s2++) if (*s1++ == 0) return (0); return (*(const unsigned char *)s1 - *(const unsigned char *)(s2 - 1)); }
// Copyright (C) 2013 Google Inc. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // * 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 GraphicsContextState_h #define GraphicsContextState_h #include "core/platform/graphics/Gradient.h" #include "core/platform/graphics/GraphicsTypes.h" #include "core/platform/graphics/Path.h" #include "core/platform/graphics/Pattern.h" #include "core/platform/graphics/StrokeData.h" #include "third_party/skia/include/core/SkColorPriv.h" #include "third_party/skia/include/core/SkDrawLooper.h" #include "third_party/skia/include/effects/SkDashPathEffect.h" #include "wtf/PassOwnPtr.h" namespace WebCore { // Encapsulates the state information we store for each pushed graphics state. // Only GraphicsContext can use this class. class GraphicsContextState { public: ~GraphicsContextState() { SkSafeUnref(m_looper); } private: friend class GraphicsContext; GraphicsContextState() : m_fillColor(Color::black) , m_fillRule(RULE_NONZERO) , m_looper(0) , m_textDrawingMode(TextModeFill) , m_alpha(1) , m_xferMode(SkXfermode::kSrcOver_Mode) , m_compositeOperator(CompositeSourceOver) , m_blendMode(BlendModeNormal) , m_clip(SkRect::MakeEmpty()) #if USE(LOW_QUALITY_IMAGE_INTERPOLATION) , m_interpolationQuality(InterpolationLow) #else , m_interpolationQuality(InterpolationHigh) #endif , m_shouldAntialias(true) , m_shouldSmoothFonts(true) { } GraphicsContextState(const GraphicsContextState& other) : m_strokeData(other.m_strokeData) , m_fillColor(other.m_fillColor) , m_fillRule(other.m_fillRule) , m_fillGradient(other.m_fillGradient) , m_fillPattern(other.m_fillPattern) , m_looper(other.m_looper) , m_textDrawingMode(other.m_textDrawingMode) , m_alpha(other.m_alpha) , m_xferMode(other.m_xferMode) , m_compositeOperator(other.m_compositeOperator) , m_blendMode(other.m_blendMode) , m_imageBufferClip(other.m_imageBufferClip) , m_clip(other.m_clip) , m_interpolationQuality(other.m_interpolationQuality) , m_shouldAntialias(other.m_shouldAntialias) , m_shouldSmoothFonts(other.m_shouldSmoothFonts) { // Up the ref count of these. SkSafeRef does nothing if its argument is 0. SkSafeRef(m_looper); // The clip image only needs to be applied once. Reset the image so that we // don't attempt to clip multiple times. m_imageBufferClip.reset(); } // Helper function for applying the state's alpha value to the given input // color to produce a new output color. SkColor applyAlpha(SkColor c) const { int s = roundf(m_alpha * 256); if (s >= 256) return c; if (s < 0) return 0; int a = SkAlphaMul(SkColorGetA(c), s); return (c & 0x00FFFFFF) | (a << 24); } // Returns a new State with all of this object's inherited properties copied. PassOwnPtr<GraphicsContextState> clone() { return adoptPtr(new GraphicsContextState(*this)); } // Not supported. No implementations. void operator=(const GraphicsContextState&); // Stroke. StrokeData m_strokeData; // Fill. Color m_fillColor; WindRule m_fillRule; RefPtr<Gradient> m_fillGradient; RefPtr<Pattern> m_fillPattern; // Shadow. (This will need tweaking if we use draw loopers for other things.) SkDrawLooper* m_looper; // Text. (See TextModeFill & friends.) TextDrawingModeFlags m_textDrawingMode; // Common shader state. float m_alpha; SkXfermode::Mode m_xferMode; // Compositing control, for the CSS and Canvas compositing spec. CompositeOperator m_compositeOperator; BlendMode m_blendMode; // If non-empty, the current State is clipped to this image. SkBitmap m_imageBufferClip; // If m_imageBufferClip is non-empty, this is the region the image is clipped to. SkRect m_clip; // Image interpolation control. InterpolationQuality m_interpolationQuality; bool m_shouldAntialias : 1; bool m_shouldSmoothFonts : 1; }; } // namespace WebCore #endif // GraphicsContextState_h
// Copyright 2015 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef COMPONENTS_HTML_VIEWER_LAYOUT_TEST_CONTENT_HANDLER_IMPL_H_ #define COMPONENTS_HTML_VIEWER_LAYOUT_TEST_CONTENT_HANDLER_IMPL_H_ #include "components/html_viewer/content_handler_impl.h" #include "components/html_viewer/html_factory.h" #include "components/test_runner/web_test_proxy.h" namespace blink { class WebView; } namespace test_runner { class WebTestInterfaces; } namespace html_viewer { class WebTestDelegateImpl; class LayoutTestContentHandlerImpl : public ContentHandlerImpl, public HTMLFactory { public: LayoutTestContentHandlerImpl(GlobalState* global_state, mojo::ApplicationImpl* app, mojo::InterfaceRequest<ContentHandler> request, test_runner::WebTestInterfaces* test_interfaces, WebTestDelegateImpl* test_delegate); ~LayoutTestContentHandlerImpl() override; private: using WebWidgetProxy = test_runner::WebTestProxy<HTMLWidgetRootLocal, HTMLWidgetRootLocal::CreateParams*>; // ContentHandler: void StartApplication( mojo::InterfaceRequest<mojo::Application> request, mojo::URLResponsePtr response, const mojo::Callback<void()>& destruct_callback) override; // HTMLFactory HTMLFrame* CreateHTMLFrame(HTMLFrame::CreateParams* params) override; HTMLWidgetRootLocal* CreateHTMLWidgetRootLocal( HTMLWidgetRootLocal::CreateParams* params) override; test_runner::WebTestInterfaces* test_interfaces_; WebTestDelegateImpl* test_delegate_; WebWidgetProxy* web_widget_proxy_; scoped_ptr<mojo::AppRefCount> app_refcount_; DISALLOW_COPY_AND_ASSIGN(LayoutTestContentHandlerImpl); }; } // namespace html_viewer #endif // COMPONENTS_HTML_VIEWER_LAYOUT_TEST_CONTENT_HANDLER_IMPL_H_
/* * Copyright (C) 2010 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. AND ITS 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 APPLE INC. OR ITS 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 BackForwardController_h #define BackForwardController_h #include <wtf/Noncopyable.h> #include <wtf/Forward.h> #include <wtf/RefPtr.h> namespace WebCore { class BackForwardClient; class HistoryItem; class Page; // FIXME: Why does this class exist? It seems to delegate almost entirely to Page, and perhaps should be part of Page's implementation. class BackForwardController { WTF_MAKE_NONCOPYABLE(BackForwardController); WTF_MAKE_FAST_ALLOCATED; public: ~BackForwardController(); static PassOwnPtr<BackForwardController> create(Page*, BackForwardClient*); BackForwardClient* client() const { return m_client; } void goBackOrForward(int distance); bool goBack(); bool goForward(); void addItem(PassRefPtr<HistoryItem>); void setCurrentItem(HistoryItem*); int count() const; int backCount() const; int forwardCount() const; HistoryItem* itemAtIndex(int); bool isActive(); void close(); HistoryItem* backItem() { return itemAtIndex(-1); } HistoryItem* currentItem() { return itemAtIndex(0); } HistoryItem* forwardItem() { return itemAtIndex(1); } private: BackForwardController(Page*, BackForwardClient*); Page* m_page; BackForwardClient* m_client; }; } // namespace WebCore #endif // BackForwardController_h
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE617_Reachable_Assertion__fgets_12.c Label Definition File: CWE617_Reachable_Assertion.label.xml Template File: sources-sink-12.tmpl.c */ /* * @description * CWE: 617 Reachable Assertion * BadSource: fgets Read data from the console using fgets() * GoodSource: Number greater than ASSERT_VALUE * Sink: * BadSink : Assert if n is less than or equal to ASSERT_VALUE * Flow Variant: 12 Control flow: if(globalReturnsTrueOrFalse()) * * */ #include "std_testcase.h" #include <assert.h> #define ASSERT_VALUE 5 #define CHAR_ARRAY_SIZE (3 * sizeof(data) + 2) #ifndef OMITBAD void CWE617_Reachable_Assertion__fgets_12_bad() { int data; /* Initialize data */ data = -1; if(globalReturnsTrueOrFalse()) { { 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."); } } } else { /* FIX: Use a value greater than the assert value */ data = ASSERT_VALUE+1; } /* POTENTIAL FLAW: this assertion could trigger if n <= ASSERT_VALUE */ assert(data > ASSERT_VALUE); } #endif /* OMITBAD */ #ifndef OMITGOOD /* goodG2B() - use goodsource and badsink by changing the "if" so that * both branches use the GoodSource */ static void goodG2B() { int data; /* Initialize data */ data = -1; if(globalReturnsTrueOrFalse()) { /* FIX: Use a value greater than the assert value */ data = ASSERT_VALUE+1; } else { /* FIX: Use a value greater than the assert value */ data = ASSERT_VALUE+1; } /* POTENTIAL FLAW: this assertion could trigger if n <= ASSERT_VALUE */ assert(data > ASSERT_VALUE); } void CWE617_Reachable_Assertion__fgets_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()..."); CWE617_Reachable_Assertion__fgets_12_good(); printLine("Finished good()"); #endif /* OMITGOOD */ #ifndef OMITBAD printLine("Calling bad()..."); CWE617_Reachable_Assertion__fgets_12_bad(); printLine("Finished bad()"); #endif /* OMITBAD */ return 0; } #endif
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE188_Reliance_on_Data_Memory_Layout__modify_local_17.c Label Definition File: CWE188_Reliance_on_Data_Memory_Layout.label.xml Template File: point-flaw-17.tmpl.c */ /* * @description * CWE: 188 Reliance on Data Memory Layout * Sinks: modify_local * GoodSink: Modify the second field of the struct using the field name * BadSink : Attempt to modify second field in struct, assuming the first field is an int * Flow Variant: 17 Control flow: for loops * * */ #include "std_testcase.h" #ifndef OMITBAD void CWE188_Reliance_on_Data_Memory_Layout__modify_local_17_bad() { int j; for(j = 0; j < 1; j++) { { struct { char charFirst; int intSecond; } structCharInt; char *charPtr; structCharInt.charFirst = 1; charPtr = &structCharInt.charFirst; /* FLAW: Attempt to modify intSecond assuming intSecond comes after charFirst and * is aligned on an int-boundary after charFirst */ *(int*)(charPtr + sizeof(int)) = 5; printIntLine(structCharInt.charFirst); printIntLine(structCharInt.intSecond); } } } #endif /* OMITBAD */ #ifndef OMITGOOD /* good1() uses the GoodSinkBody in the for statements */ static void good1() { int k; for(k = 0; k < 1; k++) { { struct { char charFirst; int intSecond; } structCharInt; structCharInt.charFirst = 1; /* FIX: Do not make unwarranted assumptions about underlying data model * Modify and access data appropriately */ structCharInt.intSecond = 5; printIntLine(structCharInt.charFirst); printIntLine(structCharInt.intSecond); } } } void CWE188_Reliance_on_Data_Memory_Layout__modify_local_17_good() { good1(); } #endif /* OMITGOOD */ /* Below is the main(). It is only used when building this testcase on its own for testing or for building a binary to use in testing binary analysis tools. It is not used when compiling all the testcases as one application, which is how source code analysis tools are tested. */ #ifdef INCLUDEMAIN int main(int argc, char * argv[]) { /* seed randomness */ srand( (unsigned)time(NULL) ); #ifndef OMITGOOD printLine("Calling good()..."); CWE188_Reliance_on_Data_Memory_Layout__modify_local_17_good(); printLine("Finished good()"); #endif /* OMITGOOD */ #ifndef OMITBAD printLine("Calling bad()..."); CWE188_Reliance_on_Data_Memory_Layout__modify_local_17_bad(); printLine("Finished bad()"); #endif /* OMITBAD */ return 0; } #endif
/* Copyright 2018 The Chromium OS Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #include "common.h" #include "ec_commands.h" #include "led_pwm.h" #include "pwm.h" #include "util.h" const enum ec_led_id supported_led_ids[] = { EC_LED_ID_POWER_LED, }; const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids); /* * We only have a blue and an amber LED, so setting any other colour results in * both LEDs being off. */ struct pwm_led_color_map led_color_map[EC_LED_COLOR_COUNT] = { /* Amber, Blue */ [EC_LED_COLOR_RED] = { 0, 0 }, [EC_LED_COLOR_GREEN] = { 0, 0 }, [EC_LED_COLOR_BLUE] = { 0, 100 }, [EC_LED_COLOR_YELLOW] = { 0, 0 }, [EC_LED_COLOR_WHITE] = { 0, 0 }, [EC_LED_COLOR_AMBER] = { 100, 0 }, }; /* One logical LED with amber and blue channels. */ struct pwm_led pwm_leds[CONFIG_LED_PWM_COUNT] = { { .ch0 = PWM_CH_LED1_AMBER, .ch1 = PWM_CH_LED2_BLUE, .ch2 = PWM_LED_NO_CHANNEL, .enable = &pwm_enable, .set_duty = &pwm_set_duty, }, }; void led_get_brightness_range(enum ec_led_id led_id, uint8_t *brightness_range) { memset(brightness_range, '\0', sizeof(*brightness_range) * EC_LED_COLOR_COUNT); brightness_range[EC_LED_COLOR_AMBER] = 100; brightness_range[EC_LED_COLOR_BLUE] = 100; } int led_set_brightness(enum ec_led_id led_id, const uint8_t *brightness) { enum pwm_led_id pwm_id; /* Convert ec_led_id to pwm_led_id. */ if (led_id == EC_LED_ID_POWER_LED) pwm_id = PWM_LED0; else return EC_ERROR_UNKNOWN; if (brightness[EC_LED_COLOR_BLUE]) set_pwm_led_color(pwm_id, EC_LED_COLOR_BLUE); else if (brightness[EC_LED_COLOR_AMBER]) set_pwm_led_color(pwm_id, EC_LED_COLOR_AMBER); else /* Otherwise, the "color" is "off". */ set_pwm_led_color(pwm_id, -1); return EC_SUCCESS; }
/* +----------------------------------------------------------------------------------------------+ | Windows Cache for PHP | +----------------------------------------------------------------------------------------------+ | Copyright (c) 2009, Microsoft Corporation. All rights reserved. | | | | Redistribution and use in source and binary forms, with or without modification, are | | permitted provided that the following conditions are met: | | - 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 Microsoft Corporation nor the names of its contributors may be | | used to endorse or promote products derived from this software without specific prior written| | permission. | | | | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS | | OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | | COPYRIGHT 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. | +----------------------------------------------------------------------------------------------+ | Module: wincache_utils.h | +----------------------------------------------------------------------------------------------+ | Author: Kanwaljeet Singla <ksingla@microsoft.com> | +----------------------------------------------------------------------------------------------+ */ #ifndef _WINCACHE_UTILS_H_ #define _WINCACHE_UTILS_H_ extern unsigned int utils_hashcalc(const char * str, unsigned int strlen); extern unsigned int utils_getindex(const char * filename, unsigned int numfiles); extern char * utils_filepath(zend_file_handle * file_handle); extern char * utils_fullpath(const char * filename); extern int utils_cwdcexec(char * buffer, unsigned int length TSRMLS_DC); extern int utils_filefolder(const char * filepath, unsigned int flength, char * pbuffer, unsigned int length); extern int utils_apoolpid(); extern unsigned int utils_ticksdiff(unsigned int present, unsigned int past); extern char * utils_resolve_path(const char *filename, int filename_length, const char *path TSRMLS_DC); #if (defined(_MSC_VER) && (_MSC_VER < 1500)) extern int wincache_php_snprintf_s(char *buf, size_t len, size_t len2, const char *format,...); #endif #endif /* _WINCACHE_UTILS_H_ */
/* * This software is distributed under BSD 3-clause license (see LICENSE file). * * Authors: Soeren Sonnenburg, Heiko Strathmann, Evan Shelhamer */ #include <shogun/lib/config.h> #ifndef MULTIQUADRIC_H_ #define MULTIQUADRIC_H_ #include <shogun/lib/common.h> #include <shogun/kernel/Kernel.h> #include <shogun/distance/Distance.h> namespace shogun { class Distance; /** @brief MultiquadricKernel * * \f[ * K(x,x') = \sqrt{\| x - x' \|^2 +c^2} * \f] */ class MultiquadricKernel: public Kernel { public: /** default constructor */ MultiquadricKernel(); /** constructor * @param cache size of cache * @param coef kernel parameter coef * @param dist distance to be used */ MultiquadricKernel(int32_t cache, float64_t coef, std::shared_ptr<Distance> dist); /** constructor * @param l features left-side * @param r features right-side * @param coef kernel parameter coef * @param dist distance to be used */ MultiquadricKernel(std::shared_ptr<Features >l, std::shared_ptr<Features >r, float64_t coef, std::shared_ptr<Distance> dist); /** initialize kernel with features * @param l features left-side * @param r features right-side * @return true if successful */ bool init(std::shared_ptr<Features> l, std::shared_ptr<Features> r) override; /** * @return kernel type */ EKernelType get_kernel_type() override { return K_MULTIQUADRIC; } /** * @return type of features */ EFeatureType get_feature_type() override { return m_distance->get_feature_type(); } /** * @return class of features */ EFeatureClass get_feature_class() override { return m_distance->get_feature_class(); } /** * @return name of kernel */ const char* get_name() const override { return "MultiquadricKernel"; } /** getter for coef parameter * @return kernel parameter coefficient */ inline float64_t get_coef() { return m_coef; } /** setter for coef parameter * @param value kernel parameter coefficient */ inline void set_coef(float64_t value) { m_coef = value; } ~MultiquadricKernel() override; protected: /** * compute kernel for specific feature vectors * corresponding to [idx_a] of left-side and [idx_b] of right-side * @param idx_a left-side index * @param idx_b right-side index * @return kernel value */ float64_t compute(int32_t idx_a, int32_t idx_b) override; private: void init(); protected: /// distance to be used std::shared_ptr<Distance> m_distance; /// theta parameter of kernel - coefficient float64_t m_coef; }; } #endif /* MULTIQUADRIC_H_ */
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE506_Embedded_Malicious_Code__file_transfer_listen_socket_16.c Label Definition File: CWE506_Embedded_Malicious_Code__file_transfer.badonly.label.xml Template File: point-flaw-badonly-16.tmpl.c */ /* * @description * CWE: 506 Embedded Malicious Code * Sinks: listen_socket * BadSink : Send file contents using a listen socket (server side) * BadOnly (No GoodSink) * Flow Variant: 16 Control flow: while(1) * * */ #include "std_testcase.h" #ifdef _WIN32 #include <winsock2.h> #include <windows.h> #include <direct.h> #pragma comment(lib, "ws2_32") /* include ws2_32.lib when linking */ #define CLOSE_SOCKET closesocket #else #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 LISTEN_BACKLOG 5 #define FILENAME "conf.txt" #ifndef OMITBAD void CWE506_Embedded_Malicious_Code__file_transfer_listen_socket_16_bad() { while(1) { { #ifdef _WIN32 WSADATA wsaData; int wsaDataInit = 0; #endif struct sockaddr_in service; SOCKET listenSocket = INVALID_SOCKET; SOCKET acceptSocket = INVALID_SOCKET; char contents[65536]; /* Assume file contents is less than 65k to make this test case easier to implement */ FILE * pFile; pFile = fopen(FILENAME, "r"); if (pFile != NULL) { if (fgets(contents, (int)(65535), pFile) == NULL) { printLine("fgets() failed"); /* Restore NUL terminator if fgets fails */ contents[0] = '\0'; } fclose(pFile); } do { #ifdef _WIN32 if (WSAStartup(MAKEWORD(2,2), &wsaData) != NO_ERROR) { break; } wsaDataInit = 1; #endif listenSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (listenSocket == INVALID_SOCKET) { break; } memset(&service, 0, sizeof(service)); service.sin_family = AF_INET; service.sin_addr.s_addr = INADDR_ANY; service.sin_port = htons(TCP_PORT); if (bind(listenSocket, (struct sockaddr*)&service, sizeof(service)) == SOCKET_ERROR) { break; } if (listen(listenSocket, LISTEN_BACKLOG) == SOCKET_ERROR) { break; } acceptSocket = accept(listenSocket, NULL, NULL); if (acceptSocket == SOCKET_ERROR) { break; } /* FLAW: Send the contents of a file over the network */ if (send(acceptSocket, contents, strlen(contents), 0) != strlen(contents)) { break; } } while (0); if (listenSocket != INVALID_SOCKET) { CLOSE_SOCKET(listenSocket); } if (acceptSocket != INVALID_SOCKET) { CLOSE_SOCKET(acceptSocket); } #ifdef _WIN32 if (wsaDataInit) { WSACleanup(); } #endif } break; } } #endif /* OMITBAD */ /* 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 OMITBAD printLine("Calling bad()..."); CWE506_Embedded_Malicious_Code__file_transfer_listen_socket_16_bad(); printLine("Finished bad()"); #endif /* OMITBAD */ return 0; } #endif
/* $NetBSD: strnlen.c,v 1.1.1.1 2011/04/13 18:15:43 elric Exp $ */ /* * Copyright (c) 1995 - 1999 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 <config.h> #include <krb5/roken.h> ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL strnlen(const char *s, size_t len) { size_t i; for(i = 0; i < len && s[i]; i++) ; return i; }
/* * Copyright (c) 1987 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that this notice is preserved and that due credit is given * to the University of California at Berkeley. The name of the University * may not be used to endorse or promote products derived from this * software without specific written prior permission. This software * is provided ``as is'' without express or implied warranty. */ /* @deftypefn Supplemental int strcasecmp (const char *@var{s1}, const char *@var{s2}) A case-insensitive @code{strcmp}. @end deftypefn */ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)strcasecmp.c 5.5 (Berkeley) 11/24/87"; #endif /* LIBC_SCCS and not lint */ #include "../include/ansidecl.h" #include "../include/stddef.h" /* * This array is designed for mapping upper and lower case letter * together for a case independent comparison. The mappings are * based upon ascii character sequences. */ typedef unsigned char uc; static const unsigned char charmap[] = { (uc)'\000',(uc)'\001',(uc)'\002',(uc)'\003',(uc)'\004',(uc)'\005',(uc)'\006',(uc)'\007', (uc)'\010',(uc)'\011',(uc)'\012',(uc)'\013',(uc)'\014',(uc)'\015',(uc)'\016',(uc)'\017', (uc)'\020',(uc)'\021',(uc)'\022',(uc)'\023',(uc)'\024',(uc)'\025',(uc)'\026',(uc)'\027', (uc)'\030',(uc)'\031',(uc)'\032',(uc)'\033',(uc)'\034',(uc)'\035',(uc)'\036',(uc)'\037', (uc)'\040',(uc)'\041',(uc)'\042',(uc)'\043',(uc)'\044',(uc)'\045',(uc)'\046',(uc)'\047', (uc)'\050',(uc)'\051',(uc)'\052',(uc)'\053',(uc)'\054',(uc)'\055',(uc)'\056',(uc)'\057', (uc)'\060',(uc)'\061',(uc)'\062',(uc)'\063',(uc)'\064',(uc)'\065',(uc)'\066',(uc)'\067', (uc)'\070',(uc)'\071',(uc)'\072',(uc)'\073',(uc)'\074',(uc)'\075',(uc)'\076',(uc)'\077', (uc)'\100',(uc)'\141',(uc)'\142',(uc)'\143',(uc)'\144',(uc)'\145',(uc)'\146',(uc)'\147', (uc)'\150',(uc)'\151',(uc)'\152',(uc)'\153',(uc)'\154',(uc)'\155',(uc)'\156',(uc)'\157', (uc)'\160',(uc)'\161',(uc)'\162',(uc)'\163',(uc)'\164',(uc)'\165',(uc)'\166',(uc)'\167', (uc)'\170',(uc)'\171',(uc)'\172',(uc)'\133',(uc)'\134',(uc)'\135',(uc)'\136',(uc)'\137', (uc)'\140',(uc)'\141',(uc)'\142',(uc)'\143',(uc)'\144',(uc)'\145',(uc)'\146',(uc)'\147', (uc)'\150',(uc)'\151',(uc)'\152',(uc)'\153',(uc)'\154',(uc)'\155',(uc)'\156',(uc)'\157', (uc)'\160',(uc)'\161',(uc)'\162',(uc)'\163',(uc)'\164',(uc)'\165',(uc)'\166',(uc)'\167', (uc)'\170',(uc)'\171',(uc)'\172',(uc)'\173',(uc)'\174',(uc)'\175',(uc)'\176',(uc)'\177', (uc)'\200',(uc)'\201',(uc)'\202',(uc)'\203',(uc)'\204',(uc)'\205',(uc)'\206',(uc)'\207', (uc)'\210',(uc)'\211',(uc)'\212',(uc)'\213',(uc)'\214',(uc)'\215',(uc)'\216',(uc)'\217', (uc)'\220',(uc)'\221',(uc)'\222',(uc)'\223',(uc)'\224',(uc)'\225',(uc)'\226',(uc)'\227', (uc)'\230',(uc)'\231',(uc)'\232',(uc)'\233',(uc)'\234',(uc)'\235',(uc)'\236',(uc)'\237', (uc)'\240',(uc)'\241',(uc)'\242',(uc)'\243',(uc)'\244',(uc)'\245',(uc)'\246',(uc)'\247', (uc)'\250',(uc)'\251',(uc)'\252',(uc)'\253',(uc)'\254',(uc)'\255',(uc)'\256',(uc)'\257', (uc)'\260',(uc)'\261',(uc)'\262',(uc)'\263',(uc)'\264',(uc)'\265',(uc)'\266',(uc)'\267', (uc)'\270',(uc)'\271',(uc)'\272',(uc)'\273',(uc)'\274',(uc)'\275',(uc)'\276',(uc)'\277', (uc)'\300',(uc)'\341',(uc)'\342',(uc)'\343',(uc)'\344',(uc)'\345',(uc)'\346',(uc)'\347', (uc)'\350',(uc)'\351',(uc)'\352',(uc)'\353',(uc)'\354',(uc)'\355',(uc)'\356',(uc)'\357', (uc)'\360',(uc)'\361',(uc)'\362',(uc)'\363',(uc)'\364',(uc)'\365',(uc)'\366',(uc)'\367', (uc)'\370',(uc)'\371',(uc)'\372',(uc)'\333',(uc)'\334',(uc)'\335',(uc)'\336',(uc)'\337', (uc)'\340',(uc)'\341',(uc)'\342',(uc)'\343',(uc)'\344',(uc)'\345',(uc)'\346',(uc)'\347', (uc)'\350',(uc)'\351',(uc)'\352',(uc)'\353',(uc)'\354',(uc)'\355',(uc)'\356',(uc)'\357', (uc)'\360',(uc)'\361',(uc)'\362',(uc)'\363',(uc)'\364',(uc)'\365',(uc)'\366',(uc)'\367', (uc)'\370',(uc)'\371',(uc)'\372',(uc)'\373',(uc)'\374',(uc)'\375',(uc)'\376',(uc)'\377', }; int strcasecmp(s1, s2) const char *s1, *s2; { register unsigned char u1, u2; for (;;) { u1 = (unsigned char) *s1++; u2 = (unsigned char) *s2++; if (charmap[u1] != charmap[u2]) { return charmap[u1] - charmap[u2]; } if (u1 == '\0') { return 0; } } }
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE126_Buffer_Overread__char_alloca_memmove_44.c Label Definition File: CWE126_Buffer_Overread.stack.label.xml Template File: sources-sink-44.tmpl.c */ /* * @description * CWE: 126 Buffer Over-read * BadSource: Set data pointer to a small buffer * GoodSource: Set data pointer to a large buffer * Sinks: memmove * BadSink : Copy data to string using memmove * Flow Variant: 44 Data/control flow: data passed as an argument from one function to a function in the same source file called via a function pointer * * */ #include "std_testcase.h" #include <wchar.h> #ifndef OMITBAD static void badSink(char * data) { { char dest[100]; memset(dest, 'C', 100-1); dest[100-1] = '\0'; /* null terminate */ /* POTENTIAL FLAW: using memmove with the length of the dest where data * could be smaller than dest causing buffer overread */ memmove(dest, data, strlen(dest)*sizeof(char)); dest[100-1] = '\0'; printLine(dest); } } void CWE126_Buffer_Overread__char_alloca_memmove_44_bad() { char * data; /* define a function pointer */ void (*funcPtr) (char *) = badSink; char * dataBadBuffer = (char *)ALLOCA(50*sizeof(char)); char * dataGoodBuffer = (char *)ALLOCA(100*sizeof(char)); memset(dataBadBuffer, 'A', 50-1); /* fill with 'A's */ dataBadBuffer[50-1] = '\0'; /* null terminate */ memset(dataGoodBuffer, 'A', 100-1); /* fill with 'A's */ dataGoodBuffer[100-1] = '\0'; /* null terminate */ /* FLAW: Set data pointer to a small buffer */ data = dataBadBuffer; /* use the function pointer */ funcPtr(data); } #endif /* OMITBAD */ #ifndef OMITGOOD /* goodG2B() uses the GoodSource with the BadSink */ static void goodG2BSink(char * data) { { char dest[100]; memset(dest, 'C', 100-1); dest[100-1] = '\0'; /* null terminate */ /* POTENTIAL FLAW: using memmove with the length of the dest where data * could be smaller than dest causing buffer overread */ memmove(dest, data, strlen(dest)*sizeof(char)); dest[100-1] = '\0'; printLine(dest); } } static void goodG2B() { char * data; void (*funcPtr) (char *) = goodG2BSink; char * dataBadBuffer = (char *)ALLOCA(50*sizeof(char)); char * dataGoodBuffer = (char *)ALLOCA(100*sizeof(char)); memset(dataBadBuffer, 'A', 50-1); /* fill with 'A's */ dataBadBuffer[50-1] = '\0'; /* null terminate */ memset(dataGoodBuffer, 'A', 100-1); /* fill with 'A's */ dataGoodBuffer[100-1] = '\0'; /* null terminate */ /* FIX: Set data pointer to a large buffer */ data = dataGoodBuffer; funcPtr(data); } void CWE126_Buffer_Overread__char_alloca_memmove_44_good() { goodG2B(); } #endif /* OMITGOOD */ /* Below is the main(). It is only used when building this testcase on * its own for testing or for building a binary to use in testing binary * analysis tools. It is not used when compiling all the testcases as one * application, which is how source code analysis tools are tested. */ #ifdef INCLUDEMAIN int main(int argc, char * argv[]) { /* seed randomness */ srand( (unsigned)time(NULL) ); #ifndef OMITGOOD printLine("Calling good()..."); CWE126_Buffer_Overread__char_alloca_memmove_44_good(); printLine("Finished good()"); #endif /* OMITGOOD */ #ifndef OMITBAD printLine("Calling bad()..."); CWE126_Buffer_Overread__char_alloca_memmove_44_bad(); printLine("Finished bad()"); #endif /* OMITBAD */ return 0; } #endif
// Copyright 2015 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CHROME_BROWSER_TASK_MANAGEMENT_PROVIDERS_ARC_ARC_PROCESS_TASK_PROVIDER_H_ #define CHROME_BROWSER_TASK_MANAGEMENT_PROVIDERS_ARC_ARC_PROCESS_TASK_PROVIDER_H_ #include <map> #include <set> #include <string> #include <vector> #include "base/macros.h" #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "base/process/process.h" #include "chrome/browser/chromeos/arc/arc_process.h" #include "chrome/browser/task_management/providers/arc/arc_process_task.h" #include "chrome/browser/task_management/providers/task_provider.h" namespace task_management { // This provides the ARC process tasks. // // Since this provider obtains ARC process information via IPC and procfs, // it can never avoid race conditions. For example, in an extreme case such as // fork(2) is called millions of times in a second, this provider can return // wrong results. However, its chance is very low, and even if we hit the case, // the worst outcome is just that an app (non-system) process which // the user did not intend to choose is killed. Since apps are designed // to be killed at any time, it sounds acceptable. class ArcProcessTaskProvider : public TaskProvider { public: ArcProcessTaskProvider(); ~ArcProcessTaskProvider() override; // task_management::TaskProvider: Task* GetTaskOfUrlRequest(int origin_pid, int child_id, int route_id) override; private: // Auto-retry if ARC bridge service is not ready. void RequestProcessList(); void OnUpdateProcessList(const std::vector<arc::ArcProcess>& processes); // task_management::TaskProvider: void StartUpdating() override; void StopUpdating() override; void ScheduleNextRequest(); std::map<base::ProcessId, scoped_ptr<ArcProcessTask>> nspid_to_task_; // Whether to continue the periodical polling. bool is_updating_; // Always keep this the last member of this class to make sure it's the // first thing to be destructed. base::WeakPtrFactory<ArcProcessTaskProvider> weak_ptr_factory_; DISALLOW_COPY_AND_ASSIGN(ArcProcessTaskProvider); }; } // namespace task_management #endif // CHROME_BROWSER_TASK_MANAGEMENT_PROVIDERS_ARC_ARC_PROCESS_TASK_PROVIDER_H_
/*- * Copyright (c) 1988, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)limits.h 8.2 (Berkeley) 1/4/94 * $Id: limits.h,v 1.1.1.1 2006/05/30 06:12:30 hhzhou Exp $ */ #ifndef _LIMITS_H_ #define _LIMITS_H_ #include <sys/_posix.h> #ifndef _ANSI_SOURCE #define _POSIX_ARG_MAX 4096 #define _POSIX_CHILD_MAX 6 #define _POSIX_LINK_MAX 8 #define _POSIX_MAX_CANON 255 #define _POSIX_MAX_INPUT 255 #define _POSIX_NAME_MAX 14 #define _POSIX_NGROUPS_MAX 0 #define _POSIX_OPEN_MAX 16 #define _POSIX_PATH_MAX 255 #define _POSIX_PIPE_BUF 512 #define _POSIX_SSIZE_MAX 32767 #define _POSIX_STREAM_MAX 8 #define _POSIX_TZNAME_MAX 3 #define _POSIX2_BC_BASE_MAX 99 #define _POSIX2_BC_DIM_MAX 2048 #define _POSIX2_BC_SCALE_MAX 99 #define _POSIX2_BC_STRING_MAX 1000 #define _POSIX2_EQUIV_CLASS_MAX 2 #define _POSIX2_EXPR_NEST_MAX 32 #define _POSIX2_LINE_MAX 2048 #define _POSIX2_RE_DUP_MAX 255 #ifdef _P1003_1B_VISIBLE #define _POSIX_AIO_LISTIO_MAX 16 #define _POSIX_AIO_MAX 1 #define _POSIX_DELAYTIMER_MAX 32 #define _POSIX_MQ_OPEN_MAX 8 #define _POSIX_MQ_PRIO_MAX 32 #define _POSIX_RTSIG_MAX 0 #define _POSIX_SEM_NSEMS_MAX 256 #define _POSIX_SEM_VALUE_MAX 32767 #define _POSIX_SIGQUEUE_MAX 32 #define _POSIX_TIMER_MAX 32 #endif #endif /* !_ANSI_SOURCE */ #if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE) || defined(_XOPEN_SOURCE) #define PASS_MAX 128 /* _PASSWORD_LEN from <pwd.h> */ #define NL_ARGMAX 99 /* max # of position args for printf */ #define NL_LANGMAX 31 /* max LANG name length */ #define NL_MSGMAX 32767 #define NL_NMAX 1 #define NL_SETMAX 255 #define NL_TEXTMAX 2048 #endif #include <machine/limits.h> #if !defined(_ANSI_SOURCE) #include <sys/syslimits.h> #endif #endif /* !_LIMITS_H_ */
/// @file /// @version 2.0 /// /// @section LICENSE /// /// This program is free software; you can redistribute it and/or modify it under /// the terms of the BSD license: http://opensource.org/licenses/BSD-3-Clause /// /// @section DESCRIPTION /// /// Demonstrates how multiple videos can be rendered at once easily. #ifdef _DEMO_MULTIPLE #ifndef THEORAPLAYER_DEMOS_MULTIPLE_H #define THEORAPLAYER_DEMOS_MULTIPLE_H #include "demo_basecode.h" namespace multiple { extern Demo demo; } #endif #endif
#include "first.h" #undef NDEBUG #include <sys/types.h> #include <assert.h> #include <stdlib.h> #include <stdio.h> #include "mod_indexfile.c" #include "fdlog.h" __attribute_noinline__ static void test_mod_indexfile_reset (request_st * const r) { r->http_status = 0; buffer_copy_string_len(&r->uri.path, CONST_STR_LEN("/")); buffer_copy_string_len(&r->physical.doc_root, CONST_STR_LEN("/tmp")); buffer_copy_string_len(&r->physical.path, CONST_STR_LEN("/tmp/")); } __attribute_noinline__ static void run_mod_indexfile_tryfiles (request_st * const r, const array * const indexfiles, int line, int status, const char *desc) { handler_t rc = mod_indexfile_tryfiles(r, indexfiles); if (r->http_status != status || rc != (status ? HANDLER_FINISHED : HANDLER_GO_ON)) { fprintf(stderr, "%s.%d: %s() failed: expected '%d', got '%d' for test %s\n", __FILE__, line, "mod_indexfile_tryfiles", status, r->http_status, desc); fflush(stderr); abort(); } } #include <unistd.h> /* unlink() */ static void test_mod_indexfile_tryfiles (request_st * const r) { char fn[] = "/tmp/lighttpd_mod_indexfile.XXXXXX"; #ifdef __COVERITY__ /* POSIX-2008 requires mkstemp create file with 0600 perms */ umask(0600); #endif /* coverity[secure_temp : FALSE] */ int fd = mkstemp(fn); if (fd < 0) { perror("mkstemp()"); exit(1); } struct stat st; if (0 != fstat(fd, &st)) { perror("fstat()"); exit(1); } array * const indexfiles = array_init(3); test_mod_indexfile_reset(r); run_mod_indexfile_tryfiles(r, indexfiles, __LINE__, 0, "empty indexfiles"); assert(buffer_eq_slen(&r->physical.path, CONST_STR_LEN("/tmp/"))); test_mod_indexfile_reset(r); /*(assumes modified tempfile name does not exist)*/ array_insert_value(indexfiles, fn+5, sizeof(fn)-6-1); run_mod_indexfile_tryfiles(r, indexfiles, __LINE__, 0, "non-matching indexfiles"); assert(buffer_eq_slen(&r->physical.path, CONST_STR_LEN("/tmp/"))); test_mod_indexfile_reset(r); array_insert_value(indexfiles, fn+5, sizeof(fn)-5-1); run_mod_indexfile_tryfiles(r, indexfiles, __LINE__, 0, "matching indexfile entry (w/o leading '/')"); assert(buffer_eq_slen(&r->physical.path, fn, sizeof(fn)-1)); test_mod_indexfile_reset(r); array_reset_data_strings(indexfiles); array_insert_value(indexfiles, fn+4, sizeof(fn)-4-1); run_mod_indexfile_tryfiles(r, indexfiles, __LINE__, 0, "matching indexfile entry (w/ leading '/')"); assert(buffer_eq_slen(&r->physical.path, fn, sizeof(fn)-1)); test_mod_indexfile_reset(r); array_free(indexfiles); unlink(fn); } void test_mod_indexfile (void); void test_mod_indexfile (void) { request_st r; memset(&r, 0, sizeof(request_st)); r.conf.errh = fdlog_init(NULL, -1, FDLOG_FD); r.conf.errh->fd = -1; /* (disable) */ r.conf.follow_symlink = 1; array * const mimetypes = array_init(0); r.conf.mimetypes = mimetypes; /*(must not be NULL)*/ test_mod_indexfile_tryfiles(&r); array_free(mimetypes); fdlog_free(r.conf.errh); free(r.uri.path.ptr); free(r.physical.path.ptr); free(r.physical.doc_root.ptr); array_free_data(&r.env); stat_cache_free(); }
//------------------------------------------------------------------------------ // // // Project: Dynamic Script Converter // // File name: DSC_ScriptConverter.c // // Author: Charles Liu // // // Copyright (c) 2002 Zeevo Inc. All rights reserved. // //------------------------------------------------------------------------------ //****************************************************************************** //* * //* IMPORTANT * //* * //* This file is automatically generated. This file MUST not be changed. * //* * //****************************************************************************** #ifndef __AppDynamicConfig__H #define __AppDynamicConfig__H typedef struct t_AppDynamicCfg { uint16 App_LongBufferNum ; // 4 : 0x4 uint16 App_LongBufferSize ; // 400 : 0x190 uint16 App_MidBufferNum ; // 8 : 0x8 uint16 App_MidBufferSize ; // 150 : 0x96 uint16 App_ShortBufferNum ; // 8 : 0x8 uint16 App_ShortBufferSize ; // 64 : 0x40 } t_AppDynamicCfg ; extern t_AppDynamicCfg *pAppDynamicCfg; #endif // __AppDynamicConfig__H
/* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include "param.h" #include "user.h" #include "proc.h" #include "systm.h" #include "vm.h" #include "kernel.h" /* * Resource controls and accounting. */ void getpriority() { register struct a { int which; int who; } *uap = (struct a *)u.u_arg; register struct proc *p; register int low = PRIO_MAX + 1; switch (uap->which) { case PRIO_PROCESS: if (uap->who == 0) p = u.u_procp; else p = pfind(uap->who); if (p == 0) break; low = p->p_nice; break; case PRIO_PGRP: if (uap->who == 0) uap->who = u.u_procp->p_pgrp; for (p = allproc; p != NULL; p = p->p_nxt) { if (p->p_pgrp == uap->who && p->p_nice < low) low = p->p_nice; } break; case PRIO_USER: if (uap->who == 0) uap->who = u.u_uid; for (p = allproc; p != NULL; p = p->p_nxt) { if (p->p_uid == uap->who && p->p_nice < low) low = p->p_nice; } break; default: u.u_error = EINVAL; return; } if (low == PRIO_MAX + 1) { u.u_error = ESRCH; return; } u.u_rval = low; } static void donice(p, n) register struct proc *p; register int n; { if (u.u_uid && u.u_ruid && u.u_uid != p->p_uid && u.u_ruid != p->p_uid) { u.u_error = EPERM; return; } if (n > PRIO_MAX) n = PRIO_MAX; if (n < PRIO_MIN) n = PRIO_MIN; if (n < p->p_nice && !suser()) { u.u_error = EACCES; return; } p->p_nice = n; } void setpriority() { register struct a { int which; int who; int prio; } *uap = (struct a *)u.u_arg; register struct proc *p; register int found = 0; switch (uap->which) { case PRIO_PROCESS: if (uap->who == 0) p = u.u_procp; else p = pfind(uap->who); if (p == 0) break; donice(p, uap->prio); found++; break; case PRIO_PGRP: if (uap->who == 0) uap->who = u.u_procp->p_pgrp; for (p = allproc; p != NULL; p = p->p_nxt) if (p->p_pgrp == uap->who) { donice(p, uap->prio); found++; } break; case PRIO_USER: if (uap->who == 0) uap->who = u.u_uid; for (p = allproc; p != NULL; p = p->p_nxt) if (p->p_uid == uap->who) { donice(p, uap->prio); found++; } break; default: u.u_error = EINVAL; return; } if (found == 0) u.u_error = ESRCH; } void setrlimit() { register struct a { u_int which; struct rlimit *lim; } *uap = (struct a *)u.u_arg; struct rlimit alim; register struct rlimit *alimp; if (uap->which >= RLIM_NLIMITS) { u.u_error = EINVAL; return; } alimp = &u.u_rlimit[uap->which]; u.u_error = copyin((caddr_t)uap->lim, (caddr_t)&alim, sizeof (struct rlimit)); if (u.u_error) return; if (uap->which == RLIMIT_CPU) { /* * 2.11 stores RLIMIT_CPU as ticks to keep from making * hardclock() do long multiplication/division. */ if (alim.rlim_cur >= RLIM_INFINITY / hz) alim.rlim_cur = RLIM_INFINITY; else alim.rlim_cur = alim.rlim_cur * hz; if (alim.rlim_max >= RLIM_INFINITY / hz) alim.rlim_max = RLIM_INFINITY; else alim.rlim_max = alim.rlim_max * hz; } if (alim.rlim_cur > alimp->rlim_max || alim.rlim_max > alimp->rlim_max) if (!suser()) return; *alimp = alim; } void getrlimit() { register struct a { u_int which; struct rlimit *rlp; } *uap = (struct a *)u.u_arg; if (uap->which >= RLIM_NLIMITS) { u.u_error = EINVAL; return; } if (uap->which == RLIMIT_CPU) { struct rlimit alim; alim = u.u_rlimit[uap->which]; if (alim.rlim_cur != RLIM_INFINITY) alim.rlim_cur = alim.rlim_cur / hz; if (alim.rlim_max != RLIM_INFINITY) alim.rlim_max = alim.rlim_max / hz; u.u_error = copyout((caddr_t)&alim, (caddr_t)uap->rlp,sizeof (struct rlimit)); } else u.u_error = copyout((caddr_t)&u.u_rlimit[uap->which], (caddr_t)uap->rlp,sizeof (struct rlimit)); } void getrusage() { register struct a { int who; struct rusage *rusage; } *uap = (struct a *)u.u_arg; register struct k_rusage *rup; struct rusage ru; switch (uap->who) { case RUSAGE_SELF: rup = &u.u_ru; break; case RUSAGE_CHILDREN: rup = &u.u_cru; break; default: u.u_error = EINVAL; return; } rucvt(&ru,rup); u.u_error = copyout((caddr_t)&ru, (caddr_t)uap->rusage, sizeof (struct rusage)); } /* * Add resource usage data. */ void ruadd(ru, ru2) struct k_rusage *ru, *ru2; { register long *ip, *ip2; register int i; /* * since the kernel timeval structures are single longs, * fold them into the loop. */ ip = &ru->k_ru_first; ip2 = &ru2->k_ru_first; for (i = &ru->k_ru_last - &ru->k_ru_first; i >= 0; i--) *ip++ += *ip2++; } /* * Convert an internal kernel rusage structure into a `real' rusage structure. */ void rucvt (rup, krup) register struct rusage *rup; register struct k_rusage *krup; { bzero((caddr_t)rup, sizeof(*rup)); rup->ru_utime.tv_sec = krup->ru_utime / hz; rup->ru_utime.tv_usec = (krup->ru_utime % hz) * usechz; rup->ru_stime.tv_sec = krup->ru_stime / hz; rup->ru_stime.tv_usec = (krup->ru_stime % hz) * usechz; rup->ru_nswap = krup->ru_nswap; rup->ru_inblock = krup->ru_inblock; rup->ru_oublock = krup->ru_oublock; rup->ru_msgsnd = krup->ru_msgsnd; rup->ru_msgrcv = krup->ru_msgrcv; rup->ru_nsignals = krup->ru_nsignals; rup->ru_nvcsw = krup->ru_nvcsw; rup->ru_nivcsw = krup->ru_nivcsw; }
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE114_Process_Control__w32_char_listen_socket_54e.c Label Definition File: CWE114_Process_Control__w32.label.xml Template File: sources-sink-54e.tmpl.c */ /* * @description * CWE: 114 Process Control * BadSource: listen_socket Read data using a listen socket (server side) * GoodSource: Hard code the full pathname to the library * Sink: * BadSink : Load a dynamic link library * Flow Variant: 54 Data flow: data passed as an argument from one function through three others to a fifth; all five functions are in different source files * * */ #include "std_testcase.h" #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 #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 LISTEN_BACKLOG 5 /* all the sinks are the same, we just want to know where the hit originated if a tool flags one */ #ifndef OMITBAD void CWE114_Process_Control__w32_char_listen_socket_54e_badSink(char * data) { { HMODULE hModule; /* POTENTIAL FLAW: If the path to the library is not specified, an attacker may be able to * replace his own file with the intended library */ hModule = LoadLibraryA(data); if (hModule != NULL) { FreeLibrary(hModule); printLine("Library loaded and freed successfully"); } else { printLine("Unable to load library"); } } } #endif /* OMITBAD */ #ifndef OMITGOOD /* goodG2B uses the GoodSource with the BadSink */ void CWE114_Process_Control__w32_char_listen_socket_54e_goodG2BSink(char * data) { { HMODULE hModule; /* POTENTIAL FLAW: If the path to the library is not specified, an attacker may be able to * replace his own file with the intended library */ hModule = LoadLibraryA(data); if (hModule != NULL) { FreeLibrary(hModule); printLine("Library loaded and freed successfully"); } else { printLine("Unable to load library"); } } } #endif /* OMITGOOD */
// Copyright 2020 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CHROME_BROWSER_SAFE_BROWSING_ANDROID_SAFE_BROWSING_SETTINGS_LAUNCHER_ANDROID_H_ #define CHROME_BROWSER_SAFE_BROWSING_ANDROID_SAFE_BROWSING_SETTINGS_LAUNCHER_ANDROID_H_ namespace content { class WebContents; } namespace safe_browsing { // Opens the Safe Browsing settings page on Android. void ShowSafeBrowsingSettings(content::WebContents* web_contents); } // namespace safe_browsing #endif // CHROME_BROWSER_SAFE_BROWSING_ANDROID_SAFE_BROWSING_SETTINGS_LAUNCHER_ANDROID_H_
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE675_Duplicate_Operations_on_Resource__w32CreateFile_10.c Label Definition File: CWE675_Duplicate_Operations_on_Resource__w32CreateFile.label.xml Template File: sources-sinks-10.tmpl.c */ /* * @description * CWE: 675 Duplicate Operations on Resource * BadSource: Open and close a file using CreateFile() and CloseHandle() * GoodSource: Open a file using CreateFile() * Sinks: * GoodSink: Do nothing * BadSink : Close the file * Flow Variant: 10 Control flow: if(globalTrue) and if(globalFalse) * * */ #include "std_testcase.h" #include <windows.h> #ifndef OMITBAD void CWE675_Duplicate_Operations_on_Resource__w32CreateFile_10_bad() { HANDLE data; data = INVALID_HANDLE_VALUE; /* Initialize data */ if(globalTrue) { data = CreateFile("BadSource_w32CreateFile.txt", (GENERIC_WRITE|GENERIC_READ), 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); /* POTENTIAL FLAW: Close the file in the source */ CloseHandle(data); } if(globalTrue) { /* POTENTIAL FLAW: Close the file in the sink (it may have been closed in the Source) */ CloseHandle(data); } } #endif /* OMITBAD */ #ifndef OMITGOOD /* goodB2G1() - use badsource and goodsink by changing the second globalTrue to globalFalse */ static void goodB2G1() { HANDLE data; data = INVALID_HANDLE_VALUE; /* Initialize data */ if(globalTrue) { data = CreateFile("BadSource_w32CreateFile.txt", (GENERIC_WRITE|GENERIC_READ), 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); /* POTENTIAL FLAW: Close the file in the source */ CloseHandle(data); } if(globalFalse) { /* INCIDENTAL: CWE 561 Dead Code, the code below will never run */ printLine("Benign, fixed string"); } else { /* Do nothing */ /* FIX: Don't close the file in the sink */ ; /* empty statement needed for some flow variants */ } } /* goodB2G2() - use badsource and goodsink by reversing the blocks in the second if */ static void goodB2G2() { HANDLE data; data = INVALID_HANDLE_VALUE; /* Initialize data */ if(globalTrue) { data = CreateFile("BadSource_w32CreateFile.txt", (GENERIC_WRITE|GENERIC_READ), 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); /* POTENTIAL FLAW: Close the file in the source */ CloseHandle(data); } if(globalTrue) { /* Do nothing */ /* FIX: Don't close the file in the sink */ ; /* empty statement needed for some flow variants */ } } /* goodG2B1() - use goodsource and badsink by changing the first globalTrue to globalFalse */ static void goodG2B1() { HANDLE data; data = INVALID_HANDLE_VALUE; /* Initialize data */ if(globalFalse) { /* INCIDENTAL: CWE 561 Dead Code, the code below will never run */ printLine("Benign, fixed string"); } else { /* FIX: Open, but do not close the file in the source */ data = CreateFile("GoodSource_w32CreateFile.txt", (GENERIC_WRITE|GENERIC_READ), 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); } if(globalTrue) { /* POTENTIAL FLAW: Close the file in the sink (it may have been closed in the Source) */ CloseHandle(data); } } /* goodG2B2() - use goodsource and badsink by reversing the blocks in the first if */ static void goodG2B2() { HANDLE data; data = INVALID_HANDLE_VALUE; /* Initialize data */ if(globalTrue) { /* FIX: Open, but do not close the file in the source */ data = CreateFile("GoodSource_w32CreateFile.txt", (GENERIC_WRITE|GENERIC_READ), 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); } if(globalTrue) { /* POTENTIAL FLAW: Close the file in the sink (it may have been closed in the Source) */ CloseHandle(data); } } void CWE675_Duplicate_Operations_on_Resource__w32CreateFile_10_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()..."); CWE675_Duplicate_Operations_on_Resource__w32CreateFile_10_good(); printLine("Finished good()"); #endif /* OMITGOOD */ #ifndef OMITBAD printLine("Calling bad()..."); CWE675_Duplicate_Operations_on_Resource__w32CreateFile_10_bad(); printLine("Finished bad()"); #endif /* OMITBAD */ return 0; } #endif
#ifndef COIN_SOSFNAME_H #define COIN_SOSFNAME_H /**************************************************************************\ * Copyright (c) Kongsberg Oil & Gas Technologies AS * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \**************************************************************************/ #include <Inventor/fields/SoSField.h> #include <Inventor/fields/SoSubField.h> #include <Inventor/SbName.h> class COIN_DLL_API SoSFName : public SoSField { typedef SoSField inherited; SO_SFIELD_HEADER(SoSFName, SbName, const SbName &); public: static void initClass(void); void setValue(const char * const name); }; #endif // !COIN_SOSFNAME_H
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE690_NULL_Deref_From_Return__wchar_t_calloc_32.c Label Definition File: CWE690_NULL_Deref_From_Return.free.label.xml Template File: source-sinks-32.tmpl.c */ /* * @description * CWE: 690 Unchecked Return Value To NULL Pointer * BadSource: calloc Allocate data using calloc() * Sinks: * GoodSink: Check to see if the data allocation failed and if not, use data * BadSink : Don't check for NULL and use data * Flow Variant: 32 Data flow: two pointers to the same value within the same function * * */ #include "std_testcase.h" #include <wchar.h> #ifndef OMITBAD void CWE690_NULL_Deref_From_Return__wchar_t_calloc_32_bad() { wchar_t * data; wchar_t * *dataPtr1 = &data; wchar_t * *dataPtr2 = &data; data = NULL; /* Initialize data */ { wchar_t * data = *dataPtr1; /* POTENTIAL FLAW: Allocate memory without checking if the memory allocation function failed */ data = (wchar_t *)calloc(20, sizeof(wchar_t)); *dataPtr1 = data; } { wchar_t * data = *dataPtr2; /* FLAW: Initialize memory buffer without checking to see if the memory allocation function failed */ wcscpy(data, L"Initialize"); printWLine(data); free(data); } } #endif /* OMITBAD */ #ifndef OMITGOOD /* goodB2G() uses the BadSource with the GoodSink */ static void goodB2G() { wchar_t * data; wchar_t * *dataPtr1 = &data; wchar_t * *dataPtr2 = &data; data = NULL; /* Initialize data */ { wchar_t * data = *dataPtr1; /* POTENTIAL FLAW: Allocate memory without checking if the memory allocation function failed */ data = (wchar_t *)calloc(20, sizeof(wchar_t)); *dataPtr1 = data; } { wchar_t * data = *dataPtr2; /* FIX: Check to see if the memory allocation function was successful before initializing the memory buffer */ if (data != NULL) { wcscpy(data, L"Initialize"); printWLine(data); free(data); } } } void CWE690_NULL_Deref_From_Return__wchar_t_calloc_32_good() { 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()..."); CWE690_NULL_Deref_From_Return__wchar_t_calloc_32_good(); printLine("Finished good()"); #endif /* OMITGOOD */ #ifndef OMITBAD printLine("Calling bad()..."); CWE690_NULL_Deref_From_Return__wchar_t_calloc_32_bad(); printLine("Finished bad()"); #endif /* OMITBAD */ return 0; } #endif