text stringlengths 4 6.14k |
|---|
/*
* gnome-keyring
*
* Copyright (C) 2009 Stefan Walter
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 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., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*/
#ifndef __GKD_SECRET_LOCK_H__
#define __GKD_SECRET_LOCK_H__
#include "gkd-secret-types.h"
#include <gck/gck.h>
#include <dbus/dbus.h>
gboolean gkd_secret_lock (GckObject *collection,
DBusError *derr);
#endif /* __GKD_SECRET_LOCK_H__ */
|
/* Copyright (C) 2018 Magnus Lång and Tuan Phong Ngo
* This benchmark is part of SWSC */
#include <assert.h>
#include <stdint.h>
#include <stdatomic.h>
#include <pthread.h>
atomic_int vars[2];
atomic_int atom_1_r1_1;
atomic_int atom_2_r1_1;
atomic_int atom_2_r3_0;
void *t0(void *arg){
label_1:;
atomic_store_explicit(&vars[0], 1, memory_order_seq_cst);
return NULL;
}
void *t1(void *arg){
label_2:;
int v2_r1 = atomic_load_explicit(&vars[0], memory_order_seq_cst);
atomic_store_explicit(&vars[1], 1, memory_order_seq_cst);
int v13 = (v2_r1 == 1);
atomic_store_explicit(&atom_1_r1_1, v13, memory_order_seq_cst);
return NULL;
}
void *t2(void *arg){
label_3:;
int v4_r1 = atomic_load_explicit(&vars[1], memory_order_seq_cst);
int v5_cmpeq = (v4_r1 == v4_r1);
if (v5_cmpeq) goto lbl_LC00; else goto lbl_LC00;
lbl_LC00:;
int v7_r3 = atomic_load_explicit(&vars[0], memory_order_seq_cst);
int v14 = (v4_r1 == 1);
atomic_store_explicit(&atom_2_r1_1, v14, memory_order_seq_cst);
int v15 = (v7_r3 == 0);
atomic_store_explicit(&atom_2_r3_0, v15, memory_order_seq_cst);
return NULL;
}
int main(int argc, char *argv[]){
pthread_t thr0;
pthread_t thr1;
pthread_t thr2;
atomic_init(&vars[0], 0);
atomic_init(&vars[1], 0);
atomic_init(&atom_1_r1_1, 0);
atomic_init(&atom_2_r1_1, 0);
atomic_init(&atom_2_r3_0, 0);
pthread_create(&thr0, NULL, t0, NULL);
pthread_create(&thr1, NULL, t1, NULL);
pthread_create(&thr2, NULL, t2, NULL);
pthread_join(thr0, NULL);
pthread_join(thr1, NULL);
pthread_join(thr2, NULL);
int v8 = atomic_load_explicit(&atom_1_r1_1, memory_order_seq_cst);
int v9 = atomic_load_explicit(&atom_2_r1_1, memory_order_seq_cst);
int v10 = atomic_load_explicit(&atom_2_r3_0, memory_order_seq_cst);
int v11_conj = v9 & v10;
int v12_conj = v8 & v11_conj;
if (v12_conj == 1) assert(0);
return 0;
}
|
/* types.h - define some extra types
* Copyright (C) 1999, 2000, 2001, 2006 Free Software Foundation, Inc.
*
* This file is part of GnuPG.
*
* GnuPG is free software; you can redistribute and/or modify this
* part of GnuPG under the terms of either
*
* - 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.
*
* or
*
* - 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.
*
* or both in parallel, as here.
*
* GnuPG 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 copies of the GNU General Public License
* and the GNU Lesser General Public License along with this program;
* if not, see <https://www.gnu.org/licenses/>.
*/
#ifndef GNUPG_COMMON_TYPES_H
#define GNUPG_COMMON_TYPES_H
#ifdef HAVE_INTTYPES_H
# include <inttypes.h>
#endif
/* The AC_CHECK_SIZEOF() in configure fails for some machines.
* we provide some fallback values here */
#if !SIZEOF_UNSIGNED_SHORT
# undef SIZEOF_UNSIGNED_SHORT
# define SIZEOF_UNSIGNED_SHORT 2
#endif
#if !SIZEOF_UNSIGNED_INT
# undef SIZEOF_UNSIGNED_INT
# define SIZEOF_UNSIGNED_INT 4
#endif
#if !SIZEOF_UNSIGNED_LONG
# undef SIZEOF_UNSIGNED_LONG
# define SIZEOF_UNSIGNED_LONG 4
#endif
#include <sys/types.h>
/* We use byte as an abbreviation for unsigned char. On some
platforms this needs special treatment:
- RISC OS:
Norcroft C treats char = unsigned char as legal assignment
but char* = unsigned char* as illegal assignment
and the same applies to the signed variants as well. Thus we use
char which is anyway unsigned.
- Windows:
Windows typedefs byte in the RPC headers but we need to avoid a
warning about a double definition.
*/
#ifndef HAVE_BYTE_TYPEDEF
# undef byte /* There might be a macro with this name. */
# ifdef __riscos__
typedef char byte;
# elif !(defined(_WIN32) && defined(cbNDRContext))
typedef unsigned char byte;
# endif
# define HAVE_BYTE_TYPEDEF
#endif /*!HAVE_BYTE_TYPEDEF*/
#ifndef HAVE_USHORT_TYPEDEF
# undef ushort /* There might be a macro with this name. */
typedef unsigned short ushort;
# define HAVE_USHORT_TYPEDEF
#endif
#ifndef HAVE_ULONG_TYPEDEF
# undef ulong /* There might be a macro with this name. */
typedef unsigned long ulong;
# define HAVE_ULONG_TYPEDEF
#endif
#ifndef HAVE_U16_TYPEDEF
# undef u16 /* There might be a macro with this name. */
# if SIZEOF_UNSIGNED_INT == 2
typedef unsigned int u16;
# elif SIZEOF_UNSIGNED_SHORT == 2
typedef unsigned short u16;
# else
# error no typedef for u16
# endif
# define HAVE_U16_TYPEDEF
#endif
#ifndef HAVE_U32_TYPEDEF
# undef u32 /* There might be a macro with this name. */
# if SIZEOF_UNSIGNED_INT == 4
typedef unsigned int u32;
# elif SIZEOF_UNSIGNED_LONG == 4
typedef unsigned long u32;
# else
# error no typedef for u32
# endif
# define HAVE_U32_TYPEDEF
#endif
#endif /*GNUPG_COMMON_TYPES_H*/
|
/*
* Copyright (C) 2015 Niek Linnenbank
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __LIBARCH_ARM_BROADCOMPOWER_H
#define __LIBARCH_ARM_BROADCOMPOWER_H
#include <Types.h>
#include <Macros.h>
#include <arm/broadcom/BroadcomMailbox.h>
/**
* @addtogroup lib
* @{
*
* @addtogroup libarch
* @{
*
* @addtogroup libarch_bcm
* @{
*/
/**
* Broadcom Power Management.
*/
class BroadcomPower
{
public:
/**
* Powered devices.
*/
enum Device
{
SD = (1 << 0),
UART0 = (1 << 1),
UART1 = (1 << 2),
USB = (1 << 3)
};
/**
* Result codes.
*/
enum Result
{
Success,
IOError
};
public:
/**
* Constructor.
*/
BroadcomPower();
/**
* Initialize the power manager.
*
* @return Result code.
*/
Result initialize();
/**
* Set power on.
*
* @param device Device to power on.
*
* @return Result code.
*/
Result enable(Device device);
private:
/** Mailbox for communicating with the GPU. */
BroadcomMailbox m_mailbox;
/** Current bitmask of enabled devices. */
u32 m_mask;
};
/**
* @}
* @}
* @}
*/
#endif /* __LIBARCH_ARM_BROADCOMPOWER_H */
|
/* Copyright © 2012 Brandon L Black <blblack@gmail.com>
*
* This file is part of gdnsd.
*
* gdnsd 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.
*
* gdnsd 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 gdnsd. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef GDNSD_ZSCAN_H
#define GDNSD_ZSCAN_H
#include "ltree.h"
#include <gdnsd/compiler.h>
// Actually scan the zonefile, creating the data. A true retval means failure.
F_NONNULL
bool zscan_rfc1035(zone_t* zone, const char* fn);
#endif // GDNSD_ZSCAN_H
|
#include <format.h>
/* Could have merged it with fmti{32,64}, but the problem is that
padding only makes sense on unsigned integers, and it's not likely
that we will ever pad 64-bit integers on 32-bit arches.
So, let's keep it a separate function with a arch-neutral long arg. */
char* fmtulp(char* buf, char* end, unsigned long num, int pad)
{
int len;
unsigned long n;
for(len = 1, n = num; n >= 10; len++)
n /= 10;
if(len < pad)
len = pad;
int i;
char* e = buf + len;
char* p = e - 1; /* len >= 1 so e > buf */
for(i = 0; i < len; i++, p--, num /= 10)
if(p < end)
*p = '0' + num % 10;
return e;
}
|
/*
* DO NOT EDIT. THIS FILE IS GENERATED FROM e:/builds/moz2_slave/rel-cen-xr-w32-bld/build/xpcom/threads/nsIEventTarget.idl
*/
#ifndef __gen_nsIEventTarget_h__
#define __gen_nsIEventTarget_h__
#ifndef __gen_nsISupports_h__
#include "nsISupports.h"
#endif
/* For IDL files that don't want to include root IDL files. */
#ifndef NS_NO_VTABLE
#define NS_NO_VTABLE
#endif
class nsIRunnable; /* forward declaration */
/* starting interface: nsIEventTarget */
#define NS_IEVENTTARGET_IID_STR "4e8febe4-6631-49dc-8ac9-308c1cb9b09c"
#define NS_IEVENTTARGET_IID \
{0x4e8febe4, 0x6631, 0x49dc, \
{ 0x8a, 0xc9, 0x30, 0x8c, 0x1c, 0xb9, 0xb0, 0x9c }}
class NS_NO_VTABLE NS_SCRIPTABLE nsIEventTarget : public nsISupports {
public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IEVENTTARGET_IID)
/**
* Dispatch an event to this event target. This function may be called from
* any thread, and it may be called re-entrantly.
*
* @param event
* The event to dispatch.
* @param flags
* The flags modifying event dispatch. The flags are described in detail
* below.
*
* @throws NS_ERROR_INVALID_ARG
* Indicates that event is null.
* @throws NS_ERROR_UNEXPECTED
* Indicates that the thread is shutting down and has finished processing
* events, so this event would never run and has not been dispatched.
*/
/* void dispatch (in nsIRunnable event, in unsigned long flags); */
NS_SCRIPTABLE NS_IMETHOD Dispatch(nsIRunnable *event, PRUint32 flags) = 0;
/**
* This flag specifies the default mode of event dispatch, whereby the event
* is simply queued for later processing. When this flag is specified,
* dispatch returns immediately after the event is queued.
*/
enum { DISPATCH_NORMAL = 0U };
/**
* This flag specifies the synchronous mode of event dispatch, in which the
* dispatch method does not return until the event has been processed.
*
* NOTE: passing this flag to dispatch may have the side-effect of causing
* other events on the current thread to be processed while waiting for the
* given event to be processed.
*/
enum { DISPATCH_SYNC = 1U };
/**
* Check to see if this event target is associated with the current thread.
*
* @returns
* A boolean value that if "true" indicates that events dispatched to this
* event target will run on the current thread (i.e., the thread calling
* this method).
*/
/* boolean isOnCurrentThread (); */
NS_SCRIPTABLE NS_IMETHOD IsOnCurrentThread(PRBool *_retval NS_OUTPARAM) = 0;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsIEventTarget, NS_IEVENTTARGET_IID)
/* Use this macro when declaring classes that implement this interface. */
#define NS_DECL_NSIEVENTTARGET \
NS_SCRIPTABLE NS_IMETHOD Dispatch(nsIRunnable *event, PRUint32 flags); \
NS_SCRIPTABLE NS_IMETHOD IsOnCurrentThread(PRBool *_retval NS_OUTPARAM);
/* Use this macro to declare functions that forward the behavior of this interface to another object. */
#define NS_FORWARD_NSIEVENTTARGET(_to) \
NS_SCRIPTABLE NS_IMETHOD Dispatch(nsIRunnable *event, PRUint32 flags) { return _to Dispatch(event, flags); } \
NS_SCRIPTABLE NS_IMETHOD IsOnCurrentThread(PRBool *_retval NS_OUTPARAM) { return _to IsOnCurrentThread(_retval); }
/* Use this macro to declare functions that forward the behavior of this interface to another object in a safe way. */
#define NS_FORWARD_SAFE_NSIEVENTTARGET(_to) \
NS_SCRIPTABLE NS_IMETHOD Dispatch(nsIRunnable *event, PRUint32 flags) { return !_to ? NS_ERROR_NULL_POINTER : _to->Dispatch(event, flags); } \
NS_SCRIPTABLE NS_IMETHOD IsOnCurrentThread(PRBool *_retval NS_OUTPARAM) { return !_to ? NS_ERROR_NULL_POINTER : _to->IsOnCurrentThread(_retval); }
#if 0
/* Use the code below as a template for the implementation class for this interface. */
/* Header file */
class nsEventTarget : public nsIEventTarget
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIEVENTTARGET
nsEventTarget();
private:
~nsEventTarget();
protected:
/* additional members */
};
/* Implementation file */
NS_IMPL_ISUPPORTS1(nsEventTarget, nsIEventTarget)
nsEventTarget::nsEventTarget()
{
/* member initializers and constructor code */
}
nsEventTarget::~nsEventTarget()
{
/* destructor code */
}
/* void dispatch (in nsIRunnable event, in unsigned long flags); */
NS_IMETHODIMP nsEventTarget::Dispatch(nsIRunnable *event, PRUint32 flags)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* boolean isOnCurrentThread (); */
NS_IMETHODIMP nsEventTarget::IsOnCurrentThread(PRBool *_retval NS_OUTPARAM)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* End of implementation class template. */
#endif
// convenient aliases:
#define NS_DISPATCH_NORMAL nsIEventTarget::DISPATCH_NORMAL
#define NS_DISPATCH_SYNC nsIEventTarget::DISPATCH_SYNC
#endif /* __gen_nsIEventTarget_h__ */
|
// g2o - General Graph Optimization
// Copyright (C) 2011 R. Kuemmerle, G. Grisetti, W. Burgard
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
// PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
// TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef G2O_BASE_VERTEX_H
#define G2O_BASE_VERTEX_H
#include "optimizable_graph.h"
#include "creators.h"
#include "../stuff/macros.h"
#include <Eigen/Core>
#include <Eigen/Dense>
#include <Eigen/Cholesky>
#include <Eigen/StdVector>
#include <stack>
namespace g2o {
using namespace Eigen;
/**
* \brief Templatized BaseVertex
*
* Templatized BaseVertex
* D : minimal dimension of the vertex, e.g., 3 for rotation in 3D
* T : internal type to represent the estimate, e.g., Quaternion for rotation in 3D
*/
template <int D, typename T>
class BaseVertex : public OptimizableGraph::Vertex {
public:
typedef T EstimateType;
typedef std::stack<EstimateType,
std::vector<EstimateType, Eigen::aligned_allocator<EstimateType> > >
BackupStackType;
static const int Dimension = D; ///< dimension of the estimate (minimal) in the manifold space
typedef Eigen::Map<Matrix<double, D, D>, Matrix<double,D,D>::Flags & AlignedBit ? Aligned : Unaligned > HessianBlockType;
public:
BaseVertex();
virtual const double& hessian(int i, int j) const { assert(i<D && j<D); return _hessian(i,j);}
virtual double& hessian(int i, int j) { assert(i<D && j<D); return _hessian(i,j);}
virtual double hessianDeterminant() const {return _hessian.determinant();}
virtual double* hessianData() { return const_cast<double*>(_hessian.data());}
virtual void mapHessianMemory(double* d);
virtual int copyB(double* b_) const {
memcpy(b_, _b.data(), Dimension * sizeof(double));
return Dimension;
}
virtual const double& b(int i) const { assert(i < D); return _b(i);}
virtual double& b(int i) { assert(i < D); return _b(i);}
virtual double* bData() { return _b.data();}
virtual void clearQuadraticForm();
//! updates the current vertex with the direct solution x += H_ii\b_ii
//! @returns the determinant of the inverted hessian
virtual double solveDirect(double lambda=0);
//! return right hand side b of the constructed linear system
Matrix<double, D, 1>& b() { return _b;}
const Matrix<double, D, 1>& b() const { return _b;}
//! return the hessian block associated with the vertex
HessianBlockType& A() { return _hessian;}
const HessianBlockType& A() const { return _hessian;}
virtual void push() { _backup.push(_estimate);}
virtual void pop() { assert(!_backup.empty()); _estimate = _backup.top(); _backup.pop(); updateCache();}
virtual void discardTop() { assert(!_backup.empty()); _backup.pop();}
virtual int stackSize() const {return _backup.size();}
//! return the current estimate of the vertex
const EstimateType& estimate() const { return _estimate;}
//! set the estimate for the vertex also calls updateCache()
void setEstimate(const EstimateType& et) { _estimate = et; updateCache();}
protected:
HessianBlockType _hessian;
Matrix<double, D, 1> _b;
EstimateType _estimate;
BackupStackType _backup;
public:
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
};
#include "base_vertex.hpp"
} // end namespace g2o
#endif
|
/* Foldery - Controller.h
_______ ___ ___
/ ___/__ / /___/ /___ _______ ___
/ __/ _ \/ // _ / -_) __/ / /
/___/ \____/\__/\____/\___/__/ \__ /
Copyright © 2014-2015 Betty Lab. /___/
Released under the terms of the GNU General Public License v3. */
#import <Cocoa/Cocoa.h>
#import "DropView.h"
#import "NSImage+BL.h"
@interface Controller : NSWindowController <NSApplicationDelegate, NSCollectionViewDelegate, DropViewDelegate> {
IBOutlet NSImageView* previewImageView;
IBOutlet NSTextField* messageTextField;
IBOutlet NSCollectionView* colorsCollectionView;
IBOutlet NSArrayController* colorsController;
IBOutlet NSColorWell* colorWell;
IBOutlet NSSegmentedControl* colorActionSegmentedControl;
IBOutlet NSButton* restoreButton;
IBOutlet NSMenuItem* saveMenuItem;
NSMutableArray* _colors;
NSImage* _folderImage;
NSImage* _previewImage;
NSImage* _tintedImage;
NSImage* _baseImage;
NSColor* _color;
NSData* _ICNS;
NSUInteger _draggedColorIndex;
BOOL _isInClearMode;
BOOL _colorsAreModified;
}
@property (nonatomic, readonly) NSArray* colors;
- (IBAction) changeToRestoreMode: (id) sender;
- (IBAction) addOrRemoveColorItem: (id) sender;
- (IBAction) restoreDefaultColors: (id) sender;
@end
// EOF
|
/*
Copyright (C) 2006-2007 M.A.L. Marques
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <stdio.h>
#include <assert.h>
#include "util.h"
#define XC_GGA_X_B86_MGC 105 /* Becke 86 Xalfa,beta,gamma (with mod. grad. correction) */
static inline void
func(const XC(gga_type) *p, FLOAT x, FLOAT *f, FLOAT *dfdx, FLOAT *ldfdx, FLOAT *d2fdx2)
{
static const FLOAT beta = 0.00375;
static const FLOAT gamma = 0.007;
FLOAT dd, ddp, f1, f2, df1, df2, d2f1, d2f2;
dd = 1.0 + gamma*x*x;
f1 = beta/X_FACTOR_C*x*x;
f2 = POW(dd, 4.0/5.0);
*f = 1.0 + f1/f2;
if(dfdx==NULL && d2fdx2==NULL) return; /* nothing else to do */
df1 = beta/X_FACTOR_C*2.0*x;
ddp = gamma*2.0*4.0/5.0*f2/dd;
df2 = ddp*x;
if(dfdx!=NULL){
*dfdx = (df1*f2 - f1*df2)/(f2*f2);
*ldfdx= beta/X_FACTOR_C;
}
if(d2fdx2==NULL) return; /* nothing else to do */
d2f1 = beta/X_FACTOR_C*2.0;
d2f2 = ddp*(1.0 - 2.0/5.0*gamma*x*x/dd);
*d2fdx2 = (2.0*f1*df2*df2 + d2f1*f2*f2 - f2*(2.0*df1*df2 + f1*d2f2))/(f2*f2*f2);
}
#include "work_gga_x.c"
const XC(func_info_type) XC(func_info_gga_x_b86_mgc) = {
XC_GGA_X_B86_MGC,
XC_EXCHANGE,
"Becke 86 with modified gradient correction",
XC_FAMILY_GGA,
"AD Becke, J. Chem. Phys 84, 4524 (1986)\n"
"AD Becke, J. Chem. Phys 85, 7184 (1986)",
XC_PROVIDES_EXC | XC_PROVIDES_VXC | XC_PROVIDES_FXC,
NULL, NULL, NULL,
work_gga_x
};
|
/*****************************************************************************
*
* PROJECT: Multi Theft Auto v1.0
* LICENSE: See LICENSE in the top level directory
* FILE: game_sa/CClockSA.h
* PURPOSE: Header file for game clock class
*
* Multi Theft Auto is available from http://www.multitheftauto.com/
*
*****************************************************************************/
#ifndef __CGAMESA_CLOCK
#define __CGAMESA_CLOCK
#include <game/CClock.h>
#include "Common.h"
#define VAR_TimeMinutes 0xB70152
#define VAR_TimeHours 0xB70153
#define VAR_TimeOfLastMinuteChange 0xB70158
class CClockSA : public CClock
{
public:
VOID Set(BYTE bHour, BYTE bMinute);
VOID Get(BYTE* bHour, BYTE* bMinute);
};
#endif
|
/*
THCustomComponent.h
Interactex Designer
Created by Juan Haladjian on 23/06/15.
Interactex Designer is a configuration tool to easily setup, simulate and connect e-Textile hardware with smartphone functionality. Interactex Client is an app to store and replay projects made with Interactex Designer.
www.interactex.org
Copyright (C) 2013 TU Munich, Munich, Germany; DRLab, University of the Arts Berlin, Berlin, Germany; Telekom Innovation Laboratories, Berlin, Germany
Contacts:
juan.haladjian@cs.tum.edu
katharina.bredies@udk-berlin.de
opensource@telekom.de
The first version of the software was designed and implemented as part of "Wearable M2M", a joint project of UdK Berlin and TU Munich, which was founded by Telekom Innovation Laboratories Berlin. It has been extended with funding from EIT ICT, as part of the activity "Connected Textiles".
Interactex is built using the Tango framework developed by TU Munich.
In the Interactex software, we use the GHUnit (a test framework for iOS developed by Gabriel Handford) and cocos2D libraries (a framework for building 2D games and graphical applications developed by Zynga Inc.).
www.cocos2d-iphone.org
github.com/gabriel/gh-unit
Interactex also implements the Firmata protocol. Its software serial library is based on the original Arduino Firmata library.
www.firmata.org
All hardware part graphics in Interactex Designer are reproduced with kind permission from Fritzing. Fritzing is an open-source hardware initiative to support designers, artists, researchers and hobbyists to work creatively with interactive electronics.
www.frizting.org
Martijn ten Bhömer from TU Eindhoven contributed PureData support. Contact: m.t.bhomer@tue.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 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/>.
*/
#import <UIKit/UIKit.h>
#import "THProgrammingElement.h"
@interface THCustomComponent : THProgrammingElement
{
}
@property (nonatomic) NSString * name;
@property (nonatomic) NSString * code;
@property (nonatomic, readonly) id result;
-(void) execute:(id) param;
@end
|
/***************************************************************************
* *
* LIBDSK: General floppy and diskimage access library *
* Copyright (C) 2001,2005 John Elliott <jce@seasip.demon.co.uk> *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; if not, write to the Free *
* Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, *
* MA 02111-1307, USA *
* *
***************************************************************************/
#ifdef HAVE_FORK
typedef struct fork_remote_data
{
REMOTE_DATA super;
int infd;
int outfd;
pid_t pidchild;
char *filename;
} FORK_REMOTE_DATA;
extern REMOTE_CLASS rpc_fork;
dsk_err_t fork_open(DSK_PDRIVER pDriver, const char *name, char *nameout);
dsk_err_t fork_close(DSK_PDRIVER pDriver);
dsk_err_t fork_call(DSK_PDRIVER pDriver, unsigned char *input,
int inp_len, unsigned char *output, int *out_len);
#endif /* def HAVE_FORK */
|
/*
CfgLoader.h
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
*
* This file is part of: freeture
*
* Copyright: (C) 2014-2015 Yoan Audureau
* FRIPON-GEOPS-UPSUD-CNRS
*
* License: GNU General Public License
*
* FreeTure 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.
* FreeTure 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 FreeTure. If not, see <http://www.gnu.org/licenses/>.
*
* Last modified: 20/10/2014
*
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
/**
* \file CfgLoader.h
* \author Yoan Audureau -- FRIPON-GEOPS-UPSUD
* \version 1.0
* \date 03/06/2014
* \brief Load parameters from a configuration file.
*/
#pragma once
#include <fstream>
#include <string>
#include <iostream>
#include <map>
#include <stdlib.h>
using namespace std;
class CfgLoader{
private :
map<string,string> mData; // Container.
public :
/**
* Constructor.
*
*/
CfgLoader(void);
/**
* Clear all values
*
*/
void Clear();
/**
* Load parameters name and value from configuration file.
*
* @param file Path of the configuration file.
* @return Success status to load parameters.
*/
bool Load(const string& file);
/**
* Check if value associated with given key exists.
*
* @param key Freeture's parameter.
* @return Key has a value or not.
*/
bool Contains(const string& key) const;
/**
* Get string value associated with given key
*
* @param key Freeture's parameter.
* @param value Key's value.
* @return Success to get value associated with given key.
*/
bool Get(const string& key, string& value) const;
/**
* Get int value associated with given key
*
* @param key Freeture's parameter.
* @param value Key's value.
* @return Success to get value associated with given key.
*/
bool Get(const string& key, int& value) const;
/**
* Get long value associated with given key
*
* @param key Freeture's parameter.
* @param value Key's value.
* @return Success to get value associated with given key.
*/
bool Get(const string& key, long& value) const;
/**
* Get double value associated with given key
*
* @param key Freeture's parameter.
* @param value Key's value.
* @return Success to get value associated with given key.
*/
bool Get(const string& key, double& value) const;
/**
* Get bool value associated with given key
*
* @param key Freeture's parameter.
* @param value Key's value.
* @return Success to get value associated with given key.
*/
bool Get(const string& key, bool& value) const;
private :
/**
* Remove spaces in configuration file's lines.
*
* @param str Configuration file's line.
* @return String without space.
*/
static string Trim(const string& str);
};
|
/* @license
* This file is part of the Game Closure SDK.
*
* The Game Closure SDK is free software: you can redistribute it and/or modify
* it under the terms of the Mozilla Public License v. 2.0 as published by Mozilla.
* The Game Closure SDK 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
* Mozilla Public License v. 2.0 for more details.
* You should have received a copy of the Mozilla Public License v. 2.0
* along with the Game Closure SDK. If not, see <http://mozilla.org/MPL/2.0/>.
*/
#ifndef LOCAL_STORAGE_H
#define LOCAL_STORAGE_H
#ifdef __cplusplus
extern "C" {
#endif
void local_storage_set_data(const char *key, const char *data);
const char *local_storage_get_data(const char *key);
void local_storage_remove_data(const char *key);
void local_storage_clear();
#ifdef __cplusplus
}
#endif
#endif
|
//////////////////////////////////////////////////////////////////////////////////
//
//
// d88b 888b d888 888888888888
// d8888b 8888b d8888 888
// d88''88b 888'8b d8'888 888
// d88' '88b 888 '8b d8' 888 8888888
// d88Y8888Y88b 888 '8b d8' 888 888
// d88""""""""88b 888 '8b d8' 888 888
// d88' '88b 888 '888' 888 888
// d88' '88b 888 '8' 888 888888888888
//
//
// AwesomeMapEditor: A map editor for GBA Pokémon games.
// Copyright (C) 2016 Diegoisawesome, Pokedude
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 3
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
//////////////////////////////////////////////////////////////////////////////////
#ifndef __AME_MOVEMENTPERMISSIONLISTENER_H__
#define __AME_MOVEMENTPERMISSIONLISTENER_H__
///////////////////////////////////////////////////////////
// Include files
//
///////////////////////////////////////////////////////////
#include <QtWidgets>
#include <QBoy/Config.hpp>
namespace ame
{
///////////////////////////////////////////////////////////
/// \file MovePermissionListener.hpp
/// \author Pokedude
/// \version 1.0.0.0
/// \date 8/25/2016
/// \brief Listens to all events sent to "label".
///
///////////////////////////////////////////////////////////
class MovePermissionListener : public QObject {
Q_OBJECT
public:
///////////////////////////////////////////////////////////
/// \brief Default constructor
///
/// Initializes MovePermissionListener with a given parent.
///
///////////////////////////////////////////////////////////
MovePermissionListener(QWidget *parent = NULL);
///////////////////////////////////////////////////////////
/// \brief Destructor
///
/// Destroys the MovePermissionListener.
///
///////////////////////////////////////////////////////////
~MovePermissionListener();
///////////////////////////////////////////////////////////
/// \brief Destructor
///
/// Destroys the MovePermissionListener.
///
///////////////////////////////////////////////////////////
UInt16 getSelectedIndex();
protected:
///////////////////////////////////////////////////////////
/// \brief Handles all events.
///
///////////////////////////////////////////////////////////
bool eventFilter(QObject *watched, QEvent *event);
private:
///////////////////////////////////////////////////////////
// Class members
//
///////////////////////////////////////////////////////////
UInt8 m_SelectedIndex;
UInt8 m_HighlightedBlock;
Boolean m_ShowCursor;
Boolean m_Selecting;
};
}
#endif //__AME_MOVEMENTPERMISSIONLISTENER_H__
|
/*
SPDX-FileCopyrightText: 2016 Volker Krause <vkrause@kde.org>
SPDX-License-Identifier: MIT
*/
#ifndef KSYNTAXHIGHLIGHTING_HTMLHIGHLIGHTER_H
#define KSYNTAXHIGHLIGHTING_HTMLHIGHLIGHTER_H
#include "abstracthighlighter.h"
#include "ksyntaxhighlighting_export.h"
#include <QIODevice>
#include <QString>
#include <memory>
namespace KSyntaxHighlighting
{
class HtmlHighlighterPrivate;
class KSYNTAXHIGHLIGHTING_EXPORT HtmlHighlighter : public AbstractHighlighter
{
public:
HtmlHighlighter();
~HtmlHighlighter() override;
void highlightFile(const QString &fileName, const QString &title = QString());
void highlightData(QIODevice *device, const QString &title = QString());
void setOutputFile(const QString &fileName);
void setOutputFile(FILE *fileHandle);
protected:
void applyFormat(int offset, int length, const Format &format) override;
private:
std::unique_ptr<HtmlHighlighterPrivate> d;
};
}
#endif // KSYNTAXHIGHLIGHTING_HTMLHIGHLIGHTER_H
|
//==============================================================================
// This file is part of Master Password.
// Copyright (c) 2011-2017, Maarten Billemont.
//
// Master Password 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.
//
// Master Password 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 can find a copy of the GNU General Public License in the
// LICENSE file. Alternatively, see <http://www.gnu.org/licenses/>.
//==============================================================================
#import <Cocoa/Cocoa.h>
@interface MPSitesWindow : NSWindow
@end
|
/*
This file is part of Darling.
Copyright (C) 2017 Lubos Dolezel
Darling 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.
Darling 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 Darling. If not, see <http://www.gnu.org/licenses/>.
*/
#include <Foundation/Foundation.h>
@interface CNContactChangesObserverProxy : NSObject
@end
|
#ifndef LIBDARXENRADARSITES_H_
#define LIBDARXENRADARSITES_H_
#include "libdarxenCommon.h"
#include <glib/gslist.h>
typedef struct _DarxenRadarSiteInfo DarxenRadarSiteInfo;
struct _DarxenRadarSiteInfo
{
/* Sites.xml */
char chrID[5];
float fltLatitude;
float fltLongitude;
char chrState[3];
char chrCity[20];
};
G_EXPORT void darxen_radar_sites_init();
G_EXPORT DarxenRadarSiteInfo* darxen_radar_sites_get_site_info(const char* id);
G_EXPORT GSList* darxen_radar_sites_get_site_list(); /* DarxenRadarSiteInfo */
G_EXPORT GSList* darxen_radar_sites_get_site_name_list(); /* char */
#endif /*LIBDARXENRADARSITES_H_*/
|
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#pragma once
#include "targetver.h"
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
// Windows Header Files:
#include <windows.h>
#include <ShellAPI.h>
#include <atlbase.h>
#include <atlwin.h>
#include <atlimage.h>
#include <wtl/atlapp.h>
#include <wtl/atlctrls.h>
#include <wtl/atlctrlx.h>
#include <wtl/atlmisc.h>
#include <wtl/atldlgs.h>
#include <logging.h>
|
/*
* global.h
*
* Created: 18/12/2014 21:47:07
* Author: Paul Qureshi
*/
#ifndef GLOBAL_H_
#define GLOBAL_H_
#include <stdbool.h>
//#define HARDWARE_V1
#define NOP() __asm__ __volatile__("nop")
#define WDR() __asm__ __volatile__("wdr")
#define LE_CHR(a,b,c,d) ( ((uint32_t)(a)<<24) | ((uint32_t)(b)<<16) | ((c)<<8) | (d) )
// compile time static assertions (http://www.pixelbeat.org/programming/gcc/static_assert.html)
// generate a compile time divide by zero if evaluated to false
#define ASSERT_CONCAT_(a, b) a##b
#define ASSERT_CONCAT(a, b) ASSERT_CONCAT_(a, b)
#define ct_assert(e) enum { ASSERT_CONCAT(assert_line_, __LINE__) = 1/(!!(e)) }
#endif /* GLOBAL_H_ */ |
/*
* This file is part of EasyRPG Editor.
*
* EasyRPG Editor 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.
*
* EasyRPG Editor 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 EasyRPG Editor. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <QWidget>
#include <lcf/rpg/animation.h>
class ProjectData;
namespace Ui {
class BattleAnimationWidget;
}
class BattleAnimationWidget : public QWidget
{
Q_OBJECT
public:
using value_type = lcf::rpg::Animation;
explicit BattleAnimationWidget(ProjectData& project, QWidget *parent = nullptr);
~BattleAnimationWidget();
void setData(lcf::rpg::Animation* anim);
private:
Ui::BattleAnimationWidget *ui;
ProjectData& m_project;
};
|
/*
* DO NOT EDIT. THIS FILE IS GENERATED FROM e:/builds/moz2_slave/rel-m-beta-xr_w32_bld-00000000/build/parser/xml/public/nsISAXXMLFilter.idl
*/
#ifndef __gen_nsISAXXMLFilter_h__
#define __gen_nsISAXXMLFilter_h__
#ifndef __gen_nsISupports_h__
#include "nsISupports.h"
#endif
#ifndef __gen_nsISAXXMLReader_h__
#include "nsISAXXMLReader.h"
#endif
/* For IDL files that don't want to include root IDL files. */
#ifndef NS_NO_VTABLE
#define NS_NO_VTABLE
#endif
/* starting interface: nsISAXXMLFilter */
#define NS_ISAXXMLFILTER_IID_STR "77a22cf0-6cdf-11da-be43-001422106990"
#define NS_ISAXXMLFILTER_IID \
{0x77a22cf0, 0x6cdf, 0x11da, \
{ 0xbe, 0x43, 0x00, 0x14, 0x22, 0x10, 0x69, 0x90 }}
class NS_NO_VTABLE nsISAXXMLFilter : public nsISAXXMLReader {
public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ISAXXMLFILTER_IID)
/* attribute nsISAXXMLReader parent; */
NS_IMETHOD GetParent(nsISAXXMLReader * *aParent) = 0;
NS_IMETHOD SetParent(nsISAXXMLReader *aParent) = 0;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsISAXXMLFilter, NS_ISAXXMLFILTER_IID)
/* Use this macro when declaring classes that implement this interface. */
#define NS_DECL_NSISAXXMLFILTER \
NS_IMETHOD GetParent(nsISAXXMLReader * *aParent); \
NS_IMETHOD SetParent(nsISAXXMLReader *aParent);
/* Use this macro to declare functions that forward the behavior of this interface to another object. */
#define NS_FORWARD_NSISAXXMLFILTER(_to) \
NS_IMETHOD GetParent(nsISAXXMLReader * *aParent) { return _to GetParent(aParent); } \
NS_IMETHOD SetParent(nsISAXXMLReader *aParent) { return _to SetParent(aParent); }
/* Use this macro to declare functions that forward the behavior of this interface to another object in a safe way. */
#define NS_FORWARD_SAFE_NSISAXXMLFILTER(_to) \
NS_IMETHOD GetParent(nsISAXXMLReader * *aParent) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetParent(aParent); } \
NS_IMETHOD SetParent(nsISAXXMLReader *aParent) { return !_to ? NS_ERROR_NULL_POINTER : _to->SetParent(aParent); }
#if 0
/* Use the code below as a template for the implementation class for this interface. */
/* Header file */
class nsSAXXMLFilter : public nsISAXXMLFilter
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSISAXXMLFILTER
nsSAXXMLFilter();
private:
~nsSAXXMLFilter();
protected:
/* additional members */
};
/* Implementation file */
NS_IMPL_ISUPPORTS1(nsSAXXMLFilter, nsISAXXMLFilter)
nsSAXXMLFilter::nsSAXXMLFilter()
{
/* member initializers and constructor code */
}
nsSAXXMLFilter::~nsSAXXMLFilter()
{
/* destructor code */
}
/* attribute nsISAXXMLReader parent; */
NS_IMETHODIMP nsSAXXMLFilter::GetParent(nsISAXXMLReader * *aParent)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsSAXXMLFilter::SetParent(nsISAXXMLReader *aParent)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* End of implementation class template. */
#endif
#endif /* __gen_nsISAXXMLFilter_h__ */
|
/****************************************************************************
**
** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://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 https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** 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-3.0.html.
**
****************************************************************************/
#pragma once
#include <QObject>
namespace CppEditor::Internal {
class CompletionTest : public QObject
{
Q_OBJECT
private slots:
void testCompletionBasic1();
void testCompletionTemplateFunction_data();
void testCompletionTemplateFunction();
void testCompletion_data();
void testCompletion();
void testGlobalCompletion_data();
void testGlobalCompletion();
void testDoxygenTagCompletion_data();
void testDoxygenTagCompletion();
void testCompletionMemberAccessOperator_data();
void testCompletionMemberAccessOperator();
void testCompletionPrefixFirstQTCREATORBUG_8737();
void testCompletionPrefixFirstQTCREATORBUG_9236();
};
} // namespace CppEditor::Internal
|
/*
File: file_blobdpapi.c
Copyright (C) 2010, 2011 Ivan Fontarensky <ivan.fontarensky@cassidian.com>
This software 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 the Free Software Foundation, Inc., 51
Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#ifdef HAVE_STRING_H
#include <string.h>
#endif
#include <stdio.h>
#include "types.h"
#include "common.h"
#include "filegen.h"
static void register_header_check_blob_dpapi(file_stat_t *file_stat);
static int header_check_blob_dpapi(const unsigned char *buffer, const unsigned int buffer_size, const unsigned int safe_header_only, const file_recovery_t *file_recovery, file_recovery_t *file_recovery_new);
static int check_guid_utf16(char* guid,int length);
const file_hint_t file_hint_blob_dpapi= {
.extension="blobdpapi",
.description="Windows Blob DPAPI",
.min_header_distance=0,
.max_filesize=1024,
.recover=1,
.enable_by_default=1,
.register_header_check=®ister_header_check_blob_dpapi
};
static const unsigned char blob_dpapi_header[20] = {0x01,0x00,0x00,0x00,0xd0,0x8c,0x9d,0xdf,0X01,0x15,0xd1,0x11,0x8c,0x7a,0x00,0xc0,0x4f,0xc2,0x97,0xeb};
typedef struct {
unsigned int Data1;
unsigned short Data2;
unsigned short Data3;
unsigned char Data4[8];
} DGUID; //<16 bytes>
typedef struct {
unsigned int dwRevision;
DGUID gProvider;
unsigned int cbMkeys;
DGUID *gMkeys;
unsigned int dwFlags;
unsigned int cbDescr;
unsigned char *wszDescr;
unsigned int idCipher;
unsigned int dwKey;
unsigned int cbData;
DGUID *pbData;
unsigned int cbStrong;
DGUID *pbStrong;
unsigned int idHash;
unsigned int cbHash;
unsigned int cbSalt;
DGUID *pbSalt;
unsigned int cbCiphertext;
DGUID *pbCiphertext;
unsigned int cbHmac;
DGUID *pbHmac;
} DPAPIBlob; //<size=sizeOfBlob>;
static void register_header_check_blob_dpapi(file_stat_t *file_stat)
{
register_header_check(0, blob_dpapi_header,sizeof(blob_dpapi_header), &header_check_blob_dpapi, file_stat);
}
static int header_check_blob_dpapi(const unsigned char *buffer, const unsigned int buffer_size, const unsigned int safe_header_only, const file_recovery_t *file_recovery, file_recovery_t *file_recovery_new)
{
DPAPIBlob db;
int size = 0;
if(memcmp(buffer,blob_dpapi_header,sizeof(blob_dpapi_header))==0)
{
memcpy(&db.dwRevision,buffer+size,sizeof(unsigned int));
size += sizeof(unsigned int);
memcpy(&db.gProvider,buffer+size,sizeof(DGUID));
size += sizeof(DGUID);
memcpy(&db.cbMkeys,buffer+size,sizeof(unsigned int));
size += sizeof(unsigned int);
//memcpy(db.gMkeys,buffer+size,sizeof(DGUID)*db.cbMkeys);
size += sizeof(DGUID)*db.cbMkeys;
memcpy(&db.dwFlags,buffer+size,sizeof(unsigned int));
size += sizeof(unsigned int);
memcpy(&db.cbDescr,buffer+size,sizeof(unsigned int));
size += sizeof(unsigned int);
memcpy(&db.wszDescr,buffer+size,sizeof(unsigned char)* (db.cbDescr >> 1) * 2);
size += sizeof(unsigned char)* (db.cbDescr >> 1) * 2;
// Verification que nous avons bien de l'UTF-16
if (!check_guid_utf16(&db.wszDescr,sizeof(unsigned char)* (db.cbDescr >> 1) * 2))
{
return 0;
}
memcpy(&db.idCipher,buffer+size,sizeof(unsigned int));
size += sizeof(unsigned int);
//memcpy(db.dwKey,buffer+size,sizeof(unsigned int));
size += sizeof(unsigned int);
memcpy(&db.cbData,buffer+size,sizeof(unsigned int));
size += sizeof(unsigned int);
// memcpy(&db.pbData,buffer+size,sizeof(DGUID)*db.cbData);
size += sizeof(DGUID)*db.cbData;
memcpy(&db.cbStrong,buffer+size,sizeof(unsigned int));
size += sizeof(unsigned int);
// memcpy(&db.pbStrong,buffer+size,sizeof(DGUID)*db.cbStrong);
size += sizeof(DGUID)*db.cbData;
memcpy(&db.idHash,buffer+size,sizeof(unsigned int));
size += sizeof(unsigned int);
memcpy(&db.cbHash,buffer+size,sizeof(unsigned int));
size += sizeof(unsigned int);
memcpy(&db.cbSalt,buffer+size,sizeof(unsigned int));
size += sizeof(unsigned int);
// memcpy(&db.pbSalt,buffer+size,sizeof(DGUID)*db.cbSalt);
size += sizeof(DGUID)*db.cbSalt;
memcpy(&db.cbCiphertext,buffer+size,sizeof(unsigned int));
size += sizeof(unsigned int);
// memcpy(&db.pbCiphertext,buffer+size,sizeof(DGUID)*db.cbCiphertext);
size += sizeof(DGUID)*db.cbCiphertext;
memcpy(&db.cbHmac,buffer+size,sizeof(unsigned int));
size += sizeof(unsigned int);
// memcpy(&db.pbHmac,buffer+size,sizeof(DGUID)*db.cbHmac);
size += sizeof(DGUID)*db.cbHmac;
reset_file_recovery(file_recovery_new);
file_recovery_new->min_filesize=16;
file_recovery_new->calculated_file_size=size;
file_recovery_new->extension=file_hint_blob_dpapi.extension;
return 1;
}
return 0;
}
//
// Code rapide, verifie seulement si c'est une chaine en
// utf-16
//
static int check_guid_utf16(char* candidate,int size)
{
int i=0;
for (i=0;i<size-2;i=i+2)
// fprintf(pFile,"%c ",candidate[i]);
if (!((candidate[i]!=0x00) && (candidate[i+1]==0x00)))
return 0;
// fprintf(pFile,"\n");
return 1;
}
|
/* vim: set expandtab ts=4 sw=4: */
/*
* You may redistribute this program and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TAPInterface_H
#define TAPInterface_H
#include "exception/Except.h"
#include "memory/Allocator.h"
#include "util/events/EventBase.h"
#include "interface/Interface.h"
struct Interface* TAPInterface_new(const char* preferredName,
char** assignedName,
struct Except* eh,
struct Log* logger,
struct EventBase* base,
struct Allocator* alloc);
#endif
|
/*
* SPDX-FileCopyrightText: (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
* SPDX-License-Identifier: BSD-1-Clause
* Generated by asn1c-0.9.22 (http://lionet.info/asn1c)
* From ASN.1 module "RRLP-Components"
* found in "../rrlp-components.asn"
*/
#include "SeqOfOTD-FirstSetMsrs.h"
static asn_per_constraints_t ASN_PER_TYPE_SEQ_OF_OTD_FIRST_SET_MSRS_CONSTR_1 = {
{APC_UNCONSTRAINED, -1, -1, 0, 0},
{APC_CONSTRAINED, 4, 4, 1, 10} /* (SIZE(1..10)) */,
0,
0 /* No PER value map */
};
static asn_TYPE_member_t asn_MBR_SeqOfOTD_FirstSetMsrs_1[] = {
{ATF_POINTER, 0, 0, (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0,
&asn_DEF_OTD_FirstSetMsrs,
0, /* Defer constraints checking to the member type */
0, /* No PER visible constraints */
0, ""},
};
static ber_tlv_tag_t asn_DEF_SeqOfOTD_FirstSetMsrs_tags_1[] = {
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))};
static asn_SET_OF_specifics_t asn_SPC_SeqOfOTD_FirstSetMsrs_specs_1 = {
sizeof(struct SeqOfOTD_FirstSetMsrs),
offsetof(struct SeqOfOTD_FirstSetMsrs, _asn_ctx),
0, /* XER encoding is XMLDelimitedItemList */
};
asn_TYPE_descriptor_t asn_DEF_SeqOfOTD_FirstSetMsrs = {
"SeqOfOTD-FirstSetMsrs",
"SeqOfOTD-FirstSetMsrs",
SEQUENCE_OF_free,
SEQUENCE_OF_print,
SEQUENCE_OF_constraint,
SEQUENCE_OF_decode_ber,
SEQUENCE_OF_encode_der,
SEQUENCE_OF_decode_xer,
SEQUENCE_OF_encode_xer,
SEQUENCE_OF_decode_uper,
SEQUENCE_OF_encode_uper,
0, /* Use generic outmost tag fetcher */
asn_DEF_SeqOfOTD_FirstSetMsrs_tags_1,
sizeof(asn_DEF_SeqOfOTD_FirstSetMsrs_tags_1) /
sizeof(asn_DEF_SeqOfOTD_FirstSetMsrs_tags_1[0]), /* 1 */
asn_DEF_SeqOfOTD_FirstSetMsrs_tags_1, /* Same as above */
sizeof(asn_DEF_SeqOfOTD_FirstSetMsrs_tags_1) /
sizeof(asn_DEF_SeqOfOTD_FirstSetMsrs_tags_1[0]), /* 1 */
&ASN_PER_TYPE_SEQ_OF_OTD_FIRST_SET_MSRS_CONSTR_1,
asn_MBR_SeqOfOTD_FirstSetMsrs_1,
1, /* Single element */
&asn_SPC_SeqOfOTD_FirstSetMsrs_specs_1 /* Additional specs */
};
|
#pragma once
#include <QThread>
class MainWindowCloseThread : public QThread
{
Q_OBJECT
public:
explicit MainWindowCloseThread(QObject* parent = nullptr);
signals:
void canClose();
private:
void run();
};
|
#pragma once
#include "../../data/PercentCodec.h"
// Uri encode and decode.
// RFC1630, RFC1738, RFC2396
inline std::string UriDecode(const std::string & sSrc)
{
return PercentDecode (sSrc);
}
// Only alphanum is safe.
const char URI_SAFE [256] =
{
/* 0 1 2 3 4 5 6 7 8 9 A B C D E F */
/* 0 */ 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0,
/* 1 */ 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0,
/* 2 */ 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0,
/* 3 */ 1,1,1,1, 1,1,1,1, 1,1,0,0, 0,0,0,0,
/* 4 */ 0,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1,
/* 5 */ 1,1,1,1, 1,1,1,1, 1,1,1,0, 0,0,0,0,
/* 6 */ 0,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1,
/* 7 */ 1,1,1,1, 1,1,1,1, 1,1,1,0, 0,0,0,0,
/* 8 */ 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0,
/* 9 */ 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0,
/* A */ 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0,
/* B */ 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0,
/* C */ 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0,
/* D */ 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0,
/* E */ 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0,
/* F */ 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0
};
inline std::string UriEncode(const std::string & sSrc)
{
return PercentEncode (sSrc, URI_SAFE);
} |
/***
* Filename: StreamerBaseBase.h
*
* Description: Stream table data to a stream.
*
* Created: 2016-04-26
*
* Author: Dilawar Singh <dilawars@ncbs.res.in>
* Organization: NCBS Bangalore
*
* License: GNU GPL2
*/
#ifndef StreamerBase_INC
#define StreamerBase_INC
#define STRINGSTREAM_DOUBLE_PRECISION 10
#include <iostream>
#include <string>
#include <map>
#include <fstream>
#include <sstream>
#include "TableBase.h"
using namespace std;
class TableBase;
enum OpenMode {WRITE, APPEND, WRITE_STR, APPEND_STR, WRITE_BIN, APPEND_BIN};
class StreamerBase : public TableBase
{
public:
StreamerBase();
~StreamerBase();
StreamerBase& operator=( const StreamerBase& st );
/* Functions to set and get Streamer fields */
void setOutFilepath( string stream );
string getOutFilepath() const;
/** @brief Write to a output file in given format.
*
* @param filepath, path of
* output file. If parent directories do not exist, they will be created. If
* creation fails for some reason, data will be saved in current working
* directory. The name of the file will be computed from the given directory
* name by replacing '/' or '\' by '_'.
*
* @param format
*
* npy : numpy binary format (version 1 and 2), version 1 is default.
* csv or dat: comma separated value (delimiter ' ' )
*
* @param openmode (write or append)
*
* @param data, vector of values
*
* @param ncols (number of columns). Incoming data will be formatted into a
* matrix with ncols.
*/
static void writeToOutFile(
const string& filepath, const string& format
, const OpenMode openmode
, const vector<double>& data
, const vector<string>& columns
);
/**
* @brief Write data to csv file. See the documentation of writeToOutfile
* for details.
*/
static void writeToCSVFile( const string& filepath, const OpenMode openMode
, const vector<double>& data, const vector<string>& columns
);
/**
* @brief Write to NPY format. See the documentation of
* writeToOutfile for more details.
*/
static void writeToNPYFile( const string& filepath, const OpenMode openmode
, const vector<double>& data
, const vector<string>& columns
);
/* --------------------------------------------------------------------------*/
/**
* @Synopsis Return a csv representation of a vector.
*
* @Param ys vector of double.
*
* @Returns CSV string.
*/
/* ----------------------------------------------------------------------------*/
string vectorToCSV( const vector<double>& ys, const string& fmt );
private:
string outfilePath_;
static const char eol = '\n';
static const char delimiter_ = ' ';
};
#endif /* ----- #ifndef StreamerBase_INC ----- */
|
/*
AudioFileStream
Convert an AudioFileSource* to a Stream*
Copyright (C) 2017 Earle F. Philhower, III
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef AUDIOFILESTREAM_H
#define AUDIOFILESTREAM_H
#include <Arduino.h>
#include "AudioFileSource.h"
class AudioFileStream : public Stream
{
public:
AudioFileStream(AudioFileSource *source, int definedLen);
virtual ~AudioFileStream();
public:
// Stream interface - see the Arduino library documentation.
virtual int available() override;
virtual int read() override;
virtual int peek() override;
virtual void flush() override;
virtual size_t write(uint8_t x) override { (void)x; return 0; };
private:
AudioFileSource *src;
int saved;
int len;
int ptr;
};
#endif
|
#ifndef __FOOBAR4000_H__
#define __FOOBAR4000_H__
class Baz {
public:
Baz() {}
};
#endif /* __FOOBAR4000_H__ */
|
/************************************************************************
* FILE NAME: smartvsynccheckbox.h
*
* DESCRIPTION: Class CSmartVSyncCheckBox
************************************************************************/
#ifndef __smart_vsync_check_box_h__
#define __smart_vsync_check_box_h__
// Physical component dependency
#include "smartsettingsmenubtn.h"
class CSmartVSyncCheckBox : public CSmartSettingsMenuBtn
{
public:
// Constructor
CSmartVSyncCheckBox( CUIControl * pUIControl );
// Handle events
void handleEvent( const SDL_Event & rEvent ) override;
// Called when the control is executed
void execute() override;
};
#endif // __smart_vsync_check_box_h__
|
/*
This file is part of SUPPL - the supplemental library for DOS
Copyright (C) 1996-2000 Steffen Kaiser
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* DON'T MODIFY THIS FILE!
This is an auto-generated file (by mkerrfct.pl), don't
modify because next time the script runs, your modifications
are lost.
Defines one of the default error strings.
*/
#include "initsupl.loc"
#include "msgs.loc"
#undef I_wdNo
const char I_wdNo[] =
#include "msgs.lng"
I_wdNo;
|
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (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.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is the PKIX-C library.
*
* The Initial Developer of the Original Code is
* Sun Microsystems, Inc.
* Portions created by the Initial Developer are
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* Contributor(s):
* Sun Microsystems, Inc.
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/*
* pkix_expirationchecker.h
*
* Header file for validate expiration function
*
*/
#ifndef _PKIX_EXPIRATIONCHECKER_H
#define _PKIX_EXPIRATIONCHECKER_H
#include "pkix_tools.h"
#ifdef __cplusplus
extern "C" {
#endif
PKIX_Error *
pkix_ExpirationChecker_Initialize(
PKIX_PL_Date *testDate,
PKIX_CertChainChecker **pChecker,
void *plContext);
#ifdef __cplusplus
}
#endif
#endif /* _PKIX_EXPIRATIONCHECKER_H */
|
/*
* ArcEmu MMORPG Server
* Copyright (C) 2008 <http://www.ArcEmu.org/>
*
* 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
* 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/>.
*
*/
#ifndef _MD5_H
#define _MD5_H
#include <stdlib.h>
#include <openssl/md5.h>
#include "Common.h"
class MD5Hash
{
public:
MD5Hash();
~MD5Hash();
void UpdateData(const uint8 *dta, int len);
void UpdateData(const std::string &str);
void Initialize();
void Finalize();
uint8 *GetDigest(void) { return mDigest; };
int GetLength(void) { return MD5_DIGEST_LENGTH; };
private:
MD5_CTX mC;
uint8 mDigest[MD5_DIGEST_LENGTH];
};
#endif
|
/*
* Copyright (C) 2011-2012 DarkCore <http://www.darkpeninsula.eu/>
* Copyright (C) 2011-2012 Project SkyFire <http://www.projectskyfire.org/>
* Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/>
* Copyright (C) 2005-2012 MaNGOS <http://getmangos.com/>
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _VMAPFACTORY_H
#define _VMAPFACTORY_H
#include "IVMapManager.h"
/**
This is the access point to the VMapManager.
*/
namespace VMAP
{
//===========================================================
class VMapFactory
{
public:
static IVMapManager* createOrGetVMapManager();
static void clear();
static void preventSpellsFromBeingTestedForLoS(const char* pSpellIdString);
static bool checkSpellForLoS(unsigned int pSpellId);
};
}
#endif
|
#ifndef __OpenViBEPlugins_Stimulation_CXMLStimulationScenarioPlayer_H__
#define __OpenViBEPlugins_Stimulation_CXMLStimulationScenarioPlayer_H__
#include "../ovp_defines.h"
#include <openvibe/ov_all.h>
#include <toolkit/ovtk_all.h>
#include <automaton/IXMLAutomatonReader.h>
#include <ebml/IReader.h>
#include <ebml/IWriter.h>
#include <ebml/TWriterCallbackProxy.h>
#include <vector>
#include <string>
namespace OpenViBEPlugins
{
namespace Stimulation
{
class CXMLStimulationScenarioPlayer : public OpenViBEToolkit::TBoxAlgorithm<OpenViBE::Plugins::IBoxAlgorithm>, virtual public OpenViBEToolkit::IBoxAlgorithmStimulationInputReaderCallback::ICallback
{
public:
CXMLStimulationScenarioPlayer(void);
virtual void release(void) { delete this; }
virtual OpenViBE::boolean initialize();
virtual OpenViBE::boolean uninitialize();
virtual OpenViBE::boolean processInput(OpenViBE::uint32 ui32InputIndex);
virtual OpenViBE::boolean processClock(OpenViBE::CMessageClock &rMessageClock);
virtual OpenViBE::uint64 getClockFrequency(){ return (128LL<<32); }
virtual OpenViBE::boolean process();
virtual OpenViBE::boolean readAutomaton(const OpenViBE::CString& oFilename);
virtual void setStimulationCount(const OpenViBE::uint32 ui32StimulationCount);
virtual void setStimulation(const OpenViBE::uint32 ui32StimulationIndex, const OpenViBE::uint64 ui64StimulationIdentifier, const OpenViBE::uint64 ui64StimulationDate);
virtual void writeStimulationOutput(const void* pBuffer, const EBML::uint64 ui64BufferSize);
_IsDerivedFromClass_Final_(OpenViBEToolkit::TBoxAlgorithm<OpenViBE::Plugins::IBoxAlgorithm>, OVP_ClassId_XMLStimulationScenarioPlayer)
public:
EBML::IReader* m_pReader;
OpenViBEToolkit::IBoxAlgorithmStimulationInputReaderCallback* m_pStimulationReaderCallBack;
std::vector<std::pair<OpenViBE::uint64, OpenViBE::uint64> > m_oStimulationReceived;
EBML::IWriter* m_pWriter;
EBML::TWriterCallbackProxy1<OpenViBEPlugins::Stimulation::CXMLStimulationScenarioPlayer> * m_pOutputWriterCallbackProxy;
OpenViBEToolkit::IBoxAlgorithmStimulationOutputWriter * m_pStimulationOutputWriterHelper;
Automaton::IXMLAutomatonReader * m_pXMLAutomatonReader;
Automaton::IAutomatonController * m_pAutomatonController;
Automaton::IAutomatonContext * m_pAutomatonContext;
Automaton::boolean m_bEndOfAutomaton;
OpenViBE::uint64 m_ui64PreviousActivationTime;
};
/**
* Plugin's description
*/
class CXMLStimulationScenarioPlayerDesc : public OpenViBE::Plugins::IBoxAlgorithmDesc
{
public:
virtual OpenViBE::CString getName(void) const { return OpenViBE::CString("XML stimulation scenario player"); }
virtual OpenViBE::CString getAuthorName(void) const { return OpenViBE::CString("Bruno Renier"); }
virtual OpenViBE::CString getAuthorCompanyName(void) const { return OpenViBE::CString("INRIA/IRISA"); }
virtual OpenViBE::CString getShortDescription(void) const { return OpenViBE::CString("Plays a stimulation scenarion from an XML file"); }
virtual OpenViBE::CString getDetailedDescription(void) const { return OpenViBE::CString("Plays a stimulation scenarion from an XML file"); }
virtual OpenViBE::CString getCategory(void) const { return OpenViBE::CString("Stimulation"); }
virtual OpenViBE::CString getVersion(void) const { return OpenViBE::CString("0.1"); }
virtual void release(void) { }
virtual OpenViBE::CIdentifier getCreatedClass(void) const { return OVP_ClassId_XMLStimulationScenarioPlayer; }
virtual OpenViBE::Plugins::IPluginObject* create(void) { return new OpenViBEPlugins::Stimulation::CXMLStimulationScenarioPlayer(); }
virtual OpenViBE::boolean getBoxPrototype(OpenViBE::Kernel::IBoxProto& rPrototype) const
{
rPrototype.addInput ("Incoming Stimulations", OV_TypeId_Stimulations);
rPrototype.addOutput ("Outgoing Stimulations", OV_TypeId_Stimulations);
rPrototype.addSetting("Filename", OV_TypeId_Filename, "");
rPrototype.addFlag (OpenViBE::Kernel::BoxFlag_IsDeprecated);
return true;
}
_IsDerivedFromClass_Final_(OpenViBE::Plugins::IBoxAlgorithmDesc, OVP_ClassId_XMLStimulationScenarioPlayerDesc)
};
};
};
#endif
|
/*
* Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
*
* This file is part of Open5GS.
*
* 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 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 <https://www.gnu.org/licenses/>.
*/
#include "core-config-private.h"
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
#include "ogs-core.h"
#include "ogs-poll-private.h"
static void select_init(ogs_pollset_t *pollset);
static void select_cleanup(ogs_pollset_t *pollset);
static int select_add(ogs_poll_t *poll);
static int select_remove(ogs_poll_t *poll);
static int select_process(ogs_pollset_t *pollset, ogs_time_t timeout);
const ogs_pollset_actions_t ogs_select_actions = {
select_init,
select_cleanup,
select_add,
select_remove,
select_process,
ogs_notify_pollset,
};
struct select_context_s {
int max_fd;
fd_set master_read_fd_set;
fd_set master_write_fd_set;
fd_set work_read_fd_set;
fd_set work_write_fd_set;
ogs_list_t list;
};
static void select_init(ogs_pollset_t *pollset)
{
struct select_context_s *context = NULL;
ogs_assert(pollset);
context = ogs_calloc(1, sizeof *context);
ogs_assert(context);
pollset->context = context;
ogs_list_init(&context->list);
context->max_fd = -1;
FD_ZERO(&context->master_read_fd_set);
FD_ZERO(&context->master_write_fd_set);
ogs_notify_init(pollset);
}
static void select_cleanup(ogs_pollset_t *pollset)
{
struct select_context_s *context = NULL;
ogs_assert(pollset);
context = pollset->context;
ogs_assert(context);
ogs_notify_final(pollset);
ogs_free(context);
}
static int select_add(ogs_poll_t *poll)
{
ogs_pollset_t *pollset = NULL;
struct select_context_s *context = NULL;
ogs_assert(poll);
pollset = poll->pollset;
ogs_assert(pollset);
context = pollset->context;
ogs_assert(context);
if (poll->when & OGS_POLLIN) {
FD_SET(poll->fd, &context->master_read_fd_set);
}
if (poll->when & OGS_POLLOUT) {
FD_SET(poll->fd, &context->master_write_fd_set);
}
if (poll->fd > context->max_fd)
context->max_fd = poll->fd;
ogs_list_add(&context->list, poll);
return OGS_OK;
}
static int select_remove(ogs_poll_t *poll)
{
ogs_pollset_t *pollset = NULL;
struct select_context_s *context = NULL;
ogs_assert(poll);
pollset = poll->pollset;
ogs_assert(pollset);
context = pollset->context;
ogs_assert(context);
if (poll->when & OGS_POLLIN)
FD_CLR(poll->fd, &context->master_read_fd_set);
if (poll->when & OGS_POLLOUT)
FD_CLR(poll->fd, &context->master_write_fd_set);
if (context->max_fd == poll->fd) {
context->max_fd = -1;
}
ogs_list_remove(&context->list, poll);
return OGS_OK;
}
static int select_process(ogs_pollset_t *pollset, ogs_time_t timeout)
{
struct select_context_s *context = NULL;
ogs_poll_t *poll = NULL, *next_poll = NULL;
int rc;
struct timeval tv, *tp;
ogs_assert(pollset);
context = pollset->context;
ogs_assert(context);
if (context->max_fd == -1) {
ogs_list_for_each(&context->list, poll) {
if (context->max_fd < poll->fd) {
context->max_fd = poll->fd;
}
}
ogs_debug("change max_fd: %d", context->max_fd);
}
context->work_read_fd_set = context->master_read_fd_set;
context->work_write_fd_set = context->master_write_fd_set;
if (timeout == OGS_INFINITE_TIME) {
tp = NULL;
} else {
tv.tv_sec = ogs_time_sec(timeout);
#if defined(_WIN32) /* I don't know why windows need more time */
tv.tv_usec = ogs_time_usec(timeout) + ogs_time_from_msec(1);
#else
tv.tv_usec = ogs_time_usec(timeout);
#endif
tp = &tv;
}
rc = select(context->max_fd + 1,
&context->work_read_fd_set, &context->work_write_fd_set, NULL, tp);
if (rc < 0) {
ogs_log_message(OGS_LOG_ERROR, ogs_socket_errno, "select() failed");
return OGS_ERROR;
} else if (rc == 0) {
return OGS_TIMEUP;
}
ogs_list_for_each_safe(&context->list, next_poll, poll) {
short when = 0;
if ((poll->when & OGS_POLLIN) &&
FD_ISSET(poll->fd, &context->work_read_fd_set)) {
when |= OGS_POLLIN;
}
if ((poll->when & OGS_POLLOUT) &&
FD_ISSET(poll->fd, &context->work_write_fd_set)) {
when |= OGS_POLLOUT;
}
if (when && poll->handler) {
poll->handler(when, poll->fd, poll->data);
}
}
return OGS_OK;
}
|
#ifndef _SPACEPARTTREE_PRIV_H_
#define _SPACEPARTTREE_PRIV_H_
#include <glib/ghash.h>
typedef enum {
SPT_NODE_TYPE_BSP,
SPT_NODE_TYPE_LABEL,
} spt_node_type;
typedef enum {
SPT_VARIABLE_X,
SPT_VARIABLE_Y,
SPT_VARIABLE_Z,
} spt_variable;
typedef enum {
SPT_COMP_LT,
SPT_COMP_LE,
SPT_COMP_GE,
SPT_COMP_GT,
} spt_comparison;
typedef struct {
char *nodelabel;
spt_node_type nodetype;
unsigned int printcount;
} spt_node_header;
/* e.g. foo L unknown */
typedef struct {
spt_node_header header;
char *printlabel;
} spt_node_label;
/* e.g. foo B x < 10.0 bar baz */
typedef struct {
spt_node_header header;
spt_variable var;
spt_comparison comp;
double value;
spt_node_header *t;
spt_node_header *f;
} spt_node_bsp;
typedef struct {
double x;
double y;
double z;
} spt_variables ;
/* The typedef for this is in the public header */
struct spt {
GHashTable *nodebyname;
spt_node_header *root;
unsigned int printcount;
};
#endif
|
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** 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.
**
**************************************************************************/
#ifndef CUSTOMWIDGETPLUGINWIZARDPAGE_H
#define CUSTOMWIDGETPLUGINWIZARDPAGE_H
#include "filenamingparameters.h"
#include <QtGui/QWizardPage>
#include <QtCore/QSharedPointer>
namespace Qt4ProjectManager {
namespace Internal {
struct PluginOptions;
class CustomWidgetWidgetsWizardPage;
namespace Ui {
class CustomWidgetPluginWizardPage;
}
class CustomWidgetPluginWizardPage : public QWizardPage {
Q_OBJECT
public:
explicit CustomWidgetPluginWizardPage(QWidget *parent = 0);
virtual ~CustomWidgetPluginWizardPage();
void init(const CustomWidgetWidgetsWizardPage *widgetsPage);
virtual bool isComplete() const;
FileNamingParameters fileNamingParameters() const { return m_fileNamingParameters; }
void setFileNamingParameters(const FileNamingParameters &fnp) {m_fileNamingParameters = fnp; }
// Fills the plugin fields, excluding widget list.
QSharedPointer<PluginOptions> basicPluginOptions() const;
protected:
void changeEvent(QEvent *e);
private slots:
void on_collectionClassEdit_textChanged();
void on_collectionHeaderEdit_textChanged();
void slotCheckCompleteness();
private:
inline QString collectionClassName() const;
inline QString pluginName() const;
void setCollectionEnabled(bool enColl);
Ui::CustomWidgetPluginWizardPage *m_ui;
FileNamingParameters m_fileNamingParameters;
int m_classCount;
bool m_complete;
};
} // namespace Internal
} // namespace Qt4ProjectManager
#endif // CUSTOMWIDGETPLUGINWIZARDPAGE_H
|
/*
* Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
* Copyright (C) 2008 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#ifndef DateInstance_h
#define DateInstance_h
#include "JSWrapperObject.h"
namespace WTF {
struct GregorianDateTime;
}
namespace JSC {
class DateInstance : public JSWrapperObject {
public:
DateInstance(ExecState*, double);
explicit DateInstance(ExecState*, NonNullPassRefPtr<Structure>);
double internalNumber() const { return internalValue().uncheckedGetNumber(); }
static JS_EXPORTDATA const ClassInfo info;
bool getGregorianDateTime(ExecState*, bool outputIsUTC, WTF::GregorianDateTime&) const;
static PassRefPtr<Structure> createStructure(JSValue prototype)
{
return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags));
}
protected:
static const unsigned StructureFlags = OverridesMarkChildren | JSWrapperObject::StructureFlags;
private:
virtual const ClassInfo* classInfo() const { return &info; }
mutable RefPtr<DateInstanceData> m_data;
};
DateInstance* asDateInstance(JSValue);
inline DateInstance* asDateInstance(JSValue value)
{
ASSERT(asObject(value)->inherits(&DateInstance::info));
return static_cast<DateInstance*>(asObject(value));
}
} // namespace JSC
#endif // DateInstance_h
|
//-----------------------------------------------------------------------bl-
//--------------------------------------------------------------------------
//
// QUESO - a library to support the Quantification of Uncertainty
// for Estimation, Simulation and Optimization
//
// Copyright (C) 2008-2015 The PECOS Development Team
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the Version 2.1 GNU Lesser General
// Public License as published by the Free Software Foundation.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc. 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA
//
//-----------------------------------------------------------------------el-
#include <queso/Defines.h>
#ifdef QUESO_HAVE_HDF5
#ifndef QUESO_INFINITE_SAMPLER_H
#define QUESO_INFINITE_SAMPLER_H
// Boost includes
#include <boost/scoped_ptr.hpp>
#include <boost/shared_ptr.hpp>
// Queso includes
#include <queso/Environment.h>
#include <queso/InfiniteDimensionalMeasureBase.h>
#include <queso/InfiniteDimensionalLikelihoodBase.h>
#include <queso/InfiniteDimensionalMCMCSamplerOptions.h>
// GSL includes
#include <gsl/gsl_rng.h>
// HDF5 includes
#include <hdf5.h>
namespace QUESO {
/*!
* \file InfiniteDimensionalMCMCSampler.h
* \brief Class representing the infinite dimensional Markov chain Monte Carlo sampler
* \class InfiniteDimensionalMCMCSampler
* \brief Class representing the infinite dimensional Markov chain Monte Carlo sampler
*/
class InfiniteDimensionalMCMCSampler
{
public:
//! Construct an infinite dimensional MCMC chain with given \c prior, likelihood \c llhd, and options \c ov.
InfiniteDimensionalMCMCSampler(
const BaseEnvironment& env,
InfiniteDimensionalMeasureBase & prior,
InfiniteDimensionalLikelihoodBase & llhd,
InfiniteDimensionalMCMCSamplerOptions * ov);
//! Destructor
~InfiniteDimensionalMCMCSampler();
//! Do one iteration of the Markov chain
void step();
//! Get the current value of the llhd
double llhd_val() const;
//! Returns current acceptance probability
double acc_prob();
//! Returns current average acceptance probability
double avg_acc_prob();
//! Returns the current iteration number
unsigned int iteration() const;
//! Returns a pointer to new sampler, with all the moments reset.
boost::shared_ptr<InfiniteDimensionalMCMCSampler> clone_and_reset() const;
private:
// Current iteration
unsigned int _iteration;
// The current value of the negative log-likelihood functional
double _llhd_val;
// The current acceptance probability
double _acc_prob;
// The current running mean of the acceptance probability
double _avg_acc_prob;
// The prior measure from which to draw
InfiniteDimensionalMeasureBase & prior;
// The negative log-likelihood functional. Operates on functions.
// Should be const?
InfiniteDimensionalLikelihoodBase & llhd;
// Aggregate options object
InfiniteDimensionalMCMCSamplerOptions * m_ov;
// The QUESO environment
const BaseEnvironment& m_env;
// Pointer to the current physical state
boost::shared_ptr<FunctionBase> current_physical_state;
// Pointer to the current proposed state
boost::shared_ptr<FunctionBase> proposed_physical_state;
// Pointer to the current physical mean
boost::shared_ptr<FunctionBase> current_physical_mean;
// Pointer to the current physical variance
boost::shared_ptr<FunctionBase> current_physical_var;
// Stores the differences from the mean
boost::shared_ptr<FunctionBase> _delta;
// Stores a running sum-of-squares (kinda)
boost::shared_ptr<FunctionBase> _M2;
// A pointer to the random number generator to use.
// Should probably use the one in the queso environment.
gsl_rng *r;
// HDF5 file identifier
hid_t _outfile;
// HDF5 datasets
hid_t _acc_dset;
hid_t _avg_acc_dset;
hid_t _neg_log_llhd_dset;
hid_t _L2_norm_samples_dset;
hid_t _L2_norm_mean_dset;
hid_t _L2_norm_var_dset;
/*!
* Make a proposal from the prior using a standard random walk
*/
void _propose();
// Do a metropolis random walk step
void _metropolis_hastings();
// Increments the current iteration and updates the running mean and variance.
void _update_moments();
// Write the current state of the chain to disk
void _write_state();
// Creates a scalar dataset called \c name in \c _outfile file and returns it
hid_t _create_scalar_dataset(const std::string & name);
// Appends to a scalar dataset in the hdf5 file
void _append_scalar_dataset(hid_t dset, double data);
};
} // End namespace QUESO
#endif // QUESO_INFINITE_SAMPLER_H
#endif // QUESO_HAVE_HDF5
|
/*
* Copyright (C) 2004-2012 George Yunaev gyunaev@ulduzsoft.com
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at your
* option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*/
#ifndef INCLUDE_IRC_SESSION_H
#define INCLUDE_IRC_SESSION_H
#include "params.h"
#include "dcc.h"
#include "libirc_events.h"
// Session flags
#define SESSIONFL_MOTD_RECEIVED (0x00000001)
#define SESSIONFL_SSL_CONNECTION (0x00000002)
#define SESSIONFL_SSL_WRITE_WANTS_READ (0x00000004)
#define SESSIONFL_SSL_READ_WANTS_WRITE (0x00000008)
#define SESSIONFL_USES_IPV6 (0x00000010)
struct irc_session_s
{
void * ctx;
int dcc_timeout;
int options;
int lasterror;
char incoming_buf[LIBIRC_BUFFER_SIZE];
unsigned int incoming_offset;
char outgoing_buf[LIBIRC_BUFFER_SIZE];
unsigned int outgoing_offset;
port_mutex_t mutex_session;
socket_t sock;
int state;
int flags;
char * server;
char * server_password;
char * realname;
char * username;
char * nick;
#if defined( ENABLE_IPV6 )
struct in6_addr local_addr6;
#endif
struct in_addr local_addr;
irc_dcc_t dcc_last_id;
irc_dcc_session_t * dcc_sessions;
port_mutex_t mutex_dcc;
irc_callbacks_t callbacks;
#if defined (ENABLE_SSL)
SSL * ssl;
#endif
};
#endif /* INCLUDE_IRC_SESSION_H */
|
#ifndef __E_NAME_WESTERN_H__
#define __E_NAME_WESTERN_H__
G_BEGIN_DECLS
typedef struct {
/* Public */
char *prefix;
char *first;
char *middle;
char *nick;
char *last;
char *suffix;
/* Private */
char *full;
} ENameWestern;
ENameWestern *e_name_western_parse (const char *full_name);
void e_name_western_free (ENameWestern *w);
G_END_DECLS
#endif /* ! __E_NAME_WESTERN_H__ */
|
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** 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.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/
#ifndef SELECTIONRECTANGLE_H
#define SELECTIONRECTANGLE_H
#include <QWeakPointer>
#include <QGraphicsRectItem>
#include "layeritem.h"
namespace QmlDesigner {
class SelectionRectangle
{
public:
SelectionRectangle(LayerItem *layerItem);
~SelectionRectangle();
void show();
void hide();
void clear();
void setRect(const QPointF &firstPoint,
const QPointF &secondPoint);
QRectF rect() const;
private:
QGraphicsRectItem *m_controlShape;
QWeakPointer<LayerItem> m_layerItem;
};
}
#endif // SELECTIONRECTANGLE_H
|
/*
* 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 Library General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* PathportPackets.h
* Datagram definitions for libpathport
* Copyright (C) 2006 Simon Newton
*/
#ifndef PLUGINS_PATHPORT_PATHPORTPACKETS_H_
#define PLUGINS_PATHPORT_PATHPORTPACKETS_H_
#include <sys/types.h>
#include <stdint.h>
#include "ola/network/IPV4Address.h"
namespace ola {
namespace plugin {
namespace pathport {
/*
* Pathport opcodes
*/
// We can't use the PACK macro for enums
#ifdef _WIN32
#pragma pack(push, 1)
#endif
enum pathport_packet_type_e {
PATHPORT_DATA = 0x0100,
PATHPORT_PATCH = 0x0200,
PATHPORT_PATCHREP = 0x0210,
PATHPORT_GET = 0x0222,
PATHPORT_GET_REPLY = 0x0223,
PATHPORT_ARP_REQUEST = 0x0301,
PATHPORT_ARP_REPLY = 0x0302,
PATHPORT_SET = 0x0400,
#ifdef _WIN32
};
#pragma pack(pop)
#else
} __attribute__((packed));
#endif
typedef enum pathport_packet_type_e pathport_packet_type_t;
/*
* Pathport xDmx
*/
PACK(
struct pathport_pdu_data_s {
uint16_t type;
uint16_t channel_count;
uint8_t universe; // not used, set to 0
uint8_t start_code;
uint16_t offset;
uint8_t data[0];
});
typedef struct pathport_pdu_data_s pathport_pdu_data;
/*
* Pathport get request
*/
PACK(
struct pathport_pdu_get_s {
uint16_t params[0];
});
typedef struct pathport_pdu_get_s pathport_pdu_get;
/*
* Pathport get reply
*/
PACK(
struct pathport_pdu_getrep_s {
uint8_t params[0];
});
typedef struct pathport_pdu_getrep_s pathport_pdu_getrep;
struct pathport_pdu_getrep_alv_s {
uint16_t type;
uint16_t len;
uint8_t val[0];
};
typedef struct pathport_pdu_getrep_alv_s pathport_pdu_getrep_alv;
/*
* Pathport arp reply
*/
PACK(
struct pathport_pdu_arp_reply_s {
uint32_t id;
uint8_t ip[ola::network::IPV4Address::LENGTH];
uint8_t manufacturer_code; // manufacturer code
uint8_t device_class; // device class
uint8_t device_type; // device type
uint8_t component_count; // number of dmx components
});
typedef struct pathport_pdu_arp_reply_s pathport_pdu_arp_reply;
PACK(
struct pathport_pdu_header_s {
uint16_t type; // pdu type
uint16_t len; // length
});
typedef struct pathport_pdu_header_s pathport_pdu_header;
/*
* PDU Header
*/
PACK(
struct pathport_packet_pdu_s {
pathport_pdu_header head;
union {
pathport_pdu_data data;
pathport_pdu_get get;
pathport_pdu_getrep getrep;
pathport_pdu_arp_reply arp_reply;
} d; // pdu data
});
typedef struct pathport_packet_pdu_s pathport_packet_pdu;
/*
* A complete Pathport packet
*/
PACK(
struct pathport_packet_header_s {
uint16_t protocol;
uint8_t version_major;
uint8_t version_minor;
uint16_t sequence;
uint8_t reserved[6]; // set to 0
uint32_t source; // src id
uint32_t destination; // dst id
});
typedef struct pathport_packet_header_s pathport_packet_header;
/*
* The complete pathport packet
*/
PACK(
struct pathport_packet_s {
pathport_packet_header header;
union {
uint8_t data[1480]; // 1500 - header size
pathport_packet_pdu pdu;
} d;
});
} // namespace pathport
} // namespace plugin
} // namespace ola
#endif // PLUGINS_PATHPORT_PATHPORTPACKETS_H_
|
/*= -*- c-basic-offset: 4; indent-tabs-mode: nil; -*-
*
* librsync -- library for network deltas
* $Id$
*
* Copyright (C) 1999, 2000, 2001 by Martin Pool <mbp@samba.org>
* Copyright (C) 1999 by Andrew Tridgell <tridge@samba.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 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., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* mksum.c -- Generate file signatures.
*
* Generating checksums is pretty easy, since we can always just
* process whatever data is available. When a whole block has
* arrived, or we've reached the end of the file, we write the
* checksum out.
*/
/* TODO: Perhaps force blocks to be a multiple of 64 bytes, so that we
* can be sure checksum generation will be more efficient. I guess it
* will be OK at the moment, though, because tails are only used if
* necessary. */
#include <config.h>
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include "librsync.h"
#include "stream.h"
#include "util.h"
#include "sumset.h"
#include "job.h"
#include "protocol.h"
#include "netint.h"
#include "trace.h"
#include "checksum.h"
/* Possible state functions for signature generation. */
static rs_result rs_sig_s_header(rs_job_t *);
static rs_result rs_sig_s_generate(rs_job_t *);
/**
* State of trying to send the signature header.
*/
static rs_result rs_sig_s_header(rs_job_t *job)
{
rs_squirt_n4(job, RS_SIG_MAGIC);
rs_squirt_n4(job, job->block_len);
rs_squirt_n4(job, job->strong_sum_len);
rs_trace("sent header (magic %#x, block len = %d, strong sum len = %d)",
RS_SIG_MAGIC, (int) job->block_len, (int) job->strong_sum_len);
job->stats.block_len = job->block_len;
job->statefn = rs_sig_s_generate;
return RS_RUNNING;
}
/**
* Generate the checksums for a block and write it out. Called when
* we already know we have enough data in memory at \p block.
*/
static rs_result
rs_sig_do_block(rs_job_t *job, const void *block, size_t len)
{
unsigned int weak_sum;
rs_strong_sum_t strong_sum;
weak_sum = rs_calc_weak_sum(block, len);
rs_calc_strong_sum(block, len, &strong_sum);
rs_squirt_n4(job, weak_sum);
rs_tube_write(job, strong_sum, job->strong_sum_len);
if (rs_trace_enabled()) {
char strong_sum_hex[RS_MD4_LENGTH * 2 + 1];
rs_hexify(strong_sum_hex, strong_sum, job->strong_sum_len);
rs_trace("sent weak sum 0x%08x and strong sum %s", weak_sum,
strong_sum_hex);
}
job->stats.sig_blocks++;
return RS_RUNNING;
}
/*
* State of reading a block and trying to generate its sum.
*/
static rs_result
rs_sig_s_generate(rs_job_t *job)
{
rs_result result;
size_t len;
void *block;
/* must get a whole block, otherwise try again */
len = job->block_len;
result = rs_scoop_read(job, len, &block);
/* unless we're near eof, in which case we'll accept
* whatever's in there */
if ((result == RS_BLOCKED && rs_job_input_is_ending(job))) {
result = rs_scoop_read_rest(job, &len, &block);
} else if (result == RS_INPUT_ENDED) {
return RS_DONE;
} else if (result != RS_DONE) {
rs_trace("generate stopped: %s", rs_strerror(result));
return result;
}
rs_trace("got %ld byte block", (long) len);
return rs_sig_do_block(job, block, len);
}
/** \brief Set up a new encoding job.
*
* \sa rs_sig_file()
*/
rs_job_t * rs_sig_begin(size_t new_block_len, size_t strong_sum_len)
{
rs_job_t *job;
job = rs_job_new("signature", rs_sig_s_header);
job->block_len = new_block_len;
assert(strong_sum_len > 0 && strong_sum_len <= RS_MD4_LENGTH);
job->strong_sum_len = strong_sum_len;
return job;
}
|
/*
* Copyright (C) 2013 Kaspar Schleiser <kaspar@schleiser.de>
* Copyright (C) 2013 Freie Universität Berlin
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @file
* @brief shows how to set up own and use the system shell commands.
* By typing help in the serial console, all the supported commands
* are listed.
*
* @author Kaspar Schleiser <kaspar@schleiser.de>
* @author Zakaria Kasmi <zkasmi@inf.fu-berlin.de>
*
*/
#include <stdio.h>
#include <string.h>
#include "shell_commands.h"
#include "shell.h"
#if MODULE_STDIO_RTT
#include "xtimer.h"
#endif
#if MODULE_SHELL_HOOKS
void shell_post_readline_hook(void)
{
puts("shell_post_readline_hook");
}
void shell_pre_command_hook(int argc, char **argv)
{
(void)argc;
(void)argv;
puts("shell_pre_command_hook");
}
void shell_post_command_hook(int ret, int argc, char **argv)
{
(void)ret;
(void)argc;
(void)argv;
puts("shell_post_command_hook");
}
#endif
static int print_teststart(int argc, char **argv)
{
(void) argc;
(void) argv;
printf("[TEST_START]\n");
return 0;
}
static int print_testend(int argc, char **argv)
{
(void) argc;
(void) argv;
printf("[TEST_END]\n");
return 0;
}
static int print_echo(int argc, char **argv)
{
for (int i = 0; i < argc; ++i) {
printf("\"%s\"", argv[i]);
}
puts("");
return 0;
}
static int print_shell_bufsize(int argc, char **argv)
{
(void) argc;
(void) argv;
printf("%d\n", SHELL_DEFAULT_BUFSIZE);
return 0;
}
static const shell_command_t shell_commands[] = {
{ "bufsize", "Get the shell's buffer size", print_shell_bufsize },
{ "start_test", "starts a test", print_teststart },
{ "end_test", "ends a test", print_testend },
{ "echo", "prints the input command", print_echo },
{ NULL, NULL, NULL }
};
int main(void)
{
printf("test_shell.\n");
/* define buffer to be used by the shell */
char line_buf[SHELL_DEFAULT_BUFSIZE];
/* define own shell commands */
shell_run(shell_commands, line_buf, SHELL_DEFAULT_BUFSIZE);
/* or use only system shell commands */
/*
shell_run(NULL, line_buf, SHELL_DEFAULT_BUFSIZE);
*/
return 0;
}
|
/****************************************************************************
**
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
** the names of its contributors may be used to endorse or promote
** products derived from this software without specific prior written
** permission.
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef LAYOUTITEM_H
#define LAYOUTITEM_H
#include <QtGui>
//! [0]
class LayoutItem : public QGraphicsLayoutItem, public QGraphicsItem
{
public:
LayoutItem(QGraphicsItem *parent = 0);
~LayoutItem();
// Inherited from QGraphicsLayoutItem
void setGeometry(const QRectF &geom);
QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const;
// Inherited from QGraphicsItem
QRectF boundingRect() const;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = 0);
private:
QPixmap *m_pix;
};
//! [0]
#endif
|
/*************************************************************************\
* Copyright (C) Michael Kerrisk, 2014. *
* *
* This program is free software. You may use, modify, and redistribute it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation, either version 3 or (at your option) any *
* later version. This program is distributed without any warranty. See *
* the file COPYING.gpl-v3 for details. *
\*************************************************************************/
/* Solution for Exercise 31-1 */
/* one_time_init.c
The one_time_init() function implemented here performs the same task as
the POSIX threads pthread_once() library function.
*/
#include <pthread.h>
#include "tlpi_hdr.h"
struct once_struct { /* Our equivalent of pthread_once_t */
pthread_mutex_t mtx;
int called;
};
#define ONCE_INITIALISER { PTHREAD_MUTEX_INITIALIZER, 0 }
struct once_struct once = ONCE_INITIALISER;
static int
one_time_init(struct once_struct *once_control, void (*init)(void))
{
int s;
s = pthread_mutex_lock(&(once_control->mtx));
if (s == -1)
errExitEN(s, "pthread_mutex_lock");
if (!once_control->called) {
(*init)();
once_control->called = 1;
}
s = pthread_mutex_unlock(&(once_control->mtx));
if (s == -1)
errExitEN(s, "pthread_mutex_unlock");
return 0;
}
/* Remaining code is for testing one_time_init() */
static void
init_func()
{
/* We should see this message only once, no matter how many
times one_time_init() is called */
printf("Called init_func()\n");
}
static void *
threadFunc(void *arg)
{
/* The following allows us to verify that even if a single thread calls
one_time_init() multiple times, init_func() is called only once */
one_time_init(&once, init_func);
one_time_init(&once, init_func);
return NULL;
}
int
main(int argc, char *argv[])
{
pthread_t t1, t2;
int s;
/* Create two threads, both of which will call one_time_init() */
s = pthread_create(&t1, NULL, threadFunc, (void *) 1);
if (s != 0)
errExitEN(s, "pthread_create");
s = pthread_create(&t2, NULL, threadFunc, (void *) 2);
if (s != 0)
errExitEN(s, "pthread_create");
s = pthread_join(t1, NULL);
if (s != 0)
errExitEN(s, "pthread_join");
printf("First thread returned\n");
s = pthread_join(t2, NULL);
if (s != 0)
errExitEN(s, "pthread_join");
printf("Second thread returned\n");
exit(EXIT_SUCCESS);
}
|
/* ============================================================================
* I B E X - HC4 Revise (forward-backward algorithm)
* ============================================================================
* Copyright : Ecole des Mines de Nantes (FRANCE)
* License : This program can be distributed under the terms of the GNU LGPL.
* See the file COPYING.LESSER.
*
* Author(s) : Gilles Chabert, Jordan Ninin
* Created : Feb 27, 2012
* ---------------------------------------------------------------------------- */
#ifndef __IBEX_CTC_FWDBWD_H__
#define __IBEX_CTC_FWDBWD_H__
#include "ibex_Ctc.h"
#include "ibex_NumConstraint.h"
namespace ibex {
/**
* \ingroup contractor
* \brief Forward-backward contractor (HC4Revise).
*
*/
class CtcFwdBwd: public Ctc {
public:
/**
* \brief Build the contractor for "f(x)=0" or "f(x)<=0".
*
* \param op: by default: EQ.
*
*/
CtcFwdBwd(Function& f, CmpOp op=EQ);
/**
* \brief Build the contractor for "f(x) in [y]".
*/
CtcFwdBwd(Function& f, const Domain& y);
/**
* \brief Build the contractor for "f(x) in [y]".
*/
CtcFwdBwd(Function& f, const Interval& y);
/**
* \brief Build the contractor for "f(x) in [y]".
*/
CtcFwdBwd(Function& f, const IntervalVector& y);
/**
* \brief Build the contractor for "f(x) in [y]".
*/
CtcFwdBwd(Function& f, const IntervalMatrix& y);
/**
* \remark ctr is not kept by reference.
*/
CtcFwdBwd(const NumConstraint& ctr);
/**
* \brief Delete this.
*/
~CtcFwdBwd();
/**
* \brief Contract the box.
*/
virtual void contract(IntervalVector& box);
/*
* \brief Whether this contractor is idempotent (optional)
*/
// TODO
// bool idempotent();
//
/** The function "f". */
const Function& f;
/** The domain "y". */
Domain d;
protected:
void init();
};
} // namespace ibex
#endif // __IBEX_CTC_FWDBWD_H__
|
/****************************************************************************
**
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the demonstration applications of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL21$
** 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 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, 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.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef SPINNER_H
#define SPINNER_H
#include <QtQuick/QQuickItem>
class Spinner : public QQuickItem
{
Q_OBJECT
Q_PROPERTY(bool spinning READ spinning WRITE setSpinning NOTIFY spinningChanged)
public:
Spinner();
bool spinning() const { return m_spinning; }
void setSpinning(bool spinning);
protected:
QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *);
signals:
void spinningChanged();
private:
bool m_spinning;
};
#endif // SQUIRCLE_H
|
/***************************************************************************
* This file is part of the propertyEditor project *
* Copyright (C) 2008 by BogDan Vatra *
* bog_dan_ro@yahoo.com *
** GNU General Public License Usage **
* *
* This library 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. *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* *
** GNU Lesser General Public License **
* *
* This library is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library. *
* If not, see <http://www.gnu.org/licenses/>. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
****************************************************************************/
#ifndef PIXMAP_H
#define PIXMAP_H
#include <propertyinterface.h>
using namespace PropertyEditor;
class Pixmap : public PropertyInterface
{
Q_OBJECT
Q_INTERFACES(PropertyEditor::PropertyInterface);
public:
Pixmap(QObject* parent = 0, QObject* object = 0, int property = -1, const PropertyModel * propertyModel = 0);
QWidget* createEditor(QWidget * parent, const QModelIndex & index);
QVariant data(const QModelIndex & index);
bool setData(QVariant data, const QModelIndex & index);
void setEditorData(QWidget * /*editor*/, const QModelIndex & /*index*/){};
bool canHandle(QObject * object, int property)const;
PropertyInterface* createInstance(QObject * object, int property, const PropertyModel * propertyModel) const;
public slots:
void chooseClicked();
};
#endif
|
#ifndef _GB19056_CALL_BACK_INTERFACE_H_
#define _GB19056_CALL_BACK_INTERFACE_H_
class GB19056CallBackInterface
{
public:
virtual int FileExistNotify() = 0;
virtual int ProgressNotify(int current_cmd, int total_cmd) = 0;
};
#endif
|
/*************************************************************************\
* Copyright (C) Michael Kerrisk, 2014. *
* *
* This program is free software. You may use, modify, and redistribute it *
* under the terms of the GNU Affero General Public License as published *
* by the Free Software Foundation, either version 3 or (at your option) *
* any later version. This program is distributed without any warranty. *
* See the file COPYING.agpl-v3 for details. *
\*************************************************************************/
/* Listing 52-7 */
#include <pthread.h>
#include <mqueue.h>
#include <fcntl.h> /* For definition of O_NONBLOCK */
#include "tlpi_hdr.h"
static void notifySetup(mqd_t *mqdp);
static void /* Thread notification function */
threadFunc(union sigval sv)
{
ssize_t numRead;
mqd_t *mqdp;
void *buffer;
struct mq_attr attr;
mqdp = sv.sival_ptr;
/* Determine mq_msgsize for message queue, and allocate an input buffer
of that size */
if (mq_getattr(*mqdp, &attr) == -1)
errExit("mq_getattr");
buffer = malloc(attr.mq_msgsize);
if (buffer == NULL)
errExit("malloc");
notifySetup(mqdp);
while ((numRead = mq_receive(*mqdp, buffer, attr.mq_msgsize, NULL)) >= 0)
printf("Read %ld bytes\n", (long) numRead);
if (errno != EAGAIN) /* Unexpected error */
errExit("mq_receive");
free(buffer);
}
static void
notifySetup(mqd_t *mqdp)
{
struct sigevent sev;
sev.sigev_notify = SIGEV_THREAD; /* Notify via thread */
sev.sigev_notify_function = threadFunc;
sev.sigev_notify_attributes = NULL;
/* Could be pointer to pthread_attr_t structure */
sev.sigev_value.sival_ptr = mqdp; /* Argument to threadFunc() */
if (mq_notify(*mqdp, &sev) == -1)
errExit("mq_notify");
}
int
main(int argc, char *argv[])
{
mqd_t mqd;
if (argc != 2 || strcmp(argv[1], "--help") == 0)
usageErr("%s mq-name\n", argv[0]);
mqd = mq_open(argv[1], O_RDONLY | O_NONBLOCK);
if (mqd == (mqd_t) -1)
errExit("mq_open");
notifySetup(&mqd);
pause(); /* Wait for notifications via thread function */
}
|
/****************************************************************\
* *
* Copyright (C) 2007 by Markus Duft <markus.duft@salomon.at> *
* *
* This file is part of parity. *
* *
* parity 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. *
* *
* parity 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 parity. If not, *
* see <http://www.gnu.org/licenses/>. *
* *
\****************************************************************/
#include "LoaderHelper.h"
#include "LoaderLog.h"
#include <internal/pcrt.h>
char* LoaderFormatErrorMessage(unsigned int error) {
char* ptrMsg = 0;
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
error,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPSTR)&ptrMsg,
0, NULL );
if(ptrMsg)
ptrMsg[strlen(ptrMsg) - 2] = 0; // newline.
return ptrMsg;
}
void LoaderWriteLastWindowsError()
{
char* ptrMsg = LoaderFormatErrorMessage(GetLastError());
LogWarning("windows reports the following error: %s\n", ptrMsg);
LocalFree(ptrMsg);
}
const char* LoaderConvertPathToNative(const char* ptr)
{
return PcrtPathToNative(ptr);
}
|
/*
* Milkymist SoC (Software)
* Copyright (C) 2007, 2008, 2009, 2010, 2011 Sebastien Bourdeauducq
*
* 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, version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __HW_VGA_H
#define __HW_VGA_H
#include <hw/common.h>
#define CSR_VGA_RESET MMPTR(0xe0003000)
#define VGA_RESET (0x01)
#define CSR_VGA_HRES MMPTR(0xe0003004)
#define CSR_VGA_HSYNC_START MMPTR(0xe0003008)
#define CSR_VGA_HSYNC_END MMPTR(0xe000300C)
#define CSR_VGA_HSCAN MMPTR(0xe0003010)
#define CSR_VGA_VRES MMPTR(0xe0003014)
#define CSR_VGA_VSYNC_START MMPTR(0xe0003018)
#define CSR_VGA_VSYNC_END MMPTR(0xe000301C)
#define CSR_VGA_VSCAN MMPTR(0xe0003020)
#define CSR_VGA_BASEADDRESS MMPTR(0xe0003024)
#define CSR_VGA_BASEADDRESS_ACT MMPTR(0xe0003028)
#define CSR_VGA_BURST_COUNT MMPTR(0xe000302C)
#define CSR_VGA_DDC MMPTR(0xe0003030)
#define CSR_VGA_CLKSEL MMPTR(0xe0003034)
#define VGA_DDC_SDAIN (0x1)
#define VGA_DDC_SDAOUT (0x2)
#define VGA_DDC_SDAOE (0x4)
#define VGA_DDC_SDC (0x8)
#endif /* __HW_VGA_H */
|
static char rcsid[] = "$Id$";
/*
* $TSUKUBA_Release: Omni OpenMP Compiler 3 $
* $TSUKUBA_Copyright:
* PLEASE DESCRIBE LICENSE AGREEMENT HERE
* $
*/
/* firstprivate 027 :
* firstprivate Àë¸À¤·¤¿ÊÑ¿ô¤òfor loop ¤Î¥«¥¦¥ó¥¿¤Ë»ÈÍÑ¡£
*/
#include <omp.h>
#include "omni.h"
#define MAGICNO 100
int errors = 0;
int thds;
int prvt;
main ()
{
int sum = 0;
thds = omp_get_max_threads ();
if (thds == 1) {
printf ("should be run this program on multi threads.\n");
exit (0);
}
omp_set_dynamic (0);
#pragma omp parallel
{
#pragma omp for firstprivate(prvt)
for (prvt=0; prvt<thds; prvt ++) {
#pragma omp critical
sum += 1;
}
}
if (sum != thds) {
errors += 1;
}
if (errors == 0) {
printf ("firstprivate 027 : SUCCESS\n");
return 0;
} else {
printf ("firstprivate 027 : FAILED\n");
return 1;
}
}
|
/*-
* Copyright (c) 2014 Peter Tworek
* 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 author nor the names of any co-contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef YTLOCALVIDEOMANAGER_H
#define YTLOCALVIDEOMANAGER_H
#include <QSharedPointer>
#include <QScopedPointer>
#include <QNetworkReply>
#include <QWeakPointer>
#include <QObject>
#include <QMutex>
#include <QUrl>
#include <QMap>
class QNetworkAccessManager;
class YTLocalVideoData;
class YTDownloadInfo;
class YTLocalVideoManager: public QObject
{
Q_OBJECT
public:
static YTLocalVideoManager& instance();
QSharedPointer<YTLocalVideoData> getDataForVideo(QString videoId);
void download(QSharedPointer<YTLocalVideoData>);
void removeDownload(QString videoId);
void pauseDownload(QString videoId);
void resumeDownload(QString videoId);
void downloadSettingsChanged();
signals:
// Notifications for the UI
void downloadFinished(QString video);
void downloadFailed(QString video);
private slots:
void onDownloadFinished(YTDownloadInfo*);
void onDownloadFailed(YTDownloadInfo*);
void onVideoDataDestroyed(QString videoId);
void onOnlineChanged(bool);
void onCellularChanged(bool);
void onProcessQueuedDownloads();
void onDownloadSettingsChanged();
void onRestoreDownloads();
void onDownload(QSharedPointer<YTLocalVideoData> data);
void onRemoveDownload(QString videoId);
void onPauseDownload(QString videoId);
void onResumeDownload(QString videoId);
private:
explicit YTLocalVideoManager(QObject *parent = 0);
void processQueuedDownloads();
void stopInProgressDownloads();
typedef QList<YTDownloadInfo*> YTDownloadInfoList;
typedef QMap<QString, QWeakPointer<YTLocalVideoData> > YTManagedVideosMap;
QMutex _managedVideosMutex;
YTDownloadInfoList _queuedDownloads;
YTDownloadInfoList _inProgressDownloads;
YTDownloadInfoList _pausedDownloads;
YTManagedVideosMap _managedVideos;
QNetworkAccessManager* _networkAccessManager;
bool _queueProcessingScheduled;
Q_DISABLE_COPY(YTLocalVideoManager)
};
#endif // YTVIDEODOWNLOADER_H
|
#pragma once
#include "il2cpp-config.h"
#ifndef _MSC_VER
# include <alloca.h>
#else
# include <malloc.h>
#endif
#include <stdint.h>
#include "mscorlib_System_Object2689449295.h"
#include "mscorlib_System_Security_RuntimeDeclSecurityEntry1853010450.h"
// System.AppDomain
struct AppDomain_t2719102437;
// System.Reflection.MethodInfo
struct MethodInfo_t;
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.Security.RuntimeSecurityFrame
struct RuntimeSecurityFrame_t1629715161 : public Il2CppObject
{
public:
// System.AppDomain System.Security.RuntimeSecurityFrame::domain
AppDomain_t2719102437 * ___domain_0;
// System.Reflection.MethodInfo System.Security.RuntimeSecurityFrame::method
MethodInfo_t * ___method_1;
// System.Security.RuntimeDeclSecurityEntry System.Security.RuntimeSecurityFrame::assert
RuntimeDeclSecurityEntry_t1853010450 ___assert_2;
// System.Security.RuntimeDeclSecurityEntry System.Security.RuntimeSecurityFrame::deny
RuntimeDeclSecurityEntry_t1853010450 ___deny_3;
// System.Security.RuntimeDeclSecurityEntry System.Security.RuntimeSecurityFrame::permitonly
RuntimeDeclSecurityEntry_t1853010450 ___permitonly_4;
public:
inline static int32_t get_offset_of_domain_0() { return static_cast<int32_t>(offsetof(RuntimeSecurityFrame_t1629715161, ___domain_0)); }
inline AppDomain_t2719102437 * get_domain_0() const { return ___domain_0; }
inline AppDomain_t2719102437 ** get_address_of_domain_0() { return &___domain_0; }
inline void set_domain_0(AppDomain_t2719102437 * value)
{
___domain_0 = value;
Il2CppCodeGenWriteBarrier(&___domain_0, value);
}
inline static int32_t get_offset_of_method_1() { return static_cast<int32_t>(offsetof(RuntimeSecurityFrame_t1629715161, ___method_1)); }
inline MethodInfo_t * get_method_1() const { return ___method_1; }
inline MethodInfo_t ** get_address_of_method_1() { return &___method_1; }
inline void set_method_1(MethodInfo_t * value)
{
___method_1 = value;
Il2CppCodeGenWriteBarrier(&___method_1, value);
}
inline static int32_t get_offset_of_assert_2() { return static_cast<int32_t>(offsetof(RuntimeSecurityFrame_t1629715161, ___assert_2)); }
inline RuntimeDeclSecurityEntry_t1853010450 get_assert_2() const { return ___assert_2; }
inline RuntimeDeclSecurityEntry_t1853010450 * get_address_of_assert_2() { return &___assert_2; }
inline void set_assert_2(RuntimeDeclSecurityEntry_t1853010450 value)
{
___assert_2 = value;
}
inline static int32_t get_offset_of_deny_3() { return static_cast<int32_t>(offsetof(RuntimeSecurityFrame_t1629715161, ___deny_3)); }
inline RuntimeDeclSecurityEntry_t1853010450 get_deny_3() const { return ___deny_3; }
inline RuntimeDeclSecurityEntry_t1853010450 * get_address_of_deny_3() { return &___deny_3; }
inline void set_deny_3(RuntimeDeclSecurityEntry_t1853010450 value)
{
___deny_3 = value;
}
inline static int32_t get_offset_of_permitonly_4() { return static_cast<int32_t>(offsetof(RuntimeSecurityFrame_t1629715161, ___permitonly_4)); }
inline RuntimeDeclSecurityEntry_t1853010450 get_permitonly_4() const { return ___permitonly_4; }
inline RuntimeDeclSecurityEntry_t1853010450 * get_address_of_permitonly_4() { return &___permitonly_4; }
inline void set_permitonly_4(RuntimeDeclSecurityEntry_t1853010450 value)
{
___permitonly_4 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
|
//
// SectionTableViewController.h
// ePubReader
//
// Created by Mark Oliver Baltazar on 2/24/15.
// Copyright (c) 2015 Cambridge University Press. All rights reserved.
//
#import <UIKit/UIKit.h>
@class PageViewController;
@interface SectionTableViewController : UITableViewController
@property (strong, nonatomic) PageViewController *detailViewController;
@end
|
/*
* Copyright (c) 2014-2015, Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* * Neither the name of Intel Corporation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY LOG OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* simple_copy.c -- show how to use pmem_memcpy_persist()
*
* usage: simple_copy src-file dst-file
*
* Reads 4k from src-file and writes it to dst-file.
*/
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <libpmem.h>
/* just copying 4k to pmem for this example */
#define BUF_LEN 4096
int
main(int argc, char *argv[])
{
int srcfd;
int dstfd;
char buf[BUF_LEN];
char *pmemaddr;
int is_pmem;
int cc;
if (argc != 3) {
fprintf(stderr, "usage: %s src-file dst-file\n", argv[0]);
exit(1);
}
/* open src-file */
if ((srcfd = open(argv[1], O_RDONLY)) < 0) {
perror(argv[1]);
exit(1);
}
/* create a pmem file */
if ((dstfd = open(argv[2], O_CREAT|O_EXCL|O_RDWR, 0666)) < 0) {
perror(argv[2]);
exit(1);
}
/* allocate the pmem */
if ((errno = posix_fallocate(dstfd, 0, BUF_LEN)) != 0) {
perror("posix_fallocate");
exit(1);
}
/* memory map it */
if ((pmemaddr = pmem_map(dstfd)) == NULL) {
perror("pmem_map");
exit(1);
}
close(dstfd);
/* determine if range is true pmem */
is_pmem = pmem_is_pmem(pmemaddr, BUF_LEN);
/* read up to BUF_LEN from srcfd */
if ((cc = read(srcfd, buf, BUF_LEN)) < 0) {
pmem_unmap(pmemaddr, BUF_LEN);
perror("read");
exit(1);
}
/* write it to the pmem */
if (is_pmem) {
pmem_memcpy_persist(pmemaddr, buf, cc);
} else {
memcpy(pmemaddr, buf, cc);
pmem_msync(pmemaddr, cc);
}
close(srcfd);
pmem_unmap(pmemaddr, BUF_LEN);
exit(0);
}
|
// Base32 implementation
//
// Copyright 2010 Google Inc.
// Author: Markus Gutschke
//
// 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.
//
// Encode and decode from base32 encoding using the following alphabet:
// ABCDEFGHIJKLMNOPQRSTUVWXYZ234567
// This alphabet is documented in RFC 4648/3548
//
// We allow white-space and hyphens, but all other characters are considered
// invalid.
//
// All functions return the number of output bytes or -1 on error. If the
// output buffer is too small, the result will silently be truncated.
#ifndef _BASE32_H_
#define _BASE32_H_
#include <stdint.h>
int base32_decode(const uint8_t *encoded, uint8_t *result, int bufSize)
__attribute__((visibility("hidden")));
int base32_encode(const uint8_t *data, int length, uint8_t *result,
int bufSize)
__attribute__((visibility("hidden")));
#endif /* _BASE32_H_ */
|
/**
* FreeRDP: A Remote Desktop Protocol Implementation
* Device Redirection Virtual Channel
*
* Copyright 2010-2011 Vic Lee
* Copyright 2010-2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
* Copyright 2015 Thincast Technologies GmbH
* Copyright 2015 DI (FH) Martin Haimberger <martin.haimberger@thincast.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <freerdp/config.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <winpr/crt.h>
#include <winpr/stream.h>
#include <freerdp/utils/rdpdr_utils.h>
#include "rdpdr_main.h"
#include "devman.h"
#include "irp.h"
/**
* Function description
*
* @return 0 on success, otherwise a Win32 error code
*/
static UINT irp_free(IRP* irp)
{
if (!irp)
return CHANNEL_RC_OK;
Stream_Free(irp->input, TRUE);
Stream_Free(irp->output, TRUE);
_aligned_free(irp);
return CHANNEL_RC_OK;
}
/**
* Function description
*
* @return 0 on success, otherwise a Win32 error code
*/
static UINT irp_complete(IRP* irp)
{
size_t pos;
rdpdrPlugin* rdpdr;
UINT error;
rdpdr = (rdpdrPlugin*)irp->devman->plugin;
pos = Stream_GetPosition(irp->output);
Stream_SetPosition(irp->output, RDPDR_DEVICE_IO_RESPONSE_LENGTH - 4);
Stream_Write_UINT32(irp->output, irp->IoStatus); /* IoStatus (4 bytes) */
Stream_SetPosition(irp->output, pos);
error = rdpdr_send(rdpdr, irp->output);
irp->output = NULL;
irp_free(irp);
return error;
}
IRP* irp_new(DEVMAN* devman, wStream* s, UINT* error)
{
IRP* irp;
DEVICE* device;
UINT32 DeviceId;
if (Stream_GetRemainingLength(s) < 20)
{
if (error)
*error = ERROR_INVALID_DATA;
return NULL;
}
Stream_Read_UINT32(s, DeviceId); /* DeviceId (4 bytes) */
device = devman_get_device_by_id(devman, DeviceId);
if (!device)
{
WLog_WARN(TAG, "devman_get_device_by_id failed!");
if (error)
*error = CHANNEL_RC_OK;
return NULL;
}
irp = (IRP*)_aligned_malloc(sizeof(IRP), MEMORY_ALLOCATION_ALIGNMENT);
if (!irp)
{
WLog_ERR(TAG, "_aligned_malloc failed!");
if (error)
*error = CHANNEL_RC_NO_MEMORY;
return NULL;
}
ZeroMemory(irp, sizeof(IRP));
irp->input = s;
irp->device = device;
irp->devman = devman;
Stream_Read_UINT32(s, irp->FileId); /* FileId (4 bytes) */
Stream_Read_UINT32(s, irp->CompletionId); /* CompletionId (4 bytes) */
Stream_Read_UINT32(s, irp->MajorFunction); /* MajorFunction (4 bytes) */
Stream_Read_UINT32(s, irp->MinorFunction); /* MinorFunction (4 bytes) */
irp->output = Stream_New(NULL, 256);
if (!irp->output)
{
WLog_ERR(TAG, "Stream_New failed!");
_aligned_free(irp);
if (error)
*error = CHANNEL_RC_NO_MEMORY;
return NULL;
}
if (!rdpdr_write_iocompletion_header(irp->output, DeviceId, irp->CompletionId, 0))
{
Stream_Free(irp->output, TRUE);
_aligned_free(irp);
if (error)
*error = CHANNEL_RC_NO_MEMORY;
return NULL;
}
irp->Complete = irp_complete;
irp->Discard = irp_free;
irp->thread = NULL;
irp->cancelled = FALSE;
if (error)
*error = CHANNEL_RC_OK;
return irp;
}
|
/*****************************************************************************\
* *
* Filename fstat.c *
* *
* Description: Redefinitions of standard C library's fstat() *
* *
* Notes: *
* *
* History: *
* 2014-06-24 JFL Created this module. *
* *
* © Copyright 2016 Hewlett Packard Enterprise Development LP *
* Licensed under the Apache 2.0 license - www.apache.org/licenses/LICENSE-2.0 *
\*****************************************************************************/
#define _CRT_SECURE_NO_WARNINGS 1 /* Avoid Visual C++ security warnings */
#define _UTF8_LIB_SOURCE /* Generate the UTF-8 version of routines */
/* Microsoft C libraries include files */
#include <errno.h>
#include <stdio.h>
#include <string.h>
/* MsvcLibX library extensions */
#include <sys/stat.h>
#include "debugm.h"
#include <stdint.h>
#if defined(_MSDOS)
/* Nothing needs to be redefined */
#endif /* defined(_MSDOS) */
#if defined(_WIN32)
/* ------------ Display the *stat* macro values at compile time ------------ */
#pragma message(MACRODEF(_MSVC_stat))
#pragma message(MACRODEF(_MSVC_fstat))
#pragma message(MACRODEF(_MSVC_lstat))
#pragma message(MACRODEF(_MSVC_stat64))
#if _MSVCLIBX_STAT_DEFINED
#pragma message(MACRODEF(_LIBX_stat))
#pragma message(MACRODEF(_LIBX_stat64))
#endif
#pragma message(MACRODEF(stat))
#pragma message(MACRODEF(fstat))
#pragma message(MACRODEF(lstat))
#if defined(_LARGEFILE_SOURCE64)
#pragma message(MACRODEF(stat64))
#pragma message(MACRODEF(fstat64))
#pragma message(MACRODEF(lstat64))
#endif
#include <windows.h>
/*---------------------------------------------------------------------------*\
* *
| Function: fstat |
| |
| Description: Redefine the standard _fstatXY() functions |
| |
| Parameters: int nFile The file handle |
| struct stat *buf Output buffer |
| |
| Returns: 0 = Success, -1 = Failure |
| |
| Notes: See sys/stat.h for a description of how the stat and fstat|
| macros work. |
| |
| History: |
| 2014-06-24 JFL Created this routine |
* *
\*---------------------------------------------------------------------------*/
int fstat(int nFile, struct stat *pStat) {
int iErr;
struct _MSVC_stat msStat;
DEBUG_CODE(
struct tm *pTime;
char szTime[100];
)
DEBUG_ENTER((STRINGIZE(fstat) "(%d, 0x%p);\n", nFile, pStat));
iErr = _MSVC_fstat(nFile, &msStat);
if (!iErr) {
ZeroMemory(pStat, sizeof(struct stat));
pStat->st_mode = msStat.st_mode;
pStat->st_size = msStat.st_size;
pStat->st_ctime =
#undef st_ctime
msStat.st_ctime;
pStat->st_mtime =
#undef st_mtime
msStat.st_mtime;
pStat->st_atime =
#undef st_atime
msStat.st_atime;
DEBUG_CODE(
pTime = LocalFileTime(&(msStat.st_mtime));
strftime(szTime, sizeof(szTime), "%Y-%m-%d %H:%M:%S", pTime);
)
RETURN_INT_COMMENT(0, ("%s mode = 0x%04X size = %I64d bytes\n", szTime, pStat->st_mode, (__int64)(pStat->st_size)));
}
/* TO DO: Get the nanosecond time resolution using Windows functions */
RETURN_INT_COMMENT(iErr, ("%s\n", strerror(errno)));
}
#endif /* _WIN32 */
|
// -------------------------------------------------------------------------
// @FileName : NFIPluginManager.h
// @Author : LvSheng.Huang
// @Date : 2012-12-15
// @Module : NFIPluginManager
//
// -------------------------------------------------------------------------
#ifndef _NFI_PLUGIN_MANAGER_H_
#define _NFI_PLUGIN_MANAGER_H_
#include "NFIActor.h"
#include "NFILogicModule.h"
#include "NFIActorManager.h"
class NFIPlugin;
class NFIPluginManager : public NFILogicModule
{
public:
NFIPluginManager(NFIActorManager* pManager)
{
}
virtual bool LoadPlugin() = 0;
virtual void Registered(NFIPlugin* plugin) = 0;
virtual void UnsRegistered(NFIPlugin* plugin) = 0;
virtual NFIPlugin* FindPlugin(const std::string& strPluginName) = 0;
virtual void AddModule(const std::string& strModuleName, NFILogicModule* pModule) = 0;
virtual void RemoveModule(const std::string& strModuleName) = 0;
virtual NFILogicModule* FindModule(const std::string& strModuleName) = 0;
virtual bool ReInitialize() = 0;
virtual NFIActorManager* GetActorManager() = 0;
virtual void HandlerEx(const NFIActorMessage& message, const Theron::Address from) = 0;
virtual int AppID() = 0;
template<typename T>
T* FindModule()
{
// std::string strClassName = typeid(T).name();
// return dynamic_cast<T*>(pPluginManager->FindModule(strClassName));
return NULL;
}
};
#endif
|
/* 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 GFXCOWSURFACEWRAPPER
#define GFXCOWSURFACEWRAPPER
#include "gfxASurface.h"
#include "nsISupportsImpl.h"
#include "nsAutoPtr.h"
class gfxImageSurface;
/**
* Provides a cross thread wrapper for a gfxImageSurface
* that has copy-on-write schemantics.
*
* Only the owner thread can write to the surface and aquire
* read locks.
*
* OMTC Usage:
* 1) Content creates a writable copy of this surface
* wrapper which be optimized to the same wrapper if there
* are no readers.
* 2) The surface is sent from content to the compositor once
* or potentially many time, each increasing a read lock.
* 3) When the compositor has processed the surface and uploaded
* the content it then releases the read lock.
*/
class gfxReusableSurfaceWrapper {
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(gfxReusableSurfaceWrapper)
public:
/**
* Pass the gfxASurface to the wrapper.
* The wrapper should hold the only strong reference
* to the surface and its memebers.
*/
gfxReusableSurfaceWrapper(gfxImageSurface* aSurface);
~gfxReusableSurfaceWrapper();
const unsigned char* GetReadOnlyData() const {
NS_ABORT_IF_FALSE(mReadCount > 0, "Should have read lock");
return mSurfaceData;
}
const gfxASurface::gfxImageFormat& Format() { return mFormat; }
/**
* Get a writable copy of the image.
* If necessary this will copy the wrapper. If there are no contention
* the same wrapper will be returned.
*/
gfxReusableSurfaceWrapper* GetWritable(gfxImageSurface** aSurface);
/**
* A read only lock count is recorded, any attempts to
* call GetWritable() while this count is positive will
* create a new surface/wrapper pair.
*/
void ReadLock();
void ReadUnlock();
private:
NS_DECL_OWNINGTHREAD
nsRefPtr<gfxImageSurface> mSurface;
const gfxASurface::gfxImageFormat mFormat;
const unsigned char* mSurfaceData;
PRInt32 mReadCount;
};
#endif // GFXCOWSURFACEWRAPPER
|
/*
* Copyright (c) 2018, Piotr Mienkowski
*
* SPDX-License-Identifier: Apache-2.0
*/
#define DT_DRV_COMPAT silabs_gecko_flash_controller
#define SOC_NV_FLASH_NODE DT_INST(0, soc_nv_flash)
#include <stddef.h>
#include <string.h>
#include <errno.h>
#include <kernel.h>
#include <device.h>
#include <em_msc.h>
#include <drivers/flash.h>
#include <soc.h>
#define LOG_LEVEL CONFIG_FLASH_LOG_LEVEL
#include <logging/log.h>
LOG_MODULE_REGISTER(flash_gecko);
struct flash_gecko_data {
struct k_sem mutex;
};
static const struct flash_parameters flash_gecko_parameters = {
.write_block_size = DT_PROP(SOC_NV_FLASH_NODE, write_block_size),
.erase_value = 0xff,
};
#define DEV_NAME(dev) ((dev)->name)
#define DEV_DATA(dev) \
((struct flash_gecko_data *const)(dev)->data)
static bool write_range_is_valid(off_t offset, uint32_t size);
static bool read_range_is_valid(off_t offset, uint32_t size);
static int erase_flash_block(off_t offset, size_t size);
static void flash_gecko_write_protection(bool enable);
static int flash_gecko_read(const struct device *dev, off_t offset,
void *data,
size_t size)
{
if (!read_range_is_valid(offset, size)) {
return -EINVAL;
}
if (!size) {
return 0;
}
memcpy(data, (uint8_t *)CONFIG_FLASH_BASE_ADDRESS + offset, size);
return 0;
}
static int flash_gecko_write(const struct device *dev, off_t offset,
const void *data, size_t size)
{
struct flash_gecko_data *const dev_data = DEV_DATA(dev);
MSC_Status_TypeDef msc_ret;
void *address;
int ret = 0;
if (!write_range_is_valid(offset, size)) {
return -EINVAL;
}
if (!size) {
return 0;
}
k_sem_take(&dev_data->mutex, K_FOREVER);
flash_gecko_write_protection(false);
address = (uint8_t *)CONFIG_FLASH_BASE_ADDRESS + offset;
msc_ret = MSC_WriteWord(address, data, size);
if (msc_ret < 0) {
ret = -EIO;
}
flash_gecko_write_protection(true);
k_sem_give(&dev_data->mutex);
return ret;
}
static int flash_gecko_erase(const struct device *dev, off_t offset,
size_t size)
{
struct flash_gecko_data *const dev_data = DEV_DATA(dev);
int ret;
if (!read_range_is_valid(offset, size)) {
return -EINVAL;
}
if ((offset % FLASH_PAGE_SIZE) != 0) {
LOG_ERR("offset 0x%lx: not on a page boundary", (long)offset);
return -EINVAL;
}
if ((size % FLASH_PAGE_SIZE) != 0) {
LOG_ERR("size %zu: not multiple of a page size", size);
return -EINVAL;
}
if (!size) {
return 0;
}
k_sem_take(&dev_data->mutex, K_FOREVER);
flash_gecko_write_protection(false);
ret = erase_flash_block(offset, size);
flash_gecko_write_protection(true);
k_sem_give(&dev_data->mutex);
return ret;
}
static void flash_gecko_write_protection(bool enable)
{
if (enable) {
/* Lock the MSC module. */
MSC->LOCK = 0;
} else {
/* Unlock the MSC module. */
#if defined(MSC_LOCK_LOCKKEY_UNLOCK)
MSC->LOCK = MSC_LOCK_LOCKKEY_UNLOCK;
#else
MSC->LOCK = MSC_UNLOCK_CODE;
#endif
}
}
/* Note:
* - A flash address to write to must be aligned to words.
* - Number of bytes to write must be divisible by 4.
*/
static bool write_range_is_valid(off_t offset, uint32_t size)
{
return read_range_is_valid(offset, size)
&& (offset % sizeof(uint32_t) == 0)
&& (size % 4 == 0U);
}
static bool read_range_is_valid(off_t offset, uint32_t size)
{
return (offset + size) <= (CONFIG_FLASH_SIZE * 1024);
}
static int erase_flash_block(off_t offset, size_t size)
{
MSC_Status_TypeDef msc_ret;
void *address;
int ret = 0;
for (off_t tmp = offset; tmp < offset + size; tmp += FLASH_PAGE_SIZE) {
address = (uint8_t *)CONFIG_FLASH_BASE_ADDRESS + tmp;
msc_ret = MSC_ErasePage(address);
if (msc_ret < 0) {
ret = -EIO;
break;
}
}
return ret;
}
#if CONFIG_FLASH_PAGE_LAYOUT
static const struct flash_pages_layout flash_gecko_0_pages_layout = {
.pages_count = DT_REG_SIZE(SOC_NV_FLASH_NODE) /
DT_PROP(SOC_NV_FLASH_NODE, erase_block_size),
.pages_size = DT_PROP(SOC_NV_FLASH_NODE, erase_block_size),
};
void flash_gecko_page_layout(const struct device *dev,
const struct flash_pages_layout **layout,
size_t *layout_size)
{
*layout = &flash_gecko_0_pages_layout;
*layout_size = 1;
}
#endif /* CONFIG_FLASH_PAGE_LAYOUT */
static const struct flash_parameters *
flash_gecko_get_parameters(const struct device *dev)
{
ARG_UNUSED(dev);
return &flash_gecko_parameters;
}
static int flash_gecko_init(const struct device *dev)
{
struct flash_gecko_data *const dev_data = DEV_DATA(dev);
k_sem_init(&dev_data->mutex, 1, 1);
MSC_Init();
/* Lock the MSC module. */
MSC->LOCK = 0;
LOG_INF("Device %s initialized", DEV_NAME(dev));
return 0;
}
static const struct flash_driver_api flash_gecko_driver_api = {
.read = flash_gecko_read,
.write = flash_gecko_write,
.erase = flash_gecko_erase,
.get_parameters = flash_gecko_get_parameters,
#ifdef CONFIG_FLASH_PAGE_LAYOUT
.page_layout = flash_gecko_page_layout,
#endif
};
static struct flash_gecko_data flash_gecko_0_data;
DEVICE_DT_INST_DEFINE(0, flash_gecko_init, device_pm_control_nop,
&flash_gecko_0_data, NULL, POST_KERNEL,
CONFIG_KERNEL_INIT_PRIORITY_DEVICE, &flash_gecko_driver_api);
|
/*
* ModSecurity, http://www.modsecurity.org/
* Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/)
*
* 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
*
* If any of the files related to licensing are missing or if you have any
* other questions related to licensing please contact Trustwave Holdings, Inc.
* directly using the email address security@modsecurity.org.
*
*/
#include <string>
#include "modsecurity/actions/action.h"
#include "src/actions/transformations/transformation.h"
#ifndef SRC_ACTIONS_TRANSFORMATIONS_TRIM_H_
#define SRC_ACTIONS_TRANSFORMATIONS_TRIM_H_
#ifdef __cplusplus
namespace modsecurity {
class Transaction;
namespace actions {
namespace transformations {
class Trim : public Transformation {
public:
explicit Trim(const std::string &action) ;
std::string evaluate(const std::string &exp,
Transaction *transaction) override;
std::string *ltrim(std::string *s);
std::string *rtrim(std::string *s);
std::string *trim(std::string *s);
};
} // namespace transformations
} // namespace actions
} // namespace modsecurity
#endif
#endif // SRC_ACTIONS_TRANSFORMATIONS_TRIM_H_
|
/*=========================================================================
*
* Copyright Leiden University Medical Center, Erasmus University Medical
* Center and contributors
*
* 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 InterfaceAcceptor_h
#define InterfaceAcceptor_h
#include "selxComponentBase.h"
namespace selx
{
// All SuperElastix Components inherit from their interfaces classes. The interface classes as defined in
// "selxInterfaces.h" are by default Providing. The InterfaceAcceptor class turns a Providing interface
// into an Accepting interface. For a SuperElastixComponent this differentiation is done by grouping the
// interfaces either in Providing<Interfaces...> or in Accepting<Interfaces...>
template< class InterfaceT >
class InterfaceAcceptor
{
public:
using Pointer = std::shared_ptr< InterfaceAcceptor< InterfaceT >>;
// Accept() is called by a succesfull Connect()
// The implementation of Accept() must be provided by component developers.
virtual int Accept( typename InterfaceT::Pointer ) = 0;
// Connect tries to connect this accepting interface with all interfaces of the provider component.
int Connect( ComponentBase::Pointer );
bool CanAcceptConnectionFrom( ComponentBase::ConstPointer );
std::shared_ptr< InterfaceT > GetAccepted()
{
return m_AcceptedInterface;
}
private:
std::shared_ptr< InterfaceT > m_AcceptedInterface;
};
} //end namespace selx
#ifndef ITK_MANUAL_INSTANTIATION
#include "selxInterfaceAcceptor.hxx"
#endif
#endif // InterfaceAcceptor_h
|
/*
Copyright 2018 Embedded Microprocessor Benchmark Consortium (EEMBC)
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.
Original Author: Shay Gal-on
*/
/* Topic: Description
This file contains declarations of the various benchmark functions.
*/
/* Configuration: TOTAL_DATA_SIZE
Define total size for data algorithms will operate on
*/
#ifndef TOTAL_DATA_SIZE
#define TOTAL_DATA_SIZE 2*1000
#endif
#define SEED_ARG 0
#define SEED_FUNC 1
#define SEED_VOLATILE 2
#define MEM_STATIC 0
#define MEM_MALLOC 1
#define MEM_STACK 2
#include "core_portme.h"
#if HAS_STDIO
#include <stdio.h>
#endif
#if HAS_PRINTF
#define ee_printf printf
#endif
/* Actual benchmark execution in iterate */
void *iterate(void *pres);
/* Typedef: secs_ret
For machines that have floating point support, get number of seconds as a double.
Otherwise an unsigned int.
*/
#if HAS_FLOAT
typedef double secs_ret;
#else
typedef ee_u32 secs_ret;
#endif
#if MAIN_HAS_NORETURN
#define MAIN_RETURN_VAL
#define MAIN_RETURN_TYPE void
#else
#define MAIN_RETURN_VAL 0
#define MAIN_RETURN_TYPE int
#endif
void start_time(void);
void stop_time(void);
CORE_TICKS get_time(void);
secs_ret time_in_secs(CORE_TICKS ticks);
/* Misc useful functions */
ee_u16 crcu8(ee_u8 data, ee_u16 crc);
ee_u16 crc16(ee_s16 newval, ee_u16 crc);
ee_u16 crcu16(ee_u16 newval, ee_u16 crc);
ee_u16 crcu32(ee_u32 newval, ee_u16 crc);
ee_u8 check_data_types();
void *portable_malloc(ee_size_t size);
void portable_free(void *p);
ee_s32 parseval(char *valstring);
/* Algorithm IDS */
#define ID_LIST (1<<0)
#define ID_MATRIX (1<<1)
#define ID_STATE (1<<2)
#define ALL_ALGORITHMS_MASK (ID_LIST|ID_MATRIX|ID_STATE)
#define NUM_ALGORITHMS 3
/* list data structures */
typedef struct list_data_s {
ee_s16 data16;
ee_s16 idx;
} list_data;
typedef struct list_head_s {
struct list_head_s *next;
struct list_data_s *info;
} list_head;
/*matrix benchmark related stuff */
#define MATDAT_INT 1
#if MATDAT_INT
typedef ee_s16 MATDAT;
typedef ee_s32 MATRES;
#else
typedef ee_f16 MATDAT;
typedef ee_f32 MATRES;
#endif
typedef struct MAT_PARAMS_S {
int N;
MATDAT *A;
MATDAT *B;
MATRES *C;
} mat_params;
/* state machine related stuff */
/* List of all the possible states for the FSM */
typedef enum CORE_STATE {
CORE_START=0,
CORE_INVALID,
CORE_S1,
CORE_S2,
CORE_INT,
CORE_FLOAT,
CORE_EXPONENT,
CORE_SCIENTIFIC,
NUM_CORE_STATES
} core_state_e ;
/* Helper structure to hold results */
typedef struct RESULTS_S {
/* inputs */
ee_s16 seed1; /* Initializing seed */
ee_s16 seed2; /* Initializing seed */
ee_s16 seed3; /* Initializing seed */
void *memblock[4]; /* Pointer to safe memory location */
ee_u32 size; /* Size of the data */
ee_u32 iterations; /* Number of iterations to execute */
ee_u32 execs; /* Bitmask of operations to execute */
struct list_head_s *list;
mat_params mat;
/* outputs */
ee_u16 crc;
ee_u16 crclist;
ee_u16 crcmatrix;
ee_u16 crcstate;
ee_s16 err;
/* ultithread specific */
core_portable port;
} core_results;
/* Multicore execution handling */
#if (MULTITHREAD>1)
ee_u8 core_start_parallel(core_results *res);
ee_u8 core_stop_parallel(core_results *res);
#endif
/* list benchmark functions */
list_head *core_list_init(ee_u32 blksize, list_head *memblock, ee_s16 seed);
ee_u16 core_bench_list(core_results *res, ee_s16 finder_idx);
/* state benchmark functions */
void core_init_state(ee_u32 size, ee_s16 seed, ee_u8 *p);
ee_u16 core_bench_state(ee_u32 blksize, ee_u8 *memblock,
ee_s16 seed1, ee_s16 seed2, ee_s16 step, ee_u16 crc);
/* matrix benchmark functions */
ee_u32 core_init_matrix(ee_u32 blksize, void *memblk, ee_s32 seed, mat_params *p);
ee_u16 core_bench_matrix(mat_params *p, ee_s16 seed, ee_u16 crc);
|
/*
* Copyright (c) 2008-2015, NVIDIA CORPORATION. All rights reserved.
*
* NVIDIA CORPORATION and its licensors retain all intellectual property
* and proprietary rights in and to this software, related documentation
* and any modifications thereto. Any use, reproduction, disclosure or
* distribution of this software and related documentation without an express
* license agreement from NVIDIA CORPORATION is strictly prohibited.
*/
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef GU_ENTITY_REPORT_H
#define GU_ENTITY_REPORT_H
#include "Ps.h"
#include "PxQueryReport.h"
namespace physx
{
namespace Gu
{
template<class T>
class EntityReport
{
public:
virtual ~EntityReport() {}
virtual PxAgain onEvent(PxU32 nbEntities, T* entities) = 0;
};
} // namespace Gu
}
#endif
|
//
// SeafAvatar.h
// seafilePro
//
// Created by Wang Wei on 4/11/14.
// Copyright (c) 2014 Seafile. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "SeafConnection.h"
#import "SeafTaskQueue.h"
@interface SeafAvatar : NSObject<SeafTask>
@property (nonatomic, readonly) NSString * accountIdentifier;
- (id)initWithConnection:(SeafConnection *)aConnection from:(NSString *)url toPath:(NSString *)path;
+ (void)clearCache;
@end
@interface SeafUserAvatar : SeafAvatar
- (id)initWithConnection:(SeafConnection *)aConnection username:(NSString *)username;
+ (NSString *)pathForAvatar:(SeafConnection *)conn username:(NSString *)username;
@end
|
../../Kiwi/Classes/Matchers/KWBeBetweenMatcher.h |
/*
Copyright (c) 2007 Cyrus Daboo. 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.
*/
// Header for CSpellEditDialog class
#ifndef __CSPELLEDITDIALOG__MULBERRY__
#define __CSPELLEDITDIALOG__MULBERRY__
#include <LDialogBox.h>
// Constants
// Panes
const PaneIDT paneid_SpellEditDialog = 20400;
const PaneIDT paneid_SpellEditDictName = 'DICT';
const PaneIDT paneid_SpellEditScroller = 'HSCR';
const PaneIDT paneid_SpellEditWordTop = 'WTOP';
const PaneIDT paneid_SpellEditWordBottom = 'WBTM';
const PaneIDT paneid_SpellEditList = 'LIST';
const PaneIDT paneid_SpellEditWord = 'WORD';
const PaneIDT paneid_SpellEditAdd = 'ADDW';
const PaneIDT paneid_SpellEditFind = 'FIND';
const PaneIDT paneid_SpellEditRemove = 'RMVE';
const PaneIDT paneid_SpellEditCancel = 'CANC';
// Mesages
const MessageT msg_SpellEditList = 'LIST';
const MessageT msg_SpellEditHScroll = 'SCRL';
const MessageT msg_SpellEditAdd = 'ADDW';
const MessageT msg_SpellEditFind = 'FIND';
const MessageT msg_SpellEditRemove = 'RMVE';
// Resources
const ResIDT RidL_CSpellEditDialogBtns = 20400;
// Classes
class CDictionaryPageScroller;
class CStaticText;
class CTextFieldX;
class LPushButton;
class CSpellPlugin;
class CTextTable;
class CSpellEditDialog : public LDialogBox
{
friend class CDictionaryPageScroller;
public:
enum { class_ID = 'EdDi' };
CSpellEditDialog();
CSpellEditDialog(LStream *inStream);
virtual ~CSpellEditDialog();
static bool PoseDialog(CSpellPlugin* speller);
protected:
virtual void FinishCreateSelf(void); // Do odds & ends
public:
virtual Boolean HandleKeyPress(const EventRecord &inKeyEvent);
virtual void ListenToMessage(MessageT inMessage, void *ioParam);
private:
CStaticText* mDictName;
CDictionaryPageScroller* mScroller;
CStaticText* mWordTop;
CStaticText* mWordBottom;
CTextTable* mList;
CTextFieldX* mWord;
LPushButton* mAdd;
LPushButton* mFind;
LPushButton* mRemove;
LPushButton* mCancel;
CSpellPlugin* mSpeller;
void SetSpeller(CSpellPlugin* speller); // Set the speller
void RotateDefault(void); // Rotate default button
void DoAdd(void); // Add word to dictionary
void DoFind(void); // Remove word from dicitonary
void DoRemove(void); // Remove word from dicitonary
};
#endif
|
// bslmf_isreference.h -*-C++-*-
#ifndef INCLUDED_BSLMF_ISREFERENCE
#define INCLUDED_BSLMF_ISREFERENCE
#include <bsls_ident.h>
BSLS_IDENT("$Id: $")
//@PURPOSE: Provide a meta-function to test reference types.
//
//@CLASSES:
// bsl::is_reference: standard meta-function for testing reference types
// bsl::is_reference_v: the result value of the standard meta-function
//
//@SEE_ALSO:
//
//@DESCRIPTION: This component defines a meta-function, 'bsl::is_reference' and
// a template variable 'bsl::is_reference_v', that represents the result value
// of the 'bsl::is_class' meta-function, that may be used to query whether a
// type is an (lvalue or rvalue) reference type.
//
// 'bsl::is_reference' meets the requirements of the 'is_reference' template
// defined in the C++11 standard [meta.unary.comp].
//
// Note that the template variable 'is_reference_v' is defined in the C++17
// standard as an inline variable. If the current compiler supports the inline
// variable C++17 compiler feature, 'bsl::is_reference_v' is defined as an
// 'inline constexpr bool' variable. Otherwise, if the compiler supports the
// variable templates C++14 compiler feature, 'bsl::is_reference_v' is defined
// as a non-'const' 'constexpr bool' variable. See
// 'BSLS_COMPILERFEATURES_SUPPORT_INLINE_VARIABLES' and
// 'BSLS_COMPILERFEATURES_SUPPORT_VARIABLE_TEMPLATES' macros in
// bsls_compilerfeatures component for details.
//
///Usage
///-----
// In this section we show intended use of this component.
//
///Example 1: Verify Reference Types
///- - - - - - - - - - - - - - - - -
// Suppose that we want to assert whether a set of types are (lvalue or rvalue)
// reference types.
//
// Now, we instantiate the 'bsl::is_reference' template for a non-reference
// type, an lvalue reference type, and an rvalue reference type, and assert the
// 'value' static data member of each instantiation:
//..
// assert(false == bsl::is_reference<int>::value);
// assert(true == bsl::is_reference<int&>::value);
//#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES)
// assert(true == bsl::is_reference<int&&>::value);
//#endif
//..
// Note that rvalue reference is a feature introduced in the C++11 standand,
// and may not be supported by all compilers.
//
// Also note that if the current compiler supports the variable templates C++14
// feature then we can re-write the snippet of code above using the
// 'bsl::is_reference_v' variable as follows:
//..
//#ifdef BSLS_COMPILERFEATURES_SUPPORT_VARIABLE_TEMPLATES
// assert(false == bsl::is_reference_v<int>);
// assert(true == bsl::is_reference_v<int&>);
// assert(true == bsl::is_reference_v<int&&>);
//#endif
//..
#include <bslscm_version.h>
#include <bslmf_integralconstant.h>
#include <bsls_compilerfeatures.h>
#include <bsls_keyword.h>
#ifndef BDE_DONT_ALLOW_TRANSITIVE_INCLUDES
#include <bslmf_islvaluereference.h>
#include <bslmf_isrvaluereference.h>
#endif // BDE_DONT_ALLOW_TRANSITIVE_INCLUDES
namespace bsl {
// ===================
// struct is_reference
// ===================
// IMPLEMENTATION NOTE: We originally implemented this trait in terms of
// 'is_lvalue_reference' and 'is_rvalue_reference' but ran into an issue on
// Sun where the compiler was reporting that the maximum depth of template
// expansion was being exceeded.
template <class TYPE> struct is_reference : false_type {
// This 'struct' template implements the 'is_reference' meta-function
// defined in the C++11 standard [meta.unary.comp] to determine if the
// (template parameter) 'TYPE' is a (lvalue or rvalue) reference type.
//
// This 'struct' derives from 'bsl::false_type' with specializations to
// follow for lvalue and rvalue references.
};
template <class TYPE>
struct is_reference<TYPE&> : true_type {
// This 'struct' template implements the 'is_reference' meta-function
// defined in the C++11 standard [meta.unary.comp] to determine if the
// (template parameter) 'TYPE' is a (lvalue or rvalue) reference type.
//
// This specialization for lvalue references derives from 'bsl::true_type'.
};
#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES)
template <class TYPE>
struct is_reference<TYPE&&> : true_type {
// This 'struct' template implements the 'is_reference' meta-function
// defined in the C++11 standard [meta.unary.comp] to determine if the
// (template parameter) 'TYPE' is a (lvalue or rvalue) reference type.
//
// This specialization for rvalue references derives from 'bsl::true_type.
};
#endif
#ifdef BSLS_COMPILERFEATURES_SUPPORT_VARIABLE_TEMPLATES
template <class TYPE>
BSLS_KEYWORD_INLINE_VARIABLE
constexpr bool is_reference_v = is_reference<TYPE>::value;
// This template variable represents the result value of the
// 'bsl::is_reference' meta-function.
#endif
} // close namespace bsl
#endif
// ----------------------------------------------------------------------------
// Copyright 2013 Bloomberg Finance L.P.
//
// 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.
// ----------------------------- END-OF-FILE ----------------------------------
|
#pragma once
#include "common/common/assert.h"
#include "common/common/logger.h"
#include "test/common/http/http2/http2_frame.h"
#include "test/fuzz/fuzz_runner.h"
#include "test/fuzz/utility.h"
#include "test/integration/h2_capture_fuzz.pb.h"
#include "test/integration/http_integration.h"
namespace Envoy {
class H2FuzzIntegrationTest : public HttpIntegrationTest {
public:
H2FuzzIntegrationTest(Network::Address::IpVersion version)
: HttpIntegrationTest(Http::CodecClient::Type::HTTP2, version) {}
void initialize() override;
void replay(const test::integration::H2CaptureFuzzTestCase&, bool ignore_response);
const std::chrono::milliseconds max_wait_ms_{10};
private:
void sendFrame(const test::integration::H2TestFrame&,
std::function<void(const Envoy::Http::Http2::Http2Frame&)>);
};
} // namespace Envoy
|
/* $NetBSD: lptest.c,v 1.10 2008/07/21 13:36:58 lukem Exp $ */
/*
* Copyright (c) 1983, 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. 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.
*/
#include <sys/cdefs.h>
#ifndef lint
__COPYRIGHT("@(#) Copyright (c) 1983, 1993\
The Regents of the University of California. All rights reserved.");
#if 0
static char sccsid[] = "@(#)lptest.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: lptest.c,v 1.10 2008/07/21 13:36:58 lukem Exp $");
#endif
#endif /* not lint */
#include <stdlib.h>
#include <stdio.h>
int main(int, char *[]);
/*
* lptest -- line printer test program (and other devices).
*/
int
main(int argc, char *argv[])
{
int len, count;
int i, j, fc, nc;
char outbuf[BUFSIZ];
setbuf(stdout, outbuf);
if (argc >= 2)
len = atoi(argv[1]);
else
len = 79;
if (argc >= 3)
count = atoi(argv[2]);
else
count = 200;
fc = ' ';
for (i = 0; i < count; i++) {
if (++fc == 0177)
fc = ' ';
nc = fc;
for (j = 0; j < len; j++) {
putchar(nc);
if (++nc == 0177)
nc = ' ';
}
putchar('\n');
}
(void)fflush(stdout);
exit(0);
}
|
/*
Author: Adam Austin
Date: 01/27/2017
*/
#ifndef ITEM_H
#define ITEM_H
#include <iostream>
#include <array>
class Item
{
public:
Item();
Item(std::string, double);
double getPrice();
std::string getProductName();
void setPrice(double);
void setProductName(std::string);
private:
double price;
std::string productName;
};
#endif // ITEM_H
|
// Copyright 2011 The Avalon Project Authors. All rights reserved.
// Use of this source code is governed by the Apache License 2.0
// that can be found in the LICENSE file.
// Author: grundmann@google.com (Steffen Grundmann)
// December 2011
#ifndef COMMON_PROBE_H_
#define COMMON_PROBE_H_
class Probe {
public:
Probe();
void Reset();
void Measure(double in);
double Value();
int Samples();
private:
int samples_;
double sum_;
};
#endif // COMMON_PROBE_H_
|
/*
* Copyright 2010-present Facebook.
*
* 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.
*/
extern const struct FBAdStarRating {
float value;
int scale;
} FBAdStarRating;
@interface FBAdImage : NSObject
@property (nonatomic, copy, readonly) NSURL *url;
@property (nonatomic, assign, readonly) int width;
@property (nonatomic, assign, readonly) int height;
- (id)initWithURL:(NSURL *)url width:(int)width height:(int)height;
@end
|
#ifndef UTIL_H
#define UTIL_H
#include <dirent.h>
#include <pcre.h>
#include <stdio.h>
#include <string.h>
#include <stdio.h>
#include <sys/time.h>
#include "config.h"
#include "log.h"
#include "options.h"
extern FILE *out_fd;
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
void *ag_malloc(size_t size);
void *ag_realloc(void *ptr, size_t size);
void *ag_calloc(size_t nelem, size_t elsize);
char *ag_strdup(const char *s);
char *ag_strndup(const char *s, size_t size);
typedef struct {
size_t start; /* Byte at which the match starts */
size_t end; /* and where it ends */
} match_t;
typedef struct {
long total_bytes;
long total_files;
long total_matches;
struct timeval time_start;
struct timeval time_end;
} ag_stats;
typedef enum {
AG_NO_COMPRESSION,
AG_GZIP,
AG_COMPRESS,
AG_ZIP
} ag_compression_type;
extern ag_stats stats;
typedef const char *(*strncmp_fp)(const char *, const char *, const size_t, const size_t, const size_t[], const size_t *);
void free_strings(char **strs, const size_t strs_len);
void generate_alpha_skip(const char *find, size_t f_len, size_t skip_lookup[], const int case_sensitive);
int is_prefix(const char *s, const size_t s_len, const size_t pos, const int case_sensitive);
size_t suffix_len(const char *s, const size_t s_len, const size_t pos, const int case_sensitive);
void generate_find_skip(const char *find, const size_t f_len, size_t **skip_lookup, const int case_sensitive);
/* max is already defined on spec-violating compilers such as MinGW */
size_t ag_max(size_t a, size_t b);
const char *boyer_moore_strnstr(const char *s, const char *find, const size_t s_len, const size_t f_len,
const size_t alpha_skip_lookup[], const size_t *find_skip_lookup);
const char *boyer_moore_strncasestr(const char *s, const char *find, const size_t s_len, const size_t f_len,
const size_t alpha_skip_lookup[], const size_t *find_skip_lookup);
strncmp_fp get_strstr(enum case_behavior opts);
size_t invert_matches(const char *buf, const size_t buf_len, match_t matches[], size_t matches_len);
void compile_study(pcre **re, pcre_extra **re_extra, char *q, const int pcre_opts, const int study_opts);
void *decompress(const ag_compression_type zip_type, const void *buf, const int buf_len, const char *dir_full_path, int *new_buf_len);
ag_compression_type is_zipped(const void *buf, const int buf_len);
int is_binary(const char *buf, const size_t buf_len);
int is_regex(const char *query);
int is_fnmatch(const char *filename);
int binary_search(const char *needle, char **haystack, int start, int end);
void init_wordchar_table(void);
int is_wordchar(char ch);
int is_lowercase(const char *s);
int is_directory(const char *path, const struct dirent *d);
int is_symlink(const char *path, const struct dirent *d);
int is_named_pipe(const char *path, const struct dirent *d);
void die(const char *fmt, ...);
void ag_asprintf(char **ret, const char *fmt, ...);
#ifndef HAVE_FGETLN
char *fgetln(FILE *fp, size_t *lenp);
#endif
#ifndef HAVE_GETLINE
ssize_t getline(char **lineptr, size_t *n, FILE *stream);
#endif
#ifndef HAVE_REALPATH
char *realpath(const char *path, char *resolved_path);
#endif
#ifndef HAVE_STRLCPY
size_t strlcpy(char *dest, const char *src, size_t size);
#endif
#ifndef HAVE_VASPRINTF
int vasprintf(char **ret, const char *fmt, va_list args);
#endif
#endif
|
//===-- ucmpti2_test.c - Test __ucmpti2 -----------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file tests __ucmpti2 for the compiler_rt library.
//
//===----------------------------------------------------------------------===//
#include "int_lib.h"
#include <stdio.h>
#ifdef CRT_HAS_128BIT
// Returns: if (a < b) returns 0
// if (a == b) returns 1
// if (a > b) returns 2
si_int __ucmpti2(tu_int a, tu_int b);
int test__ucmpti2(tu_int a, tu_int b, si_int expected)
{
si_int x = __ucmpti2(a, b);
if (x != expected)
{
utwords at;
at.all = a;
utwords bt;
bt.all = b;
printf("error in __ucmpti2(0x%.16llX%.16llX, 0x%.16llX%.16llX) = %d, "
"expected %d\n",
at.s.high, at.s.low, bt.s.high, bt.s.low, x, expected);
}
return x != expected;
}
#endif
int main()
{
#ifdef CRT_HAS_128BIT
if (test__ucmpti2(0, 0, 1))
return 1;
if (test__ucmpti2(1, 1, 1))
return 1;
if (test__ucmpti2(2, 2, 1))
return 1;
if (test__ucmpti2(0x7FFFFFFF, 0x7FFFFFFF, 1))
return 1;
if (test__ucmpti2(0x80000000, 0x80000000, 1))
return 1;
if (test__ucmpti2(0x80000001, 0x80000001, 1))
return 1;
if (test__ucmpti2(0xFFFFFFFF, 0xFFFFFFFF, 1))
return 1;
if (test__ucmpti2(0x000000010000000LL, 0x000000010000000LL, 1))
return 1;
if (test__ucmpti2(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL, 1))
return 1;
if (test__ucmpti2(0x0000000200000002LL, 0x0000000300000001LL, 0))
return 1;
if (test__ucmpti2(0x0000000200000002LL, 0x0000000300000002LL, 0))
return 1;
if (test__ucmpti2(0x0000000200000002LL, 0x0000000300000003LL, 0))
return 1;
if (test__ucmpti2(0x0000000200000002LL, 0x0000000100000001LL, 2))
return 1;
if (test__ucmpti2(0x0000000200000002LL, 0x0000000100000002LL, 2))
return 1;
if (test__ucmpti2(0x0000000200000002LL, 0x0000000100000003LL, 2))
return 1;
if (test__ucmpti2(0x0000000200000002LL, 0x0000000200000001LL, 2))
return 1;
if (test__ucmpti2(0x0000000200000002LL, 0x0000000200000002LL, 1))
return 1;
if (test__ucmpti2(0x0000000200000002LL, 0x0000000200000003LL, 0))
return 1;
if (test__ucmpti2(make_tu(0x0000000000000001uLL, 0x0000000000000000uLL),
make_tu(0x0000000000000000uLL, 0xFFFFFFFFFFFFFFFFuLL), 2))
return 1;
if (test__ucmpti2(make_tu(0x0000000000000001uLL, 0x0000000000000000uLL),
make_tu(0x0000000000000001uLL, 0x0000000000000000uLL), 1))
return 1;
if (test__ucmpti2(make_tu(0x0000000000000001uLL, 0x0000000000000000uLL),
make_tu(0x0000000000000001uLL, 0x0000000000000001uLL), 0))
return 1;
if (test__ucmpti2(make_tu(0x8000000000000000uLL, 0x0000000000000000uLL),
make_tu(0x7FFFFFFFFFFFFFFFuLL, 0xFFFFFFFFFFFFFFFFuLL), 2))
return 1;
if (test__ucmpti2(make_tu(0x8000000000000000uLL, 0x0000000000000000uLL),
make_tu(0x8000000000000000uLL, 0x0000000000000000uLL), 1))
return 1;
if (test__ucmpti2(make_tu(0x8000000000000000uLL, 0x0000000000000000uLL),
make_tu(0x8000000000000000uLL, 0x0000000000000001uLL), 0))
return 1;
if (test__ucmpti2(make_tu(0xFFFFFFFFFFFFFFFFuLL, 0xFFFFFFFFFFFFFFFFuLL),
make_tu(0xFFFFFFFFFFFFFFFFuLL, 0xFFFFFFFFFFFFFFFEuLL), 2))
return 1;
if (test__ucmpti2(make_tu(0xFFFFFFFFFFFFFFFFuLL, 0xFFFFFFFFFFFFFFFFuLL),
make_tu(0xFFFFFFFFFFFFFFFFuLL, 0xFFFFFFFFFFFFFFFFuLL), 1))
return 1;
#else
printf("skipped\n");
#endif
return 0;
}
|
//===----------------------------------------------------------------------===//
//
// Peloton
//
// op_expression.h
//
// Identification: src/include/optimizer/op_expression.h
//
// Copyright (c) 2015-16, Carnegie Mellon University Database Group
//
//===----------------------------------------------------------------------===//
#pragma once
#include "optimizer/operator_node.h"
#include "optimizer/group.h"
#include <vector>
#include <memory>
namespace peloton {
namespace optimizer {
//===--------------------------------------------------------------------===//
// Operator Expr
//===--------------------------------------------------------------------===//
class OpExpressionVisitor;
class OpExpression {
public:
OpExpression(Operator op);
void PushChild(std::shared_ptr<OpExpression> op);
void PopChild();
const std::vector<std::shared_ptr<OpExpression>> &Children() const;
const Operator &Op() const;
private:
Operator op;
std::vector<std::shared_ptr<OpExpression>> children;
};
} /* namespace optimizer */
} /* namespace peloton */
|
/*-
* Copyright (c) 2006 Verdens Gang AS
* Copyright (c) 2006-2011 Varnish Software AS
* All rights reserved.
*
* Author: Poul-Henning Kamp <phk@phk.freebsd.dk>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* XXX: charge bytes to srcaddr
*/
#include "config.h"
#include <poll.h>
#include <stdio.h>
#include "cache.h"
#include "cache_backend.h"
#include "vtcp.h"
#include "vtim.h"
static struct lock pipestat_mtx;
struct acct_pipe {
ssize_t req;
ssize_t bereq;
ssize_t in;
ssize_t out;
};
static int
rdf(int fd0, int fd1, ssize_t *pcnt)
{
int i, j;
char buf[BUFSIZ], *p;
i = read(fd0, buf, sizeof buf);
if (i <= 0)
return (1);
for (p = buf; i > 0; i -= j, p += j) {
j = write(fd1, p, i);
if (j <= 0)
return (1);
*pcnt += j;
if (i != j)
(void)usleep(100000); /* XXX hack */
}
return (0);
}
static void
pipecharge(struct req *req, const struct acct_pipe *a, struct VSC_C_vbe *b)
{
VSLb(req->vsl, SLT_PipeAcct, "%ju %ju %ju %ju",
(uintmax_t)a->req,
(uintmax_t)a->bereq,
(uintmax_t)a->in,
(uintmax_t)a->out);
Lck_Lock(&pipestat_mtx);
VSC_C_main->s_pipe_hdrbytes += a->req;
VSC_C_main->s_pipe_in += a->in;
VSC_C_main->s_pipe_out += a->out;
if (b != NULL) {
b->pipe_hdrbytes += a->bereq;
b->pipe_out += a->in;
b->pipe_in += a->out;
}
Lck_Unlock(&pipestat_mtx);
}
void
PipeRequest(struct req *req, struct busyobj *bo)
{
struct vbc *vc;
struct worker *wrk;
struct pollfd fds[2];
int i;
struct acct_pipe acct_pipe;
ssize_t hdrbytes;
CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
CHECK_OBJ_NOTNULL(req->sp, SESS_MAGIC);
wrk = req->wrk;
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
req->res_mode = RES_PIPE;
memset(&acct_pipe, 0, sizeof acct_pipe);
acct_pipe.req = req->acct.req_hdrbytes;
req->acct.req_hdrbytes = 0;
vc = VDI_GetFd(bo);
if (vc == NULL) {
VSLb(bo->vsl, SLT_FetchError, "no backend connection");
pipecharge(req, &acct_pipe, NULL);
SES_Close(req->sp, SC_OVERLOAD);
return;
}
bo->vbc = vc; /* For panic dumping */
(void)VTCP_blocking(vc->fd);
WRW_Reserve(wrk, &vc->fd, bo->vsl, req->t_req);
hdrbytes = HTTP1_Write(wrk, bo->bereq, 0);
if (req->htc->pipeline.b != NULL)
(void)WRW_Write(wrk, req->htc->pipeline.b,
Tlen(req->htc->pipeline));
i = WRW_FlushRelease(wrk, &acct_pipe.bereq);
if (acct_pipe.bereq > hdrbytes) {
acct_pipe.in = acct_pipe.bereq - hdrbytes;
acct_pipe.bereq = hdrbytes;
}
VSLb_ts_req(req, "Pipe", W_TIM_real(wrk));
if (i) {
pipecharge(req, &acct_pipe, vc->backend->vsc);
SES_Close(req->sp, SC_TX_PIPE);
VDI_CloseFd(&vc, NULL);
return;
}
memset(fds, 0, sizeof fds);
// XXX: not yet (void)VTCP_linger(vc->fd, 0);
fds[0].fd = vc->fd;
fds[0].events = POLLIN | POLLERR;
// XXX: not yet (void)VTCP_linger(req->sp->fd, 0);
fds[1].fd = req->sp->fd;
fds[1].events = POLLIN | POLLERR;
while (fds[0].fd > -1 || fds[1].fd > -1) {
fds[0].revents = 0;
fds[1].revents = 0;
i = poll(fds, 2, (int)(cache_param->pipe_timeout * 1e3));
if (i < 1)
break;
if (fds[0].revents &&
rdf(vc->fd, req->sp->fd, &acct_pipe.out)) {
if (fds[1].fd == -1)
break;
(void)shutdown(vc->fd, SHUT_RD);
(void)shutdown(req->sp->fd, SHUT_WR);
fds[0].events = 0;
fds[0].fd = -1;
}
if (fds[1].revents &&
rdf(req->sp->fd, vc->fd, &acct_pipe.in)) {
if (fds[0].fd == -1)
break;
(void)shutdown(req->sp->fd, SHUT_RD);
(void)shutdown(vc->fd, SHUT_WR);
fds[1].events = 0;
fds[1].fd = -1;
}
}
VSLb_ts_req(req, "PipeSess", W_TIM_real(wrk));
pipecharge(req, &acct_pipe, vc->backend->vsc);
SES_Close(req->sp, SC_TX_PIPE);
VDI_CloseFd(&vc, NULL);
bo->vbc = NULL;
}
/*--------------------------------------------------------------------*/
void
Pipe_Init(void)
{
Lck_New(&pipestat_mtx, lck_pipestat);
}
|
/*
* lib-src/ansi/math/fabs.c
* ANSI/ISO 9899-1990, Section 7.5.6.2.
*
* double fabs(double x)
* Return the absolute value of x.
*
* Exceptions:
* EDOM NaN x is NaN
* none +Infinity x is [+-]Infinity
*/
#include "mathlib.h"
#if defined(__TCS__)
#include <ops/custom_ops.h>
#endif /* defined(__TCS__) */
double
fabs(double x)
{
#if defined(__TCS__)
return fabsval((float)x);
#else /* defined(__TCS__) */
#if defined(__IEEE_FP__)
if (_isNaN(x)) {
errno = EDOM;
return x; /* NaN: domain error, return NaN */
} else if (_isInfinity(x))
return _pInfinity; /* [+-]Infinity: no error, return +Infinity */
#endif /* defined(__IEEE_FP__) */
return (x < 0.0) ? -x : x;
#endif /* defined(__TCS__) */
}
|
/***********************license start************************************
* Copyright (c) 2005-2007 Cavium Networks (support@cavium.com). All rights
* reserved.
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
*
* * Neither the name of Cavium Networks nor the names of
* its contributors may be used to endorse or promote products
* derived from this software without specific prior written
* permission.
*
* TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS"
* AND WITH ALL FAULTS AND CAVIUM NETWORKS MAKES NO PROMISES, REPRESENTATIONS
* OR WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH
* RESPECT TO THE SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY
* REPRESENTATION OR DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT
* DEFECTS, AND CAVIUM SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY) WARRANTIES
* OF TITLE, MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR
* PURPOSE, LACK OF VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET
* POSSESSION OR CORRESPONDENCE TO DESCRIPTION. THE ENTIRE RISK ARISING OUT
* OF USE OR PERFORMANCE OF THE SOFTWARE LIES WITH YOU.
*
*
* For any questions regarding licensing please contact marketing@caviumnetworks.com
*
***********************license end**************************************/
/* $FreeBSD: release/9.1.0/sys/mips/cavium/octopcireg.h 213089 2010-09-24 00:14:24Z jmallett $ */
#ifndef _CAVIUM_OCTOPCIREG_H_
#define _CAVIUM_OCTOPCIREG_H_
/**
* This is the bit decoding used for the Octeon PCI controller addresses for config space
*/
typedef union
{
uint64_t u64;
uint64_t * u64_ptr;
uint32_t * u32_ptr;
uint16_t * u16_ptr;
uint8_t * u8_ptr;
struct
{
uint64_t upper : 2;
uint64_t reserved : 13;
uint64_t io : 1;
uint64_t did : 5;
uint64_t subdid : 3;
uint64_t reserved2 : 4;
uint64_t endian_swap : 2;
uint64_t reserved3 : 10;
uint64_t bus : 8;
uint64_t dev : 5;
uint64_t func : 3;
uint64_t reg : 8;
} s;
} octeon_pci_config_space_address_t;
typedef union
{
uint64_t u64;
uint32_t * u32_ptr;
uint16_t * u16_ptr;
uint8_t * u8_ptr;
struct
{
uint64_t upper : 2;
uint64_t reserved : 13;
uint64_t io : 1;
uint64_t did : 5;
uint64_t subdid : 3;
uint64_t reserved2 : 4;
uint64_t endian_swap : 2;
uint64_t res1 : 1;
uint64_t port : 1;
uint64_t addr : 32;
} s;
} octeon_pci_io_space_address_t;
#define CVMX_OCT_SUBDID_PCI_CFG 1
#define CVMX_OCT_SUBDID_PCI_IO 2
#define CVMX_OCT_SUBDID_PCI_MEM1 3
#define CVMX_OCT_SUBDID_PCI_MEM2 4
#define CVMX_OCT_SUBDID_PCI_MEM3 5
#define CVMX_OCT_SUBDID_PCI_MEM4 6
#define CVMX_OCT_PCI_IO_BASE 0x00004000
#define CVMX_OCT_PCI_IO_SIZE 0x08000000
#define CVMX_OCT_PCI_MEM1_BASE 0xf0000000
#define CVMX_OCT_PCI_MEM1_SIZE 0x0f000000
#endif /* !_CAVIUM_OCTOPCIREG_H_ */
|
/* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE124_Buffer_Underwrite__char_alloca_loop_18.c
Label Definition File: CWE124_Buffer_Underwrite.stack.label.xml
Template File: sources-sink-18.tmpl.c
*/
/*
* @description
* CWE: 124 Buffer Underwrite
* BadSource: Set data pointer to before the allocated memory buffer
* GoodSource: Set data pointer to the allocated memory buffer
* Sink: loop
* BadSink : Copy string to data using a loop
* Flow Variant: 18 Control flow: goto statements
*
* */
#include "std_testcase.h"
#include <wchar.h>
#ifndef OMITBAD
void CWE124_Buffer_Underwrite__char_alloca_loop_18_bad()
{
char * data;
char * dataBuffer = (char *)ALLOCA(100*sizeof(char));
memset(dataBuffer, 'A', 100-1);
dataBuffer[100-1] = '\0';
goto source;
source:
/* FLAW: Set data pointer to before the allocated memory buffer */
data = dataBuffer - 8;
{
size_t i;
char source[100];
memset(source, 'C', 100-1); /* fill with 'C's */
source[100-1] = '\0'; /* null terminate */
/* POTENTIAL FLAW: Possibly copying data to memory before the destination buffer */
for (i = 0; i < 100; i++)
{
data[i] = source[i];
}
/* Ensure the destination buffer is null terminated */
data[100-1] = '\0';
printLine(data);
}
}
#endif /* OMITBAD */
#ifndef OMITGOOD
/* goodG2B() - use goodsource and badsink by reversing the blocks on the goto statement */
static void goodG2B()
{
char * data;
char * dataBuffer = (char *)ALLOCA(100*sizeof(char));
memset(dataBuffer, 'A', 100-1);
dataBuffer[100-1] = '\0';
goto source;
source:
/* FIX: Set data pointer to the allocated memory buffer */
data = dataBuffer;
{
size_t i;
char source[100];
memset(source, 'C', 100-1); /* fill with 'C's */
source[100-1] = '\0'; /* null terminate */
/* POTENTIAL FLAW: Possibly copying data to memory before the destination buffer */
for (i = 0; i < 100; i++)
{
data[i] = source[i];
}
/* Ensure the destination buffer is null terminated */
data[100-1] = '\0';
printLine(data);
}
}
void CWE124_Buffer_Underwrite__char_alloca_loop_18_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()...");
CWE124_Buffer_Underwrite__char_alloca_loop_18_good();
printLine("Finished good()");
#endif /* OMITGOOD */
#ifndef OMITBAD
printLine("Calling bad()...");
CWE124_Buffer_Underwrite__char_alloca_loop_18_bad();
printLine("Finished bad()");
#endif /* OMITBAD */
return 0;
}
#endif
|
/* Copyright (c) 2012 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 <ctype.h>
#include <string.h>
#include "util.h"
#include "libsyscalls.h"
/*
* These are syscalls used by the syslog() C library call. You can find them
* by running a simple test program. See below for x86_64 behavior:
* $ cat test.c
* main() { syslog(0, "foo"); }
* $ gcc test.c -static
* $ strace ./a.out
* ...
* socket(PF_FILE, SOCK_DGRAM|SOCK_CLOEXEC, 0) = 3 <- look for socket connection
* connect(...) <- important
* sendto(...) <- important
* exit_group(0) <- finish!
*/
#if defined(__x86_64__)
const char *log_syscalls[] = { "connect", "sendto" };
#elif defined(__i386__)
const char *log_syscalls[] = { "socketcall", "time" };
#elif defined(__arm__)
const char *log_syscalls[] = { "connect", "gettimeofday", "send" };
#elif defined(__powerpc__) || defined(__ia64__) || defined(__hppa__) || \
defined(__sparc__) || defined(__mips__)
const char *log_syscalls[] = { "connect", "send" };
#else
#error "Unsupported platform"
#endif
const size_t log_syscalls_len = sizeof(log_syscalls)/sizeof(log_syscalls[0]);
int lookup_syscall(const char *name)
{
const struct syscall_entry *entry = syscall_table;
for (; entry->name && entry->nr >= 0; ++entry)
if (!strcmp(entry->name, name))
return entry->nr;
return -1;
}
const char *lookup_syscall_name(int nr)
{
const struct syscall_entry *entry = syscall_table;
for (; entry->name && entry->nr >= 0; ++entry)
if (entry->nr == nr)
return entry->name;
return NULL;
}
char *strip(char *s)
{
char *end;
while (*s && isblank(*s))
s++;
end = s + strlen(s) - 1;
while (end >= s && *end && (isblank(*end) || *end == '\n'))
end--;
*(end + 1) = '\0';
return s;
}
char *tokenize(char **stringp, const char *delim)
{
char *ret = NULL;
/* If the string is NULL or empty, there are no tokens to be found. */
if (stringp == NULL || *stringp == NULL || **stringp == '\0')
return NULL;
/*
* If the delimiter is NULL or empty,
* the full string makes up the only token.
*/
if (delim == NULL || *delim == '\0') {
ret = *stringp;
*stringp = NULL;
return ret;
}
char *found;
while (**stringp != '\0') {
found = strstr(*stringp, delim);
if (!found) {
/*
* The delimiter was not found, so the full string
* makes up the only token, and we're done.
*/
ret = *stringp;
*stringp = NULL;
break;
}
if (found != *stringp) {
/* There's a non-empty token before the delimiter. */
*found = '\0';
ret = *stringp;
*stringp = found + strlen(delim);
break;
}
/*
* The delimiter was found at the start of the string,
* skip it and keep looking for a non-empty token.
*/
*stringp += strlen(delim);
}
return ret;
}
|
/***********************************************************************/
/* */
/* OCaml */
/* */
/* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
/* */
/* Copyright 1996 Institut National de Recherche en Informatique et */
/* en Automatique. All rights reserved. This file is distributed */
/* under the terms of the GNU Library General Public License, with */
/* the special exception on linking described in file ../../LICENSE. */
/* */
/***********************************************************************/
#include <string.h>
#include <mlvalues.h>
#include <alloc.h>
#include <fail.h>
#include <memory.h>
#include <signals.h>
#include "unixsupport.h"
#ifdef HAS_SOCKETS
#include "socketaddr.h"
#ifndef _WIN32
#include <sys/types.h>
#include <netdb.h>
#endif
#define NETDB_BUFFER_SIZE 10000
#ifdef _WIN32
#define GETHOSTBYADDR_IS_REENTRANT 1
#define GETHOSTBYNAME_IS_REENTRANT 1
#endif
static int entry_h_length;
extern int socket_domain_table[];
static value alloc_one_addr(char const *a)
{
struct in_addr addr;
#ifdef HAS_IPV6
struct in6_addr addr6;
if (entry_h_length == 16) {
memmove(&addr6, a, 16);
return alloc_inet6_addr(&addr6);
}
#endif
memmove (&addr, a, 4);
return alloc_inet_addr(&addr);
}
static value alloc_host_entry(struct hostent *entry)
{
value res;
value name = Val_unit, aliases = Val_unit;
value addr_list = Val_unit, adr = Val_unit;
Begin_roots4 (name, aliases, addr_list, adr);
name = copy_string((char *)(entry->h_name));
/* PR#4043: protect against buggy implementations of gethostbyname()
that return a NULL pointer in h_aliases */
if (entry->h_aliases)
aliases = copy_string_array((const char**)entry->h_aliases);
else
aliases = Atom(0);
entry_h_length = entry->h_length;
#ifdef h_addr
addr_list = alloc_array(alloc_one_addr, (const char**)entry->h_addr_list);
#else
adr = alloc_one_addr(entry->h_addr);
addr_list = alloc_small(1, 0);
Field(addr_list, 0) = adr;
#endif
res = alloc_small(4, 0);
Field(res, 0) = name;
Field(res, 1) = aliases;
switch (entry->h_addrtype) {
case PF_UNIX: Field(res, 2) = Val_int(0); break;
case PF_INET: Field(res, 2) = Val_int(1); break;
default: /*PF_INET6 */ Field(res, 2) = Val_int(2); break;
}
Field(res, 3) = addr_list;
End_roots();
return res;
}
CAMLprim value unix_gethostbyaddr(value a)
{
struct in_addr adr = GET_INET_ADDR(a);
struct hostent * hp;
#if HAS_GETHOSTBYADDR_R == 7
struct hostent h;
char buffer[NETDB_BUFFER_SIZE];
int h_errnop;
enter_blocking_section();
hp = gethostbyaddr_r((char *) &adr, 4, AF_INET,
&h, buffer, sizeof(buffer), &h_errnop);
leave_blocking_section();
#elif HAS_GETHOSTBYADDR_R == 8
struct hostent h;
char buffer[NETDB_BUFFER_SIZE];
int h_errnop, rc;
enter_blocking_section();
rc = gethostbyaddr_r((char *) &adr, 4, AF_INET,
&h, buffer, sizeof(buffer), &hp, &h_errnop);
leave_blocking_section();
if (rc != 0) hp = NULL;
#else
#ifdef GETHOSTBYADDR_IS_REENTRANT
enter_blocking_section();
#endif
hp = gethostbyaddr((char *) &adr, 4, AF_INET);
#ifdef GETHOSTBYADDR_IS_REENTRANT
leave_blocking_section();
#endif
#endif
if (hp == (struct hostent *) NULL) raise_not_found();
return alloc_host_entry(hp);
}
CAMLprim value unix_gethostbyname(value name)
{
struct hostent * hp;
char * hostname;
#if HAS_GETHOSTBYNAME_R || GETHOSTBYNAME_IS_REENTRANT
hostname = caml_strdup(String_val(name));
#else
hostname = String_val(name);
#endif
#if HAS_GETHOSTBYNAME_R == 5
{
struct hostent h;
char buffer[NETDB_BUFFER_SIZE];
int h_errno;
enter_blocking_section();
hp = gethostbyname_r(hostname, &h, buffer, sizeof(buffer), &h_errno);
leave_blocking_section();
}
#elif HAS_GETHOSTBYNAME_R == 6
{
struct hostent h;
char buffer[NETDB_BUFFER_SIZE];
int h_errno, rc;
enter_blocking_section();
rc = gethostbyname_r(hostname, &h, buffer, sizeof(buffer), &hp, &h_errno);
leave_blocking_section();
if (rc != 0) hp = NULL;
}
#else
#ifdef GETHOSTBYNAME_IS_REENTRANT
enter_blocking_section();
#endif
hp = gethostbyname(hostname);
#ifdef GETHOSTBYNAME_IS_REENTRANT
leave_blocking_section();
#endif
#endif
#if HAS_GETHOSTBYNAME_R || GETHOSTBYNAME_IS_REENTRANT
stat_free(hostname);
#endif
if (hp == (struct hostent *) NULL) raise_not_found();
return alloc_host_entry(hp);
}
#else
CAMLprim value unix_gethostbyaddr(value name)
{ invalid_argument("gethostbyaddr not implemented"); }
CAMLprim value unix_gethostbyname(value name)
{ invalid_argument("gethostbyname not implemented"); }
#endif
|
// =============================================================================
// PROJECT CHRONO - http://projectchrono.org
//
// Copyright (c) 2014 projectchrono.org
// All rights reserved.
//
// Use of this source code is governed by a BSD-style license that can be found
// in the LICENSE file at the top level of the distribution and at
// http://projectchrono.org/license-chrono.txt.
//
// =============================================================================
// Authors: Radu Serban, Holger Haut
// =============================================================================
//
// Hendrickson PRIMAXX suspension constructed with data from file.
//
// =============================================================================
#ifndef HENDRICKSON_PRIMAXX_H
#define HENDRICKSON_PRIMAXX_H
#include "chrono_vehicle/ChApiVehicle.h"
#include "chrono_vehicle/wheeled_vehicle/suspension/ChHendricksonPRIMAXX.h"
#include "chrono_thirdparty/rapidjson/document.h"
namespace chrono {
namespace vehicle {
/// @addtogroup vehicle_wheeled_suspension
/// @{
/// Hendrickson PRIMAXX suspension constructed with data from file.
class CH_VEHICLE_API HendricksonPRIMAXX : public ChHendricksonPRIMAXX {
public:
HendricksonPRIMAXX(const std::string& filename);
HendricksonPRIMAXX(const rapidjson::Document& d);
~HendricksonPRIMAXX();
virtual double getSpindleMass() const override { return m_spindleMass; }
virtual double getSpindleRadius() const override { return m_spindleRadius; }
virtual double getSpindleWidth() const override { return m_spindleWidth; }
virtual const ChVector<>& getSpindleInertia() const override { return m_spindleInertia; }
virtual double getAxleInertia() const override { return m_axleInertia; }
private:
virtual const ChVector<> getLocation(PointId which) override { return m_points[which]; }
void Create(const rapidjson::Document& d);
ChVector<> m_points[NUM_POINTS];
double m_spindleMass;
double m_spindleRadius;
double m_spindleWidth;
ChVector<> m_spindleInertia;
double m_axleInertia;
};
/// @} vehicle_wheeled_suspension
} // end namespace vehicle
} // end namespace chrono
#endif
|
/*===================================================================
The Medical Imaging Interaction Toolkit (MITK)
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#ifndef QMITKXNATCREATEOBJECTDIALOG_H
#define QMITKXNATCREATEOBJECTDIALOG_H
#include <MitkXNATExports.h>
// Qt
#include <QDialog>
#include <QWidget>
class ctkXnatObject;
class MITKXNAT_EXPORT QmitkXnatCreateObjectDialog : public QDialog
{
Q_OBJECT
public:
enum SpecificType
{
//PROJECT,
SUBJECT,
EXPERIMENT
};
QmitkXnatCreateObjectDialog(SpecificType type, QWidget* parent = 0);
virtual ~QmitkXnatCreateObjectDialog();
// Returns a specific xnat object like SpecificType
ctkXnatObject* GetXnatObject();
protected slots:
void OnAcceptClicked();
void OnCancelClicked();
private:
SpecificType m_Type;
ctkXnatObject* m_Object;
QWidget* m_Widget;
};
#endif // QMITKXNATCREATEOBJECTDIALOG_H
|
/* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE127_Buffer_Underread__wchar_t_declare_ncpy_67b.c
Label Definition File: CWE127_Buffer_Underread.stack.label.xml
Template File: sources-sink-67b.tmpl.c
*/
/*
* @description
* CWE: 127 Buffer Under-read
* BadSource: Set data pointer to before the allocated memory buffer
* GoodSource: Set data pointer to the allocated memory buffer
* Sinks: ncpy
* BadSink : Copy data to string using wcsncpy
* Flow Variant: 67 Data flow: data passed in a struct from one function to another in different source files
*
* */
#include "std_testcase.h"
#include <wchar.h>
typedef struct _CWE127_Buffer_Underread__wchar_t_declare_ncpy_67_structType
{
wchar_t * structFirst;
} CWE127_Buffer_Underread__wchar_t_declare_ncpy_67_structType;
#ifndef OMITBAD
void CWE127_Buffer_Underread__wchar_t_declare_ncpy_67b_badSink(CWE127_Buffer_Underread__wchar_t_declare_ncpy_67_structType myStruct)
{
wchar_t * data = myStruct.structFirst;
{
wchar_t dest[100];
wmemset(dest, L'C', 100-1); /* fill with 'C's */
dest[100-1] = L'\0'; /* null terminate */
/* POTENTIAL FLAW: Possibly copy from a memory location located before the source buffer */
wcsncpy(dest, data, wcslen(dest));
/* Ensure null termination */
dest[100-1] = L'\0';
printWLine(dest);
}
}
#endif /* OMITBAD */
#ifndef OMITGOOD
/* goodG2B uses the GoodSource with the BadSink */
void CWE127_Buffer_Underread__wchar_t_declare_ncpy_67b_goodG2BSink(CWE127_Buffer_Underread__wchar_t_declare_ncpy_67_structType myStruct)
{
wchar_t * data = myStruct.structFirst;
{
wchar_t dest[100];
wmemset(dest, L'C', 100-1); /* fill with 'C's */
dest[100-1] = L'\0'; /* null terminate */
/* POTENTIAL FLAW: Possibly copy from a memory location located before the source buffer */
wcsncpy(dest, data, wcslen(dest));
/* Ensure null termination */
dest[100-1] = L'\0';
printWLine(dest);
}
}
#endif /* OMITGOOD */
|
/* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE127_Buffer_Underread__char_alloca_memcpy_53d.c
Label Definition File: CWE127_Buffer_Underread.stack.label.xml
Template File: sources-sink-53d.tmpl.c
*/
/*
* @description
* CWE: 127 Buffer Under-read
* BadSource: Set data pointer to before the allocated memory buffer
* GoodSource: Set data pointer to the allocated memory buffer
* Sink: memcpy
* BadSink : Copy data to string using memcpy
* Flow Variant: 53 Data flow: data passed as an argument from one function through two others to a fourth; all four functions are in different source files
*
* */
#include "std_testcase.h"
#include <wchar.h>
/* all the sinks are the same, we just want to know where the hit originated if a tool flags one */
#ifndef OMITBAD
void CWE127_Buffer_Underread__char_alloca_memcpy_53d_badSink(char * data)
{
{
char dest[100];
memset(dest, 'C', 100-1); /* fill with 'C's */
dest[100-1] = '\0'; /* null terminate */
/* POTENTIAL FLAW: Possibly copy from a memory location located before the source buffer */
memcpy(dest, data, 100*sizeof(char));
/* Ensure null termination */
dest[100-1] = '\0';
printLine(dest);
}
}
#endif /* OMITBAD */
#ifndef OMITGOOD
/* goodG2B uses the GoodSource with the BadSink */
void CWE127_Buffer_Underread__char_alloca_memcpy_53d_goodG2BSink(char * data)
{
{
char dest[100];
memset(dest, 'C', 100-1); /* fill with 'C's */
dest[100-1] = '\0'; /* null terminate */
/* POTENTIAL FLAW: Possibly copy from a memory location located before the source buffer */
memcpy(dest, data, 100*sizeof(char));
/* Ensure null termination */
dest[100-1] = '\0';
printLine(dest);
}
}
#endif /* OMITGOOD */
|
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef EXTENSIONS_BROWSER_EXTENSION_SYSTEM_H_
#define EXTENSIONS_BROWSER_EXTENSION_SYSTEM_H_
#include <string>
#include "base/callback_forward.h"
#include "base/memory/ref_counted.h"
#include "components/keyed_service/core/keyed_service.h"
#include "extensions/common/extension.h"
#if !defined(ENABLE_EXTENSIONS)
#error "Extensions must be enabled"
#endif
class ExtensionService;
#if defined(OS_CHROMEOS)
namespace chromeos {
class DeviceLocalAccountManagementPolicyProvider;
}
#endif // defined(OS_CHROMEOS)
namespace content {
class BrowserContext;
}
namespace extensions {
class AppSorting;
class ContentVerifier;
class Extension;
class ExtensionSet;
class InfoMap;
class ManagementPolicy;
class OneShotEvent;
class QuotaService;
class RuntimeData;
class ServiceWorkerManager;
class SharedUserScriptMaster;
class StateStore;
// ExtensionSystem manages the lifetime of many of the services used by the
// extensions and apps system, and it handles startup and shutdown as needed.
// Eventually, we'd like to make more of these services into KeyedServices in
// their own right.
class ExtensionSystem : public KeyedService {
public:
ExtensionSystem();
~ExtensionSystem() override;
// Returns the instance for the given browser context, or NULL if none.
static ExtensionSystem* Get(content::BrowserContext* context);
// Initializes extensions machinery.
// Component extensions are always enabled, external and user extensions are
// controlled by |extensions_enabled|.
virtual void InitForRegularProfile(bool extensions_enabled) = 0;
// The ExtensionService is created at startup.
virtual ExtensionService* extension_service() = 0;
// Per-extension data that can change during the life of the process but
// does not persist across restarts. Lives on UI thread. Created at startup.
virtual RuntimeData* runtime_data() = 0;
// The class controlling whether users are permitted to perform certain
// actions on extensions (install, uninstall, disable, etc.).
// The ManagementPolicy is created at startup.
virtual ManagementPolicy* management_policy() = 0;
// The ServiceWorkerManager is created at startup.
virtual ServiceWorkerManager* service_worker_manager() = 0;
// The SharedUserScriptMaster is created at startup.
virtual SharedUserScriptMaster* shared_user_script_master() = 0;
// The StateStore is created at startup.
virtual StateStore* state_store() = 0;
// The rules store is created at startup.
virtual StateStore* rules_store() = 0;
// Returns the IO-thread-accessible extension data.
virtual InfoMap* info_map() = 0;
// Returns the QuotaService that limits calls to certain extension functions.
// Lives on the UI thread. Created at startup.
virtual QuotaService* quota_service() = 0;
// Returns the AppSorting which provides an ordering for all installed apps.
virtual AppSorting* app_sorting() = 0;
// Called by the ExtensionService that lives in this system. Gives the
// info map a chance to react to the load event before the EXTENSION_LOADED
// notification has fired. The purpose for handling this event first is to
// avoid race conditions by making sure URLRequestContexts learn about new
// extensions before anything else needs them to know. This operation happens
// asynchronously. |callback| is run on the calling thread once completed.
virtual void RegisterExtensionWithRequestContexts(
const Extension* extension,
const base::Closure& callback) {}
// Called by the ExtensionService that lives in this system. Lets the
// info map clean up its RequestContexts once all the listeners to the
// EXTENSION_UNLOADED notification have finished running.
virtual void UnregisterExtensionWithRequestContexts(
const std::string& extension_id,
const UnloadedExtensionInfo::Reason reason) {}
// Signaled when the extension system has completed its startup tasks.
virtual const OneShotEvent& ready() const = 0;
// Returns the content verifier, if any.
virtual ContentVerifier* content_verifier() = 0;
// Get a set of extensions that depend on the given extension.
// TODO(elijahtaylor): Move SharedModuleService out of chrome/browser
// so it can be retrieved from ExtensionSystem directly.
virtual scoped_ptr<ExtensionSet> GetDependentExtensions(
const Extension* extension) = 0;
// Install an updated version of |extension_id| with the version given in
// temp_dir. Ownership of |temp_dir| in the filesystem is transferred and
// implementors of this function are responsible for cleaning it up on
// errors, etc.
virtual void InstallUpdate(const std::string& extension_id,
const base::FilePath& temp_dir) = 0;
};
} // namespace extensions
#endif // EXTENSIONS_BROWSER_EXTENSION_SYSTEM_H_
|
// Use of this source file is governed by a BSD-style
// license that can be found in the LICENSE file.`
#include "runtime.h"
#include "defs.h"
#include "os.h"
#include "stack.h"
extern SigTab runtime·sigtab[];
extern int64 runtime·rfork_thread(int32 flags, void *stack, M *m, G *g, void (*fn)(void));
extern void runtime·sys_sched_yield(void);
// Basic spinlocks using CAS. We can improve on these later.
static void
lock(Lock *l)
{
uint32 v;
int32 ret;
for(;;) {
if(runtime·cas(&l->key, 0, 1))
return;
runtime·sys_sched_yield();
}
}
static void
unlock(Lock *l)
{
uint32 v;
int32 ret;
for (;;) {
v = l->key;
if((v&1) == 0)
runtime·throw("unlock of unlocked lock");
if(runtime·cas(&l->key, v, 0))
break;
}
}
void
runtime·lock(Lock *l)
{
if(m->locks < 0)
runtime·throw("lock count");
m->locks++;
lock(l);
}
void
runtime·unlock(Lock *l)
{
m->locks--;
if(m->locks < 0)
runtime·throw("lock count");
unlock(l);
}
// Event notifications.
void
runtime·noteclear(Note *n)
{
n->lock.key = 0;
lock(&n->lock);
}
void
runtime·notesleep(Note *n)
{
lock(&n->lock);
unlock(&n->lock);
}
void
runtime·notewakeup(Note *n)
{
unlock(&n->lock);
}
// From OpenBSD's sys/param.h
#define RFPROC (1<<4) /* change child (else changes curproc) */
#define RFMEM (1<<5) /* share `address space' */
#define RFNOWAIT (1<<6) /* parent need not wait() on child */
#define RFTHREAD (1<<13) /* create a thread, not a process */
void
runtime·newosproc(M *m, G *g, void *stk, void (*fn)(void))
{
int32 flags;
int32 ret;
flags = RFPROC | RFTHREAD | RFMEM | RFNOWAIT;
if (0) {
runtime·printf(
"newosproc stk=%p m=%p g=%p fn=%p id=%d/%d ostk=%p\n",
stk, m, g, fn, m->id, m->tls[0], &m);
}
m->tls[0] = m->id; // so 386 asm can find it
if((ret = runtime·rfork_thread(flags, stk, m, g, fn)) < 0) {
runtime·printf("runtime: failed to create new OS thread (have %d already; errno=%d)\n", runtime·mcount() - 1, -ret);
runtime·printf("runtime: is kern.rthreads disabled?\n");
runtime·throw("runtime.newosproc");
}
}
void
runtime·osinit(void)
{
}
void
runtime·goenvs(void)
{
runtime·goenvs_unix();
}
// Called to initialize a new m (including the bootstrap m).
void
runtime·minit(void)
{
// Initialize signal handling
m->gsignal = runtime·malg(32*1024);
runtime·signalstack(m->gsignal->stackguard - StackGuard, 32*1024);
}
void
runtime·sigpanic(void)
{
switch(g->sig) {
case SIGBUS:
if(g->sigcode0 == BUS_ADRERR && g->sigcode1 < 0x1000)
runtime·panicstring("invalid memory address or nil pointer dereference");
runtime·printf("unexpected fault address %p\n", g->sigcode1);
runtime·throw("fault");
case SIGSEGV:
if((g->sigcode0 == 0 || g->sigcode0 == SEGV_MAPERR || g->sigcode0 == SEGV_ACCERR) && g->sigcode1 < 0x1000)
runtime·panicstring("invalid memory address or nil pointer dereference");
runtime·printf("unexpected fault address %p\n", g->sigcode1);
runtime·throw("fault");
case SIGFPE:
switch(g->sigcode0) {
case FPE_INTDIV:
runtime·panicstring("integer divide by zero");
case FPE_INTOVF:
runtime·panicstring("integer overflow");
}
runtime·panicstring("floating point error");
}
runtime·panicstring(runtime·sigtab[g->sig].name);
}
|
/*============================================================================
WCSLIB 5.16 - an implementation of the FITS WCS standard.
Copyright (C) 1995-2017, Mark Calabretta
This file is part of WCSLIB.
WCSLIB 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.
WCSLIB 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 WCSLIB. If not, see http://www.gnu.org/licenses.
Direct correspondence concerning WCSLIB to mark@calabretta.id.au
Author: Mark Calabretta, Australia Telescope National Facility, CSIRO.
http://www.atnf.csiro.au/people/Mark.Calabretta
$Id: getwcstab.c,v 5.16 2017/01/15 04:25:01 mcalabre Exp $
*===========================================================================*/
#include <stdlib.h>
#include <string.h>
#include <fitsio.h>
#include "getwcstab.h"
/*--------------------------------------------------------------------------*/
int fits_read_wcstab(
fitsfile *fptr,
int nwtb,
wtbarr *wtb,
int *status)
{
int anynul, colnum, hdunum, iwtb, m, naxis, nostat;
long *naxes = 0, nelem;
wtbarr *wtbp;
if (*status) return *status;
if (fptr == 0) {
return (*status = NULL_INPUT_PTR);
}
if (nwtb == 0) return 0;
/* Zero the array pointers. */
wtbp = wtb;
for (iwtb = 0; iwtb < nwtb; iwtb++, wtbp++) {
*wtbp->arrayp = 0x0;
}
/* Save HDU number so that we can move back to it later. */
fits_get_hdu_num(fptr, &hdunum);
wtbp = wtb;
for (iwtb = 0; iwtb < nwtb; iwtb++, wtbp++) {
/* Move to the required binary table extension. */
if (fits_movnam_hdu(fptr, BINARY_TBL, (char *)(wtbp->extnam),
wtbp->extver, status)) {
goto cleanup;
}
/* Locate the table column. */
if (fits_get_colnum(fptr, CASEINSEN, (char *)(wtbp->ttype), &colnum,
status)) {
goto cleanup;
}
/* Get the array dimensions and check for consistency. */
if (wtbp->ndim < 1) {
*status = NEG_AXIS;
goto cleanup;
}
if (!(naxes = calloc(wtbp->ndim, sizeof(long)))) {
*status = MEMORY_ALLOCATION;
goto cleanup;
}
if (fits_read_tdim(fptr, colnum, wtbp->ndim, &naxis, naxes, status)) {
goto cleanup;
}
if (naxis != wtbp->ndim) {
if (wtbp->kind == 'c' && wtbp->ndim == 2) {
/* Allow TDIMn to be omitted for degenerate coordinate arrays. */
naxis = 2;
naxes[1] = naxes[0];
naxes[0] = 1;
} else {
*status = BAD_TDIM;
goto cleanup;
}
}
if (wtbp->kind == 'c') {
/* Coordinate array; calculate the array size. */
nelem = naxes[0];
for (m = 0; m < naxis-1; m++) {
*(wtbp->dimlen + m) = naxes[m+1];
nelem *= naxes[m+1];
}
} else {
/* Index vector; check length. */
if ((nelem = naxes[0]) != *(wtbp->dimlen)) {
/* N.B. coordinate array precedes the index vectors. */
*status = BAD_TDIM;
goto cleanup;
}
}
free(naxes);
naxes = 0;
/* Allocate memory for the array. */
if (!(*wtbp->arrayp = calloc((size_t)nelem, sizeof(double)))) {
*status = MEMORY_ALLOCATION;
goto cleanup;
}
/* Read the array from the table. */
if (fits_read_col_dbl(fptr, colnum, wtbp->row, 1L, nelem, 0.0,
*wtbp->arrayp, &anynul, status)) {
goto cleanup;
}
}
cleanup:
/* Move back to the starting HDU. */
nostat = 0;
fits_movabs_hdu(fptr, hdunum, 0, &nostat);
/* Release allocated memory. */
if (naxes) free(naxes);
if (*status) {
wtbp = wtb;
for (iwtb = 0; iwtb < nwtb; iwtb++, wtbp++) {
if (*wtbp->arrayp) free(*wtbp->arrayp);
}
}
return *status;
}
|
/** Use return to exit a test case with a failed assertion. */
#define ACEUNIT_ASSERTION_STYLE ACEUNIT_ASSERTION_STYLE_RETURN
#define ACEUNIT_GROUP
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.